babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340
  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. * Moves the observable to the top of the observer list making it get called first when notified
  4354. * @param observer the observer to move
  4355. */
  4356. makeObserverTopPriority(observer: Observer<T>): void;
  4357. /**
  4358. * Moves the observable to the bottom of the observer list making it get called last when notified
  4359. * @param observer the observer to move
  4360. */
  4361. makeObserverBottomPriority(observer: Observer<T>): void;
  4362. /**
  4363. * Notify all Observers by calling their respective callback with the given data
  4364. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4365. * @param eventData defines the data to send to all observers
  4366. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4367. * @param target defines the original target of the state
  4368. * @param currentTarget defines the current target of the state
  4369. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4370. */
  4371. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4372. /**
  4373. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4374. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4375. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4376. * and it is crucial that all callbacks will be executed.
  4377. * The order of the callbacks is kept, callbacks are not executed parallel.
  4378. *
  4379. * @param eventData The data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. * @param target defines the callback target (see EventState)
  4382. * @param currentTarget defines he current object in the bubbling phase
  4383. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4384. */
  4385. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4386. /**
  4387. * Notify a specific observer
  4388. * @param observer defines the observer to notify
  4389. * @param eventData defines the data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. */
  4392. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4393. /**
  4394. * Gets a boolean indicating if the observable has at least one observer
  4395. * @returns true is the Observable has at least one Observer registered
  4396. */
  4397. hasObservers(): boolean;
  4398. /**
  4399. * Clear the list of observers
  4400. */
  4401. clear(): void;
  4402. /**
  4403. * Clone the current observable
  4404. * @returns a new observable
  4405. */
  4406. clone(): Observable<T>;
  4407. /**
  4408. * Does this observable handles observer registered with a given mask
  4409. * @param mask defines the mask to be tested
  4410. * @return whether or not one observer registered with the given mask is handeled
  4411. **/
  4412. hasSpecificMask(mask?: number): boolean;
  4413. }
  4414. }
  4415. declare module BABYLON {
  4416. /**
  4417. * Class used to help managing file picking and drag'n'drop
  4418. * File Storage
  4419. */
  4420. export class FilesInputStore {
  4421. /**
  4422. * List of files ready to be loaded
  4423. */
  4424. static FilesToLoad: {
  4425. [key: string]: File;
  4426. };
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. /** Defines the cross module used constants to avoid circular dependncies */
  4431. export class Constants {
  4432. /** Defines that alpha blending is disabled */
  4433. static readonly ALPHA_DISABLE: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4435. static readonly ALPHA_ADD: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_COMBINE: number;
  4438. /** Defines that alpha blending to DEST - SRC * DEST */
  4439. static readonly ALPHA_SUBTRACT: number;
  4440. /** Defines that alpha blending to SRC * DEST */
  4441. static readonly ALPHA_MULTIPLY: number;
  4442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4443. static readonly ALPHA_MAXIMIZED: number;
  4444. /** Defines that alpha blending to SRC + DEST */
  4445. static readonly ALPHA_ONEONE: number;
  4446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_PREMULTIPLIED: number;
  4448. /**
  4449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4451. */
  4452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4454. static readonly ALPHA_INTERPOLATE: number;
  4455. /**
  4456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4458. */
  4459. static readonly ALPHA_SCREENMODE: number;
  4460. /** Defines that the ressource is not delayed*/
  4461. static readonly DELAYLOADSTATE_NONE: number;
  4462. /** Defines that the ressource was successfully delay loaded */
  4463. static readonly DELAYLOADSTATE_LOADED: number;
  4464. /** Defines that the ressource is currently delay loading */
  4465. static readonly DELAYLOADSTATE_LOADING: number;
  4466. /** Defines that the ressource is delayed and has not started loading */
  4467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4469. static readonly NEVER: number;
  4470. /** 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 */
  4471. static readonly ALWAYS: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4473. static readonly LESS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4475. static readonly EQUAL: number;
  4476. /** 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 */
  4477. static readonly LEQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4479. static readonly GREATER: number;
  4480. /** 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 */
  4481. static readonly GEQUAL: number;
  4482. /** 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 */
  4483. static readonly NOTEQUAL: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be kept */
  4485. static readonly KEEP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4487. static readonly REPLACE: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4489. static readonly INCR: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4491. static readonly DECR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4493. static readonly INVERT: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4495. static readonly INCR_WRAP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4497. static readonly DECR_WRAP: number;
  4498. /** Texture is not repeating outside of 0..1 UVs */
  4499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4500. /** Texture is repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4502. /** Texture is repeating and mirrored */
  4503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4504. /** ALPHA */
  4505. static readonly TEXTUREFORMAT_ALPHA: number;
  4506. /** LUMINANCE */
  4507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4508. /** LUMINANCE_ALPHA */
  4509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4510. /** RGB */
  4511. static readonly TEXTUREFORMAT_RGB: number;
  4512. /** RGBA */
  4513. static readonly TEXTUREFORMAT_RGBA: number;
  4514. /** RED */
  4515. static readonly TEXTUREFORMAT_RED: number;
  4516. /** RED (2nd reference) */
  4517. static readonly TEXTUREFORMAT_R: number;
  4518. /** RG */
  4519. static readonly TEXTUREFORMAT_RG: number;
  4520. /** RED_INTEGER */
  4521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4522. /** RED_INTEGER (2nd reference) */
  4523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4524. /** RG_INTEGER */
  4525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4526. /** RGB_INTEGER */
  4527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4528. /** RGBA_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4530. /** UNSIGNED_BYTE */
  4531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4532. /** UNSIGNED_BYTE (2nd reference) */
  4533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4534. /** FLOAT */
  4535. static readonly TEXTURETYPE_FLOAT: number;
  4536. /** HALF_FLOAT */
  4537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4538. /** BYTE */
  4539. static readonly TEXTURETYPE_BYTE: number;
  4540. /** SHORT */
  4541. static readonly TEXTURETYPE_SHORT: number;
  4542. /** UNSIGNED_SHORT */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4544. /** INT */
  4545. static readonly TEXTURETYPE_INT: number;
  4546. /** UNSIGNED_INT */
  4547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4548. /** UNSIGNED_SHORT_4_4_4_4 */
  4549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4550. /** UNSIGNED_SHORT_5_5_5_1 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4552. /** UNSIGNED_SHORT_5_6_5 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4554. /** UNSIGNED_INT_2_10_10_10_REV */
  4555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4556. /** UNSIGNED_INT_24_8 */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4558. /** UNSIGNED_INT_10F_11F_11F_REV */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4560. /** UNSIGNED_INT_5_9_9_9_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4564. /** nearest is mag = nearest and min = nearest and mip = linear */
  4565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4568. /** Trilinear is mag = linear and min = linear and mip = linear */
  4569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4570. /** nearest is mag = nearest and min = nearest and mip = linear */
  4571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4574. /** Trilinear is mag = linear and min = linear and mip = linear */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4578. /** mag = nearest and min = linear and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = linear */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4582. /** mag = nearest and min = linear and mip = none */
  4583. static readonly TEXTURE_NEAREST_LINEAR: number;
  4584. /** mag = nearest and min = nearest and mip = none */
  4585. static readonly TEXTURE_NEAREST_NEAREST: number;
  4586. /** mag = linear and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4588. /** mag = linear and min = nearest and mip = linear */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4590. /** mag = linear and min = linear and mip = none */
  4591. static readonly TEXTURE_LINEAR_LINEAR: number;
  4592. /** mag = linear and min = nearest and mip = none */
  4593. static readonly TEXTURE_LINEAR_NEAREST: number;
  4594. /** Explicit coordinates mode */
  4595. static readonly TEXTURE_EXPLICIT_MODE: number;
  4596. /** Spherical coordinates mode */
  4597. static readonly TEXTURE_SPHERICAL_MODE: number;
  4598. /** Planar coordinates mode */
  4599. static readonly TEXTURE_PLANAR_MODE: number;
  4600. /** Cubic coordinates mode */
  4601. static readonly TEXTURE_CUBIC_MODE: number;
  4602. /** Projection coordinates mode */
  4603. static readonly TEXTURE_PROJECTION_MODE: number;
  4604. /** Skybox coordinates mode */
  4605. static readonly TEXTURE_SKYBOX_MODE: number;
  4606. /** Inverse Cubic coordinates mode */
  4607. static readonly TEXTURE_INVCUBIC_MODE: number;
  4608. /** Equirectangular coordinates mode */
  4609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4610. /** Equirectangular Fixed coordinates mode */
  4611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed Mirrored coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4615. static readonly SCALEMODE_FLOOR: number;
  4616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4617. static readonly SCALEMODE_NEAREST: number;
  4618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4619. static readonly SCALEMODE_CEILING: number;
  4620. /**
  4621. * The dirty texture flag value
  4622. */
  4623. static readonly MATERIAL_TextureDirtyFlag: number;
  4624. /**
  4625. * The dirty light flag value
  4626. */
  4627. static readonly MATERIAL_LightDirtyFlag: number;
  4628. /**
  4629. * The dirty fresnel flag value
  4630. */
  4631. static readonly MATERIAL_FresnelDirtyFlag: number;
  4632. /**
  4633. * The dirty attribute flag value
  4634. */
  4635. static readonly MATERIAL_AttributesDirtyFlag: number;
  4636. /**
  4637. * The dirty misc flag value
  4638. */
  4639. static readonly MATERIAL_MiscDirtyFlag: number;
  4640. /**
  4641. * The all dirty flag value
  4642. */
  4643. static readonly MATERIAL_AllDirtyFlag: number;
  4644. /**
  4645. * Returns the triangle fill mode
  4646. */
  4647. static readonly MATERIAL_TriangleFillMode: number;
  4648. /**
  4649. * Returns the wireframe mode
  4650. */
  4651. static readonly MATERIAL_WireFrameFillMode: number;
  4652. /**
  4653. * Returns the point fill mode
  4654. */
  4655. static readonly MATERIAL_PointFillMode: number;
  4656. /**
  4657. * Returns the point list draw mode
  4658. */
  4659. static readonly MATERIAL_PointListDrawMode: number;
  4660. /**
  4661. * Returns the line list draw mode
  4662. */
  4663. static readonly MATERIAL_LineListDrawMode: number;
  4664. /**
  4665. * Returns the line loop draw mode
  4666. */
  4667. static readonly MATERIAL_LineLoopDrawMode: number;
  4668. /**
  4669. * Returns the line strip draw mode
  4670. */
  4671. static readonly MATERIAL_LineStripDrawMode: number;
  4672. /**
  4673. * Returns the triangle strip draw mode
  4674. */
  4675. static readonly MATERIAL_TriangleStripDrawMode: number;
  4676. /**
  4677. * Returns the triangle fan draw mode
  4678. */
  4679. static readonly MATERIAL_TriangleFanDrawMode: number;
  4680. /**
  4681. * Stores the clock-wise side orientation
  4682. */
  4683. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4684. /**
  4685. * Stores the counter clock-wise side orientation
  4686. */
  4687. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4688. /**
  4689. * Nothing
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_NothingTrigger: number;
  4693. /**
  4694. * On pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnPickTrigger: number;
  4698. /**
  4699. * On left pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnLeftPickTrigger: number;
  4703. /**
  4704. * On right pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnRightPickTrigger: number;
  4708. /**
  4709. * On center pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnCenterPickTrigger: number;
  4713. /**
  4714. * On pick down
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickDownTrigger: number;
  4718. /**
  4719. * On double pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnDoublePickTrigger: number;
  4723. /**
  4724. * On pick up
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickUpTrigger: number;
  4728. /**
  4729. * On pick out.
  4730. * This trigger will only be raised if you also declared a OnPickDown
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickOutTrigger: number;
  4734. /**
  4735. * On long press
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLongPressTrigger: number;
  4739. /**
  4740. * On pointer over
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPointerOverTrigger: number;
  4744. /**
  4745. * On pointer out
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnPointerOutTrigger: number;
  4749. /**
  4750. * On every frame
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnEveryFrameTrigger: number;
  4754. /**
  4755. * On intersection enter
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4759. /**
  4760. * On intersection exit
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnIntersectionExitTrigger: number;
  4764. /**
  4765. * On key down
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnKeyDownTrigger: number;
  4769. /**
  4770. * On key up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnKeyUpTrigger: number;
  4774. /**
  4775. * Billboard mode will only apply to Y axis
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4778. /**
  4779. * Billboard mode will apply to all axes
  4780. */
  4781. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4782. /**
  4783. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4784. */
  4785. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4786. /**
  4787. * Gets or sets base Assets URL
  4788. */
  4789. static readonly PARTICLES_BaseAssetsUrl: string;
  4790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4791. * Test order :
  4792. * Is the bounding sphere outside the frustum ?
  4793. * If not, are the bounding box vertices outside the frustum ?
  4794. * It not, then the cullable object is in the frustum.
  4795. */
  4796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4797. /** Culling strategy : Bounding Sphere Only.
  4798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4799. * It's also less accurate than the standard because some not visible objects can still be selected.
  4800. * Test : is the bounding sphere outside the frustum ?
  4801. * If not, then the cullable object is in the frustum.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4804. /** Culling strategy : Optimistic Inclusion.
  4805. * This in an inclusion test first, then the standard exclusion test.
  4806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4807. * 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.
  4808. * Anyway, it's as accurate as the standard strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the default culling strategy.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4817. * 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.
  4818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4824. /**
  4825. * No logging while loading
  4826. */
  4827. static readonly SCENELOADER_NO_LOGGING: number;
  4828. /**
  4829. * Minimal logging while loading
  4830. */
  4831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4832. /**
  4833. * Summary logging while loading
  4834. */
  4835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4836. /**
  4837. * Detailled logging while loading
  4838. */
  4839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4840. }
  4841. }
  4842. declare module BABYLON {
  4843. /**
  4844. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4845. * Babylon.js
  4846. */
  4847. export class DomManagement {
  4848. /**
  4849. * Checks if the window object exists
  4850. * @returns true if the window object exists
  4851. */
  4852. static IsWindowObjectExist(): boolean;
  4853. /**
  4854. * Extracts text content from a DOM element hierarchy
  4855. * @param element defines the root element
  4856. * @returns a string
  4857. */
  4858. static GetDOMTextContent(element: HTMLElement): string;
  4859. }
  4860. }
  4861. declare module BABYLON {
  4862. /**
  4863. * Logger used througouht the application to allow configuration of
  4864. * the log level required for the messages.
  4865. */
  4866. export class Logger {
  4867. /**
  4868. * No log
  4869. */
  4870. static readonly NoneLogLevel: number;
  4871. /**
  4872. * Only message logs
  4873. */
  4874. static readonly MessageLogLevel: number;
  4875. /**
  4876. * Only warning logs
  4877. */
  4878. static readonly WarningLogLevel: number;
  4879. /**
  4880. * Only error logs
  4881. */
  4882. static readonly ErrorLogLevel: number;
  4883. /**
  4884. * All logs
  4885. */
  4886. static readonly AllLogLevel: number;
  4887. private static _LogCache;
  4888. /**
  4889. * Gets a value indicating the number of loading errors
  4890. * @ignorenaming
  4891. */
  4892. static errorsCount: number;
  4893. /**
  4894. * Callback called when a new log is added
  4895. */
  4896. static OnNewCacheEntry: (entry: string) => void;
  4897. private static _AddLogEntry;
  4898. private static _FormatMessage;
  4899. private static _LogDisabled;
  4900. private static _LogEnabled;
  4901. private static _WarnDisabled;
  4902. private static _WarnEnabled;
  4903. private static _ErrorDisabled;
  4904. private static _ErrorEnabled;
  4905. /**
  4906. * Log a message to the console
  4907. */
  4908. static Log: (message: string) => void;
  4909. /**
  4910. * Write a warning message to the console
  4911. */
  4912. static Warn: (message: string) => void;
  4913. /**
  4914. * Write an error message to the console
  4915. */
  4916. static Error: (message: string) => void;
  4917. /**
  4918. * Gets current log cache (list of logs)
  4919. */
  4920. static readonly LogCache: string;
  4921. /**
  4922. * Clears the log cache
  4923. */
  4924. static ClearLogCache(): void;
  4925. /**
  4926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4927. */
  4928. static LogLevels: number;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /** @hidden */
  4933. export class _TypeStore {
  4934. /** @hidden */
  4935. static RegisteredTypes: {
  4936. [key: string]: Object;
  4937. };
  4938. /** @hidden */
  4939. static GetClass(fqdn: string): any;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class containing a set of static utilities functions for deep copy.
  4945. */
  4946. export class DeepCopier {
  4947. /**
  4948. * Tries to copy an object by duplicating every property
  4949. * @param source defines the source object
  4950. * @param destination defines the target object
  4951. * @param doNotCopyList defines a list of properties to avoid
  4952. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4953. */
  4954. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class containing a set of static utilities functions for precision date
  4960. */
  4961. export class PrecisionDate {
  4962. /**
  4963. * Gets either window.performance.now() if supported or Date.now() else
  4964. */
  4965. static readonly Now: number;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. /** @hidden */
  4970. export class _DevTools {
  4971. static WarnImport(name: string): string;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4977. */
  4978. export class WebRequest {
  4979. private _xhr;
  4980. /**
  4981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4982. * i.e. when loading files, where the server/service expects an Authorization header
  4983. */
  4984. static CustomRequestHeaders: {
  4985. [key: string]: string;
  4986. };
  4987. /**
  4988. * Add callback functions in this array to update all the requests before they get sent to the network
  4989. */
  4990. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4991. private _injectCustomRequestHeaders;
  4992. /**
  4993. * Gets or sets a function to be called when loading progress changes
  4994. */
  4995. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4996. /**
  4997. * Returns client's state
  4998. */
  4999. readonly readyState: number;
  5000. /**
  5001. * Returns client's status
  5002. */
  5003. readonly status: number;
  5004. /**
  5005. * Returns client's status as a text
  5006. */
  5007. readonly statusText: string;
  5008. /**
  5009. * Returns client's response
  5010. */
  5011. readonly response: any;
  5012. /**
  5013. * Returns client's response url
  5014. */
  5015. readonly responseURL: string;
  5016. /**
  5017. * Returns client's response as text
  5018. */
  5019. readonly responseText: string;
  5020. /**
  5021. * Gets or sets the expected response type
  5022. */
  5023. responseType: XMLHttpRequestResponseType;
  5024. /** @hidden */
  5025. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5026. /** @hidden */
  5027. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5028. /**
  5029. * Cancels any network activity
  5030. */
  5031. abort(): void;
  5032. /**
  5033. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5034. * @param body defines an optional request body
  5035. */
  5036. send(body?: Document | BodyInit | null): void;
  5037. /**
  5038. * Sets the request method, request URL
  5039. * @param method defines the method to use (GET, POST, etc..)
  5040. * @param url defines the url to connect with
  5041. */
  5042. open(method: string, url: string): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to evalaute queries containing `and` and `or` operators
  5048. */
  5049. export class AndOrNotEvaluator {
  5050. /**
  5051. * Evaluate a query
  5052. * @param query defines the query to evaluate
  5053. * @param evaluateCallback defines the callback used to filter result
  5054. * @returns true if the query matches
  5055. */
  5056. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5057. private static _HandleParenthesisContent;
  5058. private static _SimplifyNegation;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to store custom tags
  5064. */
  5065. export class Tags {
  5066. /**
  5067. * Adds support for tags on the given object
  5068. * @param obj defines the object to use
  5069. */
  5070. static EnableFor(obj: any): void;
  5071. /**
  5072. * Removes tags support
  5073. * @param obj defines the object to use
  5074. */
  5075. static DisableFor(obj: any): void;
  5076. /**
  5077. * Gets a boolean indicating if the given object has tags
  5078. * @param obj defines the object to use
  5079. * @returns a boolean
  5080. */
  5081. static HasTags(obj: any): boolean;
  5082. /**
  5083. * Gets the tags available on a given object
  5084. * @param obj defines the object to use
  5085. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5086. * @returns the tags
  5087. */
  5088. static GetTags(obj: any, asString?: boolean): any;
  5089. /**
  5090. * Adds tags to an object
  5091. * @param obj defines the object to use
  5092. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5093. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5094. */
  5095. static AddTagsTo(obj: any, tagsString: string): void;
  5096. /**
  5097. * @hidden
  5098. */
  5099. static _AddTagTo(obj: any, tag: string): void;
  5100. /**
  5101. * Removes specific tags from a specific object
  5102. * @param obj defines the object to use
  5103. * @param tagsString defines the tags to remove
  5104. */
  5105. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _RemoveTagFrom(obj: any, tag: string): void;
  5110. /**
  5111. * Defines if tags hosted on an object match a given query
  5112. * @param obj defines the object to use
  5113. * @param tagsQuery defines the tag query
  5114. * @returns a boolean
  5115. */
  5116. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5117. }
  5118. }
  5119. declare module BABYLON {
  5120. /**
  5121. * Manages the defines for the Material
  5122. */
  5123. export class MaterialDefines {
  5124. private _keys;
  5125. private _isDirty;
  5126. /** @hidden */
  5127. _renderId: number;
  5128. /** @hidden */
  5129. _areLightsDirty: boolean;
  5130. /** @hidden */
  5131. _areAttributesDirty: boolean;
  5132. /** @hidden */
  5133. _areTexturesDirty: boolean;
  5134. /** @hidden */
  5135. _areFresnelDirty: boolean;
  5136. /** @hidden */
  5137. _areMiscDirty: boolean;
  5138. /** @hidden */
  5139. _areImageProcessingDirty: boolean;
  5140. /** @hidden */
  5141. _normals: boolean;
  5142. /** @hidden */
  5143. _uvs: boolean;
  5144. /** @hidden */
  5145. _needNormals: boolean;
  5146. /** @hidden */
  5147. _needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @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
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */
  5439. _data: Nullable<DataArray>;
  5440. private _updatable;
  5441. private _instanced;
  5442. /**
  5443. * Gets the byte stride.
  5444. */
  5445. readonly byteStride: number;
  5446. /**
  5447. * Constructor
  5448. * @param engine the engine
  5449. * @param data the data to use for this buffer
  5450. * @param updatable whether the data is updatable
  5451. * @param stride the stride (optional)
  5452. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5453. * @param instanced whether the buffer is instanced (optional)
  5454. * @param useBytes set to true if the stride in in bytes (optional)
  5455. */
  5456. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5457. /**
  5458. * Create a new VertexBuffer based on the current buffer
  5459. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5460. * @param offset defines offset in the buffer (0 by default)
  5461. * @param size defines the size in floats of attributes (position is 3 for instance)
  5462. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5463. * @param instanced defines if the vertex buffer contains indexed data
  5464. * @param useBytes defines if the offset and stride are in bytes
  5465. * @returns the new vertex buffer
  5466. */
  5467. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5468. /**
  5469. * Gets a boolean indicating if the Buffer is updatable?
  5470. * @returns true if the buffer is updatable
  5471. */
  5472. isUpdatable(): boolean;
  5473. /**
  5474. * Gets current buffer's data
  5475. * @returns a DataArray or null
  5476. */
  5477. getData(): Nullable<DataArray>;
  5478. /**
  5479. * Gets underlying native buffer
  5480. * @returns underlying native buffer
  5481. */
  5482. getBuffer(): Nullable<WebGLBuffer>;
  5483. /**
  5484. * Gets the stride in float32 units (i.e. byte stride / 4).
  5485. * May not be an integer if the byte stride is not divisible by 4.
  5486. * DEPRECATED. Use byteStride instead.
  5487. * @returns the stride in float32 units
  5488. */
  5489. getStrideSize(): number;
  5490. /**
  5491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5492. * @param data defines the data to store
  5493. */
  5494. create(data?: Nullable<DataArray>): void;
  5495. /** @hidden */
  5496. _rebuild(): void;
  5497. /**
  5498. * Update current buffer data
  5499. * @param data defines the data to store
  5500. */
  5501. update(data: DataArray): void;
  5502. /**
  5503. * Updates the data directly.
  5504. * @param data the new data
  5505. * @param offset the new offset
  5506. * @param vertexCount the vertex count (optional)
  5507. * @param useBytes set to true if the offset is in bytes
  5508. */
  5509. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5510. /**
  5511. * Release all resources
  5512. */
  5513. dispose(): void;
  5514. }
  5515. /**
  5516. * Specialized buffer used to store vertex data
  5517. */
  5518. export class VertexBuffer {
  5519. /** @hidden */
  5520. _buffer: Buffer;
  5521. private _kind;
  5522. private _size;
  5523. private _ownsBuffer;
  5524. private _instanced;
  5525. private _instanceDivisor;
  5526. /**
  5527. * The byte type.
  5528. */
  5529. static readonly BYTE: number;
  5530. /**
  5531. * The unsigned byte type.
  5532. */
  5533. static readonly UNSIGNED_BYTE: number;
  5534. /**
  5535. * The short type.
  5536. */
  5537. static readonly SHORT: number;
  5538. /**
  5539. * The unsigned short type.
  5540. */
  5541. static readonly UNSIGNED_SHORT: number;
  5542. /**
  5543. * The integer type.
  5544. */
  5545. static readonly INT: number;
  5546. /**
  5547. * The unsigned integer type.
  5548. */
  5549. static readonly UNSIGNED_INT: number;
  5550. /**
  5551. * The float type.
  5552. */
  5553. static readonly FLOAT: number;
  5554. /**
  5555. * Gets or sets the instance divisor when in instanced mode
  5556. */
  5557. instanceDivisor: number;
  5558. /**
  5559. * Gets the byte stride.
  5560. */
  5561. readonly byteStride: number;
  5562. /**
  5563. * Gets the byte offset.
  5564. */
  5565. readonly byteOffset: number;
  5566. /**
  5567. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5568. */
  5569. readonly normalized: boolean;
  5570. /**
  5571. * Gets the data type of each component in the array.
  5572. */
  5573. readonly type: number;
  5574. /**
  5575. * Constructor
  5576. * @param engine the engine
  5577. * @param data the data to use for this vertex buffer
  5578. * @param kind the vertex buffer kind
  5579. * @param updatable whether the data is updatable
  5580. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5581. * @param stride the stride (optional)
  5582. * @param instanced whether the buffer is instanced (optional)
  5583. * @param offset the offset of the data (optional)
  5584. * @param size the number of components (optional)
  5585. * @param type the type of the component (optional)
  5586. * @param normalized whether the data contains normalized data (optional)
  5587. * @param useBytes set to true if stride and offset are in bytes (optional)
  5588. */
  5589. 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);
  5590. /** @hidden */
  5591. _rebuild(): void;
  5592. /**
  5593. * Returns the kind of the VertexBuffer (string)
  5594. * @returns a string
  5595. */
  5596. getKind(): string;
  5597. /**
  5598. * Gets a boolean indicating if the VertexBuffer is updatable?
  5599. * @returns true if the buffer is updatable
  5600. */
  5601. isUpdatable(): boolean;
  5602. /**
  5603. * Gets current buffer's data
  5604. * @returns a DataArray or null
  5605. */
  5606. getData(): Nullable<DataArray>;
  5607. /**
  5608. * Gets underlying native buffer
  5609. * @returns underlying native buffer
  5610. */
  5611. getBuffer(): Nullable<WebGLBuffer>;
  5612. /**
  5613. * Gets the stride in float32 units (i.e. byte stride / 4).
  5614. * May not be an integer if the byte stride is not divisible by 4.
  5615. * DEPRECATED. Use byteStride instead.
  5616. * @returns the stride in float32 units
  5617. */
  5618. getStrideSize(): number;
  5619. /**
  5620. * Returns the offset as a multiple of the type byte length.
  5621. * DEPRECATED. Use byteOffset instead.
  5622. * @returns the offset in bytes
  5623. */
  5624. getOffset(): number;
  5625. /**
  5626. * Returns the number of components per vertex attribute (integer)
  5627. * @returns the size in float
  5628. */
  5629. getSize(): number;
  5630. /**
  5631. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5632. * @returns true if this buffer is instanced
  5633. */
  5634. getIsInstanced(): boolean;
  5635. /**
  5636. * Returns the instancing divisor, zero for non-instanced (integer).
  5637. * @returns a number
  5638. */
  5639. getInstanceDivisor(): number;
  5640. /**
  5641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5642. * @param data defines the data to store
  5643. */
  5644. create(data?: DataArray): void;
  5645. /**
  5646. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5647. * This function will create a new buffer if the current one is not updatable
  5648. * @param data defines the data to store
  5649. */
  5650. update(data: DataArray): void;
  5651. /**
  5652. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5653. * Returns the directly updated WebGLBuffer.
  5654. * @param data the new data
  5655. * @param offset the new offset
  5656. * @param useBytes set to true if the offset is in bytes
  5657. */
  5658. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5659. /**
  5660. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5661. */
  5662. dispose(): void;
  5663. /**
  5664. * Enumerates each value of this vertex buffer as numbers.
  5665. * @param count the number of values to enumerate
  5666. * @param callback the callback function called for each value
  5667. */
  5668. forEach(count: number, callback: (value: number, index: number) => void): void;
  5669. /**
  5670. * Positions
  5671. */
  5672. static readonly PositionKind: string;
  5673. /**
  5674. * Normals
  5675. */
  5676. static readonly NormalKind: string;
  5677. /**
  5678. * Tangents
  5679. */
  5680. static readonly TangentKind: string;
  5681. /**
  5682. * Texture coordinates
  5683. */
  5684. static readonly UVKind: string;
  5685. /**
  5686. * Texture coordinates 2
  5687. */
  5688. static readonly UV2Kind: string;
  5689. /**
  5690. * Texture coordinates 3
  5691. */
  5692. static readonly UV3Kind: string;
  5693. /**
  5694. * Texture coordinates 4
  5695. */
  5696. static readonly UV4Kind: string;
  5697. /**
  5698. * Texture coordinates 5
  5699. */
  5700. static readonly UV5Kind: string;
  5701. /**
  5702. * Texture coordinates 6
  5703. */
  5704. static readonly UV6Kind: string;
  5705. /**
  5706. * Colors
  5707. */
  5708. static readonly ColorKind: string;
  5709. /**
  5710. * Matrix indices (for bones)
  5711. */
  5712. static readonly MatricesIndicesKind: string;
  5713. /**
  5714. * Matrix weights (for bones)
  5715. */
  5716. static readonly MatricesWeightsKind: string;
  5717. /**
  5718. * Additional matrix indices (for bones)
  5719. */
  5720. static readonly MatricesIndicesExtraKind: string;
  5721. /**
  5722. * Additional matrix weights (for bones)
  5723. */
  5724. static readonly MatricesWeightsExtraKind: string;
  5725. /**
  5726. * Deduces the stride given a kind.
  5727. * @param kind The kind string to deduce
  5728. * @returns The deduced stride
  5729. */
  5730. static DeduceStride(kind: string): number;
  5731. /**
  5732. * Gets the byte length of the given type.
  5733. * @param type the type
  5734. * @returns the number of bytes
  5735. */
  5736. static GetTypeByteLength(type: number): number;
  5737. /**
  5738. * Enumerates each value of the given parameters as numbers.
  5739. * @param data the data to enumerate
  5740. * @param byteOffset the byte offset of the data
  5741. * @param byteStride the byte stride of the data
  5742. * @param componentCount the number of components per element
  5743. * @param componentType the type of the component
  5744. * @param count the total number of components
  5745. * @param normalized whether the data is normalized
  5746. * @param callback the callback function called for each value
  5747. */
  5748. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5749. private static _GetFloatValue;
  5750. }
  5751. }
  5752. declare module BABYLON {
  5753. /**
  5754. * Class representing spherical polynomial coefficients to the 3rd degree
  5755. */
  5756. export class SphericalPolynomial {
  5757. /**
  5758. * The x coefficients of the spherical polynomial
  5759. */
  5760. x: Vector3;
  5761. /**
  5762. * The y coefficients of the spherical polynomial
  5763. */
  5764. y: Vector3;
  5765. /**
  5766. * The z coefficients of the spherical polynomial
  5767. */
  5768. z: Vector3;
  5769. /**
  5770. * The xx coefficients of the spherical polynomial
  5771. */
  5772. xx: Vector3;
  5773. /**
  5774. * The yy coefficients of the spherical polynomial
  5775. */
  5776. yy: Vector3;
  5777. /**
  5778. * The zz coefficients of the spherical polynomial
  5779. */
  5780. zz: Vector3;
  5781. /**
  5782. * The xy coefficients of the spherical polynomial
  5783. */
  5784. xy: Vector3;
  5785. /**
  5786. * The yz coefficients of the spherical polynomial
  5787. */
  5788. yz: Vector3;
  5789. /**
  5790. * The zx coefficients of the spherical polynomial
  5791. */
  5792. zx: Vector3;
  5793. /**
  5794. * Adds an ambient color to the spherical polynomial
  5795. * @param color the color to add
  5796. */
  5797. addAmbient(color: Color3): void;
  5798. /**
  5799. * Scales the spherical polynomial by the given amount
  5800. * @param scale the amount to scale
  5801. */
  5802. scale(scale: number): void;
  5803. /**
  5804. * Gets the spherical polynomial from harmonics
  5805. * @param harmonics the spherical harmonics
  5806. * @returns the spherical polynomial
  5807. */
  5808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5809. /**
  5810. * Constructs a spherical polynomial from an array.
  5811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5812. * @returns the spherical polynomial
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5815. }
  5816. /**
  5817. * Class representing spherical harmonics coefficients to the 3rd degree
  5818. */
  5819. export class SphericalHarmonics {
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. lL22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scale(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Gets the spherical harmonics from polynomial
  5892. * @param polynomial the spherical polynomial
  5893. * @returns the spherical harmonics
  5894. */
  5895. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5896. /**
  5897. * Constructs a spherical harmonics from an array.
  5898. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5899. * @returns the spherical harmonics
  5900. */
  5901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5907. */
  5908. export interface CubeMapInfo {
  5909. /**
  5910. * The pixel array for the front face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. front: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the back face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. back: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The pixel array for the left face.
  5921. * This is stored in format, left to right, up to down format.
  5922. */
  5923. left: Nullable<ArrayBufferView>;
  5924. /**
  5925. * The pixel array for the right face.
  5926. * This is stored in format, left to right, up to down format.
  5927. */
  5928. right: Nullable<ArrayBufferView>;
  5929. /**
  5930. * The pixel array for the up face.
  5931. * This is stored in format, left to right, up to down format.
  5932. */
  5933. up: Nullable<ArrayBufferView>;
  5934. /**
  5935. * The pixel array for the down face.
  5936. * This is stored in format, left to right, up to down format.
  5937. */
  5938. down: Nullable<ArrayBufferView>;
  5939. /**
  5940. * The size of the cubemap stored.
  5941. *
  5942. * Each faces will be size * size pixels.
  5943. */
  5944. size: number;
  5945. /**
  5946. * The format of the texture.
  5947. *
  5948. * RGBA, RGB.
  5949. */
  5950. format: number;
  5951. /**
  5952. * The type of the texture data.
  5953. *
  5954. * UNSIGNED_INT, FLOAT.
  5955. */
  5956. type: number;
  5957. /**
  5958. * Specifies whether the texture is in gamma space.
  5959. */
  5960. gammaSpace: boolean;
  5961. }
  5962. /**
  5963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5964. */
  5965. export class PanoramaToCubeMapTools {
  5966. private static FACE_FRONT;
  5967. private static FACE_BACK;
  5968. private static FACE_RIGHT;
  5969. private static FACE_LEFT;
  5970. private static FACE_DOWN;
  5971. private static FACE_UP;
  5972. /**
  5973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5974. *
  5975. * @param float32Array The source data.
  5976. * @param inputWidth The width of the input panorama.
  5977. * @param inputHeight The height of the input panorama.
  5978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5979. * @return The cubemap data
  5980. */
  5981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5982. private static CreateCubemapTexture;
  5983. private static CalcProjectionSpherical;
  5984. }
  5985. }
  5986. declare module BABYLON {
  5987. /**
  5988. * Helper class dealing with the extraction of spherical polynomial dataArray
  5989. * from a cube map.
  5990. */
  5991. export class CubeMapToSphericalPolynomialTools {
  5992. private static FileFaces;
  5993. /**
  5994. * Converts a texture to the according Spherical Polynomial data.
  5995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5996. *
  5997. * @param texture The texture to extract the information from.
  5998. * @return The Spherical Polynomial data.
  5999. */
  6000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6001. /**
  6002. * Converts a cubemap to the according Spherical Polynomial data.
  6003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6004. *
  6005. * @param cubeInfo The Cube map to extract the information from.
  6006. * @return The Spherical Polynomial data.
  6007. */
  6008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6014. * during the life time of the application.
  6015. */
  6016. export class EngineStore {
  6017. /** Gets the list of created engines */
  6018. static Instances: Engine[];
  6019. /**
  6020. * Gets the latest created engine
  6021. */
  6022. static readonly LastCreatedEngine: Nullable<Engine>;
  6023. /**
  6024. * Gets the latest created scene
  6025. */
  6026. static readonly LastCreatedScene: Nullable<Scene>;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. /**
  6031. * Define options used to create a render target texture
  6032. */
  6033. export class RenderTargetCreationOptions {
  6034. /**
  6035. * Specifies is mipmaps must be generated
  6036. */
  6037. generateMipMaps?: boolean;
  6038. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6039. generateDepthBuffer?: boolean;
  6040. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6041. generateStencilBuffer?: boolean;
  6042. /** Defines texture type (int by default) */
  6043. type?: number;
  6044. /** Defines sampling mode (trilinear by default) */
  6045. samplingMode?: number;
  6046. /** Defines format (RGBA by default) */
  6047. format?: number;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * @hidden
  6053. **/
  6054. export class _AlphaState {
  6055. private _isAlphaBlendDirty;
  6056. private _isBlendFunctionParametersDirty;
  6057. private _isBlendEquationParametersDirty;
  6058. private _isBlendConstantsDirty;
  6059. private _alphaBlend;
  6060. private _blendFunctionParameters;
  6061. private _blendEquationParameters;
  6062. private _blendConstants;
  6063. /**
  6064. * Initializes the state.
  6065. */
  6066. constructor();
  6067. readonly isDirty: boolean;
  6068. alphaBlend: boolean;
  6069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6072. reset(): void;
  6073. apply(gl: WebGLRenderingContext): void;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * @hidden
  6079. **/
  6080. export class _DepthCullingState {
  6081. private _isDepthTestDirty;
  6082. private _isDepthMaskDirty;
  6083. private _isDepthFuncDirty;
  6084. private _isCullFaceDirty;
  6085. private _isCullDirty;
  6086. private _isZOffsetDirty;
  6087. private _isFrontFaceDirty;
  6088. private _depthTest;
  6089. private _depthMask;
  6090. private _depthFunc;
  6091. private _cull;
  6092. private _cullFace;
  6093. private _zOffset;
  6094. private _frontFace;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. zOffset: number;
  6101. cullFace: Nullable<number>;
  6102. cull: Nullable<boolean>;
  6103. depthFunc: Nullable<number>;
  6104. depthMask: boolean;
  6105. depthTest: boolean;
  6106. frontFace: Nullable<number>;
  6107. reset(): void;
  6108. apply(gl: WebGLRenderingContext): void;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * @hidden
  6114. **/
  6115. export class _StencilState {
  6116. /** 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 */
  6117. static readonly ALWAYS: number;
  6118. /** Passed to stencilOperation to specify that stencil value must be kept */
  6119. static readonly KEEP: number;
  6120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6121. static readonly REPLACE: number;
  6122. private _isStencilTestDirty;
  6123. private _isStencilMaskDirty;
  6124. private _isStencilFuncDirty;
  6125. private _isStencilOpDirty;
  6126. private _stencilTest;
  6127. private _stencilMask;
  6128. private _stencilFunc;
  6129. private _stencilFuncRef;
  6130. private _stencilFuncMask;
  6131. private _stencilOpStencilFail;
  6132. private _stencilOpDepthFail;
  6133. private _stencilOpStencilDepthPass;
  6134. readonly isDirty: boolean;
  6135. stencilFunc: number;
  6136. stencilFuncRef: number;
  6137. stencilFuncMask: number;
  6138. stencilOpStencilFail: number;
  6139. stencilOpDepthFail: number;
  6140. stencilOpStencilDepthPass: number;
  6141. stencilMask: number;
  6142. stencilTest: boolean;
  6143. constructor();
  6144. reset(): void;
  6145. apply(gl: WebGLRenderingContext): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _TimeToken {
  6153. _startTimeQuery: Nullable<WebGLQuery>;
  6154. _endTimeQuery: Nullable<WebGLQuery>;
  6155. _timeElapsedQuery: Nullable<WebGLQuery>;
  6156. _timeElapsedQueryEnded: boolean;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Internal interface used to track InternalTexture already bound to the GL context
  6162. */
  6163. export interface IInternalTextureTracker {
  6164. /**
  6165. * Gets or set the previous tracker in the list
  6166. */
  6167. previous: Nullable<IInternalTextureTracker>;
  6168. /**
  6169. * Gets or set the next tracker in the list
  6170. */
  6171. next: Nullable<IInternalTextureTracker>;
  6172. }
  6173. /**
  6174. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6175. */
  6176. export class DummyInternalTextureTracker {
  6177. /**
  6178. * Gets or set the previous tracker in the list
  6179. */
  6180. previous: Nullable<IInternalTextureTracker>;
  6181. /**
  6182. * Gets or set the next tracker in the list
  6183. */
  6184. next: Nullable<IInternalTextureTracker>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture implements IInternalTextureTracker {
  6193. /** hidden */
  6194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6195. /**
  6196. * The source of the texture data is unknown
  6197. */
  6198. static DATASOURCE_UNKNOWN: number;
  6199. /**
  6200. * Texture data comes from an URL
  6201. */
  6202. static DATASOURCE_URL: number;
  6203. /**
  6204. * Texture data is only used for temporary storage
  6205. */
  6206. static DATASOURCE_TEMP: number;
  6207. /**
  6208. * Texture data comes from raw data (ArrayBuffer)
  6209. */
  6210. static DATASOURCE_RAW: number;
  6211. /**
  6212. * Texture content is dynamic (video or dynamic texture)
  6213. */
  6214. static DATASOURCE_DYNAMIC: number;
  6215. /**
  6216. * Texture content is generated by rendering to it
  6217. */
  6218. static DATASOURCE_RENDERTARGET: number;
  6219. /**
  6220. * Texture content is part of a multi render target process
  6221. */
  6222. static DATASOURCE_MULTIRENDERTARGET: number;
  6223. /**
  6224. * Texture data comes from a cube data file
  6225. */
  6226. static DATASOURCE_CUBE: number;
  6227. /**
  6228. * Texture data comes from a raw cube data
  6229. */
  6230. static DATASOURCE_CUBERAW: number;
  6231. /**
  6232. * Texture data come from a prefiltered cube data file
  6233. */
  6234. static DATASOURCE_CUBEPREFILTERED: number;
  6235. /**
  6236. * Texture content is raw 3D data
  6237. */
  6238. static DATASOURCE_RAW3D: number;
  6239. /**
  6240. * Texture content is a depth texture
  6241. */
  6242. static DATASOURCE_DEPTHTEXTURE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data encoded with RGBD
  6245. */
  6246. static DATASOURCE_CUBERAW_RGBD: number;
  6247. /**
  6248. * Defines if the texture is ready
  6249. */
  6250. isReady: boolean;
  6251. /**
  6252. * Defines if the texture is a cube texture
  6253. */
  6254. isCube: boolean;
  6255. /**
  6256. * Defines if the texture contains 3D data
  6257. */
  6258. is3D: boolean;
  6259. /**
  6260. * Defines if the texture contains multiview data
  6261. */
  6262. isMultiview: boolean;
  6263. /**
  6264. * Gets the URL used to load this texture
  6265. */
  6266. url: string;
  6267. /**
  6268. * Gets the sampling mode of the texture
  6269. */
  6270. samplingMode: number;
  6271. /**
  6272. * Gets a boolean indicating if the texture needs mipmaps generation
  6273. */
  6274. generateMipMaps: boolean;
  6275. /**
  6276. * Gets the number of samples used by the texture (WebGL2+ only)
  6277. */
  6278. samples: number;
  6279. /**
  6280. * Gets the type of the texture (int, float...)
  6281. */
  6282. type: number;
  6283. /**
  6284. * Gets the format of the texture (RGB, RGBA...)
  6285. */
  6286. format: number;
  6287. /**
  6288. * Observable called when the texture is loaded
  6289. */
  6290. onLoadedObservable: Observable<InternalTexture>;
  6291. /**
  6292. * Gets the width of the texture
  6293. */
  6294. width: number;
  6295. /**
  6296. * Gets the height of the texture
  6297. */
  6298. height: number;
  6299. /**
  6300. * Gets the depth of the texture
  6301. */
  6302. depth: number;
  6303. /**
  6304. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6305. */
  6306. baseWidth: number;
  6307. /**
  6308. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseHeight: number;
  6311. /**
  6312. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6313. */
  6314. baseDepth: number;
  6315. /**
  6316. * Gets a boolean indicating if the texture is inverted on Y axis
  6317. */
  6318. invertY: boolean;
  6319. /**
  6320. * Gets or set the previous tracker in the list
  6321. */
  6322. previous: Nullable<IInternalTextureTracker>;
  6323. /**
  6324. * Gets or set the next tracker in the list
  6325. */
  6326. next: Nullable<IInternalTextureTracker>;
  6327. /** @hidden */
  6328. _invertVScale: boolean;
  6329. /** @hidden */
  6330. _initialSlot: number;
  6331. /** @hidden */
  6332. _designatedSlot: number;
  6333. /** @hidden */
  6334. _dataSource: number;
  6335. /** @hidden */
  6336. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6337. /** @hidden */
  6338. _bufferView: Nullable<ArrayBufferView>;
  6339. /** @hidden */
  6340. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6341. /** @hidden */
  6342. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */
  6344. _size: number;
  6345. /** @hidden */
  6346. _extension: string;
  6347. /** @hidden */
  6348. _files: Nullable<string[]>;
  6349. /** @hidden */
  6350. _workingCanvas: HTMLCanvasElement;
  6351. /** @hidden */
  6352. _workingContext: CanvasRenderingContext2D;
  6353. /** @hidden */
  6354. _framebuffer: Nullable<WebGLFramebuffer>;
  6355. /** @hidden */
  6356. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6357. /** @hidden */
  6358. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6359. /** @hidden */
  6360. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6361. /** @hidden */
  6362. _attachments: Nullable<number[]>;
  6363. /** @hidden */
  6364. _cachedCoordinatesMode: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedWrapU: Nullable<number>;
  6367. /** @hidden */
  6368. _cachedWrapV: Nullable<number>;
  6369. /** @hidden */
  6370. _cachedWrapR: Nullable<number>;
  6371. /** @hidden */
  6372. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6373. /** @hidden */
  6374. _isDisabled: boolean;
  6375. /** @hidden */
  6376. _compression: Nullable<string>;
  6377. /** @hidden */
  6378. _generateStencilBuffer: boolean;
  6379. /** @hidden */
  6380. _generateDepthBuffer: boolean;
  6381. /** @hidden */
  6382. _comparisonFunction: number;
  6383. /** @hidden */
  6384. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6385. /** @hidden */
  6386. _lodGenerationScale: number;
  6387. /** @hidden */
  6388. _lodGenerationOffset: number;
  6389. /** @hidden */
  6390. _colorTextureArray: Nullable<WebGLTexture>;
  6391. /** @hidden */
  6392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */
  6394. _lodTextureHigh: BaseTexture;
  6395. /** @hidden */
  6396. _lodTextureMid: BaseTexture;
  6397. /** @hidden */
  6398. _lodTextureLow: BaseTexture;
  6399. /** @hidden */
  6400. _isRGBD: boolean;
  6401. /** @hidden */
  6402. _webGLTexture: Nullable<WebGLTexture>;
  6403. /** @hidden */
  6404. _references: number;
  6405. private _engine;
  6406. /**
  6407. * Gets the Engine the texture belongs to.
  6408. * @returns The babylon engine
  6409. */
  6410. getEngine(): Engine;
  6411. /**
  6412. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6413. */
  6414. readonly dataSource: number;
  6415. /**
  6416. * Creates a new InternalTexture
  6417. * @param engine defines the engine to use
  6418. * @param dataSource defines the type of data that will be used
  6419. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6420. */
  6421. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6422. /**
  6423. * Increments the number of references (ie. the number of Texture that point to it)
  6424. */
  6425. incrementReferences(): void;
  6426. /**
  6427. * Change the size of the texture (not the size of the content)
  6428. * @param width defines the new width
  6429. * @param height defines the new height
  6430. * @param depth defines the new depth (1 by default)
  6431. */
  6432. updateSize(width: int, height: int, depth?: int): void;
  6433. /** @hidden */
  6434. _rebuild(): void;
  6435. /** @hidden */
  6436. _swapAndDie(target: InternalTexture): void;
  6437. /**
  6438. * Dispose the current allocated resources
  6439. */
  6440. dispose(): void;
  6441. }
  6442. }
  6443. declare module BABYLON {
  6444. /**
  6445. * This represents the main contract an easing function should follow.
  6446. * Easing functions are used throughout the animation system.
  6447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6448. */
  6449. export interface IEasingFunction {
  6450. /**
  6451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6452. * of the easing function.
  6453. * The link below provides some of the most common examples of easing functions.
  6454. * @see https://easings.net/
  6455. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6456. * @returns the corresponding value on the curve defined by the easing function
  6457. */
  6458. ease(gradient: number): number;
  6459. }
  6460. /**
  6461. * Base class used for every default easing function.
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class EasingFunction implements IEasingFunction {
  6465. /**
  6466. * Interpolation follows the mathematical formula associated with the easing function.
  6467. */
  6468. static readonly EASINGMODE_EASEIN: number;
  6469. /**
  6470. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6471. */
  6472. static readonly EASINGMODE_EASEOUT: number;
  6473. /**
  6474. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6475. */
  6476. static readonly EASINGMODE_EASEINOUT: number;
  6477. private _easingMode;
  6478. /**
  6479. * Sets the easing mode of the current function.
  6480. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6481. */
  6482. setEasingMode(easingMode: number): void;
  6483. /**
  6484. * Gets the current easing mode.
  6485. * @returns the easing mode
  6486. */
  6487. getEasingMode(): number;
  6488. /**
  6489. * @hidden
  6490. */
  6491. easeInCore(gradient: number): number;
  6492. /**
  6493. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6494. * of the easing function.
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Easing function with a circle shape (see link below).
  6502. * @see https://easings.net/#easeInCirc
  6503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6504. */
  6505. export class CircleEase extends EasingFunction implements IEasingFunction {
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a ease back shape (see link below).
  6511. * @see https://easings.net/#easeInBack
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class BackEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the amplitude of the function */
  6516. amplitude: number;
  6517. /**
  6518. * Instantiates a back ease easing
  6519. * @see https://easings.net/#easeInBack
  6520. * @param amplitude Defines the amplitude of the function
  6521. */
  6522. constructor(
  6523. /** Defines the amplitude of the function */
  6524. amplitude?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a bouncing shape (see link below).
  6530. * @see https://easings.net/#easeInBounce
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class BounceEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of bounces */
  6535. bounces: number;
  6536. /** Defines the amplitude of the bounce */
  6537. bounciness: number;
  6538. /**
  6539. * Instantiates a bounce easing
  6540. * @see https://easings.net/#easeInBounce
  6541. * @param bounces Defines the number of bounces
  6542. * @param bounciness Defines the amplitude of the bounce
  6543. */
  6544. constructor(
  6545. /** Defines the number of bounces */
  6546. bounces?: number,
  6547. /** Defines the amplitude of the bounce */
  6548. bounciness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 3 shape (see link below).
  6554. * @see https://easings.net/#easeInCubic
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class CubicEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with an elastic shape (see link below).
  6563. * @see https://easings.net/#easeInElastic
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of oscillations*/
  6568. oscillations: number;
  6569. /** Defines the amplitude of the oscillations*/
  6570. springiness: number;
  6571. /**
  6572. * Instantiates an elastic easing function
  6573. * @see https://easings.net/#easeInElastic
  6574. * @param oscillations Defines the number of oscillations
  6575. * @param springiness Defines the amplitude of the oscillations
  6576. */
  6577. constructor(
  6578. /** Defines the number of oscillations*/
  6579. oscillations?: number,
  6580. /** Defines the amplitude of the oscillations*/
  6581. springiness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with an exponential shape (see link below).
  6587. * @see https://easings.net/#easeInExpo
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6591. /** Defines the exponent of the function */
  6592. exponent: number;
  6593. /**
  6594. * Instantiates an exponential easing function
  6595. * @see https://easings.net/#easeInExpo
  6596. * @param exponent Defines the exponent of the function
  6597. */
  6598. constructor(
  6599. /** Defines the exponent of the function */
  6600. exponent?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. /**
  6605. * Easing function with a power shape (see link below).
  6606. * @see https://easings.net/#easeInQuad
  6607. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6608. */
  6609. export class PowerEase extends EasingFunction implements IEasingFunction {
  6610. /** Defines the power of the function */
  6611. power: number;
  6612. /**
  6613. * Instantiates an power base easing function
  6614. * @see https://easings.net/#easeInQuad
  6615. * @param power Defines the power of the function
  6616. */
  6617. constructor(
  6618. /** Defines the power of the function */
  6619. power?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. /**
  6624. * Easing function with a power of 2 shape (see link below).
  6625. * @see https://easings.net/#easeInQuad
  6626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6627. */
  6628. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6629. /** @hidden */
  6630. easeInCore(gradient: number): number;
  6631. }
  6632. /**
  6633. * Easing function with a power of 4 shape (see link below).
  6634. * @see https://easings.net/#easeInQuart
  6635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6636. */
  6637. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 5 shape (see link below).
  6643. * @see https://easings.net/#easeInQuint
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a sin shape (see link below).
  6652. * @see https://easings.net/#easeInSine
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class SineEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a bezier shape (see link below).
  6661. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6665. /** Defines the x component of the start tangent in the bezier curve */
  6666. x1: number;
  6667. /** Defines the y component of the start tangent in the bezier curve */
  6668. y1: number;
  6669. /** Defines the x component of the end tangent in the bezier curve */
  6670. x2: number;
  6671. /** Defines the y component of the end tangent in the bezier curve */
  6672. y2: number;
  6673. /**
  6674. * Instantiates a bezier function
  6675. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6676. * @param x1 Defines the x component of the start tangent in the bezier curve
  6677. * @param y1 Defines the y component of the start tangent in the bezier curve
  6678. * @param x2 Defines the x component of the end tangent in the bezier curve
  6679. * @param y2 Defines the y component of the end tangent in the bezier curve
  6680. */
  6681. constructor(
  6682. /** Defines the x component of the start tangent in the bezier curve */
  6683. x1?: number,
  6684. /** Defines the y component of the start tangent in the bezier curve */
  6685. y1?: number,
  6686. /** Defines the x component of the end tangent in the bezier curve */
  6687. x2?: number,
  6688. /** Defines the y component of the end tangent in the bezier curve */
  6689. y2?: number);
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Defines an interface which represents an animation key frame
  6697. */
  6698. export interface IAnimationKey {
  6699. /**
  6700. * Frame of the key frame
  6701. */
  6702. frame: number;
  6703. /**
  6704. * Value at the specifies key frame
  6705. */
  6706. value: any;
  6707. /**
  6708. * The input tangent for the cubic hermite spline
  6709. */
  6710. inTangent?: any;
  6711. /**
  6712. * The output tangent for the cubic hermite spline
  6713. */
  6714. outTangent?: any;
  6715. /**
  6716. * The animation interpolation type
  6717. */
  6718. interpolation?: AnimationKeyInterpolation;
  6719. }
  6720. /**
  6721. * Enum for the animation key frame interpolation type
  6722. */
  6723. export enum AnimationKeyInterpolation {
  6724. /**
  6725. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6726. */
  6727. STEP = 1
  6728. }
  6729. }
  6730. declare module BABYLON {
  6731. /**
  6732. * Represents the range of an animation
  6733. */
  6734. export class AnimationRange {
  6735. /**The name of the animation range**/
  6736. name: string;
  6737. /**The starting frame of the animation */
  6738. from: number;
  6739. /**The ending frame of the animation*/
  6740. to: number;
  6741. /**
  6742. * Initializes the range of an animation
  6743. * @param name The name of the animation range
  6744. * @param from The starting frame of the animation
  6745. * @param to The ending frame of the animation
  6746. */
  6747. constructor(
  6748. /**The name of the animation range**/
  6749. name: string,
  6750. /**The starting frame of the animation */
  6751. from: number,
  6752. /**The ending frame of the animation*/
  6753. to: number);
  6754. /**
  6755. * Makes a copy of the animation range
  6756. * @returns A copy of the animation range
  6757. */
  6758. clone(): AnimationRange;
  6759. }
  6760. }
  6761. declare module BABYLON {
  6762. /**
  6763. * Composed of a frame, and an action function
  6764. */
  6765. export class AnimationEvent {
  6766. /** The frame for which the event is triggered **/
  6767. frame: number;
  6768. /** The event to perform when triggered **/
  6769. action: (currentFrame: number) => void;
  6770. /** Specifies if the event should be triggered only once**/
  6771. onlyOnce?: boolean | undefined;
  6772. /**
  6773. * Specifies if the animation event is done
  6774. */
  6775. isDone: boolean;
  6776. /**
  6777. * Initializes the animation event
  6778. * @param frame The frame for which the event is triggered
  6779. * @param action The event to perform when triggered
  6780. * @param onlyOnce Specifies if the event should be triggered only once
  6781. */
  6782. constructor(
  6783. /** The frame for which the event is triggered **/
  6784. frame: number,
  6785. /** The event to perform when triggered **/
  6786. action: (currentFrame: number) => void,
  6787. /** Specifies if the event should be triggered only once**/
  6788. onlyOnce?: boolean | undefined);
  6789. /** @hidden */
  6790. _clone(): AnimationEvent;
  6791. }
  6792. }
  6793. declare module BABYLON {
  6794. /**
  6795. * Interface used to define a behavior
  6796. */
  6797. export interface Behavior<T> {
  6798. /** gets or sets behavior's name */
  6799. name: string;
  6800. /**
  6801. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6802. */
  6803. init(): void;
  6804. /**
  6805. * Called when the behavior is attached to a target
  6806. * @param target defines the target where the behavior is attached to
  6807. */
  6808. attach(target: T): void;
  6809. /**
  6810. * Called when the behavior is detached from its target
  6811. */
  6812. detach(): void;
  6813. }
  6814. /**
  6815. * Interface implemented by classes supporting behaviors
  6816. */
  6817. export interface IBehaviorAware<T> {
  6818. /**
  6819. * Attach a behavior
  6820. * @param behavior defines the behavior to attach
  6821. * @returns the current host
  6822. */
  6823. addBehavior(behavior: Behavior<T>): T;
  6824. /**
  6825. * Remove a behavior from the current object
  6826. * @param behavior defines the behavior to detach
  6827. * @returns the current host
  6828. */
  6829. removeBehavior(behavior: Behavior<T>): T;
  6830. /**
  6831. * Gets a behavior using its name to search
  6832. * @param name defines the name to search
  6833. * @returns the behavior or null if not found
  6834. */
  6835. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6836. }
  6837. }
  6838. declare module BABYLON {
  6839. /**
  6840. * @hidden
  6841. */
  6842. export class IntersectionInfo {
  6843. bu: Nullable<number>;
  6844. bv: Nullable<number>;
  6845. distance: number;
  6846. faceId: number;
  6847. subMeshId: number;
  6848. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6849. }
  6850. }
  6851. declare module BABYLON {
  6852. /**
  6853. * Class used to store bounding sphere information
  6854. */
  6855. export class BoundingSphere {
  6856. /**
  6857. * Gets the center of the bounding sphere in local space
  6858. */
  6859. readonly center: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in local space
  6862. */
  6863. radius: number;
  6864. /**
  6865. * Gets the center of the bounding sphere in world space
  6866. */
  6867. readonly centerWorld: Vector3;
  6868. /**
  6869. * Radius of the bounding sphere in world space
  6870. */
  6871. radiusWorld: number;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Creates a new bounding sphere
  6884. * @param min defines the minimum vector (in local space)
  6885. * @param max defines the maximum vector (in local space)
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * Scale the current bounding sphere by applying a scale factor
  6898. * @param factor defines the scale factor to apply
  6899. * @returns the current bounding box
  6900. */
  6901. scale(factor: number): BoundingSphere;
  6902. /**
  6903. * Gets the world matrix of the bounding box
  6904. * @returns a matrix
  6905. */
  6906. getWorldMatrix(): DeepImmutable<Matrix>;
  6907. /** @hidden */
  6908. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6909. /**
  6910. * Tests if the bounding sphere is intersecting the frustum planes
  6911. * @param frustumPlanes defines the frustum planes to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6915. /**
  6916. * Tests if the bounding sphere center is in between the frustum planes.
  6917. * Used for optimistic fast inclusion.
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if the sphere center is in between the frustum planes
  6920. */
  6921. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if a point is inside the bounding sphere
  6924. * @param point defines the point to test
  6925. * @returns true if the point is inside the bounding sphere
  6926. */
  6927. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6928. /**
  6929. * Checks if two sphere intersct
  6930. * @param sphere0 sphere 0
  6931. * @param sphere1 sphere 1
  6932. * @returns true if the speres intersect
  6933. */
  6934. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6935. }
  6936. }
  6937. declare module BABYLON {
  6938. /**
  6939. * Class used to store bounding box information
  6940. */
  6941. export class BoundingBox implements ICullable {
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in local space
  6944. */
  6945. readonly vectors: Vector3[];
  6946. /**
  6947. * Gets the center of the bounding box in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Gets the center of the bounding box in world space
  6952. */
  6953. readonly centerWorld: Vector3;
  6954. /**
  6955. * Gets the extend size in local space
  6956. */
  6957. readonly extendSize: Vector3;
  6958. /**
  6959. * Gets the extend size in world space
  6960. */
  6961. readonly extendSizeWorld: Vector3;
  6962. /**
  6963. * Gets the OBB (object bounding box) directions
  6964. */
  6965. readonly directions: Vector3[];
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in world space
  6968. */
  6969. readonly vectorsWorld: Vector3[];
  6970. /**
  6971. * Gets the minimum vector in world space
  6972. */
  6973. readonly minimumWorld: Vector3;
  6974. /**
  6975. * Gets the maximum vector in world space
  6976. */
  6977. readonly maximumWorld: Vector3;
  6978. /**
  6979. * Gets the minimum vector in local space
  6980. */
  6981. readonly minimum: Vector3;
  6982. /**
  6983. * Gets the maximum vector in local space
  6984. */
  6985. readonly maximum: Vector3;
  6986. private _worldMatrix;
  6987. private static readonly TmpVector3;
  6988. /**
  6989. * @hidden
  6990. */
  6991. _tag: number;
  6992. /**
  6993. * Creates a new bounding box
  6994. * @param min defines the minimum vector (in local space)
  6995. * @param max defines the maximum vector (in local space)
  6996. * @param worldMatrix defines the new world matrix
  6997. */
  6998. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6999. /**
  7000. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7001. * @param min defines the new minimum vector (in local space)
  7002. * @param max defines the new maximum vector (in local space)
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Scale the current bounding box by applying a scale factor
  7008. * @param factor defines the scale factor to apply
  7009. * @returns the current bounding box
  7010. */
  7011. scale(factor: number): BoundingBox;
  7012. /**
  7013. * Gets the world matrix of the bounding box
  7014. * @returns a matrix
  7015. */
  7016. getWorldMatrix(): DeepImmutable<Matrix>;
  7017. /** @hidden */
  7018. _update(world: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Tests if the bounding box is intersecting the frustum planes
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @returns true if there is an intersection
  7023. */
  7024. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. /**
  7026. * Tests if the bounding box is entirely inside the frustum planes
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if there is an inclusion
  7029. */
  7030. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding box
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding box
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Tests if the bounding box intersects with a bounding sphere
  7039. * @param sphere defines the sphere to test
  7040. * @returns true if there is an intersection
  7041. */
  7042. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7043. /**
  7044. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7045. * @param min defines the min vector to use
  7046. * @param max defines the max vector to use
  7047. * @returns true if there is an intersection
  7048. */
  7049. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7050. /**
  7051. * Tests if two bounding boxes are intersections
  7052. * @param box0 defines the first box to test
  7053. * @param box1 defines the second box to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7057. /**
  7058. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7059. * @param minPoint defines the minimum vector of the bounding box
  7060. * @param maxPoint defines the maximum vector of the bounding box
  7061. * @param sphereCenter defines the sphere center
  7062. * @param sphereRadius defines the sphere radius
  7063. * @returns true if there is an intersection
  7064. */
  7065. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7066. /**
  7067. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7068. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @return true if there is an inclusion
  7071. */
  7072. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7075. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7076. * @param frustumPlanes defines the frustum planes to test
  7077. * @return true if there is an intersection
  7078. */
  7079. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7080. }
  7081. }
  7082. declare module BABYLON {
  7083. /** @hidden */
  7084. export class Collider {
  7085. /** Define if a collision was found */
  7086. collisionFound: boolean;
  7087. /**
  7088. * Define last intersection point in local space
  7089. */
  7090. intersectionPoint: Vector3;
  7091. /**
  7092. * Define last collided mesh
  7093. */
  7094. collidedMesh: Nullable<AbstractMesh>;
  7095. private _collisionPoint;
  7096. private _planeIntersectionPoint;
  7097. private _tempVector;
  7098. private _tempVector2;
  7099. private _tempVector3;
  7100. private _tempVector4;
  7101. private _edge;
  7102. private _baseToVertex;
  7103. private _destinationPoint;
  7104. private _slidePlaneNormal;
  7105. private _displacementVector;
  7106. /** @hidden */
  7107. _radius: Vector3;
  7108. /** @hidden */
  7109. _retry: number;
  7110. private _velocity;
  7111. private _basePoint;
  7112. private _epsilon;
  7113. /** @hidden */
  7114. _velocityWorldLength: number;
  7115. /** @hidden */
  7116. _basePointWorld: Vector3;
  7117. private _velocityWorld;
  7118. private _normalizedVelocity;
  7119. /** @hidden */
  7120. _initialVelocity: Vector3;
  7121. /** @hidden */
  7122. _initialPosition: Vector3;
  7123. private _nearestDistance;
  7124. private _collisionMask;
  7125. collisionMask: number;
  7126. /**
  7127. * Gets the plane normal used to compute the sliding response (in local space)
  7128. */
  7129. readonly slidePlaneNormal: Vector3;
  7130. /** @hidden */
  7131. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7132. /** @hidden */
  7133. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7134. /** @hidden */
  7135. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7136. /** @hidden */
  7137. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7138. /** @hidden */
  7139. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7140. /** @hidden */
  7141. _getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */
  7241. _checkCollision(collider: Collider): boolean;
  7242. /**
  7243. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7244. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7245. * @param point the point to check intersection with
  7246. * @returns if the point intersects
  7247. */
  7248. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7249. /**
  7250. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7251. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7252. * @param boundingInfo the bounding info to check intersection with
  7253. * @param precise if the intersection should be done using OBB
  7254. * @returns if the bounding info intersects
  7255. */
  7256. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Defines an array and its length.
  7262. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7263. */
  7264. export interface ISmartArrayLike<T> {
  7265. /**
  7266. * The data of the array.
  7267. */
  7268. data: Array<T>;
  7269. /**
  7270. * The active length of the array.
  7271. */
  7272. length: number;
  7273. }
  7274. /**
  7275. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7276. */
  7277. export class SmartArray<T> implements ISmartArrayLike<T> {
  7278. /**
  7279. * The full set of data from the array.
  7280. */
  7281. data: Array<T>;
  7282. /**
  7283. * The active length of the array.
  7284. */
  7285. length: number;
  7286. protected _id: number;
  7287. /**
  7288. * Instantiates a Smart Array.
  7289. * @param capacity defines the default capacity of the array.
  7290. */
  7291. constructor(capacity: number);
  7292. /**
  7293. * Pushes a value at the end of the active data.
  7294. * @param value defines the object to push in the array.
  7295. */
  7296. push(value: T): void;
  7297. /**
  7298. * Iterates over the active data and apply the lambda to them.
  7299. * @param func defines the action to apply on each value.
  7300. */
  7301. forEach(func: (content: T) => void): void;
  7302. /**
  7303. * Sorts the full sets of data.
  7304. * @param compareFn defines the comparison function to apply.
  7305. */
  7306. sort(compareFn: (a: T, b: T) => number): void;
  7307. /**
  7308. * Resets the active data to an empty array.
  7309. */
  7310. reset(): void;
  7311. /**
  7312. * Releases all the data from the array as well as the array.
  7313. */
  7314. dispose(): void;
  7315. /**
  7316. * Concats the active data with a given array.
  7317. * @param array defines the data to concatenate with.
  7318. */
  7319. concat(array: any): void;
  7320. /**
  7321. * Returns the position of a value in the active data.
  7322. * @param value defines the value to find the index for
  7323. * @returns the index if found in the active data otherwise -1
  7324. */
  7325. indexOf(value: T): number;
  7326. /**
  7327. * Returns whether an element is part of the active data.
  7328. * @param value defines the value to look for
  7329. * @returns true if found in the active data otherwise false
  7330. */
  7331. contains(value: T): boolean;
  7332. private static _GlobalId;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. * The data in this array can only be present once
  7337. */
  7338. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7339. private _duplicateId;
  7340. /**
  7341. * Pushes a value at the end of the active data.
  7342. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7343. * @param value defines the object to push in the array.
  7344. */
  7345. push(value: T): void;
  7346. /**
  7347. * Pushes a value at the end of the active data.
  7348. * If the data is already present, it won t be added again
  7349. * @param value defines the object to push in the array.
  7350. * @returns true if added false if it was already present
  7351. */
  7352. pushNoDuplicate(value: T): boolean;
  7353. /**
  7354. * Resets the active data to an empty array.
  7355. */
  7356. reset(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * This ensures no dupplicate will be present in the result.
  7360. * @param array defines the data to concatenate with.
  7361. */
  7362. concatWithNoDuplicate(array: any): void;
  7363. }
  7364. }
  7365. declare module BABYLON {
  7366. /**
  7367. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7368. * separate meshes. This can be use to improve performances.
  7369. * @see http://doc.babylonjs.com/how_to/multi_materials
  7370. */
  7371. export class MultiMaterial extends Material {
  7372. private _subMaterials;
  7373. /**
  7374. * Gets or Sets the list of Materials used within the multi material.
  7375. * They need to be ordered according to the submeshes order in the associated mesh
  7376. */
  7377. subMaterials: Nullable<Material>[];
  7378. /**
  7379. * Function used to align with Node.getChildren()
  7380. * @returns the list of Materials used within the multi material
  7381. */
  7382. getChildren(): Nullable<Material>[];
  7383. /**
  7384. * Instantiates a new Multi Material
  7385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7386. * separate meshes. This can be use to improve performances.
  7387. * @see http://doc.babylonjs.com/how_to/multi_materials
  7388. * @param name Define the name in the scene
  7389. * @param scene Define the scene the material belongs to
  7390. */
  7391. constructor(name: string, scene: Scene);
  7392. private _hookArray;
  7393. /**
  7394. * Get one of the submaterial by its index in the submaterials array
  7395. * @param index The index to look the sub material at
  7396. * @returns The Material if the index has been defined
  7397. */
  7398. getSubMaterial(index: number): Nullable<Material>;
  7399. /**
  7400. * Get the list of active textures for the whole sub materials list.
  7401. * @returns All the textures that will be used during the rendering
  7402. */
  7403. getActiveTextures(): BaseTexture[];
  7404. /**
  7405. * Gets the current class name of the material e.g. "MultiMaterial"
  7406. * Mainly use in serialization.
  7407. * @returns the class name
  7408. */
  7409. getClassName(): string;
  7410. /**
  7411. * Checks if the material is ready to render the requested sub mesh
  7412. * @param mesh Define the mesh the submesh belongs to
  7413. * @param subMesh Define the sub mesh to look readyness for
  7414. * @param useInstances Define whether or not the material is used with instances
  7415. * @returns true if ready, otherwise false
  7416. */
  7417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7418. /**
  7419. * Clones the current material and its related sub materials
  7420. * @param name Define the name of the newly cloned material
  7421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7422. * @returns the cloned material
  7423. */
  7424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7425. /**
  7426. * Serializes the materials into a JSON representation.
  7427. * @returns the JSON representation
  7428. */
  7429. serialize(): any;
  7430. /**
  7431. * Dispose the material and release its associated resources
  7432. * @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)
  7433. * @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)
  7434. * @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)
  7435. */
  7436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7437. /**
  7438. * Creates a MultiMaterial from parsed MultiMaterial data.
  7439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7440. * @param scene defines the hosting scene
  7441. * @returns a new MultiMaterial
  7442. */
  7443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7444. }
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to represent data loading progression
  7449. */
  7450. export class SceneLoaderFlags {
  7451. private static _ForceFullSceneLoadingForIncremental;
  7452. private static _ShowLoadingScreen;
  7453. private static _CleanBoneMatrixWeights;
  7454. private static _loggingLevel;
  7455. /**
  7456. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7457. */
  7458. static ForceFullSceneLoadingForIncremental: boolean;
  7459. /**
  7460. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7461. */
  7462. static ShowLoadingScreen: boolean;
  7463. /**
  7464. * Defines the current logging level (while loading the scene)
  7465. * @ignorenaming
  7466. */
  7467. static loggingLevel: number;
  7468. /**
  7469. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7470. */
  7471. static CleanBoneMatrixWeights: boolean;
  7472. }
  7473. }
  7474. declare module BABYLON {
  7475. /**
  7476. * 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.
  7477. * @see https://doc.babylonjs.com/how_to/transformnode
  7478. */
  7479. export class TransformNode extends Node {
  7480. /**
  7481. * Object will not rotate to face the camera
  7482. */
  7483. static BILLBOARDMODE_NONE: number;
  7484. /**
  7485. * Object will rotate to face the camera but only on the x axis
  7486. */
  7487. static BILLBOARDMODE_X: number;
  7488. /**
  7489. * Object will rotate to face the camera but only on the y axis
  7490. */
  7491. static BILLBOARDMODE_Y: number;
  7492. /**
  7493. * Object will rotate to face the camera but only on the z axis
  7494. */
  7495. static BILLBOARDMODE_Z: number;
  7496. /**
  7497. * Object will rotate to face the camera
  7498. */
  7499. static BILLBOARDMODE_ALL: number;
  7500. private _forward;
  7501. private _forwardInverted;
  7502. private _up;
  7503. private _right;
  7504. private _rightInverted;
  7505. private _position;
  7506. private _rotation;
  7507. private _rotationQuaternion;
  7508. protected _scaling: Vector3;
  7509. protected _isDirty: boolean;
  7510. private _transformToBoneReferal;
  7511. /**
  7512. * Set the billboard mode. Default is 0.
  7513. *
  7514. * | Value | Type | Description |
  7515. * | --- | --- | --- |
  7516. * | 0 | BILLBOARDMODE_NONE | |
  7517. * | 1 | BILLBOARDMODE_X | |
  7518. * | 2 | BILLBOARDMODE_Y | |
  7519. * | 4 | BILLBOARDMODE_Z | |
  7520. * | 7 | BILLBOARDMODE_ALL | |
  7521. *
  7522. */
  7523. billboardMode: number;
  7524. /**
  7525. * 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
  7526. */
  7527. scalingDeterminant: number;
  7528. /**
  7529. * Sets the distance of the object to max, often used by skybox
  7530. */
  7531. infiniteDistance: boolean;
  7532. /**
  7533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7534. * By default the system will update normals to compensate
  7535. */
  7536. ignoreNonUniformScaling: boolean;
  7537. /** @hidden */
  7538. _poseMatrix: Matrix;
  7539. /** @hidden */
  7540. _localMatrix: Matrix;
  7541. private _absolutePosition;
  7542. private _pivotMatrix;
  7543. private _pivotMatrixInverse;
  7544. protected _postMultiplyPivotMatrix: boolean;
  7545. private _tempMatrix;
  7546. private _tempMatrix2;
  7547. protected _isWorldMatrixFrozen: boolean;
  7548. /** @hidden */
  7549. _indexInSceneTransformNodesArray: number;
  7550. /**
  7551. * An event triggered after the world matrix is updated
  7552. */
  7553. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7554. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7555. /**
  7556. * Gets a string identifying the name of the class
  7557. * @returns "TransformNode" string
  7558. */
  7559. getClassName(): string;
  7560. /**
  7561. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7562. */
  7563. position: Vector3;
  7564. /**
  7565. * 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)).
  7566. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7567. */
  7568. rotation: Vector3;
  7569. /**
  7570. * 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)).
  7571. */
  7572. scaling: Vector3;
  7573. /**
  7574. * 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).
  7575. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7576. */
  7577. rotationQuaternion: Nullable<Quaternion>;
  7578. /**
  7579. * The forward direction of that transform in world space.
  7580. */
  7581. readonly forward: Vector3;
  7582. /**
  7583. * The up direction of that transform in world space.
  7584. */
  7585. readonly up: Vector3;
  7586. /**
  7587. * The right direction of that transform in world space.
  7588. */
  7589. readonly right: Vector3;
  7590. /**
  7591. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7592. * @param matrix the matrix to copy the pose from
  7593. * @returns this TransformNode.
  7594. */
  7595. updatePoseMatrix(matrix: Matrix): TransformNode;
  7596. /**
  7597. * Returns the mesh Pose matrix.
  7598. * @returns the pose matrix
  7599. */
  7600. getPoseMatrix(): Matrix;
  7601. /** @hidden */
  7602. _isSynchronized(): boolean;
  7603. /** @hidden */
  7604. _initCache(): void;
  7605. /**
  7606. * Flag the transform node as dirty (Forcing it to update everything)
  7607. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7608. * @returns this transform node
  7609. */
  7610. markAsDirty(property: string): TransformNode;
  7611. /**
  7612. * Returns the current mesh absolute position.
  7613. * Returns a Vector3.
  7614. */
  7615. readonly absolutePosition: Vector3;
  7616. /**
  7617. * Sets a new matrix to apply before all other transformation
  7618. * @param matrix defines the transform matrix
  7619. * @returns the current TransformNode
  7620. */
  7621. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7622. /**
  7623. * Sets a new pivot matrix to the current node
  7624. * @param matrix defines the new pivot matrix to use
  7625. * @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
  7626. * @returns the current TransformNode
  7627. */
  7628. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7629. /**
  7630. * Returns the mesh pivot matrix.
  7631. * Default : Identity.
  7632. * @returns the matrix
  7633. */
  7634. getPivotMatrix(): Matrix;
  7635. /**
  7636. * Prevents the World matrix to be computed any longer.
  7637. * @returns the TransformNode.
  7638. */
  7639. freezeWorldMatrix(): TransformNode;
  7640. /**
  7641. * Allows back the World matrix computation.
  7642. * @returns the TransformNode.
  7643. */
  7644. unfreezeWorldMatrix(): this;
  7645. /**
  7646. * True if the World matrix has been frozen.
  7647. */
  7648. readonly isWorldMatrixFrozen: boolean;
  7649. /**
  7650. * Retuns the mesh absolute position in the World.
  7651. * @returns a Vector3.
  7652. */
  7653. getAbsolutePosition(): Vector3;
  7654. /**
  7655. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7656. * @param absolutePosition the absolute position to set
  7657. * @returns the TransformNode.
  7658. */
  7659. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7660. /**
  7661. * Sets the mesh position in its local space.
  7662. * @param vector3 the position to set in localspace
  7663. * @returns the TransformNode.
  7664. */
  7665. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7666. /**
  7667. * Returns the mesh position in the local space from the current World matrix values.
  7668. * @returns a new Vector3.
  7669. */
  7670. getPositionExpressedInLocalSpace(): Vector3;
  7671. /**
  7672. * Translates the mesh along the passed Vector3 in its local space.
  7673. * @param vector3 the distance to translate in localspace
  7674. * @returns the TransformNode.
  7675. */
  7676. locallyTranslate(vector3: Vector3): TransformNode;
  7677. private static _lookAtVectorCache;
  7678. /**
  7679. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7680. * @param targetPoint the position (must be in same space as current mesh) to look at
  7681. * @param yawCor optional yaw (y-axis) correction in radians
  7682. * @param pitchCor optional pitch (x-axis) correction in radians
  7683. * @param rollCor optional roll (z-axis) correction in radians
  7684. * @param space the choosen space of the target
  7685. * @returns the TransformNode.
  7686. */
  7687. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7688. /**
  7689. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7690. * This Vector3 is expressed in the World space.
  7691. * @param localAxis axis to rotate
  7692. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7693. */
  7694. getDirection(localAxis: Vector3): Vector3;
  7695. /**
  7696. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7697. * localAxis is expressed in the mesh local space.
  7698. * result is computed in the Wordl space from the mesh World matrix.
  7699. * @param localAxis axis to rotate
  7700. * @param result the resulting transformnode
  7701. * @returns this TransformNode.
  7702. */
  7703. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7704. /**
  7705. * Sets this transform node rotation to the given local axis.
  7706. * @param localAxis the axis in local space
  7707. * @param yawCor optional yaw (y-axis) correction in radians
  7708. * @param pitchCor optional pitch (x-axis) correction in radians
  7709. * @param rollCor optional roll (z-axis) correction in radians
  7710. * @returns this TransformNode
  7711. */
  7712. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7713. /**
  7714. * Sets a new pivot point to the current node
  7715. * @param point defines the new pivot point to use
  7716. * @param space defines if the point is in world or local space (local by default)
  7717. * @returns the current TransformNode
  7718. */
  7719. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7720. /**
  7721. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7722. * @returns the pivot point
  7723. */
  7724. getPivotPoint(): Vector3;
  7725. /**
  7726. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7727. * @param result the vector3 to store the result
  7728. * @returns this TransformNode.
  7729. */
  7730. getPivotPointToRef(result: Vector3): TransformNode;
  7731. /**
  7732. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7733. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7734. */
  7735. getAbsolutePivotPoint(): Vector3;
  7736. /**
  7737. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7738. * @param result vector3 to store the result
  7739. * @returns this TransformNode.
  7740. */
  7741. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7742. /**
  7743. * Defines the passed node as the parent of the current node.
  7744. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7745. * @see https://doc.babylonjs.com/how_to/parenting
  7746. * @param node the node ot set as the parent
  7747. * @returns this TransformNode.
  7748. */
  7749. setParent(node: Nullable<Node>): TransformNode;
  7750. private _nonUniformScaling;
  7751. /**
  7752. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7753. */
  7754. readonly nonUniformScaling: boolean;
  7755. /** @hidden */
  7756. _updateNonUniformScalingState(value: boolean): boolean;
  7757. /**
  7758. * Attach the current TransformNode to another TransformNode associated with a bone
  7759. * @param bone Bone affecting the TransformNode
  7760. * @param affectedTransformNode TransformNode associated with the bone
  7761. * @returns this object
  7762. */
  7763. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7764. /**
  7765. * Detach the transform node if its associated with a bone
  7766. * @returns this object
  7767. */
  7768. detachFromBone(): TransformNode;
  7769. private static _rotationAxisCache;
  7770. /**
  7771. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7772. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7773. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7774. * The passed axis is also normalized.
  7775. * @param axis the axis to rotate around
  7776. * @param amount the amount to rotate in radians
  7777. * @param space Space to rotate in (Default: local)
  7778. * @returns the TransformNode.
  7779. */
  7780. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7781. /**
  7782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7783. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7784. * The passed axis is also normalized. .
  7785. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7786. * @param point the point to rotate around
  7787. * @param axis the axis to rotate around
  7788. * @param amount the amount to rotate in radians
  7789. * @returns the TransformNode
  7790. */
  7791. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7792. /**
  7793. * Translates the mesh along the axis vector for the passed distance in the given space.
  7794. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7795. * @param axis the axis to translate in
  7796. * @param distance the distance to translate
  7797. * @param space Space to rotate in (Default: local)
  7798. * @returns the TransformNode.
  7799. */
  7800. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7801. /**
  7802. * Adds a rotation step to the mesh current rotation.
  7803. * x, y, z are Euler angles expressed in radians.
  7804. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7805. * This means this rotation is made in the mesh local space only.
  7806. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7807. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7808. * ```javascript
  7809. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7810. * ```
  7811. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7812. * 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.
  7813. * @param x Rotation to add
  7814. * @param y Rotation to add
  7815. * @param z Rotation to add
  7816. * @returns the TransformNode.
  7817. */
  7818. addRotation(x: number, y: number, z: number): TransformNode;
  7819. /**
  7820. * Computes the world matrix of the node
  7821. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7822. * @returns the world matrix
  7823. */
  7824. computeWorldMatrix(force?: boolean): Matrix;
  7825. protected _afterComputeWorldMatrix(): void;
  7826. /**
  7827. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7828. * @param func callback function to add
  7829. *
  7830. * @returns the TransformNode.
  7831. */
  7832. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7833. /**
  7834. * Removes a registered callback function.
  7835. * @param func callback function to remove
  7836. * @returns the TransformNode.
  7837. */
  7838. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7839. /**
  7840. * Gets the position of the current mesh in camera space
  7841. * @param camera defines the camera to use
  7842. * @returns a position
  7843. */
  7844. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7845. /**
  7846. * Returns the distance from the mesh to the active camera
  7847. * @param camera defines the camera to use
  7848. * @returns the distance
  7849. */
  7850. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7851. /**
  7852. * Clone the current transform node
  7853. * @param name Name of the new clone
  7854. * @param newParent New parent for the clone
  7855. * @param doNotCloneChildren Do not clone children hierarchy
  7856. * @returns the new transform node
  7857. */
  7858. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7859. /**
  7860. * Serializes the objects information.
  7861. * @param currentSerializationObject defines the object to serialize in
  7862. * @returns the serialized object
  7863. */
  7864. serialize(currentSerializationObject?: any): any;
  7865. /**
  7866. * Returns a new TransformNode object parsed from the source provided.
  7867. * @param parsedTransformNode is the source.
  7868. * @param scene the scne the object belongs to
  7869. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7870. * @returns a new TransformNode object parsed from the source provided.
  7871. */
  7872. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7873. /**
  7874. * Get all child-transformNodes of this node
  7875. * @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
  7876. * @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
  7877. * @returns an array of TransformNode
  7878. */
  7879. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7880. /**
  7881. * Releases resources associated with this transform node.
  7882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7884. */
  7885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7886. }
  7887. }
  7888. declare module BABYLON {
  7889. /**
  7890. * Class used to override all child animations of a given target
  7891. */
  7892. export class AnimationPropertiesOverride {
  7893. /**
  7894. * Gets or sets a value indicating if animation blending must be used
  7895. */
  7896. enableBlending: boolean;
  7897. /**
  7898. * Gets or sets the blending speed to use when enableBlending is true
  7899. */
  7900. blendingSpeed: number;
  7901. /**
  7902. * Gets or sets the default loop mode to use
  7903. */
  7904. loopMode: number;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * Class used to store bone information
  7910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7911. */
  7912. export class Bone extends Node {
  7913. /**
  7914. * defines the bone name
  7915. */
  7916. name: string;
  7917. private static _tmpVecs;
  7918. private static _tmpQuat;
  7919. private static _tmpMats;
  7920. /**
  7921. * Gets the list of child bones
  7922. */
  7923. children: Bone[];
  7924. /** Gets the animations associated with this bone */
  7925. animations: Animation[];
  7926. /**
  7927. * Gets or sets bone length
  7928. */
  7929. length: number;
  7930. /**
  7931. * @hidden Internal only
  7932. * Set this value to map this bone to a different index in the transform matrices
  7933. * Set this value to -1 to exclude the bone from the transform matrices
  7934. */
  7935. _index: Nullable<number>;
  7936. private _skeleton;
  7937. private _localMatrix;
  7938. private _restPose;
  7939. private _baseMatrix;
  7940. private _absoluteTransform;
  7941. private _invertedAbsoluteTransform;
  7942. private _parent;
  7943. private _scalingDeterminant;
  7944. private _worldTransform;
  7945. private _localScaling;
  7946. private _localRotation;
  7947. private _localPosition;
  7948. private _needToDecompose;
  7949. private _needToCompose;
  7950. /** @hidden */
  7951. _linkedTransformNode: Nullable<TransformNode>;
  7952. /** @hidden */
  7953. /** @hidden */
  7954. _matrix: Matrix;
  7955. /**
  7956. * Create a new bone
  7957. * @param name defines the bone name
  7958. * @param skeleton defines the parent skeleton
  7959. * @param parentBone defines the parent (can be null if the bone is the root)
  7960. * @param localMatrix defines the local matrix
  7961. * @param restPose defines the rest pose matrix
  7962. * @param baseMatrix defines the base matrix
  7963. * @param index defines index of the bone in the hiearchy
  7964. */
  7965. constructor(
  7966. /**
  7967. * defines the bone name
  7968. */
  7969. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7970. /**
  7971. * Gets the current object class name.
  7972. * @return the class name
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Gets the parent skeleton
  7977. * @returns a skeleton
  7978. */
  7979. getSkeleton(): Skeleton;
  7980. /**
  7981. * Gets parent bone
  7982. * @returns a bone or null if the bone is the root of the bone hierarchy
  7983. */
  7984. getParent(): Nullable<Bone>;
  7985. /**
  7986. * Returns an array containing the root bones
  7987. * @returns an array containing the root bones
  7988. */
  7989. getChildren(): Array<Bone>;
  7990. /**
  7991. * Sets the parent bone
  7992. * @param parent defines the parent (can be null if the bone is the root)
  7993. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7994. */
  7995. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7996. /**
  7997. * Gets the local matrix
  7998. * @returns a matrix
  7999. */
  8000. getLocalMatrix(): Matrix;
  8001. /**
  8002. * Gets the base matrix (initial matrix which remains unchanged)
  8003. * @returns a matrix
  8004. */
  8005. getBaseMatrix(): Matrix;
  8006. /**
  8007. * Gets the rest pose matrix
  8008. * @returns a matrix
  8009. */
  8010. getRestPose(): Matrix;
  8011. /**
  8012. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8013. */
  8014. getWorldMatrix(): Matrix;
  8015. /**
  8016. * Sets the local matrix to rest pose matrix
  8017. */
  8018. returnToRest(): void;
  8019. /**
  8020. * Gets the inverse of the absolute transform matrix.
  8021. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8022. * @returns a matrix
  8023. */
  8024. getInvertedAbsoluteTransform(): Matrix;
  8025. /**
  8026. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8027. * @returns a matrix
  8028. */
  8029. getAbsoluteTransform(): Matrix;
  8030. /**
  8031. * Links with the given transform node.
  8032. * The local matrix of this bone is copied from the transform node every frame.
  8033. * @param transformNode defines the transform node to link to
  8034. */
  8035. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8036. /** Gets or sets current position (in local space) */
  8037. position: Vector3;
  8038. /** Gets or sets current rotation (in local space) */
  8039. rotation: Vector3;
  8040. /** Gets or sets current rotation quaternion (in local space) */
  8041. rotationQuaternion: Quaternion;
  8042. /** Gets or sets current scaling (in local space) */
  8043. scaling: Vector3;
  8044. /**
  8045. * Gets the animation properties override
  8046. */
  8047. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8048. private _decompose;
  8049. private _compose;
  8050. /**
  8051. * Update the base and local matrices
  8052. * @param matrix defines the new base or local matrix
  8053. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8054. * @param updateLocalMatrix defines if the local matrix should be updated
  8055. */
  8056. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8057. /** @hidden */
  8058. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8059. /**
  8060. * Flag the bone as dirty (Forcing it to update everything)
  8061. */
  8062. markAsDirty(): void;
  8063. private _markAsDirtyAndCompose;
  8064. private _markAsDirtyAndDecompose;
  8065. /**
  8066. * Translate the bone in local or world space
  8067. * @param vec The amount to translate the bone
  8068. * @param space The space that the translation is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the postion of the bone in local or world space
  8074. * @param position The position to set the bone
  8075. * @param space The space that the position is in
  8076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8077. */
  8078. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8079. /**
  8080. * Set the absolute position of the bone (world space)
  8081. * @param position The position to set the bone
  8082. * @param mesh The mesh that this bone is attached to
  8083. */
  8084. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8085. /**
  8086. * Scale the bone on the x, y and z axes (in local space)
  8087. * @param x The amount to scale the bone on the x axis
  8088. * @param y The amount to scale the bone on the y axis
  8089. * @param z The amount to scale the bone on the z axis
  8090. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8091. */
  8092. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8093. /**
  8094. * Set the bone scaling in local space
  8095. * @param scale defines the scaling vector
  8096. */
  8097. setScale(scale: Vector3): void;
  8098. /**
  8099. * Gets the current scaling in local space
  8100. * @returns the current scaling vector
  8101. */
  8102. getScale(): Vector3;
  8103. /**
  8104. * Gets the current scaling in local space and stores it in a target vector
  8105. * @param result defines the target vector
  8106. */
  8107. getScaleToRef(result: Vector3): void;
  8108. /**
  8109. * Set the yaw, pitch, and roll of the bone in local or world space
  8110. * @param yaw The rotation of the bone on the y axis
  8111. * @param pitch The rotation of the bone on the x axis
  8112. * @param roll The rotation of the bone on the z axis
  8113. * @param space The space that the axes of rotation are in
  8114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8115. */
  8116. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8117. /**
  8118. * Add a rotation to the bone on an axis in local or world space
  8119. * @param axis The axis to rotate the bone on
  8120. * @param amount The amount to rotate the bone
  8121. * @param space The space that the axis is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8125. /**
  8126. * Set the rotation of the bone to a particular axis angle in local or world space
  8127. * @param axis The axis to rotate the bone on
  8128. * @param angle The angle that the bone should be rotated to
  8129. * @param space The space that the axis is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the euler rotation of the bone in local of world space
  8135. * @param rotation The euler rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the quaternion rotation of the bone in local of world space
  8142. * @param quat The quaternion rotation that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8147. /**
  8148. * Set the rotation matrix of the bone in local of world space
  8149. * @param rotMat The rotation matrix that the bone should be set to
  8150. * @param space The space that the rotation is in
  8151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8152. */
  8153. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8154. private _rotateWithMatrix;
  8155. private _getNegativeRotationToRef;
  8156. /**
  8157. * Get the position of the bone in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @returns The position of the bone
  8161. */
  8162. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8163. /**
  8164. * Copy the position of the bone to a vector3 in local or world space
  8165. * @param space The space that the returned position is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. * @param result The vector3 to copy the position to
  8168. */
  8169. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8170. /**
  8171. * Get the absolute position of the bone (world space)
  8172. * @param mesh The mesh that this bone is attached to
  8173. * @returns The absolute position of the bone
  8174. */
  8175. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8176. /**
  8177. * Copy the absolute position of the bone (world space) to the result param
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 to copy the absolute position to
  8180. */
  8181. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8182. /**
  8183. * Compute the absolute transforms of this bone and its children
  8184. */
  8185. computeAbsoluteTransforms(): void;
  8186. /**
  8187. * Get the world direction from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @returns The world direction
  8191. */
  8192. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8193. /**
  8194. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8195. * @param localAxis The local direction that is used to compute the world direction
  8196. * @param mesh The mesh that this bone is attached to
  8197. * @param result The vector3 that the world direction will be copied to
  8198. */
  8199. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8200. /**
  8201. * Get the euler rotation of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The euler rotation
  8205. */
  8206. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 that the rotation should be copied to
  8212. */
  8213. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8214. /**
  8215. * Get the quaternion rotation of the bone in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @returns The quaternion rotation
  8219. */
  8220. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8221. /**
  8222. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @param result The quaternion that the rotation should be copied to
  8226. */
  8227. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8228. /**
  8229. * Get the rotation matrix of the bone in local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @returns The rotation matrix
  8233. */
  8234. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8235. /**
  8236. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8237. * @param space The space that the rotation should be in
  8238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8239. * @param result The quaternion that the rotation should be copied to
  8240. */
  8241. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @returns The world position
  8247. */
  8248. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8249. /**
  8250. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8251. * @param position The local position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @param result The vector3 that the world position should be copied to
  8254. */
  8255. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8256. /**
  8257. * Get the local position of a point that is in world space
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @returns The local position
  8261. */
  8262. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8263. /**
  8264. * Get the local position of a point that is in world space and copy it to the result param
  8265. * @param position The world position
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @param result The vector3 that the local position should be copied to
  8268. */
  8269. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8270. }
  8271. }
  8272. declare module BABYLON {
  8273. /**
  8274. * Enum that determines the text-wrapping mode to use.
  8275. */
  8276. export enum InspectableType {
  8277. /**
  8278. * Checkbox for booleans
  8279. */
  8280. Checkbox = 0,
  8281. /**
  8282. * Sliders for numbers
  8283. */
  8284. Slider = 1,
  8285. /**
  8286. * Vector3
  8287. */
  8288. Vector3 = 2,
  8289. /**
  8290. * Quaternions
  8291. */
  8292. Quaternion = 3,
  8293. /**
  8294. * Color3
  8295. */
  8296. Color3 = 4
  8297. }
  8298. /**
  8299. * Interface used to define custom inspectable properties.
  8300. * This interface is used by the inspector to display custom property grids
  8301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8302. */
  8303. export interface IInspectable {
  8304. /**
  8305. * Gets the label to display
  8306. */
  8307. label: string;
  8308. /**
  8309. * Gets the name of the property to edit
  8310. */
  8311. propertyName: string;
  8312. /**
  8313. * Gets the type of the editor to use
  8314. */
  8315. type: InspectableType;
  8316. /**
  8317. * Gets the minimum value of the property when using in "slider" mode
  8318. */
  8319. min?: number;
  8320. /**
  8321. * Gets the maximum value of the property when using in "slider" mode
  8322. */
  8323. max?: number;
  8324. /**
  8325. * Gets the setp to use when using in "slider" mode
  8326. */
  8327. step?: number;
  8328. }
  8329. }
  8330. declare module BABYLON {
  8331. /**
  8332. * Class for creating a cube texture
  8333. */
  8334. export class CubeTexture extends BaseTexture {
  8335. private _delayedOnLoad;
  8336. /**
  8337. * The url of the texture
  8338. */
  8339. url: string;
  8340. /**
  8341. * Gets or sets the center of the bounding box associated with the cube texture.
  8342. * It must define where the camera used to render the texture was set
  8343. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8344. */
  8345. boundingBoxPosition: Vector3;
  8346. private _boundingBoxSize;
  8347. /**
  8348. * Gets or sets the size of the bounding box associated with the cube texture
  8349. * When defined, the cubemap will switch to local mode
  8350. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8351. * @example https://www.babylonjs-playground.com/#RNASML
  8352. */
  8353. /**
  8354. * Returns the bounding box size
  8355. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8356. */
  8357. boundingBoxSize: Vector3;
  8358. protected _rotationY: number;
  8359. /**
  8360. * Sets texture matrix rotation angle around Y axis in radians.
  8361. */
  8362. /**
  8363. * Gets texture matrix rotation angle around Y axis radians.
  8364. */
  8365. rotationY: number;
  8366. /**
  8367. * Are mip maps generated for this texture or not.
  8368. */
  8369. readonly noMipmap: boolean;
  8370. private _noMipmap;
  8371. private _files;
  8372. private _extensions;
  8373. private _textureMatrix;
  8374. private _format;
  8375. private _createPolynomials;
  8376. /** @hidden */
  8377. _prefiltered: boolean;
  8378. /**
  8379. * Creates a cube texture from an array of image urls
  8380. * @param files defines an array of image urls
  8381. * @param scene defines the hosting scene
  8382. * @param noMipmap specifies if mip maps are not used
  8383. * @returns a cube texture
  8384. */
  8385. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8386. /**
  8387. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8388. * @param url defines the url of the prefiltered texture
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param forcedExtension defines the extension of the file if different from the url
  8391. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8392. * @return the prefiltered texture
  8393. */
  8394. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8395. /**
  8396. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8397. * as prefiltered data.
  8398. * @param rootUrl defines the url of the texture or the root name of the six images
  8399. * @param scene defines the scene the texture is attached to
  8400. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8401. * @param noMipmap defines if mipmaps should be created or not
  8402. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8403. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8404. * @param onError defines a callback triggered in case of error during load
  8405. * @param format defines the internal format to use for the texture once loaded
  8406. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8407. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8408. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8411. * @return the cube texture
  8412. */
  8413. 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);
  8414. /**
  8415. * Get the current class name of the texture useful for serialization or dynamic coding.
  8416. * @returns "CubeTexture"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Update the url (and optional buffer) of this texture if url was null during construction.
  8421. * @param url the url of the texture
  8422. * @param forcedExtension defines the extension to use
  8423. * @param onLoad callback called when the texture is loaded (defaults to null)
  8424. */
  8425. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8426. /**
  8427. * Delays loading of the cube texture
  8428. * @param forcedExtension defines the extension to use
  8429. */
  8430. delayLoad(forcedExtension?: string): void;
  8431. /**
  8432. * Returns the reflection texture matrix
  8433. * @returns the reflection texture matrix
  8434. */
  8435. getReflectionTextureMatrix(): Matrix;
  8436. /**
  8437. * Sets the reflection texture matrix
  8438. * @param value Reflection texture matrix
  8439. */
  8440. setReflectionTextureMatrix(value: Matrix): void;
  8441. /**
  8442. * Parses text to create a cube texture
  8443. * @param parsedTexture define the serialized text to read from
  8444. * @param scene defines the hosting scene
  8445. * @param rootUrl defines the root url of the cube texture
  8446. * @returns a cube texture
  8447. */
  8448. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8449. /**
  8450. * Makes a clone, or deep copy, of the cube texture
  8451. * @returns a new cube texture
  8452. */
  8453. clone(): CubeTexture;
  8454. }
  8455. }
  8456. declare module BABYLON {
  8457. /** @hidden */
  8458. export var postprocessVertexShader: {
  8459. name: string;
  8460. shader: string;
  8461. };
  8462. }
  8463. declare module BABYLON {
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * This will automatically adapt alpha beta and radius to fit within the new target.
  8571. * @param target Defines the new target as a Vector or a mesh
  8572. */
  8573. setTarget(target: Vector3): void;
  8574. /**
  8575. * Return the current target position of the camera. This value is expressed in local space.
  8576. * @returns the target position
  8577. */
  8578. getTarget(): Vector3;
  8579. /** @hidden */
  8580. _decideIfNeedsToMove(): boolean;
  8581. /** @hidden */
  8582. _updatePosition(): void;
  8583. /** @hidden */
  8584. _checkInputs(): void;
  8585. protected _updateCameraRotationMatrix(): void;
  8586. /**
  8587. * 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)
  8588. * @returns the current camera
  8589. */
  8590. private _rotateUpVectorWithCameraRotationMatrix;
  8591. private _cachedRotationZ;
  8592. private _cachedQuaternionRotationZ;
  8593. /** @hidden */
  8594. _getViewMatrix(): Matrix;
  8595. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8596. /**
  8597. * @hidden
  8598. */
  8599. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8600. /**
  8601. * @hidden
  8602. */
  8603. _updateRigCameras(): void;
  8604. private _getRigCamPositionAndTarget;
  8605. /**
  8606. * Gets the current object class name.
  8607. * @return the class name
  8608. */
  8609. getClassName(): string;
  8610. }
  8611. }
  8612. declare module BABYLON {
  8613. /**
  8614. * @ignore
  8615. * This is a list of all the different input types that are available in the application.
  8616. * Fo instance: ArcRotateCameraGamepadInput...
  8617. */
  8618. export var CameraInputTypes: {};
  8619. /**
  8620. * This is the contract to implement in order to create a new input class.
  8621. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8622. */
  8623. export interface ICameraInput<TCamera extends Camera> {
  8624. /**
  8625. * Defines the camera the input is attached to.
  8626. */
  8627. camera: Nullable<TCamera>;
  8628. /**
  8629. * Gets the class name of the current intput.
  8630. * @returns the class name
  8631. */
  8632. getClassName(): string;
  8633. /**
  8634. * Get the friendly name associated with the input class.
  8635. * @returns the input friendly name
  8636. */
  8637. getSimpleName(): string;
  8638. /**
  8639. * Attach the input controls to a specific dom element to get the input from.
  8640. * @param element Defines the element the controls should be listened from
  8641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8642. */
  8643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8644. /**
  8645. * Detach the current controls from the specified dom element.
  8646. * @param element Defines the element to stop listening the inputs from
  8647. */
  8648. detachControl(element: Nullable<HTMLElement>): void;
  8649. /**
  8650. * Update the current camera state depending on the inputs that have been used this frame.
  8651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8652. */
  8653. checkInputs?: () => void;
  8654. }
  8655. /**
  8656. * Represents a map of input types to input instance or input index to input instance.
  8657. */
  8658. export interface CameraInputsMap<TCamera extends Camera> {
  8659. /**
  8660. * Accessor to the input by input type.
  8661. */
  8662. [name: string]: ICameraInput<TCamera>;
  8663. /**
  8664. * Accessor to the input by input index.
  8665. */
  8666. [idx: number]: ICameraInput<TCamera>;
  8667. }
  8668. /**
  8669. * This represents the input manager used within a camera.
  8670. * It helps dealing with all the different kind of input attached to a camera.
  8671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8672. */
  8673. export class CameraInputsManager<TCamera extends Camera> {
  8674. /**
  8675. * Defines the list of inputs attahed to the camera.
  8676. */
  8677. attached: CameraInputsMap<TCamera>;
  8678. /**
  8679. * Defines the dom element the camera is collecting inputs from.
  8680. * This is null if the controls have not been attached.
  8681. */
  8682. attachedElement: Nullable<HTMLElement>;
  8683. /**
  8684. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8685. */
  8686. noPreventDefault: boolean;
  8687. /**
  8688. * Defined the camera the input manager belongs to.
  8689. */
  8690. camera: TCamera;
  8691. /**
  8692. * Update the current camera state depending on the inputs that have been used this frame.
  8693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8694. */
  8695. checkInputs: () => void;
  8696. /**
  8697. * Instantiate a new Camera Input Manager.
  8698. * @param camera Defines the camera the input manager blongs to
  8699. */
  8700. constructor(camera: TCamera);
  8701. /**
  8702. * Add an input method to a camera
  8703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8704. * @param input camera input method
  8705. */
  8706. add(input: ICameraInput<TCamera>): void;
  8707. /**
  8708. * Remove a specific input method from a camera
  8709. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8710. * @param inputToRemove camera input method
  8711. */
  8712. remove(inputToRemove: ICameraInput<TCamera>): void;
  8713. /**
  8714. * Remove a specific input type from a camera
  8715. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8716. * @param inputType the type of the input to remove
  8717. */
  8718. removeByType(inputType: string): void;
  8719. private _addCheckInputs;
  8720. /**
  8721. * Attach the input controls to the currently attached dom element to listen the events from.
  8722. * @param input Defines the input to attach
  8723. */
  8724. attachInput(input: ICameraInput<TCamera>): void;
  8725. /**
  8726. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8727. * @param element Defines the dom element to collect the events from
  8728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8729. */
  8730. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8731. /**
  8732. * Detach the current manager inputs controls from a specific dom element.
  8733. * @param element Defines the dom element to collect the events from
  8734. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8735. */
  8736. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8737. /**
  8738. * Rebuild the dynamic inputCheck function from the current list of
  8739. * defined inputs in the manager.
  8740. */
  8741. rebuildInputCheck(): void;
  8742. /**
  8743. * Remove all attached input methods from a camera
  8744. */
  8745. clear(): void;
  8746. /**
  8747. * Serialize the current input manager attached to a camera.
  8748. * This ensures than once parsed,
  8749. * the input associated to the camera will be identical to the current ones
  8750. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8751. */
  8752. serialize(serializedCamera: any): void;
  8753. /**
  8754. * Parses an input manager serialized JSON to restore the previous list of inputs
  8755. * and states associated to a camera.
  8756. * @param parsedCamera Defines the JSON to parse
  8757. */
  8758. parse(parsedCamera: any): void;
  8759. }
  8760. }
  8761. declare module BABYLON {
  8762. /**
  8763. * Gather the list of keyboard event types as constants.
  8764. */
  8765. export class KeyboardEventTypes {
  8766. /**
  8767. * The keydown event is fired when a key becomes active (pressed).
  8768. */
  8769. static readonly KEYDOWN: number;
  8770. /**
  8771. * The keyup event is fired when a key has been released.
  8772. */
  8773. static readonly KEYUP: number;
  8774. }
  8775. /**
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. */
  8778. export class KeyboardInfo {
  8779. /**
  8780. * Defines the type of event (KeyboardEventTypes)
  8781. */
  8782. type: number;
  8783. /**
  8784. * Defines the related dom event
  8785. */
  8786. event: KeyboardEvent;
  8787. /**
  8788. * Instantiates a new keyboard info.
  8789. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8790. * @param type Defines the type of event (KeyboardEventTypes)
  8791. * @param event Defines the related dom event
  8792. */
  8793. constructor(
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number,
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent);
  8802. }
  8803. /**
  8804. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8805. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8806. */
  8807. export class KeyboardInfoPre extends KeyboardInfo {
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number;
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent;
  8816. /**
  8817. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8818. */
  8819. skipOnPointerObservable: boolean;
  8820. /**
  8821. * Instantiates a new keyboard pre info.
  8822. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8823. * @param type Defines the type of event (KeyboardEventTypes)
  8824. * @param event Defines the related dom event
  8825. */
  8826. constructor(
  8827. /**
  8828. * Defines the type of event (KeyboardEventTypes)
  8829. */
  8830. type: number,
  8831. /**
  8832. * Defines the related dom event
  8833. */
  8834. event: KeyboardEvent);
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Manage the keyboard inputs to control the movement of a free camera.
  8840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8841. */
  8842. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8843. /**
  8844. * Defines the camera the input is attached to.
  8845. */
  8846. camera: FreeCamera;
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8849. */
  8850. keysUp: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8853. */
  8854. keysDown: number[];
  8855. /**
  8856. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8857. */
  8858. keysLeft: number[];
  8859. /**
  8860. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8861. */
  8862. keysRight: number[];
  8863. private _keys;
  8864. private _onCanvasBlurObserver;
  8865. private _onKeyboardObserver;
  8866. private _engine;
  8867. private _scene;
  8868. /**
  8869. * Attach the input controls to a specific dom element to get the input from.
  8870. * @param element Defines the element the controls should be listened from
  8871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8872. */
  8873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8874. /**
  8875. * Detach the current controls from the specified dom element.
  8876. * @param element Defines the element to stop listening the inputs from
  8877. */
  8878. detachControl(element: Nullable<HTMLElement>): void;
  8879. /**
  8880. * Update the current camera state depending on the inputs that have been used this frame.
  8881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8882. */
  8883. checkInputs(): void;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /** @hidden */
  8890. _onLostFocus(): void;
  8891. /**
  8892. * Get the friendly name associated with the input class.
  8893. * @returns the input friendly name
  8894. */
  8895. getSimpleName(): string;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * Interface describing all the common properties and methods a shadow light needs to implement.
  8901. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8902. * as well as binding the different shadow properties to the effects.
  8903. */
  8904. export interface IShadowLight extends Light {
  8905. /**
  8906. * The light id in the scene (used in scene.findLighById for instance)
  8907. */
  8908. id: string;
  8909. /**
  8910. * The position the shdow will be casted from.
  8911. */
  8912. position: Vector3;
  8913. /**
  8914. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8915. */
  8916. direction: Vector3;
  8917. /**
  8918. * The transformed position. Position of the light in world space taking parenting in account.
  8919. */
  8920. transformedPosition: Vector3;
  8921. /**
  8922. * The transformed direction. Direction of the light in world space taking parenting in account.
  8923. */
  8924. transformedDirection: Vector3;
  8925. /**
  8926. * The friendly name of the light in the scene.
  8927. */
  8928. name: string;
  8929. /**
  8930. * Defines the shadow projection clipping minimum z value.
  8931. */
  8932. shadowMinZ: number;
  8933. /**
  8934. * Defines the shadow projection clipping maximum z value.
  8935. */
  8936. shadowMaxZ: number;
  8937. /**
  8938. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8939. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8940. */
  8941. computeTransformedInformation(): boolean;
  8942. /**
  8943. * Gets the scene the light belongs to.
  8944. * @returns The scene
  8945. */
  8946. getScene(): Scene;
  8947. /**
  8948. * Callback defining a custom Projection Matrix Builder.
  8949. * This can be used to override the default projection matrix computation.
  8950. */
  8951. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8952. /**
  8953. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8954. * @param matrix The materix to updated with the projection information
  8955. * @param viewMatrix The transform matrix of the light
  8956. * @param renderList The list of mesh to render in the map
  8957. * @returns The current light
  8958. */
  8959. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8960. /**
  8961. * Gets the current depth scale used in ESM.
  8962. * @returns The scale
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8967. * @returns true if a cube texture needs to be use
  8968. */
  8969. needCube(): boolean;
  8970. /**
  8971. * Detects if the projection matrix requires to be recomputed this frame.
  8972. * @returns true if it requires to be recomputed otherwise, false.
  8973. */
  8974. needProjectionMatrixCompute(): boolean;
  8975. /**
  8976. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8977. */
  8978. forceProjectionMatrixCompute(): void;
  8979. /**
  8980. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8983. */
  8984. getShadowDirection(faceIndex?: number): Vector3;
  8985. /**
  8986. * Gets the minZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the min for
  8988. * @returns the depth min z
  8989. */
  8990. getDepthMinZ(activeCamera: Camera): number;
  8991. /**
  8992. * Gets the maxZ used for shadow according to both the scene and the light.
  8993. * @param activeCamera The camera we are returning the max for
  8994. * @returns the depth max z
  8995. */
  8996. getDepthMaxZ(activeCamera: Camera): number;
  8997. }
  8998. /**
  8999. * Base implementation IShadowLight
  9000. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9001. */
  9002. export abstract class ShadowLight extends Light implements IShadowLight {
  9003. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9004. protected _position: Vector3;
  9005. protected _setPosition(value: Vector3): void;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. position: Vector3;
  9015. protected _direction: Vector3;
  9016. protected _setDirection(value: Vector3): void;
  9017. /**
  9018. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. /**
  9022. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. direction: Vector3;
  9026. private _shadowMinZ;
  9027. /**
  9028. * Gets the shadow projection clipping minimum z value.
  9029. */
  9030. /**
  9031. * Sets the shadow projection clipping minimum z value.
  9032. */
  9033. shadowMinZ: number;
  9034. private _shadowMaxZ;
  9035. /**
  9036. * Sets the shadow projection clipping maximum z value.
  9037. */
  9038. /**
  9039. * Gets the shadow projection clipping maximum z value.
  9040. */
  9041. shadowMaxZ: number;
  9042. /**
  9043. * Callback defining a custom Projection Matrix Builder.
  9044. * This can be used to override the default projection matrix computation.
  9045. */
  9046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9047. /**
  9048. * The transformed position. Position of the light in world space taking parenting in account.
  9049. */
  9050. transformedPosition: Vector3;
  9051. /**
  9052. * The transformed direction. Direction of the light in world space taking parenting in account.
  9053. */
  9054. transformedDirection: Vector3;
  9055. private _needProjectionMatrixCompute;
  9056. /**
  9057. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9058. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9059. */
  9060. computeTransformedInformation(): boolean;
  9061. /**
  9062. * Return the depth scale used for the shadow map.
  9063. * @returns the depth scale.
  9064. */
  9065. getDepthScale(): number;
  9066. /**
  9067. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9068. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9069. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9070. */
  9071. getShadowDirection(faceIndex?: number): Vector3;
  9072. /**
  9073. * Returns the ShadowLight absolute position in the World.
  9074. * @returns the position vector in world space
  9075. */
  9076. getAbsolutePosition(): Vector3;
  9077. /**
  9078. * Sets the ShadowLight direction toward the passed target.
  9079. * @param target The point to target in local space
  9080. * @returns the updated ShadowLight direction
  9081. */
  9082. setDirectionToTarget(target: Vector3): Vector3;
  9083. /**
  9084. * Returns the light rotation in euler definition.
  9085. * @returns the x y z rotation in local space.
  9086. */
  9087. getRotation(): Vector3;
  9088. /**
  9089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9090. * @returns true if a cube texture needs to be use
  9091. */
  9092. needCube(): boolean;
  9093. /**
  9094. * Detects if the projection matrix requires to be recomputed this frame.
  9095. * @returns true if it requires to be recomputed otherwise, false.
  9096. */
  9097. needProjectionMatrixCompute(): boolean;
  9098. /**
  9099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9100. */
  9101. forceProjectionMatrixCompute(): void;
  9102. /** @hidden */
  9103. _initCache(): void;
  9104. /** @hidden */
  9105. _isSynchronized(): boolean;
  9106. /**
  9107. * Computes the world matrix of the node
  9108. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9109. * @returns the world matrix
  9110. */
  9111. computeWorldMatrix(force?: boolean): Matrix;
  9112. /**
  9113. * Gets the minZ used for shadow according to both the scene and the light.
  9114. * @param activeCamera The camera we are returning the min for
  9115. * @returns the depth min z
  9116. */
  9117. getDepthMinZ(activeCamera: Camera): number;
  9118. /**
  9119. * Gets the maxZ used for shadow according to both the scene and the light.
  9120. * @param activeCamera The camera we are returning the max for
  9121. * @returns the depth max z
  9122. */
  9123. getDepthMaxZ(activeCamera: Camera): number;
  9124. /**
  9125. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9126. * @param matrix The materix to updated with the projection information
  9127. * @param viewMatrix The transform matrix of the light
  9128. * @param renderList The list of mesh to render in the map
  9129. * @returns The current light
  9130. */
  9131. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9132. }
  9133. }
  9134. declare module BABYLON {
  9135. /**
  9136. * "Static Class" containing the most commonly used helper while dealing with material for
  9137. * rendering purpose.
  9138. *
  9139. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9140. *
  9141. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9142. */
  9143. export class MaterialHelper {
  9144. /**
  9145. * Bind the current view position to an effect.
  9146. * @param effect The effect to be bound
  9147. * @param scene The scene the eyes position is used from
  9148. */
  9149. static BindEyePosition(effect: Effect, scene: Scene): void;
  9150. /**
  9151. * Helps preparing the defines values about the UVs in used in the effect.
  9152. * UVs are shared as much as we can accross channels in the shaders.
  9153. * @param texture The texture we are preparing the UVs for
  9154. * @param defines The defines to update
  9155. * @param key The channel key "diffuse", "specular"... used in the shader
  9156. */
  9157. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9158. /**
  9159. * Binds a texture matrix value to its corrsponding uniform
  9160. * @param texture The texture to bind the matrix for
  9161. * @param uniformBuffer The uniform buffer receivin the data
  9162. * @param key The channel key "diffuse", "specular"... used in the shader
  9163. */
  9164. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9165. /**
  9166. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9167. * @param mesh defines the current mesh
  9168. * @param scene defines the current scene
  9169. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9170. * @param pointsCloud defines if point cloud rendering has to be turned on
  9171. * @param fogEnabled defines if fog has to be turned on
  9172. * @param alphaTest defines if alpha testing has to be turned on
  9173. * @param defines defines the current list of defines
  9174. */
  9175. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9176. /**
  9177. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9178. * @param scene defines the current scene
  9179. * @param engine defines the current engine
  9180. * @param defines specifies the list of active defines
  9181. * @param useInstances defines if instances have to be turned on
  9182. * @param useClipPlane defines if clip plane have to be turned on
  9183. */
  9184. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9185. /**
  9186. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9187. * @param mesh The mesh containing the geometry data we will draw
  9188. * @param defines The defines to update
  9189. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9190. * @param useBones Precise whether bones should be used or not (override mesh info)
  9191. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9192. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9193. * @returns false if defines are considered not dirty and have not been checked
  9194. */
  9195. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9196. /**
  9197. * Prepares the defines related to multiview
  9198. * @param scene The scene we are intending to draw
  9199. * @param defines The defines to update
  9200. */
  9201. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9202. /**
  9203. * Prepares the defines related to the light information passed in parameter
  9204. * @param scene The scene we are intending to draw
  9205. * @param mesh The mesh the effect is compiling for
  9206. * @param defines The defines to update
  9207. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9208. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9209. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9210. * @returns true if normals will be required for the rest of the effect
  9211. */
  9212. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9213. /**
  9214. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9215. * that won t be acctive due to defines being turned off.
  9216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9217. * @param samplersList The samplers list
  9218. * @param defines The defines helping in the list generation
  9219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9220. */
  9221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9222. /**
  9223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9224. * @param defines The defines to update while falling back
  9225. * @param fallbacks The authorized effect fallbacks
  9226. * @param maxSimultaneousLights The maximum number of lights allowed
  9227. * @param rank the current rank of the Effect
  9228. * @returns The newly affected rank
  9229. */
  9230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9231. /**
  9232. * Prepares the list of attributes required for morph targets according to the effect defines.
  9233. * @param attribs The current list of supported attribs
  9234. * @param mesh The mesh to prepare the morph targets attributes for
  9235. * @param defines The current Defines of the effect
  9236. */
  9237. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9238. /**
  9239. * Prepares the list of attributes required for bones according to the effect defines.
  9240. * @param attribs The current list of supported attribs
  9241. * @param mesh The mesh to prepare the bones attributes for
  9242. * @param defines The current Defines of the effect
  9243. * @param fallbacks The current efffect fallback strategy
  9244. */
  9245. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9246. /**
  9247. * Prepares the list of attributes required for instances according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param defines The current Defines of the effect
  9250. */
  9251. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9252. /**
  9253. * Binds the light shadow information to the effect for the given mesh.
  9254. * @param light The light containing the generator
  9255. * @param scene The scene the lights belongs to
  9256. * @param mesh The mesh we are binding the information to render
  9257. * @param lightIndex The light index in the effect used to render the mesh
  9258. * @param effect The effect we are binding the data to
  9259. */
  9260. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9261. /**
  9262. * Binds the light information to the effect.
  9263. * @param light The light containing the generator
  9264. * @param effect The effect we are binding the data to
  9265. * @param lightIndex The light index in the effect used to render
  9266. */
  9267. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9268. /**
  9269. * Binds the lights information from the scene to the effect for the given mesh.
  9270. * @param scene The scene the lights belongs to
  9271. * @param mesh The mesh we are binding the information to render
  9272. * @param effect The effect we are binding the data to
  9273. * @param defines The generated defines for the effect
  9274. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9275. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9276. */
  9277. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9278. private static _tempFogColor;
  9279. /**
  9280. * Binds the fog information from the scene to the effect for the given mesh.
  9281. * @param scene The scene the lights belongs to
  9282. * @param mesh The mesh we are binding the information to render
  9283. * @param effect The effect we are binding the data to
  9284. * @param linearSpace Defines if the fog effect is applied in linear space
  9285. */
  9286. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9287. /**
  9288. * Binds the bones information from the mesh to the effect.
  9289. * @param mesh The mesh we are binding the information to render
  9290. * @param effect The effect we are binding the data to
  9291. */
  9292. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9293. /**
  9294. * Binds the morph targets information from the mesh to the effect.
  9295. * @param abstractMesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9299. /**
  9300. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9301. * @param defines The generated defines used in the effect
  9302. * @param effect The effect we are binding the data to
  9303. * @param scene The scene we are willing to render with logarithmic scale for
  9304. */
  9305. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9306. /**
  9307. * Binds the clip plane information from the scene to the effect.
  9308. * @param scene The scene the clip plane information are extracted from
  9309. * @param effect The effect we are binding the data to
  9310. */
  9311. static BindClipPlane(effect: Effect, scene: Scene): void;
  9312. }
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var kernelBlurVaryingDeclaration: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var kernelBlurFragment: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var kernelBlurFragment2: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var kernelBlurPixelShader: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var kernelBlurVertex: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var kernelBlurVertexShader: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /**
  9358. * The Blur Post Process which blurs an image based on a kernel and direction.
  9359. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9360. */
  9361. export class BlurPostProcess extends PostProcess {
  9362. /** The direction in which to blur the image. */
  9363. direction: Vector2;
  9364. private blockCompilation;
  9365. protected _kernel: number;
  9366. protected _idealKernel: number;
  9367. protected _packedFloat: boolean;
  9368. private _staticDefines;
  9369. /**
  9370. * Sets the length in pixels of the blur sample region
  9371. */
  9372. /**
  9373. * Gets the length in pixels of the blur sample region
  9374. */
  9375. kernel: number;
  9376. /**
  9377. * Sets wether or not the blur needs to unpack/repack floats
  9378. */
  9379. /**
  9380. * Gets wether or not the blur is unpacking/repacking floats
  9381. */
  9382. packedFloat: boolean;
  9383. /**
  9384. * Creates a new instance BlurPostProcess
  9385. * @param name The name of the effect.
  9386. * @param direction The direction in which to blur the image.
  9387. * @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.
  9388. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9389. * @param camera The camera to apply the render pass to.
  9390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9391. * @param engine The engine which the post process will be applied. (default: current engine)
  9392. * @param reusable If the post process can be reused on the same frame. (default: false)
  9393. * @param textureType Type of textures used when performing the post process. (default: 0)
  9394. * @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)
  9395. */
  9396. constructor(name: string,
  9397. /** The direction in which to blur the image. */
  9398. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9399. /**
  9400. * Updates the effect with the current post process compile time values and recompiles the shader.
  9401. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9402. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9403. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9404. * @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
  9405. * @param onCompiled Called when the shader has been compiled.
  9406. * @param onError Called if there is an error when compiling a shader.
  9407. */
  9408. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9409. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9410. /**
  9411. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9412. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9413. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9414. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9415. * The gaps between physical kernels are compensated for in the weighting of the samples
  9416. * @param idealKernel Ideal blur kernel.
  9417. * @return Nearest best kernel.
  9418. */
  9419. protected _nearestBestKernel(idealKernel: number): number;
  9420. /**
  9421. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9422. * @param x The point on the Gaussian distribution to sample.
  9423. * @return the value of the Gaussian function at x.
  9424. */
  9425. protected _gaussianWeight(x: number): number;
  9426. /**
  9427. * Generates a string that can be used as a floating point number in GLSL.
  9428. * @param x Value to print.
  9429. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9430. * @return GLSL float string.
  9431. */
  9432. protected _glslFloat(x: number, decimalFigures?: number): string;
  9433. }
  9434. }
  9435. declare module BABYLON {
  9436. /** @hidden */
  9437. export var shadowMapPixelShader: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module BABYLON {
  9443. /** @hidden */
  9444. export var bonesDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module BABYLON {
  9450. /** @hidden */
  9451. export var morphTargetsVertexGlobalDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module BABYLON {
  9457. /** @hidden */
  9458. export var morphTargetsVertexDeclaration: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module BABYLON {
  9464. /** @hidden */
  9465. export var instancesDeclaration: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module BABYLON {
  9471. /** @hidden */
  9472. export var helperFunctions: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module BABYLON {
  9478. /** @hidden */
  9479. export var morphTargetsVertex: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var instancesVertex: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var bonesVertex: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var shadowMapVertexShader: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /** @hidden */
  9507. export var depthBoxBlurPixelShader: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module BABYLON {
  9513. /**
  9514. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9515. */
  9516. export interface ICustomShaderOptions {
  9517. /**
  9518. * Gets or sets the custom shader name to use
  9519. */
  9520. shaderName: string;
  9521. /**
  9522. * The list of attribute names used in the shader
  9523. */
  9524. attributes?: string[];
  9525. /**
  9526. * The list of unifrom names used in the shader
  9527. */
  9528. uniforms?: string[];
  9529. /**
  9530. * The list of sampler names used in the shader
  9531. */
  9532. samplers?: string[];
  9533. /**
  9534. * The list of defines used in the shader
  9535. */
  9536. defines?: string[];
  9537. }
  9538. /**
  9539. * Interface to implement to create a shadow generator compatible with BJS.
  9540. */
  9541. export interface IShadowGenerator {
  9542. /**
  9543. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9544. * @returns The render target texture if present otherwise, null
  9545. */
  9546. getShadowMap(): Nullable<RenderTargetTexture>;
  9547. /**
  9548. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9549. * @returns The render target texture if the shadow map is present otherwise, null
  9550. */
  9551. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9552. /**
  9553. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9554. * @param subMesh The submesh we want to render in the shadow map
  9555. * @param useInstances Defines wether will draw in the map using instances
  9556. * @returns true if ready otherwise, false
  9557. */
  9558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9559. /**
  9560. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9561. * @param defines Defines of the material we want to update
  9562. * @param lightIndex Index of the light in the enabled light list of the material
  9563. */
  9564. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9565. /**
  9566. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9567. * defined in the generator but impacting the effect).
  9568. * It implies the unifroms available on the materials are the standard BJS ones.
  9569. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9570. * @param effect The effect we are binfing the information for
  9571. */
  9572. bindShadowLight(lightIndex: string, effect: Effect): void;
  9573. /**
  9574. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9575. * (eq to shadow prjection matrix * light transform matrix)
  9576. * @returns The transform matrix used to create the shadow map
  9577. */
  9578. getTransformMatrix(): Matrix;
  9579. /**
  9580. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9581. * Cube and 2D textures for instance.
  9582. */
  9583. recreateShadowMap(): void;
  9584. /**
  9585. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9586. * @param onCompiled Callback triggered at the and of the effects compilation
  9587. * @param options Sets of optional options forcing the compilation with different modes
  9588. */
  9589. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9590. useInstances: boolean;
  9591. }>): void;
  9592. /**
  9593. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9594. * @param options Sets of optional options forcing the compilation with different modes
  9595. * @returns A promise that resolves when the compilation completes
  9596. */
  9597. forceCompilationAsync(options?: Partial<{
  9598. useInstances: boolean;
  9599. }>): Promise<void>;
  9600. /**
  9601. * Serializes the shadow generator setup to a json object.
  9602. * @returns The serialized JSON object
  9603. */
  9604. serialize(): any;
  9605. /**
  9606. * Disposes the Shadow map and related Textures and effects.
  9607. */
  9608. dispose(): void;
  9609. }
  9610. /**
  9611. * Default implementation IShadowGenerator.
  9612. * This is the main object responsible of generating shadows in the framework.
  9613. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9614. */
  9615. export class ShadowGenerator implements IShadowGenerator {
  9616. /**
  9617. * Shadow generator mode None: no filtering applied.
  9618. */
  9619. static readonly FILTER_NONE: number;
  9620. /**
  9621. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9622. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9623. */
  9624. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9625. /**
  9626. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9627. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9628. */
  9629. static readonly FILTER_POISSONSAMPLING: number;
  9630. /**
  9631. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9632. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9633. */
  9634. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9635. /**
  9636. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9637. * edge artifacts on steep falloff.
  9638. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9639. */
  9640. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9641. /**
  9642. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9643. * edge artifacts on steep falloff.
  9644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9645. */
  9646. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9647. /**
  9648. * Shadow generator mode PCF: Percentage Closer Filtering
  9649. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9650. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9651. */
  9652. static readonly FILTER_PCF: number;
  9653. /**
  9654. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9655. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9656. * Contact Hardening
  9657. */
  9658. static readonly FILTER_PCSS: number;
  9659. /**
  9660. * Reserved for PCF and PCSS
  9661. * Highest Quality.
  9662. *
  9663. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9664. *
  9665. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9666. */
  9667. static readonly QUALITY_HIGH: number;
  9668. /**
  9669. * Reserved for PCF and PCSS
  9670. * Good tradeoff for quality/perf cross devices
  9671. *
  9672. * Execute PCF on a 3*3 kernel.
  9673. *
  9674. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9675. */
  9676. static readonly QUALITY_MEDIUM: number;
  9677. /**
  9678. * Reserved for PCF and PCSS
  9679. * The lowest quality but the fastest.
  9680. *
  9681. * Execute PCF on a 1*1 kernel.
  9682. *
  9683. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9684. */
  9685. static readonly QUALITY_LOW: number;
  9686. /** Gets or sets the custom shader name to use */
  9687. customShaderOptions: ICustomShaderOptions;
  9688. /**
  9689. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9690. */
  9691. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9692. /**
  9693. * Observable triggered before a mesh is rendered in the shadow map.
  9694. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9695. */
  9696. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9697. private _bias;
  9698. /**
  9699. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9700. */
  9701. /**
  9702. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9703. */
  9704. bias: number;
  9705. private _normalBias;
  9706. /**
  9707. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9708. */
  9709. /**
  9710. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9711. */
  9712. normalBias: number;
  9713. private _blurBoxOffset;
  9714. /**
  9715. * Gets the blur box offset: offset applied during the blur pass.
  9716. * Only useful if useKernelBlur = false
  9717. */
  9718. /**
  9719. * Sets the blur box offset: offset applied during the blur pass.
  9720. * Only useful if useKernelBlur = false
  9721. */
  9722. blurBoxOffset: number;
  9723. private _blurScale;
  9724. /**
  9725. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9726. * 2 means half of the size.
  9727. */
  9728. /**
  9729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9730. * 2 means half of the size.
  9731. */
  9732. blurScale: number;
  9733. private _blurKernel;
  9734. /**
  9735. * Gets the blur kernel: kernel size of the blur pass.
  9736. * Only useful if useKernelBlur = true
  9737. */
  9738. /**
  9739. * Sets the blur kernel: kernel size of the blur pass.
  9740. * Only useful if useKernelBlur = true
  9741. */
  9742. blurKernel: number;
  9743. private _useKernelBlur;
  9744. /**
  9745. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9746. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9747. */
  9748. /**
  9749. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9750. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9751. */
  9752. useKernelBlur: boolean;
  9753. private _depthScale;
  9754. /**
  9755. * Gets the depth scale used in ESM mode.
  9756. */
  9757. /**
  9758. * Sets the depth scale used in ESM mode.
  9759. * This can override the scale stored on the light.
  9760. */
  9761. depthScale: number;
  9762. private _filter;
  9763. /**
  9764. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9765. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9766. */
  9767. /**
  9768. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9769. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9770. */
  9771. filter: number;
  9772. /**
  9773. * Gets if the current filter is set to Poisson Sampling.
  9774. */
  9775. /**
  9776. * Sets the current filter to Poisson Sampling.
  9777. */
  9778. usePoissonSampling: boolean;
  9779. /**
  9780. * Gets if the current filter is set to ESM.
  9781. */
  9782. /**
  9783. * Sets the current filter is to ESM.
  9784. */
  9785. useExponentialShadowMap: boolean;
  9786. /**
  9787. * Gets if the current filter is set to filtered ESM.
  9788. */
  9789. /**
  9790. * Gets if the current filter is set to filtered ESM.
  9791. */
  9792. useBlurExponentialShadowMap: boolean;
  9793. /**
  9794. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9795. * exponential to prevent steep falloff artifacts).
  9796. */
  9797. /**
  9798. * Sets the current filter to "close ESM" (using the inverse of the
  9799. * exponential to prevent steep falloff artifacts).
  9800. */
  9801. useCloseExponentialShadowMap: boolean;
  9802. /**
  9803. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9804. * exponential to prevent steep falloff artifacts).
  9805. */
  9806. /**
  9807. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9808. * exponential to prevent steep falloff artifacts).
  9809. */
  9810. useBlurCloseExponentialShadowMap: boolean;
  9811. /**
  9812. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9813. */
  9814. /**
  9815. * Sets the current filter to "PCF" (percentage closer filtering).
  9816. */
  9817. usePercentageCloserFiltering: boolean;
  9818. private _filteringQuality;
  9819. /**
  9820. * Gets the PCF or PCSS Quality.
  9821. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9822. */
  9823. /**
  9824. * Sets the PCF or PCSS Quality.
  9825. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9826. */
  9827. filteringQuality: number;
  9828. /**
  9829. * Gets if the current filter is set to "PCSS" (contact hardening).
  9830. */
  9831. /**
  9832. * Sets the current filter to "PCSS" (contact hardening).
  9833. */
  9834. useContactHardeningShadow: boolean;
  9835. private _contactHardeningLightSizeUVRatio;
  9836. /**
  9837. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9838. * Using a ratio helps keeping shape stability independently of the map size.
  9839. *
  9840. * It does not account for the light projection as it was having too much
  9841. * instability during the light setup or during light position changes.
  9842. *
  9843. * Only valid if useContactHardeningShadow is true.
  9844. */
  9845. /**
  9846. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9847. * Using a ratio helps keeping shape stability independently of the map size.
  9848. *
  9849. * It does not account for the light projection as it was having too much
  9850. * instability during the light setup or during light position changes.
  9851. *
  9852. * Only valid if useContactHardeningShadow is true.
  9853. */
  9854. contactHardeningLightSizeUVRatio: number;
  9855. private _darkness;
  9856. /**
  9857. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9858. * 0 means strongest and 1 would means no shadow.
  9859. * @returns the darkness.
  9860. */
  9861. getDarkness(): number;
  9862. /**
  9863. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9864. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9865. * @returns the shadow generator allowing fluent coding.
  9866. */
  9867. setDarkness(darkness: number): ShadowGenerator;
  9868. private _transparencyShadow;
  9869. /**
  9870. * Sets the ability to have transparent shadow (boolean).
  9871. * @param transparent True if transparent else False
  9872. * @returns the shadow generator allowing fluent coding
  9873. */
  9874. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9875. private _shadowMap;
  9876. private _shadowMap2;
  9877. /**
  9878. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9879. * @returns The render target texture if present otherwise, null
  9880. */
  9881. getShadowMap(): Nullable<RenderTargetTexture>;
  9882. /**
  9883. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9884. * @returns The render target texture if the shadow map is present otherwise, null
  9885. */
  9886. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9887. /**
  9888. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9889. * @param mesh Mesh to add
  9890. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9891. * @returns the Shadow Generator itself
  9892. */
  9893. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9894. /**
  9895. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9896. * @param mesh Mesh to remove
  9897. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9898. * @returns the Shadow Generator itself
  9899. */
  9900. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9901. /**
  9902. * Controls the extent to which the shadows fade out at the edge of the frustum
  9903. * Used only by directionals and spots
  9904. */
  9905. frustumEdgeFalloff: number;
  9906. private _light;
  9907. /**
  9908. * Returns the associated light object.
  9909. * @returns the light generating the shadow
  9910. */
  9911. getLight(): IShadowLight;
  9912. /**
  9913. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9914. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9915. * It might on the other hand introduce peter panning.
  9916. */
  9917. forceBackFacesOnly: boolean;
  9918. private _scene;
  9919. private _lightDirection;
  9920. private _effect;
  9921. private _viewMatrix;
  9922. private _projectionMatrix;
  9923. private _transformMatrix;
  9924. private _cachedPosition;
  9925. private _cachedDirection;
  9926. private _cachedDefines;
  9927. private _currentRenderID;
  9928. private _boxBlurPostprocess;
  9929. private _kernelBlurXPostprocess;
  9930. private _kernelBlurYPostprocess;
  9931. private _blurPostProcesses;
  9932. private _mapSize;
  9933. private _currentFaceIndex;
  9934. private _currentFaceIndexCache;
  9935. private _textureType;
  9936. private _defaultTextureMatrix;
  9937. /** @hidden */
  9938. static _SceneComponentInitialization: (scene: Scene) => void;
  9939. /**
  9940. * Creates a ShadowGenerator object.
  9941. * A ShadowGenerator is the required tool to use the shadows.
  9942. * Each light casting shadows needs to use its own ShadowGenerator.
  9943. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9944. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9945. * @param light The light object generating the shadows.
  9946. * @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.
  9947. */
  9948. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9949. private _initializeGenerator;
  9950. private _initializeShadowMap;
  9951. private _initializeBlurRTTAndPostProcesses;
  9952. private _renderForShadowMap;
  9953. private _renderSubMeshForShadowMap;
  9954. private _applyFilterValues;
  9955. /**
  9956. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9957. * @param onCompiled Callback triggered at the and of the effects compilation
  9958. * @param options Sets of optional options forcing the compilation with different modes
  9959. */
  9960. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9961. useInstances: boolean;
  9962. }>): void;
  9963. /**
  9964. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9965. * @param options Sets of optional options forcing the compilation with different modes
  9966. * @returns A promise that resolves when the compilation completes
  9967. */
  9968. forceCompilationAsync(options?: Partial<{
  9969. useInstances: boolean;
  9970. }>): Promise<void>;
  9971. /**
  9972. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9973. * @param subMesh The submesh we want to render in the shadow map
  9974. * @param useInstances Defines wether will draw in the map using instances
  9975. * @returns true if ready otherwise, false
  9976. */
  9977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9978. /**
  9979. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9980. * @param defines Defines of the material we want to update
  9981. * @param lightIndex Index of the light in the enabled light list of the material
  9982. */
  9983. prepareDefines(defines: any, lightIndex: number): void;
  9984. /**
  9985. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9986. * defined in the generator but impacting the effect).
  9987. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9988. * @param effect The effect we are binfing the information for
  9989. */
  9990. bindShadowLight(lightIndex: string, effect: Effect): void;
  9991. /**
  9992. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9993. * (eq to shadow prjection matrix * light transform matrix)
  9994. * @returns The transform matrix used to create the shadow map
  9995. */
  9996. getTransformMatrix(): Matrix;
  9997. /**
  9998. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9999. * Cube and 2D textures for instance.
  10000. */
  10001. recreateShadowMap(): void;
  10002. private _disposeBlurPostProcesses;
  10003. private _disposeRTTandPostProcesses;
  10004. /**
  10005. * Disposes the ShadowGenerator.
  10006. * Returns nothing.
  10007. */
  10008. dispose(): void;
  10009. /**
  10010. * Serializes the shadow generator setup to a json object.
  10011. * @returns The serialized JSON object
  10012. */
  10013. serialize(): any;
  10014. /**
  10015. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10016. * @param parsedShadowGenerator The JSON object to parse
  10017. * @param scene The scene to create the shadow map for
  10018. * @returns The parsed shadow generator
  10019. */
  10020. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10021. }
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10026. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10027. * 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.
  10028. */
  10029. export abstract class Light extends Node {
  10030. /**
  10031. * Falloff Default: light is falling off following the material specification:
  10032. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10033. */
  10034. static readonly FALLOFF_DEFAULT: number;
  10035. /**
  10036. * Falloff Physical: light is falling off following the inverse squared distance law.
  10037. */
  10038. static readonly FALLOFF_PHYSICAL: number;
  10039. /**
  10040. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10041. * to enhance interoperability with other engines.
  10042. */
  10043. static readonly FALLOFF_GLTF: number;
  10044. /**
  10045. * Falloff Standard: light is falling off like in the standard material
  10046. * to enhance interoperability with other materials.
  10047. */
  10048. static readonly FALLOFF_STANDARD: number;
  10049. /**
  10050. * If every light affecting the material is in this lightmapMode,
  10051. * material.lightmapTexture adds or multiplies
  10052. * (depends on material.useLightmapAsShadowmap)
  10053. * after every other light calculations.
  10054. */
  10055. static readonly LIGHTMAP_DEFAULT: number;
  10056. /**
  10057. * material.lightmapTexture as only diffuse lighting from this light
  10058. * adds only specular lighting from this light
  10059. * adds dynamic shadows
  10060. */
  10061. static readonly LIGHTMAP_SPECULAR: number;
  10062. /**
  10063. * material.lightmapTexture as only lighting
  10064. * no light calculation from this light
  10065. * only adds dynamic shadows from this light
  10066. */
  10067. static readonly LIGHTMAP_SHADOWSONLY: number;
  10068. /**
  10069. * Each light type uses the default quantity according to its type:
  10070. * point/spot lights use luminous intensity
  10071. * directional lights use illuminance
  10072. */
  10073. static readonly INTENSITYMODE_AUTOMATIC: number;
  10074. /**
  10075. * lumen (lm)
  10076. */
  10077. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10078. /**
  10079. * candela (lm/sr)
  10080. */
  10081. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10082. /**
  10083. * lux (lm/m^2)
  10084. */
  10085. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10086. /**
  10087. * nit (cd/m^2)
  10088. */
  10089. static readonly INTENSITYMODE_LUMINANCE: number;
  10090. /**
  10091. * Light type const id of the point light.
  10092. */
  10093. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10094. /**
  10095. * Light type const id of the directional light.
  10096. */
  10097. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10098. /**
  10099. * Light type const id of the spot light.
  10100. */
  10101. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10102. /**
  10103. * Light type const id of the hemispheric light.
  10104. */
  10105. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10106. /**
  10107. * Diffuse gives the basic color to an object.
  10108. */
  10109. diffuse: Color3;
  10110. /**
  10111. * Specular produces a highlight color on an object.
  10112. * Note: This is note affecting PBR materials.
  10113. */
  10114. specular: Color3;
  10115. /**
  10116. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10117. * falling off base on range or angle.
  10118. * This can be set to any values in Light.FALLOFF_x.
  10119. *
  10120. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10121. * other types of materials.
  10122. */
  10123. falloffType: number;
  10124. /**
  10125. * Strength of the light.
  10126. * Note: By default it is define in the framework own unit.
  10127. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10128. */
  10129. intensity: number;
  10130. private _range;
  10131. protected _inverseSquaredRange: number;
  10132. /**
  10133. * Defines how far from the source the light is impacting in scene units.
  10134. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10135. */
  10136. /**
  10137. * Defines how far from the source the light is impacting in scene units.
  10138. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10139. */
  10140. range: number;
  10141. /**
  10142. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10143. * of light.
  10144. */
  10145. private _photometricScale;
  10146. private _intensityMode;
  10147. /**
  10148. * Gets the photometric scale used to interpret the intensity.
  10149. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10150. */
  10151. /**
  10152. * Sets the photometric scale used to interpret the intensity.
  10153. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10154. */
  10155. intensityMode: number;
  10156. private _radius;
  10157. /**
  10158. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10159. */
  10160. /**
  10161. * sets the light radius used by PBR Materials to simulate soft area lights.
  10162. */
  10163. radius: number;
  10164. private _renderPriority;
  10165. /**
  10166. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10167. * exceeding the number allowed of the materials.
  10168. */
  10169. renderPriority: number;
  10170. private _shadowEnabled;
  10171. /**
  10172. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10173. * the current shadow generator.
  10174. */
  10175. /**
  10176. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10177. * the current shadow generator.
  10178. */
  10179. shadowEnabled: boolean;
  10180. private _includedOnlyMeshes;
  10181. /**
  10182. * Gets the only meshes impacted by this light.
  10183. */
  10184. /**
  10185. * Sets the only meshes impacted by this light.
  10186. */
  10187. includedOnlyMeshes: AbstractMesh[];
  10188. private _excludedMeshes;
  10189. /**
  10190. * Gets the meshes not impacted by this light.
  10191. */
  10192. /**
  10193. * Sets the meshes not impacted by this light.
  10194. */
  10195. excludedMeshes: AbstractMesh[];
  10196. private _excludeWithLayerMask;
  10197. /**
  10198. * Gets the layer id use to find what meshes are not impacted by the light.
  10199. * Inactive if 0
  10200. */
  10201. /**
  10202. * Sets the layer id use to find what meshes are not impacted by the light.
  10203. * Inactive if 0
  10204. */
  10205. excludeWithLayerMask: number;
  10206. private _includeOnlyWithLayerMask;
  10207. /**
  10208. * Gets the layer id use to find what meshes are impacted by the light.
  10209. * Inactive if 0
  10210. */
  10211. /**
  10212. * Sets the layer id use to find what meshes are impacted by the light.
  10213. * Inactive if 0
  10214. */
  10215. includeOnlyWithLayerMask: number;
  10216. private _lightmapMode;
  10217. /**
  10218. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10219. */
  10220. /**
  10221. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10222. */
  10223. lightmapMode: number;
  10224. /**
  10225. * Shadow generator associted to the light.
  10226. * @hidden Internal use only.
  10227. */
  10228. _shadowGenerator: Nullable<IShadowGenerator>;
  10229. /**
  10230. * @hidden Internal use only.
  10231. */
  10232. _excludedMeshesIds: string[];
  10233. /**
  10234. * @hidden Internal use only.
  10235. */
  10236. _includedOnlyMeshesIds: string[];
  10237. /**
  10238. * The current light unifom buffer.
  10239. * @hidden Internal use only.
  10240. */
  10241. _uniformBuffer: UniformBuffer;
  10242. /**
  10243. * Creates a Light object in the scene.
  10244. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10245. * @param name The firendly name of the light
  10246. * @param scene The scene the light belongs too
  10247. */
  10248. constructor(name: string, scene: Scene);
  10249. protected abstract _buildUniformLayout(): void;
  10250. /**
  10251. * Sets the passed Effect "effect" with the Light information.
  10252. * @param effect The effect to update
  10253. * @param lightIndex The index of the light in the effect to update
  10254. * @returns The light
  10255. */
  10256. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10257. /**
  10258. * Returns the string "Light".
  10259. * @returns the class name
  10260. */
  10261. getClassName(): string;
  10262. /** @hidden */
  10263. readonly _isLight: boolean;
  10264. /**
  10265. * Converts the light information to a readable string for debug purpose.
  10266. * @param fullDetails Supports for multiple levels of logging within scene loading
  10267. * @returns the human readable light info
  10268. */
  10269. toString(fullDetails?: boolean): string;
  10270. /** @hidden */
  10271. protected _syncParentEnabledState(): void;
  10272. /**
  10273. * Set the enabled state of this node.
  10274. * @param value - the new enabled state
  10275. */
  10276. setEnabled(value: boolean): void;
  10277. /**
  10278. * Returns the Light associated shadow generator if any.
  10279. * @return the associated shadow generator.
  10280. */
  10281. getShadowGenerator(): Nullable<IShadowGenerator>;
  10282. /**
  10283. * Returns a Vector3, the absolute light position in the World.
  10284. * @returns the world space position of the light
  10285. */
  10286. getAbsolutePosition(): Vector3;
  10287. /**
  10288. * Specifies if the light will affect the passed mesh.
  10289. * @param mesh The mesh to test against the light
  10290. * @return true the mesh is affected otherwise, false.
  10291. */
  10292. canAffectMesh(mesh: AbstractMesh): boolean;
  10293. /**
  10294. * Sort function to order lights for rendering.
  10295. * @param a First Light object to compare to second.
  10296. * @param b Second Light object to compare first.
  10297. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10298. */
  10299. static CompareLightsPriority(a: Light, b: Light): number;
  10300. /**
  10301. * Releases resources associated with this node.
  10302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10304. */
  10305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10306. /**
  10307. * Returns the light type ID (integer).
  10308. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10309. */
  10310. getTypeID(): number;
  10311. /**
  10312. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10313. * @returns the scaled intensity in intensity mode unit
  10314. */
  10315. getScaledIntensity(): number;
  10316. /**
  10317. * Returns a new Light object, named "name", from the current one.
  10318. * @param name The name of the cloned light
  10319. * @returns the new created light
  10320. */
  10321. clone(name: string): Nullable<Light>;
  10322. /**
  10323. * Serializes the current light into a Serialization object.
  10324. * @returns the serialized object.
  10325. */
  10326. serialize(): any;
  10327. /**
  10328. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10329. * This new light is named "name" and added to the passed scene.
  10330. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10331. * @param name The friendly name of the light
  10332. * @param scene The scene the new light will belong to
  10333. * @returns the constructor function
  10334. */
  10335. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10336. /**
  10337. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10338. * @param parsedLight The JSON representation of the light
  10339. * @param scene The scene to create the parsed light in
  10340. * @returns the created light after parsing
  10341. */
  10342. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10343. private _hookArrayForExcluded;
  10344. private _hookArrayForIncludedOnly;
  10345. private _resyncMeshes;
  10346. /**
  10347. * Forces the meshes to update their light related information in their rendering used effects
  10348. * @hidden Internal Use Only
  10349. */
  10350. _markMeshesAsLightDirty(): void;
  10351. /**
  10352. * Recomputes the cached photometric scale if needed.
  10353. */
  10354. private _computePhotometricScale;
  10355. /**
  10356. * Returns the Photometric Scale according to the light type and intensity mode.
  10357. */
  10358. private _getPhotometricScale;
  10359. /**
  10360. * Reorder the light in the scene according to their defined priority.
  10361. * @hidden Internal Use Only
  10362. */
  10363. _reorderLightsInScene(): void;
  10364. /**
  10365. * Prepares the list of defines specific to the light type.
  10366. * @param defines the list of defines
  10367. * @param lightIndex defines the index of the light for the effect
  10368. */
  10369. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10370. }
  10371. }
  10372. declare module BABYLON {
  10373. /**
  10374. * Interface used to define Action
  10375. */
  10376. export interface IAction {
  10377. /**
  10378. * Trigger for the action
  10379. */
  10380. trigger: number;
  10381. /** Options of the trigger */
  10382. triggerOptions: any;
  10383. /**
  10384. * Gets the trigger parameters
  10385. * @returns the trigger parameters
  10386. */
  10387. getTriggerParameter(): any;
  10388. /**
  10389. * Internal only - executes current action event
  10390. * @hidden
  10391. */
  10392. _executeCurrent(evt?: ActionEvent): void;
  10393. /**
  10394. * Serialize placeholder for child classes
  10395. * @param parent of child
  10396. * @returns the serialized object
  10397. */
  10398. serialize(parent: any): any;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _prepare(): void;
  10404. /**
  10405. * Internal only - manager for action
  10406. * @hidden
  10407. */
  10408. _actionManager: AbstractActionManager;
  10409. }
  10410. /**
  10411. * The action to be carried out following a trigger
  10412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10413. */
  10414. export class Action implements IAction {
  10415. /** the trigger, with or without parameters, for the action */
  10416. triggerOptions: any;
  10417. /**
  10418. * Trigger for the action
  10419. */
  10420. trigger: number;
  10421. /**
  10422. * Internal only - manager for action
  10423. * @hidden
  10424. */
  10425. _actionManager: ActionManager;
  10426. private _nextActiveAction;
  10427. private _child;
  10428. private _condition?;
  10429. private _triggerParameter;
  10430. /**
  10431. * An event triggered prior to action being executed.
  10432. */
  10433. onBeforeExecuteObservable: Observable<Action>;
  10434. /**
  10435. * Creates a new Action
  10436. * @param triggerOptions the trigger, with or without parameters, for the action
  10437. * @param condition an optional determinant of action
  10438. */
  10439. constructor(
  10440. /** the trigger, with or without parameters, for the action */
  10441. triggerOptions: any, condition?: Condition);
  10442. /**
  10443. * Internal only
  10444. * @hidden
  10445. */
  10446. _prepare(): void;
  10447. /**
  10448. * Gets the trigger parameters
  10449. * @returns the trigger parameters
  10450. */
  10451. getTriggerParameter(): any;
  10452. /**
  10453. * Internal only - executes current action event
  10454. * @hidden
  10455. */
  10456. _executeCurrent(evt?: ActionEvent): void;
  10457. /**
  10458. * Execute placeholder for child classes
  10459. * @param evt optional action event
  10460. */
  10461. execute(evt?: ActionEvent): void;
  10462. /**
  10463. * Skips to next active action
  10464. */
  10465. skipToNextActiveAction(): void;
  10466. /**
  10467. * Adds action to chain of actions, may be a DoNothingAction
  10468. * @param action defines the next action to execute
  10469. * @returns The action passed in
  10470. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10471. */
  10472. then(action: Action): Action;
  10473. /**
  10474. * Internal only
  10475. * @hidden
  10476. */
  10477. _getProperty(propertyPath: string): string;
  10478. /**
  10479. * Internal only
  10480. * @hidden
  10481. */
  10482. _getEffectiveTarget(target: any, propertyPath: string): any;
  10483. /**
  10484. * Serialize placeholder for child classes
  10485. * @param parent of child
  10486. * @returns the serialized object
  10487. */
  10488. serialize(parent: any): any;
  10489. /**
  10490. * Internal only called by serialize
  10491. * @hidden
  10492. */
  10493. protected _serialize(serializedAction: any, parent?: any): any;
  10494. /**
  10495. * Internal only
  10496. * @hidden
  10497. */
  10498. static _SerializeValueAsString: (value: any) => string;
  10499. /**
  10500. * Internal only
  10501. * @hidden
  10502. */
  10503. static _GetTargetProperty: (target: Scene | Node) => {
  10504. name: string;
  10505. targetType: string;
  10506. value: string;
  10507. };
  10508. }
  10509. }
  10510. declare module BABYLON {
  10511. /**
  10512. * A Condition applied to an Action
  10513. */
  10514. export class Condition {
  10515. /**
  10516. * Internal only - manager for action
  10517. * @hidden
  10518. */
  10519. _actionManager: ActionManager;
  10520. /**
  10521. * Internal only
  10522. * @hidden
  10523. */
  10524. _evaluationId: number;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. _currentResult: boolean;
  10530. /**
  10531. * Creates a new Condition
  10532. * @param actionManager the manager of the action the condition is applied to
  10533. */
  10534. constructor(actionManager: ActionManager);
  10535. /**
  10536. * Check if the current condition is valid
  10537. * @returns a boolean
  10538. */
  10539. isValid(): boolean;
  10540. /**
  10541. * Internal only
  10542. * @hidden
  10543. */
  10544. _getProperty(propertyPath: string): string;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _getEffectiveTarget(target: any, propertyPath: string): any;
  10550. /**
  10551. * Serialize placeholder for child classes
  10552. * @returns the serialized object
  10553. */
  10554. serialize(): any;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. protected _serialize(serializedCondition: any): any;
  10560. }
  10561. /**
  10562. * Defines specific conditional operators as extensions of Condition
  10563. */
  10564. export class ValueCondition extends Condition {
  10565. /** path to specify the property of the target the conditional operator uses */
  10566. propertyPath: string;
  10567. /** the value compared by the conditional operator against the current value of the property */
  10568. value: any;
  10569. /** the conditional operator, default ValueCondition.IsEqual */
  10570. operator: number;
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */
  10575. private static _IsEqual;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. private static _IsDifferent;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsGreater;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsLesser;
  10591. /**
  10592. * returns the number for IsEqual
  10593. */
  10594. static readonly IsEqual: number;
  10595. /**
  10596. * Returns the number for IsDifferent
  10597. */
  10598. static readonly IsDifferent: number;
  10599. /**
  10600. * Returns the number for IsGreater
  10601. */
  10602. static readonly IsGreater: number;
  10603. /**
  10604. * Returns the number for IsLesser
  10605. */
  10606. static readonly IsLesser: number;
  10607. /**
  10608. * Internal only The action manager for the condition
  10609. * @hidden
  10610. */
  10611. _actionManager: ActionManager;
  10612. /**
  10613. * Internal only
  10614. * @hidden
  10615. */
  10616. private _target;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. private _effectiveTarget;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _property;
  10627. /**
  10628. * Creates a new ValueCondition
  10629. * @param actionManager manager for the action the condition applies to
  10630. * @param target for the action
  10631. * @param propertyPath path to specify the property of the target the conditional operator uses
  10632. * @param value the value compared by the conditional operator against the current value of the property
  10633. * @param operator the conditional operator, default ValueCondition.IsEqual
  10634. */
  10635. constructor(actionManager: ActionManager, target: any,
  10636. /** path to specify the property of the target the conditional operator uses */
  10637. propertyPath: string,
  10638. /** the value compared by the conditional operator against the current value of the property */
  10639. value: any,
  10640. /** the conditional operator, default ValueCondition.IsEqual */
  10641. operator?: number);
  10642. /**
  10643. * Compares the given value with the property value for the specified conditional operator
  10644. * @returns the result of the comparison
  10645. */
  10646. isValid(): boolean;
  10647. /**
  10648. * Serialize the ValueCondition into a JSON compatible object
  10649. * @returns serialization object
  10650. */
  10651. serialize(): any;
  10652. /**
  10653. * Gets the name of the conditional operator for the ValueCondition
  10654. * @param operator the conditional operator
  10655. * @returns the name
  10656. */
  10657. static GetOperatorName(operator: number): string;
  10658. }
  10659. /**
  10660. * Defines a predicate condition as an extension of Condition
  10661. */
  10662. export class PredicateCondition extends Condition {
  10663. /** defines the predicate function used to validate the condition */
  10664. predicate: () => boolean;
  10665. /**
  10666. * Internal only - manager for action
  10667. * @hidden
  10668. */
  10669. _actionManager: ActionManager;
  10670. /**
  10671. * Creates a new PredicateCondition
  10672. * @param actionManager manager for the action the condition applies to
  10673. * @param predicate defines the predicate function used to validate the condition
  10674. */
  10675. constructor(actionManager: ActionManager,
  10676. /** defines the predicate function used to validate the condition */
  10677. predicate: () => boolean);
  10678. /**
  10679. * @returns the validity of the predicate condition
  10680. */
  10681. isValid(): boolean;
  10682. }
  10683. /**
  10684. * Defines a state condition as an extension of Condition
  10685. */
  10686. export class StateCondition extends Condition {
  10687. /** Value to compare with target state */
  10688. value: string;
  10689. /**
  10690. * Internal only - manager for action
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private _target;
  10699. /**
  10700. * Creates a new StateCondition
  10701. * @param actionManager manager for the action the condition applies to
  10702. * @param target of the condition
  10703. * @param value to compare with target state
  10704. */
  10705. constructor(actionManager: ActionManager, target: any,
  10706. /** Value to compare with target state */
  10707. value: string);
  10708. /**
  10709. * Gets a boolean indicating if the current condition is met
  10710. * @returns the validity of the state
  10711. */
  10712. isValid(): boolean;
  10713. /**
  10714. * Serialize the StateCondition into a JSON compatible object
  10715. * @returns serialization object
  10716. */
  10717. serialize(): any;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /**
  10722. * This defines an action responsible to toggle a boolean once triggered.
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10724. */
  10725. export class SwitchBooleanAction extends Action {
  10726. /**
  10727. * The path to the boolean property in the target object
  10728. */
  10729. propertyPath: string;
  10730. private _target;
  10731. private _effectiveTarget;
  10732. private _property;
  10733. /**
  10734. * Instantiate the action
  10735. * @param triggerOptions defines the trigger options
  10736. * @param target defines the object containing the boolean
  10737. * @param propertyPath defines the path to the boolean property in the target object
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10741. /** @hidden */
  10742. _prepare(): void;
  10743. /**
  10744. * Execute the action toggle the boolean value.
  10745. */
  10746. execute(): void;
  10747. /**
  10748. * Serializes the actions and its related information.
  10749. * @param parent defines the object to serialize in
  10750. * @returns the serialized object
  10751. */
  10752. serialize(parent: any): any;
  10753. }
  10754. /**
  10755. * This defines an action responsible to set a the state field of the target
  10756. * to a desired value once triggered.
  10757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10758. */
  10759. export class SetStateAction extends Action {
  10760. /**
  10761. * The value to store in the state field.
  10762. */
  10763. value: string;
  10764. private _target;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the object containing the state property
  10769. * @param value defines the value to store in the state field
  10770. * @param condition defines the trigger related conditions
  10771. */
  10772. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10773. /**
  10774. * Execute the action and store the value on the target state property.
  10775. */
  10776. execute(): void;
  10777. /**
  10778. * Serializes the actions and its related information.
  10779. * @param parent defines the object to serialize in
  10780. * @returns the serialized object
  10781. */
  10782. serialize(parent: any): any;
  10783. }
  10784. /**
  10785. * This defines an action responsible to set a property of the target
  10786. * to a desired value once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class SetValueAction extends Action {
  10790. /**
  10791. * The path of the property to set in the target.
  10792. */
  10793. propertyPath: string;
  10794. /**
  10795. * The value to set in the property
  10796. */
  10797. value: any;
  10798. private _target;
  10799. private _effectiveTarget;
  10800. private _property;
  10801. /**
  10802. * Instantiate the action
  10803. * @param triggerOptions defines the trigger options
  10804. * @param target defines the object containing the property
  10805. * @param propertyPath defines the path of the property to set in the target
  10806. * @param value defines the value to set in the property
  10807. * @param condition defines the trigger related conditions
  10808. */
  10809. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10810. /** @hidden */
  10811. _prepare(): void;
  10812. /**
  10813. * Execute the action and set the targetted property to the desired value.
  10814. */
  10815. execute(): void;
  10816. /**
  10817. * Serializes the actions and its related information.
  10818. * @param parent defines the object to serialize in
  10819. * @returns the serialized object
  10820. */
  10821. serialize(parent: any): any;
  10822. }
  10823. /**
  10824. * This defines an action responsible to increment the target value
  10825. * to a desired value once triggered.
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10827. */
  10828. export class IncrementValueAction extends Action {
  10829. /**
  10830. * The path of the property to increment in the target.
  10831. */
  10832. propertyPath: string;
  10833. /**
  10834. * The value we should increment the property by.
  10835. */
  10836. value: any;
  10837. private _target;
  10838. private _effectiveTarget;
  10839. private _property;
  10840. /**
  10841. * Instantiate the action
  10842. * @param triggerOptions defines the trigger options
  10843. * @param target defines the object containing the property
  10844. * @param propertyPath defines the path of the property to increment in the target
  10845. * @param value defines the value value we should increment the property by
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and increment the target of the value amount.
  10853. */
  10854. execute(): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to start an animation once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class PlayAnimationAction extends Action {
  10867. /**
  10868. * Where the animation should start (animation frame)
  10869. */
  10870. from: number;
  10871. /**
  10872. * Where the animation should stop (animation frame)
  10873. */
  10874. to: number;
  10875. /**
  10876. * Define if the animation should loop or stop after the first play.
  10877. */
  10878. loop?: boolean;
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param from defines from where the animation should start (animation frame)
  10885. * @param end defines where the animation should stop (animation frame)
  10886. * @param loop defines if the animation should loop or stop after the first play
  10887. * @param condition defines the trigger related conditions
  10888. */
  10889. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10890. /** @hidden */
  10891. _prepare(): void;
  10892. /**
  10893. * Execute the action and play the animation.
  10894. */
  10895. execute(): void;
  10896. /**
  10897. * Serializes the actions and its related information.
  10898. * @param parent defines the object to serialize in
  10899. * @returns the serialized object
  10900. */
  10901. serialize(parent: any): any;
  10902. }
  10903. /**
  10904. * This defines an action responsible to stop an animation once triggered.
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10906. */
  10907. export class StopAnimationAction extends Action {
  10908. private _target;
  10909. /**
  10910. * Instantiate the action
  10911. * @param triggerOptions defines the trigger options
  10912. * @param target defines the target animation or animation name
  10913. * @param condition defines the trigger related conditions
  10914. */
  10915. constructor(triggerOptions: any, target: any, condition?: Condition);
  10916. /** @hidden */
  10917. _prepare(): void;
  10918. /**
  10919. * Execute the action and stop the animation.
  10920. */
  10921. execute(): void;
  10922. /**
  10923. * Serializes the actions and its related information.
  10924. * @param parent defines the object to serialize in
  10925. * @returns the serialized object
  10926. */
  10927. serialize(parent: any): any;
  10928. }
  10929. /**
  10930. * This defines an action responsible that does nothing once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class DoNothingAction extends Action {
  10934. /**
  10935. * Instantiate the action
  10936. * @param triggerOptions defines the trigger options
  10937. * @param condition defines the trigger related conditions
  10938. */
  10939. constructor(triggerOptions?: any, condition?: Condition);
  10940. /**
  10941. * Execute the action and do nothing.
  10942. */
  10943. execute(): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to trigger several actions once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class CombineAction extends Action {
  10956. /**
  10957. * The list of aggregated animations to run.
  10958. */
  10959. children: Action[];
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param children defines the list of aggregated animations to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10967. /** @hidden */
  10968. _prepare(): void;
  10969. /**
  10970. * Execute the action and executes all the aggregated actions.
  10971. */
  10972. execute(evt: ActionEvent): void;
  10973. /**
  10974. * Serializes the actions and its related information.
  10975. * @param parent defines the object to serialize in
  10976. * @returns the serialized object
  10977. */
  10978. serialize(parent: any): any;
  10979. }
  10980. /**
  10981. * This defines an action responsible to run code (external event) once triggered.
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10983. */
  10984. export class ExecuteCodeAction extends Action {
  10985. /**
  10986. * The callback function to run.
  10987. */
  10988. func: (evt: ActionEvent) => void;
  10989. /**
  10990. * Instantiate the action
  10991. * @param triggerOptions defines the trigger options
  10992. * @param func defines the callback function to run
  10993. * @param condition defines the trigger related conditions
  10994. */
  10995. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10996. /**
  10997. * Execute the action and run the attached code.
  10998. */
  10999. execute(evt: ActionEvent): void;
  11000. }
  11001. /**
  11002. * This defines an action responsible to set the parent property of the target once triggered.
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11004. */
  11005. export class SetParentAction extends Action {
  11006. private _parent;
  11007. private _target;
  11008. /**
  11009. * Instantiate the action
  11010. * @param triggerOptions defines the trigger options
  11011. * @param target defines the target containing the parent property
  11012. * @param parent defines from where the animation should start (animation frame)
  11013. * @param condition defines the trigger related conditions
  11014. */
  11015. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11016. /** @hidden */
  11017. _prepare(): void;
  11018. /**
  11019. * Execute the action and set the parent property.
  11020. */
  11021. execute(): void;
  11022. /**
  11023. * Serializes the actions and its related information.
  11024. * @param parent defines the object to serialize in
  11025. * @returns the serialized object
  11026. */
  11027. serialize(parent: any): any;
  11028. }
  11029. }
  11030. declare module BABYLON {
  11031. /**
  11032. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11033. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11035. */
  11036. export class ActionManager extends AbstractActionManager {
  11037. /**
  11038. * Nothing
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly NothingTrigger: number;
  11042. /**
  11043. * On pick
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnPickTrigger: number;
  11047. /**
  11048. * On left pick
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnLeftPickTrigger: number;
  11052. /**
  11053. * On right pick
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnRightPickTrigger: number;
  11057. /**
  11058. * On center pick
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnCenterPickTrigger: number;
  11062. /**
  11063. * On pick down
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnPickDownTrigger: number;
  11067. /**
  11068. * On double pick
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11070. */
  11071. static readonly OnDoublePickTrigger: number;
  11072. /**
  11073. * On pick up
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnPickUpTrigger: number;
  11077. /**
  11078. * On pick out.
  11079. * This trigger will only be raised if you also declared a OnPickDown
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnPickOutTrigger: number;
  11083. /**
  11084. * On long press
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnLongPressTrigger: number;
  11088. /**
  11089. * On pointer over
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnPointerOverTrigger: number;
  11093. /**
  11094. * On pointer out
  11095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11096. */
  11097. static readonly OnPointerOutTrigger: number;
  11098. /**
  11099. * On every frame
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11101. */
  11102. static readonly OnEveryFrameTrigger: number;
  11103. /**
  11104. * On intersection enter
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11106. */
  11107. static readonly OnIntersectionEnterTrigger: number;
  11108. /**
  11109. * On intersection exit
  11110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11111. */
  11112. static readonly OnIntersectionExitTrigger: number;
  11113. /**
  11114. * On key down
  11115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11116. */
  11117. static readonly OnKeyDownTrigger: number;
  11118. /**
  11119. * On key up
  11120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11121. */
  11122. static readonly OnKeyUpTrigger: number;
  11123. private _scene;
  11124. /**
  11125. * Creates a new action manager
  11126. * @param scene defines the hosting scene
  11127. */
  11128. constructor(scene: Scene);
  11129. /**
  11130. * Releases all associated resources
  11131. */
  11132. dispose(): void;
  11133. /**
  11134. * Gets hosting scene
  11135. * @returns the hosting scene
  11136. */
  11137. getScene(): Scene;
  11138. /**
  11139. * Does this action manager handles actions of any of the given triggers
  11140. * @param triggers defines the triggers to be tested
  11141. * @return a boolean indicating whether one (or more) of the triggers is handled
  11142. */
  11143. hasSpecificTriggers(triggers: number[]): boolean;
  11144. /**
  11145. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11146. * speed.
  11147. * @param triggerA defines the trigger to be tested
  11148. * @param triggerB defines the trigger to be tested
  11149. * @return a boolean indicating whether one (or more) of the triggers is handled
  11150. */
  11151. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11152. /**
  11153. * Does this action manager handles actions of a given trigger
  11154. * @param trigger defines the trigger to be tested
  11155. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11156. * @return whether the trigger is handled
  11157. */
  11158. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11159. /**
  11160. * Does this action manager has pointer triggers
  11161. */
  11162. readonly hasPointerTriggers: boolean;
  11163. /**
  11164. * Does this action manager has pick triggers
  11165. */
  11166. readonly hasPickTriggers: boolean;
  11167. /**
  11168. * Registers an action to this action manager
  11169. * @param action defines the action to be registered
  11170. * @return the action amended (prepared) after registration
  11171. */
  11172. registerAction(action: IAction): Nullable<IAction>;
  11173. /**
  11174. * Unregisters an action to this action manager
  11175. * @param action defines the action to be unregistered
  11176. * @return a boolean indicating whether the action has been unregistered
  11177. */
  11178. unregisterAction(action: IAction): Boolean;
  11179. /**
  11180. * Process a specific trigger
  11181. * @param trigger defines the trigger to process
  11182. * @param evt defines the event details to be processed
  11183. */
  11184. processTrigger(trigger: number, evt?: IActionEvent): void;
  11185. /** @hidden */
  11186. _getEffectiveTarget(target: any, propertyPath: string): any;
  11187. /** @hidden */
  11188. _getProperty(propertyPath: string): string;
  11189. /**
  11190. * Serialize this manager to a JSON object
  11191. * @param name defines the property name to store this manager
  11192. * @returns a JSON representation of this manager
  11193. */
  11194. serialize(name: string): any;
  11195. /**
  11196. * Creates a new ActionManager from a JSON data
  11197. * @param parsedActions defines the JSON data to read from
  11198. * @param object defines the hosting mesh
  11199. * @param scene defines the hosting scene
  11200. */
  11201. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11202. /**
  11203. * Get a trigger name by index
  11204. * @param trigger defines the trigger index
  11205. * @returns a trigger name
  11206. */
  11207. static GetTriggerName(trigger: number): string;
  11208. }
  11209. }
  11210. declare module BABYLON {
  11211. /**
  11212. * Class representing a ray with position and direction
  11213. */
  11214. export class Ray {
  11215. /** origin point */
  11216. origin: Vector3;
  11217. /** direction */
  11218. direction: Vector3;
  11219. /** length of the ray */
  11220. length: number;
  11221. private static readonly TmpVector3;
  11222. private _tmpRay;
  11223. /**
  11224. * Creates a new ray
  11225. * @param origin origin point
  11226. * @param direction direction
  11227. * @param length length of the ray
  11228. */
  11229. constructor(
  11230. /** origin point */
  11231. origin: Vector3,
  11232. /** direction */
  11233. direction: Vector3,
  11234. /** length of the ray */
  11235. length?: number);
  11236. /**
  11237. * Checks if the ray intersects a box
  11238. * @param minimum bound of the box
  11239. * @param maximum bound of the box
  11240. * @param intersectionTreshold extra extend to be added to the box in all direction
  11241. * @returns if the box was hit
  11242. */
  11243. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * Checks if the ray intersects a box
  11246. * @param box the bounding box to check
  11247. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11248. * @returns if the box was hit
  11249. */
  11250. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11251. /**
  11252. * If the ray hits a sphere
  11253. * @param sphere the bounding sphere to check
  11254. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11255. * @returns true if it hits the sphere
  11256. */
  11257. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11258. /**
  11259. * If the ray hits a triange
  11260. * @param vertex0 triangle vertex
  11261. * @param vertex1 triangle vertex
  11262. * @param vertex2 triangle vertex
  11263. * @returns intersection information if hit
  11264. */
  11265. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11266. /**
  11267. * Checks if ray intersects a plane
  11268. * @param plane the plane to check
  11269. * @returns the distance away it was hit
  11270. */
  11271. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11272. /**
  11273. * Checks if ray intersects a mesh
  11274. * @param mesh the mesh to check
  11275. * @param fastCheck if only the bounding box should checked
  11276. * @returns picking info of the intersecton
  11277. */
  11278. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11279. /**
  11280. * Checks if ray intersects a mesh
  11281. * @param meshes the meshes to check
  11282. * @param fastCheck if only the bounding box should checked
  11283. * @param results array to store result in
  11284. * @returns Array of picking infos
  11285. */
  11286. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11287. private _comparePickingInfo;
  11288. private static smallnum;
  11289. private static rayl;
  11290. /**
  11291. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11292. * @param sega the first point of the segment to test the intersection against
  11293. * @param segb the second point of the segment to test the intersection against
  11294. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11295. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11296. */
  11297. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11298. /**
  11299. * Update the ray from viewport position
  11300. * @param x position
  11301. * @param y y position
  11302. * @param viewportWidth viewport width
  11303. * @param viewportHeight viewport height
  11304. * @param world world matrix
  11305. * @param view view matrix
  11306. * @param projection projection matrix
  11307. * @returns this ray updated
  11308. */
  11309. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Creates a ray with origin and direction of 0,0,0
  11312. * @returns the new ray
  11313. */
  11314. static Zero(): Ray;
  11315. /**
  11316. * Creates a new ray from screen space and viewport
  11317. * @param x position
  11318. * @param y y position
  11319. * @param viewportWidth viewport width
  11320. * @param viewportHeight viewport height
  11321. * @param world world matrix
  11322. * @param view view matrix
  11323. * @param projection projection matrix
  11324. * @returns new ray
  11325. */
  11326. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11327. /**
  11328. * 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
  11329. * transformed to the given world matrix.
  11330. * @param origin The origin point
  11331. * @param end The end point
  11332. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11333. * @returns the new ray
  11334. */
  11335. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * Transforms a ray by a matrix
  11338. * @param ray ray to transform
  11339. * @param matrix matrix to apply
  11340. * @returns the resulting new ray
  11341. */
  11342. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11343. /**
  11344. * Transforms a ray by a matrix
  11345. * @param ray ray to transform
  11346. * @param matrix matrix to apply
  11347. * @param result ray to store result in
  11348. */
  11349. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11350. /**
  11351. * Unproject a ray from screen space to object space
  11352. * @param sourceX defines the screen space x coordinate to use
  11353. * @param sourceY defines the screen space y coordinate to use
  11354. * @param viewportWidth defines the current width of the viewport
  11355. * @param viewportHeight defines the current height of the viewport
  11356. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11357. * @param view defines the view matrix to use
  11358. * @param projection defines the projection matrix to use
  11359. */
  11360. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11361. }
  11362. /**
  11363. * Type used to define predicate used to select faces when a mesh intersection is detected
  11364. */
  11365. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11366. interface Scene {
  11367. /** @hidden */
  11368. _tempPickingRay: Nullable<Ray>;
  11369. /** @hidden */
  11370. _cachedRayForTransform: Ray;
  11371. /** @hidden */
  11372. _pickWithRayInverseMatrix: Matrix;
  11373. /** @hidden */
  11374. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11375. /** @hidden */
  11376. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11377. }
  11378. }
  11379. declare module BABYLON {
  11380. /**
  11381. * Groups all the scene component constants in one place to ease maintenance.
  11382. * @hidden
  11383. */
  11384. export class SceneComponentConstants {
  11385. static readonly NAME_EFFECTLAYER: string;
  11386. static readonly NAME_LAYER: string;
  11387. static readonly NAME_LENSFLARESYSTEM: string;
  11388. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11389. static readonly NAME_PARTICLESYSTEM: string;
  11390. static readonly NAME_GAMEPAD: string;
  11391. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11392. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11393. static readonly NAME_DEPTHRENDERER: string;
  11394. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11395. static readonly NAME_SPRITE: string;
  11396. static readonly NAME_OUTLINERENDERER: string;
  11397. static readonly NAME_PROCEDURALTEXTURE: string;
  11398. static readonly NAME_SHADOWGENERATOR: string;
  11399. static readonly NAME_OCTREE: string;
  11400. static readonly NAME_PHYSICSENGINE: string;
  11401. static readonly NAME_AUDIO: string;
  11402. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11403. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11404. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11405. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11406. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11407. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11408. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11409. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11410. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11411. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11412. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11413. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11415. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11416. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11417. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11418. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11419. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11420. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11421. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11422. static readonly STEP_AFTERRENDER_AUDIO: number;
  11423. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11424. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11425. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11426. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11427. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11428. static readonly STEP_POINTERMOVE_SPRITE: number;
  11429. static readonly STEP_POINTERDOWN_SPRITE: number;
  11430. static readonly STEP_POINTERUP_SPRITE: number;
  11431. }
  11432. /**
  11433. * This represents a scene component.
  11434. *
  11435. * This is used to decouple the dependency the scene is having on the different workloads like
  11436. * layers, post processes...
  11437. */
  11438. export interface ISceneComponent {
  11439. /**
  11440. * The name of the component. Each component must have a unique name.
  11441. */
  11442. name: string;
  11443. /**
  11444. * The scene the component belongs to.
  11445. */
  11446. scene: Scene;
  11447. /**
  11448. * Register the component to one instance of a scene.
  11449. */
  11450. register(): void;
  11451. /**
  11452. * Rebuilds the elements related to this component in case of
  11453. * context lost for instance.
  11454. */
  11455. rebuild(): void;
  11456. /**
  11457. * Disposes the component and the associated ressources.
  11458. */
  11459. dispose(): void;
  11460. }
  11461. /**
  11462. * This represents a SERIALIZABLE scene component.
  11463. *
  11464. * This extends Scene Component to add Serialization methods on top.
  11465. */
  11466. export interface ISceneSerializableComponent extends ISceneComponent {
  11467. /**
  11468. * Adds all the element from the container to the scene
  11469. * @param container the container holding the elements
  11470. */
  11471. addFromContainer(container: AbstractScene): void;
  11472. /**
  11473. * Removes all the elements in the container from the scene
  11474. * @param container contains the elements to remove
  11475. * @param dispose if the removed element should be disposed (default: false)
  11476. */
  11477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11478. /**
  11479. * Serializes the component data to the specified json object
  11480. * @param serializationObject The object to serialize to
  11481. */
  11482. serialize(serializationObject: any): void;
  11483. }
  11484. /**
  11485. * Strong typing of a Mesh related stage step action
  11486. */
  11487. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11488. /**
  11489. * Strong typing of a Evaluate Sub Mesh related stage step action
  11490. */
  11491. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11492. /**
  11493. * Strong typing of a Active Mesh related stage step action
  11494. */
  11495. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11496. /**
  11497. * Strong typing of a Camera related stage step action
  11498. */
  11499. export type CameraStageAction = (camera: Camera) => void;
  11500. /**
  11501. * Strong typing of a Render Target related stage step action
  11502. */
  11503. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11504. /**
  11505. * Strong typing of a RenderingGroup related stage step action
  11506. */
  11507. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11508. /**
  11509. * Strong typing of a Mesh Render related stage step action
  11510. */
  11511. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11512. /**
  11513. * Strong typing of a simple stage step action
  11514. */
  11515. export type SimpleStageAction = () => void;
  11516. /**
  11517. * Strong typing of a render target action.
  11518. */
  11519. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11520. /**
  11521. * Strong typing of a pointer move action.
  11522. */
  11523. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11524. /**
  11525. * Strong typing of a pointer up/down action.
  11526. */
  11527. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11528. /**
  11529. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11530. * @hidden
  11531. */
  11532. export class Stage<T extends Function> extends Array<{
  11533. index: number;
  11534. component: ISceneComponent;
  11535. action: T;
  11536. }> {
  11537. /**
  11538. * Hide ctor from the rest of the world.
  11539. * @param items The items to add.
  11540. */
  11541. private constructor();
  11542. /**
  11543. * Creates a new Stage.
  11544. * @returns A new instance of a Stage
  11545. */
  11546. static Create<T extends Function>(): Stage<T>;
  11547. /**
  11548. * Registers a step in an ordered way in the targeted stage.
  11549. * @param index Defines the position to register the step in
  11550. * @param component Defines the component attached to the step
  11551. * @param action Defines the action to launch during the step
  11552. */
  11553. registerStep(index: number, component: ISceneComponent, action: T): void;
  11554. /**
  11555. * Clears all the steps from the stage.
  11556. */
  11557. clear(): void;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. interface Scene {
  11562. /** @hidden */
  11563. _pointerOverSprite: Nullable<Sprite>;
  11564. /** @hidden */
  11565. _pickedDownSprite: Nullable<Sprite>;
  11566. /** @hidden */
  11567. _tempSpritePickingRay: Nullable<Ray>;
  11568. /**
  11569. * All of the sprite managers added to this scene
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. spriteManagers: Array<ISpriteManager>;
  11573. /**
  11574. * An event triggered when sprites rendering is about to start
  11575. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11576. */
  11577. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11578. /**
  11579. * An event triggered when sprites rendering is done
  11580. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11581. */
  11582. onAfterSpritesRenderingObservable: Observable<Scene>;
  11583. /** @hidden */
  11584. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11585. /** Launch a ray to try to pick a sprite in the scene
  11586. * @param x position on screen
  11587. * @param y position on screen
  11588. * @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
  11589. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11590. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11591. * @returns a PickingInfo
  11592. */
  11593. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11594. /** Use the given ray to pick a sprite in the scene
  11595. * @param ray The ray (in world space) to use to pick meshes
  11596. * @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
  11597. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11598. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11599. * @returns a PickingInfo
  11600. */
  11601. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11602. /**
  11603. * Force the sprite under the pointer
  11604. * @param sprite defines the sprite to use
  11605. */
  11606. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11607. /**
  11608. * Gets the sprite under the pointer
  11609. * @returns a Sprite or null if no sprite is under the pointer
  11610. */
  11611. getPointerOverSprite(): Nullable<Sprite>;
  11612. }
  11613. /**
  11614. * Defines the sprite scene component responsible to manage sprites
  11615. * in a given scene.
  11616. */
  11617. export class SpriteSceneComponent implements ISceneComponent {
  11618. /**
  11619. * The component name helpfull to identify the component in the list of scene components.
  11620. */
  11621. readonly name: string;
  11622. /**
  11623. * The scene the component belongs to.
  11624. */
  11625. scene: Scene;
  11626. /** @hidden */
  11627. private _spritePredicate;
  11628. /**
  11629. * Creates a new instance of the component for the given scene
  11630. * @param scene Defines the scene to register the component in
  11631. */
  11632. constructor(scene: Scene);
  11633. /**
  11634. * Registers the component in a given scene
  11635. */
  11636. register(): void;
  11637. /**
  11638. * Rebuilds the elements related to this component in case of
  11639. * context lost for instance.
  11640. */
  11641. rebuild(): void;
  11642. /**
  11643. * Disposes the component and the associated ressources.
  11644. */
  11645. dispose(): void;
  11646. private _pickSpriteButKeepRay;
  11647. private _pointerMove;
  11648. private _pointerDown;
  11649. private _pointerUp;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var fogFragmentDeclaration: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /** @hidden */
  11661. export var fogFragment: {
  11662. name: string;
  11663. shader: string;
  11664. };
  11665. }
  11666. declare module BABYLON {
  11667. /** @hidden */
  11668. export var spritesPixelShader: {
  11669. name: string;
  11670. shader: string;
  11671. };
  11672. }
  11673. declare module BABYLON {
  11674. /** @hidden */
  11675. export var fogVertexDeclaration: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module BABYLON {
  11681. /** @hidden */
  11682. export var spritesVertexShader: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module BABYLON {
  11688. /**
  11689. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11690. */
  11691. export interface ISpriteManager extends IDisposable {
  11692. /**
  11693. * Restricts the camera to viewing objects with the same layerMask.
  11694. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11695. */
  11696. layerMask: number;
  11697. /**
  11698. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11699. */
  11700. isPickable: boolean;
  11701. /**
  11702. * Specifies the rendering group id for this mesh (0 by default)
  11703. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11704. */
  11705. renderingGroupId: number;
  11706. /**
  11707. * Defines the list of sprites managed by the manager.
  11708. */
  11709. sprites: Array<Sprite>;
  11710. /**
  11711. * Tests the intersection of a sprite with a specific ray.
  11712. * @param ray The ray we are sending to test the collision
  11713. * @param camera The camera space we are sending rays in
  11714. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11715. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11716. * @returns picking info or null.
  11717. */
  11718. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11719. /**
  11720. * Renders the list of sprites on screen.
  11721. */
  11722. render(): void;
  11723. }
  11724. /**
  11725. * Class used to manage multiple sprites on the same spritesheet
  11726. * @see http://doc.babylonjs.com/babylon101/sprites
  11727. */
  11728. export class SpriteManager implements ISpriteManager {
  11729. /** defines the manager's name */
  11730. name: string;
  11731. /** Gets the list of sprites */
  11732. sprites: Sprite[];
  11733. /** Gets or sets the rendering group id (0 by default) */
  11734. renderingGroupId: number;
  11735. /** Gets or sets camera layer mask */
  11736. layerMask: number;
  11737. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11738. fogEnabled: boolean;
  11739. /** Gets or sets a boolean indicating if the sprites are pickable */
  11740. isPickable: boolean;
  11741. /** Defines the default width of a cell in the spritesheet */
  11742. cellWidth: number;
  11743. /** Defines the default height of a cell in the spritesheet */
  11744. cellHeight: number;
  11745. /**
  11746. * An event triggered when the manager is disposed.
  11747. */
  11748. onDisposeObservable: Observable<SpriteManager>;
  11749. private _onDisposeObserver;
  11750. /**
  11751. * Callback called when the manager is disposed
  11752. */
  11753. onDispose: () => void;
  11754. private _capacity;
  11755. private _spriteTexture;
  11756. private _epsilon;
  11757. private _scene;
  11758. private _vertexData;
  11759. private _buffer;
  11760. private _vertexBuffers;
  11761. private _indexBuffer;
  11762. private _effectBase;
  11763. private _effectFog;
  11764. /**
  11765. * Gets or sets the spritesheet texture
  11766. */
  11767. texture: Texture;
  11768. /**
  11769. * Creates a new sprite manager
  11770. * @param name defines the manager's name
  11771. * @param imgUrl defines the sprite sheet url
  11772. * @param capacity defines the maximum allowed number of sprites
  11773. * @param cellSize defines the size of a sprite cell
  11774. * @param scene defines the hosting scene
  11775. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11776. * @param samplingMode defines the smapling mode to use with spritesheet
  11777. */
  11778. constructor(
  11779. /** defines the manager's name */
  11780. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11781. private _appendSpriteVertex;
  11782. /**
  11783. * Intersects the sprites with a ray
  11784. * @param ray defines the ray to intersect with
  11785. * @param camera defines the current active camera
  11786. * @param predicate defines a predicate used to select candidate sprites
  11787. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11788. * @returns null if no hit or a PickingInfo
  11789. */
  11790. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11791. /**
  11792. * Render all child sprites
  11793. */
  11794. render(): void;
  11795. /**
  11796. * Release associated resources
  11797. */
  11798. dispose(): void;
  11799. }
  11800. }
  11801. declare module BABYLON {
  11802. /**
  11803. * Class used to represent a sprite
  11804. * @see http://doc.babylonjs.com/babylon101/sprites
  11805. */
  11806. export class Sprite {
  11807. /** defines the name */
  11808. name: string;
  11809. /** Gets or sets the current world position */
  11810. position: Vector3;
  11811. /** Gets or sets the main color */
  11812. color: Color4;
  11813. /** Gets or sets the width */
  11814. width: number;
  11815. /** Gets or sets the height */
  11816. height: number;
  11817. /** Gets or sets rotation angle */
  11818. angle: number;
  11819. /** Gets or sets the cell index in the sprite sheet */
  11820. cellIndex: number;
  11821. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11822. invertU: number;
  11823. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11824. invertV: number;
  11825. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11826. disposeWhenFinishedAnimating: boolean;
  11827. /** Gets the list of attached animations */
  11828. animations: Animation[];
  11829. /** Gets or sets a boolean indicating if the sprite can be picked */
  11830. isPickable: boolean;
  11831. /**
  11832. * Gets or sets the associated action manager
  11833. */
  11834. actionManager: Nullable<ActionManager>;
  11835. private _animationStarted;
  11836. private _loopAnimation;
  11837. private _fromIndex;
  11838. private _toIndex;
  11839. private _delay;
  11840. private _direction;
  11841. private _manager;
  11842. private _time;
  11843. private _onAnimationEnd;
  11844. /**
  11845. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11846. */
  11847. isVisible: boolean;
  11848. /**
  11849. * Gets or sets the sprite size
  11850. */
  11851. size: number;
  11852. /**
  11853. * Creates a new Sprite
  11854. * @param name defines the name
  11855. * @param manager defines the manager
  11856. */
  11857. constructor(
  11858. /** defines the name */
  11859. name: string, manager: ISpriteManager);
  11860. /**
  11861. * Starts an animation
  11862. * @param from defines the initial key
  11863. * @param to defines the end key
  11864. * @param loop defines if the animation must loop
  11865. * @param delay defines the start delay (in ms)
  11866. * @param onAnimationEnd defines a callback to call when animation ends
  11867. */
  11868. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11869. /** Stops current animation (if any) */
  11870. stopAnimation(): void;
  11871. /** @hidden */
  11872. _animate(deltaTime: number): void;
  11873. /** Release associated resources */
  11874. dispose(): void;
  11875. }
  11876. }
  11877. declare module BABYLON {
  11878. /**
  11879. * Information about the result of picking within a scene
  11880. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11881. */
  11882. export class PickingInfo {
  11883. /** @hidden */
  11884. _pickingUnavailable: boolean;
  11885. /**
  11886. * If the pick collided with an object
  11887. */
  11888. hit: boolean;
  11889. /**
  11890. * Distance away where the pick collided
  11891. */
  11892. distance: number;
  11893. /**
  11894. * The location of pick collision
  11895. */
  11896. pickedPoint: Nullable<Vector3>;
  11897. /**
  11898. * The mesh corresponding the the pick collision
  11899. */
  11900. pickedMesh: Nullable<AbstractMesh>;
  11901. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11902. bu: number;
  11903. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11904. bv: number;
  11905. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11906. faceId: number;
  11907. /** Id of the the submesh that was picked */
  11908. subMeshId: number;
  11909. /** If a sprite was picked, this will be the sprite the pick collided with */
  11910. pickedSprite: Nullable<Sprite>;
  11911. /**
  11912. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11913. */
  11914. originMesh: Nullable<AbstractMesh>;
  11915. /**
  11916. * The ray that was used to perform the picking.
  11917. */
  11918. ray: Nullable<Ray>;
  11919. /**
  11920. * Gets the normal correspodning to the face the pick collided with
  11921. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11922. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11923. * @returns The normal correspodning to the face the pick collided with
  11924. */
  11925. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11926. /**
  11927. * Gets the texture coordinates of where the pick occured
  11928. * @returns the vector containing the coordnates of the texture
  11929. */
  11930. getTextureCoordinates(): Nullable<Vector2>;
  11931. }
  11932. }
  11933. declare module BABYLON {
  11934. /**
  11935. * Gather the list of pointer event types as constants.
  11936. */
  11937. export class PointerEventTypes {
  11938. /**
  11939. * 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.
  11940. */
  11941. static readonly POINTERDOWN: number;
  11942. /**
  11943. * The pointerup event is fired when a pointer is no longer active.
  11944. */
  11945. static readonly POINTERUP: number;
  11946. /**
  11947. * The pointermove event is fired when a pointer changes coordinates.
  11948. */
  11949. static readonly POINTERMOVE: number;
  11950. /**
  11951. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11952. */
  11953. static readonly POINTERWHEEL: number;
  11954. /**
  11955. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11956. */
  11957. static readonly POINTERPICK: number;
  11958. /**
  11959. * The pointertap event is fired when a the object has been touched and released without drag.
  11960. */
  11961. static readonly POINTERTAP: number;
  11962. /**
  11963. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11964. */
  11965. static readonly POINTERDOUBLETAP: number;
  11966. }
  11967. /**
  11968. * Base class of pointer info types.
  11969. */
  11970. export class PointerInfoBase {
  11971. /**
  11972. * Defines the type of event (PointerEventTypes)
  11973. */
  11974. type: number;
  11975. /**
  11976. * Defines the related dom event
  11977. */
  11978. event: PointerEvent | MouseWheelEvent;
  11979. /**
  11980. * Instantiates the base class of pointers info.
  11981. * @param type Defines the type of event (PointerEventTypes)
  11982. * @param event Defines the related dom event
  11983. */
  11984. constructor(
  11985. /**
  11986. * Defines the type of event (PointerEventTypes)
  11987. */
  11988. type: number,
  11989. /**
  11990. * Defines the related dom event
  11991. */
  11992. event: PointerEvent | MouseWheelEvent);
  11993. }
  11994. /**
  11995. * This class is used to store pointer related info for the onPrePointerObservable event.
  11996. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11997. */
  11998. export class PointerInfoPre extends PointerInfoBase {
  11999. /**
  12000. * Ray from a pointer if availible (eg. 6dof controller)
  12001. */
  12002. ray: Nullable<Ray>;
  12003. /**
  12004. * Defines the local position of the pointer on the canvas.
  12005. */
  12006. localPosition: Vector2;
  12007. /**
  12008. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12009. */
  12010. skipOnPointerObservable: boolean;
  12011. /**
  12012. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12013. * @param type Defines the type of event (PointerEventTypes)
  12014. * @param event Defines the related dom event
  12015. * @param localX Defines the local x coordinates of the pointer when the event occured
  12016. * @param localY Defines the local y coordinates of the pointer when the event occured
  12017. */
  12018. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12019. }
  12020. /**
  12021. * This type contains all the data related to a pointer event in Babylon.js.
  12022. * 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.
  12023. */
  12024. export class PointerInfo extends PointerInfoBase {
  12025. /**
  12026. * Defines the picking info associated to the info (if any)\
  12027. */
  12028. pickInfo: Nullable<PickingInfo>;
  12029. /**
  12030. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12031. * @param type Defines the type of event (PointerEventTypes)
  12032. * @param event Defines the related dom event
  12033. * @param pickInfo Defines the picking info associated to the info (if any)\
  12034. */
  12035. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12036. /**
  12037. * Defines the picking info associated to the info (if any)\
  12038. */
  12039. pickInfo: Nullable<PickingInfo>);
  12040. }
  12041. /**
  12042. * Data relating to a touch event on the screen.
  12043. */
  12044. export interface PointerTouch {
  12045. /**
  12046. * X coordinate of touch.
  12047. */
  12048. x: number;
  12049. /**
  12050. * Y coordinate of touch.
  12051. */
  12052. y: number;
  12053. /**
  12054. * Id of touch. Unique for each finger.
  12055. */
  12056. pointerId: number;
  12057. /**
  12058. * Event type passed from DOM.
  12059. */
  12060. type: any;
  12061. }
  12062. }
  12063. declare module BABYLON {
  12064. /**
  12065. * Manage the mouse inputs to control the movement of a free camera.
  12066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12067. */
  12068. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12069. /**
  12070. * Define if touch is enabled in the mouse input
  12071. */
  12072. touchEnabled: boolean;
  12073. /**
  12074. * Defines the camera the input is attached to.
  12075. */
  12076. camera: FreeCamera;
  12077. /**
  12078. * Defines the buttons associated with the input to handle camera move.
  12079. */
  12080. buttons: number[];
  12081. /**
  12082. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12083. */
  12084. angularSensibility: number;
  12085. private _pointerInput;
  12086. private _onMouseMove;
  12087. private _observer;
  12088. private previousPosition;
  12089. /**
  12090. * Observable for when a pointer move event occurs containing the move offset
  12091. */
  12092. onPointerMovedObservable: Observable<{
  12093. offsetX: number;
  12094. offsetY: number;
  12095. }>;
  12096. /**
  12097. * @hidden
  12098. * If the camera should be rotated automatically based on pointer movement
  12099. */
  12100. _allowCameraRotation: boolean;
  12101. /**
  12102. * Manage the mouse inputs to control the movement of a free camera.
  12103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12104. * @param touchEnabled Defines if touch is enabled or not
  12105. */
  12106. constructor(
  12107. /**
  12108. * Define if touch is enabled in the mouse input
  12109. */
  12110. touchEnabled?: boolean);
  12111. /**
  12112. * Attach the input controls to a specific dom element to get the input from.
  12113. * @param element Defines the element the controls should be listened from
  12114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12115. */
  12116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12117. /**
  12118. * Called on JS contextmenu event.
  12119. * Override this method to provide functionality.
  12120. */
  12121. protected onContextMenu(evt: PointerEvent): void;
  12122. /**
  12123. * Detach the current controls from the specified dom element.
  12124. * @param element Defines the element to stop listening the inputs from
  12125. */
  12126. detachControl(element: Nullable<HTMLElement>): void;
  12127. /**
  12128. * Gets the class name of the current intput.
  12129. * @returns the class name
  12130. */
  12131. getClassName(): string;
  12132. /**
  12133. * Get the friendly name associated with the input class.
  12134. * @returns the input friendly name
  12135. */
  12136. getSimpleName(): string;
  12137. }
  12138. }
  12139. declare module BABYLON {
  12140. /**
  12141. * Manage the touch inputs to control the movement of a free camera.
  12142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12143. */
  12144. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12145. /**
  12146. * Defines the camera the input is attached to.
  12147. */
  12148. camera: FreeCamera;
  12149. /**
  12150. * Defines the touch sensibility for rotation.
  12151. * The higher the faster.
  12152. */
  12153. touchAngularSensibility: number;
  12154. /**
  12155. * Defines the touch sensibility for move.
  12156. * The higher the faster.
  12157. */
  12158. touchMoveSensibility: number;
  12159. private _offsetX;
  12160. private _offsetY;
  12161. private _pointerPressed;
  12162. private _pointerInput;
  12163. private _observer;
  12164. private _onLostFocus;
  12165. /**
  12166. * Attach the input controls to a specific dom element to get the input from.
  12167. * @param element Defines the element the controls should be listened from
  12168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12169. */
  12170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12171. /**
  12172. * Detach the current controls from the specified dom element.
  12173. * @param element Defines the element to stop listening the inputs from
  12174. */
  12175. detachControl(element: Nullable<HTMLElement>): void;
  12176. /**
  12177. * Update the current camera state depending on the inputs that have been used this frame.
  12178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12179. */
  12180. checkInputs(): void;
  12181. /**
  12182. * Gets the class name of the current intput.
  12183. * @returns the class name
  12184. */
  12185. getClassName(): string;
  12186. /**
  12187. * Get the friendly name associated with the input class.
  12188. * @returns the input friendly name
  12189. */
  12190. getSimpleName(): string;
  12191. }
  12192. }
  12193. declare module BABYLON {
  12194. /**
  12195. * Default Inputs manager for the FreeCamera.
  12196. * It groups all the default supported inputs for ease of use.
  12197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12198. */
  12199. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12200. /**
  12201. * @hidden
  12202. */
  12203. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12204. /**
  12205. * @hidden
  12206. */
  12207. _mouseInput: Nullable<FreeCameraMouseInput>;
  12208. /**
  12209. * Instantiates a new FreeCameraInputsManager.
  12210. * @param camera Defines the camera the inputs belong to
  12211. */
  12212. constructor(camera: FreeCamera);
  12213. /**
  12214. * Add keyboard input support to the input manager.
  12215. * @returns the current input manager
  12216. */
  12217. addKeyboard(): FreeCameraInputsManager;
  12218. /**
  12219. * Add mouse input support to the input manager.
  12220. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12221. * @returns the current input manager
  12222. */
  12223. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12224. /**
  12225. * Removes the mouse input support from the manager
  12226. * @returns the current input manager
  12227. */
  12228. removeMouse(): FreeCameraInputsManager;
  12229. /**
  12230. * Add touch input support to the input manager.
  12231. * @returns the current input manager
  12232. */
  12233. addTouch(): FreeCameraInputsManager;
  12234. }
  12235. }
  12236. declare module BABYLON {
  12237. /**
  12238. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12239. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12241. */
  12242. export class FreeCamera extends TargetCamera {
  12243. /**
  12244. * Define the collision ellipsoid of the camera.
  12245. * This is helpful to simulate a camera body like the player body around the camera
  12246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12247. */
  12248. ellipsoid: Vector3;
  12249. /**
  12250. * Define an offset for the position of the ellipsoid around the camera.
  12251. * This can be helpful to determine the center of the body near the gravity center of the body
  12252. * instead of its head.
  12253. */
  12254. ellipsoidOffset: Vector3;
  12255. /**
  12256. * Enable or disable collisions of the camera with the rest of the scene objects.
  12257. */
  12258. checkCollisions: boolean;
  12259. /**
  12260. * Enable or disable gravity on the camera.
  12261. */
  12262. applyGravity: boolean;
  12263. /**
  12264. * Define the input manager associated to the camera.
  12265. */
  12266. inputs: FreeCameraInputsManager;
  12267. /**
  12268. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12269. * Higher values reduce sensitivity.
  12270. */
  12271. /**
  12272. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12273. * Higher values reduce sensitivity.
  12274. */
  12275. angularSensibility: number;
  12276. /**
  12277. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12278. */
  12279. keysUp: number[];
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12282. */
  12283. keysDown: number[];
  12284. /**
  12285. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12286. */
  12287. keysLeft: number[];
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12290. */
  12291. keysRight: number[];
  12292. /**
  12293. * Event raised when the camera collide with a mesh in the scene.
  12294. */
  12295. onCollide: (collidedMesh: AbstractMesh) => void;
  12296. private _collider;
  12297. private _needMoveForGravity;
  12298. private _oldPosition;
  12299. private _diffPosition;
  12300. private _newPosition;
  12301. /** @hidden */
  12302. _localDirection: Vector3;
  12303. /** @hidden */
  12304. _transformedDirection: Vector3;
  12305. /**
  12306. * Instantiates a Free Camera.
  12307. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12308. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12310. * @param name Define the name of the camera in the scene
  12311. * @param position Define the start position of the camera in the scene
  12312. * @param scene Define the scene the camera belongs to
  12313. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12314. */
  12315. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12316. /**
  12317. * Attached controls to the current camera.
  12318. * @param element Defines the element the controls should be listened from
  12319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12320. */
  12321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12322. /**
  12323. * Detach the current controls from the camera.
  12324. * The camera will stop reacting to inputs.
  12325. * @param element Defines the element to stop listening the inputs from
  12326. */
  12327. detachControl(element: HTMLElement): void;
  12328. private _collisionMask;
  12329. /**
  12330. * Define a collision mask to limit the list of object the camera can collide with
  12331. */
  12332. collisionMask: number;
  12333. /** @hidden */
  12334. _collideWithWorld(displacement: Vector3): void;
  12335. private _onCollisionPositionChange;
  12336. /** @hidden */
  12337. _checkInputs(): void;
  12338. /** @hidden */
  12339. _decideIfNeedsToMove(): boolean;
  12340. /** @hidden */
  12341. _updatePosition(): void;
  12342. /**
  12343. * Destroy the camera and release the current resources hold by it.
  12344. */
  12345. dispose(): void;
  12346. /**
  12347. * Gets the current object class name.
  12348. * @return the class name
  12349. */
  12350. getClassName(): string;
  12351. }
  12352. }
  12353. declare module BABYLON {
  12354. /**
  12355. * Represents a gamepad control stick position
  12356. */
  12357. export class StickValues {
  12358. /**
  12359. * The x component of the control stick
  12360. */
  12361. x: number;
  12362. /**
  12363. * The y component of the control stick
  12364. */
  12365. y: number;
  12366. /**
  12367. * Initializes the gamepad x and y control stick values
  12368. * @param x The x component of the gamepad control stick value
  12369. * @param y The y component of the gamepad control stick value
  12370. */
  12371. constructor(
  12372. /**
  12373. * The x component of the control stick
  12374. */
  12375. x: number,
  12376. /**
  12377. * The y component of the control stick
  12378. */
  12379. y: number);
  12380. }
  12381. /**
  12382. * An interface which manages callbacks for gamepad button changes
  12383. */
  12384. export interface GamepadButtonChanges {
  12385. /**
  12386. * Called when a gamepad has been changed
  12387. */
  12388. changed: boolean;
  12389. /**
  12390. * Called when a gamepad press event has been triggered
  12391. */
  12392. pressChanged: boolean;
  12393. /**
  12394. * Called when a touch event has been triggered
  12395. */
  12396. touchChanged: boolean;
  12397. /**
  12398. * Called when a value has changed
  12399. */
  12400. valueChanged: boolean;
  12401. }
  12402. /**
  12403. * Represents a gamepad
  12404. */
  12405. export class Gamepad {
  12406. /**
  12407. * The id of the gamepad
  12408. */
  12409. id: string;
  12410. /**
  12411. * The index of the gamepad
  12412. */
  12413. index: number;
  12414. /**
  12415. * The browser gamepad
  12416. */
  12417. browserGamepad: any;
  12418. /**
  12419. * Specifies what type of gamepad this represents
  12420. */
  12421. type: number;
  12422. private _leftStick;
  12423. private _rightStick;
  12424. /** @hidden */
  12425. _isConnected: boolean;
  12426. private _leftStickAxisX;
  12427. private _leftStickAxisY;
  12428. private _rightStickAxisX;
  12429. private _rightStickAxisY;
  12430. /**
  12431. * Triggered when the left control stick has been changed
  12432. */
  12433. private _onleftstickchanged;
  12434. /**
  12435. * Triggered when the right control stick has been changed
  12436. */
  12437. private _onrightstickchanged;
  12438. /**
  12439. * Represents a gamepad controller
  12440. */
  12441. static GAMEPAD: number;
  12442. /**
  12443. * Represents a generic controller
  12444. */
  12445. static GENERIC: number;
  12446. /**
  12447. * Represents an XBox controller
  12448. */
  12449. static XBOX: number;
  12450. /**
  12451. * Represents a pose-enabled controller
  12452. */
  12453. static POSE_ENABLED: number;
  12454. /**
  12455. * Specifies whether the left control stick should be Y-inverted
  12456. */
  12457. protected _invertLeftStickY: boolean;
  12458. /**
  12459. * Specifies if the gamepad has been connected
  12460. */
  12461. readonly isConnected: boolean;
  12462. /**
  12463. * Initializes the gamepad
  12464. * @param id The id of the gamepad
  12465. * @param index The index of the gamepad
  12466. * @param browserGamepad The browser gamepad
  12467. * @param leftStickX The x component of the left joystick
  12468. * @param leftStickY The y component of the left joystick
  12469. * @param rightStickX The x component of the right joystick
  12470. * @param rightStickY The y component of the right joystick
  12471. */
  12472. constructor(
  12473. /**
  12474. * The id of the gamepad
  12475. */
  12476. id: string,
  12477. /**
  12478. * The index of the gamepad
  12479. */
  12480. index: number,
  12481. /**
  12482. * The browser gamepad
  12483. */
  12484. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12485. /**
  12486. * Callback triggered when the left joystick has changed
  12487. * @param callback
  12488. */
  12489. onleftstickchanged(callback: (values: StickValues) => void): void;
  12490. /**
  12491. * Callback triggered when the right joystick has changed
  12492. * @param callback
  12493. */
  12494. onrightstickchanged(callback: (values: StickValues) => void): void;
  12495. /**
  12496. * Gets the left joystick
  12497. */
  12498. /**
  12499. * Sets the left joystick values
  12500. */
  12501. leftStick: StickValues;
  12502. /**
  12503. * Gets the right joystick
  12504. */
  12505. /**
  12506. * Sets the right joystick value
  12507. */
  12508. rightStick: StickValues;
  12509. /**
  12510. * Updates the gamepad joystick positions
  12511. */
  12512. update(): void;
  12513. /**
  12514. * Disposes the gamepad
  12515. */
  12516. dispose(): void;
  12517. }
  12518. /**
  12519. * Represents a generic gamepad
  12520. */
  12521. export class GenericPad extends Gamepad {
  12522. private _buttons;
  12523. private _onbuttondown;
  12524. private _onbuttonup;
  12525. /**
  12526. * Observable triggered when a button has been pressed
  12527. */
  12528. onButtonDownObservable: Observable<number>;
  12529. /**
  12530. * Observable triggered when a button has been released
  12531. */
  12532. onButtonUpObservable: Observable<number>;
  12533. /**
  12534. * Callback triggered when a button has been pressed
  12535. * @param callback Called when a button has been pressed
  12536. */
  12537. onbuttondown(callback: (buttonPressed: number) => void): void;
  12538. /**
  12539. * Callback triggered when a button has been released
  12540. * @param callback Called when a button has been released
  12541. */
  12542. onbuttonup(callback: (buttonReleased: number) => void): void;
  12543. /**
  12544. * Initializes the generic gamepad
  12545. * @param id The id of the generic gamepad
  12546. * @param index The index of the generic gamepad
  12547. * @param browserGamepad The browser gamepad
  12548. */
  12549. constructor(id: string, index: number, browserGamepad: any);
  12550. private _setButtonValue;
  12551. /**
  12552. * Updates the generic gamepad
  12553. */
  12554. update(): void;
  12555. /**
  12556. * Disposes the generic gamepad
  12557. */
  12558. dispose(): void;
  12559. }
  12560. }
  12561. declare module BABYLON {
  12562. /**
  12563. * Defines the types of pose enabled controllers that are supported
  12564. */
  12565. export enum PoseEnabledControllerType {
  12566. /**
  12567. * HTC Vive
  12568. */
  12569. VIVE = 0,
  12570. /**
  12571. * Oculus Rift
  12572. */
  12573. OCULUS = 1,
  12574. /**
  12575. * Windows mixed reality
  12576. */
  12577. WINDOWS = 2,
  12578. /**
  12579. * Samsung gear VR
  12580. */
  12581. GEAR_VR = 3,
  12582. /**
  12583. * Google Daydream
  12584. */
  12585. DAYDREAM = 4,
  12586. /**
  12587. * Generic
  12588. */
  12589. GENERIC = 5
  12590. }
  12591. /**
  12592. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12593. */
  12594. export interface MutableGamepadButton {
  12595. /**
  12596. * Value of the button/trigger
  12597. */
  12598. value: number;
  12599. /**
  12600. * If the button/trigger is currently touched
  12601. */
  12602. touched: boolean;
  12603. /**
  12604. * If the button/trigger is currently pressed
  12605. */
  12606. pressed: boolean;
  12607. }
  12608. /**
  12609. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12610. * @hidden
  12611. */
  12612. export interface ExtendedGamepadButton extends GamepadButton {
  12613. /**
  12614. * If the button/trigger is currently pressed
  12615. */
  12616. readonly pressed: boolean;
  12617. /**
  12618. * If the button/trigger is currently touched
  12619. */
  12620. readonly touched: boolean;
  12621. /**
  12622. * Value of the button/trigger
  12623. */
  12624. readonly value: number;
  12625. }
  12626. /** @hidden */
  12627. export interface _GamePadFactory {
  12628. /**
  12629. * Returns wether or not the current gamepad can be created for this type of controller.
  12630. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12631. * @returns true if it can be created, otherwise false
  12632. */
  12633. canCreate(gamepadInfo: any): boolean;
  12634. /**
  12635. * Creates a new instance of the Gamepad.
  12636. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12637. * @returns the new gamepad instance
  12638. */
  12639. create(gamepadInfo: any): Gamepad;
  12640. }
  12641. /**
  12642. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12643. */
  12644. export class PoseEnabledControllerHelper {
  12645. /** @hidden */
  12646. static _ControllerFactories: _GamePadFactory[];
  12647. /** @hidden */
  12648. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12649. /**
  12650. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12651. * @param vrGamepad the gamepad to initialized
  12652. * @returns a vr controller of the type the gamepad identified as
  12653. */
  12654. static InitiateController(vrGamepad: any): Gamepad;
  12655. }
  12656. /**
  12657. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12658. */
  12659. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12660. private _deviceRoomPosition;
  12661. private _deviceRoomRotationQuaternion;
  12662. /**
  12663. * The device position in babylon space
  12664. */
  12665. devicePosition: Vector3;
  12666. /**
  12667. * The device rotation in babylon space
  12668. */
  12669. deviceRotationQuaternion: Quaternion;
  12670. /**
  12671. * The scale factor of the device in babylon space
  12672. */
  12673. deviceScaleFactor: number;
  12674. /**
  12675. * (Likely devicePosition should be used instead) The device position in its room space
  12676. */
  12677. position: Vector3;
  12678. /**
  12679. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12680. */
  12681. rotationQuaternion: Quaternion;
  12682. /**
  12683. * The type of controller (Eg. Windows mixed reality)
  12684. */
  12685. controllerType: PoseEnabledControllerType;
  12686. protected _calculatedPosition: Vector3;
  12687. private _calculatedRotation;
  12688. /**
  12689. * The raw pose from the device
  12690. */
  12691. rawPose: DevicePose;
  12692. private _trackPosition;
  12693. private _maxRotationDistFromHeadset;
  12694. private _draggedRoomRotation;
  12695. /**
  12696. * @hidden
  12697. */
  12698. _disableTrackPosition(fixedPosition: Vector3): void;
  12699. /**
  12700. * Internal, the mesh attached to the controller
  12701. * @hidden
  12702. */
  12703. _mesh: Nullable<AbstractMesh>;
  12704. private _poseControlledCamera;
  12705. private _leftHandSystemQuaternion;
  12706. /**
  12707. * Internal, matrix used to convert room space to babylon space
  12708. * @hidden
  12709. */
  12710. _deviceToWorld: Matrix;
  12711. /**
  12712. * Node to be used when casting a ray from the controller
  12713. * @hidden
  12714. */
  12715. _pointingPoseNode: Nullable<TransformNode>;
  12716. /**
  12717. * Name of the child mesh that can be used to cast a ray from the controller
  12718. */
  12719. static readonly POINTING_POSE: string;
  12720. /**
  12721. * Creates a new PoseEnabledController from a gamepad
  12722. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12723. */
  12724. constructor(browserGamepad: any);
  12725. private _workingMatrix;
  12726. /**
  12727. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12728. */
  12729. update(): void;
  12730. /**
  12731. * Updates only the pose device and mesh without doing any button event checking
  12732. */
  12733. protected _updatePoseAndMesh(): void;
  12734. /**
  12735. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12736. * @param poseData raw pose fromthe device
  12737. */
  12738. updateFromDevice(poseData: DevicePose): void;
  12739. /**
  12740. * @hidden
  12741. */
  12742. _meshAttachedObservable: Observable<AbstractMesh>;
  12743. /**
  12744. * Attaches a mesh to the controller
  12745. * @param mesh the mesh to be attached
  12746. */
  12747. attachToMesh(mesh: AbstractMesh): void;
  12748. /**
  12749. * Attaches the controllers mesh to a camera
  12750. * @param camera the camera the mesh should be attached to
  12751. */
  12752. attachToPoseControlledCamera(camera: TargetCamera): void;
  12753. /**
  12754. * Disposes of the controller
  12755. */
  12756. dispose(): void;
  12757. /**
  12758. * The mesh that is attached to the controller
  12759. */
  12760. readonly mesh: Nullable<AbstractMesh>;
  12761. /**
  12762. * Gets the ray of the controller in the direction the controller is pointing
  12763. * @param length the length the resulting ray should be
  12764. * @returns a ray in the direction the controller is pointing
  12765. */
  12766. getForwardRay(length?: number): Ray;
  12767. }
  12768. }
  12769. declare module BABYLON {
  12770. /**
  12771. * Defines the WebVRController object that represents controllers tracked in 3D space
  12772. */
  12773. export abstract class WebVRController extends PoseEnabledController {
  12774. /**
  12775. * Internal, the default controller model for the controller
  12776. */
  12777. protected _defaultModel: AbstractMesh;
  12778. /**
  12779. * Fired when the trigger state has changed
  12780. */
  12781. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12782. /**
  12783. * Fired when the main button state has changed
  12784. */
  12785. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12786. /**
  12787. * Fired when the secondary button state has changed
  12788. */
  12789. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12790. /**
  12791. * Fired when the pad state has changed
  12792. */
  12793. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12794. /**
  12795. * Fired when controllers stick values have changed
  12796. */
  12797. onPadValuesChangedObservable: Observable<StickValues>;
  12798. /**
  12799. * Array of button availible on the controller
  12800. */
  12801. protected _buttons: Array<MutableGamepadButton>;
  12802. private _onButtonStateChange;
  12803. /**
  12804. * Fired when a controller button's state has changed
  12805. * @param callback the callback containing the button that was modified
  12806. */
  12807. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12808. /**
  12809. * X and Y axis corrisponding to the controllers joystick
  12810. */
  12811. pad: StickValues;
  12812. /**
  12813. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12814. */
  12815. hand: string;
  12816. /**
  12817. * The default controller model for the controller
  12818. */
  12819. readonly defaultModel: AbstractMesh;
  12820. /**
  12821. * Creates a new WebVRController from a gamepad
  12822. * @param vrGamepad the gamepad that the WebVRController should be created from
  12823. */
  12824. constructor(vrGamepad: any);
  12825. /**
  12826. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12827. */
  12828. update(): void;
  12829. /**
  12830. * Function to be called when a button is modified
  12831. */
  12832. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12833. /**
  12834. * Loads a mesh and attaches it to the controller
  12835. * @param scene the scene the mesh should be added to
  12836. * @param meshLoaded callback for when the mesh has been loaded
  12837. */
  12838. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12839. private _setButtonValue;
  12840. private _changes;
  12841. private _checkChanges;
  12842. /**
  12843. * Disposes of th webVRCOntroller
  12844. */
  12845. dispose(): void;
  12846. }
  12847. }
  12848. declare module BABYLON {
  12849. /**
  12850. * The HemisphericLight simulates the ambient environment light,
  12851. * so the passed direction is the light reflection direction, not the incoming direction.
  12852. */
  12853. export class HemisphericLight extends Light {
  12854. /**
  12855. * The groundColor is the light in the opposite direction to the one specified during creation.
  12856. * 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.
  12857. */
  12858. groundColor: Color3;
  12859. /**
  12860. * The light reflection direction, not the incoming direction.
  12861. */
  12862. direction: Vector3;
  12863. /**
  12864. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12865. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12866. * The HemisphericLight can't cast shadows.
  12867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12868. * @param name The friendly name of the light
  12869. * @param direction The direction of the light reflection
  12870. * @param scene The scene the light belongs to
  12871. */
  12872. constructor(name: string, direction: Vector3, scene: Scene);
  12873. protected _buildUniformLayout(): void;
  12874. /**
  12875. * Returns the string "HemisphericLight".
  12876. * @return The class name
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12881. * Returns the updated direction.
  12882. * @param target The target the direction should point to
  12883. * @return The computed direction
  12884. */
  12885. setDirectionToTarget(target: Vector3): Vector3;
  12886. /**
  12887. * Returns the shadow generator associated to the light.
  12888. * @returns Always null for hemispheric lights because it does not support shadows.
  12889. */
  12890. getShadowGenerator(): Nullable<IShadowGenerator>;
  12891. /**
  12892. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12893. * @param effect The effect to update
  12894. * @param lightIndex The index of the light in the effect to update
  12895. * @returns The hemispheric light
  12896. */
  12897. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12898. /**
  12899. * Computes the world matrix of the node
  12900. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12901. * @param useWasUpdatedFlag defines a reserved property
  12902. * @returns the world matrix
  12903. */
  12904. computeWorldMatrix(): Matrix;
  12905. /**
  12906. * Returns the integer 3.
  12907. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12908. */
  12909. getTypeID(): number;
  12910. /**
  12911. * Prepares the list of defines specific to the light type.
  12912. * @param defines the list of defines
  12913. * @param lightIndex defines the index of the light for the effect
  12914. */
  12915. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12916. }
  12917. }
  12918. declare module BABYLON {
  12919. /** @hidden */
  12920. export var vrMultiviewToSingleviewPixelShader: {
  12921. name: string;
  12922. shader: string;
  12923. };
  12924. }
  12925. declare module BABYLON {
  12926. /**
  12927. * Renders to multiple views with a single draw call
  12928. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12929. */
  12930. export class MultiviewRenderTarget extends RenderTargetTexture {
  12931. /**
  12932. * Creates a multiview render target
  12933. * @param scene scene used with the render target
  12934. * @param size the size of the render target (used for each view)
  12935. */
  12936. constructor(scene: Scene, size?: number | {
  12937. width: number;
  12938. height: number;
  12939. } | {
  12940. ratio: number;
  12941. });
  12942. /**
  12943. * @hidden
  12944. * @param faceIndex the face index, if its a cube texture
  12945. */
  12946. _bindFrameBuffer(faceIndex?: number): void;
  12947. /**
  12948. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12949. * @returns the view count
  12950. */
  12951. getViewCount(): number;
  12952. }
  12953. }
  12954. declare module BABYLON {
  12955. interface Engine {
  12956. /**
  12957. * Creates a new multiview render target
  12958. * @param width defines the width of the texture
  12959. * @param height defines the height of the texture
  12960. * @returns the created multiview texture
  12961. */
  12962. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12963. /**
  12964. * Binds a multiview framebuffer to be drawn to
  12965. * @param multiviewTexture texture to bind
  12966. */
  12967. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12968. }
  12969. interface Camera {
  12970. /**
  12971. * @hidden
  12972. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12973. */
  12974. _useMultiviewToSingleView: boolean;
  12975. /**
  12976. * @hidden
  12977. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  12978. */
  12979. _multiviewTexture: Nullable<RenderTargetTexture>;
  12980. /**
  12981. * @hidden
  12982. * ensures the multiview texture of the camera exists and has the specified width/height
  12983. * @param width height to set on the multiview texture
  12984. * @param height width to set on the multiview texture
  12985. */
  12986. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12987. }
  12988. interface Scene {
  12989. /** @hidden */
  12990. _transformMatrixR: Matrix;
  12991. /** @hidden */
  12992. _multiviewSceneUbo: Nullable<UniformBuffer>;
  12993. /** @hidden */
  12994. _createMultiviewUbo(): void;
  12995. /** @hidden */
  12996. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12997. /** @hidden */
  12998. _renderMultiviewToSingleView(camera: Camera): void;
  12999. }
  13000. }
  13001. declare module BABYLON {
  13002. /**
  13003. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13004. * This will not be used for webXR as it supports displaying texture arrays directly
  13005. */
  13006. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13007. /**
  13008. * Initializes a VRMultiviewToSingleview
  13009. * @param name name of the post process
  13010. * @param camera camera to be applied to
  13011. * @param scaleFactor scaling factor to the size of the output texture
  13012. */
  13013. constructor(name: string, camera: Camera, scaleFactor: number);
  13014. }
  13015. }
  13016. declare module BABYLON {
  13017. /**
  13018. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13019. * IMPORTANT!! The data is right-hand data.
  13020. * @export
  13021. * @interface DevicePose
  13022. */
  13023. export interface DevicePose {
  13024. /**
  13025. * The position of the device, values in array are [x,y,z].
  13026. */
  13027. readonly position: Nullable<Float32Array>;
  13028. /**
  13029. * The linearVelocity of the device, values in array are [x,y,z].
  13030. */
  13031. readonly linearVelocity: Nullable<Float32Array>;
  13032. /**
  13033. * The linearAcceleration of the device, values in array are [x,y,z].
  13034. */
  13035. readonly linearAcceleration: Nullable<Float32Array>;
  13036. /**
  13037. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13038. */
  13039. readonly orientation: Nullable<Float32Array>;
  13040. /**
  13041. * The angularVelocity of the device, values in array are [x,y,z].
  13042. */
  13043. readonly angularVelocity: Nullable<Float32Array>;
  13044. /**
  13045. * The angularAcceleration of the device, values in array are [x,y,z].
  13046. */
  13047. readonly angularAcceleration: Nullable<Float32Array>;
  13048. }
  13049. /**
  13050. * Interface representing a pose controlled object in Babylon.
  13051. * A pose controlled object has both regular pose values as well as pose values
  13052. * from an external device such as a VR head mounted display
  13053. */
  13054. export interface PoseControlled {
  13055. /**
  13056. * The position of the object in babylon space.
  13057. */
  13058. position: Vector3;
  13059. /**
  13060. * The rotation quaternion of the object in babylon space.
  13061. */
  13062. rotationQuaternion: Quaternion;
  13063. /**
  13064. * The position of the device in babylon space.
  13065. */
  13066. devicePosition?: Vector3;
  13067. /**
  13068. * The rotation quaternion of the device in babylon space.
  13069. */
  13070. deviceRotationQuaternion: Quaternion;
  13071. /**
  13072. * The raw pose coming from the device.
  13073. */
  13074. rawPose: Nullable<DevicePose>;
  13075. /**
  13076. * The scale of the device to be used when translating from device space to babylon space.
  13077. */
  13078. deviceScaleFactor: number;
  13079. /**
  13080. * Updates the poseControlled values based on the input device pose.
  13081. * @param poseData the pose data to update the object with
  13082. */
  13083. updateFromDevice(poseData: DevicePose): void;
  13084. }
  13085. /**
  13086. * Set of options to customize the webVRCamera
  13087. */
  13088. export interface WebVROptions {
  13089. /**
  13090. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13091. */
  13092. trackPosition?: boolean;
  13093. /**
  13094. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13095. */
  13096. positionScale?: number;
  13097. /**
  13098. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13099. */
  13100. displayName?: string;
  13101. /**
  13102. * Should the native controller meshes be initialized. (default: true)
  13103. */
  13104. controllerMeshes?: boolean;
  13105. /**
  13106. * Creating a default HemiLight only on controllers. (default: true)
  13107. */
  13108. defaultLightingOnControllers?: boolean;
  13109. /**
  13110. * If you don't want to use the default VR button of the helper. (default: false)
  13111. */
  13112. useCustomVRButton?: boolean;
  13113. /**
  13114. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13115. */
  13116. customVRButton?: HTMLButtonElement;
  13117. /**
  13118. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13119. */
  13120. rayLength?: number;
  13121. /**
  13122. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13123. */
  13124. defaultHeight?: number;
  13125. /**
  13126. * If multiview should be used if availible (default: false)
  13127. */
  13128. useMultiview?: boolean;
  13129. }
  13130. /**
  13131. * This represents a WebVR camera.
  13132. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13133. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13134. */
  13135. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13136. private webVROptions;
  13137. /**
  13138. * @hidden
  13139. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13140. */
  13141. _vrDevice: any;
  13142. /**
  13143. * The rawPose of the vrDevice.
  13144. */
  13145. rawPose: Nullable<DevicePose>;
  13146. private _onVREnabled;
  13147. private _specsVersion;
  13148. private _attached;
  13149. private _frameData;
  13150. protected _descendants: Array<Node>;
  13151. private _deviceRoomPosition;
  13152. /** @hidden */
  13153. _deviceRoomRotationQuaternion: Quaternion;
  13154. private _standingMatrix;
  13155. /**
  13156. * Represents device position in babylon space.
  13157. */
  13158. devicePosition: Vector3;
  13159. /**
  13160. * Represents device rotation in babylon space.
  13161. */
  13162. deviceRotationQuaternion: Quaternion;
  13163. /**
  13164. * The scale of the device to be used when translating from device space to babylon space.
  13165. */
  13166. deviceScaleFactor: number;
  13167. private _deviceToWorld;
  13168. private _worldToDevice;
  13169. /**
  13170. * References to the webVR controllers for the vrDevice.
  13171. */
  13172. controllers: Array<WebVRController>;
  13173. /**
  13174. * Emits an event when a controller is attached.
  13175. */
  13176. onControllersAttachedObservable: Observable<WebVRController[]>;
  13177. /**
  13178. * Emits an event when a controller's mesh has been loaded;
  13179. */
  13180. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13181. /**
  13182. * Emits an event when the HMD's pose has been updated.
  13183. */
  13184. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13185. private _poseSet;
  13186. /**
  13187. * If the rig cameras be used as parent instead of this camera.
  13188. */
  13189. rigParenting: boolean;
  13190. private _lightOnControllers;
  13191. private _defaultHeight?;
  13192. /**
  13193. * Instantiates a WebVRFreeCamera.
  13194. * @param name The name of the WebVRFreeCamera
  13195. * @param position The starting anchor position for the camera
  13196. * @param scene The scene the camera belongs to
  13197. * @param webVROptions a set of customizable options for the webVRCamera
  13198. */
  13199. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13200. /**
  13201. * Gets the device distance from the ground in meters.
  13202. * @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.
  13203. */
  13204. deviceDistanceToRoomGround(): number;
  13205. /**
  13206. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13207. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13208. */
  13209. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13210. /**
  13211. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13212. * @returns A promise with a boolean set to if the standing matrix is supported.
  13213. */
  13214. useStandingMatrixAsync(): Promise<boolean>;
  13215. /**
  13216. * Disposes the camera
  13217. */
  13218. dispose(): void;
  13219. /**
  13220. * Gets a vrController by name.
  13221. * @param name The name of the controller to retreive
  13222. * @returns the controller matching the name specified or null if not found
  13223. */
  13224. getControllerByName(name: string): Nullable<WebVRController>;
  13225. private _leftController;
  13226. /**
  13227. * The controller corrisponding to the users left hand.
  13228. */
  13229. readonly leftController: Nullable<WebVRController>;
  13230. private _rightController;
  13231. /**
  13232. * The controller corrisponding to the users right hand.
  13233. */
  13234. readonly rightController: Nullable<WebVRController>;
  13235. /**
  13236. * Casts a ray forward from the vrCamera's gaze.
  13237. * @param length Length of the ray (default: 100)
  13238. * @returns the ray corrisponding to the gaze
  13239. */
  13240. getForwardRay(length?: number): Ray;
  13241. /**
  13242. * @hidden
  13243. * Updates the camera based on device's frame data
  13244. */
  13245. _checkInputs(): void;
  13246. /**
  13247. * Updates the poseControlled values based on the input device pose.
  13248. * @param poseData Pose coming from the device
  13249. */
  13250. updateFromDevice(poseData: DevicePose): void;
  13251. private _htmlElementAttached;
  13252. private _detachIfAttached;
  13253. /**
  13254. * WebVR's attach control will start broadcasting frames to the device.
  13255. * Note that in certain browsers (chrome for example) this function must be called
  13256. * within a user-interaction callback. Example:
  13257. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13258. *
  13259. * @param element html element to attach the vrDevice to
  13260. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13261. */
  13262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13263. /**
  13264. * Detaches the camera from the html element and disables VR
  13265. *
  13266. * @param element html element to detach from
  13267. */
  13268. detachControl(element: HTMLElement): void;
  13269. /**
  13270. * @returns the name of this class
  13271. */
  13272. getClassName(): string;
  13273. /**
  13274. * Calls resetPose on the vrDisplay
  13275. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13276. */
  13277. resetToCurrentRotation(): void;
  13278. /**
  13279. * @hidden
  13280. * Updates the rig cameras (left and right eye)
  13281. */
  13282. _updateRigCameras(): void;
  13283. private _workingVector;
  13284. private _oneVector;
  13285. private _workingMatrix;
  13286. private updateCacheCalled;
  13287. private _correctPositionIfNotTrackPosition;
  13288. /**
  13289. * @hidden
  13290. * Updates the cached values of the camera
  13291. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13292. */
  13293. _updateCache(ignoreParentClass?: boolean): void;
  13294. /**
  13295. * @hidden
  13296. * Get current device position in babylon world
  13297. */
  13298. _computeDevicePosition(): void;
  13299. /**
  13300. * Updates the current device position and rotation in the babylon world
  13301. */
  13302. update(): void;
  13303. /**
  13304. * @hidden
  13305. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13306. * @returns an identity matrix
  13307. */
  13308. _getViewMatrix(): Matrix;
  13309. private _tmpMatrix;
  13310. /**
  13311. * This function is called by the two RIG cameras.
  13312. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13313. * @hidden
  13314. */
  13315. _getWebVRViewMatrix(): Matrix;
  13316. /** @hidden */
  13317. _getWebVRProjectionMatrix(): Matrix;
  13318. private _onGamepadConnectedObserver;
  13319. private _onGamepadDisconnectedObserver;
  13320. private _updateCacheWhenTrackingDisabledObserver;
  13321. /**
  13322. * Initializes the controllers and their meshes
  13323. */
  13324. initControllers(): void;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Size options for a post process
  13330. */
  13331. export type PostProcessOptions = {
  13332. width: number;
  13333. height: number;
  13334. };
  13335. /**
  13336. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13337. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13338. */
  13339. export class PostProcess {
  13340. /** Name of the PostProcess. */
  13341. name: string;
  13342. /**
  13343. * Gets or sets the unique id of the post process
  13344. */
  13345. uniqueId: number;
  13346. /**
  13347. * Width of the texture to apply the post process on
  13348. */
  13349. width: number;
  13350. /**
  13351. * Height of the texture to apply the post process on
  13352. */
  13353. height: number;
  13354. /**
  13355. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13356. * @hidden
  13357. */
  13358. _outputTexture: Nullable<InternalTexture>;
  13359. /**
  13360. * Sampling mode used by the shader
  13361. * See https://doc.babylonjs.com/classes/3.1/texture
  13362. */
  13363. renderTargetSamplingMode: number;
  13364. /**
  13365. * Clear color to use when screen clearing
  13366. */
  13367. clearColor: Color4;
  13368. /**
  13369. * If the buffer needs to be cleared before applying the post process. (default: true)
  13370. * Should be set to false if shader will overwrite all previous pixels.
  13371. */
  13372. autoClear: boolean;
  13373. /**
  13374. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13375. */
  13376. alphaMode: number;
  13377. /**
  13378. * Sets the setAlphaBlendConstants of the babylon engine
  13379. */
  13380. alphaConstants: Color4;
  13381. /**
  13382. * Animations to be used for the post processing
  13383. */
  13384. animations: Animation[];
  13385. /**
  13386. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13387. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13388. */
  13389. enablePixelPerfectMode: boolean;
  13390. /**
  13391. * Force the postprocess to be applied without taking in account viewport
  13392. */
  13393. forceFullscreenViewport: boolean;
  13394. /**
  13395. * List of inspectable custom properties (used by the Inspector)
  13396. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13397. */
  13398. inspectableCustomProperties: IInspectable[];
  13399. /**
  13400. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13401. *
  13402. * | Value | Type | Description |
  13403. * | ----- | ----------------------------------- | ----------- |
  13404. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13405. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13406. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13407. *
  13408. */
  13409. scaleMode: number;
  13410. /**
  13411. * Force textures to be a power of two (default: false)
  13412. */
  13413. alwaysForcePOT: boolean;
  13414. private _samples;
  13415. /**
  13416. * Number of sample textures (default: 1)
  13417. */
  13418. samples: number;
  13419. /**
  13420. * Modify the scale of the post process to be the same as the viewport (default: false)
  13421. */
  13422. adaptScaleToCurrentViewport: boolean;
  13423. private _camera;
  13424. private _scene;
  13425. private _engine;
  13426. private _options;
  13427. private _reusable;
  13428. private _textureType;
  13429. /**
  13430. * Smart array of input and output textures for the post process.
  13431. * @hidden
  13432. */
  13433. _textures: SmartArray<InternalTexture>;
  13434. /**
  13435. * The index in _textures that corresponds to the output texture.
  13436. * @hidden
  13437. */
  13438. _currentRenderTextureInd: number;
  13439. private _effect;
  13440. private _samplers;
  13441. private _fragmentUrl;
  13442. private _vertexUrl;
  13443. private _parameters;
  13444. private _scaleRatio;
  13445. protected _indexParameters: any;
  13446. private _shareOutputWithPostProcess;
  13447. private _texelSize;
  13448. private _forcedOutputTexture;
  13449. /**
  13450. * Returns the fragment url or shader name used in the post process.
  13451. * @returns the fragment url or name in the shader store.
  13452. */
  13453. getEffectName(): string;
  13454. /**
  13455. * An event triggered when the postprocess is activated.
  13456. */
  13457. onActivateObservable: Observable<Camera>;
  13458. private _onActivateObserver;
  13459. /**
  13460. * A function that is added to the onActivateObservable
  13461. */
  13462. onActivate: Nullable<(camera: Camera) => void>;
  13463. /**
  13464. * An event triggered when the postprocess changes its size.
  13465. */
  13466. onSizeChangedObservable: Observable<PostProcess>;
  13467. private _onSizeChangedObserver;
  13468. /**
  13469. * A function that is added to the onSizeChangedObservable
  13470. */
  13471. onSizeChanged: (postProcess: PostProcess) => void;
  13472. /**
  13473. * An event triggered when the postprocess applies its effect.
  13474. */
  13475. onApplyObservable: Observable<Effect>;
  13476. private _onApplyObserver;
  13477. /**
  13478. * A function that is added to the onApplyObservable
  13479. */
  13480. onApply: (effect: Effect) => void;
  13481. /**
  13482. * An event triggered before rendering the postprocess
  13483. */
  13484. onBeforeRenderObservable: Observable<Effect>;
  13485. private _onBeforeRenderObserver;
  13486. /**
  13487. * A function that is added to the onBeforeRenderObservable
  13488. */
  13489. onBeforeRender: (effect: Effect) => void;
  13490. /**
  13491. * An event triggered after rendering the postprocess
  13492. */
  13493. onAfterRenderObservable: Observable<Effect>;
  13494. private _onAfterRenderObserver;
  13495. /**
  13496. * A function that is added to the onAfterRenderObservable
  13497. */
  13498. onAfterRender: (efect: Effect) => void;
  13499. /**
  13500. * 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
  13501. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13502. */
  13503. inputTexture: InternalTexture;
  13504. /**
  13505. * Gets the camera which post process is applied to.
  13506. * @returns The camera the post process is applied to.
  13507. */
  13508. getCamera(): Camera;
  13509. /**
  13510. * Gets the texel size of the postprocess.
  13511. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13512. */
  13513. readonly texelSize: Vector2;
  13514. /**
  13515. * Creates a new instance PostProcess
  13516. * @param name The name of the PostProcess.
  13517. * @param fragmentUrl The url of the fragment shader to be used.
  13518. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13519. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13520. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13521. * @param camera The camera to apply the render pass to.
  13522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13523. * @param engine The engine which the post process will be applied. (default: current engine)
  13524. * @param reusable If the post process can be reused on the same frame. (default: false)
  13525. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13526. * @param textureType Type of textures used when performing the post process. (default: 0)
  13527. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13528. * @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
  13529. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13530. */
  13531. constructor(
  13532. /** Name of the PostProcess. */
  13533. 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);
  13534. /**
  13535. * Gets a string idenfifying the name of the class
  13536. * @returns "PostProcess" string
  13537. */
  13538. getClassName(): string;
  13539. /**
  13540. * Gets the engine which this post process belongs to.
  13541. * @returns The engine the post process was enabled with.
  13542. */
  13543. getEngine(): Engine;
  13544. /**
  13545. * The effect that is created when initializing the post process.
  13546. * @returns The created effect corrisponding the the postprocess.
  13547. */
  13548. getEffect(): Effect;
  13549. /**
  13550. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13551. * @param postProcess The post process to share the output with.
  13552. * @returns This post process.
  13553. */
  13554. shareOutputWith(postProcess: PostProcess): PostProcess;
  13555. /**
  13556. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13557. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13558. */
  13559. useOwnOutput(): void;
  13560. /**
  13561. * Updates the effect with the current post process compile time values and recompiles the shader.
  13562. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13563. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13564. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13565. * @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
  13566. * @param onCompiled Called when the shader has been compiled.
  13567. * @param onError Called if there is an error when compiling a shader.
  13568. */
  13569. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13570. /**
  13571. * The post process is reusable if it can be used multiple times within one frame.
  13572. * @returns If the post process is reusable
  13573. */
  13574. isReusable(): boolean;
  13575. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13576. markTextureDirty(): void;
  13577. /**
  13578. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13579. * 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.
  13580. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13581. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13582. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13583. * @returns The target texture that was bound to be written to.
  13584. */
  13585. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13586. /**
  13587. * If the post process is supported.
  13588. */
  13589. readonly isSupported: boolean;
  13590. /**
  13591. * The aspect ratio of the output texture.
  13592. */
  13593. readonly aspectRatio: number;
  13594. /**
  13595. * Get a value indicating if the post-process is ready to be used
  13596. * @returns true if the post-process is ready (shader is compiled)
  13597. */
  13598. isReady(): boolean;
  13599. /**
  13600. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13601. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13602. */
  13603. apply(): Nullable<Effect>;
  13604. private _disposeTextures;
  13605. /**
  13606. * Disposes the post process.
  13607. * @param camera The camera to dispose the post process on.
  13608. */
  13609. dispose(camera?: Camera): void;
  13610. }
  13611. }
  13612. declare module BABYLON {
  13613. /**
  13614. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13615. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13616. */
  13617. export class PostProcessManager {
  13618. private _scene;
  13619. private _indexBuffer;
  13620. private _vertexBuffers;
  13621. /**
  13622. * Creates a new instance PostProcess
  13623. * @param scene The scene that the post process is associated with.
  13624. */
  13625. constructor(scene: Scene);
  13626. private _prepareBuffers;
  13627. private _buildIndexBuffer;
  13628. /**
  13629. * Rebuilds the vertex buffers of the manager.
  13630. * @hidden
  13631. */
  13632. _rebuild(): void;
  13633. /**
  13634. * Prepares a frame to be run through a post process.
  13635. * @param sourceTexture The input texture to the post procesess. (default: null)
  13636. * @param postProcesses An array of post processes to be run. (default: null)
  13637. * @returns True if the post processes were able to be run.
  13638. * @hidden
  13639. */
  13640. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13641. /**
  13642. * Manually render a set of post processes to a texture.
  13643. * @param postProcesses An array of post processes to be run.
  13644. * @param targetTexture The target texture to render to.
  13645. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13646. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13647. * @param lodLevel defines which lod of the texture to render to
  13648. */
  13649. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13650. /**
  13651. * Finalize the result of the output of the postprocesses.
  13652. * @param doNotPresent If true the result will not be displayed to the screen.
  13653. * @param targetTexture The target texture to render to.
  13654. * @param faceIndex The index of the face to bind the target texture to.
  13655. * @param postProcesses The array of post processes to render.
  13656. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13657. * @hidden
  13658. */
  13659. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13660. /**
  13661. * Disposes of the post process manager.
  13662. */
  13663. dispose(): void;
  13664. }
  13665. }
  13666. declare module BABYLON {
  13667. interface AbstractScene {
  13668. /**
  13669. * The list of layers (background and foreground) of the scene
  13670. */
  13671. layers: Array<Layer>;
  13672. }
  13673. /**
  13674. * Defines the layer scene component responsible to manage any layers
  13675. * in a given scene.
  13676. */
  13677. export class LayerSceneComponent implements ISceneComponent {
  13678. /**
  13679. * The component name helpfull to identify the component in the list of scene components.
  13680. */
  13681. readonly name: string;
  13682. /**
  13683. * The scene the component belongs to.
  13684. */
  13685. scene: Scene;
  13686. private _engine;
  13687. /**
  13688. * Creates a new instance of the component for the given scene
  13689. * @param scene Defines the scene to register the component in
  13690. */
  13691. constructor(scene: Scene);
  13692. /**
  13693. * Registers the component in a given scene
  13694. */
  13695. register(): void;
  13696. /**
  13697. * Rebuilds the elements related to this component in case of
  13698. * context lost for instance.
  13699. */
  13700. rebuild(): void;
  13701. /**
  13702. * Disposes the component and the associated ressources.
  13703. */
  13704. dispose(): void;
  13705. private _draw;
  13706. private _drawCameraPredicate;
  13707. private _drawCameraBackground;
  13708. private _drawCameraForeground;
  13709. private _drawRenderTargetPredicate;
  13710. private _drawRenderTargetBackground;
  13711. private _drawRenderTargetForeground;
  13712. }
  13713. }
  13714. declare module BABYLON {
  13715. /** @hidden */
  13716. export var layerPixelShader: {
  13717. name: string;
  13718. shader: string;
  13719. };
  13720. }
  13721. declare module BABYLON {
  13722. /** @hidden */
  13723. export var layerVertexShader: {
  13724. name: string;
  13725. shader: string;
  13726. };
  13727. }
  13728. declare module BABYLON {
  13729. /**
  13730. * This represents a full screen 2d layer.
  13731. * This can be useful to display a picture in the background of your scene for instance.
  13732. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13733. */
  13734. export class Layer {
  13735. /**
  13736. * Define the name of the layer.
  13737. */
  13738. name: string;
  13739. /**
  13740. * Define the texture the layer should display.
  13741. */
  13742. texture: Nullable<Texture>;
  13743. /**
  13744. * Is the layer in background or foreground.
  13745. */
  13746. isBackground: boolean;
  13747. /**
  13748. * Define the color of the layer (instead of texture).
  13749. */
  13750. color: Color4;
  13751. /**
  13752. * Define the scale of the layer in order to zoom in out of the texture.
  13753. */
  13754. scale: Vector2;
  13755. /**
  13756. * Define an offset for the layer in order to shift the texture.
  13757. */
  13758. offset: Vector2;
  13759. /**
  13760. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13761. */
  13762. alphaBlendingMode: number;
  13763. /**
  13764. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13765. * Alpha test will not mix with the background color in case of transparency.
  13766. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13767. */
  13768. alphaTest: boolean;
  13769. /**
  13770. * Define a mask to restrict the layer to only some of the scene cameras.
  13771. */
  13772. layerMask: number;
  13773. /**
  13774. * Define the list of render target the layer is visible into.
  13775. */
  13776. renderTargetTextures: RenderTargetTexture[];
  13777. /**
  13778. * Define if the layer is only used in renderTarget or if it also
  13779. * renders in the main frame buffer of the canvas.
  13780. */
  13781. renderOnlyInRenderTargetTextures: boolean;
  13782. private _scene;
  13783. private _vertexBuffers;
  13784. private _indexBuffer;
  13785. private _effect;
  13786. private _alphaTestEffect;
  13787. /**
  13788. * An event triggered when the layer is disposed.
  13789. */
  13790. onDisposeObservable: Observable<Layer>;
  13791. private _onDisposeObserver;
  13792. /**
  13793. * Back compatibility with callback before the onDisposeObservable existed.
  13794. * The set callback will be triggered when the layer has been disposed.
  13795. */
  13796. onDispose: () => void;
  13797. /**
  13798. * An event triggered before rendering the scene
  13799. */
  13800. onBeforeRenderObservable: Observable<Layer>;
  13801. private _onBeforeRenderObserver;
  13802. /**
  13803. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13804. * The set callback will be triggered just before rendering the layer.
  13805. */
  13806. onBeforeRender: () => void;
  13807. /**
  13808. * An event triggered after rendering the scene
  13809. */
  13810. onAfterRenderObservable: Observable<Layer>;
  13811. private _onAfterRenderObserver;
  13812. /**
  13813. * Back compatibility with callback before the onAfterRenderObservable existed.
  13814. * The set callback will be triggered just after rendering the layer.
  13815. */
  13816. onAfterRender: () => void;
  13817. /**
  13818. * Instantiates a new layer.
  13819. * This represents a full screen 2d layer.
  13820. * This can be useful to display a picture in the background of your scene for instance.
  13821. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13822. * @param name Define the name of the layer in the scene
  13823. * @param imgUrl Define the url of the texture to display in the layer
  13824. * @param scene Define the scene the layer belongs to
  13825. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13826. * @param color Defines a color for the layer
  13827. */
  13828. constructor(
  13829. /**
  13830. * Define the name of the layer.
  13831. */
  13832. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13833. private _createIndexBuffer;
  13834. /** @hidden */
  13835. _rebuild(): void;
  13836. /**
  13837. * Renders the layer in the scene.
  13838. */
  13839. render(): void;
  13840. /**
  13841. * Disposes and releases the associated ressources.
  13842. */
  13843. dispose(): void;
  13844. }
  13845. }
  13846. declare module BABYLON {
  13847. interface AbstractScene {
  13848. /**
  13849. * The list of procedural textures added to the scene
  13850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13851. */
  13852. proceduralTextures: Array<ProceduralTexture>;
  13853. }
  13854. /**
  13855. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13856. * in a given scene.
  13857. */
  13858. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13859. /**
  13860. * The component name helpfull to identify the component in the list of scene components.
  13861. */
  13862. readonly name: string;
  13863. /**
  13864. * The scene the component belongs to.
  13865. */
  13866. scene: Scene;
  13867. /**
  13868. * Creates a new instance of the component for the given scene
  13869. * @param scene Defines the scene to register the component in
  13870. */
  13871. constructor(scene: Scene);
  13872. /**
  13873. * Registers the component in a given scene
  13874. */
  13875. register(): void;
  13876. /**
  13877. * Rebuilds the elements related to this component in case of
  13878. * context lost for instance.
  13879. */
  13880. rebuild(): void;
  13881. /**
  13882. * Disposes the component and the associated ressources.
  13883. */
  13884. dispose(): void;
  13885. private _beforeClear;
  13886. }
  13887. }
  13888. declare module BABYLON {
  13889. /** @hidden */
  13890. export var proceduralVertexShader: {
  13891. name: string;
  13892. shader: string;
  13893. };
  13894. }
  13895. declare module BABYLON {
  13896. /**
  13897. * 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.
  13898. * This is the base class of any Procedural texture and contains most of the shareable code.
  13899. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13900. */
  13901. export class ProceduralTexture extends Texture {
  13902. isCube: boolean;
  13903. /**
  13904. * Define if the texture is enabled or not (disabled texture will not render)
  13905. */
  13906. isEnabled: boolean;
  13907. /**
  13908. * Define if the texture must be cleared before rendering (default is true)
  13909. */
  13910. autoClear: boolean;
  13911. /**
  13912. * Callback called when the texture is generated
  13913. */
  13914. onGenerated: () => void;
  13915. /**
  13916. * Event raised when the texture is generated
  13917. */
  13918. onGeneratedObservable: Observable<ProceduralTexture>;
  13919. /** @hidden */
  13920. _generateMipMaps: boolean;
  13921. /** @hidden **/
  13922. _effect: Effect;
  13923. /** @hidden */
  13924. _textures: {
  13925. [key: string]: Texture;
  13926. };
  13927. private _size;
  13928. private _currentRefreshId;
  13929. private _refreshRate;
  13930. private _vertexBuffers;
  13931. private _indexBuffer;
  13932. private _uniforms;
  13933. private _samplers;
  13934. private _fragment;
  13935. private _floats;
  13936. private _ints;
  13937. private _floatsArrays;
  13938. private _colors3;
  13939. private _colors4;
  13940. private _vectors2;
  13941. private _vectors3;
  13942. private _matrices;
  13943. private _fallbackTexture;
  13944. private _fallbackTextureUsed;
  13945. private _engine;
  13946. private _cachedDefines;
  13947. private _contentUpdateId;
  13948. private _contentData;
  13949. /**
  13950. * Instantiates a new procedural texture.
  13951. * 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.
  13952. * This is the base class of any Procedural texture and contains most of the shareable code.
  13953. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13954. * @param name Define the name of the texture
  13955. * @param size Define the size of the texture to create
  13956. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13957. * @param scene Define the scene the texture belongs to
  13958. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13959. * @param generateMipMaps Define if the texture should creates mip maps or not
  13960. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13961. */
  13962. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13963. /**
  13964. * The effect that is created when initializing the post process.
  13965. * @returns The created effect corrisponding the the postprocess.
  13966. */
  13967. getEffect(): Effect;
  13968. /**
  13969. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13970. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13971. */
  13972. getContent(): Nullable<ArrayBufferView>;
  13973. private _createIndexBuffer;
  13974. /** @hidden */
  13975. _rebuild(): void;
  13976. /**
  13977. * Resets the texture in order to recreate its associated resources.
  13978. * This can be called in case of context loss
  13979. */
  13980. reset(): void;
  13981. protected _getDefines(): string;
  13982. /**
  13983. * Is the texture ready to be used ? (rendered at least once)
  13984. * @returns true if ready, otherwise, false.
  13985. */
  13986. isReady(): boolean;
  13987. /**
  13988. * Resets the refresh counter of the texture and start bak from scratch.
  13989. * Could be useful to regenerate the texture if it is setup to render only once.
  13990. */
  13991. resetRefreshCounter(): void;
  13992. /**
  13993. * Set the fragment shader to use in order to render the texture.
  13994. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13995. */
  13996. setFragment(fragment: any): void;
  13997. /**
  13998. * Define the refresh rate of the texture or the rendering frequency.
  13999. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14000. */
  14001. refreshRate: number;
  14002. /** @hidden */
  14003. _shouldRender(): boolean;
  14004. /**
  14005. * Get the size the texture is rendering at.
  14006. * @returns the size (texture is always squared)
  14007. */
  14008. getRenderSize(): number;
  14009. /**
  14010. * Resize the texture to new value.
  14011. * @param size Define the new size the texture should have
  14012. * @param generateMipMaps Define whether the new texture should create mip maps
  14013. */
  14014. resize(size: number, generateMipMaps: boolean): void;
  14015. private _checkUniform;
  14016. /**
  14017. * Set a texture in the shader program used to render.
  14018. * @param name Define the name of the uniform samplers as defined in the shader
  14019. * @param texture Define the texture to bind to this sampler
  14020. * @return the texture itself allowing "fluent" like uniform updates
  14021. */
  14022. setTexture(name: string, texture: Texture): ProceduralTexture;
  14023. /**
  14024. * Set a float in the shader.
  14025. * @param name Define the name of the uniform as defined in the shader
  14026. * @param value Define the value to give to the uniform
  14027. * @return the texture itself allowing "fluent" like uniform updates
  14028. */
  14029. setFloat(name: string, value: number): ProceduralTexture;
  14030. /**
  14031. * Set a int in the shader.
  14032. * @param name Define the name of the uniform as defined in the shader
  14033. * @param value Define the value to give to the uniform
  14034. * @return the texture itself allowing "fluent" like uniform updates
  14035. */
  14036. setInt(name: string, value: number): ProceduralTexture;
  14037. /**
  14038. * Set an array of floats in the shader.
  14039. * @param name Define the name of the uniform as defined in the shader
  14040. * @param value Define the value to give to the uniform
  14041. * @return the texture itself allowing "fluent" like uniform updates
  14042. */
  14043. setFloats(name: string, value: number[]): ProceduralTexture;
  14044. /**
  14045. * Set a vec3 in the shader from a Color3.
  14046. * @param name Define the name of the uniform as defined in the shader
  14047. * @param value Define the value to give to the uniform
  14048. * @return the texture itself allowing "fluent" like uniform updates
  14049. */
  14050. setColor3(name: string, value: Color3): ProceduralTexture;
  14051. /**
  14052. * Set a vec4 in the shader from a Color4.
  14053. * @param name Define the name of the uniform as defined in the shader
  14054. * @param value Define the value to give to the uniform
  14055. * @return the texture itself allowing "fluent" like uniform updates
  14056. */
  14057. setColor4(name: string, value: Color4): ProceduralTexture;
  14058. /**
  14059. * Set a vec2 in the shader from a Vector2.
  14060. * @param name Define the name of the uniform as defined in the shader
  14061. * @param value Define the value to give to the uniform
  14062. * @return the texture itself allowing "fluent" like uniform updates
  14063. */
  14064. setVector2(name: string, value: Vector2): ProceduralTexture;
  14065. /**
  14066. * Set a vec3 in the shader from a Vector3.
  14067. * @param name Define the name of the uniform as defined in the shader
  14068. * @param value Define the value to give to the uniform
  14069. * @return the texture itself allowing "fluent" like uniform updates
  14070. */
  14071. setVector3(name: string, value: Vector3): ProceduralTexture;
  14072. /**
  14073. * Set a mat4 in the shader from a MAtrix.
  14074. * @param name Define the name of the uniform as defined in the shader
  14075. * @param value Define the value to give to the uniform
  14076. * @return the texture itself allowing "fluent" like uniform updates
  14077. */
  14078. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14079. /**
  14080. * Render the texture to its associated render target.
  14081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14082. */
  14083. render(useCameraPostProcess?: boolean): void;
  14084. /**
  14085. * Clone the texture.
  14086. * @returns the cloned texture
  14087. */
  14088. clone(): ProceduralTexture;
  14089. /**
  14090. * Dispose the texture and release its asoociated resources.
  14091. */
  14092. dispose(): void;
  14093. }
  14094. }
  14095. declare module BABYLON {
  14096. /**
  14097. * This represents the base class for particle system in Babylon.
  14098. * 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.
  14099. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14100. * @example https://doc.babylonjs.com/babylon101/particles
  14101. */
  14102. export class BaseParticleSystem {
  14103. /**
  14104. * Source color is added to the destination color without alpha affecting the result
  14105. */
  14106. static BLENDMODE_ONEONE: number;
  14107. /**
  14108. * Blend current color and particle color using particle’s alpha
  14109. */
  14110. static BLENDMODE_STANDARD: number;
  14111. /**
  14112. * Add current color and particle color multiplied by particle’s alpha
  14113. */
  14114. static BLENDMODE_ADD: number;
  14115. /**
  14116. * Multiply current color with particle color
  14117. */
  14118. static BLENDMODE_MULTIPLY: number;
  14119. /**
  14120. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14121. */
  14122. static BLENDMODE_MULTIPLYADD: number;
  14123. /**
  14124. * List of animations used by the particle system.
  14125. */
  14126. animations: Animation[];
  14127. /**
  14128. * The id of the Particle system.
  14129. */
  14130. id: string;
  14131. /**
  14132. * The friendly name of the Particle system.
  14133. */
  14134. name: string;
  14135. /**
  14136. * The rendering group used by the Particle system to chose when to render.
  14137. */
  14138. renderingGroupId: number;
  14139. /**
  14140. * The emitter represents the Mesh or position we are attaching the particle system to.
  14141. */
  14142. emitter: Nullable<AbstractMesh | Vector3>;
  14143. /**
  14144. * The maximum number of particles to emit per frame
  14145. */
  14146. emitRate: number;
  14147. /**
  14148. * If you want to launch only a few particles at once, that can be done, as well.
  14149. */
  14150. manualEmitCount: number;
  14151. /**
  14152. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14153. */
  14154. updateSpeed: number;
  14155. /**
  14156. * The amount of time the particle system is running (depends of the overall update speed).
  14157. */
  14158. targetStopDuration: number;
  14159. /**
  14160. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14161. */
  14162. disposeOnStop: boolean;
  14163. /**
  14164. * Minimum power of emitting particles.
  14165. */
  14166. minEmitPower: number;
  14167. /**
  14168. * Maximum power of emitting particles.
  14169. */
  14170. maxEmitPower: number;
  14171. /**
  14172. * Minimum life time of emitting particles.
  14173. */
  14174. minLifeTime: number;
  14175. /**
  14176. * Maximum life time of emitting particles.
  14177. */
  14178. maxLifeTime: number;
  14179. /**
  14180. * Minimum Size of emitting particles.
  14181. */
  14182. minSize: number;
  14183. /**
  14184. * Maximum Size of emitting particles.
  14185. */
  14186. maxSize: number;
  14187. /**
  14188. * Minimum scale of emitting particles on X axis.
  14189. */
  14190. minScaleX: number;
  14191. /**
  14192. * Maximum scale of emitting particles on X axis.
  14193. */
  14194. maxScaleX: number;
  14195. /**
  14196. * Minimum scale of emitting particles on Y axis.
  14197. */
  14198. minScaleY: number;
  14199. /**
  14200. * Maximum scale of emitting particles on Y axis.
  14201. */
  14202. maxScaleY: number;
  14203. /**
  14204. * Gets or sets the minimal initial rotation in radians.
  14205. */
  14206. minInitialRotation: number;
  14207. /**
  14208. * Gets or sets the maximal initial rotation in radians.
  14209. */
  14210. maxInitialRotation: number;
  14211. /**
  14212. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14213. */
  14214. minAngularSpeed: number;
  14215. /**
  14216. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14217. */
  14218. maxAngularSpeed: number;
  14219. /**
  14220. * The texture used to render each particle. (this can be a spritesheet)
  14221. */
  14222. particleTexture: Nullable<Texture>;
  14223. /**
  14224. * The layer mask we are rendering the particles through.
  14225. */
  14226. layerMask: number;
  14227. /**
  14228. * This can help using your own shader to render the particle system.
  14229. * The according effect will be created
  14230. */
  14231. customShader: any;
  14232. /**
  14233. * By default particle system starts as soon as they are created. This prevents the
  14234. * automatic start to happen and let you decide when to start emitting particles.
  14235. */
  14236. preventAutoStart: boolean;
  14237. private _noiseTexture;
  14238. /**
  14239. * Gets or sets a texture used to add random noise to particle positions
  14240. */
  14241. noiseTexture: Nullable<ProceduralTexture>;
  14242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14243. noiseStrength: Vector3;
  14244. /**
  14245. * Callback triggered when the particle animation is ending.
  14246. */
  14247. onAnimationEnd: Nullable<() => void>;
  14248. /**
  14249. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14250. */
  14251. blendMode: number;
  14252. /**
  14253. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14254. * to override the particles.
  14255. */
  14256. forceDepthWrite: boolean;
  14257. /** 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 */
  14258. preWarmCycles: number;
  14259. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14260. preWarmStepOffset: number;
  14261. /**
  14262. * 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)
  14263. */
  14264. spriteCellChangeSpeed: number;
  14265. /**
  14266. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14267. */
  14268. startSpriteCellID: number;
  14269. /**
  14270. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14271. */
  14272. endSpriteCellID: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14275. */
  14276. spriteCellWidth: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14279. */
  14280. spriteCellHeight: number;
  14281. /**
  14282. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14283. */
  14284. spriteRandomStartCell: boolean;
  14285. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14286. translationPivot: Vector2;
  14287. /** @hidden */
  14288. protected _isAnimationSheetEnabled: boolean;
  14289. /**
  14290. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14291. */
  14292. beginAnimationOnStart: boolean;
  14293. /**
  14294. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14295. */
  14296. beginAnimationFrom: number;
  14297. /**
  14298. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14299. */
  14300. beginAnimationTo: number;
  14301. /**
  14302. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14303. */
  14304. beginAnimationLoop: boolean;
  14305. /**
  14306. * Gets or sets a world offset applied to all particles
  14307. */
  14308. worldOffset: Vector3;
  14309. /**
  14310. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14311. */
  14312. isAnimationSheetEnabled: boolean;
  14313. /**
  14314. * Get hosting scene
  14315. * @returns the scene
  14316. */
  14317. getScene(): Scene;
  14318. /**
  14319. * You can use gravity if you want to give an orientation to your particles.
  14320. */
  14321. gravity: Vector3;
  14322. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14323. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14324. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14325. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14326. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14327. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14328. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14329. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14330. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14331. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14332. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14333. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14334. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14335. /**
  14336. * Defines the delay in milliseconds before starting the system (0 by default)
  14337. */
  14338. startDelay: number;
  14339. /**
  14340. * Gets the current list of drag gradients.
  14341. * You must use addDragGradient and removeDragGradient to udpate this list
  14342. * @returns the list of drag gradients
  14343. */
  14344. getDragGradients(): Nullable<Array<FactorGradient>>;
  14345. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14346. limitVelocityDamping: number;
  14347. /**
  14348. * Gets the current list of limit velocity gradients.
  14349. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14350. * @returns the list of limit velocity gradients
  14351. */
  14352. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Gets the current list of color gradients.
  14355. * You must use addColorGradient and removeColorGradient to udpate this list
  14356. * @returns the list of color gradients
  14357. */
  14358. getColorGradients(): Nullable<Array<ColorGradient>>;
  14359. /**
  14360. * Gets the current list of size gradients.
  14361. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14362. * @returns the list of size gradients
  14363. */
  14364. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14365. /**
  14366. * Gets the current list of color remap gradients.
  14367. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14368. * @returns the list of color remap gradients
  14369. */
  14370. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14371. /**
  14372. * Gets the current list of alpha remap gradients.
  14373. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14374. * @returns the list of alpha remap gradients
  14375. */
  14376. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14377. /**
  14378. * Gets the current list of life time gradients.
  14379. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14380. * @returns the list of life time gradients
  14381. */
  14382. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14383. /**
  14384. * Gets the current list of angular speed gradients.
  14385. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14386. * @returns the list of angular speed gradients
  14387. */
  14388. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14389. /**
  14390. * Gets the current list of velocity gradients.
  14391. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14392. * @returns the list of velocity gradients
  14393. */
  14394. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14395. /**
  14396. * Gets the current list of start size gradients.
  14397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14398. * @returns the list of start size gradients
  14399. */
  14400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14401. /**
  14402. * Gets the current list of emit rate gradients.
  14403. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14404. * @returns the list of emit rate gradients
  14405. */
  14406. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14407. /**
  14408. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14409. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14410. */
  14411. direction1: Vector3;
  14412. /**
  14413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14414. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14415. */
  14416. direction2: Vector3;
  14417. /**
  14418. * 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.
  14419. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14420. */
  14421. minEmitBox: Vector3;
  14422. /**
  14423. * 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.
  14424. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14425. */
  14426. maxEmitBox: Vector3;
  14427. /**
  14428. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14429. */
  14430. color1: Color4;
  14431. /**
  14432. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14433. */
  14434. color2: Color4;
  14435. /**
  14436. * Color the particle will have at the end of its lifetime
  14437. */
  14438. colorDead: Color4;
  14439. /**
  14440. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14441. */
  14442. textureMask: Color4;
  14443. /**
  14444. * The particle emitter type defines the emitter used by the particle system.
  14445. * It can be for example box, sphere, or cone...
  14446. */
  14447. particleEmitterType: IParticleEmitterType;
  14448. /** @hidden */
  14449. _isSubEmitter: boolean;
  14450. /**
  14451. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14452. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14453. */
  14454. billboardMode: number;
  14455. protected _isBillboardBased: boolean;
  14456. /**
  14457. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14458. */
  14459. isBillboardBased: boolean;
  14460. /**
  14461. * The scene the particle system belongs to.
  14462. */
  14463. protected _scene: Scene;
  14464. /**
  14465. * Local cache of defines for image processing.
  14466. */
  14467. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14468. /**
  14469. * Default configuration related to image processing available in the standard Material.
  14470. */
  14471. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14472. /**
  14473. * Gets the image processing configuration used either in this material.
  14474. */
  14475. /**
  14476. * Sets the Default image processing configuration used either in the this material.
  14477. *
  14478. * If sets to null, the scene one is in use.
  14479. */
  14480. imageProcessingConfiguration: ImageProcessingConfiguration;
  14481. /**
  14482. * Attaches a new image processing configuration to the Standard Material.
  14483. * @param configuration
  14484. */
  14485. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14486. /** @hidden */
  14487. protected _reset(): void;
  14488. /** @hidden */
  14489. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14490. /**
  14491. * Instantiates a particle system.
  14492. * 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.
  14493. * @param name The name of the particle system
  14494. */
  14495. constructor(name: string);
  14496. /**
  14497. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14500. * @returns the emitter
  14501. */
  14502. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14503. /**
  14504. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14505. * @param radius The radius of the hemisphere to emit from
  14506. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14507. * @returns the emitter
  14508. */
  14509. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14510. /**
  14511. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14512. * @param radius The radius of the sphere to emit from
  14513. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14514. * @returns the emitter
  14515. */
  14516. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14517. /**
  14518. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14519. * @param radius The radius of the sphere to emit from
  14520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14522. * @returns the emitter
  14523. */
  14524. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14525. /**
  14526. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14527. * @param radius The radius of the emission cylinder
  14528. * @param height The height of the emission cylinder
  14529. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14530. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14531. * @returns the emitter
  14532. */
  14533. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14534. /**
  14535. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14536. * @param radius The radius of the cylinder to emit from
  14537. * @param height The height of the emission cylinder
  14538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14539. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14540. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14541. * @returns the emitter
  14542. */
  14543. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14544. /**
  14545. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14546. * @param radius The radius of the cone to emit from
  14547. * @param angle The base angle of the cone
  14548. * @returns the emitter
  14549. */
  14550. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14551. /**
  14552. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14555. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14556. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14557. * @returns the emitter
  14558. */
  14559. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14560. }
  14561. }
  14562. declare module BABYLON {
  14563. /**
  14564. * Type of sub emitter
  14565. */
  14566. export enum SubEmitterType {
  14567. /**
  14568. * Attached to the particle over it's lifetime
  14569. */
  14570. ATTACHED = 0,
  14571. /**
  14572. * Created when the particle dies
  14573. */
  14574. END = 1
  14575. }
  14576. /**
  14577. * Sub emitter class used to emit particles from an existing particle
  14578. */
  14579. export class SubEmitter {
  14580. /**
  14581. * the particle system to be used by the sub emitter
  14582. */
  14583. particleSystem: ParticleSystem;
  14584. /**
  14585. * Type of the submitter (Default: END)
  14586. */
  14587. type: SubEmitterType;
  14588. /**
  14589. * 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)
  14590. * Note: This only is supported when using an emitter of type Mesh
  14591. */
  14592. inheritDirection: boolean;
  14593. /**
  14594. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14595. */
  14596. inheritedVelocityAmount: number;
  14597. /**
  14598. * Creates a sub emitter
  14599. * @param particleSystem the particle system to be used by the sub emitter
  14600. */
  14601. constructor(
  14602. /**
  14603. * the particle system to be used by the sub emitter
  14604. */
  14605. particleSystem: ParticleSystem);
  14606. /**
  14607. * Clones the sub emitter
  14608. * @returns the cloned sub emitter
  14609. */
  14610. clone(): SubEmitter;
  14611. /**
  14612. * Serialize current object to a JSON object
  14613. * @returns the serialized object
  14614. */
  14615. serialize(): any;
  14616. /** @hidden */
  14617. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14618. /**
  14619. * Creates a new SubEmitter from a serialized JSON version
  14620. * @param serializationObject defines the JSON object to read from
  14621. * @param scene defines the hosting scene
  14622. * @param rootUrl defines the rootUrl for data loading
  14623. * @returns a new SubEmitter
  14624. */
  14625. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14626. /** Release associated resources */
  14627. dispose(): void;
  14628. }
  14629. }
  14630. declare module BABYLON {
  14631. /** @hidden */
  14632. export var clipPlaneFragmentDeclaration: {
  14633. name: string;
  14634. shader: string;
  14635. };
  14636. }
  14637. declare module BABYLON {
  14638. /** @hidden */
  14639. export var imageProcessingDeclaration: {
  14640. name: string;
  14641. shader: string;
  14642. };
  14643. }
  14644. declare module BABYLON {
  14645. /** @hidden */
  14646. export var imageProcessingFunctions: {
  14647. name: string;
  14648. shader: string;
  14649. };
  14650. }
  14651. declare module BABYLON {
  14652. /** @hidden */
  14653. export var clipPlaneFragment: {
  14654. name: string;
  14655. shader: string;
  14656. };
  14657. }
  14658. declare module BABYLON {
  14659. /** @hidden */
  14660. export var particlesPixelShader: {
  14661. name: string;
  14662. shader: string;
  14663. };
  14664. }
  14665. declare module BABYLON {
  14666. /** @hidden */
  14667. export var clipPlaneVertexDeclaration: {
  14668. name: string;
  14669. shader: string;
  14670. };
  14671. }
  14672. declare module BABYLON {
  14673. /** @hidden */
  14674. export var clipPlaneVertex: {
  14675. name: string;
  14676. shader: string;
  14677. };
  14678. }
  14679. declare module BABYLON {
  14680. /** @hidden */
  14681. export var particlesVertexShader: {
  14682. name: string;
  14683. shader: string;
  14684. };
  14685. }
  14686. declare module BABYLON {
  14687. /**
  14688. * This represents a particle system in Babylon.
  14689. * 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.
  14690. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14691. * @example https://doc.babylonjs.com/babylon101/particles
  14692. */
  14693. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14694. /**
  14695. * Billboard mode will only apply to Y axis
  14696. */
  14697. static readonly BILLBOARDMODE_Y: number;
  14698. /**
  14699. * Billboard mode will apply to all axes
  14700. */
  14701. static readonly BILLBOARDMODE_ALL: number;
  14702. /**
  14703. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14704. */
  14705. static readonly BILLBOARDMODE_STRETCHED: number;
  14706. /**
  14707. * This function can be defined to provide custom update for active particles.
  14708. * This function will be called instead of regular update (age, position, color, etc.).
  14709. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14710. */
  14711. updateFunction: (particles: Particle[]) => void;
  14712. private _emitterWorldMatrix;
  14713. /**
  14714. * This function can be defined to specify initial direction for every new particle.
  14715. * It by default use the emitterType defined function
  14716. */
  14717. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14718. /**
  14719. * This function can be defined to specify initial position for every new particle.
  14720. * It by default use the emitterType defined function
  14721. */
  14722. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14723. /**
  14724. * @hidden
  14725. */
  14726. _inheritedVelocityOffset: Vector3;
  14727. /**
  14728. * An event triggered when the system is disposed
  14729. */
  14730. onDisposeObservable: Observable<ParticleSystem>;
  14731. private _onDisposeObserver;
  14732. /**
  14733. * Sets a callback that will be triggered when the system is disposed
  14734. */
  14735. onDispose: () => void;
  14736. private _particles;
  14737. private _epsilon;
  14738. private _capacity;
  14739. private _stockParticles;
  14740. private _newPartsExcess;
  14741. private _vertexData;
  14742. private _vertexBuffer;
  14743. private _vertexBuffers;
  14744. private _spriteBuffer;
  14745. private _indexBuffer;
  14746. private _effect;
  14747. private _customEffect;
  14748. private _cachedDefines;
  14749. private _scaledColorStep;
  14750. private _colorDiff;
  14751. private _scaledDirection;
  14752. private _scaledGravity;
  14753. private _currentRenderId;
  14754. private _alive;
  14755. private _useInstancing;
  14756. private _started;
  14757. private _stopped;
  14758. private _actualFrame;
  14759. private _scaledUpdateSpeed;
  14760. private _vertexBufferSize;
  14761. /** @hidden */
  14762. _currentEmitRateGradient: Nullable<FactorGradient>;
  14763. /** @hidden */
  14764. _currentEmitRate1: number;
  14765. /** @hidden */
  14766. _currentEmitRate2: number;
  14767. /** @hidden */
  14768. _currentStartSizeGradient: Nullable<FactorGradient>;
  14769. /** @hidden */
  14770. _currentStartSize1: number;
  14771. /** @hidden */
  14772. _currentStartSize2: number;
  14773. private readonly _rawTextureWidth;
  14774. private _rampGradientsTexture;
  14775. private _useRampGradients;
  14776. /** Gets or sets a boolean indicating that ramp gradients must be used
  14777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14778. */
  14779. useRampGradients: boolean;
  14780. /**
  14781. * 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.
  14782. * 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: [])
  14783. */
  14784. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14785. private _subEmitters;
  14786. /**
  14787. * @hidden
  14788. * If the particle systems emitter should be disposed when the particle system is disposed
  14789. */
  14790. _disposeEmitterOnDispose: boolean;
  14791. /**
  14792. * The current active Sub-systems, this property is used by the root particle system only.
  14793. */
  14794. activeSubSystems: Array<ParticleSystem>;
  14795. private _rootParticleSystem;
  14796. /**
  14797. * Gets the current list of active particles
  14798. */
  14799. readonly particles: Particle[];
  14800. /**
  14801. * Returns the string "ParticleSystem"
  14802. * @returns a string containing the class name
  14803. */
  14804. getClassName(): string;
  14805. /**
  14806. * Instantiates a particle system.
  14807. * 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.
  14808. * @param name The name of the particle system
  14809. * @param capacity The max number of particles alive at the same time
  14810. * @param scene The scene the particle system belongs to
  14811. * @param customEffect a custom effect used to change the way particles are rendered by default
  14812. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14813. * @param epsilon Offset used to render the particles
  14814. */
  14815. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14816. private _addFactorGradient;
  14817. private _removeFactorGradient;
  14818. /**
  14819. * Adds a new life time gradient
  14820. * @param gradient defines the gradient to use (between 0 and 1)
  14821. * @param factor defines the life time factor to affect to the specified gradient
  14822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14823. * @returns the current particle system
  14824. */
  14825. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14826. /**
  14827. * Remove a specific life time gradient
  14828. * @param gradient defines the gradient to remove
  14829. * @returns the current particle system
  14830. */
  14831. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14832. /**
  14833. * Adds a new size gradient
  14834. * @param gradient defines the gradient to use (between 0 and 1)
  14835. * @param factor defines the size factor to affect to the specified gradient
  14836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14837. * @returns the current particle system
  14838. */
  14839. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14840. /**
  14841. * Remove a specific size gradient
  14842. * @param gradient defines the gradient to remove
  14843. * @returns the current particle system
  14844. */
  14845. removeSizeGradient(gradient: number): IParticleSystem;
  14846. /**
  14847. * Adds a new color remap gradient
  14848. * @param gradient defines the gradient to use (between 0 and 1)
  14849. * @param min defines the color remap minimal range
  14850. * @param max defines the color remap maximal range
  14851. * @returns the current particle system
  14852. */
  14853. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14854. /**
  14855. * Remove a specific color remap gradient
  14856. * @param gradient defines the gradient to remove
  14857. * @returns the current particle system
  14858. */
  14859. removeColorRemapGradient(gradient: number): IParticleSystem;
  14860. /**
  14861. * Adds a new alpha remap gradient
  14862. * @param gradient defines the gradient to use (between 0 and 1)
  14863. * @param min defines the alpha remap minimal range
  14864. * @param max defines the alpha remap maximal range
  14865. * @returns the current particle system
  14866. */
  14867. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14868. /**
  14869. * Remove a specific alpha remap gradient
  14870. * @param gradient defines the gradient to remove
  14871. * @returns the current particle system
  14872. */
  14873. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14874. /**
  14875. * Adds a new angular speed gradient
  14876. * @param gradient defines the gradient to use (between 0 and 1)
  14877. * @param factor defines the angular speed to affect to the specified gradient
  14878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14879. * @returns the current particle system
  14880. */
  14881. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14882. /**
  14883. * Remove a specific angular speed gradient
  14884. * @param gradient defines the gradient to remove
  14885. * @returns the current particle system
  14886. */
  14887. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14888. /**
  14889. * Adds a new velocity gradient
  14890. * @param gradient defines the gradient to use (between 0 and 1)
  14891. * @param factor defines the velocity to affect to the specified gradient
  14892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14893. * @returns the current particle system
  14894. */
  14895. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14896. /**
  14897. * Remove a specific velocity gradient
  14898. * @param gradient defines the gradient to remove
  14899. * @returns the current particle system
  14900. */
  14901. removeVelocityGradient(gradient: number): IParticleSystem;
  14902. /**
  14903. * Adds a new limit velocity gradient
  14904. * @param gradient defines the gradient to use (between 0 and 1)
  14905. * @param factor defines the limit velocity value to affect to the specified gradient
  14906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14907. * @returns the current particle system
  14908. */
  14909. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14910. /**
  14911. * Remove a specific limit velocity gradient
  14912. * @param gradient defines the gradient to remove
  14913. * @returns the current particle system
  14914. */
  14915. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14916. /**
  14917. * Adds a new drag gradient
  14918. * @param gradient defines the gradient to use (between 0 and 1)
  14919. * @param factor defines the drag value to affect to the specified gradient
  14920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14921. * @returns the current particle system
  14922. */
  14923. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14924. /**
  14925. * Remove a specific drag gradient
  14926. * @param gradient defines the gradient to remove
  14927. * @returns the current particle system
  14928. */
  14929. removeDragGradient(gradient: number): IParticleSystem;
  14930. /**
  14931. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14932. * @param gradient defines the gradient to use (between 0 and 1)
  14933. * @param factor defines the emit rate value to affect to the specified gradient
  14934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14935. * @returns the current particle system
  14936. */
  14937. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14938. /**
  14939. * Remove a specific emit rate gradient
  14940. * @param gradient defines the gradient to remove
  14941. * @returns the current particle system
  14942. */
  14943. removeEmitRateGradient(gradient: number): IParticleSystem;
  14944. /**
  14945. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14946. * @param gradient defines the gradient to use (between 0 and 1)
  14947. * @param factor defines the start size value to affect to the specified gradient
  14948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14949. * @returns the current particle system
  14950. */
  14951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14952. /**
  14953. * Remove a specific start size gradient
  14954. * @param gradient defines the gradient to remove
  14955. * @returns the current particle system
  14956. */
  14957. removeStartSizeGradient(gradient: number): IParticleSystem;
  14958. private _createRampGradientTexture;
  14959. /**
  14960. * Gets the current list of ramp gradients.
  14961. * You must use addRampGradient and removeRampGradient to udpate this list
  14962. * @returns the list of ramp gradients
  14963. */
  14964. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14965. /**
  14966. * Adds a new ramp gradient used to remap particle colors
  14967. * @param gradient defines the gradient to use (between 0 and 1)
  14968. * @param color defines the color to affect to the specified gradient
  14969. * @returns the current particle system
  14970. */
  14971. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14972. /**
  14973. * Remove a specific ramp gradient
  14974. * @param gradient defines the gradient to remove
  14975. * @returns the current particle system
  14976. */
  14977. removeRampGradient(gradient: number): ParticleSystem;
  14978. /**
  14979. * Adds a new color gradient
  14980. * @param gradient defines the gradient to use (between 0 and 1)
  14981. * @param color1 defines the color to affect to the specified gradient
  14982. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14983. * @returns this particle system
  14984. */
  14985. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14986. /**
  14987. * Remove a specific color gradient
  14988. * @param gradient defines the gradient to remove
  14989. * @returns this particle system
  14990. */
  14991. removeColorGradient(gradient: number): IParticleSystem;
  14992. private _fetchR;
  14993. protected _reset(): void;
  14994. private _resetEffect;
  14995. private _createVertexBuffers;
  14996. private _createIndexBuffer;
  14997. /**
  14998. * Gets the maximum number of particles active at the same time.
  14999. * @returns The max number of active particles.
  15000. */
  15001. getCapacity(): number;
  15002. /**
  15003. * Gets whether there are still active particles in the system.
  15004. * @returns True if it is alive, otherwise false.
  15005. */
  15006. isAlive(): boolean;
  15007. /**
  15008. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15009. * @returns True if it has been started, otherwise false.
  15010. */
  15011. isStarted(): boolean;
  15012. private _prepareSubEmitterInternalArray;
  15013. /**
  15014. * Starts the particle system and begins to emit
  15015. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15016. */
  15017. start(delay?: number): void;
  15018. /**
  15019. * Stops the particle system.
  15020. * @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.
  15021. */
  15022. stop(stopSubEmitters?: boolean): void;
  15023. /**
  15024. * Remove all active particles
  15025. */
  15026. reset(): void;
  15027. /**
  15028. * @hidden (for internal use only)
  15029. */
  15030. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15031. /**
  15032. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15033. * Its lifetime will start back at 0.
  15034. */
  15035. recycleParticle: (particle: Particle) => void;
  15036. private _stopSubEmitters;
  15037. private _createParticle;
  15038. private _removeFromRoot;
  15039. private _emitFromParticle;
  15040. private _update;
  15041. /** @hidden */
  15042. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15043. /** @hidden */
  15044. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15045. /** @hidden */
  15046. private _getEffect;
  15047. /**
  15048. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15049. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15050. */
  15051. animate(preWarmOnly?: boolean): void;
  15052. private _appendParticleVertices;
  15053. /**
  15054. * Rebuilds the particle system.
  15055. */
  15056. rebuild(): void;
  15057. /**
  15058. * Is this system ready to be used/rendered
  15059. * @return true if the system is ready
  15060. */
  15061. isReady(): boolean;
  15062. private _render;
  15063. /**
  15064. * Renders the particle system in its current state.
  15065. * @returns the current number of particles
  15066. */
  15067. render(): number;
  15068. /**
  15069. * Disposes the particle system and free the associated resources
  15070. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15071. */
  15072. dispose(disposeTexture?: boolean): void;
  15073. /**
  15074. * Clones the particle system.
  15075. * @param name The name of the cloned object
  15076. * @param newEmitter The new emitter to use
  15077. * @returns the cloned particle system
  15078. */
  15079. clone(name: string, newEmitter: any): ParticleSystem;
  15080. /**
  15081. * Serializes the particle system to a JSON object.
  15082. * @returns the JSON object
  15083. */
  15084. serialize(): any;
  15085. /** @hidden */
  15086. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15087. /** @hidden */
  15088. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15089. /**
  15090. * Parses a JSON object to create a particle system.
  15091. * @param parsedParticleSystem The JSON object to parse
  15092. * @param scene The scene to create the particle system in
  15093. * @param rootUrl The root url to use to load external dependencies like texture
  15094. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15095. * @returns the Parsed particle system
  15096. */
  15097. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15098. }
  15099. }
  15100. declare module BABYLON {
  15101. /**
  15102. * A particle represents one of the element emitted by a particle system.
  15103. * This is mainly define by its coordinates, direction, velocity and age.
  15104. */
  15105. export class Particle {
  15106. /**
  15107. * The particle system the particle belongs to.
  15108. */
  15109. particleSystem: ParticleSystem;
  15110. private static _Count;
  15111. /**
  15112. * Unique ID of the particle
  15113. */
  15114. id: number;
  15115. /**
  15116. * The world position of the particle in the scene.
  15117. */
  15118. position: Vector3;
  15119. /**
  15120. * The world direction of the particle in the scene.
  15121. */
  15122. direction: Vector3;
  15123. /**
  15124. * The color of the particle.
  15125. */
  15126. color: Color4;
  15127. /**
  15128. * The color change of the particle per step.
  15129. */
  15130. colorStep: Color4;
  15131. /**
  15132. * Defines how long will the life of the particle be.
  15133. */
  15134. lifeTime: number;
  15135. /**
  15136. * The current age of the particle.
  15137. */
  15138. age: number;
  15139. /**
  15140. * The current size of the particle.
  15141. */
  15142. size: number;
  15143. /**
  15144. * The current scale of the particle.
  15145. */
  15146. scale: Vector2;
  15147. /**
  15148. * The current angle of the particle.
  15149. */
  15150. angle: number;
  15151. /**
  15152. * Defines how fast is the angle changing.
  15153. */
  15154. angularSpeed: number;
  15155. /**
  15156. * Defines the cell index used by the particle to be rendered from a sprite.
  15157. */
  15158. cellIndex: number;
  15159. /**
  15160. * The information required to support color remapping
  15161. */
  15162. remapData: Vector4;
  15163. /** @hidden */
  15164. _randomCellOffset?: number;
  15165. /** @hidden */
  15166. _initialDirection: Nullable<Vector3>;
  15167. /** @hidden */
  15168. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15169. /** @hidden */
  15170. _initialStartSpriteCellID: number;
  15171. /** @hidden */
  15172. _initialEndSpriteCellID: number;
  15173. /** @hidden */
  15174. _currentColorGradient: Nullable<ColorGradient>;
  15175. /** @hidden */
  15176. _currentColor1: Color4;
  15177. /** @hidden */
  15178. _currentColor2: Color4;
  15179. /** @hidden */
  15180. _currentSizeGradient: Nullable<FactorGradient>;
  15181. /** @hidden */
  15182. _currentSize1: number;
  15183. /** @hidden */
  15184. _currentSize2: number;
  15185. /** @hidden */
  15186. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15187. /** @hidden */
  15188. _currentAngularSpeed1: number;
  15189. /** @hidden */
  15190. _currentAngularSpeed2: number;
  15191. /** @hidden */
  15192. _currentVelocityGradient: Nullable<FactorGradient>;
  15193. /** @hidden */
  15194. _currentVelocity1: number;
  15195. /** @hidden */
  15196. _currentVelocity2: number;
  15197. /** @hidden */
  15198. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15199. /** @hidden */
  15200. _currentLimitVelocity1: number;
  15201. /** @hidden */
  15202. _currentLimitVelocity2: number;
  15203. /** @hidden */
  15204. _currentDragGradient: Nullable<FactorGradient>;
  15205. /** @hidden */
  15206. _currentDrag1: number;
  15207. /** @hidden */
  15208. _currentDrag2: number;
  15209. /** @hidden */
  15210. _randomNoiseCoordinates1: Vector3;
  15211. /** @hidden */
  15212. _randomNoiseCoordinates2: Vector3;
  15213. /**
  15214. * Creates a new instance Particle
  15215. * @param particleSystem the particle system the particle belongs to
  15216. */
  15217. constructor(
  15218. /**
  15219. * The particle system the particle belongs to.
  15220. */
  15221. particleSystem: ParticleSystem);
  15222. private updateCellInfoFromSystem;
  15223. /**
  15224. * Defines how the sprite cell index is updated for the particle
  15225. */
  15226. updateCellIndex(): void;
  15227. /** @hidden */
  15228. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15229. /** @hidden */
  15230. _inheritParticleInfoToSubEmitters(): void;
  15231. /** @hidden */
  15232. _reset(): void;
  15233. /**
  15234. * Copy the properties of particle to another one.
  15235. * @param other the particle to copy the information to.
  15236. */
  15237. copyTo(other: Particle): void;
  15238. }
  15239. }
  15240. declare module BABYLON {
  15241. /**
  15242. * Particle emitter represents a volume emitting particles.
  15243. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15244. */
  15245. export interface IParticleEmitterType {
  15246. /**
  15247. * Called by the particle System when the direction is computed for the created particle.
  15248. * @param worldMatrix is the world matrix of the particle system
  15249. * @param directionToUpdate is the direction vector to update with the result
  15250. * @param particle is the particle we are computed the direction for
  15251. */
  15252. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15253. /**
  15254. * Called by the particle System when the position is computed for the created particle.
  15255. * @param worldMatrix is the world matrix of the particle system
  15256. * @param positionToUpdate is the position vector to update with the result
  15257. * @param particle is the particle we are computed the position for
  15258. */
  15259. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15260. /**
  15261. * Clones the current emitter and returns a copy of it
  15262. * @returns the new emitter
  15263. */
  15264. clone(): IParticleEmitterType;
  15265. /**
  15266. * Called by the GPUParticleSystem to setup the update shader
  15267. * @param effect defines the update shader
  15268. */
  15269. applyToShader(effect: Effect): void;
  15270. /**
  15271. * Returns a string to use to update the GPU particles update shader
  15272. * @returns the effect defines string
  15273. */
  15274. getEffectDefines(): string;
  15275. /**
  15276. * Returns a string representing the class name
  15277. * @returns a string containing the class name
  15278. */
  15279. getClassName(): string;
  15280. /**
  15281. * Serializes the particle system to a JSON object.
  15282. * @returns the JSON object
  15283. */
  15284. serialize(): any;
  15285. /**
  15286. * Parse properties from a JSON object
  15287. * @param serializationObject defines the JSON object
  15288. */
  15289. parse(serializationObject: any): void;
  15290. }
  15291. }
  15292. declare module BABYLON {
  15293. /**
  15294. * Particle emitter emitting particles from the inside of a box.
  15295. * It emits the particles randomly between 2 given directions.
  15296. */
  15297. export class BoxParticleEmitter implements IParticleEmitterType {
  15298. /**
  15299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15300. */
  15301. direction1: Vector3;
  15302. /**
  15303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15304. */
  15305. direction2: Vector3;
  15306. /**
  15307. * 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.
  15308. */
  15309. minEmitBox: Vector3;
  15310. /**
  15311. * 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.
  15312. */
  15313. maxEmitBox: Vector3;
  15314. /**
  15315. * Creates a new instance BoxParticleEmitter
  15316. */
  15317. constructor();
  15318. /**
  15319. * Called by the particle System when the direction is computed for the created particle.
  15320. * @param worldMatrix is the world matrix of the particle system
  15321. * @param directionToUpdate is the direction vector to update with the result
  15322. * @param particle is the particle we are computed the direction for
  15323. */
  15324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15325. /**
  15326. * Called by the particle System when the position is computed for the created particle.
  15327. * @param worldMatrix is the world matrix of the particle system
  15328. * @param positionToUpdate is the position vector to update with the result
  15329. * @param particle is the particle we are computed the position for
  15330. */
  15331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15332. /**
  15333. * Clones the current emitter and returns a copy of it
  15334. * @returns the new emitter
  15335. */
  15336. clone(): BoxParticleEmitter;
  15337. /**
  15338. * Called by the GPUParticleSystem to setup the update shader
  15339. * @param effect defines the update shader
  15340. */
  15341. applyToShader(effect: Effect): void;
  15342. /**
  15343. * Returns a string to use to update the GPU particles update shader
  15344. * @returns a string containng the defines string
  15345. */
  15346. getEffectDefines(): string;
  15347. /**
  15348. * Returns the string "BoxParticleEmitter"
  15349. * @returns a string containing the class name
  15350. */
  15351. getClassName(): string;
  15352. /**
  15353. * Serializes the particle system to a JSON object.
  15354. * @returns the JSON object
  15355. */
  15356. serialize(): any;
  15357. /**
  15358. * Parse properties from a JSON object
  15359. * @param serializationObject defines the JSON object
  15360. */
  15361. parse(serializationObject: any): void;
  15362. }
  15363. }
  15364. declare module BABYLON {
  15365. /**
  15366. * Particle emitter emitting particles from the inside of a cone.
  15367. * It emits the particles alongside the cone volume from the base to the particle.
  15368. * The emission direction might be randomized.
  15369. */
  15370. export class ConeParticleEmitter implements IParticleEmitterType {
  15371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15372. directionRandomizer: number;
  15373. private _radius;
  15374. private _angle;
  15375. private _height;
  15376. /**
  15377. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15378. */
  15379. radiusRange: number;
  15380. /**
  15381. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15382. */
  15383. heightRange: number;
  15384. /**
  15385. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15386. */
  15387. emitFromSpawnPointOnly: boolean;
  15388. /**
  15389. * Gets or sets the radius of the emission cone
  15390. */
  15391. radius: number;
  15392. /**
  15393. * Gets or sets the angle of the emission cone
  15394. */
  15395. angle: number;
  15396. private _buildHeight;
  15397. /**
  15398. * Creates a new instance ConeParticleEmitter
  15399. * @param radius the radius of the emission cone (1 by default)
  15400. * @param angle the cone base angle (PI by default)
  15401. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15402. */
  15403. constructor(radius?: number, angle?: number,
  15404. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15405. directionRandomizer?: number);
  15406. /**
  15407. * Called by the particle System when the direction is computed for the created particle.
  15408. * @param worldMatrix is the world matrix of the particle system
  15409. * @param directionToUpdate is the direction vector to update with the result
  15410. * @param particle is the particle we are computed the direction for
  15411. */
  15412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15413. /**
  15414. * Called by the particle System when the position is computed for the created particle.
  15415. * @param worldMatrix is the world matrix of the particle system
  15416. * @param positionToUpdate is the position vector to update with the result
  15417. * @param particle is the particle we are computed the position for
  15418. */
  15419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15420. /**
  15421. * Clones the current emitter and returns a copy of it
  15422. * @returns the new emitter
  15423. */
  15424. clone(): ConeParticleEmitter;
  15425. /**
  15426. * Called by the GPUParticleSystem to setup the update shader
  15427. * @param effect defines the update shader
  15428. */
  15429. applyToShader(effect: Effect): void;
  15430. /**
  15431. * Returns a string to use to update the GPU particles update shader
  15432. * @returns a string containng the defines string
  15433. */
  15434. getEffectDefines(): string;
  15435. /**
  15436. * Returns the string "ConeParticleEmitter"
  15437. * @returns a string containing the class name
  15438. */
  15439. getClassName(): string;
  15440. /**
  15441. * Serializes the particle system to a JSON object.
  15442. * @returns the JSON object
  15443. */
  15444. serialize(): any;
  15445. /**
  15446. * Parse properties from a JSON object
  15447. * @param serializationObject defines the JSON object
  15448. */
  15449. parse(serializationObject: any): void;
  15450. }
  15451. }
  15452. declare module BABYLON {
  15453. /**
  15454. * Particle emitter emitting particles from the inside of a cylinder.
  15455. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15456. */
  15457. export class CylinderParticleEmitter implements IParticleEmitterType {
  15458. /**
  15459. * The radius of the emission cylinder.
  15460. */
  15461. radius: number;
  15462. /**
  15463. * The height of the emission cylinder.
  15464. */
  15465. height: number;
  15466. /**
  15467. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15468. */
  15469. radiusRange: number;
  15470. /**
  15471. * How much to randomize the particle direction [0-1].
  15472. */
  15473. directionRandomizer: number;
  15474. /**
  15475. * Creates a new instance CylinderParticleEmitter
  15476. * @param radius the radius of the emission cylinder (1 by default)
  15477. * @param height the height of the emission cylinder (1 by default)
  15478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15479. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15480. */
  15481. constructor(
  15482. /**
  15483. * The radius of the emission cylinder.
  15484. */
  15485. radius?: number,
  15486. /**
  15487. * The height of the emission cylinder.
  15488. */
  15489. height?: number,
  15490. /**
  15491. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15492. */
  15493. radiusRange?: number,
  15494. /**
  15495. * How much to randomize the particle direction [0-1].
  15496. */
  15497. directionRandomizer?: number);
  15498. /**
  15499. * Called by the particle System when the direction is computed for the created particle.
  15500. * @param worldMatrix is the world matrix of the particle system
  15501. * @param directionToUpdate is the direction vector to update with the result
  15502. * @param particle is the particle we are computed the direction for
  15503. */
  15504. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15505. /**
  15506. * Called by the particle System when the position is computed for the created particle.
  15507. * @param worldMatrix is the world matrix of the particle system
  15508. * @param positionToUpdate is the position vector to update with the result
  15509. * @param particle is the particle we are computed the position for
  15510. */
  15511. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15512. /**
  15513. * Clones the current emitter and returns a copy of it
  15514. * @returns the new emitter
  15515. */
  15516. clone(): CylinderParticleEmitter;
  15517. /**
  15518. * Called by the GPUParticleSystem to setup the update shader
  15519. * @param effect defines the update shader
  15520. */
  15521. applyToShader(effect: Effect): void;
  15522. /**
  15523. * Returns a string to use to update the GPU particles update shader
  15524. * @returns a string containng the defines string
  15525. */
  15526. getEffectDefines(): string;
  15527. /**
  15528. * Returns the string "CylinderParticleEmitter"
  15529. * @returns a string containing the class name
  15530. */
  15531. getClassName(): string;
  15532. /**
  15533. * Serializes the particle system to a JSON object.
  15534. * @returns the JSON object
  15535. */
  15536. serialize(): any;
  15537. /**
  15538. * Parse properties from a JSON object
  15539. * @param serializationObject defines the JSON object
  15540. */
  15541. parse(serializationObject: any): void;
  15542. }
  15543. /**
  15544. * Particle emitter emitting particles from the inside of a cylinder.
  15545. * It emits the particles randomly between two vectors.
  15546. */
  15547. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15548. /**
  15549. * The min limit of the emission direction.
  15550. */
  15551. direction1: Vector3;
  15552. /**
  15553. * The max limit of the emission direction.
  15554. */
  15555. direction2: Vector3;
  15556. /**
  15557. * Creates a new instance CylinderDirectedParticleEmitter
  15558. * @param radius the radius of the emission cylinder (1 by default)
  15559. * @param height the height of the emission cylinder (1 by default)
  15560. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15561. * @param direction1 the min limit of the emission direction (up vector by default)
  15562. * @param direction2 the max limit of the emission direction (up vector by default)
  15563. */
  15564. constructor(radius?: number, height?: number, radiusRange?: number,
  15565. /**
  15566. * The min limit of the emission direction.
  15567. */
  15568. direction1?: Vector3,
  15569. /**
  15570. * The max limit of the emission direction.
  15571. */
  15572. direction2?: Vector3);
  15573. /**
  15574. * Called by the particle System when the direction is computed for the created particle.
  15575. * @param worldMatrix is the world matrix of the particle system
  15576. * @param directionToUpdate is the direction vector to update with the result
  15577. * @param particle is the particle we are computed the direction for
  15578. */
  15579. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15580. /**
  15581. * Clones the current emitter and returns a copy of it
  15582. * @returns the new emitter
  15583. */
  15584. clone(): CylinderDirectedParticleEmitter;
  15585. /**
  15586. * Called by the GPUParticleSystem to setup the update shader
  15587. * @param effect defines the update shader
  15588. */
  15589. applyToShader(effect: Effect): void;
  15590. /**
  15591. * Returns a string to use to update the GPU particles update shader
  15592. * @returns a string containng the defines string
  15593. */
  15594. getEffectDefines(): string;
  15595. /**
  15596. * Returns the string "CylinderDirectedParticleEmitter"
  15597. * @returns a string containing the class name
  15598. */
  15599. getClassName(): string;
  15600. /**
  15601. * Serializes the particle system to a JSON object.
  15602. * @returns the JSON object
  15603. */
  15604. serialize(): any;
  15605. /**
  15606. * Parse properties from a JSON object
  15607. * @param serializationObject defines the JSON object
  15608. */
  15609. parse(serializationObject: any): void;
  15610. }
  15611. }
  15612. declare module BABYLON {
  15613. /**
  15614. * Particle emitter emitting particles from the inside of a hemisphere.
  15615. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15616. */
  15617. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15618. /**
  15619. * The radius of the emission hemisphere.
  15620. */
  15621. radius: number;
  15622. /**
  15623. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15624. */
  15625. radiusRange: number;
  15626. /**
  15627. * How much to randomize the particle direction [0-1].
  15628. */
  15629. directionRandomizer: number;
  15630. /**
  15631. * Creates a new instance HemisphericParticleEmitter
  15632. * @param radius the radius of the emission hemisphere (1 by default)
  15633. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15634. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15635. */
  15636. constructor(
  15637. /**
  15638. * The radius of the emission hemisphere.
  15639. */
  15640. radius?: number,
  15641. /**
  15642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15643. */
  15644. radiusRange?: number,
  15645. /**
  15646. * How much to randomize the particle direction [0-1].
  15647. */
  15648. directionRandomizer?: number);
  15649. /**
  15650. * Called by the particle System when the direction is computed for the created particle.
  15651. * @param worldMatrix is the world matrix of the particle system
  15652. * @param directionToUpdate is the direction vector to update with the result
  15653. * @param particle is the particle we are computed the direction for
  15654. */
  15655. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15656. /**
  15657. * Called by the particle System when the position is computed for the created particle.
  15658. * @param worldMatrix is the world matrix of the particle system
  15659. * @param positionToUpdate is the position vector to update with the result
  15660. * @param particle is the particle we are computed the position for
  15661. */
  15662. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15663. /**
  15664. * Clones the current emitter and returns a copy of it
  15665. * @returns the new emitter
  15666. */
  15667. clone(): HemisphericParticleEmitter;
  15668. /**
  15669. * Called by the GPUParticleSystem to setup the update shader
  15670. * @param effect defines the update shader
  15671. */
  15672. applyToShader(effect: Effect): void;
  15673. /**
  15674. * Returns a string to use to update the GPU particles update shader
  15675. * @returns a string containng the defines string
  15676. */
  15677. getEffectDefines(): string;
  15678. /**
  15679. * Returns the string "HemisphericParticleEmitter"
  15680. * @returns a string containing the class name
  15681. */
  15682. getClassName(): string;
  15683. /**
  15684. * Serializes the particle system to a JSON object.
  15685. * @returns the JSON object
  15686. */
  15687. serialize(): any;
  15688. /**
  15689. * Parse properties from a JSON object
  15690. * @param serializationObject defines the JSON object
  15691. */
  15692. parse(serializationObject: any): void;
  15693. }
  15694. }
  15695. declare module BABYLON {
  15696. /**
  15697. * Particle emitter emitting particles from a point.
  15698. * It emits the particles randomly between 2 given directions.
  15699. */
  15700. export class PointParticleEmitter implements IParticleEmitterType {
  15701. /**
  15702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15703. */
  15704. direction1: Vector3;
  15705. /**
  15706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15707. */
  15708. direction2: Vector3;
  15709. /**
  15710. * Creates a new instance PointParticleEmitter
  15711. */
  15712. constructor();
  15713. /**
  15714. * Called by the particle System when the direction is computed for the created particle.
  15715. * @param worldMatrix is the world matrix of the particle system
  15716. * @param directionToUpdate is the direction vector to update with the result
  15717. * @param particle is the particle we are computed the direction for
  15718. */
  15719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15720. /**
  15721. * Called by the particle System when the position is computed for the created particle.
  15722. * @param worldMatrix is the world matrix of the particle system
  15723. * @param positionToUpdate is the position vector to update with the result
  15724. * @param particle is the particle we are computed the position for
  15725. */
  15726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15727. /**
  15728. * Clones the current emitter and returns a copy of it
  15729. * @returns the new emitter
  15730. */
  15731. clone(): PointParticleEmitter;
  15732. /**
  15733. * Called by the GPUParticleSystem to setup the update shader
  15734. * @param effect defines the update shader
  15735. */
  15736. applyToShader(effect: Effect): void;
  15737. /**
  15738. * Returns a string to use to update the GPU particles update shader
  15739. * @returns a string containng the defines string
  15740. */
  15741. getEffectDefines(): string;
  15742. /**
  15743. * Returns the string "PointParticleEmitter"
  15744. * @returns a string containing the class name
  15745. */
  15746. getClassName(): string;
  15747. /**
  15748. * Serializes the particle system to a JSON object.
  15749. * @returns the JSON object
  15750. */
  15751. serialize(): any;
  15752. /**
  15753. * Parse properties from a JSON object
  15754. * @param serializationObject defines the JSON object
  15755. */
  15756. parse(serializationObject: any): void;
  15757. }
  15758. }
  15759. declare module BABYLON {
  15760. /**
  15761. * Particle emitter emitting particles from the inside of a sphere.
  15762. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15763. */
  15764. export class SphereParticleEmitter implements IParticleEmitterType {
  15765. /**
  15766. * The radius of the emission sphere.
  15767. */
  15768. radius: number;
  15769. /**
  15770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15771. */
  15772. radiusRange: number;
  15773. /**
  15774. * How much to randomize the particle direction [0-1].
  15775. */
  15776. directionRandomizer: number;
  15777. /**
  15778. * Creates a new instance SphereParticleEmitter
  15779. * @param radius the radius of the emission sphere (1 by default)
  15780. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15781. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15782. */
  15783. constructor(
  15784. /**
  15785. * The radius of the emission sphere.
  15786. */
  15787. radius?: number,
  15788. /**
  15789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15790. */
  15791. radiusRange?: number,
  15792. /**
  15793. * How much to randomize the particle direction [0-1].
  15794. */
  15795. directionRandomizer?: number);
  15796. /**
  15797. * Called by the particle System when the direction is computed for the created particle.
  15798. * @param worldMatrix is the world matrix of the particle system
  15799. * @param directionToUpdate is the direction vector to update with the result
  15800. * @param particle is the particle we are computed the direction for
  15801. */
  15802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15803. /**
  15804. * Called by the particle System when the position is computed for the created particle.
  15805. * @param worldMatrix is the world matrix of the particle system
  15806. * @param positionToUpdate is the position vector to update with the result
  15807. * @param particle is the particle we are computed the position for
  15808. */
  15809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15810. /**
  15811. * Clones the current emitter and returns a copy of it
  15812. * @returns the new emitter
  15813. */
  15814. clone(): SphereParticleEmitter;
  15815. /**
  15816. * Called by the GPUParticleSystem to setup the update shader
  15817. * @param effect defines the update shader
  15818. */
  15819. applyToShader(effect: Effect): void;
  15820. /**
  15821. * Returns a string to use to update the GPU particles update shader
  15822. * @returns a string containng the defines string
  15823. */
  15824. getEffectDefines(): string;
  15825. /**
  15826. * Returns the string "SphereParticleEmitter"
  15827. * @returns a string containing the class name
  15828. */
  15829. getClassName(): string;
  15830. /**
  15831. * Serializes the particle system to a JSON object.
  15832. * @returns the JSON object
  15833. */
  15834. serialize(): any;
  15835. /**
  15836. * Parse properties from a JSON object
  15837. * @param serializationObject defines the JSON object
  15838. */
  15839. parse(serializationObject: any): void;
  15840. }
  15841. /**
  15842. * Particle emitter emitting particles from the inside of a sphere.
  15843. * It emits the particles randomly between two vectors.
  15844. */
  15845. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15846. /**
  15847. * The min limit of the emission direction.
  15848. */
  15849. direction1: Vector3;
  15850. /**
  15851. * The max limit of the emission direction.
  15852. */
  15853. direction2: Vector3;
  15854. /**
  15855. * Creates a new instance SphereDirectedParticleEmitter
  15856. * @param radius the radius of the emission sphere (1 by default)
  15857. * @param direction1 the min limit of the emission direction (up vector by default)
  15858. * @param direction2 the max limit of the emission direction (up vector by default)
  15859. */
  15860. constructor(radius?: number,
  15861. /**
  15862. * The min limit of the emission direction.
  15863. */
  15864. direction1?: Vector3,
  15865. /**
  15866. * The max limit of the emission direction.
  15867. */
  15868. direction2?: Vector3);
  15869. /**
  15870. * Called by the particle System when the direction is computed for the created particle.
  15871. * @param worldMatrix is the world matrix of the particle system
  15872. * @param directionToUpdate is the direction vector to update with the result
  15873. * @param particle is the particle we are computed the direction for
  15874. */
  15875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15876. /**
  15877. * Clones the current emitter and returns a copy of it
  15878. * @returns the new emitter
  15879. */
  15880. clone(): SphereDirectedParticleEmitter;
  15881. /**
  15882. * Called by the GPUParticleSystem to setup the update shader
  15883. * @param effect defines the update shader
  15884. */
  15885. applyToShader(effect: Effect): void;
  15886. /**
  15887. * Returns a string to use to update the GPU particles update shader
  15888. * @returns a string containng the defines string
  15889. */
  15890. getEffectDefines(): string;
  15891. /**
  15892. * Returns the string "SphereDirectedParticleEmitter"
  15893. * @returns a string containing the class name
  15894. */
  15895. getClassName(): string;
  15896. /**
  15897. * Serializes the particle system to a JSON object.
  15898. * @returns the JSON object
  15899. */
  15900. serialize(): any;
  15901. /**
  15902. * Parse properties from a JSON object
  15903. * @param serializationObject defines the JSON object
  15904. */
  15905. parse(serializationObject: any): void;
  15906. }
  15907. }
  15908. declare module BABYLON {
  15909. /**
  15910. * Interface representing a particle system in Babylon.js.
  15911. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15912. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15913. */
  15914. export interface IParticleSystem {
  15915. /**
  15916. * List of animations used by the particle system.
  15917. */
  15918. animations: Animation[];
  15919. /**
  15920. * The id of the Particle system.
  15921. */
  15922. id: string;
  15923. /**
  15924. * The name of the Particle system.
  15925. */
  15926. name: string;
  15927. /**
  15928. * The emitter represents the Mesh or position we are attaching the particle system to.
  15929. */
  15930. emitter: Nullable<AbstractMesh | Vector3>;
  15931. /**
  15932. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15933. */
  15934. isBillboardBased: boolean;
  15935. /**
  15936. * The rendering group used by the Particle system to chose when to render.
  15937. */
  15938. renderingGroupId: number;
  15939. /**
  15940. * The layer mask we are rendering the particles through.
  15941. */
  15942. layerMask: number;
  15943. /**
  15944. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15945. */
  15946. updateSpeed: number;
  15947. /**
  15948. * The amount of time the particle system is running (depends of the overall update speed).
  15949. */
  15950. targetStopDuration: number;
  15951. /**
  15952. * The texture used to render each particle. (this can be a spritesheet)
  15953. */
  15954. particleTexture: Nullable<Texture>;
  15955. /**
  15956. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15957. */
  15958. blendMode: number;
  15959. /**
  15960. * Minimum life time of emitting particles.
  15961. */
  15962. minLifeTime: number;
  15963. /**
  15964. * Maximum life time of emitting particles.
  15965. */
  15966. maxLifeTime: number;
  15967. /**
  15968. * Minimum Size of emitting particles.
  15969. */
  15970. minSize: number;
  15971. /**
  15972. * Maximum Size of emitting particles.
  15973. */
  15974. maxSize: number;
  15975. /**
  15976. * Minimum scale of emitting particles on X axis.
  15977. */
  15978. minScaleX: number;
  15979. /**
  15980. * Maximum scale of emitting particles on X axis.
  15981. */
  15982. maxScaleX: number;
  15983. /**
  15984. * Minimum scale of emitting particles on Y axis.
  15985. */
  15986. minScaleY: number;
  15987. /**
  15988. * Maximum scale of emitting particles on Y axis.
  15989. */
  15990. maxScaleY: number;
  15991. /**
  15992. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15993. */
  15994. color1: Color4;
  15995. /**
  15996. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15997. */
  15998. color2: Color4;
  15999. /**
  16000. * Color the particle will have at the end of its lifetime.
  16001. */
  16002. colorDead: Color4;
  16003. /**
  16004. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16005. */
  16006. emitRate: number;
  16007. /**
  16008. * You can use gravity if you want to give an orientation to your particles.
  16009. */
  16010. gravity: Vector3;
  16011. /**
  16012. * Minimum power of emitting particles.
  16013. */
  16014. minEmitPower: number;
  16015. /**
  16016. * Maximum power of emitting particles.
  16017. */
  16018. maxEmitPower: number;
  16019. /**
  16020. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16021. */
  16022. minAngularSpeed: number;
  16023. /**
  16024. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16025. */
  16026. maxAngularSpeed: number;
  16027. /**
  16028. * Gets or sets the minimal initial rotation in radians.
  16029. */
  16030. minInitialRotation: number;
  16031. /**
  16032. * Gets or sets the maximal initial rotation in radians.
  16033. */
  16034. maxInitialRotation: number;
  16035. /**
  16036. * The particle emitter type defines the emitter used by the particle system.
  16037. * It can be for example box, sphere, or cone...
  16038. */
  16039. particleEmitterType: Nullable<IParticleEmitterType>;
  16040. /**
  16041. * Defines the delay in milliseconds before starting the system (0 by default)
  16042. */
  16043. startDelay: number;
  16044. /**
  16045. * 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
  16046. */
  16047. preWarmCycles: number;
  16048. /**
  16049. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16050. */
  16051. preWarmStepOffset: number;
  16052. /**
  16053. * 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)
  16054. */
  16055. spriteCellChangeSpeed: number;
  16056. /**
  16057. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16058. */
  16059. startSpriteCellID: number;
  16060. /**
  16061. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16062. */
  16063. endSpriteCellID: number;
  16064. /**
  16065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16066. */
  16067. spriteCellWidth: number;
  16068. /**
  16069. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16070. */
  16071. spriteCellHeight: number;
  16072. /**
  16073. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16074. */
  16075. spriteRandomStartCell: boolean;
  16076. /**
  16077. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16078. */
  16079. isAnimationSheetEnabled: boolean;
  16080. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16081. translationPivot: Vector2;
  16082. /**
  16083. * Gets or sets a texture used to add random noise to particle positions
  16084. */
  16085. noiseTexture: Nullable<BaseTexture>;
  16086. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16087. noiseStrength: Vector3;
  16088. /**
  16089. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16090. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16091. */
  16092. billboardMode: number;
  16093. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16094. limitVelocityDamping: number;
  16095. /**
  16096. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16097. */
  16098. beginAnimationOnStart: boolean;
  16099. /**
  16100. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16101. */
  16102. beginAnimationFrom: number;
  16103. /**
  16104. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16105. */
  16106. beginAnimationTo: number;
  16107. /**
  16108. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16109. */
  16110. beginAnimationLoop: boolean;
  16111. /**
  16112. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16113. */
  16114. disposeOnStop: boolean;
  16115. /**
  16116. * Gets the maximum number of particles active at the same time.
  16117. * @returns The max number of active particles.
  16118. */
  16119. getCapacity(): number;
  16120. /**
  16121. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16122. * @returns True if it has been started, otherwise false.
  16123. */
  16124. isStarted(): boolean;
  16125. /**
  16126. * Animates the particle system for this frame.
  16127. */
  16128. animate(): void;
  16129. /**
  16130. * Renders the particle system in its current state.
  16131. * @returns the current number of particles
  16132. */
  16133. render(): number;
  16134. /**
  16135. * Dispose the particle system and frees its associated resources.
  16136. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16137. */
  16138. dispose(disposeTexture?: boolean): void;
  16139. /**
  16140. * Clones the particle system.
  16141. * @param name The name of the cloned object
  16142. * @param newEmitter The new emitter to use
  16143. * @returns the cloned particle system
  16144. */
  16145. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16146. /**
  16147. * Serializes the particle system to a JSON object.
  16148. * @returns the JSON object
  16149. */
  16150. serialize(): any;
  16151. /**
  16152. * Rebuild the particle system
  16153. */
  16154. rebuild(): void;
  16155. /**
  16156. * Starts the particle system and begins to emit
  16157. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16158. */
  16159. start(delay?: number): void;
  16160. /**
  16161. * Stops the particle system.
  16162. */
  16163. stop(): void;
  16164. /**
  16165. * Remove all active particles
  16166. */
  16167. reset(): void;
  16168. /**
  16169. * Is this system ready to be used/rendered
  16170. * @return true if the system is ready
  16171. */
  16172. isReady(): boolean;
  16173. /**
  16174. * Adds a new color gradient
  16175. * @param gradient defines the gradient to use (between 0 and 1)
  16176. * @param color1 defines the color to affect to the specified gradient
  16177. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16178. * @returns the current particle system
  16179. */
  16180. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16181. /**
  16182. * Remove a specific color gradient
  16183. * @param gradient defines the gradient to remove
  16184. * @returns the current particle system
  16185. */
  16186. removeColorGradient(gradient: number): IParticleSystem;
  16187. /**
  16188. * Adds a new size gradient
  16189. * @param gradient defines the gradient to use (between 0 and 1)
  16190. * @param factor defines the size factor to affect to the specified gradient
  16191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16192. * @returns the current particle system
  16193. */
  16194. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16195. /**
  16196. * Remove a specific size gradient
  16197. * @param gradient defines the gradient to remove
  16198. * @returns the current particle system
  16199. */
  16200. removeSizeGradient(gradient: number): IParticleSystem;
  16201. /**
  16202. * Gets the current list of color gradients.
  16203. * You must use addColorGradient and removeColorGradient to udpate this list
  16204. * @returns the list of color gradients
  16205. */
  16206. getColorGradients(): Nullable<Array<ColorGradient>>;
  16207. /**
  16208. * Gets the current list of size gradients.
  16209. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16210. * @returns the list of size gradients
  16211. */
  16212. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16213. /**
  16214. * Gets the current list of angular speed gradients.
  16215. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16216. * @returns the list of angular speed gradients
  16217. */
  16218. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16219. /**
  16220. * Adds a new angular speed gradient
  16221. * @param gradient defines the gradient to use (between 0 and 1)
  16222. * @param factor defines the angular speed to affect to the specified gradient
  16223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16224. * @returns the current particle system
  16225. */
  16226. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16227. /**
  16228. * Remove a specific angular speed gradient
  16229. * @param gradient defines the gradient to remove
  16230. * @returns the current particle system
  16231. */
  16232. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16233. /**
  16234. * Gets the current list of velocity gradients.
  16235. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16236. * @returns the list of velocity gradients
  16237. */
  16238. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16239. /**
  16240. * Adds a new velocity gradient
  16241. * @param gradient defines the gradient to use (between 0 and 1)
  16242. * @param factor defines the velocity to affect to the specified gradient
  16243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16244. * @returns the current particle system
  16245. */
  16246. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16247. /**
  16248. * Remove a specific velocity gradient
  16249. * @param gradient defines the gradient to remove
  16250. * @returns the current particle system
  16251. */
  16252. removeVelocityGradient(gradient: number): IParticleSystem;
  16253. /**
  16254. * Gets the current list of limit velocity gradients.
  16255. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16256. * @returns the list of limit velocity gradients
  16257. */
  16258. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16259. /**
  16260. * Adds a new limit velocity gradient
  16261. * @param gradient defines the gradient to use (between 0 and 1)
  16262. * @param factor defines the limit velocity to affect to the specified gradient
  16263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16264. * @returns the current particle system
  16265. */
  16266. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16267. /**
  16268. * Remove a specific limit velocity gradient
  16269. * @param gradient defines the gradient to remove
  16270. * @returns the current particle system
  16271. */
  16272. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16273. /**
  16274. * Adds a new drag gradient
  16275. * @param gradient defines the gradient to use (between 0 and 1)
  16276. * @param factor defines the drag to affect to the specified gradient
  16277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16278. * @returns the current particle system
  16279. */
  16280. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16281. /**
  16282. * Remove a specific drag gradient
  16283. * @param gradient defines the gradient to remove
  16284. * @returns the current particle system
  16285. */
  16286. removeDragGradient(gradient: number): IParticleSystem;
  16287. /**
  16288. * Gets the current list of drag gradients.
  16289. * You must use addDragGradient and removeDragGradient to udpate this list
  16290. * @returns the list of drag gradients
  16291. */
  16292. getDragGradients(): Nullable<Array<FactorGradient>>;
  16293. /**
  16294. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16295. * @param gradient defines the gradient to use (between 0 and 1)
  16296. * @param factor defines the emit rate to affect to the specified gradient
  16297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16298. * @returns the current particle system
  16299. */
  16300. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16301. /**
  16302. * Remove a specific emit rate gradient
  16303. * @param gradient defines the gradient to remove
  16304. * @returns the current particle system
  16305. */
  16306. removeEmitRateGradient(gradient: number): IParticleSystem;
  16307. /**
  16308. * Gets the current list of emit rate gradients.
  16309. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16310. * @returns the list of emit rate gradients
  16311. */
  16312. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16313. /**
  16314. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16315. * @param gradient defines the gradient to use (between 0 and 1)
  16316. * @param factor defines the start size to affect to the specified gradient
  16317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16318. * @returns the current particle system
  16319. */
  16320. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16321. /**
  16322. * Remove a specific start size gradient
  16323. * @param gradient defines the gradient to remove
  16324. * @returns the current particle system
  16325. */
  16326. removeStartSizeGradient(gradient: number): IParticleSystem;
  16327. /**
  16328. * Gets the current list of start size gradients.
  16329. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16330. * @returns the list of start size gradients
  16331. */
  16332. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16333. /**
  16334. * Adds a new life time gradient
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param factor defines the life time factor to affect to the specified gradient
  16337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16338. * @returns the current particle system
  16339. */
  16340. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16341. /**
  16342. * Remove a specific life time gradient
  16343. * @param gradient defines the gradient to remove
  16344. * @returns the current particle system
  16345. */
  16346. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16347. /**
  16348. * Gets the current list of life time gradients.
  16349. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16350. * @returns the list of life time gradients
  16351. */
  16352. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16353. /**
  16354. * Gets the current list of color gradients.
  16355. * You must use addColorGradient and removeColorGradient to udpate this list
  16356. * @returns the list of color gradients
  16357. */
  16358. getColorGradients(): Nullable<Array<ColorGradient>>;
  16359. /**
  16360. * Adds a new ramp gradient used to remap particle colors
  16361. * @param gradient defines the gradient to use (between 0 and 1)
  16362. * @param color defines the color to affect to the specified gradient
  16363. * @returns the current particle system
  16364. */
  16365. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16366. /**
  16367. * Gets the current list of ramp gradients.
  16368. * You must use addRampGradient and removeRampGradient to udpate this list
  16369. * @returns the list of ramp gradients
  16370. */
  16371. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16372. /** Gets or sets a boolean indicating that ramp gradients must be used
  16373. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16374. */
  16375. useRampGradients: boolean;
  16376. /**
  16377. * Adds a new color remap gradient
  16378. * @param gradient defines the gradient to use (between 0 and 1)
  16379. * @param min defines the color remap minimal range
  16380. * @param max defines the color remap maximal range
  16381. * @returns the current particle system
  16382. */
  16383. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16384. /**
  16385. * Gets the current list of color remap gradients.
  16386. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16387. * @returns the list of color remap gradients
  16388. */
  16389. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16390. /**
  16391. * Adds a new alpha remap gradient
  16392. * @param gradient defines the gradient to use (between 0 and 1)
  16393. * @param min defines the alpha remap minimal range
  16394. * @param max defines the alpha remap maximal range
  16395. * @returns the current particle system
  16396. */
  16397. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16398. /**
  16399. * Gets the current list of alpha remap gradients.
  16400. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16401. * @returns the list of alpha remap gradients
  16402. */
  16403. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16404. /**
  16405. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16408. * @returns the emitter
  16409. */
  16410. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16411. /**
  16412. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16413. * @param radius The radius of the hemisphere to emit from
  16414. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16415. * @returns the emitter
  16416. */
  16417. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16418. /**
  16419. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16420. * @param radius The radius of the sphere to emit from
  16421. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16422. * @returns the emitter
  16423. */
  16424. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16425. /**
  16426. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16427. * @param radius The radius of the sphere to emit from
  16428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16430. * @returns the emitter
  16431. */
  16432. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16433. /**
  16434. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16435. * @param radius The radius of the emission cylinder
  16436. * @param height The height of the emission cylinder
  16437. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16438. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16439. * @returns the emitter
  16440. */
  16441. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16442. /**
  16443. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16444. * @param radius The radius of the cylinder to emit from
  16445. * @param height The height of the emission cylinder
  16446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16449. * @returns the emitter
  16450. */
  16451. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16452. /**
  16453. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16454. * @param radius The radius of the cone to emit from
  16455. * @param angle The base angle of the cone
  16456. * @returns the emitter
  16457. */
  16458. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16459. /**
  16460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16465. * @returns the emitter
  16466. */
  16467. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16468. /**
  16469. * Get hosting scene
  16470. * @returns the scene
  16471. */
  16472. getScene(): Scene;
  16473. }
  16474. }
  16475. declare module BABYLON {
  16476. /**
  16477. * Creates an instance based on a source mesh.
  16478. */
  16479. export class InstancedMesh extends AbstractMesh {
  16480. private _sourceMesh;
  16481. private _currentLOD;
  16482. /** @hidden */
  16483. _indexInSourceMeshInstanceArray: number;
  16484. constructor(name: string, source: Mesh);
  16485. /**
  16486. * Returns the string "InstancedMesh".
  16487. */
  16488. getClassName(): string;
  16489. /**
  16490. * If the source mesh receives shadows
  16491. */
  16492. readonly receiveShadows: boolean;
  16493. /**
  16494. * The material of the source mesh
  16495. */
  16496. readonly material: Nullable<Material>;
  16497. /**
  16498. * Visibility of the source mesh
  16499. */
  16500. readonly visibility: number;
  16501. /**
  16502. * Skeleton of the source mesh
  16503. */
  16504. readonly skeleton: Nullable<Skeleton>;
  16505. /**
  16506. * Rendering ground id of the source mesh
  16507. */
  16508. renderingGroupId: number;
  16509. /**
  16510. * Returns the total number of vertices (integer).
  16511. */
  16512. getTotalVertices(): number;
  16513. /**
  16514. * Returns a positive integer : the total number of indices in this mesh geometry.
  16515. * @returns the numner of indices or zero if the mesh has no geometry.
  16516. */
  16517. getTotalIndices(): number;
  16518. /**
  16519. * The source mesh of the instance
  16520. */
  16521. readonly sourceMesh: Mesh;
  16522. /**
  16523. * Is this node ready to be used/rendered
  16524. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16525. * @return {boolean} is it ready
  16526. */
  16527. isReady(completeCheck?: boolean): boolean;
  16528. /**
  16529. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16530. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16531. * @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.
  16532. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16533. */
  16534. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16535. /**
  16536. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16537. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16538. * The `data` are either a numeric array either a Float32Array.
  16539. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16540. * 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).
  16541. * Note that a new underlying VertexBuffer object is created each call.
  16542. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16543. *
  16544. * Possible `kind` values :
  16545. * - VertexBuffer.PositionKind
  16546. * - VertexBuffer.UVKind
  16547. * - VertexBuffer.UV2Kind
  16548. * - VertexBuffer.UV3Kind
  16549. * - VertexBuffer.UV4Kind
  16550. * - VertexBuffer.UV5Kind
  16551. * - VertexBuffer.UV6Kind
  16552. * - VertexBuffer.ColorKind
  16553. * - VertexBuffer.MatricesIndicesKind
  16554. * - VertexBuffer.MatricesIndicesExtraKind
  16555. * - VertexBuffer.MatricesWeightsKind
  16556. * - VertexBuffer.MatricesWeightsExtraKind
  16557. *
  16558. * Returns the Mesh.
  16559. */
  16560. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16561. /**
  16562. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16563. * If the mesh has no geometry, it is simply returned as it is.
  16564. * The `data` are either a numeric array either a Float32Array.
  16565. * No new underlying VertexBuffer object is created.
  16566. * 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.
  16567. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16568. *
  16569. * Possible `kind` values :
  16570. * - VertexBuffer.PositionKind
  16571. * - VertexBuffer.UVKind
  16572. * - VertexBuffer.UV2Kind
  16573. * - VertexBuffer.UV3Kind
  16574. * - VertexBuffer.UV4Kind
  16575. * - VertexBuffer.UV5Kind
  16576. * - VertexBuffer.UV6Kind
  16577. * - VertexBuffer.ColorKind
  16578. * - VertexBuffer.MatricesIndicesKind
  16579. * - VertexBuffer.MatricesIndicesExtraKind
  16580. * - VertexBuffer.MatricesWeightsKind
  16581. * - VertexBuffer.MatricesWeightsExtraKind
  16582. *
  16583. * Returns the Mesh.
  16584. */
  16585. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16586. /**
  16587. * Sets the mesh indices.
  16588. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16589. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16590. * This method creates a new index buffer each call.
  16591. * Returns the Mesh.
  16592. */
  16593. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16594. /**
  16595. * Boolean : True if the mesh owns the requested kind of data.
  16596. */
  16597. isVerticesDataPresent(kind: string): boolean;
  16598. /**
  16599. * Returns an array of indices (IndicesArray).
  16600. */
  16601. getIndices(): Nullable<IndicesArray>;
  16602. readonly _positions: Nullable<Vector3[]>;
  16603. /**
  16604. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16605. * This means the mesh underlying bounding box and sphere are recomputed.
  16606. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16607. * @returns the current mesh
  16608. */
  16609. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16610. /** @hidden */
  16611. _preActivate(): InstancedMesh;
  16612. /** @hidden */
  16613. _activate(renderId: number): InstancedMesh;
  16614. /**
  16615. * Returns the current associated LOD AbstractMesh.
  16616. */
  16617. getLOD(camera: Camera): AbstractMesh;
  16618. /** @hidden */
  16619. _syncSubMeshes(): InstancedMesh;
  16620. /** @hidden */
  16621. _generatePointsArray(): boolean;
  16622. /**
  16623. * Creates a new InstancedMesh from the current mesh.
  16624. * - name (string) : the cloned mesh name
  16625. * - newParent (optional Node) : the optional Node to parent the clone to.
  16626. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16627. *
  16628. * Returns the clone.
  16629. */
  16630. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16631. /**
  16632. * Disposes the InstancedMesh.
  16633. * Returns nothing.
  16634. */
  16635. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16636. }
  16637. }
  16638. declare module BABYLON {
  16639. /**
  16640. * Defines the options associated with the creation of a shader material.
  16641. */
  16642. export interface IShaderMaterialOptions {
  16643. /**
  16644. * Does the material work in alpha blend mode
  16645. */
  16646. needAlphaBlending: boolean;
  16647. /**
  16648. * Does the material work in alpha test mode
  16649. */
  16650. needAlphaTesting: boolean;
  16651. /**
  16652. * The list of attribute names used in the shader
  16653. */
  16654. attributes: string[];
  16655. /**
  16656. * The list of unifrom names used in the shader
  16657. */
  16658. uniforms: string[];
  16659. /**
  16660. * The list of UBO names used in the shader
  16661. */
  16662. uniformBuffers: string[];
  16663. /**
  16664. * The list of sampler names used in the shader
  16665. */
  16666. samplers: string[];
  16667. /**
  16668. * The list of defines used in the shader
  16669. */
  16670. defines: string[];
  16671. }
  16672. /**
  16673. * 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.
  16674. *
  16675. * This returned material effects how the mesh will look based on the code in the shaders.
  16676. *
  16677. * @see http://doc.babylonjs.com/how_to/shader_material
  16678. */
  16679. export class ShaderMaterial extends Material {
  16680. private _shaderPath;
  16681. private _options;
  16682. private _textures;
  16683. private _textureArrays;
  16684. private _floats;
  16685. private _ints;
  16686. private _floatsArrays;
  16687. private _colors3;
  16688. private _colors3Arrays;
  16689. private _colors4;
  16690. private _vectors2;
  16691. private _vectors3;
  16692. private _vectors4;
  16693. private _matrices;
  16694. private _matrices3x3;
  16695. private _matrices2x2;
  16696. private _vectors2Arrays;
  16697. private _vectors3Arrays;
  16698. private _cachedWorldViewMatrix;
  16699. private _renderId;
  16700. /**
  16701. * Instantiate a new shader material.
  16702. * 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.
  16703. * This returned material effects how the mesh will look based on the code in the shaders.
  16704. * @see http://doc.babylonjs.com/how_to/shader_material
  16705. * @param name Define the name of the material in the scene
  16706. * @param scene Define the scene the material belongs to
  16707. * @param shaderPath Defines the route to the shader code in one of three ways:
  16708. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16709. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16710. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16711. * @param options Define the options used to create the shader
  16712. */
  16713. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16714. /**
  16715. * Gets the options used to compile the shader.
  16716. * They can be modified to trigger a new compilation
  16717. */
  16718. readonly options: IShaderMaterialOptions;
  16719. /**
  16720. * Gets the current class name of the material e.g. "ShaderMaterial"
  16721. * Mainly use in serialization.
  16722. * @returns the class name
  16723. */
  16724. getClassName(): string;
  16725. /**
  16726. * Specifies if the material will require alpha blending
  16727. * @returns a boolean specifying if alpha blending is needed
  16728. */
  16729. needAlphaBlending(): boolean;
  16730. /**
  16731. * Specifies if this material should be rendered in alpha test mode
  16732. * @returns a boolean specifying if an alpha test is needed.
  16733. */
  16734. needAlphaTesting(): boolean;
  16735. private _checkUniform;
  16736. /**
  16737. * Set a texture in the shader.
  16738. * @param name Define the name of the uniform samplers as defined in the shader
  16739. * @param texture Define the texture to bind to this sampler
  16740. * @return the material itself allowing "fluent" like uniform updates
  16741. */
  16742. setTexture(name: string, texture: Texture): ShaderMaterial;
  16743. /**
  16744. * Set a texture array in the shader.
  16745. * @param name Define the name of the uniform sampler array as defined in the shader
  16746. * @param textures Define the list of textures to bind to this sampler
  16747. * @return the material itself allowing "fluent" like uniform updates
  16748. */
  16749. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16750. /**
  16751. * Set a float in the shader.
  16752. * @param name Define the name of the uniform as defined in the shader
  16753. * @param value Define the value to give to the uniform
  16754. * @return the material itself allowing "fluent" like uniform updates
  16755. */
  16756. setFloat(name: string, value: number): ShaderMaterial;
  16757. /**
  16758. * Set a int in the shader.
  16759. * @param name Define the name of the uniform as defined in the shader
  16760. * @param value Define the value to give to the uniform
  16761. * @return the material itself allowing "fluent" like uniform updates
  16762. */
  16763. setInt(name: string, value: number): ShaderMaterial;
  16764. /**
  16765. * Set an array of floats in the shader.
  16766. * @param name Define the name of the uniform as defined in the shader
  16767. * @param value Define the value to give to the uniform
  16768. * @return the material itself allowing "fluent" like uniform updates
  16769. */
  16770. setFloats(name: string, value: number[]): ShaderMaterial;
  16771. /**
  16772. * Set a vec3 in the shader from a Color3.
  16773. * @param name Define the name of the uniform as defined in the shader
  16774. * @param value Define the value to give to the uniform
  16775. * @return the material itself allowing "fluent" like uniform updates
  16776. */
  16777. setColor3(name: string, value: Color3): ShaderMaterial;
  16778. /**
  16779. * Set a vec3 array in the shader from a Color3 array.
  16780. * @param name Define the name of the uniform as defined in the shader
  16781. * @param value Define the value to give to the uniform
  16782. * @return the material itself allowing "fluent" like uniform updates
  16783. */
  16784. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16785. /**
  16786. * Set a vec4 in the shader from a Color4.
  16787. * @param name Define the name of the uniform as defined in the shader
  16788. * @param value Define the value to give to the uniform
  16789. * @return the material itself allowing "fluent" like uniform updates
  16790. */
  16791. setColor4(name: string, value: Color4): ShaderMaterial;
  16792. /**
  16793. * Set a vec2 in the shader from a Vector2.
  16794. * @param name Define the name of the uniform as defined in the shader
  16795. * @param value Define the value to give to the uniform
  16796. * @return the material itself allowing "fluent" like uniform updates
  16797. */
  16798. setVector2(name: string, value: Vector2): ShaderMaterial;
  16799. /**
  16800. * Set a vec3 in the shader from a Vector3.
  16801. * @param name Define the name of the uniform as defined in the shader
  16802. * @param value Define the value to give to the uniform
  16803. * @return the material itself allowing "fluent" like uniform updates
  16804. */
  16805. setVector3(name: string, value: Vector3): ShaderMaterial;
  16806. /**
  16807. * Set a vec4 in the shader from a Vector4.
  16808. * @param name Define the name of the uniform as defined in the shader
  16809. * @param value Define the value to give to the uniform
  16810. * @return the material itself allowing "fluent" like uniform updates
  16811. */
  16812. setVector4(name: string, value: Vector4): ShaderMaterial;
  16813. /**
  16814. * Set a mat4 in the shader from a Matrix.
  16815. * @param name Define the name of the uniform as defined in the shader
  16816. * @param value Define the value to give to the uniform
  16817. * @return the material itself allowing "fluent" like uniform updates
  16818. */
  16819. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16820. /**
  16821. * Set a mat3 in the shader from a Float32Array.
  16822. * @param name Define the name of the uniform as defined in the shader
  16823. * @param value Define the value to give to the uniform
  16824. * @return the material itself allowing "fluent" like uniform updates
  16825. */
  16826. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16827. /**
  16828. * Set a mat2 in the shader from a Float32Array.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the material itself allowing "fluent" like uniform updates
  16832. */
  16833. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16834. /**
  16835. * Set a vec2 array in the shader from a number array.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the material itself allowing "fluent" like uniform updates
  16839. */
  16840. setArray2(name: string, value: number[]): ShaderMaterial;
  16841. /**
  16842. * Set a vec3 array in the shader from a number array.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the material itself allowing "fluent" like uniform updates
  16846. */
  16847. setArray3(name: string, value: number[]): ShaderMaterial;
  16848. private _checkCache;
  16849. /**
  16850. * Specifies that the submesh is ready to be used
  16851. * @param mesh defines the mesh to check
  16852. * @param subMesh defines which submesh to check
  16853. * @param useInstances specifies that instances should be used
  16854. * @returns a boolean indicating that the submesh is ready or not
  16855. */
  16856. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16857. /**
  16858. * Checks if the material is ready to render the requested mesh
  16859. * @param mesh Define the mesh to render
  16860. * @param useInstances Define whether or not the material is used with instances
  16861. * @returns true if ready, otherwise false
  16862. */
  16863. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16864. /**
  16865. * Binds the world matrix to the material
  16866. * @param world defines the world transformation matrix
  16867. */
  16868. bindOnlyWorldMatrix(world: Matrix): void;
  16869. /**
  16870. * Binds the material to the mesh
  16871. * @param world defines the world transformation matrix
  16872. * @param mesh defines the mesh to bind the material to
  16873. */
  16874. bind(world: Matrix, mesh?: Mesh): void;
  16875. /**
  16876. * Gets the active textures from the material
  16877. * @returns an array of textures
  16878. */
  16879. getActiveTextures(): BaseTexture[];
  16880. /**
  16881. * Specifies if the material uses a texture
  16882. * @param texture defines the texture to check against the material
  16883. * @returns a boolean specifying if the material uses the texture
  16884. */
  16885. hasTexture(texture: BaseTexture): boolean;
  16886. /**
  16887. * Makes a duplicate of the material, and gives it a new name
  16888. * @param name defines the new name for the duplicated material
  16889. * @returns the cloned material
  16890. */
  16891. clone(name: string): ShaderMaterial;
  16892. /**
  16893. * Disposes the material
  16894. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16895. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16896. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16897. */
  16898. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16899. /**
  16900. * Serializes this material in a JSON representation
  16901. * @returns the serialized material object
  16902. */
  16903. serialize(): any;
  16904. /**
  16905. * Creates a shader material from parsed shader material data
  16906. * @param source defines the JSON represnetation of the material
  16907. * @param scene defines the hosting scene
  16908. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16909. * @returns a new material
  16910. */
  16911. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /** @hidden */
  16916. export var colorPixelShader: {
  16917. name: string;
  16918. shader: string;
  16919. };
  16920. }
  16921. declare module BABYLON {
  16922. /** @hidden */
  16923. export var colorVertexShader: {
  16924. name: string;
  16925. shader: string;
  16926. };
  16927. }
  16928. declare module BABYLON {
  16929. /**
  16930. * Line mesh
  16931. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16932. */
  16933. export class LinesMesh extends Mesh {
  16934. /**
  16935. * If vertex color should be applied to the mesh
  16936. */
  16937. useVertexColor?: boolean | undefined;
  16938. /**
  16939. * If vertex alpha should be applied to the mesh
  16940. */
  16941. useVertexAlpha?: boolean | undefined;
  16942. /**
  16943. * Color of the line (Default: White)
  16944. */
  16945. color: Color3;
  16946. /**
  16947. * Alpha of the line (Default: 1)
  16948. */
  16949. alpha: number;
  16950. /**
  16951. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16952. * This margin is expressed in world space coordinates, so its value may vary.
  16953. * Default value is 0.1
  16954. */
  16955. intersectionThreshold: number;
  16956. private _colorShader;
  16957. /**
  16958. * Creates a new LinesMesh
  16959. * @param name defines the name
  16960. * @param scene defines the hosting scene
  16961. * @param parent defines the parent mesh if any
  16962. * @param source defines the optional source LinesMesh used to clone data from
  16963. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16964. * When false, achieved by calling a clone(), also passing False.
  16965. * This will make creation of children, recursive.
  16966. * @param useVertexColor defines if this LinesMesh supports vertex color
  16967. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16968. */
  16969. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16970. /**
  16971. * If vertex color should be applied to the mesh
  16972. */
  16973. useVertexColor?: boolean | undefined,
  16974. /**
  16975. * If vertex alpha should be applied to the mesh
  16976. */
  16977. useVertexAlpha?: boolean | undefined);
  16978. private _addClipPlaneDefine;
  16979. private _removeClipPlaneDefine;
  16980. isReady(): boolean;
  16981. /**
  16982. * Returns the string "LineMesh"
  16983. */
  16984. getClassName(): string;
  16985. /**
  16986. * @hidden
  16987. */
  16988. /**
  16989. * @hidden
  16990. */
  16991. material: Material;
  16992. /**
  16993. * @hidden
  16994. */
  16995. readonly checkCollisions: boolean;
  16996. /** @hidden */
  16997. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16998. /** @hidden */
  16999. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17000. /**
  17001. * Disposes of the line mesh
  17002. * @param doNotRecurse If children should be disposed
  17003. */
  17004. dispose(doNotRecurse?: boolean): void;
  17005. /**
  17006. * Returns a new LineMesh object cloned from the current one.
  17007. */
  17008. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17009. /**
  17010. * Creates a new InstancedLinesMesh object from the mesh model.
  17011. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17012. * @param name defines the name of the new instance
  17013. * @returns a new InstancedLinesMesh
  17014. */
  17015. createInstance(name: string): InstancedLinesMesh;
  17016. }
  17017. /**
  17018. * Creates an instance based on a source LinesMesh
  17019. */
  17020. export class InstancedLinesMesh extends InstancedMesh {
  17021. /**
  17022. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17023. * This margin is expressed in world space coordinates, so its value may vary.
  17024. * Initilized with the intersectionThreshold value of the source LinesMesh
  17025. */
  17026. intersectionThreshold: number;
  17027. constructor(name: string, source: LinesMesh);
  17028. /**
  17029. * Returns the string "InstancedLinesMesh".
  17030. */
  17031. getClassName(): string;
  17032. }
  17033. }
  17034. declare module BABYLON {
  17035. /** @hidden */
  17036. export var linePixelShader: {
  17037. name: string;
  17038. shader: string;
  17039. };
  17040. }
  17041. declare module BABYLON {
  17042. /** @hidden */
  17043. export var lineVertexShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module BABYLON {
  17049. interface AbstractMesh {
  17050. /**
  17051. * Disables the mesh edge rendering mode
  17052. * @returns the currentAbstractMesh
  17053. */
  17054. disableEdgesRendering(): AbstractMesh;
  17055. /**
  17056. * Enables the edge rendering mode on the mesh.
  17057. * This mode makes the mesh edges visible
  17058. * @param epsilon defines the maximal distance between two angles to detect a face
  17059. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17060. * @returns the currentAbstractMesh
  17061. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17062. */
  17063. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17064. /**
  17065. * Gets the edgesRenderer associated with the mesh
  17066. */
  17067. edgesRenderer: Nullable<EdgesRenderer>;
  17068. }
  17069. interface LinesMesh {
  17070. /**
  17071. * Enables the edge rendering mode on the mesh.
  17072. * This mode makes the mesh edges visible
  17073. * @param epsilon defines the maximal distance between two angles to detect a face
  17074. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17075. * @returns the currentAbstractMesh
  17076. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17077. */
  17078. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17079. }
  17080. interface InstancedLinesMesh {
  17081. /**
  17082. * Enables the edge rendering mode on the mesh.
  17083. * This mode makes the mesh edges visible
  17084. * @param epsilon defines the maximal distance between two angles to detect a face
  17085. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17086. * @returns the current InstancedLinesMesh
  17087. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17088. */
  17089. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17090. }
  17091. /**
  17092. * Defines the minimum contract an Edges renderer should follow.
  17093. */
  17094. export interface IEdgesRenderer extends IDisposable {
  17095. /**
  17096. * Gets or sets a boolean indicating if the edgesRenderer is active
  17097. */
  17098. isEnabled: boolean;
  17099. /**
  17100. * Renders the edges of the attached mesh,
  17101. */
  17102. render(): void;
  17103. /**
  17104. * Checks wether or not the edges renderer is ready to render.
  17105. * @return true if ready, otherwise false.
  17106. */
  17107. isReady(): boolean;
  17108. }
  17109. /**
  17110. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17111. */
  17112. export class EdgesRenderer implements IEdgesRenderer {
  17113. /**
  17114. * Define the size of the edges with an orthographic camera
  17115. */
  17116. edgesWidthScalerForOrthographic: number;
  17117. /**
  17118. * Define the size of the edges with a perspective camera
  17119. */
  17120. edgesWidthScalerForPerspective: number;
  17121. protected _source: AbstractMesh;
  17122. protected _linesPositions: number[];
  17123. protected _linesNormals: number[];
  17124. protected _linesIndices: number[];
  17125. protected _epsilon: number;
  17126. protected _indicesCount: number;
  17127. protected _lineShader: ShaderMaterial;
  17128. protected _ib: WebGLBuffer;
  17129. protected _buffers: {
  17130. [key: string]: Nullable<VertexBuffer>;
  17131. };
  17132. protected _checkVerticesInsteadOfIndices: boolean;
  17133. private _meshRebuildObserver;
  17134. private _meshDisposeObserver;
  17135. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17136. isEnabled: boolean;
  17137. /**
  17138. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17139. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17140. * @param source Mesh used to create edges
  17141. * @param epsilon sum of angles in adjacency to check for edge
  17142. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17143. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17144. */
  17145. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17146. protected _prepareRessources(): void;
  17147. /** @hidden */
  17148. _rebuild(): void;
  17149. /**
  17150. * Releases the required resources for the edges renderer
  17151. */
  17152. dispose(): void;
  17153. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17154. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17155. /**
  17156. * Checks if the pair of p0 and p1 is en edge
  17157. * @param faceIndex
  17158. * @param edge
  17159. * @param faceNormals
  17160. * @param p0
  17161. * @param p1
  17162. * @private
  17163. */
  17164. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17165. /**
  17166. * push line into the position, normal and index buffer
  17167. * @protected
  17168. */
  17169. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17170. /**
  17171. * Generates lines edges from adjacencjes
  17172. * @private
  17173. */
  17174. _generateEdgesLines(): void;
  17175. /**
  17176. * Checks wether or not the edges renderer is ready to render.
  17177. * @return true if ready, otherwise false.
  17178. */
  17179. isReady(): boolean;
  17180. /**
  17181. * Renders the edges of the attached mesh,
  17182. */
  17183. render(): void;
  17184. }
  17185. /**
  17186. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17187. */
  17188. export class LineEdgesRenderer extends EdgesRenderer {
  17189. /**
  17190. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17191. * @param source LineMesh used to generate edges
  17192. * @param epsilon not important (specified angle for edge detection)
  17193. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17194. */
  17195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17196. /**
  17197. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17198. */
  17199. _generateEdgesLines(): void;
  17200. }
  17201. }
  17202. declare module BABYLON {
  17203. /**
  17204. * This represents the object necessary to create a rendering group.
  17205. * This is exclusively used and created by the rendering manager.
  17206. * To modify the behavior, you use the available helpers in your scene or meshes.
  17207. * @hidden
  17208. */
  17209. export class RenderingGroup {
  17210. index: number;
  17211. private _scene;
  17212. private _opaqueSubMeshes;
  17213. private _transparentSubMeshes;
  17214. private _alphaTestSubMeshes;
  17215. private _depthOnlySubMeshes;
  17216. private _particleSystems;
  17217. private _spriteManagers;
  17218. private _opaqueSortCompareFn;
  17219. private _alphaTestSortCompareFn;
  17220. private _transparentSortCompareFn;
  17221. private _renderOpaque;
  17222. private _renderAlphaTest;
  17223. private _renderTransparent;
  17224. private _edgesRenderers;
  17225. onBeforeTransparentRendering: () => void;
  17226. /**
  17227. * Set the opaque sort comparison function.
  17228. * If null the sub meshes will be render in the order they were created
  17229. */
  17230. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17231. /**
  17232. * Set the alpha test sort comparison function.
  17233. * If null the sub meshes will be render in the order they were created
  17234. */
  17235. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17236. /**
  17237. * Set the transparent sort comparison function.
  17238. * If null the sub meshes will be render in the order they were created
  17239. */
  17240. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17241. /**
  17242. * Creates a new rendering group.
  17243. * @param index The rendering group index
  17244. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17245. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17246. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17247. */
  17248. 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>);
  17249. /**
  17250. * Render all the sub meshes contained in the group.
  17251. * @param customRenderFunction Used to override the default render behaviour of the group.
  17252. * @returns true if rendered some submeshes.
  17253. */
  17254. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17255. /**
  17256. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17257. * @param subMeshes The submeshes to render
  17258. */
  17259. private renderOpaqueSorted;
  17260. /**
  17261. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17262. * @param subMeshes The submeshes to render
  17263. */
  17264. private renderAlphaTestSorted;
  17265. /**
  17266. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17267. * @param subMeshes The submeshes to render
  17268. */
  17269. private renderTransparentSorted;
  17270. /**
  17271. * Renders the submeshes in a specified order.
  17272. * @param subMeshes The submeshes to sort before render
  17273. * @param sortCompareFn The comparison function use to sort
  17274. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17275. * @param transparent Specifies to activate blending if true
  17276. */
  17277. private static renderSorted;
  17278. /**
  17279. * Renders the submeshes in the order they were dispatched (no sort applied).
  17280. * @param subMeshes The submeshes to render
  17281. */
  17282. private static renderUnsorted;
  17283. /**
  17284. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17285. * are rendered back to front if in the same alpha index.
  17286. *
  17287. * @param a The first submesh
  17288. * @param b The second submesh
  17289. * @returns The result of the comparison
  17290. */
  17291. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17292. /**
  17293. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17294. * are rendered back to front.
  17295. *
  17296. * @param a The first submesh
  17297. * @param b The second submesh
  17298. * @returns The result of the comparison
  17299. */
  17300. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17301. /**
  17302. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17303. * are rendered front to back (prevent overdraw).
  17304. *
  17305. * @param a The first submesh
  17306. * @param b The second submesh
  17307. * @returns The result of the comparison
  17308. */
  17309. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17310. /**
  17311. * Resets the different lists of submeshes to prepare a new frame.
  17312. */
  17313. prepare(): void;
  17314. dispose(): void;
  17315. /**
  17316. * Inserts the submesh in its correct queue depending on its material.
  17317. * @param subMesh The submesh to dispatch
  17318. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17319. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17320. */
  17321. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17322. dispatchSprites(spriteManager: ISpriteManager): void;
  17323. dispatchParticles(particleSystem: IParticleSystem): void;
  17324. private _renderParticles;
  17325. private _renderSprites;
  17326. }
  17327. }
  17328. declare module BABYLON {
  17329. /**
  17330. * Interface describing the different options available in the rendering manager
  17331. * regarding Auto Clear between groups.
  17332. */
  17333. export interface IRenderingManagerAutoClearSetup {
  17334. /**
  17335. * Defines whether or not autoclear is enable.
  17336. */
  17337. autoClear: boolean;
  17338. /**
  17339. * Defines whether or not to autoclear the depth buffer.
  17340. */
  17341. depth: boolean;
  17342. /**
  17343. * Defines whether or not to autoclear the stencil buffer.
  17344. */
  17345. stencil: boolean;
  17346. }
  17347. /**
  17348. * This class is used by the onRenderingGroupObservable
  17349. */
  17350. export class RenderingGroupInfo {
  17351. /**
  17352. * The Scene that being rendered
  17353. */
  17354. scene: Scene;
  17355. /**
  17356. * The camera currently used for the rendering pass
  17357. */
  17358. camera: Nullable<Camera>;
  17359. /**
  17360. * The ID of the renderingGroup being processed
  17361. */
  17362. renderingGroupId: number;
  17363. }
  17364. /**
  17365. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17366. * It is enable to manage the different groups as well as the different necessary sort functions.
  17367. * This should not be used directly aside of the few static configurations
  17368. */
  17369. export class RenderingManager {
  17370. /**
  17371. * The max id used for rendering groups (not included)
  17372. */
  17373. static MAX_RENDERINGGROUPS: number;
  17374. /**
  17375. * The min id used for rendering groups (included)
  17376. */
  17377. static MIN_RENDERINGGROUPS: number;
  17378. /**
  17379. * Used to globally prevent autoclearing scenes.
  17380. */
  17381. static AUTOCLEAR: boolean;
  17382. /**
  17383. * @hidden
  17384. */
  17385. _useSceneAutoClearSetup: boolean;
  17386. private _scene;
  17387. private _renderingGroups;
  17388. private _depthStencilBufferAlreadyCleaned;
  17389. private _autoClearDepthStencil;
  17390. private _customOpaqueSortCompareFn;
  17391. private _customAlphaTestSortCompareFn;
  17392. private _customTransparentSortCompareFn;
  17393. private _renderingGroupInfo;
  17394. /**
  17395. * Instantiates a new rendering group for a particular scene
  17396. * @param scene Defines the scene the groups belongs to
  17397. */
  17398. constructor(scene: Scene);
  17399. private _clearDepthStencilBuffer;
  17400. /**
  17401. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17402. * @hidden
  17403. */
  17404. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17405. /**
  17406. * Resets the different information of the group to prepare a new frame
  17407. * @hidden
  17408. */
  17409. reset(): void;
  17410. /**
  17411. * Dispose and release the group and its associated resources.
  17412. * @hidden
  17413. */
  17414. dispose(): void;
  17415. /**
  17416. * Clear the info related to rendering groups preventing retention points during dispose.
  17417. */
  17418. freeRenderingGroups(): void;
  17419. private _prepareRenderingGroup;
  17420. /**
  17421. * Add a sprite manager to the rendering manager in order to render it this frame.
  17422. * @param spriteManager Define the sprite manager to render
  17423. */
  17424. dispatchSprites(spriteManager: ISpriteManager): void;
  17425. /**
  17426. * Add a particle system to the rendering manager in order to render it this frame.
  17427. * @param particleSystem Define the particle system to render
  17428. */
  17429. dispatchParticles(particleSystem: IParticleSystem): void;
  17430. /**
  17431. * Add a submesh to the manager in order to render it this frame
  17432. * @param subMesh The submesh to dispatch
  17433. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17434. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17435. */
  17436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17437. /**
  17438. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17439. * This allowed control for front to back rendering or reversly depending of the special needs.
  17440. *
  17441. * @param renderingGroupId The rendering group id corresponding to its index
  17442. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17443. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17444. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17445. */
  17446. 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;
  17447. /**
  17448. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17449. *
  17450. * @param renderingGroupId The rendering group id corresponding to its index
  17451. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17452. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17453. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17454. */
  17455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17456. /**
  17457. * Gets the current auto clear configuration for one rendering group of the rendering
  17458. * manager.
  17459. * @param index the rendering group index to get the information for
  17460. * @returns The auto clear setup for the requested rendering group
  17461. */
  17462. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17463. }
  17464. }
  17465. declare module BABYLON {
  17466. /**
  17467. * This Helps creating a texture that will be created from a camera in your scene.
  17468. * It is basically a dynamic texture that could be used to create special effects for instance.
  17469. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17470. */
  17471. export class RenderTargetTexture extends Texture {
  17472. isCube: boolean;
  17473. /**
  17474. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17475. */
  17476. static readonly REFRESHRATE_RENDER_ONCE: number;
  17477. /**
  17478. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17479. */
  17480. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17481. /**
  17482. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17483. * the central point of your effect and can save a lot of performances.
  17484. */
  17485. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17486. /**
  17487. * Use this predicate to dynamically define the list of mesh you want to render.
  17488. * If set, the renderList property will be overwritten.
  17489. */
  17490. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17491. private _renderList;
  17492. /**
  17493. * Use this list to define the list of mesh you want to render.
  17494. */
  17495. renderList: Nullable<Array<AbstractMesh>>;
  17496. private _hookArray;
  17497. /**
  17498. * Define if particles should be rendered in your texture.
  17499. */
  17500. renderParticles: boolean;
  17501. /**
  17502. * Define if sprites should be rendered in your texture.
  17503. */
  17504. renderSprites: boolean;
  17505. /**
  17506. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17507. */
  17508. coordinatesMode: number;
  17509. /**
  17510. * Define the camera used to render the texture.
  17511. */
  17512. activeCamera: Nullable<Camera>;
  17513. /**
  17514. * Override the render function of the texture with your own one.
  17515. */
  17516. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17517. /**
  17518. * Define if camera post processes should be use while rendering the texture.
  17519. */
  17520. useCameraPostProcesses: boolean;
  17521. /**
  17522. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17523. */
  17524. ignoreCameraViewport: boolean;
  17525. private _postProcessManager;
  17526. private _postProcesses;
  17527. private _resizeObserver;
  17528. /**
  17529. * An event triggered when the texture is unbind.
  17530. */
  17531. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17532. /**
  17533. * An event triggered when the texture is unbind.
  17534. */
  17535. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17536. private _onAfterUnbindObserver;
  17537. /**
  17538. * Set a after unbind callback in the texture.
  17539. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17540. */
  17541. onAfterUnbind: () => void;
  17542. /**
  17543. * An event triggered before rendering the texture
  17544. */
  17545. onBeforeRenderObservable: Observable<number>;
  17546. private _onBeforeRenderObserver;
  17547. /**
  17548. * Set a before render callback in the texture.
  17549. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17550. */
  17551. onBeforeRender: (faceIndex: number) => void;
  17552. /**
  17553. * An event triggered after rendering the texture
  17554. */
  17555. onAfterRenderObservable: Observable<number>;
  17556. private _onAfterRenderObserver;
  17557. /**
  17558. * Set a after render callback in the texture.
  17559. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17560. */
  17561. onAfterRender: (faceIndex: number) => void;
  17562. /**
  17563. * An event triggered after the texture clear
  17564. */
  17565. onClearObservable: Observable<Engine>;
  17566. private _onClearObserver;
  17567. /**
  17568. * Set a clear callback in the texture.
  17569. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17570. */
  17571. onClear: (Engine: Engine) => void;
  17572. /**
  17573. * Define the clear color of the Render Target if it should be different from the scene.
  17574. */
  17575. clearColor: Color4;
  17576. protected _size: number | {
  17577. width: number;
  17578. height: number;
  17579. };
  17580. protected _initialSizeParameter: number | {
  17581. width: number;
  17582. height: number;
  17583. } | {
  17584. ratio: number;
  17585. };
  17586. protected _sizeRatio: Nullable<number>;
  17587. /** @hidden */
  17588. _generateMipMaps: boolean;
  17589. protected _renderingManager: RenderingManager;
  17590. /** @hidden */
  17591. _waitingRenderList: string[];
  17592. protected _doNotChangeAspectRatio: boolean;
  17593. protected _currentRefreshId: number;
  17594. protected _refreshRate: number;
  17595. protected _textureMatrix: Matrix;
  17596. protected _samples: number;
  17597. protected _renderTargetOptions: RenderTargetCreationOptions;
  17598. /**
  17599. * Gets render target creation options that were used.
  17600. */
  17601. readonly renderTargetOptions: RenderTargetCreationOptions;
  17602. protected _engine: Engine;
  17603. protected _onRatioRescale(): void;
  17604. /**
  17605. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17606. * It must define where the camera used to render the texture is set
  17607. */
  17608. boundingBoxPosition: Vector3;
  17609. private _boundingBoxSize;
  17610. /**
  17611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17612. * When defined, the cubemap will switch to local mode
  17613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17614. * @example https://www.babylonjs-playground.com/#RNASML
  17615. */
  17616. boundingBoxSize: Vector3;
  17617. /**
  17618. * In case the RTT has been created with a depth texture, get the associated
  17619. * depth texture.
  17620. * Otherwise, return null.
  17621. */
  17622. depthStencilTexture: Nullable<InternalTexture>;
  17623. /**
  17624. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17625. * or used a shadow, depth texture...
  17626. * @param name The friendly name of the texture
  17627. * @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)
  17628. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17629. * @param generateMipMaps True if mip maps need to be generated after render.
  17630. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17631. * @param type The type of the buffer in the RTT (int, half float, float...)
  17632. * @param isCube True if a cube texture needs to be created
  17633. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17634. * @param generateDepthBuffer True to generate a depth buffer
  17635. * @param generateStencilBuffer True to generate a stencil buffer
  17636. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17637. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17638. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17639. */
  17640. constructor(name: string, size: number | {
  17641. width: number;
  17642. height: number;
  17643. } | {
  17644. ratio: number;
  17645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17646. /**
  17647. * Creates a depth stencil texture.
  17648. * This is only available in WebGL 2 or with the depth texture extension available.
  17649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17652. */
  17653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17654. private _processSizeParameter;
  17655. /**
  17656. * Define the number of samples to use in case of MSAA.
  17657. * It defaults to one meaning no MSAA has been enabled.
  17658. */
  17659. samples: number;
  17660. /**
  17661. * Resets the refresh counter of the texture and start bak from scratch.
  17662. * Could be useful to regenerate the texture if it is setup to render only once.
  17663. */
  17664. resetRefreshCounter(): void;
  17665. /**
  17666. * Define the refresh rate of the texture or the rendering frequency.
  17667. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17668. */
  17669. refreshRate: number;
  17670. /**
  17671. * Adds a post process to the render target rendering passes.
  17672. * @param postProcess define the post process to add
  17673. */
  17674. addPostProcess(postProcess: PostProcess): void;
  17675. /**
  17676. * Clear all the post processes attached to the render target
  17677. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17678. */
  17679. clearPostProcesses(dispose?: boolean): void;
  17680. /**
  17681. * Remove one of the post process from the list of attached post processes to the texture
  17682. * @param postProcess define the post process to remove from the list
  17683. */
  17684. removePostProcess(postProcess: PostProcess): void;
  17685. /** @hidden */
  17686. _shouldRender(): boolean;
  17687. /**
  17688. * Gets the actual render size of the texture.
  17689. * @returns the width of the render size
  17690. */
  17691. getRenderSize(): number;
  17692. /**
  17693. * Gets the actual render width of the texture.
  17694. * @returns the width of the render size
  17695. */
  17696. getRenderWidth(): number;
  17697. /**
  17698. * Gets the actual render height of the texture.
  17699. * @returns the height of the render size
  17700. */
  17701. getRenderHeight(): number;
  17702. /**
  17703. * Get if the texture can be rescaled or not.
  17704. */
  17705. readonly canRescale: boolean;
  17706. /**
  17707. * Resize the texture using a ratio.
  17708. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17709. */
  17710. scale(ratio: number): void;
  17711. /**
  17712. * Get the texture reflection matrix used to rotate/transform the reflection.
  17713. * @returns the reflection matrix
  17714. */
  17715. getReflectionTextureMatrix(): Matrix;
  17716. /**
  17717. * Resize the texture to a new desired size.
  17718. * Be carrefull as it will recreate all the data in the new texture.
  17719. * @param size Define the new size. It can be:
  17720. * - a number for squared texture,
  17721. * - an object containing { width: number, height: number }
  17722. * - or an object containing a ratio { ratio: number }
  17723. */
  17724. resize(size: number | {
  17725. width: number;
  17726. height: number;
  17727. } | {
  17728. ratio: number;
  17729. }): void;
  17730. /**
  17731. * Renders all the objects from the render list into the texture.
  17732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17734. */
  17735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17736. private _bestReflectionRenderTargetDimension;
  17737. /**
  17738. * @hidden
  17739. * @param faceIndex face index to bind to if this is a cubetexture
  17740. */
  17741. _bindFrameBuffer(faceIndex?: number): void;
  17742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17743. private renderToTarget;
  17744. /**
  17745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17746. * This allowed control for front to back rendering or reversly depending of the special needs.
  17747. *
  17748. * @param renderingGroupId The rendering group id corresponding to its index
  17749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17752. */
  17753. 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;
  17754. /**
  17755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17756. *
  17757. * @param renderingGroupId The rendering group id corresponding to its index
  17758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17759. */
  17760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17761. /**
  17762. * Clones the texture.
  17763. * @returns the cloned texture
  17764. */
  17765. clone(): RenderTargetTexture;
  17766. /**
  17767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17768. * @returns The JSON representation of the texture
  17769. */
  17770. serialize(): any;
  17771. /**
  17772. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17773. */
  17774. disposeFramebufferObjects(): void;
  17775. /**
  17776. * Dispose the texture and release its associated resources.
  17777. */
  17778. dispose(): void;
  17779. /** @hidden */
  17780. _rebuild(): void;
  17781. /**
  17782. * Clear the info related to rendering groups preventing retention point in material dispose.
  17783. */
  17784. freeRenderingGroups(): void;
  17785. /**
  17786. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17787. * @returns the view count
  17788. */
  17789. getViewCount(): number;
  17790. }
  17791. }
  17792. declare module BABYLON {
  17793. /**
  17794. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17795. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17796. * You can then easily use it as a reflectionTexture on a flat surface.
  17797. * In case the surface is not a plane, please consider relying on reflection probes.
  17798. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17799. */
  17800. export class MirrorTexture extends RenderTargetTexture {
  17801. private scene;
  17802. /**
  17803. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17804. * 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.
  17805. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17806. */
  17807. mirrorPlane: Plane;
  17808. /**
  17809. * Define the blur ratio used to blur the reflection if needed.
  17810. */
  17811. blurRatio: number;
  17812. /**
  17813. * Define the adaptive blur kernel used to blur the reflection if needed.
  17814. * This will autocompute the closest best match for the `blurKernel`
  17815. */
  17816. adaptiveBlurKernel: number;
  17817. /**
  17818. * Define the blur kernel used to blur the reflection if needed.
  17819. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17820. */
  17821. blurKernel: number;
  17822. /**
  17823. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17824. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17825. */
  17826. blurKernelX: number;
  17827. /**
  17828. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17829. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17830. */
  17831. blurKernelY: number;
  17832. private _autoComputeBlurKernel;
  17833. protected _onRatioRescale(): void;
  17834. private _updateGammaSpace;
  17835. private _imageProcessingConfigChangeObserver;
  17836. private _transformMatrix;
  17837. private _mirrorMatrix;
  17838. private _savedViewMatrix;
  17839. private _blurX;
  17840. private _blurY;
  17841. private _adaptiveBlurKernel;
  17842. private _blurKernelX;
  17843. private _blurKernelY;
  17844. private _blurRatio;
  17845. /**
  17846. * Instantiates a Mirror Texture.
  17847. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17848. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17849. * You can then easily use it as a reflectionTexture on a flat surface.
  17850. * In case the surface is not a plane, please consider relying on reflection probes.
  17851. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17852. * @param name
  17853. * @param size
  17854. * @param scene
  17855. * @param generateMipMaps
  17856. * @param type
  17857. * @param samplingMode
  17858. * @param generateDepthBuffer
  17859. */
  17860. constructor(name: string, size: number | {
  17861. width: number;
  17862. height: number;
  17863. } | {
  17864. ratio: number;
  17865. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17866. private _preparePostProcesses;
  17867. /**
  17868. * Clone the mirror texture.
  17869. * @returns the cloned texture
  17870. */
  17871. clone(): MirrorTexture;
  17872. /**
  17873. * Serialize the texture to a JSON representation you could use in Parse later on
  17874. * @returns the serialized JSON representation
  17875. */
  17876. serialize(): any;
  17877. /**
  17878. * Dispose the texture and release its associated resources.
  17879. */
  17880. dispose(): void;
  17881. }
  17882. }
  17883. declare module BABYLON {
  17884. /**
  17885. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17886. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17887. */
  17888. export class Texture extends BaseTexture {
  17889. /** @hidden */
  17890. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17891. /** @hidden */
  17892. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17893. /** @hidden */
  17894. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17895. /** nearest is mag = nearest and min = nearest and mip = linear */
  17896. static readonly NEAREST_SAMPLINGMODE: number;
  17897. /** nearest is mag = nearest and min = nearest and mip = linear */
  17898. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17900. static readonly BILINEAR_SAMPLINGMODE: number;
  17901. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17902. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17903. /** Trilinear is mag = linear and min = linear and mip = linear */
  17904. static readonly TRILINEAR_SAMPLINGMODE: number;
  17905. /** Trilinear is mag = linear and min = linear and mip = linear */
  17906. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17907. /** mag = nearest and min = nearest and mip = nearest */
  17908. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17909. /** mag = nearest and min = linear and mip = nearest */
  17910. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17911. /** mag = nearest and min = linear and mip = linear */
  17912. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17913. /** mag = nearest and min = linear and mip = none */
  17914. static readonly NEAREST_LINEAR: number;
  17915. /** mag = nearest and min = nearest and mip = none */
  17916. static readonly NEAREST_NEAREST: number;
  17917. /** mag = linear and min = nearest and mip = nearest */
  17918. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17919. /** mag = linear and min = nearest and mip = linear */
  17920. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17921. /** mag = linear and min = linear and mip = none */
  17922. static readonly LINEAR_LINEAR: number;
  17923. /** mag = linear and min = nearest and mip = none */
  17924. static readonly LINEAR_NEAREST: number;
  17925. /** Explicit coordinates mode */
  17926. static readonly EXPLICIT_MODE: number;
  17927. /** Spherical coordinates mode */
  17928. static readonly SPHERICAL_MODE: number;
  17929. /** Planar coordinates mode */
  17930. static readonly PLANAR_MODE: number;
  17931. /** Cubic coordinates mode */
  17932. static readonly CUBIC_MODE: number;
  17933. /** Projection coordinates mode */
  17934. static readonly PROJECTION_MODE: number;
  17935. /** Inverse Cubic coordinates mode */
  17936. static readonly SKYBOX_MODE: number;
  17937. /** Inverse Cubic coordinates mode */
  17938. static readonly INVCUBIC_MODE: number;
  17939. /** Equirectangular coordinates mode */
  17940. static readonly EQUIRECTANGULAR_MODE: number;
  17941. /** Equirectangular Fixed coordinates mode */
  17942. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17943. /** Equirectangular Fixed Mirrored coordinates mode */
  17944. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17945. /** Texture is not repeating outside of 0..1 UVs */
  17946. static readonly CLAMP_ADDRESSMODE: number;
  17947. /** Texture is repeating outside of 0..1 UVs */
  17948. static readonly WRAP_ADDRESSMODE: number;
  17949. /** Texture is repeating and mirrored */
  17950. static readonly MIRROR_ADDRESSMODE: number;
  17951. /**
  17952. * 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
  17953. */
  17954. static UseSerializedUrlIfAny: boolean;
  17955. /**
  17956. * Define the url of the texture.
  17957. */
  17958. url: Nullable<string>;
  17959. /**
  17960. * Define an offset on the texture to offset the u coordinates of the UVs
  17961. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17962. */
  17963. uOffset: number;
  17964. /**
  17965. * Define an offset on the texture to offset the v coordinates of the UVs
  17966. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17967. */
  17968. vOffset: number;
  17969. /**
  17970. * Define an offset on the texture to scale the u coordinates of the UVs
  17971. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17972. */
  17973. uScale: number;
  17974. /**
  17975. * Define an offset on the texture to scale the v coordinates of the UVs
  17976. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17977. */
  17978. vScale: number;
  17979. /**
  17980. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17981. * @see http://doc.babylonjs.com/how_to/more_materials
  17982. */
  17983. uAng: number;
  17984. /**
  17985. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17986. * @see http://doc.babylonjs.com/how_to/more_materials
  17987. */
  17988. vAng: number;
  17989. /**
  17990. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17991. * @see http://doc.babylonjs.com/how_to/more_materials
  17992. */
  17993. wAng: number;
  17994. /**
  17995. * Defines the center of rotation (U)
  17996. */
  17997. uRotationCenter: number;
  17998. /**
  17999. * Defines the center of rotation (V)
  18000. */
  18001. vRotationCenter: number;
  18002. /**
  18003. * Defines the center of rotation (W)
  18004. */
  18005. wRotationCenter: number;
  18006. /**
  18007. * Are mip maps generated for this texture or not.
  18008. */
  18009. readonly noMipmap: boolean;
  18010. /**
  18011. * List of inspectable custom properties (used by the Inspector)
  18012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18013. */
  18014. inspectableCustomProperties: IInspectable[];
  18015. private _noMipmap;
  18016. /** @hidden */
  18017. _invertY: boolean;
  18018. private _rowGenerationMatrix;
  18019. private _cachedTextureMatrix;
  18020. private _projectionModeMatrix;
  18021. private _t0;
  18022. private _t1;
  18023. private _t2;
  18024. private _cachedUOffset;
  18025. private _cachedVOffset;
  18026. private _cachedUScale;
  18027. private _cachedVScale;
  18028. private _cachedUAng;
  18029. private _cachedVAng;
  18030. private _cachedWAng;
  18031. private _cachedProjectionMatrixId;
  18032. private _cachedCoordinatesMode;
  18033. /** @hidden */
  18034. protected _initialSamplingMode: number;
  18035. /** @hidden */
  18036. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18037. private _deleteBuffer;
  18038. protected _format: Nullable<number>;
  18039. private _delayedOnLoad;
  18040. private _delayedOnError;
  18041. /**
  18042. * Observable triggered once the texture has been loaded.
  18043. */
  18044. onLoadObservable: Observable<Texture>;
  18045. protected _isBlocking: boolean;
  18046. /**
  18047. * Is the texture preventing material to render while loading.
  18048. * If false, a default texture will be used instead of the loading one during the preparation step.
  18049. */
  18050. isBlocking: boolean;
  18051. /**
  18052. * Get the current sampling mode associated with the texture.
  18053. */
  18054. readonly samplingMode: number;
  18055. /**
  18056. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18057. */
  18058. readonly invertY: boolean;
  18059. /**
  18060. * Instantiates a new texture.
  18061. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18062. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18063. * @param url define the url of the picture to load as a texture
  18064. * @param scene define the scene the texture will belong to
  18065. * @param noMipmap define if the texture will require mip maps or not
  18066. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18067. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18068. * @param onLoad define a callback triggered when the texture has been loaded
  18069. * @param onError define a callback triggered when an error occurred during the loading session
  18070. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18071. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18072. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18073. */
  18074. 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);
  18075. /**
  18076. * Update the url (and optional buffer) of this texture if url was null during construction.
  18077. * @param url the url of the texture
  18078. * @param buffer the buffer of the texture (defaults to null)
  18079. * @param onLoad callback called when the texture is loaded (defaults to null)
  18080. */
  18081. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18082. /**
  18083. * Finish the loading sequence of a texture flagged as delayed load.
  18084. * @hidden
  18085. */
  18086. delayLoad(): void;
  18087. private _prepareRowForTextureGeneration;
  18088. /**
  18089. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18090. * @returns the transform matrix of the texture.
  18091. */
  18092. getTextureMatrix(): Matrix;
  18093. /**
  18094. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18095. * @returns The reflection texture transform
  18096. */
  18097. getReflectionTextureMatrix(): Matrix;
  18098. /**
  18099. * Clones the texture.
  18100. * @returns the cloned texture
  18101. */
  18102. clone(): Texture;
  18103. /**
  18104. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18105. * @returns The JSON representation of the texture
  18106. */
  18107. serialize(): any;
  18108. /**
  18109. * Get the current class name of the texture useful for serialization or dynamic coding.
  18110. * @returns "Texture"
  18111. */
  18112. getClassName(): string;
  18113. /**
  18114. * Dispose the texture and release its associated resources.
  18115. */
  18116. dispose(): void;
  18117. /**
  18118. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18119. * @param parsedTexture Define the JSON representation of the texture
  18120. * @param scene Define the scene the parsed texture should be instantiated in
  18121. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18122. * @returns The parsed texture if successful
  18123. */
  18124. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18125. /**
  18126. * Creates a texture from its base 64 representation.
  18127. * @param data Define the base64 payload without the data: prefix
  18128. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18129. * @param scene Define the scene the texture should belong to
  18130. * @param noMipmap Forces the texture to not create mip map information if true
  18131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18133. * @param onLoad define a callback triggered when the texture has been loaded
  18134. * @param onError define a callback triggered when an error occurred during the loading session
  18135. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18136. * @returns the created texture
  18137. */
  18138. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18139. /**
  18140. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18141. * @param data Define the base64 payload without the data: prefix
  18142. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18143. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18144. * @param scene Define the scene the texture should belong to
  18145. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18146. * @param noMipmap Forces the texture to not create mip map information if true
  18147. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18148. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18149. * @param onLoad define a callback triggered when the texture has been loaded
  18150. * @param onError define a callback triggered when an error occurred during the loading session
  18151. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18152. * @returns the created texture
  18153. */
  18154. 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;
  18155. }
  18156. }
  18157. declare module BABYLON {
  18158. /**
  18159. * Raw texture can help creating a texture directly from an array of data.
  18160. * This can be super useful if you either get the data from an uncompressed source or
  18161. * if you wish to create your texture pixel by pixel.
  18162. */
  18163. export class RawTexture extends Texture {
  18164. /**
  18165. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18166. */
  18167. format: number;
  18168. private _engine;
  18169. /**
  18170. * Instantiates a new RawTexture.
  18171. * Raw texture can help creating a texture directly from an array of data.
  18172. * This can be super useful if you either get the data from an uncompressed source or
  18173. * if you wish to create your texture pixel by pixel.
  18174. * @param data define the array of data to use to create the texture
  18175. * @param width define the width of the texture
  18176. * @param height define the height of the texture
  18177. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18178. * @param scene define the scene the texture belongs to
  18179. * @param generateMipMaps define whether mip maps should be generated or not
  18180. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18181. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18182. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18183. */
  18184. constructor(data: ArrayBufferView, width: number, height: number,
  18185. /**
  18186. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18187. */
  18188. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18189. /**
  18190. * Updates the texture underlying data.
  18191. * @param data Define the new data of the texture
  18192. */
  18193. update(data: ArrayBufferView): void;
  18194. /**
  18195. * Creates a luminance texture from some data.
  18196. * @param data Define the texture data
  18197. * @param width Define the width of the texture
  18198. * @param height Define the height of the texture
  18199. * @param scene Define the scene the texture belongs to
  18200. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18201. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18202. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18203. * @returns the luminance texture
  18204. */
  18205. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18206. /**
  18207. * Creates a luminance alpha texture from some data.
  18208. * @param data Define the texture data
  18209. * @param width Define the width of the texture
  18210. * @param height Define the height of the texture
  18211. * @param scene Define the scene the texture belongs to
  18212. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18213. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18214. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18215. * @returns the luminance alpha texture
  18216. */
  18217. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18218. /**
  18219. * Creates an alpha texture from some data.
  18220. * @param data Define the texture data
  18221. * @param width Define the width of the texture
  18222. * @param height Define the height of the texture
  18223. * @param scene Define the scene the texture belongs to
  18224. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18225. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18226. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18227. * @returns the alpha texture
  18228. */
  18229. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18230. /**
  18231. * Creates a RGB texture from some data.
  18232. * @param data Define the texture data
  18233. * @param width Define the width of the texture
  18234. * @param height Define the height of the texture
  18235. * @param scene Define the scene the texture belongs to
  18236. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18237. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18238. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18239. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18240. * @returns the RGB alpha texture
  18241. */
  18242. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18243. /**
  18244. * Creates a RGBA texture from some data.
  18245. * @param data Define the texture data
  18246. * @param width Define the width of the texture
  18247. * @param height Define the height of the texture
  18248. * @param scene Define the scene the texture belongs to
  18249. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18250. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18251. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18252. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18253. * @returns the RGBA texture
  18254. */
  18255. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18256. /**
  18257. * Creates a R texture from some data.
  18258. * @param data Define the texture data
  18259. * @param width Define the width of the texture
  18260. * @param height Define the height of the texture
  18261. * @param scene Define the scene the texture belongs to
  18262. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18263. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18264. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18265. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18266. * @returns the R texture
  18267. */
  18268. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18269. }
  18270. }
  18271. declare module BABYLON {
  18272. /**
  18273. * Defines a runtime animation
  18274. */
  18275. export class RuntimeAnimation {
  18276. private _events;
  18277. /**
  18278. * The current frame of the runtime animation
  18279. */
  18280. private _currentFrame;
  18281. /**
  18282. * The animation used by the runtime animation
  18283. */
  18284. private _animation;
  18285. /**
  18286. * The target of the runtime animation
  18287. */
  18288. private _target;
  18289. /**
  18290. * The initiating animatable
  18291. */
  18292. private _host;
  18293. /**
  18294. * The original value of the runtime animation
  18295. */
  18296. private _originalValue;
  18297. /**
  18298. * The original blend value of the runtime animation
  18299. */
  18300. private _originalBlendValue;
  18301. /**
  18302. * The offsets cache of the runtime animation
  18303. */
  18304. private _offsetsCache;
  18305. /**
  18306. * The high limits cache of the runtime animation
  18307. */
  18308. private _highLimitsCache;
  18309. /**
  18310. * Specifies if the runtime animation has been stopped
  18311. */
  18312. private _stopped;
  18313. /**
  18314. * The blending factor of the runtime animation
  18315. */
  18316. private _blendingFactor;
  18317. /**
  18318. * The BabylonJS scene
  18319. */
  18320. private _scene;
  18321. /**
  18322. * The current value of the runtime animation
  18323. */
  18324. private _currentValue;
  18325. /** @hidden */
  18326. _workValue: any;
  18327. /**
  18328. * The active target of the runtime animation
  18329. */
  18330. private _activeTarget;
  18331. /**
  18332. * The target path of the runtime animation
  18333. */
  18334. private _targetPath;
  18335. /**
  18336. * The weight of the runtime animation
  18337. */
  18338. private _weight;
  18339. /**
  18340. * The ratio offset of the runtime animation
  18341. */
  18342. private _ratioOffset;
  18343. /**
  18344. * The previous delay of the runtime animation
  18345. */
  18346. private _previousDelay;
  18347. /**
  18348. * The previous ratio of the runtime animation
  18349. */
  18350. private _previousRatio;
  18351. /**
  18352. * Gets the current frame of the runtime animation
  18353. */
  18354. readonly currentFrame: number;
  18355. /**
  18356. * Gets the weight of the runtime animation
  18357. */
  18358. readonly weight: number;
  18359. /**
  18360. * Gets the current value of the runtime animation
  18361. */
  18362. readonly currentValue: any;
  18363. /**
  18364. * Gets the target path of the runtime animation
  18365. */
  18366. readonly targetPath: string;
  18367. /**
  18368. * Gets the actual target of the runtime animation
  18369. */
  18370. readonly target: any;
  18371. /**
  18372. * Create a new RuntimeAnimation object
  18373. * @param target defines the target of the animation
  18374. * @param animation defines the source animation object
  18375. * @param scene defines the hosting scene
  18376. * @param host defines the initiating Animatable
  18377. */
  18378. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18379. /**
  18380. * Gets the animation from the runtime animation
  18381. */
  18382. readonly animation: Animation;
  18383. /**
  18384. * Resets the runtime animation to the beginning
  18385. * @param restoreOriginal defines whether to restore the target property to the original value
  18386. */
  18387. reset(restoreOriginal?: boolean): void;
  18388. /**
  18389. * Specifies if the runtime animation is stopped
  18390. * @returns Boolean specifying if the runtime animation is stopped
  18391. */
  18392. isStopped(): boolean;
  18393. /**
  18394. * Disposes of the runtime animation
  18395. */
  18396. dispose(): void;
  18397. /**
  18398. * Interpolates the animation from the current frame
  18399. * @param currentFrame The frame to interpolate the animation to
  18400. * @param repeatCount The number of times that the animation should loop
  18401. * @param loopMode The type of looping mode to use
  18402. * @param offsetValue Animation offset value
  18403. * @param highLimitValue The high limit value
  18404. * @returns The interpolated value
  18405. */
  18406. private _interpolate;
  18407. /**
  18408. * Apply the interpolated value to the target
  18409. * @param currentValue defines the value computed by the animation
  18410. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18411. */
  18412. setValue(currentValue: any, weight?: number): void;
  18413. private _setValue;
  18414. /**
  18415. * Gets the loop pmode of the runtime animation
  18416. * @returns Loop Mode
  18417. */
  18418. private _getCorrectLoopMode;
  18419. /**
  18420. * Move the current animation to a given frame
  18421. * @param frame defines the frame to move to
  18422. */
  18423. goToFrame(frame: number): void;
  18424. /**
  18425. * @hidden Internal use only
  18426. */
  18427. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18428. /**
  18429. * Execute the current animation
  18430. * @param delay defines the delay to add to the current frame
  18431. * @param from defines the lower bound of the animation range
  18432. * @param to defines the upper bound of the animation range
  18433. * @param loop defines if the current animation must loop
  18434. * @param speedRatio defines the current speed ratio
  18435. * @param weight defines the weight of the animation (default is -1 so no weight)
  18436. * @param onLoop optional callback called when animation loops
  18437. * @returns a boolean indicating if the animation is running
  18438. */
  18439. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18440. }
  18441. }
  18442. declare module BABYLON {
  18443. /**
  18444. * Class used to store an actual running animation
  18445. */
  18446. export class Animatable {
  18447. /** defines the target object */
  18448. target: any;
  18449. /** defines the starting frame number (default is 0) */
  18450. fromFrame: number;
  18451. /** defines the ending frame number (default is 100) */
  18452. toFrame: number;
  18453. /** defines if the animation must loop (default is false) */
  18454. loopAnimation: boolean;
  18455. /** defines a callback to call when animation ends if it is not looping */
  18456. onAnimationEnd?: (() => void) | null | undefined;
  18457. /** defines a callback to call when animation loops */
  18458. onAnimationLoop?: (() => void) | null | undefined;
  18459. private _localDelayOffset;
  18460. private _pausedDelay;
  18461. private _runtimeAnimations;
  18462. private _paused;
  18463. private _scene;
  18464. private _speedRatio;
  18465. private _weight;
  18466. private _syncRoot;
  18467. /**
  18468. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18469. * This will only apply for non looping animation (default is true)
  18470. */
  18471. disposeOnEnd: boolean;
  18472. /**
  18473. * Gets a boolean indicating if the animation has started
  18474. */
  18475. animationStarted: boolean;
  18476. /**
  18477. * Observer raised when the animation ends
  18478. */
  18479. onAnimationEndObservable: Observable<Animatable>;
  18480. /**
  18481. * Observer raised when the animation loops
  18482. */
  18483. onAnimationLoopObservable: Observable<Animatable>;
  18484. /**
  18485. * Gets the root Animatable used to synchronize and normalize animations
  18486. */
  18487. readonly syncRoot: Animatable;
  18488. /**
  18489. * Gets the current frame of the first RuntimeAnimation
  18490. * Used to synchronize Animatables
  18491. */
  18492. readonly masterFrame: number;
  18493. /**
  18494. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18495. */
  18496. weight: number;
  18497. /**
  18498. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18499. */
  18500. speedRatio: number;
  18501. /**
  18502. * Creates a new Animatable
  18503. * @param scene defines the hosting scene
  18504. * @param target defines the target object
  18505. * @param fromFrame defines the starting frame number (default is 0)
  18506. * @param toFrame defines the ending frame number (default is 100)
  18507. * @param loopAnimation defines if the animation must loop (default is false)
  18508. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18509. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18510. * @param animations defines a group of animation to add to the new Animatable
  18511. * @param onAnimationLoop defines a callback to call when animation loops
  18512. */
  18513. constructor(scene: Scene,
  18514. /** defines the target object */
  18515. target: any,
  18516. /** defines the starting frame number (default is 0) */
  18517. fromFrame?: number,
  18518. /** defines the ending frame number (default is 100) */
  18519. toFrame?: number,
  18520. /** defines if the animation must loop (default is false) */
  18521. loopAnimation?: boolean, speedRatio?: number,
  18522. /** defines a callback to call when animation ends if it is not looping */
  18523. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18524. /** defines a callback to call when animation loops */
  18525. onAnimationLoop?: (() => void) | null | undefined);
  18526. /**
  18527. * Synchronize and normalize current Animatable with a source Animatable
  18528. * This is useful when using animation weights and when animations are not of the same length
  18529. * @param root defines the root Animatable to synchronize with
  18530. * @returns the current Animatable
  18531. */
  18532. syncWith(root: Animatable): Animatable;
  18533. /**
  18534. * Gets the list of runtime animations
  18535. * @returns an array of RuntimeAnimation
  18536. */
  18537. getAnimations(): RuntimeAnimation[];
  18538. /**
  18539. * Adds more animations to the current animatable
  18540. * @param target defines the target of the animations
  18541. * @param animations defines the new animations to add
  18542. */
  18543. appendAnimations(target: any, animations: Animation[]): void;
  18544. /**
  18545. * Gets the source animation for a specific property
  18546. * @param property defines the propertyu to look for
  18547. * @returns null or the source animation for the given property
  18548. */
  18549. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18550. /**
  18551. * Gets the runtime animation for a specific property
  18552. * @param property defines the propertyu to look for
  18553. * @returns null or the runtime animation for the given property
  18554. */
  18555. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18556. /**
  18557. * Resets the animatable to its original state
  18558. */
  18559. reset(): void;
  18560. /**
  18561. * Allows the animatable to blend with current running animations
  18562. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18563. * @param blendingSpeed defines the blending speed to use
  18564. */
  18565. enableBlending(blendingSpeed: number): void;
  18566. /**
  18567. * Disable animation blending
  18568. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18569. */
  18570. disableBlending(): void;
  18571. /**
  18572. * Jump directly to a given frame
  18573. * @param frame defines the frame to jump to
  18574. */
  18575. goToFrame(frame: number): void;
  18576. /**
  18577. * Pause the animation
  18578. */
  18579. pause(): void;
  18580. /**
  18581. * Restart the animation
  18582. */
  18583. restart(): void;
  18584. private _raiseOnAnimationEnd;
  18585. /**
  18586. * Stop and delete the current animation
  18587. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18588. * @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)
  18589. */
  18590. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18591. /**
  18592. * Wait asynchronously for the animation to end
  18593. * @returns a promise which will be fullfilled when the animation ends
  18594. */
  18595. waitAsync(): Promise<Animatable>;
  18596. /** @hidden */
  18597. _animate(delay: number): boolean;
  18598. }
  18599. interface Scene {
  18600. /** @hidden */
  18601. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18602. /** @hidden */
  18603. _processLateAnimationBindingsForMatrices(holder: {
  18604. totalWeight: number;
  18605. animations: RuntimeAnimation[];
  18606. originalValue: Matrix;
  18607. }): any;
  18608. /** @hidden */
  18609. _processLateAnimationBindingsForQuaternions(holder: {
  18610. totalWeight: number;
  18611. animations: RuntimeAnimation[];
  18612. originalValue: Quaternion;
  18613. }, refQuaternion: Quaternion): Quaternion;
  18614. /** @hidden */
  18615. _processLateAnimationBindings(): void;
  18616. /**
  18617. * Will start the animation sequence of a given target
  18618. * @param target defines the target
  18619. * @param from defines from which frame should animation start
  18620. * @param to defines until which frame should animation run.
  18621. * @param weight defines the weight to apply to the animation (1.0 by default)
  18622. * @param loop defines if the animation loops
  18623. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18624. * @param onAnimationEnd defines the function to be executed when the animation ends
  18625. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18626. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18627. * @param onAnimationLoop defines the callback to call when an animation loops
  18628. * @returns the animatable object created for this animation
  18629. */
  18630. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18631. /**
  18632. * Will start the animation sequence of a given target
  18633. * @param target defines the target
  18634. * @param from defines from which frame should animation start
  18635. * @param to defines until which frame should animation run.
  18636. * @param loop defines if the animation loops
  18637. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18638. * @param onAnimationEnd defines the function to be executed when the animation ends
  18639. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18640. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18641. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18642. * @param onAnimationLoop defines the callback to call when an animation loops
  18643. * @returns the animatable object created for this animation
  18644. */
  18645. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18646. /**
  18647. * Will start the animation sequence of a given target and its hierarchy
  18648. * @param target defines the target
  18649. * @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.
  18650. * @param from defines from which frame should animation start
  18651. * @param to defines until which frame should animation run.
  18652. * @param loop defines if the animation loops
  18653. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18654. * @param onAnimationEnd defines the function to be executed when the animation ends
  18655. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18656. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18657. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18658. * @param onAnimationLoop defines the callback to call when an animation loops
  18659. * @returns the list of created animatables
  18660. */
  18661. 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[];
  18662. /**
  18663. * Begin a new animation on a given node
  18664. * @param target defines the target where the animation will take place
  18665. * @param animations defines the list of animations to start
  18666. * @param from defines the initial value
  18667. * @param to defines the final value
  18668. * @param loop defines if you want animation to loop (off by default)
  18669. * @param speedRatio defines the speed ratio to apply to all animations
  18670. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18671. * @param onAnimationLoop defines the callback to call when an animation loops
  18672. * @returns the list of created animatables
  18673. */
  18674. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18675. /**
  18676. * Begin a new animation on a given node and its hierarchy
  18677. * @param target defines the root node where the animation will take place
  18678. * @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.
  18679. * @param animations defines the list of animations to start
  18680. * @param from defines the initial value
  18681. * @param to defines the final value
  18682. * @param loop defines if you want animation to loop (off by default)
  18683. * @param speedRatio defines the speed ratio to apply to all animations
  18684. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18685. * @param onAnimationLoop defines the callback to call when an animation loops
  18686. * @returns the list of animatables created for all nodes
  18687. */
  18688. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18689. /**
  18690. * Gets the animatable associated with a specific target
  18691. * @param target defines the target of the animatable
  18692. * @returns the required animatable if found
  18693. */
  18694. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18695. /**
  18696. * Gets all animatables associated with a given target
  18697. * @param target defines the target to look animatables for
  18698. * @returns an array of Animatables
  18699. */
  18700. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18701. /**
  18702. * Will stop the animation of the given target
  18703. * @param target - the target
  18704. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18705. * @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)
  18706. */
  18707. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18708. /**
  18709. * Stops and removes all animations that have been applied to the scene
  18710. */
  18711. stopAllAnimations(): void;
  18712. }
  18713. interface Bone {
  18714. /**
  18715. * Copy an animation range from another bone
  18716. * @param source defines the source bone
  18717. * @param rangeName defines the range name to copy
  18718. * @param frameOffset defines the frame offset
  18719. * @param rescaleAsRequired defines if rescaling must be applied if required
  18720. * @param skelDimensionsRatio defines the scaling ratio
  18721. * @returns true if operation was successful
  18722. */
  18723. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18724. }
  18725. }
  18726. declare module BABYLON {
  18727. /**
  18728. * Class used to handle skinning animations
  18729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18730. */
  18731. export class Skeleton implements IAnimatable {
  18732. /** defines the skeleton name */
  18733. name: string;
  18734. /** defines the skeleton Id */
  18735. id: string;
  18736. /**
  18737. * Defines the list of child bones
  18738. */
  18739. bones: Bone[];
  18740. /**
  18741. * Defines an estimate of the dimension of the skeleton at rest
  18742. */
  18743. dimensionsAtRest: Vector3;
  18744. /**
  18745. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18746. */
  18747. needInitialSkinMatrix: boolean;
  18748. /**
  18749. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18750. */
  18751. overrideMesh: Nullable<AbstractMesh>;
  18752. /**
  18753. * Gets the list of animations attached to this skeleton
  18754. */
  18755. animations: Array<Animation>;
  18756. private _scene;
  18757. private _isDirty;
  18758. private _transformMatrices;
  18759. private _transformMatrixTexture;
  18760. private _meshesWithPoseMatrix;
  18761. private _animatables;
  18762. private _identity;
  18763. private _synchronizedWithMesh;
  18764. private _ranges;
  18765. private _lastAbsoluteTransformsUpdateId;
  18766. private _canUseTextureForBones;
  18767. private _uniqueId;
  18768. /** @hidden */
  18769. _numBonesWithLinkedTransformNode: number;
  18770. /**
  18771. * Specifies if the skeleton should be serialized
  18772. */
  18773. doNotSerialize: boolean;
  18774. private _useTextureToStoreBoneMatrices;
  18775. /**
  18776. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18777. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18778. */
  18779. useTextureToStoreBoneMatrices: boolean;
  18780. private _animationPropertiesOverride;
  18781. /**
  18782. * Gets or sets the animation properties override
  18783. */
  18784. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18785. /**
  18786. * List of inspectable custom properties (used by the Inspector)
  18787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18788. */
  18789. inspectableCustomProperties: IInspectable[];
  18790. /**
  18791. * An observable triggered before computing the skeleton's matrices
  18792. */
  18793. onBeforeComputeObservable: Observable<Skeleton>;
  18794. /**
  18795. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18796. */
  18797. readonly isUsingTextureForMatrices: boolean;
  18798. /**
  18799. * Gets the unique ID of this skeleton
  18800. */
  18801. readonly uniqueId: number;
  18802. /**
  18803. * Creates a new skeleton
  18804. * @param name defines the skeleton name
  18805. * @param id defines the skeleton Id
  18806. * @param scene defines the hosting scene
  18807. */
  18808. constructor(
  18809. /** defines the skeleton name */
  18810. name: string,
  18811. /** defines the skeleton Id */
  18812. id: string, scene: Scene);
  18813. /**
  18814. * Gets the current object class name.
  18815. * @return the class name
  18816. */
  18817. getClassName(): string;
  18818. /**
  18819. * Returns an array containing the root bones
  18820. * @returns an array containing the root bones
  18821. */
  18822. getChildren(): Array<Bone>;
  18823. /**
  18824. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18825. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18826. * @returns a Float32Array containing matrices data
  18827. */
  18828. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18829. /**
  18830. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18831. * @returns a raw texture containing the data
  18832. */
  18833. getTransformMatrixTexture(): Nullable<RawTexture>;
  18834. /**
  18835. * Gets the current hosting scene
  18836. * @returns a scene object
  18837. */
  18838. getScene(): Scene;
  18839. /**
  18840. * Gets a string representing the current skeleton data
  18841. * @param fullDetails defines a boolean indicating if we want a verbose version
  18842. * @returns a string representing the current skeleton data
  18843. */
  18844. toString(fullDetails?: boolean): string;
  18845. /**
  18846. * Get bone's index searching by name
  18847. * @param name defines bone's name to search for
  18848. * @return the indice of the bone. Returns -1 if not found
  18849. */
  18850. getBoneIndexByName(name: string): number;
  18851. /**
  18852. * Creater a new animation range
  18853. * @param name defines the name of the range
  18854. * @param from defines the start key
  18855. * @param to defines the end key
  18856. */
  18857. createAnimationRange(name: string, from: number, to: number): void;
  18858. /**
  18859. * Delete a specific animation range
  18860. * @param name defines the name of the range
  18861. * @param deleteFrames defines if frames must be removed as well
  18862. */
  18863. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18864. /**
  18865. * Gets a specific animation range
  18866. * @param name defines the name of the range to look for
  18867. * @returns the requested animation range or null if not found
  18868. */
  18869. getAnimationRange(name: string): Nullable<AnimationRange>;
  18870. /**
  18871. * Gets the list of all animation ranges defined on this skeleton
  18872. * @returns an array
  18873. */
  18874. getAnimationRanges(): Nullable<AnimationRange>[];
  18875. /**
  18876. * Copy animation range from a source skeleton.
  18877. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18878. * @param source defines the source skeleton
  18879. * @param name defines the name of the range to copy
  18880. * @param rescaleAsRequired defines if rescaling must be applied if required
  18881. * @returns true if operation was successful
  18882. */
  18883. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18884. /**
  18885. * Forces the skeleton to go to rest pose
  18886. */
  18887. returnToRest(): void;
  18888. private _getHighestAnimationFrame;
  18889. /**
  18890. * Begin a specific animation range
  18891. * @param name defines the name of the range to start
  18892. * @param loop defines if looping must be turned on (false by default)
  18893. * @param speedRatio defines the speed ratio to apply (1 by default)
  18894. * @param onAnimationEnd defines a callback which will be called when animation will end
  18895. * @returns a new animatable
  18896. */
  18897. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18898. /** @hidden */
  18899. _markAsDirty(): void;
  18900. /** @hidden */
  18901. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18902. /** @hidden */
  18903. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18904. private _computeTransformMatrices;
  18905. /**
  18906. * Build all resources required to render a skeleton
  18907. */
  18908. prepare(): void;
  18909. /**
  18910. * Gets the list of animatables currently running for this skeleton
  18911. * @returns an array of animatables
  18912. */
  18913. getAnimatables(): IAnimatable[];
  18914. /**
  18915. * Clone the current skeleton
  18916. * @param name defines the name of the new skeleton
  18917. * @param id defines the id of the enw skeleton
  18918. * @returns the new skeleton
  18919. */
  18920. clone(name: string, id: string): Skeleton;
  18921. /**
  18922. * Enable animation blending for this skeleton
  18923. * @param blendingSpeed defines the blending speed to apply
  18924. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18925. */
  18926. enableBlending(blendingSpeed?: number): void;
  18927. /**
  18928. * Releases all resources associated with the current skeleton
  18929. */
  18930. dispose(): void;
  18931. /**
  18932. * Serialize the skeleton in a JSON object
  18933. * @returns a JSON object
  18934. */
  18935. serialize(): any;
  18936. /**
  18937. * Creates a new skeleton from serialized data
  18938. * @param parsedSkeleton defines the serialized data
  18939. * @param scene defines the hosting scene
  18940. * @returns a new skeleton
  18941. */
  18942. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18943. /**
  18944. * Compute all node absolute transforms
  18945. * @param forceUpdate defines if computation must be done even if cache is up to date
  18946. */
  18947. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18948. /**
  18949. * Gets the root pose matrix
  18950. * @returns a matrix
  18951. */
  18952. getPoseMatrix(): Nullable<Matrix>;
  18953. /**
  18954. * Sorts bones per internal index
  18955. */
  18956. sortBones(): void;
  18957. private _sortBones;
  18958. }
  18959. }
  18960. declare module BABYLON {
  18961. /**
  18962. * Defines a target to use with MorphTargetManager
  18963. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18964. */
  18965. export class MorphTarget implements IAnimatable {
  18966. /** defines the name of the target */
  18967. name: string;
  18968. /**
  18969. * Gets or sets the list of animations
  18970. */
  18971. animations: Animation[];
  18972. private _scene;
  18973. private _positions;
  18974. private _normals;
  18975. private _tangents;
  18976. private _influence;
  18977. /**
  18978. * Observable raised when the influence changes
  18979. */
  18980. onInfluenceChanged: Observable<boolean>;
  18981. /** @hidden */
  18982. _onDataLayoutChanged: Observable<void>;
  18983. /**
  18984. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18985. */
  18986. influence: number;
  18987. /**
  18988. * Gets or sets the id of the morph Target
  18989. */
  18990. id: string;
  18991. private _animationPropertiesOverride;
  18992. /**
  18993. * Gets or sets the animation properties override
  18994. */
  18995. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18996. /**
  18997. * Creates a new MorphTarget
  18998. * @param name defines the name of the target
  18999. * @param influence defines the influence to use
  19000. * @param scene defines the scene the morphtarget belongs to
  19001. */
  19002. constructor(
  19003. /** defines the name of the target */
  19004. name: string, influence?: number, scene?: Nullable<Scene>);
  19005. /**
  19006. * Gets a boolean defining if the target contains position data
  19007. */
  19008. readonly hasPositions: boolean;
  19009. /**
  19010. * Gets a boolean defining if the target contains normal data
  19011. */
  19012. readonly hasNormals: boolean;
  19013. /**
  19014. * Gets a boolean defining if the target contains tangent data
  19015. */
  19016. readonly hasTangents: boolean;
  19017. /**
  19018. * Affects position data to this target
  19019. * @param data defines the position data to use
  19020. */
  19021. setPositions(data: Nullable<FloatArray>): void;
  19022. /**
  19023. * Gets the position data stored in this target
  19024. * @returns a FloatArray containing the position data (or null if not present)
  19025. */
  19026. getPositions(): Nullable<FloatArray>;
  19027. /**
  19028. * Affects normal data to this target
  19029. * @param data defines the normal data to use
  19030. */
  19031. setNormals(data: Nullable<FloatArray>): void;
  19032. /**
  19033. * Gets the normal data stored in this target
  19034. * @returns a FloatArray containing the normal data (or null if not present)
  19035. */
  19036. getNormals(): Nullable<FloatArray>;
  19037. /**
  19038. * Affects tangent data to this target
  19039. * @param data defines the tangent data to use
  19040. */
  19041. setTangents(data: Nullable<FloatArray>): void;
  19042. /**
  19043. * Gets the tangent data stored in this target
  19044. * @returns a FloatArray containing the tangent data (or null if not present)
  19045. */
  19046. getTangents(): Nullable<FloatArray>;
  19047. /**
  19048. * Serializes the current target into a Serialization object
  19049. * @returns the serialized object
  19050. */
  19051. serialize(): any;
  19052. /**
  19053. * Returns the string "MorphTarget"
  19054. * @returns "MorphTarget"
  19055. */
  19056. getClassName(): string;
  19057. /**
  19058. * Creates a new target from serialized data
  19059. * @param serializationObject defines the serialized data to use
  19060. * @returns a new MorphTarget
  19061. */
  19062. static Parse(serializationObject: any): MorphTarget;
  19063. /**
  19064. * Creates a MorphTarget from mesh data
  19065. * @param mesh defines the source mesh
  19066. * @param name defines the name to use for the new target
  19067. * @param influence defines the influence to attach to the target
  19068. * @returns a new MorphTarget
  19069. */
  19070. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19071. }
  19072. }
  19073. declare module BABYLON {
  19074. /**
  19075. * This class is used to deform meshes using morphing between different targets
  19076. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19077. */
  19078. export class MorphTargetManager {
  19079. private _targets;
  19080. private _targetInfluenceChangedObservers;
  19081. private _targetDataLayoutChangedObservers;
  19082. private _activeTargets;
  19083. private _scene;
  19084. private _influences;
  19085. private _supportsNormals;
  19086. private _supportsTangents;
  19087. private _vertexCount;
  19088. private _uniqueId;
  19089. private _tempInfluences;
  19090. /**
  19091. * Creates a new MorphTargetManager
  19092. * @param scene defines the current scene
  19093. */
  19094. constructor(scene?: Nullable<Scene>);
  19095. /**
  19096. * Gets the unique ID of this manager
  19097. */
  19098. readonly uniqueId: number;
  19099. /**
  19100. * Gets the number of vertices handled by this manager
  19101. */
  19102. readonly vertexCount: number;
  19103. /**
  19104. * Gets a boolean indicating if this manager supports morphing of normals
  19105. */
  19106. readonly supportsNormals: boolean;
  19107. /**
  19108. * Gets a boolean indicating if this manager supports morphing of tangents
  19109. */
  19110. readonly supportsTangents: boolean;
  19111. /**
  19112. * Gets the number of targets stored in this manager
  19113. */
  19114. readonly numTargets: number;
  19115. /**
  19116. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19117. */
  19118. readonly numInfluencers: number;
  19119. /**
  19120. * Gets the list of influences (one per target)
  19121. */
  19122. readonly influences: Float32Array;
  19123. /**
  19124. * Gets the active target at specified index. An active target is a target with an influence > 0
  19125. * @param index defines the index to check
  19126. * @returns the requested target
  19127. */
  19128. getActiveTarget(index: number): MorphTarget;
  19129. /**
  19130. * Gets the target at specified index
  19131. * @param index defines the index to check
  19132. * @returns the requested target
  19133. */
  19134. getTarget(index: number): MorphTarget;
  19135. /**
  19136. * Add a new target to this manager
  19137. * @param target defines the target to add
  19138. */
  19139. addTarget(target: MorphTarget): void;
  19140. /**
  19141. * Removes a target from the manager
  19142. * @param target defines the target to remove
  19143. */
  19144. removeTarget(target: MorphTarget): void;
  19145. /**
  19146. * Serializes the current manager into a Serialization object
  19147. * @returns the serialized object
  19148. */
  19149. serialize(): any;
  19150. private _syncActiveTargets;
  19151. /**
  19152. * Syncrhonize the targets with all the meshes using this morph target manager
  19153. */
  19154. synchronize(): void;
  19155. /**
  19156. * Creates a new MorphTargetManager from serialized data
  19157. * @param serializationObject defines the serialized data
  19158. * @param scene defines the hosting scene
  19159. * @returns the new MorphTargetManager
  19160. */
  19161. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19162. }
  19163. }
  19164. declare module BABYLON {
  19165. /**
  19166. * Mesh representing the gorund
  19167. */
  19168. export class GroundMesh extends Mesh {
  19169. /** If octree should be generated */
  19170. generateOctree: boolean;
  19171. private _heightQuads;
  19172. /** @hidden */
  19173. _subdivisionsX: number;
  19174. /** @hidden */
  19175. _subdivisionsY: number;
  19176. /** @hidden */
  19177. _width: number;
  19178. /** @hidden */
  19179. _height: number;
  19180. /** @hidden */
  19181. _minX: number;
  19182. /** @hidden */
  19183. _maxX: number;
  19184. /** @hidden */
  19185. _minZ: number;
  19186. /** @hidden */
  19187. _maxZ: number;
  19188. constructor(name: string, scene: Scene);
  19189. /**
  19190. * "GroundMesh"
  19191. * @returns "GroundMesh"
  19192. */
  19193. getClassName(): string;
  19194. /**
  19195. * The minimum of x and y subdivisions
  19196. */
  19197. readonly subdivisions: number;
  19198. /**
  19199. * X subdivisions
  19200. */
  19201. readonly subdivisionsX: number;
  19202. /**
  19203. * Y subdivisions
  19204. */
  19205. readonly subdivisionsY: number;
  19206. /**
  19207. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19208. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19209. * @param chunksCount the number of subdivisions for x and y
  19210. * @param octreeBlocksSize (Default: 32)
  19211. */
  19212. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19213. /**
  19214. * Returns a height (y) value in the Worl system :
  19215. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19216. * @param x x coordinate
  19217. * @param z z coordinate
  19218. * @returns the ground y position if (x, z) are outside the ground surface.
  19219. */
  19220. getHeightAtCoordinates(x: number, z: number): number;
  19221. /**
  19222. * Returns a normalized vector (Vector3) orthogonal to the ground
  19223. * at the ground coordinates (x, z) expressed in the World system.
  19224. * @param x x coordinate
  19225. * @param z z coordinate
  19226. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19227. */
  19228. getNormalAtCoordinates(x: number, z: number): Vector3;
  19229. /**
  19230. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19231. * at the ground coordinates (x, z) expressed in the World system.
  19232. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19233. * @param x x coordinate
  19234. * @param z z coordinate
  19235. * @param ref vector to store the result
  19236. * @returns the GroundMesh.
  19237. */
  19238. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19239. /**
  19240. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19241. * if the ground has been updated.
  19242. * This can be used in the render loop.
  19243. * @returns the GroundMesh.
  19244. */
  19245. updateCoordinateHeights(): GroundMesh;
  19246. private _getFacetAt;
  19247. private _initHeightQuads;
  19248. private _computeHeightQuads;
  19249. /**
  19250. * Serializes this ground mesh
  19251. * @param serializationObject object to write serialization to
  19252. */
  19253. serialize(serializationObject: any): void;
  19254. /**
  19255. * Parses a serialized ground mesh
  19256. * @param parsedMesh the serialized mesh
  19257. * @param scene the scene to create the ground mesh in
  19258. * @returns the created ground mesh
  19259. */
  19260. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19261. }
  19262. }
  19263. declare module BABYLON {
  19264. /**
  19265. * Interface for Physics-Joint data
  19266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19267. */
  19268. export interface PhysicsJointData {
  19269. /**
  19270. * The main pivot of the joint
  19271. */
  19272. mainPivot?: Vector3;
  19273. /**
  19274. * The connected pivot of the joint
  19275. */
  19276. connectedPivot?: Vector3;
  19277. /**
  19278. * The main axis of the joint
  19279. */
  19280. mainAxis?: Vector3;
  19281. /**
  19282. * The connected axis of the joint
  19283. */
  19284. connectedAxis?: Vector3;
  19285. /**
  19286. * The collision of the joint
  19287. */
  19288. collision?: boolean;
  19289. /**
  19290. * Native Oimo/Cannon/Energy data
  19291. */
  19292. nativeParams?: any;
  19293. }
  19294. /**
  19295. * This is a holder class for the physics joint created by the physics plugin
  19296. * It holds a set of functions to control the underlying joint
  19297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19298. */
  19299. export class PhysicsJoint {
  19300. /**
  19301. * The type of the physics joint
  19302. */
  19303. type: number;
  19304. /**
  19305. * The data for the physics joint
  19306. */
  19307. jointData: PhysicsJointData;
  19308. private _physicsJoint;
  19309. protected _physicsPlugin: IPhysicsEnginePlugin;
  19310. /**
  19311. * Initializes the physics joint
  19312. * @param type The type of the physics joint
  19313. * @param jointData The data for the physics joint
  19314. */
  19315. constructor(
  19316. /**
  19317. * The type of the physics joint
  19318. */
  19319. type: number,
  19320. /**
  19321. * The data for the physics joint
  19322. */
  19323. jointData: PhysicsJointData);
  19324. /**
  19325. * Gets the physics joint
  19326. */
  19327. /**
  19328. * Sets the physics joint
  19329. */
  19330. physicsJoint: any;
  19331. /**
  19332. * Sets the physics plugin
  19333. */
  19334. physicsPlugin: IPhysicsEnginePlugin;
  19335. /**
  19336. * Execute a function that is physics-plugin specific.
  19337. * @param {Function} func the function that will be executed.
  19338. * It accepts two parameters: the physics world and the physics joint
  19339. */
  19340. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19341. /**
  19342. * Distance-Joint type
  19343. */
  19344. static DistanceJoint: number;
  19345. /**
  19346. * Hinge-Joint type
  19347. */
  19348. static HingeJoint: number;
  19349. /**
  19350. * Ball-and-Socket joint type
  19351. */
  19352. static BallAndSocketJoint: number;
  19353. /**
  19354. * Wheel-Joint type
  19355. */
  19356. static WheelJoint: number;
  19357. /**
  19358. * Slider-Joint type
  19359. */
  19360. static SliderJoint: number;
  19361. /**
  19362. * Prismatic-Joint type
  19363. */
  19364. static PrismaticJoint: number;
  19365. /**
  19366. * Universal-Joint type
  19367. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19368. */
  19369. static UniversalJoint: number;
  19370. /**
  19371. * Hinge-Joint 2 type
  19372. */
  19373. static Hinge2Joint: number;
  19374. /**
  19375. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19376. */
  19377. static PointToPointJoint: number;
  19378. /**
  19379. * Spring-Joint type
  19380. */
  19381. static SpringJoint: number;
  19382. /**
  19383. * Lock-Joint type
  19384. */
  19385. static LockJoint: number;
  19386. }
  19387. /**
  19388. * A class representing a physics distance joint
  19389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19390. */
  19391. export class DistanceJoint extends PhysicsJoint {
  19392. /**
  19393. *
  19394. * @param jointData The data for the Distance-Joint
  19395. */
  19396. constructor(jointData: DistanceJointData);
  19397. /**
  19398. * Update the predefined distance.
  19399. * @param maxDistance The maximum preferred distance
  19400. * @param minDistance The minimum preferred distance
  19401. */
  19402. updateDistance(maxDistance: number, minDistance?: number): void;
  19403. }
  19404. /**
  19405. * Represents a Motor-Enabled Joint
  19406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19407. */
  19408. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19409. /**
  19410. * Initializes the Motor-Enabled Joint
  19411. * @param type The type of the joint
  19412. * @param jointData The physica joint data for the joint
  19413. */
  19414. constructor(type: number, jointData: PhysicsJointData);
  19415. /**
  19416. * Set the motor values.
  19417. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19418. * @param force the force to apply
  19419. * @param maxForce max force for this motor.
  19420. */
  19421. setMotor(force?: number, maxForce?: number): void;
  19422. /**
  19423. * Set the motor's limits.
  19424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19425. * @param upperLimit The upper limit of the motor
  19426. * @param lowerLimit The lower limit of the motor
  19427. */
  19428. setLimit(upperLimit: number, lowerLimit?: number): void;
  19429. }
  19430. /**
  19431. * This class represents a single physics Hinge-Joint
  19432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19433. */
  19434. export class HingeJoint extends MotorEnabledJoint {
  19435. /**
  19436. * Initializes the Hinge-Joint
  19437. * @param jointData The joint data for the Hinge-Joint
  19438. */
  19439. constructor(jointData: PhysicsJointData);
  19440. /**
  19441. * Set the motor values.
  19442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19443. * @param {number} force the force to apply
  19444. * @param {number} maxForce max force for this motor.
  19445. */
  19446. setMotor(force?: number, maxForce?: number): void;
  19447. /**
  19448. * Set the motor's limits.
  19449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19450. * @param upperLimit The upper limit of the motor
  19451. * @param lowerLimit The lower limit of the motor
  19452. */
  19453. setLimit(upperLimit: number, lowerLimit?: number): void;
  19454. }
  19455. /**
  19456. * This class represents a dual hinge physics joint (same as wheel joint)
  19457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19458. */
  19459. export class Hinge2Joint extends MotorEnabledJoint {
  19460. /**
  19461. * Initializes the Hinge2-Joint
  19462. * @param jointData The joint data for the Hinge2-Joint
  19463. */
  19464. constructor(jointData: PhysicsJointData);
  19465. /**
  19466. * Set the motor values.
  19467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19468. * @param {number} targetSpeed the speed the motor is to reach
  19469. * @param {number} maxForce max force for this motor.
  19470. * @param {motorIndex} the motor's index, 0 or 1.
  19471. */
  19472. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19473. /**
  19474. * Set the motor limits.
  19475. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19476. * @param {number} upperLimit the upper limit
  19477. * @param {number} lowerLimit lower limit
  19478. * @param {motorIndex} the motor's index, 0 or 1.
  19479. */
  19480. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19481. }
  19482. /**
  19483. * Interface for a motor enabled joint
  19484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19485. */
  19486. export interface IMotorEnabledJoint {
  19487. /**
  19488. * Physics joint
  19489. */
  19490. physicsJoint: any;
  19491. /**
  19492. * Sets the motor of the motor-enabled joint
  19493. * @param force The force of the motor
  19494. * @param maxForce The maximum force of the motor
  19495. * @param motorIndex The index of the motor
  19496. */
  19497. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19498. /**
  19499. * Sets the limit of the motor
  19500. * @param upperLimit The upper limit of the motor
  19501. * @param lowerLimit The lower limit of the motor
  19502. * @param motorIndex The index of the motor
  19503. */
  19504. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19505. }
  19506. /**
  19507. * Joint data for a Distance-Joint
  19508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19509. */
  19510. export interface DistanceJointData extends PhysicsJointData {
  19511. /**
  19512. * Max distance the 2 joint objects can be apart
  19513. */
  19514. maxDistance: number;
  19515. }
  19516. /**
  19517. * Joint data from a spring joint
  19518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19519. */
  19520. export interface SpringJointData extends PhysicsJointData {
  19521. /**
  19522. * Length of the spring
  19523. */
  19524. length: number;
  19525. /**
  19526. * Stiffness of the spring
  19527. */
  19528. stiffness: number;
  19529. /**
  19530. * Damping of the spring
  19531. */
  19532. damping: number;
  19533. /** this callback will be called when applying the force to the impostors. */
  19534. forceApplicationCallback: () => void;
  19535. }
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * Holds the data for the raycast result
  19540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19541. */
  19542. export class PhysicsRaycastResult {
  19543. private _hasHit;
  19544. private _hitDistance;
  19545. private _hitNormalWorld;
  19546. private _hitPointWorld;
  19547. private _rayFromWorld;
  19548. private _rayToWorld;
  19549. /**
  19550. * Gets if there was a hit
  19551. */
  19552. readonly hasHit: boolean;
  19553. /**
  19554. * Gets the distance from the hit
  19555. */
  19556. readonly hitDistance: number;
  19557. /**
  19558. * Gets the hit normal/direction in the world
  19559. */
  19560. readonly hitNormalWorld: Vector3;
  19561. /**
  19562. * Gets the hit point in the world
  19563. */
  19564. readonly hitPointWorld: Vector3;
  19565. /**
  19566. * Gets the ray "start point" of the ray in the world
  19567. */
  19568. readonly rayFromWorld: Vector3;
  19569. /**
  19570. * Gets the ray "end point" of the ray in the world
  19571. */
  19572. readonly rayToWorld: Vector3;
  19573. /**
  19574. * Sets the hit data (normal & point in world space)
  19575. * @param hitNormalWorld defines the normal in world space
  19576. * @param hitPointWorld defines the point in world space
  19577. */
  19578. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19579. /**
  19580. * Sets the distance from the start point to the hit point
  19581. * @param distance
  19582. */
  19583. setHitDistance(distance: number): void;
  19584. /**
  19585. * Calculates the distance manually
  19586. */
  19587. calculateHitDistance(): void;
  19588. /**
  19589. * Resets all the values to default
  19590. * @param from The from point on world space
  19591. * @param to The to point on world space
  19592. */
  19593. reset(from?: Vector3, to?: Vector3): void;
  19594. }
  19595. /**
  19596. * Interface for the size containing width and height
  19597. */
  19598. interface IXYZ {
  19599. /**
  19600. * X
  19601. */
  19602. x: number;
  19603. /**
  19604. * Y
  19605. */
  19606. y: number;
  19607. /**
  19608. * Z
  19609. */
  19610. z: number;
  19611. }
  19612. }
  19613. declare module BABYLON {
  19614. /**
  19615. * Interface used to describe a physics joint
  19616. */
  19617. export interface PhysicsImpostorJoint {
  19618. /** Defines the main impostor to which the joint is linked */
  19619. mainImpostor: PhysicsImpostor;
  19620. /** Defines the impostor that is connected to the main impostor using this joint */
  19621. connectedImpostor: PhysicsImpostor;
  19622. /** Defines the joint itself */
  19623. joint: PhysicsJoint;
  19624. }
  19625. /** @hidden */
  19626. export interface IPhysicsEnginePlugin {
  19627. world: any;
  19628. name: string;
  19629. setGravity(gravity: Vector3): void;
  19630. setTimeStep(timeStep: number): void;
  19631. getTimeStep(): number;
  19632. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19633. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19635. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19636. removePhysicsBody(impostor: PhysicsImpostor): void;
  19637. generateJoint(joint: PhysicsImpostorJoint): void;
  19638. removeJoint(joint: PhysicsImpostorJoint): void;
  19639. isSupported(): boolean;
  19640. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19641. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19643. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19644. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19645. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19647. getBodyMass(impostor: PhysicsImpostor): number;
  19648. getBodyFriction(impostor: PhysicsImpostor): number;
  19649. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19650. getBodyRestitution(impostor: PhysicsImpostor): number;
  19651. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19652. getBodyPressure?(impostor: PhysicsImpostor): number;
  19653. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19654. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19655. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19656. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19657. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19658. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19659. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19660. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19661. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19662. sleepBody(impostor: PhysicsImpostor): void;
  19663. wakeUpBody(impostor: PhysicsImpostor): void;
  19664. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19665. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19666. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19667. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19668. getRadius(impostor: PhysicsImpostor): number;
  19669. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19670. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19671. dispose(): void;
  19672. }
  19673. /**
  19674. * Interface used to define a physics engine
  19675. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19676. */
  19677. export interface IPhysicsEngine {
  19678. /**
  19679. * Gets the gravity vector used by the simulation
  19680. */
  19681. gravity: Vector3;
  19682. /**
  19683. * Sets the gravity vector used by the simulation
  19684. * @param gravity defines the gravity vector to use
  19685. */
  19686. setGravity(gravity: Vector3): void;
  19687. /**
  19688. * Set the time step of the physics engine.
  19689. * Default is 1/60.
  19690. * To slow it down, enter 1/600 for example.
  19691. * To speed it up, 1/30
  19692. * @param newTimeStep the new timestep to apply to this world.
  19693. */
  19694. setTimeStep(newTimeStep: number): void;
  19695. /**
  19696. * Get the time step of the physics engine.
  19697. * @returns the current time step
  19698. */
  19699. getTimeStep(): number;
  19700. /**
  19701. * Release all resources
  19702. */
  19703. dispose(): void;
  19704. /**
  19705. * Gets the name of the current physics plugin
  19706. * @returns the name of the plugin
  19707. */
  19708. getPhysicsPluginName(): string;
  19709. /**
  19710. * Adding a new impostor for the impostor tracking.
  19711. * This will be done by the impostor itself.
  19712. * @param impostor the impostor to add
  19713. */
  19714. addImpostor(impostor: PhysicsImpostor): void;
  19715. /**
  19716. * Remove an impostor from the engine.
  19717. * This impostor and its mesh will not longer be updated by the physics engine.
  19718. * @param impostor the impostor to remove
  19719. */
  19720. removeImpostor(impostor: PhysicsImpostor): void;
  19721. /**
  19722. * Add a joint to the physics engine
  19723. * @param mainImpostor defines the main impostor to which the joint is added.
  19724. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19725. * @param joint defines the joint that will connect both impostors.
  19726. */
  19727. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19728. /**
  19729. * Removes a joint from the simulation
  19730. * @param mainImpostor defines the impostor used with the joint
  19731. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19732. * @param joint defines the joint to remove
  19733. */
  19734. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19735. /**
  19736. * Gets the current plugin used to run the simulation
  19737. * @returns current plugin
  19738. */
  19739. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19740. /**
  19741. * Gets the list of physic impostors
  19742. * @returns an array of PhysicsImpostor
  19743. */
  19744. getImpostors(): Array<PhysicsImpostor>;
  19745. /**
  19746. * Gets the impostor for a physics enabled object
  19747. * @param object defines the object impersonated by the impostor
  19748. * @returns the PhysicsImpostor or null if not found
  19749. */
  19750. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19751. /**
  19752. * Gets the impostor for a physics body object
  19753. * @param body defines physics body used by the impostor
  19754. * @returns the PhysicsImpostor or null if not found
  19755. */
  19756. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19757. /**
  19758. * Does a raycast in the physics world
  19759. * @param from when should the ray start?
  19760. * @param to when should the ray end?
  19761. * @returns PhysicsRaycastResult
  19762. */
  19763. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19764. /**
  19765. * Called by the scene. No need to call it.
  19766. * @param delta defines the timespam between frames
  19767. */
  19768. _step(delta: number): void;
  19769. }
  19770. }
  19771. declare module BABYLON {
  19772. /**
  19773. * The interface for the physics imposter parameters
  19774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19775. */
  19776. export interface PhysicsImpostorParameters {
  19777. /**
  19778. * The mass of the physics imposter
  19779. */
  19780. mass: number;
  19781. /**
  19782. * The friction of the physics imposter
  19783. */
  19784. friction?: number;
  19785. /**
  19786. * The coefficient of restitution of the physics imposter
  19787. */
  19788. restitution?: number;
  19789. /**
  19790. * The native options of the physics imposter
  19791. */
  19792. nativeOptions?: any;
  19793. /**
  19794. * Specifies if the parent should be ignored
  19795. */
  19796. ignoreParent?: boolean;
  19797. /**
  19798. * Specifies if bi-directional transformations should be disabled
  19799. */
  19800. disableBidirectionalTransformation?: boolean;
  19801. /**
  19802. * The pressure inside the physics imposter, soft object only
  19803. */
  19804. pressure?: number;
  19805. /**
  19806. * The stiffness the physics imposter, soft object only
  19807. */
  19808. stiffness?: number;
  19809. /**
  19810. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19811. */
  19812. velocityIterations?: number;
  19813. /**
  19814. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19815. */
  19816. positionIterations?: number;
  19817. /**
  19818. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19819. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19820. * Add to fix multiple points
  19821. */
  19822. fixedPoints?: number;
  19823. /**
  19824. * The collision margin around a soft object
  19825. */
  19826. margin?: number;
  19827. /**
  19828. * The collision margin around a soft object
  19829. */
  19830. damping?: number;
  19831. /**
  19832. * The path for a rope based on an extrusion
  19833. */
  19834. path?: any;
  19835. /**
  19836. * The shape of an extrusion used for a rope based on an extrusion
  19837. */
  19838. shape?: any;
  19839. }
  19840. /**
  19841. * Interface for a physics-enabled object
  19842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19843. */
  19844. export interface IPhysicsEnabledObject {
  19845. /**
  19846. * The position of the physics-enabled object
  19847. */
  19848. position: Vector3;
  19849. /**
  19850. * The rotation of the physics-enabled object
  19851. */
  19852. rotationQuaternion: Nullable<Quaternion>;
  19853. /**
  19854. * The scale of the physics-enabled object
  19855. */
  19856. scaling: Vector3;
  19857. /**
  19858. * The rotation of the physics-enabled object
  19859. */
  19860. rotation?: Vector3;
  19861. /**
  19862. * The parent of the physics-enabled object
  19863. */
  19864. parent?: any;
  19865. /**
  19866. * The bounding info of the physics-enabled object
  19867. * @returns The bounding info of the physics-enabled object
  19868. */
  19869. getBoundingInfo(): BoundingInfo;
  19870. /**
  19871. * Computes the world matrix
  19872. * @param force Specifies if the world matrix should be computed by force
  19873. * @returns A world matrix
  19874. */
  19875. computeWorldMatrix(force: boolean): Matrix;
  19876. /**
  19877. * Gets the world matrix
  19878. * @returns A world matrix
  19879. */
  19880. getWorldMatrix?(): Matrix;
  19881. /**
  19882. * Gets the child meshes
  19883. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19884. * @returns An array of abstract meshes
  19885. */
  19886. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19887. /**
  19888. * Gets the vertex data
  19889. * @param kind The type of vertex data
  19890. * @returns A nullable array of numbers, or a float32 array
  19891. */
  19892. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19893. /**
  19894. * Gets the indices from the mesh
  19895. * @returns A nullable array of index arrays
  19896. */
  19897. getIndices?(): Nullable<IndicesArray>;
  19898. /**
  19899. * Gets the scene from the mesh
  19900. * @returns the indices array or null
  19901. */
  19902. getScene?(): Scene;
  19903. /**
  19904. * Gets the absolute position from the mesh
  19905. * @returns the absolute position
  19906. */
  19907. getAbsolutePosition(): Vector3;
  19908. /**
  19909. * Gets the absolute pivot point from the mesh
  19910. * @returns the absolute pivot point
  19911. */
  19912. getAbsolutePivotPoint(): Vector3;
  19913. /**
  19914. * Rotates the mesh
  19915. * @param axis The axis of rotation
  19916. * @param amount The amount of rotation
  19917. * @param space The space of the rotation
  19918. * @returns The rotation transform node
  19919. */
  19920. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19921. /**
  19922. * Translates the mesh
  19923. * @param axis The axis of translation
  19924. * @param distance The distance of translation
  19925. * @param space The space of the translation
  19926. * @returns The transform node
  19927. */
  19928. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19929. /**
  19930. * Sets the absolute position of the mesh
  19931. * @param absolutePosition The absolute position of the mesh
  19932. * @returns The transform node
  19933. */
  19934. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19935. /**
  19936. * Gets the class name of the mesh
  19937. * @returns The class name
  19938. */
  19939. getClassName(): string;
  19940. }
  19941. /**
  19942. * Represents a physics imposter
  19943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19944. */
  19945. export class PhysicsImpostor {
  19946. /**
  19947. * The physics-enabled object used as the physics imposter
  19948. */
  19949. object: IPhysicsEnabledObject;
  19950. /**
  19951. * The type of the physics imposter
  19952. */
  19953. type: number;
  19954. private _options;
  19955. private _scene?;
  19956. /**
  19957. * The default object size of the imposter
  19958. */
  19959. static DEFAULT_OBJECT_SIZE: Vector3;
  19960. /**
  19961. * The identity quaternion of the imposter
  19962. */
  19963. static IDENTITY_QUATERNION: Quaternion;
  19964. /** @hidden */
  19965. _pluginData: any;
  19966. private _physicsEngine;
  19967. private _physicsBody;
  19968. private _bodyUpdateRequired;
  19969. private _onBeforePhysicsStepCallbacks;
  19970. private _onAfterPhysicsStepCallbacks;
  19971. /** @hidden */
  19972. _onPhysicsCollideCallbacks: Array<{
  19973. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19974. otherImpostors: Array<PhysicsImpostor>;
  19975. }>;
  19976. private _deltaPosition;
  19977. private _deltaRotation;
  19978. private _deltaRotationConjugated;
  19979. /** hidden */
  19980. _isFromLine: boolean;
  19981. private _parent;
  19982. private _isDisposed;
  19983. private static _tmpVecs;
  19984. private static _tmpQuat;
  19985. /**
  19986. * Specifies if the physics imposter is disposed
  19987. */
  19988. readonly isDisposed: boolean;
  19989. /**
  19990. * Gets the mass of the physics imposter
  19991. */
  19992. mass: number;
  19993. /**
  19994. * Gets the coefficient of friction
  19995. */
  19996. /**
  19997. * Sets the coefficient of friction
  19998. */
  19999. friction: number;
  20000. /**
  20001. * Gets the coefficient of restitution
  20002. */
  20003. /**
  20004. * Sets the coefficient of restitution
  20005. */
  20006. restitution: number;
  20007. /**
  20008. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20009. */
  20010. /**
  20011. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20012. */
  20013. pressure: number;
  20014. /**
  20015. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20016. */
  20017. /**
  20018. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20019. */
  20020. stiffness: number;
  20021. /**
  20022. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20023. */
  20024. /**
  20025. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20026. */
  20027. velocityIterations: number;
  20028. /**
  20029. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20030. */
  20031. /**
  20032. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20033. */
  20034. positionIterations: number;
  20035. /**
  20036. * The unique id of the physics imposter
  20037. * set by the physics engine when adding this impostor to the array
  20038. */
  20039. uniqueId: number;
  20040. /**
  20041. * @hidden
  20042. */
  20043. soft: boolean;
  20044. /**
  20045. * @hidden
  20046. */
  20047. segments: number;
  20048. private _joints;
  20049. /**
  20050. * Initializes the physics imposter
  20051. * @param object The physics-enabled object used as the physics imposter
  20052. * @param type The type of the physics imposter
  20053. * @param _options The options for the physics imposter
  20054. * @param _scene The Babylon scene
  20055. */
  20056. constructor(
  20057. /**
  20058. * The physics-enabled object used as the physics imposter
  20059. */
  20060. object: IPhysicsEnabledObject,
  20061. /**
  20062. * The type of the physics imposter
  20063. */
  20064. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20065. /**
  20066. * This function will completly initialize this impostor.
  20067. * It will create a new body - but only if this mesh has no parent.
  20068. * If it has, this impostor will not be used other than to define the impostor
  20069. * of the child mesh.
  20070. * @hidden
  20071. */
  20072. _init(): void;
  20073. private _getPhysicsParent;
  20074. /**
  20075. * Should a new body be generated.
  20076. * @returns boolean specifying if body initialization is required
  20077. */
  20078. isBodyInitRequired(): boolean;
  20079. /**
  20080. * Sets the updated scaling
  20081. * @param updated Specifies if the scaling is updated
  20082. */
  20083. setScalingUpdated(): void;
  20084. /**
  20085. * Force a regeneration of this or the parent's impostor's body.
  20086. * Use under cautious - This will remove all joints already implemented.
  20087. */
  20088. forceUpdate(): void;
  20089. /**
  20090. * Gets the body that holds this impostor. Either its own, or its parent.
  20091. */
  20092. /**
  20093. * Set the physics body. Used mainly by the physics engine/plugin
  20094. */
  20095. physicsBody: any;
  20096. /**
  20097. * Get the parent of the physics imposter
  20098. * @returns Physics imposter or null
  20099. */
  20100. /**
  20101. * Sets the parent of the physics imposter
  20102. */
  20103. parent: Nullable<PhysicsImpostor>;
  20104. /**
  20105. * Resets the update flags
  20106. */
  20107. resetUpdateFlags(): void;
  20108. /**
  20109. * Gets the object extend size
  20110. * @returns the object extend size
  20111. */
  20112. getObjectExtendSize(): Vector3;
  20113. /**
  20114. * Gets the object center
  20115. * @returns The object center
  20116. */
  20117. getObjectCenter(): Vector3;
  20118. /**
  20119. * Get a specific parametes from the options parameter
  20120. * @param paramName The object parameter name
  20121. * @returns The object parameter
  20122. */
  20123. getParam(paramName: string): any;
  20124. /**
  20125. * Sets a specific parameter in the options given to the physics plugin
  20126. * @param paramName The parameter name
  20127. * @param value The value of the parameter
  20128. */
  20129. setParam(paramName: string, value: number): void;
  20130. /**
  20131. * Specifically change the body's mass option. Won't recreate the physics body object
  20132. * @param mass The mass of the physics imposter
  20133. */
  20134. setMass(mass: number): void;
  20135. /**
  20136. * Gets the linear velocity
  20137. * @returns linear velocity or null
  20138. */
  20139. getLinearVelocity(): Nullable<Vector3>;
  20140. /**
  20141. * Sets the linear velocity
  20142. * @param velocity linear velocity or null
  20143. */
  20144. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20145. /**
  20146. * Gets the angular velocity
  20147. * @returns angular velocity or null
  20148. */
  20149. getAngularVelocity(): Nullable<Vector3>;
  20150. /**
  20151. * Sets the angular velocity
  20152. * @param velocity The velocity or null
  20153. */
  20154. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20155. /**
  20156. * Execute a function with the physics plugin native code
  20157. * Provide a function the will have two variables - the world object and the physics body object
  20158. * @param func The function to execute with the physics plugin native code
  20159. */
  20160. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20161. /**
  20162. * Register a function that will be executed before the physics world is stepping forward
  20163. * @param func The function to execute before the physics world is stepped forward
  20164. */
  20165. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20166. /**
  20167. * Unregister a function that will be executed before the physics world is stepping forward
  20168. * @param func The function to execute before the physics world is stepped forward
  20169. */
  20170. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20171. /**
  20172. * Register a function that will be executed after the physics step
  20173. * @param func The function to execute after physics step
  20174. */
  20175. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20176. /**
  20177. * Unregisters a function that will be executed after the physics step
  20178. * @param func The function to execute after physics step
  20179. */
  20180. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20181. /**
  20182. * register a function that will be executed when this impostor collides against a different body
  20183. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20184. * @param func Callback that is executed on collision
  20185. */
  20186. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20187. /**
  20188. * Unregisters the physics imposter on contact
  20189. * @param collideAgainst The physics object to collide against
  20190. * @param func Callback to execute on collision
  20191. */
  20192. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20193. private _tmpQuat;
  20194. private _tmpQuat2;
  20195. /**
  20196. * Get the parent rotation
  20197. * @returns The parent rotation
  20198. */
  20199. getParentsRotation(): Quaternion;
  20200. /**
  20201. * this function is executed by the physics engine.
  20202. */
  20203. beforeStep: () => void;
  20204. /**
  20205. * this function is executed by the physics engine
  20206. */
  20207. afterStep: () => void;
  20208. /**
  20209. * Legacy collision detection event support
  20210. */
  20211. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20212. /**
  20213. * event and body object due to cannon's event-based architecture.
  20214. */
  20215. onCollide: (e: {
  20216. body: any;
  20217. }) => void;
  20218. /**
  20219. * Apply a force
  20220. * @param force The force to apply
  20221. * @param contactPoint The contact point for the force
  20222. * @returns The physics imposter
  20223. */
  20224. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20225. /**
  20226. * Apply an impulse
  20227. * @param force The impulse force
  20228. * @param contactPoint The contact point for the impulse force
  20229. * @returns The physics imposter
  20230. */
  20231. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20232. /**
  20233. * A help function to create a joint
  20234. * @param otherImpostor A physics imposter used to create a joint
  20235. * @param jointType The type of joint
  20236. * @param jointData The data for the joint
  20237. * @returns The physics imposter
  20238. */
  20239. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20240. /**
  20241. * Add a joint to this impostor with a different impostor
  20242. * @param otherImpostor A physics imposter used to add a joint
  20243. * @param joint The joint to add
  20244. * @returns The physics imposter
  20245. */
  20246. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20247. /**
  20248. * Add an anchor to a cloth impostor
  20249. * @param otherImpostor rigid impostor to anchor to
  20250. * @param width ratio across width from 0 to 1
  20251. * @param height ratio up height from 0 to 1
  20252. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20253. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20254. * @returns impostor the soft imposter
  20255. */
  20256. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20257. /**
  20258. * Add a hook to a rope impostor
  20259. * @param otherImpostor rigid impostor to anchor to
  20260. * @param length ratio across rope from 0 to 1
  20261. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20262. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20263. * @returns impostor the rope imposter
  20264. */
  20265. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20266. /**
  20267. * Will keep this body still, in a sleep mode.
  20268. * @returns the physics imposter
  20269. */
  20270. sleep(): PhysicsImpostor;
  20271. /**
  20272. * Wake the body up.
  20273. * @returns The physics imposter
  20274. */
  20275. wakeUp(): PhysicsImpostor;
  20276. /**
  20277. * Clones the physics imposter
  20278. * @param newObject The physics imposter clones to this physics-enabled object
  20279. * @returns A nullable physics imposter
  20280. */
  20281. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20282. /**
  20283. * Disposes the physics imposter
  20284. */
  20285. dispose(): void;
  20286. /**
  20287. * Sets the delta position
  20288. * @param position The delta position amount
  20289. */
  20290. setDeltaPosition(position: Vector3): void;
  20291. /**
  20292. * Sets the delta rotation
  20293. * @param rotation The delta rotation amount
  20294. */
  20295. setDeltaRotation(rotation: Quaternion): void;
  20296. /**
  20297. * Gets the box size of the physics imposter and stores the result in the input parameter
  20298. * @param result Stores the box size
  20299. * @returns The physics imposter
  20300. */
  20301. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20302. /**
  20303. * Gets the radius of the physics imposter
  20304. * @returns Radius of the physics imposter
  20305. */
  20306. getRadius(): number;
  20307. /**
  20308. * Sync a bone with this impostor
  20309. * @param bone The bone to sync to the impostor.
  20310. * @param boneMesh The mesh that the bone is influencing.
  20311. * @param jointPivot The pivot of the joint / bone in local space.
  20312. * @param distToJoint Optional distance from the impostor to the joint.
  20313. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20314. */
  20315. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20316. /**
  20317. * Sync impostor to a bone
  20318. * @param bone The bone that the impostor will be synced to.
  20319. * @param boneMesh The mesh that the bone is influencing.
  20320. * @param jointPivot The pivot of the joint / bone in local space.
  20321. * @param distToJoint Optional distance from the impostor to the joint.
  20322. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20323. * @param boneAxis Optional vector3 axis the bone is aligned with
  20324. */
  20325. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20326. /**
  20327. * No-Imposter type
  20328. */
  20329. static NoImpostor: number;
  20330. /**
  20331. * Sphere-Imposter type
  20332. */
  20333. static SphereImpostor: number;
  20334. /**
  20335. * Box-Imposter type
  20336. */
  20337. static BoxImpostor: number;
  20338. /**
  20339. * Plane-Imposter type
  20340. */
  20341. static PlaneImpostor: number;
  20342. /**
  20343. * Mesh-imposter type
  20344. */
  20345. static MeshImpostor: number;
  20346. /**
  20347. * Cylinder-Imposter type
  20348. */
  20349. static CylinderImpostor: number;
  20350. /**
  20351. * Particle-Imposter type
  20352. */
  20353. static ParticleImpostor: number;
  20354. /**
  20355. * Heightmap-Imposter type
  20356. */
  20357. static HeightmapImpostor: number;
  20358. /**
  20359. * ConvexHull-Impostor type (Ammo.js plugin only)
  20360. */
  20361. static ConvexHullImpostor: number;
  20362. /**
  20363. * Rope-Imposter type
  20364. */
  20365. static RopeImpostor: number;
  20366. /**
  20367. * Cloth-Imposter type
  20368. */
  20369. static ClothImpostor: number;
  20370. /**
  20371. * Softbody-Imposter type
  20372. */
  20373. static SoftbodyImpostor: number;
  20374. }
  20375. }
  20376. declare module BABYLON {
  20377. /**
  20378. * Class used to represent a specific level of detail of a mesh
  20379. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20380. */
  20381. export class MeshLODLevel {
  20382. /** Defines the distance where this level should star being displayed */
  20383. distance: number;
  20384. /** Defines the mesh to use to render this level */
  20385. mesh: Nullable<Mesh>;
  20386. /**
  20387. * Creates a new LOD level
  20388. * @param distance defines the distance where this level should star being displayed
  20389. * @param mesh defines the mesh to use to render this level
  20390. */
  20391. constructor(
  20392. /** Defines the distance where this level should star being displayed */
  20393. distance: number,
  20394. /** Defines the mesh to use to render this level */
  20395. mesh: Nullable<Mesh>);
  20396. }
  20397. /**
  20398. * @hidden
  20399. **/
  20400. export class _CreationDataStorage {
  20401. closePath?: boolean;
  20402. closeArray?: boolean;
  20403. idx: number[];
  20404. dashSize: number;
  20405. gapSize: number;
  20406. path3D: Path3D;
  20407. pathArray: Vector3[][];
  20408. arc: number;
  20409. radius: number;
  20410. cap: number;
  20411. tessellation: number;
  20412. }
  20413. /**
  20414. * @hidden
  20415. **/
  20416. class _InstanceDataStorage {
  20417. visibleInstances: any;
  20418. renderIdForInstances: number[];
  20419. batchCache: _InstancesBatch;
  20420. instancesBufferSize: number;
  20421. instancesBuffer: Nullable<Buffer>;
  20422. instancesData: Float32Array;
  20423. overridenInstanceCount: number;
  20424. }
  20425. /**
  20426. * @hidden
  20427. **/
  20428. export class _InstancesBatch {
  20429. mustReturn: boolean;
  20430. visibleInstances: Nullable<InstancedMesh[]>[];
  20431. renderSelf: boolean[];
  20432. }
  20433. /**
  20434. * Class used to represent renderable models
  20435. */
  20436. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20437. /**
  20438. * Mesh side orientation : usually the external or front surface
  20439. */
  20440. static readonly FRONTSIDE: number;
  20441. /**
  20442. * Mesh side orientation : usually the internal or back surface
  20443. */
  20444. static readonly BACKSIDE: number;
  20445. /**
  20446. * Mesh side orientation : both internal and external or front and back surfaces
  20447. */
  20448. static readonly DOUBLESIDE: number;
  20449. /**
  20450. * Mesh side orientation : by default, `FRONTSIDE`
  20451. */
  20452. static readonly DEFAULTSIDE: number;
  20453. /**
  20454. * Mesh cap setting : no cap
  20455. */
  20456. static readonly NO_CAP: number;
  20457. /**
  20458. * Mesh cap setting : one cap at the beginning of the mesh
  20459. */
  20460. static readonly CAP_START: number;
  20461. /**
  20462. * Mesh cap setting : one cap at the end of the mesh
  20463. */
  20464. static readonly CAP_END: number;
  20465. /**
  20466. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20467. */
  20468. static readonly CAP_ALL: number;
  20469. /**
  20470. * Gets the default side orientation.
  20471. * @param orientation the orientation to value to attempt to get
  20472. * @returns the default orientation
  20473. * @hidden
  20474. */
  20475. static _GetDefaultSideOrientation(orientation?: number): number;
  20476. private _onBeforeRenderObservable;
  20477. private _onBeforeBindObservable;
  20478. private _onAfterRenderObservable;
  20479. private _onBeforeDrawObservable;
  20480. /**
  20481. * An event triggered before rendering the mesh
  20482. */
  20483. readonly onBeforeRenderObservable: Observable<Mesh>;
  20484. /**
  20485. * An event triggered before binding the mesh
  20486. */
  20487. readonly onBeforeBindObservable: Observable<Mesh>;
  20488. /**
  20489. * An event triggered after rendering the mesh
  20490. */
  20491. readonly onAfterRenderObservable: Observable<Mesh>;
  20492. /**
  20493. * An event triggered before drawing the mesh
  20494. */
  20495. readonly onBeforeDrawObservable: Observable<Mesh>;
  20496. private _onBeforeDrawObserver;
  20497. /**
  20498. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20499. */
  20500. onBeforeDraw: () => void;
  20501. /**
  20502. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20503. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20504. */
  20505. delayLoadState: number;
  20506. /**
  20507. * Gets the list of instances created from this mesh
  20508. * it is not supposed to be modified manually.
  20509. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20510. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20511. */
  20512. instances: InstancedMesh[];
  20513. /**
  20514. * Gets the file containing delay loading data for this mesh
  20515. */
  20516. delayLoadingFile: string;
  20517. /** @hidden */
  20518. _binaryInfo: any;
  20519. private _LODLevels;
  20520. /**
  20521. * User defined function used to change how LOD level selection is done
  20522. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20523. */
  20524. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20525. private _morphTargetManager;
  20526. /**
  20527. * Gets or sets the morph target manager
  20528. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20529. */
  20530. morphTargetManager: Nullable<MorphTargetManager>;
  20531. /** @hidden */
  20532. _creationDataStorage: Nullable<_CreationDataStorage>;
  20533. /** @hidden */
  20534. _geometry: Nullable<Geometry>;
  20535. /** @hidden */
  20536. _delayInfo: Array<string>;
  20537. /** @hidden */
  20538. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20539. /** @hidden */
  20540. _instanceDataStorage: _InstanceDataStorage;
  20541. private _effectiveMaterial;
  20542. /** @hidden */
  20543. _shouldGenerateFlatShading: boolean;
  20544. private _preActivateId;
  20545. /** @hidden */
  20546. _originalBuilderSideOrientation: number;
  20547. /**
  20548. * Use this property to change the original side orientation defined at construction time
  20549. */
  20550. overrideMaterialSideOrientation: Nullable<number>;
  20551. private _areNormalsFrozen;
  20552. private _sourcePositions;
  20553. private _sourceNormals;
  20554. private _source;
  20555. private meshMap;
  20556. /**
  20557. * Gets the source mesh (the one used to clone this one from)
  20558. */
  20559. readonly source: Nullable<Mesh>;
  20560. /**
  20561. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20562. */
  20563. isUnIndexed: boolean;
  20564. /**
  20565. * @constructor
  20566. * @param name The value used by scene.getMeshByName() to do a lookup.
  20567. * @param scene The scene to add this mesh to.
  20568. * @param parent The parent of this mesh, if it has one
  20569. * @param source An optional Mesh from which geometry is shared, cloned.
  20570. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20571. * When false, achieved by calling a clone(), also passing False.
  20572. * This will make creation of children, recursive.
  20573. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20574. */
  20575. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20576. /**
  20577. * Gets the class name
  20578. * @returns the string "Mesh".
  20579. */
  20580. getClassName(): string;
  20581. /** @hidden */
  20582. readonly _isMesh: boolean;
  20583. /**
  20584. * Returns a description of this mesh
  20585. * @param fullDetails define if full details about this mesh must be used
  20586. * @returns a descriptive string representing this mesh
  20587. */
  20588. toString(fullDetails?: boolean): string;
  20589. /** @hidden */
  20590. _unBindEffect(): void;
  20591. /**
  20592. * Gets a boolean indicating if this mesh has LOD
  20593. */
  20594. readonly hasLODLevels: boolean;
  20595. /**
  20596. * Gets the list of MeshLODLevel associated with the current mesh
  20597. * @returns an array of MeshLODLevel
  20598. */
  20599. getLODLevels(): MeshLODLevel[];
  20600. private _sortLODLevels;
  20601. /**
  20602. * Add a mesh as LOD level triggered at the given distance.
  20603. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20604. * @param distance The distance from the center of the object to show this level
  20605. * @param mesh The mesh to be added as LOD level (can be null)
  20606. * @return This mesh (for chaining)
  20607. */
  20608. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20609. /**
  20610. * Returns the LOD level mesh at the passed distance or null if not found.
  20611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20612. * @param distance The distance from the center of the object to show this level
  20613. * @returns a Mesh or `null`
  20614. */
  20615. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20616. /**
  20617. * Remove a mesh from the LOD array
  20618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20619. * @param mesh defines the mesh to be removed
  20620. * @return This mesh (for chaining)
  20621. */
  20622. removeLODLevel(mesh: Mesh): Mesh;
  20623. /**
  20624. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20625. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20626. * @param camera defines the camera to use to compute distance
  20627. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20628. * @return This mesh (for chaining)
  20629. */
  20630. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20631. /**
  20632. * Gets the mesh internal Geometry object
  20633. */
  20634. readonly geometry: Nullable<Geometry>;
  20635. /**
  20636. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20637. * @returns the total number of vertices
  20638. */
  20639. getTotalVertices(): number;
  20640. /**
  20641. * Returns the content of an associated vertex buffer
  20642. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20643. * - VertexBuffer.PositionKind
  20644. * - VertexBuffer.UVKind
  20645. * - VertexBuffer.UV2Kind
  20646. * - VertexBuffer.UV3Kind
  20647. * - VertexBuffer.UV4Kind
  20648. * - VertexBuffer.UV5Kind
  20649. * - VertexBuffer.UV6Kind
  20650. * - VertexBuffer.ColorKind
  20651. * - VertexBuffer.MatricesIndicesKind
  20652. * - VertexBuffer.MatricesIndicesExtraKind
  20653. * - VertexBuffer.MatricesWeightsKind
  20654. * - VertexBuffer.MatricesWeightsExtraKind
  20655. * @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
  20656. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20657. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20658. */
  20659. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20660. /**
  20661. * Returns the mesh VertexBuffer object from the requested `kind`
  20662. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20663. * - VertexBuffer.PositionKind
  20664. * - VertexBuffer.UVKind
  20665. * - VertexBuffer.UV2Kind
  20666. * - VertexBuffer.UV3Kind
  20667. * - VertexBuffer.UV4Kind
  20668. * - VertexBuffer.UV5Kind
  20669. * - VertexBuffer.UV6Kind
  20670. * - VertexBuffer.ColorKind
  20671. * - VertexBuffer.MatricesIndicesKind
  20672. * - VertexBuffer.MatricesIndicesExtraKind
  20673. * - VertexBuffer.MatricesWeightsKind
  20674. * - VertexBuffer.MatricesWeightsExtraKind
  20675. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20676. */
  20677. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20678. /**
  20679. * Tests if a specific vertex buffer is associated with this mesh
  20680. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20681. * - VertexBuffer.PositionKind
  20682. * - VertexBuffer.UVKind
  20683. * - VertexBuffer.UV2Kind
  20684. * - VertexBuffer.UV3Kind
  20685. * - VertexBuffer.UV4Kind
  20686. * - VertexBuffer.UV5Kind
  20687. * - VertexBuffer.UV6Kind
  20688. * - VertexBuffer.ColorKind
  20689. * - VertexBuffer.MatricesIndicesKind
  20690. * - VertexBuffer.MatricesIndicesExtraKind
  20691. * - VertexBuffer.MatricesWeightsKind
  20692. * - VertexBuffer.MatricesWeightsExtraKind
  20693. * @returns a boolean
  20694. */
  20695. isVerticesDataPresent(kind: string): boolean;
  20696. /**
  20697. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20698. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20699. * - VertexBuffer.PositionKind
  20700. * - VertexBuffer.UVKind
  20701. * - VertexBuffer.UV2Kind
  20702. * - VertexBuffer.UV3Kind
  20703. * - VertexBuffer.UV4Kind
  20704. * - VertexBuffer.UV5Kind
  20705. * - VertexBuffer.UV6Kind
  20706. * - VertexBuffer.ColorKind
  20707. * - VertexBuffer.MatricesIndicesKind
  20708. * - VertexBuffer.MatricesIndicesExtraKind
  20709. * - VertexBuffer.MatricesWeightsKind
  20710. * - VertexBuffer.MatricesWeightsExtraKind
  20711. * @returns a boolean
  20712. */
  20713. isVertexBufferUpdatable(kind: string): boolean;
  20714. /**
  20715. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20716. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20717. * - VertexBuffer.PositionKind
  20718. * - VertexBuffer.UVKind
  20719. * - VertexBuffer.UV2Kind
  20720. * - VertexBuffer.UV3Kind
  20721. * - VertexBuffer.UV4Kind
  20722. * - VertexBuffer.UV5Kind
  20723. * - VertexBuffer.UV6Kind
  20724. * - VertexBuffer.ColorKind
  20725. * - VertexBuffer.MatricesIndicesKind
  20726. * - VertexBuffer.MatricesIndicesExtraKind
  20727. * - VertexBuffer.MatricesWeightsKind
  20728. * - VertexBuffer.MatricesWeightsExtraKind
  20729. * @returns an array of strings
  20730. */
  20731. getVerticesDataKinds(): string[];
  20732. /**
  20733. * Returns a positive integer : the total number of indices in this mesh geometry.
  20734. * @returns the numner of indices or zero if the mesh has no geometry.
  20735. */
  20736. getTotalIndices(): number;
  20737. /**
  20738. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20739. * @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.
  20740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20741. * @returns the indices array or an empty array if the mesh has no geometry
  20742. */
  20743. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20744. readonly isBlocked: boolean;
  20745. /**
  20746. * Determine if the current mesh is ready to be rendered
  20747. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20748. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20749. * @returns true if all associated assets are ready (material, textures, shaders)
  20750. */
  20751. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20752. /**
  20753. * 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.
  20754. */
  20755. readonly areNormalsFrozen: boolean;
  20756. /**
  20757. * 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.
  20758. * @returns the current mesh
  20759. */
  20760. freezeNormals(): Mesh;
  20761. /**
  20762. * 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
  20763. * @returns the current mesh
  20764. */
  20765. unfreezeNormals(): Mesh;
  20766. /**
  20767. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20768. */
  20769. overridenInstanceCount: number;
  20770. /** @hidden */
  20771. _preActivate(): Mesh;
  20772. /** @hidden */
  20773. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20774. /** @hidden */
  20775. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20776. /**
  20777. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20778. * This means the mesh underlying bounding box and sphere are recomputed.
  20779. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20780. * @returns the current mesh
  20781. */
  20782. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20783. /** @hidden */
  20784. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20785. /**
  20786. * This function will subdivide the mesh into multiple submeshes
  20787. * @param count defines the expected number of submeshes
  20788. */
  20789. subdivide(count: number): void;
  20790. /**
  20791. * Copy a FloatArray into a specific associated vertex buffer
  20792. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20793. * - VertexBuffer.PositionKind
  20794. * - VertexBuffer.UVKind
  20795. * - VertexBuffer.UV2Kind
  20796. * - VertexBuffer.UV3Kind
  20797. * - VertexBuffer.UV4Kind
  20798. * - VertexBuffer.UV5Kind
  20799. * - VertexBuffer.UV6Kind
  20800. * - VertexBuffer.ColorKind
  20801. * - VertexBuffer.MatricesIndicesKind
  20802. * - VertexBuffer.MatricesIndicesExtraKind
  20803. * - VertexBuffer.MatricesWeightsKind
  20804. * - VertexBuffer.MatricesWeightsExtraKind
  20805. * @param data defines the data source
  20806. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20807. * @param stride defines the data stride size (can be null)
  20808. * @returns the current mesh
  20809. */
  20810. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20811. /**
  20812. * Flags an associated vertex buffer as updatable
  20813. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20814. * - VertexBuffer.PositionKind
  20815. * - VertexBuffer.UVKind
  20816. * - VertexBuffer.UV2Kind
  20817. * - VertexBuffer.UV3Kind
  20818. * - VertexBuffer.UV4Kind
  20819. * - VertexBuffer.UV5Kind
  20820. * - VertexBuffer.UV6Kind
  20821. * - VertexBuffer.ColorKind
  20822. * - VertexBuffer.MatricesIndicesKind
  20823. * - VertexBuffer.MatricesIndicesExtraKind
  20824. * - VertexBuffer.MatricesWeightsKind
  20825. * - VertexBuffer.MatricesWeightsExtraKind
  20826. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20827. */
  20828. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20829. /**
  20830. * Sets the mesh global Vertex Buffer
  20831. * @param buffer defines the buffer to use
  20832. * @returns the current mesh
  20833. */
  20834. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20835. /**
  20836. * Update a specific associated vertex buffer
  20837. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20838. * - VertexBuffer.PositionKind
  20839. * - VertexBuffer.UVKind
  20840. * - VertexBuffer.UV2Kind
  20841. * - VertexBuffer.UV3Kind
  20842. * - VertexBuffer.UV4Kind
  20843. * - VertexBuffer.UV5Kind
  20844. * - VertexBuffer.UV6Kind
  20845. * - VertexBuffer.ColorKind
  20846. * - VertexBuffer.MatricesIndicesKind
  20847. * - VertexBuffer.MatricesIndicesExtraKind
  20848. * - VertexBuffer.MatricesWeightsKind
  20849. * - VertexBuffer.MatricesWeightsExtraKind
  20850. * @param data defines the data source
  20851. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20852. * @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)
  20853. * @returns the current mesh
  20854. */
  20855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20856. /**
  20857. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20858. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20859. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20860. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20861. * @returns the current mesh
  20862. */
  20863. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20864. /**
  20865. * Creates a un-shared specific occurence of the geometry for the mesh.
  20866. * @returns the current mesh
  20867. */
  20868. makeGeometryUnique(): Mesh;
  20869. /**
  20870. * Set the index buffer of this mesh
  20871. * @param indices defines the source data
  20872. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20873. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20874. * @returns the current mesh
  20875. */
  20876. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20877. /**
  20878. * Update the current index buffer
  20879. * @param indices defines the source data
  20880. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20881. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20882. * @returns the current mesh
  20883. */
  20884. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20885. /**
  20886. * Invert the geometry to move from a right handed system to a left handed one.
  20887. * @returns the current mesh
  20888. */
  20889. toLeftHanded(): Mesh;
  20890. /** @hidden */
  20891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20892. /** @hidden */
  20893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20894. /**
  20895. * Registers for this mesh a javascript function called just before the rendering process
  20896. * @param func defines the function to call before rendering this mesh
  20897. * @returns the current mesh
  20898. */
  20899. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20900. /**
  20901. * Disposes a previously registered javascript function called before the rendering
  20902. * @param func defines the function to remove
  20903. * @returns the current mesh
  20904. */
  20905. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20906. /**
  20907. * Registers for this mesh a javascript function called just after the rendering is complete
  20908. * @param func defines the function to call after rendering this mesh
  20909. * @returns the current mesh
  20910. */
  20911. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20912. /**
  20913. * Disposes a previously registered javascript function called after the rendering.
  20914. * @param func defines the function to remove
  20915. * @returns the current mesh
  20916. */
  20917. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20918. /** @hidden */
  20919. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20920. /** @hidden */
  20921. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20922. /** @hidden */
  20923. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20924. /**
  20925. * 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
  20926. * @param subMesh defines the subMesh to render
  20927. * @param enableAlphaMode defines if alpha mode can be changed
  20928. * @returns the current mesh
  20929. */
  20930. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20931. private _onBeforeDraw;
  20932. /**
  20933. * Renormalize the mesh and patch it up if there are no weights
  20934. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20935. * However in the case of zero weights then we set just a single influence to 1.
  20936. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20937. */
  20938. cleanMatrixWeights(): void;
  20939. private normalizeSkinFourWeights;
  20940. private normalizeSkinWeightsAndExtra;
  20941. /**
  20942. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20943. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20944. * the user know there was an issue with importing the mesh
  20945. * @returns a validation object with skinned, valid and report string
  20946. */
  20947. validateSkinning(): {
  20948. skinned: boolean;
  20949. valid: boolean;
  20950. report: string;
  20951. };
  20952. /** @hidden */
  20953. _checkDelayState(): Mesh;
  20954. private _queueLoad;
  20955. /**
  20956. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20957. * A mesh is in the frustum if its bounding box intersects the frustum
  20958. * @param frustumPlanes defines the frustum to test
  20959. * @returns true if the mesh is in the frustum planes
  20960. */
  20961. isInFrustum(frustumPlanes: Plane[]): boolean;
  20962. /**
  20963. * Sets the mesh material by the material or multiMaterial `id` property
  20964. * @param id is a string identifying the material or the multiMaterial
  20965. * @returns the current mesh
  20966. */
  20967. setMaterialByID(id: string): Mesh;
  20968. /**
  20969. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20970. * @returns an array of IAnimatable
  20971. */
  20972. getAnimatables(): IAnimatable[];
  20973. /**
  20974. * Modifies the mesh geometry according to the passed transformation matrix.
  20975. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20976. * The mesh normals are modified using the same transformation.
  20977. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20978. * @param transform defines the transform matrix to use
  20979. * @see http://doc.babylonjs.com/resources/baking_transformations
  20980. * @returns the current mesh
  20981. */
  20982. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20983. /**
  20984. * Modifies the mesh geometry according to its own current World Matrix.
  20985. * The mesh World Matrix is then reset.
  20986. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20987. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20988. * @see http://doc.babylonjs.com/resources/baking_transformations
  20989. * @returns the current mesh
  20990. */
  20991. bakeCurrentTransformIntoVertices(): Mesh;
  20992. /** @hidden */
  20993. readonly _positions: Nullable<Vector3[]>;
  20994. /** @hidden */
  20995. _resetPointsArrayCache(): Mesh;
  20996. /** @hidden */
  20997. _generatePointsArray(): boolean;
  20998. /**
  20999. * Returns a new Mesh object generated from the current mesh properties.
  21000. * This method must not get confused with createInstance()
  21001. * @param name is a string, the name given to the new mesh
  21002. * @param newParent can be any Node object (default `null`)
  21003. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21004. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21005. * @returns a new mesh
  21006. */
  21007. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21008. /**
  21009. * Releases resources associated with this mesh.
  21010. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21011. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21012. */
  21013. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21014. /**
  21015. * Modifies the mesh geometry according to a displacement map.
  21016. * 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.
  21017. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21018. * @param url is a string, the URL from the image file is to be downloaded.
  21019. * @param minHeight is the lower limit of the displacement.
  21020. * @param maxHeight is the upper limit of the displacement.
  21021. * @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.
  21022. * @param uvOffset is an optional vector2 used to offset UV.
  21023. * @param uvScale is an optional vector2 used to scale UV.
  21024. * @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.
  21025. * @returns the Mesh.
  21026. */
  21027. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21028. /**
  21029. * Modifies the mesh geometry according to a displacementMap buffer.
  21030. * 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.
  21031. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21032. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21033. * @param heightMapWidth is the width of the buffer image.
  21034. * @param heightMapHeight is the height of the buffer image.
  21035. * @param minHeight is the lower limit of the displacement.
  21036. * @param maxHeight is the upper limit of the displacement.
  21037. * @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.
  21038. * @param uvOffset is an optional vector2 used to offset UV.
  21039. * @param uvScale is an optional vector2 used to scale UV.
  21040. * @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.
  21041. * @returns the Mesh.
  21042. */
  21043. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21044. /**
  21045. * Modify the mesh to get a flat shading rendering.
  21046. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21047. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21048. * @returns current mesh
  21049. */
  21050. convertToFlatShadedMesh(): Mesh;
  21051. /**
  21052. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21053. * In other words, more vertices, no more indices and a single bigger VBO.
  21054. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21055. * @returns current mesh
  21056. */
  21057. convertToUnIndexedMesh(): Mesh;
  21058. /**
  21059. * Inverses facet orientations.
  21060. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21061. * @param flipNormals will also inverts the normals
  21062. * @returns current mesh
  21063. */
  21064. flipFaces(flipNormals?: boolean): Mesh;
  21065. /**
  21066. * Increase the number of facets and hence vertices in a mesh
  21067. * Vertex normals are interpolated from existing vertex normals
  21068. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21069. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21070. */
  21071. increaseVertices(numberPerEdge: number): void;
  21072. /**
  21073. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21074. * This will undo any application of covertToFlatShadedMesh
  21075. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21076. */
  21077. forceSharedVertices(): void;
  21078. /** @hidden */
  21079. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21080. /** @hidden */
  21081. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21082. /**
  21083. * Creates a new InstancedMesh object from the mesh model.
  21084. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21085. * @param name defines the name of the new instance
  21086. * @returns a new InstancedMesh
  21087. */
  21088. createInstance(name: string): InstancedMesh;
  21089. /**
  21090. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21091. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21092. * @returns the current mesh
  21093. */
  21094. synchronizeInstances(): Mesh;
  21095. /**
  21096. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21097. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21098. * This should be used together with the simplification to avoid disappearing triangles.
  21099. * @param successCallback an optional success callback to be called after the optimization finished.
  21100. * @returns the current mesh
  21101. */
  21102. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21103. /**
  21104. * Serialize current mesh
  21105. * @param serializationObject defines the object which will receive the serialization data
  21106. */
  21107. serialize(serializationObject: any): void;
  21108. /** @hidden */
  21109. _syncGeometryWithMorphTargetManager(): void;
  21110. /** @hidden */
  21111. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21112. /**
  21113. * Returns a new Mesh object parsed from the source provided.
  21114. * @param parsedMesh is the source
  21115. * @param scene defines the hosting scene
  21116. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21117. * @returns a new Mesh
  21118. */
  21119. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21120. /**
  21121. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21122. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21123. * @param name defines the name of the mesh to create
  21124. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21125. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21126. * @param closePath creates a seam between the first and the last points of each path of the path array
  21127. * @param offset is taken in account only if the `pathArray` is containing a single path
  21128. * @param scene defines the hosting scene
  21129. * @param updatable defines if the mesh must be flagged as updatable
  21130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21131. * @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)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21135. /**
  21136. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21137. * @param name defines the name of the mesh to create
  21138. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21139. * @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
  21140. * @param scene defines the hosting scene
  21141. * @param updatable defines if the mesh must be flagged as updatable
  21142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21143. * @returns a new Mesh
  21144. */
  21145. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21146. /**
  21147. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21148. * @param name defines the name of the mesh to create
  21149. * @param size sets the size (float) of each box side (default 1)
  21150. * @param scene defines the hosting scene
  21151. * @param updatable defines if the mesh must be flagged as updatable
  21152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21153. * @returns a new Mesh
  21154. */
  21155. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21156. /**
  21157. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21158. * @param name defines the name of the mesh to create
  21159. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21160. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21161. * @param scene defines the hosting scene
  21162. * @param updatable defines if the mesh must be flagged as updatable
  21163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21164. * @returns a new Mesh
  21165. */
  21166. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21167. /**
  21168. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21169. * @param name defines the name of the mesh to create
  21170. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21171. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21172. * @param scene defines the hosting scene
  21173. * @returns a new Mesh
  21174. */
  21175. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21176. /**
  21177. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21178. * @param name defines the name of the mesh to create
  21179. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21180. * @param diameterTop set the top cap diameter (floats, default 1)
  21181. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21182. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21183. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21184. * @param scene defines the hosting scene
  21185. * @param updatable defines if the mesh must be flagged as updatable
  21186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21187. * @returns a new Mesh
  21188. */
  21189. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21190. /**
  21191. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21192. * @param name defines the name of the mesh to create
  21193. * @param diameter sets the diameter size (float) of the torus (default 1)
  21194. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21195. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21196. * @param scene defines the hosting scene
  21197. * @param updatable defines if the mesh must be flagged as updatable
  21198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21199. * @returns a new Mesh
  21200. */
  21201. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21202. /**
  21203. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21204. * @param name defines the name of the mesh to create
  21205. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21206. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21207. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21208. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21209. * @param p the number of windings on X axis (positive integers, default 2)
  21210. * @param q the number of windings on Y axis (positive integers, default 3)
  21211. * @param scene defines the hosting scene
  21212. * @param updatable defines if the mesh must be flagged as updatable
  21213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21214. * @returns a new Mesh
  21215. */
  21216. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21217. /**
  21218. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21219. * @param name defines the name of the mesh to create
  21220. * @param points is an array successive Vector3
  21221. * @param scene defines the hosting scene
  21222. * @param updatable defines if the mesh must be flagged as updatable
  21223. * @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).
  21224. * @returns a new Mesh
  21225. */
  21226. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21227. /**
  21228. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21229. * @param name defines the name of the mesh to create
  21230. * @param points is an array successive Vector3
  21231. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21232. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21233. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21234. * @param scene defines the hosting scene
  21235. * @param updatable defines if the mesh must be flagged as updatable
  21236. * @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)
  21237. * @returns a new Mesh
  21238. */
  21239. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21240. /**
  21241. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21242. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21243. * 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.
  21244. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21245. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21246. * Remember you can only change the shape positions, not their number when updating a polygon.
  21247. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21248. * @param name defines the name of the mesh to create
  21249. * @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
  21250. * @param scene defines the hosting scene
  21251. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21252. * @param updatable defines if the mesh must be flagged as updatable
  21253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21254. * @param earcutInjection can be used to inject your own earcut reference
  21255. * @returns a new Mesh
  21256. */
  21257. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21258. /**
  21259. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21261. * @param name defines the name of the mesh to create
  21262. * @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
  21263. * @param depth defines the height of extrusion
  21264. * @param scene defines the hosting scene
  21265. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21266. * @param updatable defines if the mesh must be flagged as updatable
  21267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21268. * @param earcutInjection can be used to inject your own earcut reference
  21269. * @returns a new Mesh
  21270. */
  21271. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21272. /**
  21273. * Creates an extruded shape mesh.
  21274. * 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
  21275. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21276. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21277. * @param name defines the name of the mesh to create
  21278. * @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
  21279. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21280. * @param scale is the value to scale the shape
  21281. * @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
  21282. * @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
  21283. * @param scene defines the hosting scene
  21284. * @param updatable defines if the mesh must be flagged as updatable
  21285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21286. * @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)
  21287. * @returns a new Mesh
  21288. */
  21289. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21290. /**
  21291. * Creates an custom extruded shape mesh.
  21292. * The custom extrusion is a parametric shape.
  21293. * It has no predefined shape. Its final shape will depend on the input parameters.
  21294. * Please consider using the same method from the MeshBuilder class instead
  21295. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21296. * @param name defines the name of the mesh to create
  21297. * @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
  21298. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21299. * @param scaleFunction is a custom Javascript function called on each path point
  21300. * @param rotationFunction is a custom Javascript function called on each path point
  21301. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21302. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21303. * @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
  21304. * @param scene defines the hosting scene
  21305. * @param updatable defines if the mesh must be flagged as updatable
  21306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21307. * @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)
  21308. * @returns a new Mesh
  21309. */
  21310. 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;
  21311. /**
  21312. * Creates lathe mesh.
  21313. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21314. * Please consider using the same method from the MeshBuilder class instead
  21315. * @param name defines the name of the mesh to create
  21316. * @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
  21317. * @param radius is the radius value of the lathe
  21318. * @param tessellation is the side number of the lathe.
  21319. * @param scene defines the hosting scene
  21320. * @param updatable defines if the mesh must be flagged as updatable
  21321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21322. * @returns a new Mesh
  21323. */
  21324. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21325. /**
  21326. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21327. * @param name defines the name of the mesh to create
  21328. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21329. * @param scene defines the hosting scene
  21330. * @param updatable defines if the mesh must be flagged as updatable
  21331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21332. * @returns a new Mesh
  21333. */
  21334. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21335. /**
  21336. * Creates a ground mesh.
  21337. * Please consider using the same method from the MeshBuilder class instead
  21338. * @param name defines the name of the mesh to create
  21339. * @param width set the width of the ground
  21340. * @param height set the height of the ground
  21341. * @param subdivisions sets the number of subdivisions per side
  21342. * @param scene defines the hosting scene
  21343. * @param updatable defines if the mesh must be flagged as updatable
  21344. * @returns a new Mesh
  21345. */
  21346. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21347. /**
  21348. * Creates a tiled ground mesh.
  21349. * Please consider using the same method from the MeshBuilder class instead
  21350. * @param name defines the name of the mesh to create
  21351. * @param xmin set the ground minimum X coordinate
  21352. * @param zmin set the ground minimum Y coordinate
  21353. * @param xmax set the ground maximum X coordinate
  21354. * @param zmax set the ground maximum Z coordinate
  21355. * @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
  21356. * @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
  21357. * @param scene defines the hosting scene
  21358. * @param updatable defines if the mesh must be flagged as updatable
  21359. * @returns a new Mesh
  21360. */
  21361. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21362. w: number;
  21363. h: number;
  21364. }, precision: {
  21365. w: number;
  21366. h: number;
  21367. }, scene: Scene, updatable?: boolean): Mesh;
  21368. /**
  21369. * Creates a ground mesh from a height map.
  21370. * Please consider using the same method from the MeshBuilder class instead
  21371. * @see http://doc.babylonjs.com/babylon101/height_map
  21372. * @param name defines the name of the mesh to create
  21373. * @param url sets the URL of the height map image resource
  21374. * @param width set the ground width size
  21375. * @param height set the ground height size
  21376. * @param subdivisions sets the number of subdivision per side
  21377. * @param minHeight is the minimum altitude on the ground
  21378. * @param maxHeight is the maximum altitude on the ground
  21379. * @param scene defines the hosting scene
  21380. * @param updatable defines if the mesh must be flagged as updatable
  21381. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21382. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21383. * @returns a new Mesh
  21384. */
  21385. 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;
  21386. /**
  21387. * Creates a tube mesh.
  21388. * The tube is a parametric shape.
  21389. * It has no predefined shape. Its final shape will depend on the input parameters.
  21390. * Please consider using the same method from the MeshBuilder class instead
  21391. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21392. * @param name defines the name of the mesh to create
  21393. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21394. * @param radius sets the tube radius size
  21395. * @param tessellation is the number of sides on the tubular surface
  21396. * @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
  21397. * @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
  21398. * @param scene defines the hosting scene
  21399. * @param updatable defines if the mesh must be flagged as updatable
  21400. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21401. * @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)
  21402. * @returns a new Mesh
  21403. */
  21404. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21405. (i: number, distance: number): number;
  21406. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21407. /**
  21408. * Creates a polyhedron mesh.
  21409. * Please consider using the same method from the MeshBuilder class instead.
  21410. * * 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
  21411. * * The parameter `size` (positive float, default 1) sets the polygon size
  21412. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21413. * * 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`
  21414. * * 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
  21415. * * 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)`)
  21416. * * 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
  21417. * * 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
  21418. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21419. * * 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
  21420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21421. * @param name defines the name of the mesh to create
  21422. * @param options defines the options used to create the mesh
  21423. * @param scene defines the hosting scene
  21424. * @returns a new Mesh
  21425. */
  21426. static CreatePolyhedron(name: string, options: {
  21427. type?: number;
  21428. size?: number;
  21429. sizeX?: number;
  21430. sizeY?: number;
  21431. sizeZ?: number;
  21432. custom?: any;
  21433. faceUV?: Vector4[];
  21434. faceColors?: Color4[];
  21435. updatable?: boolean;
  21436. sideOrientation?: number;
  21437. }, scene: Scene): Mesh;
  21438. /**
  21439. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21440. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21441. * * 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`)
  21442. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21443. * * 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
  21444. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21445. * * 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
  21446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21447. * @param name defines the name of the mesh
  21448. * @param options defines the options used to create the mesh
  21449. * @param scene defines the hosting scene
  21450. * @returns a new Mesh
  21451. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21452. */
  21453. static CreateIcoSphere(name: string, options: {
  21454. radius?: number;
  21455. flat?: boolean;
  21456. subdivisions?: number;
  21457. sideOrientation?: number;
  21458. updatable?: boolean;
  21459. }, scene: Scene): Mesh;
  21460. /**
  21461. * Creates a decal mesh.
  21462. * Please consider using the same method from the MeshBuilder class instead.
  21463. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21464. * @param name defines the name of the mesh
  21465. * @param sourceMesh defines the mesh receiving the decal
  21466. * @param position sets the position of the decal in world coordinates
  21467. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21468. * @param size sets the decal scaling
  21469. * @param angle sets the angle to rotate the decal
  21470. * @returns a new Mesh
  21471. */
  21472. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21473. /**
  21474. * Prepare internal position array for software CPU skinning
  21475. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21476. */
  21477. setPositionsForCPUSkinning(): Float32Array;
  21478. /**
  21479. * Prepare internal normal array for software CPU skinning
  21480. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21481. */
  21482. setNormalsForCPUSkinning(): Float32Array;
  21483. /**
  21484. * Updates the vertex buffer by applying transformation from the bones
  21485. * @param skeleton defines the skeleton to apply to current mesh
  21486. * @returns the current mesh
  21487. */
  21488. applySkeleton(skeleton: Skeleton): Mesh;
  21489. /**
  21490. * 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
  21491. * @param meshes defines the list of meshes to scan
  21492. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21493. */
  21494. static MinMax(meshes: AbstractMesh[]): {
  21495. min: Vector3;
  21496. max: Vector3;
  21497. };
  21498. /**
  21499. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21500. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21501. * @returns a vector3
  21502. */
  21503. static Center(meshesOrMinMaxVector: {
  21504. min: Vector3;
  21505. max: Vector3;
  21506. } | AbstractMesh[]): Vector3;
  21507. /**
  21508. * Merge the array of meshes into a single mesh for performance reasons.
  21509. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21510. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21511. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21512. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21513. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21514. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21515. * @returns a new mesh
  21516. */
  21517. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21518. /** @hidden */
  21519. addInstance(instance: InstancedMesh): void;
  21520. /** @hidden */
  21521. removeInstance(instance: InstancedMesh): void;
  21522. }
  21523. }
  21524. declare module BABYLON {
  21525. /**
  21526. * Base class for the main features of a material in Babylon.js
  21527. */
  21528. export class Material implements IAnimatable {
  21529. /**
  21530. * Returns the triangle fill mode
  21531. */
  21532. static readonly TriangleFillMode: number;
  21533. /**
  21534. * Returns the wireframe mode
  21535. */
  21536. static readonly WireFrameFillMode: number;
  21537. /**
  21538. * Returns the point fill mode
  21539. */
  21540. static readonly PointFillMode: number;
  21541. /**
  21542. * Returns the point list draw mode
  21543. */
  21544. static readonly PointListDrawMode: number;
  21545. /**
  21546. * Returns the line list draw mode
  21547. */
  21548. static readonly LineListDrawMode: number;
  21549. /**
  21550. * Returns the line loop draw mode
  21551. */
  21552. static readonly LineLoopDrawMode: number;
  21553. /**
  21554. * Returns the line strip draw mode
  21555. */
  21556. static readonly LineStripDrawMode: number;
  21557. /**
  21558. * Returns the triangle strip draw mode
  21559. */
  21560. static readonly TriangleStripDrawMode: number;
  21561. /**
  21562. * Returns the triangle fan draw mode
  21563. */
  21564. static readonly TriangleFanDrawMode: number;
  21565. /**
  21566. * Stores the clock-wise side orientation
  21567. */
  21568. static readonly ClockWiseSideOrientation: number;
  21569. /**
  21570. * Stores the counter clock-wise side orientation
  21571. */
  21572. static readonly CounterClockWiseSideOrientation: number;
  21573. /**
  21574. * The dirty texture flag value
  21575. */
  21576. static readonly TextureDirtyFlag: number;
  21577. /**
  21578. * The dirty light flag value
  21579. */
  21580. static readonly LightDirtyFlag: number;
  21581. /**
  21582. * The dirty fresnel flag value
  21583. */
  21584. static readonly FresnelDirtyFlag: number;
  21585. /**
  21586. * The dirty attribute flag value
  21587. */
  21588. static readonly AttributesDirtyFlag: number;
  21589. /**
  21590. * The dirty misc flag value
  21591. */
  21592. static readonly MiscDirtyFlag: number;
  21593. /**
  21594. * The all dirty flag value
  21595. */
  21596. static readonly AllDirtyFlag: number;
  21597. /**
  21598. * The ID of the material
  21599. */
  21600. id: string;
  21601. /**
  21602. * Gets or sets the unique id of the material
  21603. */
  21604. uniqueId: number;
  21605. /**
  21606. * The name of the material
  21607. */
  21608. name: string;
  21609. /**
  21610. * Gets or sets user defined metadata
  21611. */
  21612. metadata: any;
  21613. /**
  21614. * For internal use only. Please do not use.
  21615. */
  21616. reservedDataStore: any;
  21617. /**
  21618. * Specifies if the ready state should be checked on each call
  21619. */
  21620. checkReadyOnEveryCall: boolean;
  21621. /**
  21622. * Specifies if the ready state should be checked once
  21623. */
  21624. checkReadyOnlyOnce: boolean;
  21625. /**
  21626. * The state of the material
  21627. */
  21628. state: string;
  21629. /**
  21630. * The alpha value of the material
  21631. */
  21632. protected _alpha: number;
  21633. /**
  21634. * List of inspectable custom properties (used by the Inspector)
  21635. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21636. */
  21637. inspectableCustomProperties: IInspectable[];
  21638. /**
  21639. * Sets the alpha value of the material
  21640. */
  21641. /**
  21642. * Gets the alpha value of the material
  21643. */
  21644. alpha: number;
  21645. /**
  21646. * Specifies if back face culling is enabled
  21647. */
  21648. protected _backFaceCulling: boolean;
  21649. /**
  21650. * Sets the back-face culling state
  21651. */
  21652. /**
  21653. * Gets the back-face culling state
  21654. */
  21655. backFaceCulling: boolean;
  21656. /**
  21657. * Stores the value for side orientation
  21658. */
  21659. sideOrientation: number;
  21660. /**
  21661. * Callback triggered when the material is compiled
  21662. */
  21663. onCompiled: (effect: Effect) => void;
  21664. /**
  21665. * Callback triggered when an error occurs
  21666. */
  21667. onError: (effect: Effect, errors: string) => void;
  21668. /**
  21669. * Callback triggered to get the render target textures
  21670. */
  21671. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21672. /**
  21673. * Gets a boolean indicating that current material needs to register RTT
  21674. */
  21675. readonly hasRenderTargetTextures: boolean;
  21676. /**
  21677. * Specifies if the material should be serialized
  21678. */
  21679. doNotSerialize: boolean;
  21680. /**
  21681. * @hidden
  21682. */
  21683. _storeEffectOnSubMeshes: boolean;
  21684. /**
  21685. * Stores the animations for the material
  21686. */
  21687. animations: Array<Animation>;
  21688. /**
  21689. * An event triggered when the material is disposed
  21690. */
  21691. onDisposeObservable: Observable<Material>;
  21692. /**
  21693. * An observer which watches for dispose events
  21694. */
  21695. private _onDisposeObserver;
  21696. private _onUnBindObservable;
  21697. /**
  21698. * Called during a dispose event
  21699. */
  21700. onDispose: () => void;
  21701. private _onBindObservable;
  21702. /**
  21703. * An event triggered when the material is bound
  21704. */
  21705. readonly onBindObservable: Observable<AbstractMesh>;
  21706. /**
  21707. * An observer which watches for bind events
  21708. */
  21709. private _onBindObserver;
  21710. /**
  21711. * Called during a bind event
  21712. */
  21713. onBind: (Mesh: AbstractMesh) => void;
  21714. /**
  21715. * An event triggered when the material is unbound
  21716. */
  21717. readonly onUnBindObservable: Observable<Material>;
  21718. /**
  21719. * Stores the value of the alpha mode
  21720. */
  21721. private _alphaMode;
  21722. /**
  21723. * Sets the value of the alpha mode.
  21724. *
  21725. * | Value | Type | Description |
  21726. * | --- | --- | --- |
  21727. * | 0 | ALPHA_DISABLE | |
  21728. * | 1 | ALPHA_ADD | |
  21729. * | 2 | ALPHA_COMBINE | |
  21730. * | 3 | ALPHA_SUBTRACT | |
  21731. * | 4 | ALPHA_MULTIPLY | |
  21732. * | 5 | ALPHA_MAXIMIZED | |
  21733. * | 6 | ALPHA_ONEONE | |
  21734. * | 7 | ALPHA_PREMULTIPLIED | |
  21735. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21736. * | 9 | ALPHA_INTERPOLATE | |
  21737. * | 10 | ALPHA_SCREENMODE | |
  21738. *
  21739. */
  21740. /**
  21741. * Gets the value of the alpha mode
  21742. */
  21743. alphaMode: number;
  21744. /**
  21745. * Stores the state of the need depth pre-pass value
  21746. */
  21747. private _needDepthPrePass;
  21748. /**
  21749. * Sets the need depth pre-pass value
  21750. */
  21751. /**
  21752. * Gets the depth pre-pass value
  21753. */
  21754. needDepthPrePass: boolean;
  21755. /**
  21756. * Specifies if depth writing should be disabled
  21757. */
  21758. disableDepthWrite: boolean;
  21759. /**
  21760. * Specifies if depth writing should be forced
  21761. */
  21762. forceDepthWrite: boolean;
  21763. /**
  21764. * Specifies if there should be a separate pass for culling
  21765. */
  21766. separateCullingPass: boolean;
  21767. /**
  21768. * Stores the state specifing if fog should be enabled
  21769. */
  21770. private _fogEnabled;
  21771. /**
  21772. * Sets the state for enabling fog
  21773. */
  21774. /**
  21775. * Gets the value of the fog enabled state
  21776. */
  21777. fogEnabled: boolean;
  21778. /**
  21779. * Stores the size of points
  21780. */
  21781. pointSize: number;
  21782. /**
  21783. * Stores the z offset value
  21784. */
  21785. zOffset: number;
  21786. /**
  21787. * Gets a value specifying if wireframe mode is enabled
  21788. */
  21789. /**
  21790. * Sets the state of wireframe mode
  21791. */
  21792. wireframe: boolean;
  21793. /**
  21794. * Gets the value specifying if point clouds are enabled
  21795. */
  21796. /**
  21797. * Sets the state of point cloud mode
  21798. */
  21799. pointsCloud: boolean;
  21800. /**
  21801. * Gets the material fill mode
  21802. */
  21803. /**
  21804. * Sets the material fill mode
  21805. */
  21806. fillMode: number;
  21807. /**
  21808. * @hidden
  21809. * Stores the effects for the material
  21810. */
  21811. _effect: Nullable<Effect>;
  21812. /**
  21813. * @hidden
  21814. * Specifies if the material was previously ready
  21815. */
  21816. _wasPreviouslyReady: boolean;
  21817. /**
  21818. * Specifies if uniform buffers should be used
  21819. */
  21820. private _useUBO;
  21821. /**
  21822. * Stores a reference to the scene
  21823. */
  21824. private _scene;
  21825. /**
  21826. * Stores the fill mode state
  21827. */
  21828. private _fillMode;
  21829. /**
  21830. * Specifies if the depth write state should be cached
  21831. */
  21832. private _cachedDepthWriteState;
  21833. /**
  21834. * Stores the uniform buffer
  21835. */
  21836. protected _uniformBuffer: UniformBuffer;
  21837. /** @hidden */
  21838. _indexInSceneMaterialArray: number;
  21839. /** @hidden */
  21840. meshMap: Nullable<{
  21841. [id: string]: AbstractMesh | undefined;
  21842. }>;
  21843. /**
  21844. * Creates a material instance
  21845. * @param name defines the name of the material
  21846. * @param scene defines the scene to reference
  21847. * @param doNotAdd specifies if the material should be added to the scene
  21848. */
  21849. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21850. /**
  21851. * Returns a string representation of the current material
  21852. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21853. * @returns a string with material information
  21854. */
  21855. toString(fullDetails?: boolean): string;
  21856. /**
  21857. * Gets the class name of the material
  21858. * @returns a string with the class name of the material
  21859. */
  21860. getClassName(): string;
  21861. /**
  21862. * Specifies if updates for the material been locked
  21863. */
  21864. readonly isFrozen: boolean;
  21865. /**
  21866. * Locks updates for the material
  21867. */
  21868. freeze(): void;
  21869. /**
  21870. * Unlocks updates for the material
  21871. */
  21872. unfreeze(): void;
  21873. /**
  21874. * Specifies if the material is ready to be used
  21875. * @param mesh defines the mesh to check
  21876. * @param useInstances specifies if instances should be used
  21877. * @returns a boolean indicating if the material is ready to be used
  21878. */
  21879. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21880. /**
  21881. * Specifies that the submesh is ready to be used
  21882. * @param mesh defines the mesh to check
  21883. * @param subMesh defines which submesh to check
  21884. * @param useInstances specifies that instances should be used
  21885. * @returns a boolean indicating that the submesh is ready or not
  21886. */
  21887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21888. /**
  21889. * Returns the material effect
  21890. * @returns the effect associated with the material
  21891. */
  21892. getEffect(): Nullable<Effect>;
  21893. /**
  21894. * Returns the current scene
  21895. * @returns a Scene
  21896. */
  21897. getScene(): Scene;
  21898. /**
  21899. * Specifies if the material will require alpha blending
  21900. * @returns a boolean specifying if alpha blending is needed
  21901. */
  21902. needAlphaBlending(): boolean;
  21903. /**
  21904. * Specifies if the mesh will require alpha blending
  21905. * @param mesh defines the mesh to check
  21906. * @returns a boolean specifying if alpha blending is needed for the mesh
  21907. */
  21908. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21909. /**
  21910. * Specifies if this material should be rendered in alpha test mode
  21911. * @returns a boolean specifying if an alpha test is needed.
  21912. */
  21913. needAlphaTesting(): boolean;
  21914. /**
  21915. * Gets the texture used for the alpha test
  21916. * @returns the texture to use for alpha testing
  21917. */
  21918. getAlphaTestTexture(): Nullable<BaseTexture>;
  21919. /**
  21920. * Marks the material to indicate that it needs to be re-calculated
  21921. */
  21922. markDirty(): void;
  21923. /** @hidden */
  21924. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21925. /**
  21926. * Binds the material to the mesh
  21927. * @param world defines the world transformation matrix
  21928. * @param mesh defines the mesh to bind the material to
  21929. */
  21930. bind(world: Matrix, mesh?: Mesh): void;
  21931. /**
  21932. * Binds the submesh to the material
  21933. * @param world defines the world transformation matrix
  21934. * @param mesh defines the mesh containing the submesh
  21935. * @param subMesh defines the submesh to bind the material to
  21936. */
  21937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21938. /**
  21939. * Binds the world matrix to the material
  21940. * @param world defines the world transformation matrix
  21941. */
  21942. bindOnlyWorldMatrix(world: Matrix): void;
  21943. /**
  21944. * Binds the scene's uniform buffer to the effect.
  21945. * @param effect defines the effect to bind to the scene uniform buffer
  21946. * @param sceneUbo defines the uniform buffer storing scene data
  21947. */
  21948. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21949. /**
  21950. * Binds the view matrix to the effect
  21951. * @param effect defines the effect to bind the view matrix to
  21952. */
  21953. bindView(effect: Effect): void;
  21954. /**
  21955. * Binds the view projection matrix to the effect
  21956. * @param effect defines the effect to bind the view projection matrix to
  21957. */
  21958. bindViewProjection(effect: Effect): void;
  21959. /**
  21960. * Specifies if material alpha testing should be turned on for the mesh
  21961. * @param mesh defines the mesh to check
  21962. */
  21963. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21964. /**
  21965. * Processes to execute after binding the material to a mesh
  21966. * @param mesh defines the rendered mesh
  21967. */
  21968. protected _afterBind(mesh?: Mesh): void;
  21969. /**
  21970. * Unbinds the material from the mesh
  21971. */
  21972. unbind(): void;
  21973. /**
  21974. * Gets the active textures from the material
  21975. * @returns an array of textures
  21976. */
  21977. getActiveTextures(): BaseTexture[];
  21978. /**
  21979. * Specifies if the material uses a texture
  21980. * @param texture defines the texture to check against the material
  21981. * @returns a boolean specifying if the material uses the texture
  21982. */
  21983. hasTexture(texture: BaseTexture): boolean;
  21984. /**
  21985. * Makes a duplicate of the material, and gives it a new name
  21986. * @param name defines the new name for the duplicated material
  21987. * @returns the cloned material
  21988. */
  21989. clone(name: string): Nullable<Material>;
  21990. /**
  21991. * Gets the meshes bound to the material
  21992. * @returns an array of meshes bound to the material
  21993. */
  21994. getBindedMeshes(): AbstractMesh[];
  21995. /**
  21996. * Force shader compilation
  21997. * @param mesh defines the mesh associated with this material
  21998. * @param onCompiled defines a function to execute once the material is compiled
  21999. * @param options defines the options to configure the compilation
  22000. */
  22001. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22002. clipPlane: boolean;
  22003. }>): void;
  22004. /**
  22005. * Force shader compilation
  22006. * @param mesh defines the mesh that will use this material
  22007. * @param options defines additional options for compiling the shaders
  22008. * @returns a promise that resolves when the compilation completes
  22009. */
  22010. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22011. clipPlane: boolean;
  22012. }>): Promise<void>;
  22013. private static readonly _ImageProcessingDirtyCallBack;
  22014. private static readonly _TextureDirtyCallBack;
  22015. private static readonly _FresnelDirtyCallBack;
  22016. private static readonly _MiscDirtyCallBack;
  22017. private static readonly _LightsDirtyCallBack;
  22018. private static readonly _AttributeDirtyCallBack;
  22019. private static _FresnelAndMiscDirtyCallBack;
  22020. private static _TextureAndMiscDirtyCallBack;
  22021. private static readonly _DirtyCallbackArray;
  22022. private static readonly _RunDirtyCallBacks;
  22023. /**
  22024. * Marks a define in the material to indicate that it needs to be re-computed
  22025. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22026. */
  22027. markAsDirty(flag: number): void;
  22028. /**
  22029. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22030. * @param func defines a function which checks material defines against the submeshes
  22031. */
  22032. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22033. /**
  22034. * Indicates that image processing needs to be re-calculated for all submeshes
  22035. */
  22036. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22037. /**
  22038. * Indicates that textures need to be re-calculated for all submeshes
  22039. */
  22040. protected _markAllSubMeshesAsTexturesDirty(): void;
  22041. /**
  22042. * Indicates that fresnel needs to be re-calculated for all submeshes
  22043. */
  22044. protected _markAllSubMeshesAsFresnelDirty(): void;
  22045. /**
  22046. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22047. */
  22048. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22049. /**
  22050. * Indicates that lights need to be re-calculated for all submeshes
  22051. */
  22052. protected _markAllSubMeshesAsLightsDirty(): void;
  22053. /**
  22054. * Indicates that attributes need to be re-calculated for all submeshes
  22055. */
  22056. protected _markAllSubMeshesAsAttributesDirty(): void;
  22057. /**
  22058. * Indicates that misc needs to be re-calculated for all submeshes
  22059. */
  22060. protected _markAllSubMeshesAsMiscDirty(): void;
  22061. /**
  22062. * Indicates that textures and misc need to be re-calculated for all submeshes
  22063. */
  22064. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22065. /**
  22066. * Disposes the material
  22067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22070. */
  22071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22072. /** @hidden */
  22073. private releaseVertexArrayObject;
  22074. /**
  22075. * Serializes this material
  22076. * @returns the serialized material object
  22077. */
  22078. serialize(): any;
  22079. /**
  22080. * Creates a material from parsed material data
  22081. * @param parsedMaterial defines parsed material data
  22082. * @param scene defines the hosting scene
  22083. * @param rootUrl defines the root URL to use to load textures
  22084. * @returns a new material
  22085. */
  22086. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22087. }
  22088. }
  22089. declare module BABYLON {
  22090. /**
  22091. * Base class for submeshes
  22092. */
  22093. export class BaseSubMesh {
  22094. /** @hidden */
  22095. _materialDefines: Nullable<MaterialDefines>;
  22096. /** @hidden */
  22097. _materialEffect: Nullable<Effect>;
  22098. /**
  22099. * Gets associated effect
  22100. */
  22101. readonly effect: Nullable<Effect>;
  22102. /**
  22103. * Sets associated effect (effect used to render this submesh)
  22104. * @param effect defines the effect to associate with
  22105. * @param defines defines the set of defines used to compile this effect
  22106. */
  22107. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22108. }
  22109. /**
  22110. * Defines a subdivision inside a mesh
  22111. */
  22112. export class SubMesh extends BaseSubMesh implements ICullable {
  22113. /** the material index to use */
  22114. materialIndex: number;
  22115. /** vertex index start */
  22116. verticesStart: number;
  22117. /** vertices count */
  22118. verticesCount: number;
  22119. /** index start */
  22120. indexStart: number;
  22121. /** indices count */
  22122. indexCount: number;
  22123. /** @hidden */
  22124. _linesIndexCount: number;
  22125. private _mesh;
  22126. private _renderingMesh;
  22127. private _boundingInfo;
  22128. private _linesIndexBuffer;
  22129. /** @hidden */
  22130. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22131. /** @hidden */
  22132. _trianglePlanes: Plane[];
  22133. /** @hidden */
  22134. _lastColliderTransformMatrix: Matrix;
  22135. /** @hidden */
  22136. _renderId: number;
  22137. /** @hidden */
  22138. _alphaIndex: number;
  22139. /** @hidden */
  22140. _distanceToCamera: number;
  22141. /** @hidden */
  22142. _id: number;
  22143. private _currentMaterial;
  22144. /**
  22145. * Add a new submesh to a mesh
  22146. * @param materialIndex defines the material index to use
  22147. * @param verticesStart defines vertex index start
  22148. * @param verticesCount defines vertices count
  22149. * @param indexStart defines index start
  22150. * @param indexCount defines indices count
  22151. * @param mesh defines the parent mesh
  22152. * @param renderingMesh defines an optional rendering mesh
  22153. * @param createBoundingBox defines if bounding box should be created for this submesh
  22154. * @returns the new submesh
  22155. */
  22156. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22157. /**
  22158. * Creates a new submesh
  22159. * @param materialIndex defines the material index to use
  22160. * @param verticesStart defines vertex index start
  22161. * @param verticesCount defines vertices count
  22162. * @param indexStart defines index start
  22163. * @param indexCount defines indices count
  22164. * @param mesh defines the parent mesh
  22165. * @param renderingMesh defines an optional rendering mesh
  22166. * @param createBoundingBox defines if bounding box should be created for this submesh
  22167. */
  22168. constructor(
  22169. /** the material index to use */
  22170. materialIndex: number,
  22171. /** vertex index start */
  22172. verticesStart: number,
  22173. /** vertices count */
  22174. verticesCount: number,
  22175. /** index start */
  22176. indexStart: number,
  22177. /** indices count */
  22178. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22179. /**
  22180. * Returns true if this submesh covers the entire parent mesh
  22181. * @ignorenaming
  22182. */
  22183. readonly IsGlobal: boolean;
  22184. /**
  22185. * Returns the submesh BoudingInfo object
  22186. * @returns current bounding info (or mesh's one if the submesh is global)
  22187. */
  22188. getBoundingInfo(): BoundingInfo;
  22189. /**
  22190. * Sets the submesh BoundingInfo
  22191. * @param boundingInfo defines the new bounding info to use
  22192. * @returns the SubMesh
  22193. */
  22194. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22195. /**
  22196. * Returns the mesh of the current submesh
  22197. * @return the parent mesh
  22198. */
  22199. getMesh(): AbstractMesh;
  22200. /**
  22201. * Returns the rendering mesh of the submesh
  22202. * @returns the rendering mesh (could be different from parent mesh)
  22203. */
  22204. getRenderingMesh(): Mesh;
  22205. /**
  22206. * Returns the submesh material
  22207. * @returns null or the current material
  22208. */
  22209. getMaterial(): Nullable<Material>;
  22210. /**
  22211. * Sets a new updated BoundingInfo object to the submesh
  22212. * @returns the SubMesh
  22213. */
  22214. refreshBoundingInfo(): SubMesh;
  22215. /** @hidden */
  22216. _checkCollision(collider: Collider): boolean;
  22217. /**
  22218. * Updates the submesh BoundingInfo
  22219. * @param world defines the world matrix to use to update the bounding info
  22220. * @returns the submesh
  22221. */
  22222. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22223. /**
  22224. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22225. * @param frustumPlanes defines the frustum planes
  22226. * @returns true if the submesh is intersecting with the frustum
  22227. */
  22228. isInFrustum(frustumPlanes: Plane[]): boolean;
  22229. /**
  22230. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22231. * @param frustumPlanes defines the frustum planes
  22232. * @returns true if the submesh is inside the frustum
  22233. */
  22234. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22235. /**
  22236. * Renders the submesh
  22237. * @param enableAlphaMode defines if alpha needs to be used
  22238. * @returns the submesh
  22239. */
  22240. render(enableAlphaMode: boolean): SubMesh;
  22241. /**
  22242. * @hidden
  22243. */
  22244. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22245. /**
  22246. * Checks if the submesh intersects with a ray
  22247. * @param ray defines the ray to test
  22248. * @returns true is the passed ray intersects the submesh bounding box
  22249. */
  22250. canIntersects(ray: Ray): boolean;
  22251. /**
  22252. * Intersects current submesh with a ray
  22253. * @param ray defines the ray to test
  22254. * @param positions defines mesh's positions array
  22255. * @param indices defines mesh's indices array
  22256. * @param fastCheck defines if only bounding info should be used
  22257. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22258. * @returns intersection info or null if no intersection
  22259. */
  22260. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22261. /** @hidden */
  22262. private _intersectLines;
  22263. /** @hidden */
  22264. private _intersectTriangles;
  22265. /** @hidden */
  22266. _rebuild(): void;
  22267. /**
  22268. * Creates a new submesh from the passed mesh
  22269. * @param newMesh defines the new hosting mesh
  22270. * @param newRenderingMesh defines an optional rendering mesh
  22271. * @returns the new submesh
  22272. */
  22273. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22274. /**
  22275. * Release associated resources
  22276. */
  22277. dispose(): void;
  22278. /**
  22279. * Gets the class name
  22280. * @returns the string "SubMesh".
  22281. */
  22282. getClassName(): string;
  22283. /**
  22284. * Creates a new submesh from indices data
  22285. * @param materialIndex the index of the main mesh material
  22286. * @param startIndex the index where to start the copy in the mesh indices array
  22287. * @param indexCount the number of indices to copy then from the startIndex
  22288. * @param mesh the main mesh to create the submesh from
  22289. * @param renderingMesh the optional rendering mesh
  22290. * @returns a new submesh
  22291. */
  22292. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22293. }
  22294. }
  22295. declare module BABYLON {
  22296. /**
  22297. * Class used to store geometry data (vertex buffers + index buffer)
  22298. */
  22299. export class Geometry implements IGetSetVerticesData {
  22300. /**
  22301. * Gets or sets the ID of the geometry
  22302. */
  22303. id: string;
  22304. /**
  22305. * Gets or sets the unique ID of the geometry
  22306. */
  22307. uniqueId: number;
  22308. /**
  22309. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22310. */
  22311. delayLoadState: number;
  22312. /**
  22313. * Gets the file containing the data to load when running in delay load state
  22314. */
  22315. delayLoadingFile: Nullable<string>;
  22316. /**
  22317. * Callback called when the geometry is updated
  22318. */
  22319. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22320. private _scene;
  22321. private _engine;
  22322. private _meshes;
  22323. private _totalVertices;
  22324. /** @hidden */
  22325. _indices: IndicesArray;
  22326. /** @hidden */
  22327. _vertexBuffers: {
  22328. [key: string]: VertexBuffer;
  22329. };
  22330. private _isDisposed;
  22331. private _extend;
  22332. private _boundingBias;
  22333. /** @hidden */
  22334. _delayInfo: Array<string>;
  22335. private _indexBuffer;
  22336. private _indexBufferIsUpdatable;
  22337. /** @hidden */
  22338. _boundingInfo: Nullable<BoundingInfo>;
  22339. /** @hidden */
  22340. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22341. /** @hidden */
  22342. _softwareSkinningFrameId: number;
  22343. private _vertexArrayObjects;
  22344. private _updatable;
  22345. /** @hidden */
  22346. _positions: Nullable<Vector3[]>;
  22347. /**
  22348. * 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
  22349. */
  22350. /**
  22351. * 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
  22352. */
  22353. boundingBias: Vector2;
  22354. /**
  22355. * Static function used to attach a new empty geometry to a mesh
  22356. * @param mesh defines the mesh to attach the geometry to
  22357. * @returns the new Geometry
  22358. */
  22359. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22360. /**
  22361. * Creates a new geometry
  22362. * @param id defines the unique ID
  22363. * @param scene defines the hosting scene
  22364. * @param vertexData defines the VertexData used to get geometry data
  22365. * @param updatable defines if geometry must be updatable (false by default)
  22366. * @param mesh defines the mesh that will be associated with the geometry
  22367. */
  22368. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22369. /**
  22370. * Gets the current extend of the geometry
  22371. */
  22372. readonly extend: {
  22373. minimum: Vector3;
  22374. maximum: Vector3;
  22375. };
  22376. /**
  22377. * Gets the hosting scene
  22378. * @returns the hosting Scene
  22379. */
  22380. getScene(): Scene;
  22381. /**
  22382. * Gets the hosting engine
  22383. * @returns the hosting Engine
  22384. */
  22385. getEngine(): Engine;
  22386. /**
  22387. * Defines if the geometry is ready to use
  22388. * @returns true if the geometry is ready to be used
  22389. */
  22390. isReady(): boolean;
  22391. /**
  22392. * Gets a value indicating that the geometry should not be serialized
  22393. */
  22394. readonly doNotSerialize: boolean;
  22395. /** @hidden */
  22396. _rebuild(): void;
  22397. /**
  22398. * Affects all geometry data in one call
  22399. * @param vertexData defines the geometry data
  22400. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22401. */
  22402. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22403. /**
  22404. * Set specific vertex data
  22405. * @param kind defines the data kind (Position, normal, etc...)
  22406. * @param data defines the vertex data to use
  22407. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22408. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22409. */
  22410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22411. /**
  22412. * Removes a specific vertex data
  22413. * @param kind defines the data kind (Position, normal, etc...)
  22414. */
  22415. removeVerticesData(kind: string): void;
  22416. /**
  22417. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22418. * @param buffer defines the vertex buffer to use
  22419. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22420. */
  22421. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22422. /**
  22423. * Update a specific vertex buffer
  22424. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22425. * It will do nothing if the buffer is not updatable
  22426. * @param kind defines the data kind (Position, normal, etc...)
  22427. * @param data defines the data to use
  22428. * @param offset defines the offset in the target buffer where to store the data
  22429. * @param useBytes set to true if the offset is in bytes
  22430. */
  22431. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22432. /**
  22433. * Update a specific vertex buffer
  22434. * This function will create a new buffer if the current one is not updatable
  22435. * @param kind defines the data kind (Position, normal, etc...)
  22436. * @param data defines the data to use
  22437. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22438. */
  22439. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22440. private _updateBoundingInfo;
  22441. /** @hidden */
  22442. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22443. /**
  22444. * Gets total number of vertices
  22445. * @returns the total number of vertices
  22446. */
  22447. getTotalVertices(): number;
  22448. /**
  22449. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22450. * @param kind defines the data kind (Position, normal, etc...)
  22451. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22453. * @returns a float array containing vertex data
  22454. */
  22455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22456. /**
  22457. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22458. * @param kind defines the data kind (Position, normal, etc...)
  22459. * @returns true if the vertex buffer with the specified kind is updatable
  22460. */
  22461. isVertexBufferUpdatable(kind: string): boolean;
  22462. /**
  22463. * Gets a specific vertex buffer
  22464. * @param kind defines the data kind (Position, normal, etc...)
  22465. * @returns a VertexBuffer
  22466. */
  22467. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22468. /**
  22469. * Returns all vertex buffers
  22470. * @return an object holding all vertex buffers indexed by kind
  22471. */
  22472. getVertexBuffers(): Nullable<{
  22473. [key: string]: VertexBuffer;
  22474. }>;
  22475. /**
  22476. * Gets a boolean indicating if specific vertex buffer is present
  22477. * @param kind defines the data kind (Position, normal, etc...)
  22478. * @returns true if data is present
  22479. */
  22480. isVerticesDataPresent(kind: string): boolean;
  22481. /**
  22482. * Gets a list of all attached data kinds (Position, normal, etc...)
  22483. * @returns a list of string containing all kinds
  22484. */
  22485. getVerticesDataKinds(): string[];
  22486. /**
  22487. * Update index buffer
  22488. * @param indices defines the indices to store in the index buffer
  22489. * @param offset defines the offset in the target buffer where to store the data
  22490. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22491. */
  22492. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22493. /**
  22494. * Creates a new index buffer
  22495. * @param indices defines the indices to store in the index buffer
  22496. * @param totalVertices defines the total number of vertices (could be null)
  22497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22498. */
  22499. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22500. /**
  22501. * Return the total number of indices
  22502. * @returns the total number of indices
  22503. */
  22504. getTotalIndices(): number;
  22505. /**
  22506. * Gets the index buffer array
  22507. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22508. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22509. * @returns the index buffer array
  22510. */
  22511. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22512. /**
  22513. * Gets the index buffer
  22514. * @return the index buffer
  22515. */
  22516. getIndexBuffer(): Nullable<WebGLBuffer>;
  22517. /** @hidden */
  22518. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22519. /**
  22520. * Release the associated resources for a specific mesh
  22521. * @param mesh defines the source mesh
  22522. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22523. */
  22524. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22525. /**
  22526. * Apply current geometry to a given mesh
  22527. * @param mesh defines the mesh to apply geometry to
  22528. */
  22529. applyToMesh(mesh: Mesh): void;
  22530. private _updateExtend;
  22531. private _applyToMesh;
  22532. private notifyUpdate;
  22533. /**
  22534. * Load the geometry if it was flagged as delay loaded
  22535. * @param scene defines the hosting scene
  22536. * @param onLoaded defines a callback called when the geometry is loaded
  22537. */
  22538. load(scene: Scene, onLoaded?: () => void): void;
  22539. private _queueLoad;
  22540. /**
  22541. * Invert the geometry to move from a right handed system to a left handed one.
  22542. */
  22543. toLeftHanded(): void;
  22544. /** @hidden */
  22545. _resetPointsArrayCache(): void;
  22546. /** @hidden */
  22547. _generatePointsArray(): boolean;
  22548. /**
  22549. * Gets a value indicating if the geometry is disposed
  22550. * @returns true if the geometry was disposed
  22551. */
  22552. isDisposed(): boolean;
  22553. private _disposeVertexArrayObjects;
  22554. /**
  22555. * Free all associated resources
  22556. */
  22557. dispose(): void;
  22558. /**
  22559. * Clone the current geometry into a new geometry
  22560. * @param id defines the unique ID of the new geometry
  22561. * @returns a new geometry object
  22562. */
  22563. copy(id: string): Geometry;
  22564. /**
  22565. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22566. * @return a JSON representation of the current geometry data (without the vertices data)
  22567. */
  22568. serialize(): any;
  22569. private toNumberArray;
  22570. /**
  22571. * Serialize all vertices data into a JSON oject
  22572. * @returns a JSON representation of the current geometry data
  22573. */
  22574. serializeVerticeData(): any;
  22575. /**
  22576. * Extracts a clone of a mesh geometry
  22577. * @param mesh defines the source mesh
  22578. * @param id defines the unique ID of the new geometry object
  22579. * @returns the new geometry object
  22580. */
  22581. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22582. /**
  22583. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22584. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22585. * Be aware Math.random() could cause collisions, but:
  22586. * "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"
  22587. * @returns a string containing a new GUID
  22588. */
  22589. static RandomId(): string;
  22590. /** @hidden */
  22591. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22592. private static _CleanMatricesWeights;
  22593. /**
  22594. * Create a new geometry from persisted data (Using .babylon file format)
  22595. * @param parsedVertexData defines the persisted data
  22596. * @param scene defines the hosting scene
  22597. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22598. * @returns the new geometry object
  22599. */
  22600. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22601. }
  22602. }
  22603. declare module BABYLON {
  22604. /**
  22605. * Define an interface for all classes that will get and set the data on vertices
  22606. */
  22607. export interface IGetSetVerticesData {
  22608. /**
  22609. * Gets a boolean indicating if specific vertex data is present
  22610. * @param kind defines the vertex data kind to use
  22611. * @returns true is data kind is present
  22612. */
  22613. isVerticesDataPresent(kind: string): boolean;
  22614. /**
  22615. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22616. * @param kind defines the data kind (Position, normal, etc...)
  22617. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22618. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22619. * @returns a float array containing vertex data
  22620. */
  22621. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22622. /**
  22623. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22624. * @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.
  22625. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22626. * @returns the indices array or an empty array if the mesh has no geometry
  22627. */
  22628. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22629. /**
  22630. * Set specific vertex data
  22631. * @param kind defines the data kind (Position, normal, etc...)
  22632. * @param data defines the vertex data to use
  22633. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22634. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22635. */
  22636. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22637. /**
  22638. * Update a specific associated vertex buffer
  22639. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22640. * - VertexBuffer.PositionKind
  22641. * - VertexBuffer.UVKind
  22642. * - VertexBuffer.UV2Kind
  22643. * - VertexBuffer.UV3Kind
  22644. * - VertexBuffer.UV4Kind
  22645. * - VertexBuffer.UV5Kind
  22646. * - VertexBuffer.UV6Kind
  22647. * - VertexBuffer.ColorKind
  22648. * - VertexBuffer.MatricesIndicesKind
  22649. * - VertexBuffer.MatricesIndicesExtraKind
  22650. * - VertexBuffer.MatricesWeightsKind
  22651. * - VertexBuffer.MatricesWeightsExtraKind
  22652. * @param data defines the data source
  22653. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22654. * @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)
  22655. */
  22656. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22657. /**
  22658. * Creates a new index buffer
  22659. * @param indices defines the indices to store in the index buffer
  22660. * @param totalVertices defines the total number of vertices (could be null)
  22661. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22662. */
  22663. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22664. }
  22665. /**
  22666. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22667. */
  22668. export class VertexData {
  22669. /**
  22670. * Mesh side orientation : usually the external or front surface
  22671. */
  22672. static readonly FRONTSIDE: number;
  22673. /**
  22674. * Mesh side orientation : usually the internal or back surface
  22675. */
  22676. static readonly BACKSIDE: number;
  22677. /**
  22678. * Mesh side orientation : both internal and external or front and back surfaces
  22679. */
  22680. static readonly DOUBLESIDE: number;
  22681. /**
  22682. * Mesh side orientation : by default, `FRONTSIDE`
  22683. */
  22684. static readonly DEFAULTSIDE: number;
  22685. /**
  22686. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22687. */
  22688. positions: Nullable<FloatArray>;
  22689. /**
  22690. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22691. */
  22692. normals: Nullable<FloatArray>;
  22693. /**
  22694. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22695. */
  22696. tangents: Nullable<FloatArray>;
  22697. /**
  22698. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22699. */
  22700. uvs: Nullable<FloatArray>;
  22701. /**
  22702. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22703. */
  22704. uvs2: Nullable<FloatArray>;
  22705. /**
  22706. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22707. */
  22708. uvs3: Nullable<FloatArray>;
  22709. /**
  22710. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22711. */
  22712. uvs4: Nullable<FloatArray>;
  22713. /**
  22714. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22715. */
  22716. uvs5: Nullable<FloatArray>;
  22717. /**
  22718. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22719. */
  22720. uvs6: Nullable<FloatArray>;
  22721. /**
  22722. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22723. */
  22724. colors: Nullable<FloatArray>;
  22725. /**
  22726. * 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).
  22727. */
  22728. matricesIndices: Nullable<FloatArray>;
  22729. /**
  22730. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22731. */
  22732. matricesWeights: Nullable<FloatArray>;
  22733. /**
  22734. * An array extending the number of possible indices
  22735. */
  22736. matricesIndicesExtra: Nullable<FloatArray>;
  22737. /**
  22738. * An array extending the number of possible weights when the number of indices is extended
  22739. */
  22740. matricesWeightsExtra: Nullable<FloatArray>;
  22741. /**
  22742. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22743. */
  22744. indices: Nullable<IndicesArray>;
  22745. /**
  22746. * Uses the passed data array to set the set the values for the specified kind of data
  22747. * @param data a linear array of floating numbers
  22748. * @param kind the type of data that is being set, eg positions, colors etc
  22749. */
  22750. set(data: FloatArray, kind: string): void;
  22751. /**
  22752. * Associates the vertexData to the passed Mesh.
  22753. * Sets it as updatable or not (default `false`)
  22754. * @param mesh the mesh the vertexData is applied to
  22755. * @param updatable when used and having the value true allows new data to update the vertexData
  22756. * @returns the VertexData
  22757. */
  22758. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22759. /**
  22760. * Associates the vertexData to the passed Geometry.
  22761. * Sets it as updatable or not (default `false`)
  22762. * @param geometry the geometry the vertexData is applied to
  22763. * @param updatable when used and having the value true allows new data to update the vertexData
  22764. * @returns VertexData
  22765. */
  22766. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22767. /**
  22768. * Updates the associated mesh
  22769. * @param mesh the mesh to be updated
  22770. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22771. * @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
  22772. * @returns VertexData
  22773. */
  22774. updateMesh(mesh: Mesh): VertexData;
  22775. /**
  22776. * Updates the associated geometry
  22777. * @param geometry the geometry to be updated
  22778. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22779. * @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
  22780. * @returns VertexData.
  22781. */
  22782. updateGeometry(geometry: Geometry): VertexData;
  22783. private _applyTo;
  22784. private _update;
  22785. /**
  22786. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22787. * @param matrix the transforming matrix
  22788. * @returns the VertexData
  22789. */
  22790. transform(matrix: Matrix): VertexData;
  22791. /**
  22792. * Merges the passed VertexData into the current one
  22793. * @param other the VertexData to be merged into the current one
  22794. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22795. * @returns the modified VertexData
  22796. */
  22797. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22798. private _mergeElement;
  22799. private _validate;
  22800. /**
  22801. * Serializes the VertexData
  22802. * @returns a serialized object
  22803. */
  22804. serialize(): any;
  22805. /**
  22806. * Extracts the vertexData from a mesh
  22807. * @param mesh the mesh from which to extract the VertexData
  22808. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22809. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22810. * @returns the object VertexData associated to the passed mesh
  22811. */
  22812. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22813. /**
  22814. * Extracts the vertexData from the geometry
  22815. * @param geometry the geometry from which to extract the VertexData
  22816. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22817. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22818. * @returns the object VertexData associated to the passed mesh
  22819. */
  22820. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22821. private static _ExtractFrom;
  22822. /**
  22823. * Creates the VertexData for a Ribbon
  22824. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22825. * * pathArray array of paths, each of which an array of successive Vector3
  22826. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22827. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22828. * * 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
  22829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22830. * * 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)
  22831. * * 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)
  22832. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22833. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22834. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22835. * @returns the VertexData of the ribbon
  22836. */
  22837. static CreateRibbon(options: {
  22838. pathArray: Vector3[][];
  22839. closeArray?: boolean;
  22840. closePath?: boolean;
  22841. offset?: number;
  22842. sideOrientation?: number;
  22843. frontUVs?: Vector4;
  22844. backUVs?: Vector4;
  22845. invertUV?: boolean;
  22846. uvs?: Vector2[];
  22847. colors?: Color4[];
  22848. }): VertexData;
  22849. /**
  22850. * Creates the VertexData for a box
  22851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22852. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22853. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22854. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22855. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22856. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22857. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22859. * * 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)
  22860. * * 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)
  22861. * @returns the VertexData of the box
  22862. */
  22863. static CreateBox(options: {
  22864. size?: number;
  22865. width?: number;
  22866. height?: number;
  22867. depth?: number;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. sideOrientation?: number;
  22871. frontUVs?: Vector4;
  22872. backUVs?: Vector4;
  22873. }): VertexData;
  22874. /**
  22875. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22877. * * segments sets the number of horizontal strips optional, default 32
  22878. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22879. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22880. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22881. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22882. * * 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
  22883. * * 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
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the ellipsoid
  22888. */
  22889. static CreateSphere(options: {
  22890. segments?: number;
  22891. diameter?: number;
  22892. diameterX?: number;
  22893. diameterY?: number;
  22894. diameterZ?: number;
  22895. arc?: number;
  22896. slice?: number;
  22897. sideOrientation?: number;
  22898. frontUVs?: Vector4;
  22899. backUVs?: Vector4;
  22900. }): VertexData;
  22901. /**
  22902. * Creates the VertexData for a cylinder, cone or prism
  22903. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22904. * * height sets the height (y direction) of the cylinder, optional, default 2
  22905. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22906. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22907. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22908. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22909. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22910. * * 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
  22911. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22912. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22913. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22914. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22916. * * 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)
  22917. * * 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)
  22918. * @returns the VertexData of the cylinder, cone or prism
  22919. */
  22920. static CreateCylinder(options: {
  22921. height?: number;
  22922. diameterTop?: number;
  22923. diameterBottom?: number;
  22924. diameter?: number;
  22925. tessellation?: number;
  22926. subdivisions?: number;
  22927. arc?: number;
  22928. faceColors?: Color4[];
  22929. faceUV?: Vector4[];
  22930. hasRings?: boolean;
  22931. enclose?: boolean;
  22932. sideOrientation?: number;
  22933. frontUVs?: Vector4;
  22934. backUVs?: Vector4;
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData for a torus
  22938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22939. * * diameter the diameter of the torus, optional default 1
  22940. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22941. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22943. * * 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)
  22944. * * 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)
  22945. * @returns the VertexData of the torus
  22946. */
  22947. static CreateTorus(options: {
  22948. diameter?: number;
  22949. thickness?: number;
  22950. tessellation?: number;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData of the LineSystem
  22957. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22958. * - lines an array of lines, each line being an array of successive Vector3
  22959. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22960. * @returns the VertexData of the LineSystem
  22961. */
  22962. static CreateLineSystem(options: {
  22963. lines: Vector3[][];
  22964. colors?: Nullable<Color4[][]>;
  22965. }): VertexData;
  22966. /**
  22967. * Create the VertexData for a DashedLines
  22968. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22969. * - points an array successive Vector3
  22970. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22971. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22972. * - dashNb the intended total number of dashes, optional, default 200
  22973. * @returns the VertexData for the DashedLines
  22974. */
  22975. static CreateDashedLines(options: {
  22976. points: Vector3[];
  22977. dashSize?: number;
  22978. gapSize?: number;
  22979. dashNb?: number;
  22980. }): VertexData;
  22981. /**
  22982. * Creates the VertexData for a Ground
  22983. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22984. * - width the width (x direction) of the ground, optional, default 1
  22985. * - height the height (z direction) of the ground, optional, default 1
  22986. * - subdivisions the number of subdivisions per side, optional, default 1
  22987. * @returns the VertexData of the Ground
  22988. */
  22989. static CreateGround(options: {
  22990. width?: number;
  22991. height?: number;
  22992. subdivisions?: number;
  22993. subdivisionsX?: number;
  22994. subdivisionsY?: number;
  22995. }): VertexData;
  22996. /**
  22997. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22998. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22999. * * xmin the ground minimum X coordinate, optional, default -1
  23000. * * zmin the ground minimum Z coordinate, optional, default -1
  23001. * * xmax the ground maximum X coordinate, optional, default 1
  23002. * * zmax the ground maximum Z coordinate, optional, default 1
  23003. * * 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}
  23004. * * 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}
  23005. * @returns the VertexData of the TiledGround
  23006. */
  23007. static CreateTiledGround(options: {
  23008. xmin: number;
  23009. zmin: number;
  23010. xmax: number;
  23011. zmax: number;
  23012. subdivisions?: {
  23013. w: number;
  23014. h: number;
  23015. };
  23016. precision?: {
  23017. w: number;
  23018. h: number;
  23019. };
  23020. }): VertexData;
  23021. /**
  23022. * Creates the VertexData of the Ground designed from a heightmap
  23023. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23024. * * width the width (x direction) of the ground
  23025. * * height the height (z direction) of the ground
  23026. * * subdivisions the number of subdivisions per side
  23027. * * minHeight the minimum altitude on the ground, optional, default 0
  23028. * * maxHeight the maximum altitude on the ground, optional default 1
  23029. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23030. * * buffer the array holding the image color data
  23031. * * bufferWidth the width of image
  23032. * * bufferHeight the height of image
  23033. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23034. * @returns the VertexData of the Ground designed from a heightmap
  23035. */
  23036. static CreateGroundFromHeightMap(options: {
  23037. width: number;
  23038. height: number;
  23039. subdivisions: number;
  23040. minHeight: number;
  23041. maxHeight: number;
  23042. colorFilter: Color3;
  23043. buffer: Uint8Array;
  23044. bufferWidth: number;
  23045. bufferHeight: number;
  23046. alphaFilter: number;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a Plane
  23050. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23051. * * size sets the width and height of the plane to the value of size, optional default 1
  23052. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23053. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23055. * * 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)
  23056. * * 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)
  23057. * @returns the VertexData of the box
  23058. */
  23059. static CreatePlane(options: {
  23060. size?: number;
  23061. width?: number;
  23062. height?: number;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData of the Disc or regular Polygon
  23069. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23070. * * radius the radius of the disc, optional default 0.5
  23071. * * tessellation the number of polygon sides, optional, default 64
  23072. * * 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
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * * 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)
  23075. * * 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)
  23076. * @returns the VertexData of the box
  23077. */
  23078. static CreateDisc(options: {
  23079. radius?: number;
  23080. tessellation?: number;
  23081. arc?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23088. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23089. * @param polygon a mesh built from polygonTriangulation.build()
  23090. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23091. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23092. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23093. * @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)
  23094. * @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)
  23095. * @returns the VertexData of the Polygon
  23096. */
  23097. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23098. /**
  23099. * Creates the VertexData of the IcoSphere
  23100. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23101. * * radius the radius of the IcoSphere, optional default 1
  23102. * * radiusX allows stretching in the x direction, optional, default radius
  23103. * * radiusY allows stretching in the y direction, optional, default radius
  23104. * * radiusZ allows stretching in the z direction, optional, default radius
  23105. * * flat when true creates a flat shaded mesh, optional, default true
  23106. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23108. * * 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)
  23109. * * 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)
  23110. * @returns the VertexData of the IcoSphere
  23111. */
  23112. static CreateIcoSphere(options: {
  23113. radius?: number;
  23114. radiusX?: number;
  23115. radiusY?: number;
  23116. radiusZ?: number;
  23117. flat?: boolean;
  23118. subdivisions?: number;
  23119. sideOrientation?: number;
  23120. frontUVs?: Vector4;
  23121. backUVs?: Vector4;
  23122. }): VertexData;
  23123. /**
  23124. * Creates the VertexData for a Polyhedron
  23125. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23126. * * type provided types are:
  23127. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23128. * * 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)
  23129. * * size the size of the IcoSphere, optional default 1
  23130. * * sizeX allows stretching in the x direction, optional, default size
  23131. * * sizeY allows stretching in the y direction, optional, default size
  23132. * * sizeZ allows stretching in the z direction, optional, default size
  23133. * * 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
  23134. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23135. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23136. * * flat when true creates a flat shaded mesh, optional, default true
  23137. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23139. * * 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)
  23140. * * 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)
  23141. * @returns the VertexData of the Polyhedron
  23142. */
  23143. static CreatePolyhedron(options: {
  23144. type?: number;
  23145. size?: number;
  23146. sizeX?: number;
  23147. sizeY?: number;
  23148. sizeZ?: number;
  23149. custom?: any;
  23150. faceUV?: Vector4[];
  23151. faceColors?: Color4[];
  23152. flat?: boolean;
  23153. sideOrientation?: number;
  23154. frontUVs?: Vector4;
  23155. backUVs?: Vector4;
  23156. }): VertexData;
  23157. /**
  23158. * Creates the VertexData for a TorusKnot
  23159. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23160. * * radius the radius of the torus knot, optional, default 2
  23161. * * tube the thickness of the tube, optional, default 0.5
  23162. * * radialSegments the number of sides on each tube segments, optional, default 32
  23163. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23164. * * p the number of windings around the z axis, optional, default 2
  23165. * * q the number of windings around the x axis, optional, default 3
  23166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23167. * * 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)
  23168. * * 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)
  23169. * @returns the VertexData of the Torus Knot
  23170. */
  23171. static CreateTorusKnot(options: {
  23172. radius?: number;
  23173. tube?: number;
  23174. radialSegments?: number;
  23175. tubularSegments?: number;
  23176. p?: number;
  23177. q?: number;
  23178. sideOrientation?: number;
  23179. frontUVs?: Vector4;
  23180. backUVs?: Vector4;
  23181. }): VertexData;
  23182. /**
  23183. * Compute normals for given positions and indices
  23184. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23185. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23186. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23187. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23188. * * facetNormals : optional array of facet normals (vector3)
  23189. * * facetPositions : optional array of facet positions (vector3)
  23190. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23191. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23192. * * bInfo : optional bounding info, required for facetPartitioning computation
  23193. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23194. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23195. * * useRightHandedSystem: optional boolean to for right handed system computation
  23196. * * depthSort : optional boolean to enable the facet depth sort computation
  23197. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23198. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23199. */
  23200. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23201. facetNormals?: any;
  23202. facetPositions?: any;
  23203. facetPartitioning?: any;
  23204. ratio?: number;
  23205. bInfo?: any;
  23206. bbSize?: Vector3;
  23207. subDiv?: any;
  23208. useRightHandedSystem?: boolean;
  23209. depthSort?: boolean;
  23210. distanceTo?: Vector3;
  23211. depthSortedFacets?: any;
  23212. }): void;
  23213. /** @hidden */
  23214. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23215. /**
  23216. * Applies VertexData created from the imported parameters to the geometry
  23217. * @param parsedVertexData the parsed data from an imported file
  23218. * @param geometry the geometry to apply the VertexData to
  23219. */
  23220. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23221. }
  23222. }
  23223. declare module BABYLON {
  23224. /**
  23225. * Class containing static functions to help procedurally build meshes
  23226. */
  23227. export class DiscBuilder {
  23228. /**
  23229. * Creates a plane polygonal mesh. By default, this is a disc
  23230. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23231. * * 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
  23232. * * 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
  23233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23234. * * 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
  23235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23236. * @param name defines the name of the mesh
  23237. * @param options defines the options used to create the mesh
  23238. * @param scene defines the hosting scene
  23239. * @returns the plane polygonal mesh
  23240. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23241. */
  23242. static CreateDisc(name: string, options: {
  23243. radius?: number;
  23244. tessellation?: number;
  23245. arc?: number;
  23246. updatable?: boolean;
  23247. sideOrientation?: number;
  23248. frontUVs?: Vector4;
  23249. backUVs?: Vector4;
  23250. }, scene?: Nullable<Scene>): Mesh;
  23251. }
  23252. }
  23253. declare module BABYLON {
  23254. /**
  23255. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23256. *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.
  23257. * The SPS is also a particle system. It provides some methods to manage the particles.
  23258. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23259. *
  23260. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23261. */
  23262. export class SolidParticleSystem implements IDisposable {
  23263. /**
  23264. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23265. * Example : var p = SPS.particles[i];
  23266. */
  23267. particles: SolidParticle[];
  23268. /**
  23269. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23270. */
  23271. nbParticles: number;
  23272. /**
  23273. * If the particles must ever face the camera (default false). Useful for planar particles.
  23274. */
  23275. billboard: boolean;
  23276. /**
  23277. * Recompute normals when adding a shape
  23278. */
  23279. recomputeNormals: boolean;
  23280. /**
  23281. * This a counter ofr your own usage. It's not set by any SPS functions.
  23282. */
  23283. counter: number;
  23284. /**
  23285. * The SPS name. This name is also given to the underlying mesh.
  23286. */
  23287. name: string;
  23288. /**
  23289. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23290. */
  23291. mesh: Mesh;
  23292. /**
  23293. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23294. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23295. */
  23296. vars: any;
  23297. /**
  23298. * This array is populated when the SPS is set as 'pickable'.
  23299. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23300. * Each element of this array is an object `{idx: int, faceId: int}`.
  23301. * `idx` is the picked particle index in the `SPS.particles` array
  23302. * `faceId` is the picked face index counted within this particle.
  23303. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23304. */
  23305. pickedParticles: {
  23306. idx: number;
  23307. faceId: number;
  23308. }[];
  23309. /**
  23310. * This array is populated when `enableDepthSort` is set to true.
  23311. * Each element of this array is an instance of the class DepthSortedParticle.
  23312. */
  23313. depthSortedParticles: DepthSortedParticle[];
  23314. /**
  23315. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23316. * @hidden
  23317. */
  23318. _bSphereOnly: boolean;
  23319. /**
  23320. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23321. * @hidden
  23322. */
  23323. _bSphereRadiusFactor: number;
  23324. private _scene;
  23325. private _positions;
  23326. private _indices;
  23327. private _normals;
  23328. private _colors;
  23329. private _uvs;
  23330. private _indices32;
  23331. private _positions32;
  23332. private _normals32;
  23333. private _fixedNormal32;
  23334. private _colors32;
  23335. private _uvs32;
  23336. private _index;
  23337. private _updatable;
  23338. private _pickable;
  23339. private _isVisibilityBoxLocked;
  23340. private _alwaysVisible;
  23341. private _depthSort;
  23342. private _shapeCounter;
  23343. private _copy;
  23344. private _color;
  23345. private _computeParticleColor;
  23346. private _computeParticleTexture;
  23347. private _computeParticleRotation;
  23348. private _computeParticleVertex;
  23349. private _computeBoundingBox;
  23350. private _depthSortParticles;
  23351. private _camera;
  23352. private _mustUnrotateFixedNormals;
  23353. private _particlesIntersect;
  23354. private _needs32Bits;
  23355. /**
  23356. * Creates a SPS (Solid Particle System) object.
  23357. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23358. * @param scene (Scene) is the scene in which the SPS is added.
  23359. * @param options defines the options of the sps e.g.
  23360. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23361. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23362. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23363. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23364. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23365. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23366. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23367. */
  23368. constructor(name: string, scene: Scene, options?: {
  23369. updatable?: boolean;
  23370. isPickable?: boolean;
  23371. enableDepthSort?: boolean;
  23372. particleIntersection?: boolean;
  23373. boundingSphereOnly?: boolean;
  23374. bSphereRadiusFactor?: number;
  23375. });
  23376. /**
  23377. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23378. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23379. * @returns the created mesh
  23380. */
  23381. buildMesh(): Mesh;
  23382. /**
  23383. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23384. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23385. * Thus the particles generated from `digest()` have their property `position` set yet.
  23386. * @param mesh ( Mesh ) is the mesh to be digested
  23387. * @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
  23388. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23389. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23390. * @returns the current SPS
  23391. */
  23392. digest(mesh: Mesh, options?: {
  23393. facetNb?: number;
  23394. number?: number;
  23395. delta?: number;
  23396. }): SolidParticleSystem;
  23397. private _unrotateFixedNormals;
  23398. private _resetCopy;
  23399. private _meshBuilder;
  23400. private _posToShape;
  23401. private _uvsToShapeUV;
  23402. private _addParticle;
  23403. /**
  23404. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23405. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23406. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23407. * @param nb (positive integer) the number of particles to be created from this model
  23408. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23409. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23410. * @returns the number of shapes in the system
  23411. */
  23412. addShape(mesh: Mesh, nb: number, options?: {
  23413. positionFunction?: any;
  23414. vertexFunction?: any;
  23415. }): number;
  23416. private _rebuildParticle;
  23417. /**
  23418. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23419. * @returns the SPS.
  23420. */
  23421. rebuildMesh(): SolidParticleSystem;
  23422. /**
  23423. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23424. * This method calls `updateParticle()` for each particle of the SPS.
  23425. * For an animated SPS, it is usually called within the render loop.
  23426. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23427. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23428. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23429. * @returns the SPS.
  23430. */
  23431. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23432. /**
  23433. * Disposes the SPS.
  23434. */
  23435. dispose(): void;
  23436. /**
  23437. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23438. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23439. * @returns the SPS.
  23440. */
  23441. refreshVisibleSize(): SolidParticleSystem;
  23442. /**
  23443. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23444. * @param size the size (float) of the visibility box
  23445. * note : this doesn't lock the SPS mesh bounding box.
  23446. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23447. */
  23448. setVisibilityBox(size: number): void;
  23449. /**
  23450. * Gets whether the SPS as always visible or not
  23451. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23452. */
  23453. /**
  23454. * Sets the SPS as always visible or not
  23455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23456. */
  23457. isAlwaysVisible: boolean;
  23458. /**
  23459. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. */
  23462. /**
  23463. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23464. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23465. */
  23466. isVisibilityBoxLocked: boolean;
  23467. /**
  23468. * Tells to `setParticles()` to compute the particle rotations or not.
  23469. * Default value : true. The SPS is faster when it's set to false.
  23470. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23471. */
  23472. /**
  23473. * Gets if `setParticles()` computes the particle rotations or not.
  23474. * Default value : true. The SPS is faster when it's set to false.
  23475. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23476. */
  23477. computeParticleRotation: boolean;
  23478. /**
  23479. * Tells to `setParticles()` to compute the particle colors or not.
  23480. * Default value : true. The SPS is faster when it's set to false.
  23481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23482. */
  23483. /**
  23484. * Gets if `setParticles()` computes the particle colors or not.
  23485. * Default value : true. The SPS is faster when it's set to false.
  23486. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23487. */
  23488. computeParticleColor: boolean;
  23489. /**
  23490. * Gets if `setParticles()` computes the particle textures or not.
  23491. * Default value : true. The SPS is faster when it's set to false.
  23492. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23493. */
  23494. computeParticleTexture: boolean;
  23495. /**
  23496. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23497. * Default value : false. The SPS is faster when it's set to false.
  23498. * Note : the particle custom vertex positions aren't stored values.
  23499. */
  23500. /**
  23501. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23502. * Default value : false. The SPS is faster when it's set to false.
  23503. * Note : the particle custom vertex positions aren't stored values.
  23504. */
  23505. computeParticleVertex: boolean;
  23506. /**
  23507. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23511. */
  23512. computeBoundingBox: boolean;
  23513. /**
  23514. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23515. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23516. * Default : `true`
  23517. */
  23518. /**
  23519. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23520. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23521. * Default : `true`
  23522. */
  23523. depthSortParticles: boolean;
  23524. /**
  23525. * This function does nothing. It may be overwritten to set all the particle first values.
  23526. * The SPS doesn't call this function, you may have to call it by your own.
  23527. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23528. */
  23529. initParticles(): void;
  23530. /**
  23531. * This function does nothing. It may be overwritten to recycle a particle.
  23532. * The SPS doesn't call this function, you may have to call it by your own.
  23533. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23534. * @param particle The particle to recycle
  23535. * @returns the recycled particle
  23536. */
  23537. recycleParticle(particle: SolidParticle): SolidParticle;
  23538. /**
  23539. * Updates a particle : this function should be overwritten by the user.
  23540. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23541. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23542. * @example : just set a particle position or velocity and recycle conditions
  23543. * @param particle The particle to update
  23544. * @returns the updated particle
  23545. */
  23546. updateParticle(particle: SolidParticle): SolidParticle;
  23547. /**
  23548. * Updates a vertex of a particle : it can be overwritten by the user.
  23549. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23550. * @param particle the current particle
  23551. * @param vertex the current index of the current particle
  23552. * @param pt the index of the current vertex in the particle shape
  23553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23554. * @example : just set a vertex particle position
  23555. * @returns the updated vertex
  23556. */
  23557. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23558. /**
  23559. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23560. * This does nothing and may be overwritten by the user.
  23561. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23562. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23563. * @param update the boolean update value actually passed to setParticles()
  23564. */
  23565. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23566. /**
  23567. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23568. * This will be passed three parameters.
  23569. * This does nothing and may be overwritten by the user.
  23570. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23571. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23572. * @param update the boolean update value actually passed to setParticles()
  23573. */
  23574. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23575. }
  23576. }
  23577. declare module BABYLON {
  23578. /**
  23579. * Represents one particle of a solid particle system.
  23580. */
  23581. export class SolidParticle {
  23582. /**
  23583. * particle global index
  23584. */
  23585. idx: number;
  23586. /**
  23587. * The color of the particle
  23588. */
  23589. color: Nullable<Color4>;
  23590. /**
  23591. * The world space position of the particle.
  23592. */
  23593. position: Vector3;
  23594. /**
  23595. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23596. */
  23597. rotation: Vector3;
  23598. /**
  23599. * The world space rotation quaternion of the particle.
  23600. */
  23601. rotationQuaternion: Nullable<Quaternion>;
  23602. /**
  23603. * The scaling of the particle.
  23604. */
  23605. scaling: Vector3;
  23606. /**
  23607. * The uvs of the particle.
  23608. */
  23609. uvs: Vector4;
  23610. /**
  23611. * The current speed of the particle.
  23612. */
  23613. velocity: Vector3;
  23614. /**
  23615. * The pivot point in the particle local space.
  23616. */
  23617. pivot: Vector3;
  23618. /**
  23619. * Must the particle be translated from its pivot point in its local space ?
  23620. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23621. * Default : false
  23622. */
  23623. translateFromPivot: boolean;
  23624. /**
  23625. * Is the particle active or not ?
  23626. */
  23627. alive: boolean;
  23628. /**
  23629. * Is the particle visible or not ?
  23630. */
  23631. isVisible: boolean;
  23632. /**
  23633. * Index of this particle in the global "positions" array (Internal use)
  23634. * @hidden
  23635. */
  23636. _pos: number;
  23637. /**
  23638. * @hidden Index of this particle in the global "indices" array (Internal use)
  23639. */
  23640. _ind: number;
  23641. /**
  23642. * @hidden ModelShape of this particle (Internal use)
  23643. */
  23644. _model: ModelShape;
  23645. /**
  23646. * ModelShape id of this particle
  23647. */
  23648. shapeId: number;
  23649. /**
  23650. * Index of the particle in its shape id (Internal use)
  23651. */
  23652. idxInShape: number;
  23653. /**
  23654. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23655. */
  23656. _modelBoundingInfo: BoundingInfo;
  23657. /**
  23658. * @hidden Particle BoundingInfo object (Internal use)
  23659. */
  23660. _boundingInfo: BoundingInfo;
  23661. /**
  23662. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23663. */
  23664. _sps: SolidParticleSystem;
  23665. /**
  23666. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23667. */
  23668. _stillInvisible: boolean;
  23669. /**
  23670. * @hidden Last computed particle rotation matrix
  23671. */
  23672. _rotationMatrix: number[];
  23673. /**
  23674. * Parent particle Id, if any.
  23675. * Default null.
  23676. */
  23677. parentId: Nullable<number>;
  23678. /**
  23679. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23680. * The possible values are :
  23681. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23682. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23683. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23684. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23685. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23686. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23687. * */
  23688. cullingStrategy: number;
  23689. /**
  23690. * @hidden Internal global position in the SPS.
  23691. */
  23692. _globalPosition: Vector3;
  23693. /**
  23694. * Creates a Solid Particle object.
  23695. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23696. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23697. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23698. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23699. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23700. * @param shapeId (integer) is the model shape identifier in the SPS.
  23701. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23702. * @param sps defines the sps it is associated to
  23703. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23704. */
  23705. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23706. /**
  23707. * Legacy support, changed scale to scaling
  23708. */
  23709. /**
  23710. * Legacy support, changed scale to scaling
  23711. */
  23712. scale: Vector3;
  23713. /**
  23714. * Legacy support, changed quaternion to rotationQuaternion
  23715. */
  23716. /**
  23717. * Legacy support, changed quaternion to rotationQuaternion
  23718. */
  23719. quaternion: Nullable<Quaternion>;
  23720. /**
  23721. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23722. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23723. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23724. * @returns true if it intersects
  23725. */
  23726. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23727. /**
  23728. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23729. * A particle is in the frustum if its bounding box intersects the frustum
  23730. * @param frustumPlanes defines the frustum to test
  23731. * @returns true if the particle is in the frustum planes
  23732. */
  23733. isInFrustum(frustumPlanes: Plane[]): boolean;
  23734. /**
  23735. * get the rotation matrix of the particle
  23736. * @hidden
  23737. */
  23738. getRotationMatrix(m: Matrix): void;
  23739. }
  23740. /**
  23741. * Represents the shape of the model used by one particle of a solid particle system.
  23742. * SPS internal tool, don't use it manually.
  23743. */
  23744. export class ModelShape {
  23745. /**
  23746. * The shape id
  23747. * @hidden
  23748. */
  23749. shapeID: number;
  23750. /**
  23751. * flat array of model positions (internal use)
  23752. * @hidden
  23753. */
  23754. _shape: Vector3[];
  23755. /**
  23756. * flat array of model UVs (internal use)
  23757. * @hidden
  23758. */
  23759. _shapeUV: number[];
  23760. /**
  23761. * length of the shape in the model indices array (internal use)
  23762. * @hidden
  23763. */
  23764. _indicesLength: number;
  23765. /**
  23766. * Custom position function (internal use)
  23767. * @hidden
  23768. */
  23769. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23770. /**
  23771. * Custom vertex function (internal use)
  23772. * @hidden
  23773. */
  23774. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23775. /**
  23776. * 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.
  23777. * SPS internal tool, don't use it manually.
  23778. * @hidden
  23779. */
  23780. 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>);
  23781. }
  23782. /**
  23783. * Represents a Depth Sorted Particle in the solid particle system.
  23784. */
  23785. export class DepthSortedParticle {
  23786. /**
  23787. * Index of the particle in the "indices" array
  23788. */
  23789. ind: number;
  23790. /**
  23791. * Length of the particle shape in the "indices" array
  23792. */
  23793. indicesLength: number;
  23794. /**
  23795. * Squared distance from the particle to the camera
  23796. */
  23797. sqDistance: number;
  23798. }
  23799. }
  23800. declare module BABYLON {
  23801. /**
  23802. * Class used to store all common mesh properties
  23803. */
  23804. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23805. /** No occlusion */
  23806. static OCCLUSION_TYPE_NONE: number;
  23807. /** Occlusion set to optimisitic */
  23808. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23809. /** Occlusion set to strict */
  23810. static OCCLUSION_TYPE_STRICT: number;
  23811. /** Use an accurante occlusion algorithm */
  23812. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23813. /** Use a conservative occlusion algorithm */
  23814. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23815. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23816. * Test order :
  23817. * Is the bounding sphere outside the frustum ?
  23818. * If not, are the bounding box vertices outside the frustum ?
  23819. * It not, then the cullable object is in the frustum.
  23820. */
  23821. static readonly CULLINGSTRATEGY_STANDARD: number;
  23822. /** Culling strategy : Bounding Sphere Only.
  23823. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23824. * It's also less accurate than the standard because some not visible objects can still be selected.
  23825. * Test : is the bounding sphere outside the frustum ?
  23826. * If not, then the cullable object is in the frustum.
  23827. */
  23828. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23829. /** Culling strategy : Optimistic Inclusion.
  23830. * This in an inclusion test first, then the standard exclusion test.
  23831. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23832. * 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.
  23833. * Anyway, it's as accurate as the standard strategy.
  23834. * Test :
  23835. * Is the cullable object bounding sphere center in the frustum ?
  23836. * If not, apply the default culling strategy.
  23837. */
  23838. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23839. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23840. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23841. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23842. * 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.
  23843. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23844. * Test :
  23845. * Is the cullable object bounding sphere center in the frustum ?
  23846. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23847. */
  23848. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23849. /**
  23850. * No billboard
  23851. */
  23852. static readonly BILLBOARDMODE_NONE: number;
  23853. /** Billboard on X axis */
  23854. static readonly BILLBOARDMODE_X: number;
  23855. /** Billboard on Y axis */
  23856. static readonly BILLBOARDMODE_Y: number;
  23857. /** Billboard on Z axis */
  23858. static readonly BILLBOARDMODE_Z: number;
  23859. /** Billboard on all axes */
  23860. static readonly BILLBOARDMODE_ALL: number;
  23861. private _facetData;
  23862. /**
  23863. * The culling strategy to use to check whether the mesh must be rendered or not.
  23864. * This value can be changed at any time and will be used on the next render mesh selection.
  23865. * The possible values are :
  23866. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23867. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23868. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23869. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23870. * Please read each static variable documentation to get details about the culling process.
  23871. * */
  23872. cullingStrategy: number;
  23873. /**
  23874. * Gets the number of facets in the mesh
  23875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23876. */
  23877. readonly facetNb: number;
  23878. /**
  23879. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23881. */
  23882. partitioningSubdivisions: number;
  23883. /**
  23884. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23885. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23887. */
  23888. partitioningBBoxRatio: number;
  23889. /**
  23890. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23891. * Works only for updatable meshes.
  23892. * Doesn't work with multi-materials
  23893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23894. */
  23895. mustDepthSortFacets: boolean;
  23896. /**
  23897. * The location (Vector3) where the facet depth sort must be computed from.
  23898. * By default, the active camera position.
  23899. * Used only when facet depth sort is enabled
  23900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23901. */
  23902. facetDepthSortFrom: Vector3;
  23903. /**
  23904. * gets a boolean indicating if facetData is enabled
  23905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23906. */
  23907. readonly isFacetDataEnabled: boolean;
  23908. /** @hidden */
  23909. _updateNonUniformScalingState(value: boolean): boolean;
  23910. /**
  23911. * An event triggered when this mesh collides with another one
  23912. */
  23913. onCollideObservable: Observable<AbstractMesh>;
  23914. private _onCollideObserver;
  23915. /** Set a function to call when this mesh collides with another one */
  23916. onCollide: () => void;
  23917. /**
  23918. * An event triggered when the collision's position changes
  23919. */
  23920. onCollisionPositionChangeObservable: Observable<Vector3>;
  23921. private _onCollisionPositionChangeObserver;
  23922. /** Set a function to call when the collision's position changes */
  23923. onCollisionPositionChange: () => void;
  23924. /**
  23925. * An event triggered when material is changed
  23926. */
  23927. onMaterialChangedObservable: Observable<AbstractMesh>;
  23928. /**
  23929. * Gets or sets the orientation for POV movement & rotation
  23930. */
  23931. definedFacingForward: boolean;
  23932. /** @hidden */
  23933. _occlusionQuery: Nullable<WebGLQuery>;
  23934. private _visibility;
  23935. /**
  23936. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23937. */
  23938. /**
  23939. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23940. */
  23941. visibility: number;
  23942. /** Gets or sets the alpha index used to sort transparent meshes
  23943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23944. */
  23945. alphaIndex: number;
  23946. /**
  23947. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23948. */
  23949. isVisible: boolean;
  23950. /**
  23951. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23952. */
  23953. isPickable: boolean;
  23954. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23955. showSubMeshesBoundingBox: boolean;
  23956. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23958. */
  23959. isBlocker: boolean;
  23960. /**
  23961. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23962. */
  23963. enablePointerMoveEvents: boolean;
  23964. /**
  23965. * Specifies the rendering group id for this mesh (0 by default)
  23966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23967. */
  23968. renderingGroupId: number;
  23969. private _material;
  23970. /** Gets or sets current material */
  23971. material: Nullable<Material>;
  23972. private _receiveShadows;
  23973. /**
  23974. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23975. * @see http://doc.babylonjs.com/babylon101/shadows
  23976. */
  23977. receiveShadows: boolean;
  23978. /** Defines color to use when rendering outline */
  23979. outlineColor: Color3;
  23980. /** Define width to use when rendering outline */
  23981. outlineWidth: number;
  23982. /** Defines color to use when rendering overlay */
  23983. overlayColor: Color3;
  23984. /** Defines alpha to use when rendering overlay */
  23985. overlayAlpha: number;
  23986. private _hasVertexAlpha;
  23987. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23988. hasVertexAlpha: boolean;
  23989. private _useVertexColors;
  23990. /** 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) */
  23991. useVertexColors: boolean;
  23992. private _computeBonesUsingShaders;
  23993. /**
  23994. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23995. */
  23996. computeBonesUsingShaders: boolean;
  23997. private _numBoneInfluencers;
  23998. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23999. numBoneInfluencers: number;
  24000. private _applyFog;
  24001. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24002. applyFog: boolean;
  24003. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24004. useOctreeForRenderingSelection: boolean;
  24005. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24006. useOctreeForPicking: boolean;
  24007. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24008. useOctreeForCollisions: boolean;
  24009. private _layerMask;
  24010. /**
  24011. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24012. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24013. */
  24014. layerMask: number;
  24015. /**
  24016. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24017. */
  24018. alwaysSelectAsActiveMesh: boolean;
  24019. /**
  24020. * Gets or sets the current action manager
  24021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24022. */
  24023. actionManager: Nullable<AbstractActionManager>;
  24024. private _checkCollisions;
  24025. private _collisionMask;
  24026. private _collisionGroup;
  24027. /**
  24028. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24029. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24030. */
  24031. ellipsoid: Vector3;
  24032. /**
  24033. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24034. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24035. */
  24036. ellipsoidOffset: Vector3;
  24037. private _collider;
  24038. private _oldPositionForCollisions;
  24039. private _diffPositionForCollisions;
  24040. /**
  24041. * Gets or sets a collision mask used to mask collisions (default is -1).
  24042. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24043. */
  24044. collisionMask: number;
  24045. /**
  24046. * Gets or sets the current collision group mask (-1 by default).
  24047. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24048. */
  24049. collisionGroup: number;
  24050. /**
  24051. * Defines edge width used when edgesRenderer is enabled
  24052. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24053. */
  24054. edgesWidth: number;
  24055. /**
  24056. * Defines edge color used when edgesRenderer is enabled
  24057. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24058. */
  24059. edgesColor: Color4;
  24060. /** @hidden */
  24061. _edgesRenderer: Nullable<IEdgesRenderer>;
  24062. /** @hidden */
  24063. _masterMesh: Nullable<AbstractMesh>;
  24064. /** @hidden */
  24065. _boundingInfo: Nullable<BoundingInfo>;
  24066. /** @hidden */
  24067. _renderId: number;
  24068. /**
  24069. * Gets or sets the list of subMeshes
  24070. * @see http://doc.babylonjs.com/how_to/multi_materials
  24071. */
  24072. subMeshes: SubMesh[];
  24073. /** @hidden */
  24074. _intersectionsInProgress: AbstractMesh[];
  24075. /** @hidden */
  24076. _unIndexed: boolean;
  24077. /** @hidden */
  24078. _lightSources: Light[];
  24079. /** @hidden */
  24080. readonly _positions: Nullable<Vector3[]>;
  24081. /** @hidden */
  24082. _waitingActions: any;
  24083. /** @hidden */
  24084. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24085. private _skeleton;
  24086. /** @hidden */
  24087. _bonesTransformMatrices: Nullable<Float32Array>;
  24088. /**
  24089. * Gets or sets a skeleton to apply skining transformations
  24090. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24091. */
  24092. skeleton: Nullable<Skeleton>;
  24093. /**
  24094. * An event triggered when the mesh is rebuilt.
  24095. */
  24096. onRebuildObservable: Observable<AbstractMesh>;
  24097. /**
  24098. * Creates a new AbstractMesh
  24099. * @param name defines the name of the mesh
  24100. * @param scene defines the hosting scene
  24101. */
  24102. constructor(name: string, scene?: Nullable<Scene>);
  24103. /**
  24104. * Returns the string "AbstractMesh"
  24105. * @returns "AbstractMesh"
  24106. */
  24107. getClassName(): string;
  24108. /**
  24109. * Gets a string representation of the current mesh
  24110. * @param fullDetails defines a boolean indicating if full details must be included
  24111. * @returns a string representation of the current mesh
  24112. */
  24113. toString(fullDetails?: boolean): string;
  24114. /** @hidden */
  24115. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24116. /** @hidden */
  24117. _rebuild(): void;
  24118. /** @hidden */
  24119. _resyncLightSources(): void;
  24120. /** @hidden */
  24121. _resyncLighSource(light: Light): void;
  24122. /** @hidden */
  24123. _unBindEffect(): void;
  24124. /** @hidden */
  24125. _removeLightSource(light: Light): void;
  24126. private _markSubMeshesAsDirty;
  24127. /** @hidden */
  24128. _markSubMeshesAsLightDirty(): void;
  24129. /** @hidden */
  24130. _markSubMeshesAsAttributesDirty(): void;
  24131. /** @hidden */
  24132. _markSubMeshesAsMiscDirty(): void;
  24133. /**
  24134. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24135. */
  24136. scaling: Vector3;
  24137. /**
  24138. * Returns true if the mesh is blocked. Implemented by child classes
  24139. */
  24140. readonly isBlocked: boolean;
  24141. /**
  24142. * Returns the mesh itself by default. Implemented by child classes
  24143. * @param camera defines the camera to use to pick the right LOD level
  24144. * @returns the currentAbstractMesh
  24145. */
  24146. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24147. /**
  24148. * Returns 0 by default. Implemented by child classes
  24149. * @returns an integer
  24150. */
  24151. getTotalVertices(): number;
  24152. /**
  24153. * Returns a positive integer : the total number of indices in this mesh geometry.
  24154. * @returns the numner of indices or zero if the mesh has no geometry.
  24155. */
  24156. getTotalIndices(): number;
  24157. /**
  24158. * Returns null by default. Implemented by child classes
  24159. * @returns null
  24160. */
  24161. getIndices(): Nullable<IndicesArray>;
  24162. /**
  24163. * Returns the array of the requested vertex data kind. Implemented by child classes
  24164. * @param kind defines the vertex data kind to use
  24165. * @returns null
  24166. */
  24167. getVerticesData(kind: string): Nullable<FloatArray>;
  24168. /**
  24169. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24170. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24171. * Note that a new underlying VertexBuffer object is created each call.
  24172. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24173. * @param kind defines vertex data kind:
  24174. * * VertexBuffer.PositionKind
  24175. * * VertexBuffer.UVKind
  24176. * * VertexBuffer.UV2Kind
  24177. * * VertexBuffer.UV3Kind
  24178. * * VertexBuffer.UV4Kind
  24179. * * VertexBuffer.UV5Kind
  24180. * * VertexBuffer.UV6Kind
  24181. * * VertexBuffer.ColorKind
  24182. * * VertexBuffer.MatricesIndicesKind
  24183. * * VertexBuffer.MatricesIndicesExtraKind
  24184. * * VertexBuffer.MatricesWeightsKind
  24185. * * VertexBuffer.MatricesWeightsExtraKind
  24186. * @param data defines the data source
  24187. * @param updatable defines if the data must be flagged as updatable (or static)
  24188. * @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
  24189. * @returns the current mesh
  24190. */
  24191. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24192. /**
  24193. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24194. * If the mesh has no geometry, it is simply returned as it is.
  24195. * @param kind defines vertex data kind:
  24196. * * VertexBuffer.PositionKind
  24197. * * VertexBuffer.UVKind
  24198. * * VertexBuffer.UV2Kind
  24199. * * VertexBuffer.UV3Kind
  24200. * * VertexBuffer.UV4Kind
  24201. * * VertexBuffer.UV5Kind
  24202. * * VertexBuffer.UV6Kind
  24203. * * VertexBuffer.ColorKind
  24204. * * VertexBuffer.MatricesIndicesKind
  24205. * * VertexBuffer.MatricesIndicesExtraKind
  24206. * * VertexBuffer.MatricesWeightsKind
  24207. * * VertexBuffer.MatricesWeightsExtraKind
  24208. * @param data defines the data source
  24209. * @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
  24210. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24211. * @returns the current mesh
  24212. */
  24213. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24214. /**
  24215. * Sets the mesh indices,
  24216. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24217. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24218. * @param totalVertices Defines the total number of vertices
  24219. * @returns the current mesh
  24220. */
  24221. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24222. /**
  24223. * Gets a boolean indicating if specific vertex data is present
  24224. * @param kind defines the vertex data kind to use
  24225. * @returns true is data kind is present
  24226. */
  24227. isVerticesDataPresent(kind: string): boolean;
  24228. /**
  24229. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24230. * @returns a BoundingInfo
  24231. */
  24232. getBoundingInfo(): BoundingInfo;
  24233. /**
  24234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24237. * @returns the current mesh
  24238. */
  24239. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24240. /**
  24241. * Overwrite the current bounding info
  24242. * @param boundingInfo defines the new bounding info
  24243. * @returns the current mesh
  24244. */
  24245. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24246. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24247. readonly useBones: boolean;
  24248. /** @hidden */
  24249. _preActivate(): void;
  24250. /** @hidden */
  24251. _preActivateForIntermediateRendering(renderId: number): void;
  24252. /** @hidden */
  24253. _activate(renderId: number): void;
  24254. /**
  24255. * Gets the current world matrix
  24256. * @returns a Matrix
  24257. */
  24258. getWorldMatrix(): Matrix;
  24259. /** @hidden */
  24260. _getWorldMatrixDeterminant(): number;
  24261. /**
  24262. * Perform relative position change from the point of view of behind the front of the mesh.
  24263. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24264. * Supports definition of mesh facing forward or backward
  24265. * @param amountRight defines the distance on the right axis
  24266. * @param amountUp defines the distance on the up axis
  24267. * @param amountForward defines the distance on the forward axis
  24268. * @returns the current mesh
  24269. */
  24270. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24271. /**
  24272. * Calculate relative position change from the point of view of behind the front of the mesh.
  24273. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24274. * Supports definition of mesh facing forward or backward
  24275. * @param amountRight defines the distance on the right axis
  24276. * @param amountUp defines the distance on the up axis
  24277. * @param amountForward defines the distance on the forward axis
  24278. * @returns the new displacement vector
  24279. */
  24280. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24281. /**
  24282. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24283. * Supports definition of mesh facing forward or backward
  24284. * @param flipBack defines the flip
  24285. * @param twirlClockwise defines the twirl
  24286. * @param tiltRight defines the tilt
  24287. * @returns the current mesh
  24288. */
  24289. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24290. /**
  24291. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24292. * Supports definition of mesh facing forward or backward.
  24293. * @param flipBack defines the flip
  24294. * @param twirlClockwise defines the twirl
  24295. * @param tiltRight defines the tilt
  24296. * @returns the new rotation vector
  24297. */
  24298. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24299. /**
  24300. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24301. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24302. * @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
  24303. * @returns the new bounding vectors
  24304. */
  24305. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24306. min: Vector3;
  24307. max: Vector3;
  24308. };
  24309. /**
  24310. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24311. * This means the mesh underlying bounding box and sphere are recomputed.
  24312. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24313. * @returns the current mesh
  24314. */
  24315. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24316. /** @hidden */
  24317. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24318. /** @hidden */
  24319. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24320. /** @hidden */
  24321. _updateBoundingInfo(): AbstractMesh;
  24322. /** @hidden */
  24323. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24324. /** @hidden */
  24325. protected _afterComputeWorldMatrix(): void;
  24326. /** @hidden */
  24327. readonly _effectiveMesh: AbstractMesh;
  24328. /**
  24329. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24330. * A mesh is in the frustum if its bounding box intersects the frustum
  24331. * @param frustumPlanes defines the frustum to test
  24332. * @returns true if the mesh is in the frustum planes
  24333. */
  24334. isInFrustum(frustumPlanes: Plane[]): boolean;
  24335. /**
  24336. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24337. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24338. * @param frustumPlanes defines the frustum to test
  24339. * @returns true if the mesh is completely in the frustum planes
  24340. */
  24341. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24342. /**
  24343. * True if the mesh intersects another mesh or a SolidParticle object
  24344. * @param mesh defines a target mesh or SolidParticle to test
  24345. * @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)
  24346. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24347. * @returns true if there is an intersection
  24348. */
  24349. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24350. /**
  24351. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24352. * @param point defines the point to test
  24353. * @returns true if there is an intersection
  24354. */
  24355. intersectsPoint(point: Vector3): boolean;
  24356. /**
  24357. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24359. */
  24360. checkCollisions: boolean;
  24361. /**
  24362. * Gets Collider object used to compute collisions (not physics)
  24363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24364. */
  24365. readonly collider: Collider;
  24366. /**
  24367. * Move the mesh using collision engine
  24368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24369. * @param displacement defines the requested displacement vector
  24370. * @returns the current mesh
  24371. */
  24372. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24373. private _onCollisionPositionChange;
  24374. /** @hidden */
  24375. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24376. /** @hidden */
  24377. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24378. /** @hidden */
  24379. _checkCollision(collider: Collider): AbstractMesh;
  24380. /** @hidden */
  24381. _generatePointsArray(): boolean;
  24382. /**
  24383. * Checks if the passed Ray intersects with the mesh
  24384. * @param ray defines the ray to use
  24385. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24387. * @returns the picking info
  24388. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24389. */
  24390. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24391. /**
  24392. * Clones the current mesh
  24393. * @param name defines the mesh name
  24394. * @param newParent defines the new mesh parent
  24395. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24396. * @returns the new mesh
  24397. */
  24398. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24399. /**
  24400. * Disposes all the submeshes of the current meshnp
  24401. * @returns the current mesh
  24402. */
  24403. releaseSubMeshes(): AbstractMesh;
  24404. /**
  24405. * Releases resources associated with this abstract mesh.
  24406. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24407. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24408. */
  24409. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24410. /**
  24411. * Adds the passed mesh as a child to the current mesh
  24412. * @param mesh defines the child mesh
  24413. * @returns the current mesh
  24414. */
  24415. addChild(mesh: AbstractMesh): AbstractMesh;
  24416. /**
  24417. * Removes the passed mesh from the current mesh children list
  24418. * @param mesh defines the child mesh
  24419. * @returns the current mesh
  24420. */
  24421. removeChild(mesh: AbstractMesh): AbstractMesh;
  24422. /** @hidden */
  24423. private _initFacetData;
  24424. /**
  24425. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24426. * This method can be called within the render loop.
  24427. * 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
  24428. * @returns the current mesh
  24429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24430. */
  24431. updateFacetData(): AbstractMesh;
  24432. /**
  24433. * Returns the facetLocalNormals array.
  24434. * The normals are expressed in the mesh local spac
  24435. * @returns an array of Vector3
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24437. */
  24438. getFacetLocalNormals(): Vector3[];
  24439. /**
  24440. * Returns the facetLocalPositions array.
  24441. * The facet positions are expressed in the mesh local space
  24442. * @returns an array of Vector3
  24443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24444. */
  24445. getFacetLocalPositions(): Vector3[];
  24446. /**
  24447. * Returns the facetLocalPartioning array
  24448. * @returns an array of array of numbers
  24449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24450. */
  24451. getFacetLocalPartitioning(): number[][];
  24452. /**
  24453. * Returns the i-th facet position in the world system.
  24454. * This method allocates a new Vector3 per call
  24455. * @param i defines the facet index
  24456. * @returns a new Vector3
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24458. */
  24459. getFacetPosition(i: number): Vector3;
  24460. /**
  24461. * Sets the reference Vector3 with the i-th facet position in the world system
  24462. * @param i defines the facet index
  24463. * @param ref defines the target vector
  24464. * @returns the current mesh
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24466. */
  24467. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24468. /**
  24469. * Returns the i-th facet normal in the world system.
  24470. * This method allocates a new Vector3 per call
  24471. * @param i defines the facet index
  24472. * @returns a new Vector3
  24473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24474. */
  24475. getFacetNormal(i: number): Vector3;
  24476. /**
  24477. * Sets the reference Vector3 with the i-th facet normal in the world system
  24478. * @param i defines the facet index
  24479. * @param ref defines the target vector
  24480. * @returns the current mesh
  24481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24482. */
  24483. getFacetNormalToRef(i: number, ref: Vector3): this;
  24484. /**
  24485. * 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)
  24486. * @param x defines x coordinate
  24487. * @param y defines y coordinate
  24488. * @param z defines z coordinate
  24489. * @returns the array of facet indexes
  24490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24491. */
  24492. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24493. /**
  24494. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24495. * @param projected sets as the (x,y,z) world projection on the facet
  24496. * @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
  24497. * @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
  24498. * @param x defines x coordinate
  24499. * @param y defines y coordinate
  24500. * @param z defines z coordinate
  24501. * @returns the face index if found (or null instead)
  24502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24503. */
  24504. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24505. /**
  24506. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24507. * @param projected sets as the (x,y,z) local projection on the facet
  24508. * @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
  24509. * @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
  24510. * @param x defines x coordinate
  24511. * @param y defines y coordinate
  24512. * @param z defines z coordinate
  24513. * @returns the face index if found (or null instead)
  24514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24515. */
  24516. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24517. /**
  24518. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24519. * @returns the parameters
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24521. */
  24522. getFacetDataParameters(): any;
  24523. /**
  24524. * Disables the feature FacetData and frees the related memory
  24525. * @returns the current mesh
  24526. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24527. */
  24528. disableFacetData(): AbstractMesh;
  24529. /**
  24530. * Updates the AbstractMesh indices array
  24531. * @param indices defines the data source
  24532. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24533. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24534. * @returns the current mesh
  24535. */
  24536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24537. /**
  24538. * Creates new normals data for the mesh
  24539. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24540. * @returns the current mesh
  24541. */
  24542. createNormals(updatable: boolean): AbstractMesh;
  24543. /**
  24544. * Align the mesh with a normal
  24545. * @param normal defines the normal to use
  24546. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24547. * @returns the current mesh
  24548. */
  24549. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24550. /** @hidden */
  24551. _checkOcclusionQuery(): boolean;
  24552. }
  24553. }
  24554. declare module BABYLON {
  24555. /**
  24556. * Interface used to define ActionEvent
  24557. */
  24558. export interface IActionEvent {
  24559. /** The mesh or sprite that triggered the action */
  24560. source: any;
  24561. /** The X mouse cursor position at the time of the event */
  24562. pointerX: number;
  24563. /** The Y mouse cursor position at the time of the event */
  24564. pointerY: number;
  24565. /** The mesh that is currently pointed at (can be null) */
  24566. meshUnderPointer: Nullable<AbstractMesh>;
  24567. /** the original (browser) event that triggered the ActionEvent */
  24568. sourceEvent?: any;
  24569. /** additional data for the event */
  24570. additionalData?: any;
  24571. }
  24572. /**
  24573. * ActionEvent is the event being sent when an action is triggered.
  24574. */
  24575. export class ActionEvent implements IActionEvent {
  24576. /** The mesh or sprite that triggered the action */
  24577. source: any;
  24578. /** The X mouse cursor position at the time of the event */
  24579. pointerX: number;
  24580. /** The Y mouse cursor position at the time of the event */
  24581. pointerY: number;
  24582. /** The mesh that is currently pointed at (can be null) */
  24583. meshUnderPointer: Nullable<AbstractMesh>;
  24584. /** the original (browser) event that triggered the ActionEvent */
  24585. sourceEvent?: any;
  24586. /** additional data for the event */
  24587. additionalData?: any;
  24588. /**
  24589. * Creates a new ActionEvent
  24590. * @param source The mesh or sprite that triggered the action
  24591. * @param pointerX The X mouse cursor position at the time of the event
  24592. * @param pointerY The Y mouse cursor position at the time of the event
  24593. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24594. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24595. * @param additionalData additional data for the event
  24596. */
  24597. constructor(
  24598. /** The mesh or sprite that triggered the action */
  24599. source: any,
  24600. /** The X mouse cursor position at the time of the event */
  24601. pointerX: number,
  24602. /** The Y mouse cursor position at the time of the event */
  24603. pointerY: number,
  24604. /** The mesh that is currently pointed at (can be null) */
  24605. meshUnderPointer: Nullable<AbstractMesh>,
  24606. /** the original (browser) event that triggered the ActionEvent */
  24607. sourceEvent?: any,
  24608. /** additional data for the event */
  24609. additionalData?: any);
  24610. /**
  24611. * Helper function to auto-create an ActionEvent from a source mesh.
  24612. * @param source The source mesh that triggered the event
  24613. * @param evt The original (browser) event
  24614. * @param additionalData additional data for the event
  24615. * @returns the new ActionEvent
  24616. */
  24617. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24618. /**
  24619. * Helper function to auto-create an ActionEvent from a source sprite
  24620. * @param source The source sprite that triggered the event
  24621. * @param scene Scene associated with the sprite
  24622. * @param evt The original (browser) event
  24623. * @param additionalData additional data for the event
  24624. * @returns the new ActionEvent
  24625. */
  24626. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24627. /**
  24628. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24629. * @param scene the scene where the event occurred
  24630. * @param evt The original (browser) event
  24631. * @returns the new ActionEvent
  24632. */
  24633. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24634. /**
  24635. * Helper function to auto-create an ActionEvent from a primitive
  24636. * @param prim defines the target primitive
  24637. * @param pointerPos defines the pointer position
  24638. * @param evt The original (browser) event
  24639. * @param additionalData additional data for the event
  24640. * @returns the new ActionEvent
  24641. */
  24642. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24643. }
  24644. }
  24645. declare module BABYLON {
  24646. /**
  24647. * Abstract class used to decouple action Manager from scene and meshes.
  24648. * Do not instantiate.
  24649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24650. */
  24651. export abstract class AbstractActionManager implements IDisposable {
  24652. /** Gets the list of active triggers */
  24653. static Triggers: {
  24654. [key: string]: number;
  24655. };
  24656. /** Gets the cursor to use when hovering items */
  24657. hoverCursor: string;
  24658. /** Gets the list of actions */
  24659. actions: IAction[];
  24660. /**
  24661. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24662. */
  24663. isRecursive: boolean;
  24664. /**
  24665. * Releases all associated resources
  24666. */
  24667. abstract dispose(): void;
  24668. /**
  24669. * Does this action manager has pointer triggers
  24670. */
  24671. abstract readonly hasPointerTriggers: boolean;
  24672. /**
  24673. * Does this action manager has pick triggers
  24674. */
  24675. abstract readonly hasPickTriggers: boolean;
  24676. /**
  24677. * Process a specific trigger
  24678. * @param trigger defines the trigger to process
  24679. * @param evt defines the event details to be processed
  24680. */
  24681. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24682. /**
  24683. * Does this action manager handles actions of any of the given triggers
  24684. * @param triggers defines the triggers to be tested
  24685. * @return a boolean indicating whether one (or more) of the triggers is handled
  24686. */
  24687. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24688. /**
  24689. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24690. * speed.
  24691. * @param triggerA defines the trigger to be tested
  24692. * @param triggerB defines the trigger to be tested
  24693. * @return a boolean indicating whether one (or more) of the triggers is handled
  24694. */
  24695. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24696. /**
  24697. * Does this action manager handles actions of a given trigger
  24698. * @param trigger defines the trigger to be tested
  24699. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24700. * @return whether the trigger is handled
  24701. */
  24702. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24703. /**
  24704. * Serialize this manager to a JSON object
  24705. * @param name defines the property name to store this manager
  24706. * @returns a JSON representation of this manager
  24707. */
  24708. abstract serialize(name: string): any;
  24709. /**
  24710. * Registers an action to this action manager
  24711. * @param action defines the action to be registered
  24712. * @return the action amended (prepared) after registration
  24713. */
  24714. abstract registerAction(action: IAction): Nullable<IAction>;
  24715. /**
  24716. * Unregisters an action to this action manager
  24717. * @param action defines the action to be unregistered
  24718. * @return a boolean indicating whether the action has been unregistered
  24719. */
  24720. abstract unregisterAction(action: IAction): Boolean;
  24721. /**
  24722. * Does exist one action manager with at least one trigger
  24723. **/
  24724. static readonly HasTriggers: boolean;
  24725. /**
  24726. * Does exist one action manager with at least one pick trigger
  24727. **/
  24728. static readonly HasPickTriggers: boolean;
  24729. /**
  24730. * Does exist one action manager that handles actions of a given trigger
  24731. * @param trigger defines the trigger to be tested
  24732. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24733. **/
  24734. static HasSpecificTrigger(trigger: number): boolean;
  24735. }
  24736. }
  24737. declare module BABYLON {
  24738. /**
  24739. * Defines how a node can be built from a string name.
  24740. */
  24741. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24742. /**
  24743. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24744. */
  24745. export class Node implements IBehaviorAware<Node> {
  24746. /** @hidden */
  24747. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24748. private static _NodeConstructors;
  24749. /**
  24750. * Add a new node constructor
  24751. * @param type defines the type name of the node to construct
  24752. * @param constructorFunc defines the constructor function
  24753. */
  24754. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24755. /**
  24756. * Returns a node constructor based on type name
  24757. * @param type defines the type name
  24758. * @param name defines the new node name
  24759. * @param scene defines the hosting scene
  24760. * @param options defines optional options to transmit to constructors
  24761. * @returns the new constructor or null
  24762. */
  24763. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24764. /**
  24765. * Gets or sets the name of the node
  24766. */
  24767. name: string;
  24768. /**
  24769. * Gets or sets the id of the node
  24770. */
  24771. id: string;
  24772. /**
  24773. * Gets or sets the unique id of the node
  24774. */
  24775. uniqueId: number;
  24776. /**
  24777. * Gets or sets a string used to store user defined state for the node
  24778. */
  24779. state: string;
  24780. /**
  24781. * Gets or sets an object used to store user defined information for the node
  24782. */
  24783. metadata: any;
  24784. /**
  24785. * For internal use only. Please do not use.
  24786. */
  24787. reservedDataStore: any;
  24788. /**
  24789. * List of inspectable custom properties (used by the Inspector)
  24790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24791. */
  24792. inspectableCustomProperties: IInspectable[];
  24793. /**
  24794. * Gets or sets a boolean used to define if the node must be serialized
  24795. */
  24796. doNotSerialize: boolean;
  24797. /** @hidden */
  24798. _isDisposed: boolean;
  24799. /**
  24800. * Gets a list of Animations associated with the node
  24801. */
  24802. animations: Animation[];
  24803. protected _ranges: {
  24804. [name: string]: Nullable<AnimationRange>;
  24805. };
  24806. /**
  24807. * Callback raised when the node is ready to be used
  24808. */
  24809. onReady: (node: Node) => void;
  24810. private _isEnabled;
  24811. private _isParentEnabled;
  24812. private _isReady;
  24813. /** @hidden */
  24814. _currentRenderId: number;
  24815. private _parentUpdateId;
  24816. protected _childUpdateId: number;
  24817. /** @hidden */
  24818. _waitingParentId: Nullable<string>;
  24819. /** @hidden */
  24820. _scene: Scene;
  24821. /** @hidden */
  24822. _cache: any;
  24823. private _parentNode;
  24824. private _children;
  24825. /** @hidden */
  24826. _worldMatrix: Matrix;
  24827. /** @hidden */
  24828. _worldMatrixDeterminant: number;
  24829. /** @hidden */
  24830. private _sceneRootNodesIndex;
  24831. /**
  24832. * Gets a boolean indicating if the node has been disposed
  24833. * @returns true if the node was disposed
  24834. */
  24835. isDisposed(): boolean;
  24836. /**
  24837. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24838. * @see https://doc.babylonjs.com/how_to/parenting
  24839. */
  24840. parent: Nullable<Node>;
  24841. private addToSceneRootNodes;
  24842. private removeFromSceneRootNodes;
  24843. private _animationPropertiesOverride;
  24844. /**
  24845. * Gets or sets the animation properties override
  24846. */
  24847. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24848. /**
  24849. * Gets a string idenfifying the name of the class
  24850. * @returns "Node" string
  24851. */
  24852. getClassName(): string;
  24853. /** @hidden */
  24854. readonly _isNode: boolean;
  24855. /**
  24856. * An event triggered when the mesh is disposed
  24857. */
  24858. onDisposeObservable: Observable<Node>;
  24859. private _onDisposeObserver;
  24860. /**
  24861. * Sets a callback that will be raised when the node will be disposed
  24862. */
  24863. onDispose: () => void;
  24864. /**
  24865. * Creates a new Node
  24866. * @param name the name and id to be given to this node
  24867. * @param scene the scene this node will be added to
  24868. * @param addToRootNodes the node will be added to scene.rootNodes
  24869. */
  24870. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24871. /**
  24872. * Gets the scene of the node
  24873. * @returns a scene
  24874. */
  24875. getScene(): Scene;
  24876. /**
  24877. * Gets the engine of the node
  24878. * @returns a Engine
  24879. */
  24880. getEngine(): Engine;
  24881. private _behaviors;
  24882. /**
  24883. * Attach a behavior to the node
  24884. * @see http://doc.babylonjs.com/features/behaviour
  24885. * @param behavior defines the behavior to attach
  24886. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24887. * @returns the current Node
  24888. */
  24889. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24890. /**
  24891. * Remove an attached behavior
  24892. * @see http://doc.babylonjs.com/features/behaviour
  24893. * @param behavior defines the behavior to attach
  24894. * @returns the current Node
  24895. */
  24896. removeBehavior(behavior: Behavior<Node>): Node;
  24897. /**
  24898. * Gets the list of attached behaviors
  24899. * @see http://doc.babylonjs.com/features/behaviour
  24900. */
  24901. readonly behaviors: Behavior<Node>[];
  24902. /**
  24903. * Gets an attached behavior by name
  24904. * @param name defines the name of the behavior to look for
  24905. * @see http://doc.babylonjs.com/features/behaviour
  24906. * @returns null if behavior was not found else the requested behavior
  24907. */
  24908. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24909. /**
  24910. * Returns the latest update of the World matrix
  24911. * @returns a Matrix
  24912. */
  24913. getWorldMatrix(): Matrix;
  24914. /** @hidden */
  24915. _getWorldMatrixDeterminant(): number;
  24916. /**
  24917. * Returns directly the latest state of the mesh World matrix.
  24918. * A Matrix is returned.
  24919. */
  24920. readonly worldMatrixFromCache: Matrix;
  24921. /** @hidden */
  24922. _initCache(): void;
  24923. /** @hidden */
  24924. updateCache(force?: boolean): void;
  24925. /** @hidden */
  24926. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24927. /** @hidden */
  24928. _updateCache(ignoreParentClass?: boolean): void;
  24929. /** @hidden */
  24930. _isSynchronized(): boolean;
  24931. /** @hidden */
  24932. _markSyncedWithParent(): void;
  24933. /** @hidden */
  24934. isSynchronizedWithParent(): boolean;
  24935. /** @hidden */
  24936. isSynchronized(): boolean;
  24937. /**
  24938. * Is this node ready to be used/rendered
  24939. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24940. * @return true if the node is ready
  24941. */
  24942. isReady(completeCheck?: boolean): boolean;
  24943. /**
  24944. * Is this node enabled?
  24945. * 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
  24946. * @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
  24947. * @return whether this node (and its parent) is enabled
  24948. */
  24949. isEnabled(checkAncestors?: boolean): boolean;
  24950. /** @hidden */
  24951. protected _syncParentEnabledState(): void;
  24952. /**
  24953. * Set the enabled state of this node
  24954. * @param value defines the new enabled state
  24955. */
  24956. setEnabled(value: boolean): void;
  24957. /**
  24958. * Is this node a descendant of the given node?
  24959. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24960. * @param ancestor defines the parent node to inspect
  24961. * @returns a boolean indicating if this node is a descendant of the given node
  24962. */
  24963. isDescendantOf(ancestor: Node): boolean;
  24964. /** @hidden */
  24965. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24966. /**
  24967. * Will return all nodes that have this node as ascendant
  24968. * @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
  24969. * @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
  24970. * @return all children nodes of all types
  24971. */
  24972. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24973. /**
  24974. * Get all child-meshes of this node
  24975. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  24976. * @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
  24977. * @returns an array of AbstractMesh
  24978. */
  24979. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24980. /**
  24981. * Get all direct children of this node
  24982. * @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
  24983. * @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)
  24984. * @returns an array of Node
  24985. */
  24986. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24987. /** @hidden */
  24988. _setReady(state: boolean): void;
  24989. /**
  24990. * Get an animation by name
  24991. * @param name defines the name of the animation to look for
  24992. * @returns null if not found else the requested animation
  24993. */
  24994. getAnimationByName(name: string): Nullable<Animation>;
  24995. /**
  24996. * Creates an animation range for this node
  24997. * @param name defines the name of the range
  24998. * @param from defines the starting key
  24999. * @param to defines the end key
  25000. */
  25001. createAnimationRange(name: string, from: number, to: number): void;
  25002. /**
  25003. * Delete a specific animation range
  25004. * @param name defines the name of the range to delete
  25005. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25006. */
  25007. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25008. /**
  25009. * Get an animation range by name
  25010. * @param name defines the name of the animation range to look for
  25011. * @returns null if not found else the requested animation range
  25012. */
  25013. getAnimationRange(name: string): Nullable<AnimationRange>;
  25014. /**
  25015. * Gets the list of all animation ranges defined on this node
  25016. * @returns an array
  25017. */
  25018. getAnimationRanges(): Nullable<AnimationRange>[];
  25019. /**
  25020. * Will start the animation sequence
  25021. * @param name defines the range frames for animation sequence
  25022. * @param loop defines if the animation should loop (false by default)
  25023. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25024. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25025. * @returns the object created for this animation. If range does not exist, it will return null
  25026. */
  25027. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25028. /**
  25029. * Serialize animation ranges into a JSON compatible object
  25030. * @returns serialization object
  25031. */
  25032. serializeAnimationRanges(): any;
  25033. /**
  25034. * Computes the world matrix of the node
  25035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25036. * @returns the world matrix
  25037. */
  25038. computeWorldMatrix(force?: boolean): Matrix;
  25039. /**
  25040. * Releases resources associated with this node.
  25041. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25042. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25043. */
  25044. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25045. /**
  25046. * Parse animation range data from a serialization object and store them into a given node
  25047. * @param node defines where to store the animation ranges
  25048. * @param parsedNode defines the serialization object to read data from
  25049. * @param scene defines the hosting scene
  25050. */
  25051. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25052. }
  25053. }
  25054. declare module BABYLON {
  25055. /**
  25056. * Class used to store any kind of animation
  25057. */
  25058. export class Animation {
  25059. /**Name of the animation */
  25060. name: string;
  25061. /**Property to animate */
  25062. targetProperty: string;
  25063. /**The frames per second of the animation */
  25064. framePerSecond: number;
  25065. /**The data type of the animation */
  25066. dataType: number;
  25067. /**The loop mode of the animation */
  25068. loopMode?: number | undefined;
  25069. /**Specifies if blending should be enabled */
  25070. enableBlending?: boolean | undefined;
  25071. /**
  25072. * Use matrix interpolation instead of using direct key value when animating matrices
  25073. */
  25074. static AllowMatricesInterpolation: boolean;
  25075. /**
  25076. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25077. */
  25078. static AllowMatrixDecomposeForInterpolation: boolean;
  25079. /**
  25080. * Stores the key frames of the animation
  25081. */
  25082. private _keys;
  25083. /**
  25084. * Stores the easing function of the animation
  25085. */
  25086. private _easingFunction;
  25087. /**
  25088. * @hidden Internal use only
  25089. */
  25090. _runtimeAnimations: RuntimeAnimation[];
  25091. /**
  25092. * The set of event that will be linked to this animation
  25093. */
  25094. private _events;
  25095. /**
  25096. * Stores an array of target property paths
  25097. */
  25098. targetPropertyPath: string[];
  25099. /**
  25100. * Stores the blending speed of the animation
  25101. */
  25102. blendingSpeed: number;
  25103. /**
  25104. * Stores the animation ranges for the animation
  25105. */
  25106. private _ranges;
  25107. /**
  25108. * @hidden Internal use
  25109. */
  25110. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25111. /**
  25112. * Sets up an animation
  25113. * @param property The property to animate
  25114. * @param animationType The animation type to apply
  25115. * @param framePerSecond The frames per second of the animation
  25116. * @param easingFunction The easing function used in the animation
  25117. * @returns The created animation
  25118. */
  25119. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25120. /**
  25121. * Create and start an animation on a node
  25122. * @param name defines the name of the global animation that will be run on all nodes
  25123. * @param node defines the root node where the animation will take place
  25124. * @param targetProperty defines property to animate
  25125. * @param framePerSecond defines the number of frame per second yo use
  25126. * @param totalFrame defines the number of frames in total
  25127. * @param from defines the initial value
  25128. * @param to defines the final value
  25129. * @param loopMode defines which loop mode you want to use (off by default)
  25130. * @param easingFunction defines the easing function to use (linear by default)
  25131. * @param onAnimationEnd defines the callback to call when animation end
  25132. * @returns the animatable created for this animation
  25133. */
  25134. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25135. /**
  25136. * Create and start an animation on a node and its descendants
  25137. * @param name defines the name of the global animation that will be run on all nodes
  25138. * @param node defines the root node where the animation will take place
  25139. * @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
  25140. * @param targetProperty defines property to animate
  25141. * @param framePerSecond defines the number of frame per second to use
  25142. * @param totalFrame defines the number of frames in total
  25143. * @param from defines the initial value
  25144. * @param to defines the final value
  25145. * @param loopMode defines which loop mode you want to use (off by default)
  25146. * @param easingFunction defines the easing function to use (linear by default)
  25147. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25148. * @returns the list of animatables created for all nodes
  25149. * @example https://www.babylonjs-playground.com/#MH0VLI
  25150. */
  25151. 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[]>;
  25152. /**
  25153. * Creates a new animation, merges it with the existing animations and starts it
  25154. * @param name Name of the animation
  25155. * @param node Node which contains the scene that begins the animations
  25156. * @param targetProperty Specifies which property to animate
  25157. * @param framePerSecond The frames per second of the animation
  25158. * @param totalFrame The total number of frames
  25159. * @param from The frame at the beginning of the animation
  25160. * @param to The frame at the end of the animation
  25161. * @param loopMode Specifies the loop mode of the animation
  25162. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25163. * @param onAnimationEnd Callback to run once the animation is complete
  25164. * @returns Nullable animation
  25165. */
  25166. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25167. /**
  25168. * Transition property of an host to the target Value
  25169. * @param property The property to transition
  25170. * @param targetValue The target Value of the property
  25171. * @param host The object where the property to animate belongs
  25172. * @param scene Scene used to run the animation
  25173. * @param frameRate Framerate (in frame/s) to use
  25174. * @param transition The transition type we want to use
  25175. * @param duration The duration of the animation, in milliseconds
  25176. * @param onAnimationEnd Callback trigger at the end of the animation
  25177. * @returns Nullable animation
  25178. */
  25179. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25180. /**
  25181. * Return the array of runtime animations currently using this animation
  25182. */
  25183. readonly runtimeAnimations: RuntimeAnimation[];
  25184. /**
  25185. * Specifies if any of the runtime animations are currently running
  25186. */
  25187. readonly hasRunningRuntimeAnimations: boolean;
  25188. /**
  25189. * Initializes the animation
  25190. * @param name Name of the animation
  25191. * @param targetProperty Property to animate
  25192. * @param framePerSecond The frames per second of the animation
  25193. * @param dataType The data type of the animation
  25194. * @param loopMode The loop mode of the animation
  25195. * @param enableBlending Specifies if blending should be enabled
  25196. */
  25197. constructor(
  25198. /**Name of the animation */
  25199. name: string,
  25200. /**Property to animate */
  25201. targetProperty: string,
  25202. /**The frames per second of the animation */
  25203. framePerSecond: number,
  25204. /**The data type of the animation */
  25205. dataType: number,
  25206. /**The loop mode of the animation */
  25207. loopMode?: number | undefined,
  25208. /**Specifies if blending should be enabled */
  25209. enableBlending?: boolean | undefined);
  25210. /**
  25211. * Converts the animation to a string
  25212. * @param fullDetails support for multiple levels of logging within scene loading
  25213. * @returns String form of the animation
  25214. */
  25215. toString(fullDetails?: boolean): string;
  25216. /**
  25217. * Add an event to this animation
  25218. * @param event Event to add
  25219. */
  25220. addEvent(event: AnimationEvent): void;
  25221. /**
  25222. * Remove all events found at the given frame
  25223. * @param frame The frame to remove events from
  25224. */
  25225. removeEvents(frame: number): void;
  25226. /**
  25227. * Retrieves all the events from the animation
  25228. * @returns Events from the animation
  25229. */
  25230. getEvents(): AnimationEvent[];
  25231. /**
  25232. * Creates an animation range
  25233. * @param name Name of the animation range
  25234. * @param from Starting frame of the animation range
  25235. * @param to Ending frame of the animation
  25236. */
  25237. createRange(name: string, from: number, to: number): void;
  25238. /**
  25239. * Deletes an animation range by name
  25240. * @param name Name of the animation range to delete
  25241. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25242. */
  25243. deleteRange(name: string, deleteFrames?: boolean): void;
  25244. /**
  25245. * Gets the animation range by name, or null if not defined
  25246. * @param name Name of the animation range
  25247. * @returns Nullable animation range
  25248. */
  25249. getRange(name: string): Nullable<AnimationRange>;
  25250. /**
  25251. * Gets the key frames from the animation
  25252. * @returns The key frames of the animation
  25253. */
  25254. getKeys(): Array<IAnimationKey>;
  25255. /**
  25256. * Gets the highest frame rate of the animation
  25257. * @returns Highest frame rate of the animation
  25258. */
  25259. getHighestFrame(): number;
  25260. /**
  25261. * Gets the easing function of the animation
  25262. * @returns Easing function of the animation
  25263. */
  25264. getEasingFunction(): IEasingFunction;
  25265. /**
  25266. * Sets the easing function of the animation
  25267. * @param easingFunction A custom mathematical formula for animation
  25268. */
  25269. setEasingFunction(easingFunction: EasingFunction): void;
  25270. /**
  25271. * Interpolates a scalar linearly
  25272. * @param startValue Start value of the animation curve
  25273. * @param endValue End value of the animation curve
  25274. * @param gradient Scalar amount to interpolate
  25275. * @returns Interpolated scalar value
  25276. */
  25277. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25278. /**
  25279. * Interpolates a scalar cubically
  25280. * @param startValue Start value of the animation curve
  25281. * @param outTangent End tangent of the animation
  25282. * @param endValue End value of the animation curve
  25283. * @param inTangent Start tangent of the animation curve
  25284. * @param gradient Scalar amount to interpolate
  25285. * @returns Interpolated scalar value
  25286. */
  25287. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25288. /**
  25289. * Interpolates a quaternion using a spherical linear interpolation
  25290. * @param startValue Start value of the animation curve
  25291. * @param endValue End value of the animation curve
  25292. * @param gradient Scalar amount to interpolate
  25293. * @returns Interpolated quaternion value
  25294. */
  25295. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25296. /**
  25297. * Interpolates a quaternion cubically
  25298. * @param startValue Start value of the animation curve
  25299. * @param outTangent End tangent of the animation curve
  25300. * @param endValue End value of the animation curve
  25301. * @param inTangent Start tangent of the animation curve
  25302. * @param gradient Scalar amount to interpolate
  25303. * @returns Interpolated quaternion value
  25304. */
  25305. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25306. /**
  25307. * Interpolates a Vector3 linearl
  25308. * @param startValue Start value of the animation curve
  25309. * @param endValue End value of the animation curve
  25310. * @param gradient Scalar amount to interpolate
  25311. * @returns Interpolated scalar value
  25312. */
  25313. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25314. /**
  25315. * Interpolates a Vector3 cubically
  25316. * @param startValue Start value of the animation curve
  25317. * @param outTangent End tangent of the animation
  25318. * @param endValue End value of the animation curve
  25319. * @param inTangent Start tangent of the animation curve
  25320. * @param gradient Scalar amount to interpolate
  25321. * @returns InterpolatedVector3 value
  25322. */
  25323. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25324. /**
  25325. * Interpolates a Vector2 linearly
  25326. * @param startValue Start value of the animation curve
  25327. * @param endValue End value of the animation curve
  25328. * @param gradient Scalar amount to interpolate
  25329. * @returns Interpolated Vector2 value
  25330. */
  25331. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25332. /**
  25333. * Interpolates a Vector2 cubically
  25334. * @param startValue Start value of the animation curve
  25335. * @param outTangent End tangent of the animation
  25336. * @param endValue End value of the animation curve
  25337. * @param inTangent Start tangent of the animation curve
  25338. * @param gradient Scalar amount to interpolate
  25339. * @returns Interpolated Vector2 value
  25340. */
  25341. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25342. /**
  25343. * Interpolates a size linearly
  25344. * @param startValue Start value of the animation curve
  25345. * @param endValue End value of the animation curve
  25346. * @param gradient Scalar amount to interpolate
  25347. * @returns Interpolated Size value
  25348. */
  25349. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25350. /**
  25351. * Interpolates a Color3 linearly
  25352. * @param startValue Start value of the animation curve
  25353. * @param endValue End value of the animation curve
  25354. * @param gradient Scalar amount to interpolate
  25355. * @returns Interpolated Color3 value
  25356. */
  25357. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25358. /**
  25359. * @hidden Internal use only
  25360. */
  25361. _getKeyValue(value: any): any;
  25362. /**
  25363. * @hidden Internal use only
  25364. */
  25365. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25366. /**
  25367. * Defines the function to use to interpolate matrices
  25368. * @param startValue defines the start matrix
  25369. * @param endValue defines the end matrix
  25370. * @param gradient defines the gradient between both matrices
  25371. * @param result defines an optional target matrix where to store the interpolation
  25372. * @returns the interpolated matrix
  25373. */
  25374. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25375. /**
  25376. * Makes a copy of the animation
  25377. * @returns Cloned animation
  25378. */
  25379. clone(): Animation;
  25380. /**
  25381. * Sets the key frames of the animation
  25382. * @param values The animation key frames to set
  25383. */
  25384. setKeys(values: Array<IAnimationKey>): void;
  25385. /**
  25386. * Serializes the animation to an object
  25387. * @returns Serialized object
  25388. */
  25389. serialize(): any;
  25390. /**
  25391. * Float animation type
  25392. */
  25393. private static _ANIMATIONTYPE_FLOAT;
  25394. /**
  25395. * Vector3 animation type
  25396. */
  25397. private static _ANIMATIONTYPE_VECTOR3;
  25398. /**
  25399. * Quaternion animation type
  25400. */
  25401. private static _ANIMATIONTYPE_QUATERNION;
  25402. /**
  25403. * Matrix animation type
  25404. */
  25405. private static _ANIMATIONTYPE_MATRIX;
  25406. /**
  25407. * Color3 animation type
  25408. */
  25409. private static _ANIMATIONTYPE_COLOR3;
  25410. /**
  25411. * Vector2 animation type
  25412. */
  25413. private static _ANIMATIONTYPE_VECTOR2;
  25414. /**
  25415. * Size animation type
  25416. */
  25417. private static _ANIMATIONTYPE_SIZE;
  25418. /**
  25419. * Relative Loop Mode
  25420. */
  25421. private static _ANIMATIONLOOPMODE_RELATIVE;
  25422. /**
  25423. * Cycle Loop Mode
  25424. */
  25425. private static _ANIMATIONLOOPMODE_CYCLE;
  25426. /**
  25427. * Constant Loop Mode
  25428. */
  25429. private static _ANIMATIONLOOPMODE_CONSTANT;
  25430. /**
  25431. * Get the float animation type
  25432. */
  25433. static readonly ANIMATIONTYPE_FLOAT: number;
  25434. /**
  25435. * Get the Vector3 animation type
  25436. */
  25437. static readonly ANIMATIONTYPE_VECTOR3: number;
  25438. /**
  25439. * Get the Vector2 animation type
  25440. */
  25441. static readonly ANIMATIONTYPE_VECTOR2: number;
  25442. /**
  25443. * Get the Size animation type
  25444. */
  25445. static readonly ANIMATIONTYPE_SIZE: number;
  25446. /**
  25447. * Get the Quaternion animation type
  25448. */
  25449. static readonly ANIMATIONTYPE_QUATERNION: number;
  25450. /**
  25451. * Get the Matrix animation type
  25452. */
  25453. static readonly ANIMATIONTYPE_MATRIX: number;
  25454. /**
  25455. * Get the Color3 animation type
  25456. */
  25457. static readonly ANIMATIONTYPE_COLOR3: number;
  25458. /**
  25459. * Get the Relative Loop Mode
  25460. */
  25461. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25462. /**
  25463. * Get the Cycle Loop Mode
  25464. */
  25465. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25466. /**
  25467. * Get the Constant Loop Mode
  25468. */
  25469. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25470. /** @hidden */
  25471. static _UniversalLerp(left: any, right: any, amount: number): any;
  25472. /**
  25473. * Parses an animation object and creates an animation
  25474. * @param parsedAnimation Parsed animation object
  25475. * @returns Animation object
  25476. */
  25477. static Parse(parsedAnimation: any): Animation;
  25478. /**
  25479. * Appends the serialized animations from the source animations
  25480. * @param source Source containing the animations
  25481. * @param destination Target to store the animations
  25482. */
  25483. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25484. }
  25485. }
  25486. declare module BABYLON {
  25487. /**
  25488. * Base class of all the textures in babylon.
  25489. * It groups all the common properties the materials, post process, lights... might need
  25490. * in order to make a correct use of the texture.
  25491. */
  25492. export class BaseTexture implements IAnimatable {
  25493. /**
  25494. * Default anisotropic filtering level for the application.
  25495. * It is set to 4 as a good tradeoff between perf and quality.
  25496. */
  25497. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25498. /**
  25499. * Gets or sets the unique id of the texture
  25500. */
  25501. uniqueId: number;
  25502. /**
  25503. * Define the name of the texture.
  25504. */
  25505. name: string;
  25506. /**
  25507. * Gets or sets an object used to store user defined information.
  25508. */
  25509. metadata: any;
  25510. /**
  25511. * For internal use only. Please do not use.
  25512. */
  25513. reservedDataStore: any;
  25514. private _hasAlpha;
  25515. /**
  25516. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25517. */
  25518. hasAlpha: boolean;
  25519. /**
  25520. * Defines if the alpha value should be determined via the rgb values.
  25521. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25522. */
  25523. getAlphaFromRGB: boolean;
  25524. /**
  25525. * Intensity or strength of the texture.
  25526. * It is commonly used by materials to fine tune the intensity of the texture
  25527. */
  25528. level: number;
  25529. /**
  25530. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25531. * This is part of the texture as textures usually maps to one uv set.
  25532. */
  25533. coordinatesIndex: number;
  25534. private _coordinatesMode;
  25535. /**
  25536. * How a texture is mapped.
  25537. *
  25538. * | Value | Type | Description |
  25539. * | ----- | ----------------------------------- | ----------- |
  25540. * | 0 | EXPLICIT_MODE | |
  25541. * | 1 | SPHERICAL_MODE | |
  25542. * | 2 | PLANAR_MODE | |
  25543. * | 3 | CUBIC_MODE | |
  25544. * | 4 | PROJECTION_MODE | |
  25545. * | 5 | SKYBOX_MODE | |
  25546. * | 6 | INVCUBIC_MODE | |
  25547. * | 7 | EQUIRECTANGULAR_MODE | |
  25548. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25549. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25550. */
  25551. coordinatesMode: number;
  25552. /**
  25553. * | Value | Type | Description |
  25554. * | ----- | ------------------ | ----------- |
  25555. * | 0 | CLAMP_ADDRESSMODE | |
  25556. * | 1 | WRAP_ADDRESSMODE | |
  25557. * | 2 | MIRROR_ADDRESSMODE | |
  25558. */
  25559. wrapU: number;
  25560. /**
  25561. * | Value | Type | Description |
  25562. * | ----- | ------------------ | ----------- |
  25563. * | 0 | CLAMP_ADDRESSMODE | |
  25564. * | 1 | WRAP_ADDRESSMODE | |
  25565. * | 2 | MIRROR_ADDRESSMODE | |
  25566. */
  25567. wrapV: number;
  25568. /**
  25569. * | Value | Type | Description |
  25570. * | ----- | ------------------ | ----------- |
  25571. * | 0 | CLAMP_ADDRESSMODE | |
  25572. * | 1 | WRAP_ADDRESSMODE | |
  25573. * | 2 | MIRROR_ADDRESSMODE | |
  25574. */
  25575. wrapR: number;
  25576. /**
  25577. * With compliant hardware and browser (supporting anisotropic filtering)
  25578. * this defines the level of anisotropic filtering in the texture.
  25579. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25580. */
  25581. anisotropicFilteringLevel: number;
  25582. /**
  25583. * Define if the texture is a cube texture or if false a 2d texture.
  25584. */
  25585. isCube: boolean;
  25586. /**
  25587. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25588. */
  25589. is3D: boolean;
  25590. /**
  25591. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25592. * HDR texture are usually stored in linear space.
  25593. * This only impacts the PBR and Background materials
  25594. */
  25595. gammaSpace: boolean;
  25596. /**
  25597. * Gets whether or not the texture contains RGBD data.
  25598. */
  25599. readonly isRGBD: boolean;
  25600. /**
  25601. * Is Z inverted in the texture (useful in a cube texture).
  25602. */
  25603. invertZ: boolean;
  25604. /**
  25605. * Are mip maps generated for this texture or not.
  25606. */
  25607. readonly noMipmap: boolean;
  25608. /**
  25609. * @hidden
  25610. */
  25611. lodLevelInAlpha: boolean;
  25612. /**
  25613. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25614. */
  25615. lodGenerationOffset: number;
  25616. /**
  25617. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25618. */
  25619. lodGenerationScale: number;
  25620. /**
  25621. * Define if the texture is a render target.
  25622. */
  25623. isRenderTarget: boolean;
  25624. /**
  25625. * Define the unique id of the texture in the scene.
  25626. */
  25627. readonly uid: string;
  25628. /**
  25629. * Return a string representation of the texture.
  25630. * @returns the texture as a string
  25631. */
  25632. toString(): string;
  25633. /**
  25634. * Get the class name of the texture.
  25635. * @returns "BaseTexture"
  25636. */
  25637. getClassName(): string;
  25638. /**
  25639. * Define the list of animation attached to the texture.
  25640. */
  25641. animations: Animation[];
  25642. /**
  25643. * An event triggered when the texture is disposed.
  25644. */
  25645. onDisposeObservable: Observable<BaseTexture>;
  25646. private _onDisposeObserver;
  25647. /**
  25648. * Callback triggered when the texture has been disposed.
  25649. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25650. */
  25651. onDispose: () => void;
  25652. /**
  25653. * Define the current state of the loading sequence when in delayed load mode.
  25654. */
  25655. delayLoadState: number;
  25656. private _scene;
  25657. /** @hidden */
  25658. _texture: Nullable<InternalTexture>;
  25659. private _uid;
  25660. /**
  25661. * Define if the texture is preventinga material to render or not.
  25662. * If not and the texture is not ready, the engine will use a default black texture instead.
  25663. */
  25664. readonly isBlocking: boolean;
  25665. /**
  25666. * Instantiates a new BaseTexture.
  25667. * Base class of all the textures in babylon.
  25668. * It groups all the common properties the materials, post process, lights... might need
  25669. * in order to make a correct use of the texture.
  25670. * @param scene Define the scene the texture blongs to
  25671. */
  25672. constructor(scene: Nullable<Scene>);
  25673. /**
  25674. * Get the scene the texture belongs to.
  25675. * @returns the scene or null if undefined
  25676. */
  25677. getScene(): Nullable<Scene>;
  25678. /**
  25679. * Get the texture transform matrix used to offset tile the texture for istance.
  25680. * @returns the transformation matrix
  25681. */
  25682. getTextureMatrix(): Matrix;
  25683. /**
  25684. * Get the texture reflection matrix used to rotate/transform the reflection.
  25685. * @returns the reflection matrix
  25686. */
  25687. getReflectionTextureMatrix(): Matrix;
  25688. /**
  25689. * Get the underlying lower level texture from Babylon.
  25690. * @returns the insternal texture
  25691. */
  25692. getInternalTexture(): Nullable<InternalTexture>;
  25693. /**
  25694. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25695. * @returns true if ready or not blocking
  25696. */
  25697. isReadyOrNotBlocking(): boolean;
  25698. /**
  25699. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25700. * @returns true if fully ready
  25701. */
  25702. isReady(): boolean;
  25703. private _cachedSize;
  25704. /**
  25705. * Get the size of the texture.
  25706. * @returns the texture size.
  25707. */
  25708. getSize(): ISize;
  25709. /**
  25710. * Get the base size of the texture.
  25711. * It can be different from the size if the texture has been resized for POT for instance
  25712. * @returns the base size
  25713. */
  25714. getBaseSize(): ISize;
  25715. /**
  25716. * Update the sampling mode of the texture.
  25717. * Default is Trilinear mode.
  25718. *
  25719. * | Value | Type | Description |
  25720. * | ----- | ------------------ | ----------- |
  25721. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25722. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25723. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25724. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25725. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25726. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25727. * | 7 | NEAREST_LINEAR | |
  25728. * | 8 | NEAREST_NEAREST | |
  25729. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25730. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25731. * | 11 | LINEAR_LINEAR | |
  25732. * | 12 | LINEAR_NEAREST | |
  25733. *
  25734. * > _mag_: magnification filter (close to the viewer)
  25735. * > _min_: minification filter (far from the viewer)
  25736. * > _mip_: filter used between mip map levels
  25737. *@param samplingMode Define the new sampling mode of the texture
  25738. */
  25739. updateSamplingMode(samplingMode: number): void;
  25740. /**
  25741. * Scales the texture if is `canRescale()`
  25742. * @param ratio the resize factor we want to use to rescale
  25743. */
  25744. scale(ratio: number): void;
  25745. /**
  25746. * Get if the texture can rescale.
  25747. */
  25748. readonly canRescale: boolean;
  25749. /** @hidden */
  25750. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25751. /** @hidden */
  25752. _rebuild(): void;
  25753. /**
  25754. * Triggers the load sequence in delayed load mode.
  25755. */
  25756. delayLoad(): void;
  25757. /**
  25758. * Clones the texture.
  25759. * @returns the cloned texture
  25760. */
  25761. clone(): Nullable<BaseTexture>;
  25762. /**
  25763. * Get the texture underlying type (INT, FLOAT...)
  25764. */
  25765. readonly textureType: number;
  25766. /**
  25767. * Get the texture underlying format (RGB, RGBA...)
  25768. */
  25769. readonly textureFormat: number;
  25770. /**
  25771. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25772. * This will returns an RGBA array buffer containing either in values (0-255) or
  25773. * float values (0-1) depending of the underlying buffer type.
  25774. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25775. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25776. * @param buffer defines a user defined buffer to fill with data (can be null)
  25777. * @returns The Array buffer containing the pixels data.
  25778. */
  25779. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25780. /**
  25781. * Release and destroy the underlying lower level texture aka internalTexture.
  25782. */
  25783. releaseInternalTexture(): void;
  25784. /**
  25785. * Get the polynomial representation of the texture data.
  25786. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25787. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25788. */
  25789. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25790. /** @hidden */
  25791. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25792. /** @hidden */
  25793. readonly _lodTextureMid: Nullable<BaseTexture>;
  25794. /** @hidden */
  25795. readonly _lodTextureLow: Nullable<BaseTexture>;
  25796. /**
  25797. * Dispose the texture and release its associated resources.
  25798. */
  25799. dispose(): void;
  25800. /**
  25801. * Serialize the texture into a JSON representation that can be parsed later on.
  25802. * @returns the JSON representation of the texture
  25803. */
  25804. serialize(): any;
  25805. /**
  25806. * Helper function to be called back once a list of texture contains only ready textures.
  25807. * @param textures Define the list of textures to wait for
  25808. * @param callback Define the callback triggered once the entire list will be ready
  25809. */
  25810. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25811. }
  25812. }
  25813. declare module BABYLON {
  25814. /**
  25815. * Uniform buffer objects.
  25816. *
  25817. * Handles blocks of uniform on the GPU.
  25818. *
  25819. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25820. *
  25821. * For more information, please refer to :
  25822. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25823. */
  25824. export class UniformBuffer {
  25825. private _engine;
  25826. private _buffer;
  25827. private _data;
  25828. private _bufferData;
  25829. private _dynamic?;
  25830. private _uniformLocations;
  25831. private _uniformSizes;
  25832. private _uniformLocationPointer;
  25833. private _needSync;
  25834. private _noUBO;
  25835. private _currentEffect;
  25836. private static _MAX_UNIFORM_SIZE;
  25837. private static _tempBuffer;
  25838. /**
  25839. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25840. * This is dynamic to allow compat with webgl 1 and 2.
  25841. * You will need to pass the name of the uniform as well as the value.
  25842. */
  25843. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25844. /**
  25845. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25846. * This is dynamic to allow compat with webgl 1 and 2.
  25847. * You will need to pass the name of the uniform as well as the value.
  25848. */
  25849. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25850. /**
  25851. * Lambda to Update a single float in a uniform buffer.
  25852. * This is dynamic to allow compat with webgl 1 and 2.
  25853. * You will need to pass the name of the uniform as well as the value.
  25854. */
  25855. updateFloat: (name: string, x: number) => void;
  25856. /**
  25857. * Lambda to Update a vec2 of float in a uniform buffer.
  25858. * This is dynamic to allow compat with webgl 1 and 2.
  25859. * You will need to pass the name of the uniform as well as the value.
  25860. */
  25861. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25862. /**
  25863. * Lambda to Update a vec3 of float in a uniform buffer.
  25864. * This is dynamic to allow compat with webgl 1 and 2.
  25865. * You will need to pass the name of the uniform as well as the value.
  25866. */
  25867. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25868. /**
  25869. * Lambda to Update a vec4 of float in a uniform buffer.
  25870. * This is dynamic to allow compat with webgl 1 and 2.
  25871. * You will need to pass the name of the uniform as well as the value.
  25872. */
  25873. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25874. /**
  25875. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25876. * This is dynamic to allow compat with webgl 1 and 2.
  25877. * You will need to pass the name of the uniform as well as the value.
  25878. */
  25879. updateMatrix: (name: string, mat: Matrix) => void;
  25880. /**
  25881. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25882. * This is dynamic to allow compat with webgl 1 and 2.
  25883. * You will need to pass the name of the uniform as well as the value.
  25884. */
  25885. updateVector3: (name: string, vector: Vector3) => void;
  25886. /**
  25887. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25888. * This is dynamic to allow compat with webgl 1 and 2.
  25889. * You will need to pass the name of the uniform as well as the value.
  25890. */
  25891. updateVector4: (name: string, vector: Vector4) => void;
  25892. /**
  25893. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25894. * This is dynamic to allow compat with webgl 1 and 2.
  25895. * You will need to pass the name of the uniform as well as the value.
  25896. */
  25897. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25898. /**
  25899. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25900. * This is dynamic to allow compat with webgl 1 and 2.
  25901. * You will need to pass the name of the uniform as well as the value.
  25902. */
  25903. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25904. /**
  25905. * Instantiates a new Uniform buffer objects.
  25906. *
  25907. * Handles blocks of uniform on the GPU.
  25908. *
  25909. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25910. *
  25911. * For more information, please refer to :
  25912. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25913. * @param engine Define the engine the buffer is associated with
  25914. * @param data Define the data contained in the buffer
  25915. * @param dynamic Define if the buffer is updatable
  25916. */
  25917. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25918. /**
  25919. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25920. * or just falling back on setUniformXXX calls.
  25921. */
  25922. readonly useUbo: boolean;
  25923. /**
  25924. * Indicates if the WebGL underlying uniform buffer is in sync
  25925. * with the javascript cache data.
  25926. */
  25927. readonly isSync: boolean;
  25928. /**
  25929. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25930. * Also, a dynamic UniformBuffer will disable cache verification and always
  25931. * update the underlying WebGL uniform buffer to the GPU.
  25932. * @returns if Dynamic, otherwise false
  25933. */
  25934. isDynamic(): boolean;
  25935. /**
  25936. * The data cache on JS side.
  25937. * @returns the underlying data as a float array
  25938. */
  25939. getData(): Float32Array;
  25940. /**
  25941. * The underlying WebGL Uniform buffer.
  25942. * @returns the webgl buffer
  25943. */
  25944. getBuffer(): Nullable<WebGLBuffer>;
  25945. /**
  25946. * std140 layout specifies how to align data within an UBO structure.
  25947. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25948. * for specs.
  25949. */
  25950. private _fillAlignment;
  25951. /**
  25952. * Adds an uniform in the buffer.
  25953. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25954. * for the layout to be correct !
  25955. * @param name Name of the uniform, as used in the uniform block in the shader.
  25956. * @param size Data size, or data directly.
  25957. */
  25958. addUniform(name: string, size: number | number[]): void;
  25959. /**
  25960. * Adds a Matrix 4x4 to the uniform buffer.
  25961. * @param name Name of the uniform, as used in the uniform block in the shader.
  25962. * @param mat A 4x4 matrix.
  25963. */
  25964. addMatrix(name: string, mat: Matrix): void;
  25965. /**
  25966. * Adds a vec2 to the uniform buffer.
  25967. * @param name Name of the uniform, as used in the uniform block in the shader.
  25968. * @param x Define the x component value of the vec2
  25969. * @param y Define the y component value of the vec2
  25970. */
  25971. addFloat2(name: string, x: number, y: number): void;
  25972. /**
  25973. * Adds a vec3 to the uniform buffer.
  25974. * @param name Name of the uniform, as used in the uniform block in the shader.
  25975. * @param x Define the x component value of the vec3
  25976. * @param y Define the y component value of the vec3
  25977. * @param z Define the z component value of the vec3
  25978. */
  25979. addFloat3(name: string, x: number, y: number, z: number): void;
  25980. /**
  25981. * Adds a vec3 to the uniform buffer.
  25982. * @param name Name of the uniform, as used in the uniform block in the shader.
  25983. * @param color Define the vec3 from a Color
  25984. */
  25985. addColor3(name: string, color: Color3): void;
  25986. /**
  25987. * Adds a vec4 to the uniform buffer.
  25988. * @param name Name of the uniform, as used in the uniform block in the shader.
  25989. * @param color Define the rgb components from a Color
  25990. * @param alpha Define the a component of the vec4
  25991. */
  25992. addColor4(name: string, color: Color3, alpha: number): void;
  25993. /**
  25994. * Adds a vec3 to the uniform buffer.
  25995. * @param name Name of the uniform, as used in the uniform block in the shader.
  25996. * @param vector Define the vec3 components from a Vector
  25997. */
  25998. addVector3(name: string, vector: Vector3): void;
  25999. /**
  26000. * Adds a Matrix 3x3 to the uniform buffer.
  26001. * @param name Name of the uniform, as used in the uniform block in the shader.
  26002. */
  26003. addMatrix3x3(name: string): void;
  26004. /**
  26005. * Adds a Matrix 2x2 to the uniform buffer.
  26006. * @param name Name of the uniform, as used in the uniform block in the shader.
  26007. */
  26008. addMatrix2x2(name: string): void;
  26009. /**
  26010. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26011. */
  26012. create(): void;
  26013. /** @hidden */
  26014. _rebuild(): void;
  26015. /**
  26016. * Updates the WebGL Uniform Buffer on the GPU.
  26017. * If the `dynamic` flag is set to true, no cache comparison is done.
  26018. * Otherwise, the buffer will be updated only if the cache differs.
  26019. */
  26020. update(): void;
  26021. /**
  26022. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26023. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26024. * @param data Define the flattened data
  26025. * @param size Define the size of the data.
  26026. */
  26027. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26028. private _updateMatrix3x3ForUniform;
  26029. private _updateMatrix3x3ForEffect;
  26030. private _updateMatrix2x2ForEffect;
  26031. private _updateMatrix2x2ForUniform;
  26032. private _updateFloatForEffect;
  26033. private _updateFloatForUniform;
  26034. private _updateFloat2ForEffect;
  26035. private _updateFloat2ForUniform;
  26036. private _updateFloat3ForEffect;
  26037. private _updateFloat3ForUniform;
  26038. private _updateFloat4ForEffect;
  26039. private _updateFloat4ForUniform;
  26040. private _updateMatrixForEffect;
  26041. private _updateMatrixForUniform;
  26042. private _updateVector3ForEffect;
  26043. private _updateVector3ForUniform;
  26044. private _updateVector4ForEffect;
  26045. private _updateVector4ForUniform;
  26046. private _updateColor3ForEffect;
  26047. private _updateColor3ForUniform;
  26048. private _updateColor4ForEffect;
  26049. private _updateColor4ForUniform;
  26050. /**
  26051. * Sets a sampler uniform on the effect.
  26052. * @param name Define the name of the sampler.
  26053. * @param texture Define the texture to set in the sampler
  26054. */
  26055. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26056. /**
  26057. * Directly updates the value of the uniform in the cache AND on the GPU.
  26058. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26059. * @param data Define the flattened data
  26060. */
  26061. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26062. /**
  26063. * Binds this uniform buffer to an effect.
  26064. * @param effect Define the effect to bind the buffer to
  26065. * @param name Name of the uniform block in the shader.
  26066. */
  26067. bindToEffect(effect: Effect, name: string): void;
  26068. /**
  26069. * Disposes the uniform buffer.
  26070. */
  26071. dispose(): void;
  26072. }
  26073. }
  26074. declare module BABYLON {
  26075. /**
  26076. * This represents the required contract to create a new type of texture loader.
  26077. */
  26078. export interface IInternalTextureLoader {
  26079. /**
  26080. * Defines wether the loader supports cascade loading the different faces.
  26081. */
  26082. supportCascades: boolean;
  26083. /**
  26084. * This returns if the loader support the current file information.
  26085. * @param extension defines the file extension of the file being loaded
  26086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26087. * @param fallback defines the fallback internal texture if any
  26088. * @param isBase64 defines whether the texture is encoded as a base64
  26089. * @param isBuffer defines whether the texture data are stored as a buffer
  26090. * @returns true if the loader can load the specified file
  26091. */
  26092. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26093. /**
  26094. * Transform the url before loading if required.
  26095. * @param rootUrl the url of the texture
  26096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26097. * @returns the transformed texture
  26098. */
  26099. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26100. /**
  26101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26102. * @param rootUrl the url of the texture
  26103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26104. * @returns the fallback texture
  26105. */
  26106. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26107. /**
  26108. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26109. * @param data contains the texture data
  26110. * @param texture defines the BabylonJS internal texture
  26111. * @param createPolynomials will be true if polynomials have been requested
  26112. * @param onLoad defines the callback to trigger once the texture is ready
  26113. * @param onError defines the callback to trigger in case of error
  26114. */
  26115. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26116. /**
  26117. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26118. * @param data contains the texture data
  26119. * @param texture defines the BabylonJS internal texture
  26120. * @param callback defines the method to call once ready to upload
  26121. */
  26122. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26123. }
  26124. }
  26125. declare module BABYLON {
  26126. /**
  26127. * Creation options of the multi render target texture.
  26128. */
  26129. export interface IMultiRenderTargetOptions {
  26130. /**
  26131. * Define if the texture needs to create mip maps after render.
  26132. */
  26133. generateMipMaps?: boolean;
  26134. /**
  26135. * Define the types of all the draw buffers we want to create
  26136. */
  26137. types?: number[];
  26138. /**
  26139. * Define the sampling modes of all the draw buffers we want to create
  26140. */
  26141. samplingModes?: number[];
  26142. /**
  26143. * Define if a depth buffer is required
  26144. */
  26145. generateDepthBuffer?: boolean;
  26146. /**
  26147. * Define if a stencil buffer is required
  26148. */
  26149. generateStencilBuffer?: boolean;
  26150. /**
  26151. * Define if a depth texture is required instead of a depth buffer
  26152. */
  26153. generateDepthTexture?: boolean;
  26154. /**
  26155. * Define the number of desired draw buffers
  26156. */
  26157. textureCount?: number;
  26158. /**
  26159. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26160. */
  26161. doNotChangeAspectRatio?: boolean;
  26162. /**
  26163. * Define the default type of the buffers we are creating
  26164. */
  26165. defaultType?: number;
  26166. }
  26167. /**
  26168. * A multi render target, like a render target provides the ability to render to a texture.
  26169. * Unlike the render target, it can render to several draw buffers in one draw.
  26170. * This is specially interesting in deferred rendering or for any effects requiring more than
  26171. * just one color from a single pass.
  26172. */
  26173. export class MultiRenderTarget extends RenderTargetTexture {
  26174. private _internalTextures;
  26175. private _textures;
  26176. private _multiRenderTargetOptions;
  26177. /**
  26178. * Get if draw buffers are currently supported by the used hardware and browser.
  26179. */
  26180. readonly isSupported: boolean;
  26181. /**
  26182. * Get the list of textures generated by the multi render target.
  26183. */
  26184. readonly textures: Texture[];
  26185. /**
  26186. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26187. */
  26188. readonly depthTexture: Texture;
  26189. /**
  26190. * Set the wrapping mode on U of all the textures we are rendering to.
  26191. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26192. */
  26193. wrapU: number;
  26194. /**
  26195. * Set the wrapping mode on V of all the textures we are rendering to.
  26196. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26197. */
  26198. wrapV: number;
  26199. /**
  26200. * Instantiate a new multi render target texture.
  26201. * A multi render target, like a render target provides the ability to render to a texture.
  26202. * Unlike the render target, it can render to several draw buffers in one draw.
  26203. * This is specially interesting in deferred rendering or for any effects requiring more than
  26204. * just one color from a single pass.
  26205. * @param name Define the name of the texture
  26206. * @param size Define the size of the buffers to render to
  26207. * @param count Define the number of target we are rendering into
  26208. * @param scene Define the scene the texture belongs to
  26209. * @param options Define the options used to create the multi render target
  26210. */
  26211. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26212. /** @hidden */
  26213. _rebuild(): void;
  26214. private _createInternalTextures;
  26215. private _createTextures;
  26216. /**
  26217. * Define the number of samples used if MSAA is enabled.
  26218. */
  26219. samples: number;
  26220. /**
  26221. * Resize all the textures in the multi render target.
  26222. * Be carrefull as it will recreate all the data in the new texture.
  26223. * @param size Define the new size
  26224. */
  26225. resize(size: any): void;
  26226. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26227. /**
  26228. * Dispose the render targets and their associated resources
  26229. */
  26230. dispose(): void;
  26231. /**
  26232. * Release all the underlying texture used as draw buffers.
  26233. */
  26234. releaseInternalTextures(): void;
  26235. }
  26236. }
  26237. declare module BABYLON {
  26238. /**
  26239. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26241. */
  26242. export class Analyser {
  26243. /**
  26244. * Gets or sets the smoothing
  26245. * @ignorenaming
  26246. */
  26247. SMOOTHING: number;
  26248. /**
  26249. * Gets or sets the FFT table size
  26250. * @ignorenaming
  26251. */
  26252. FFT_SIZE: number;
  26253. /**
  26254. * Gets or sets the bar graph amplitude
  26255. * @ignorenaming
  26256. */
  26257. BARGRAPHAMPLITUDE: number;
  26258. /**
  26259. * Gets or sets the position of the debug canvas
  26260. * @ignorenaming
  26261. */
  26262. DEBUGCANVASPOS: {
  26263. x: number;
  26264. y: number;
  26265. };
  26266. /**
  26267. * Gets or sets the debug canvas size
  26268. * @ignorenaming
  26269. */
  26270. DEBUGCANVASSIZE: {
  26271. width: number;
  26272. height: number;
  26273. };
  26274. private _byteFreqs;
  26275. private _byteTime;
  26276. private _floatFreqs;
  26277. private _webAudioAnalyser;
  26278. private _debugCanvas;
  26279. private _debugCanvasContext;
  26280. private _scene;
  26281. private _registerFunc;
  26282. private _audioEngine;
  26283. /**
  26284. * Creates a new analyser
  26285. * @param scene defines hosting scene
  26286. */
  26287. constructor(scene: Scene);
  26288. /**
  26289. * Get the number of data values you will have to play with for the visualization
  26290. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26291. * @returns a number
  26292. */
  26293. getFrequencyBinCount(): number;
  26294. /**
  26295. * Gets the current frequency data as a byte array
  26296. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26297. * @returns a Uint8Array
  26298. */
  26299. getByteFrequencyData(): Uint8Array;
  26300. /**
  26301. * Gets the current waveform as a byte array
  26302. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26303. * @returns a Uint8Array
  26304. */
  26305. getByteTimeDomainData(): Uint8Array;
  26306. /**
  26307. * Gets the current frequency data as a float array
  26308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26309. * @returns a Float32Array
  26310. */
  26311. getFloatFrequencyData(): Float32Array;
  26312. /**
  26313. * Renders the debug canvas
  26314. */
  26315. drawDebugCanvas(): void;
  26316. /**
  26317. * Stops rendering the debug canvas and removes it
  26318. */
  26319. stopDebugCanvas(): void;
  26320. /**
  26321. * Connects two audio nodes
  26322. * @param inputAudioNode defines first node to connect
  26323. * @param outputAudioNode defines second node to connect
  26324. */
  26325. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26326. /**
  26327. * Releases all associated resources
  26328. */
  26329. dispose(): void;
  26330. }
  26331. }
  26332. declare module BABYLON {
  26333. /**
  26334. * This represents an audio engine and it is responsible
  26335. * to play, synchronize and analyse sounds throughout the application.
  26336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26337. */
  26338. export interface IAudioEngine extends IDisposable {
  26339. /**
  26340. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26341. */
  26342. readonly canUseWebAudio: boolean;
  26343. /**
  26344. * Gets the current AudioContext if available.
  26345. */
  26346. readonly audioContext: Nullable<AudioContext>;
  26347. /**
  26348. * The master gain node defines the global audio volume of your audio engine.
  26349. */
  26350. readonly masterGain: GainNode;
  26351. /**
  26352. * Gets whether or not mp3 are supported by your browser.
  26353. */
  26354. readonly isMP3supported: boolean;
  26355. /**
  26356. * Gets whether or not ogg are supported by your browser.
  26357. */
  26358. readonly isOGGsupported: boolean;
  26359. /**
  26360. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26361. * @ignoreNaming
  26362. */
  26363. WarnedWebAudioUnsupported: boolean;
  26364. /**
  26365. * Defines if the audio engine relies on a custom unlocked button.
  26366. * In this case, the embedded button will not be displayed.
  26367. */
  26368. useCustomUnlockedButton: boolean;
  26369. /**
  26370. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26371. */
  26372. readonly unlocked: boolean;
  26373. /**
  26374. * Event raised when audio has been unlocked on the browser.
  26375. */
  26376. onAudioUnlockedObservable: Observable<AudioEngine>;
  26377. /**
  26378. * Event raised when audio has been locked on the browser.
  26379. */
  26380. onAudioLockedObservable: Observable<AudioEngine>;
  26381. /**
  26382. * Flags the audio engine in Locked state.
  26383. * This happens due to new browser policies preventing audio to autoplay.
  26384. */
  26385. lock(): void;
  26386. /**
  26387. * Unlocks the audio engine once a user action has been done on the dom.
  26388. * This is helpful to resume play once browser policies have been satisfied.
  26389. */
  26390. unlock(): void;
  26391. }
  26392. /**
  26393. * This represents the default audio engine used in babylon.
  26394. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26396. */
  26397. export class AudioEngine implements IAudioEngine {
  26398. private _audioContext;
  26399. private _audioContextInitialized;
  26400. private _muteButton;
  26401. private _hostElement;
  26402. /**
  26403. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26404. */
  26405. canUseWebAudio: boolean;
  26406. /**
  26407. * The master gain node defines the global audio volume of your audio engine.
  26408. */
  26409. masterGain: GainNode;
  26410. /**
  26411. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26412. * @ignoreNaming
  26413. */
  26414. WarnedWebAudioUnsupported: boolean;
  26415. /**
  26416. * Gets whether or not mp3 are supported by your browser.
  26417. */
  26418. isMP3supported: boolean;
  26419. /**
  26420. * Gets whether or not ogg are supported by your browser.
  26421. */
  26422. isOGGsupported: boolean;
  26423. /**
  26424. * Gets whether audio has been unlocked on the device.
  26425. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26426. * a user interaction has happened.
  26427. */
  26428. unlocked: boolean;
  26429. /**
  26430. * Defines if the audio engine relies on a custom unlocked button.
  26431. * In this case, the embedded button will not be displayed.
  26432. */
  26433. useCustomUnlockedButton: boolean;
  26434. /**
  26435. * Event raised when audio has been unlocked on the browser.
  26436. */
  26437. onAudioUnlockedObservable: Observable<AudioEngine>;
  26438. /**
  26439. * Event raised when audio has been locked on the browser.
  26440. */
  26441. onAudioLockedObservable: Observable<AudioEngine>;
  26442. /**
  26443. * Gets the current AudioContext if available.
  26444. */
  26445. readonly audioContext: Nullable<AudioContext>;
  26446. private _connectedAnalyser;
  26447. /**
  26448. * Instantiates a new audio engine.
  26449. *
  26450. * There should be only one per page as some browsers restrict the number
  26451. * of audio contexts you can create.
  26452. * @param hostElement defines the host element where to display the mute icon if necessary
  26453. */
  26454. constructor(hostElement?: Nullable<HTMLElement>);
  26455. /**
  26456. * Flags the audio engine in Locked state.
  26457. * This happens due to new browser policies preventing audio to autoplay.
  26458. */
  26459. lock(): void;
  26460. /**
  26461. * Unlocks the audio engine once a user action has been done on the dom.
  26462. * This is helpful to resume play once browser policies have been satisfied.
  26463. */
  26464. unlock(): void;
  26465. private _resumeAudioContext;
  26466. private _initializeAudioContext;
  26467. private _tryToRun;
  26468. private _triggerRunningState;
  26469. private _triggerSuspendedState;
  26470. private _displayMuteButton;
  26471. private _moveButtonToTopLeft;
  26472. private _onResize;
  26473. private _hideMuteButton;
  26474. /**
  26475. * Destroy and release the resources associated with the audio ccontext.
  26476. */
  26477. dispose(): void;
  26478. /**
  26479. * Gets the global volume sets on the master gain.
  26480. * @returns the global volume if set or -1 otherwise
  26481. */
  26482. getGlobalVolume(): number;
  26483. /**
  26484. * Sets the global volume of your experience (sets on the master gain).
  26485. * @param newVolume Defines the new global volume of the application
  26486. */
  26487. setGlobalVolume(newVolume: number): void;
  26488. /**
  26489. * Connect the audio engine to an audio analyser allowing some amazing
  26490. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26492. * @param analyser The analyser to connect to the engine
  26493. */
  26494. connectToAnalyser(analyser: Analyser): void;
  26495. }
  26496. }
  26497. declare module BABYLON {
  26498. /**
  26499. * Interface used to present a loading screen while loading a scene
  26500. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26501. */
  26502. export interface ILoadingScreen {
  26503. /**
  26504. * Function called to display the loading screen
  26505. */
  26506. displayLoadingUI: () => void;
  26507. /**
  26508. * Function called to hide the loading screen
  26509. */
  26510. hideLoadingUI: () => void;
  26511. /**
  26512. * Gets or sets the color to use for the background
  26513. */
  26514. loadingUIBackgroundColor: string;
  26515. /**
  26516. * Gets or sets the text to display while loading
  26517. */
  26518. loadingUIText: string;
  26519. }
  26520. /**
  26521. * Class used for the default loading screen
  26522. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26523. */
  26524. export class DefaultLoadingScreen implements ILoadingScreen {
  26525. private _renderingCanvas;
  26526. private _loadingText;
  26527. private _loadingDivBackgroundColor;
  26528. private _loadingDiv;
  26529. private _loadingTextDiv;
  26530. /**
  26531. * Creates a new default loading screen
  26532. * @param _renderingCanvas defines the canvas used to render the scene
  26533. * @param _loadingText defines the default text to display
  26534. * @param _loadingDivBackgroundColor defines the default background color
  26535. */
  26536. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26537. /**
  26538. * Function called to display the loading screen
  26539. */
  26540. displayLoadingUI(): void;
  26541. /**
  26542. * Function called to hide the loading screen
  26543. */
  26544. hideLoadingUI(): void;
  26545. /**
  26546. * Gets or sets the text to display while loading
  26547. */
  26548. loadingUIText: string;
  26549. /**
  26550. * Gets or sets the color to use for the background
  26551. */
  26552. loadingUIBackgroundColor: string;
  26553. private _resizeLoadingUI;
  26554. }
  26555. }
  26556. declare module BABYLON {
  26557. /**
  26558. * Settings for finer control over video usage
  26559. */
  26560. export interface VideoTextureSettings {
  26561. /**
  26562. * Applies `autoplay` to video, if specified
  26563. */
  26564. autoPlay?: boolean;
  26565. /**
  26566. * Applies `loop` to video, if specified
  26567. */
  26568. loop?: boolean;
  26569. /**
  26570. * Automatically updates internal texture from video at every frame in the render loop
  26571. */
  26572. autoUpdateTexture: boolean;
  26573. /**
  26574. * Image src displayed during the video loading or until the user interacts with the video.
  26575. */
  26576. poster?: string;
  26577. }
  26578. /**
  26579. * If you want to display a video in your scene, this is the special texture for that.
  26580. * This special texture works similar to other textures, with the exception of a few parameters.
  26581. * @see https://doc.babylonjs.com/how_to/video_texture
  26582. */
  26583. export class VideoTexture extends Texture {
  26584. /**
  26585. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26586. */
  26587. readonly autoUpdateTexture: boolean;
  26588. /**
  26589. * The video instance used by the texture internally
  26590. */
  26591. readonly video: HTMLVideoElement;
  26592. private _onUserActionRequestedObservable;
  26593. /**
  26594. * Event triggerd when a dom action is required by the user to play the video.
  26595. * This happens due to recent changes in browser policies preventing video to auto start.
  26596. */
  26597. readonly onUserActionRequestedObservable: Observable<Texture>;
  26598. private _generateMipMaps;
  26599. private _engine;
  26600. private _stillImageCaptured;
  26601. private _displayingPosterTexture;
  26602. private _settings;
  26603. private _createInternalTextureOnEvent;
  26604. /**
  26605. * Creates a video texture.
  26606. * If you want to display a video in your scene, this is the special texture for that.
  26607. * This special texture works similar to other textures, with the exception of a few parameters.
  26608. * @see https://doc.babylonjs.com/how_to/video_texture
  26609. * @param name optional name, will detect from video source, if not defined
  26610. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26611. * @param scene is obviously the current scene.
  26612. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26613. * @param invertY is false by default but can be used to invert video on Y axis
  26614. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26615. * @param settings allows finer control over video usage
  26616. */
  26617. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26618. private _getName;
  26619. private _getVideo;
  26620. private _createInternalTexture;
  26621. private reset;
  26622. /**
  26623. * @hidden Internal method to initiate `update`.
  26624. */
  26625. _rebuild(): void;
  26626. /**
  26627. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26628. */
  26629. update(): void;
  26630. /**
  26631. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26632. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26633. */
  26634. updateTexture(isVisible: boolean): void;
  26635. protected _updateInternalTexture: () => void;
  26636. /**
  26637. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26638. * @param url New url.
  26639. */
  26640. updateURL(url: string): void;
  26641. /**
  26642. * Dispose the texture and release its associated resources.
  26643. */
  26644. dispose(): void;
  26645. /**
  26646. * Creates a video texture straight from a stream.
  26647. * @param scene Define the scene the texture should be created in
  26648. * @param stream Define the stream the texture should be created from
  26649. * @returns The created video texture as a promise
  26650. */
  26651. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26652. /**
  26653. * Creates a video texture straight from your WebCam video feed.
  26654. * @param scene Define the scene the texture should be created in
  26655. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26656. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26657. * @returns The created video texture as a promise
  26658. */
  26659. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26660. minWidth: number;
  26661. maxWidth: number;
  26662. minHeight: number;
  26663. maxHeight: number;
  26664. deviceId: string;
  26665. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26666. /**
  26667. * Creates a video texture straight from your WebCam video feed.
  26668. * @param scene Define the scene the texture should be created in
  26669. * @param onReady Define a callback to triggered once the texture will be ready
  26670. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26671. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26672. */
  26673. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26674. minWidth: number;
  26675. maxWidth: number;
  26676. minHeight: number;
  26677. maxHeight: number;
  26678. deviceId: string;
  26679. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26680. }
  26681. }
  26682. declare module BABYLON {
  26683. /**
  26684. * Interface for attribute information associated with buffer instanciation
  26685. */
  26686. export class InstancingAttributeInfo {
  26687. /**
  26688. * Index/offset of the attribute in the vertex shader
  26689. */
  26690. index: number;
  26691. /**
  26692. * size of the attribute, 1, 2, 3 or 4
  26693. */
  26694. attributeSize: number;
  26695. /**
  26696. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26697. * default is FLOAT
  26698. */
  26699. attribyteType: number;
  26700. /**
  26701. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26702. */
  26703. normalized: boolean;
  26704. /**
  26705. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26706. */
  26707. offset: number;
  26708. /**
  26709. * Name of the GLSL attribute, for debugging purpose only
  26710. */
  26711. attributeName: string;
  26712. }
  26713. /**
  26714. * Define options used to create a depth texture
  26715. */
  26716. export class DepthTextureCreationOptions {
  26717. /** Specifies whether or not a stencil should be allocated in the texture */
  26718. generateStencil?: boolean;
  26719. /** Specifies whether or not bilinear filtering is enable on the texture */
  26720. bilinearFiltering?: boolean;
  26721. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26722. comparisonFunction?: number;
  26723. /** Specifies if the created texture is a cube texture */
  26724. isCube?: boolean;
  26725. }
  26726. /**
  26727. * Class used to describe the capabilities of the engine relatively to the current browser
  26728. */
  26729. export class EngineCapabilities {
  26730. /** Maximum textures units per fragment shader */
  26731. maxTexturesImageUnits: number;
  26732. /** Maximum texture units per vertex shader */
  26733. maxVertexTextureImageUnits: number;
  26734. /** Maximum textures units in the entire pipeline */
  26735. maxCombinedTexturesImageUnits: number;
  26736. /** Maximum texture size */
  26737. maxTextureSize: number;
  26738. /** Maximum cube texture size */
  26739. maxCubemapTextureSize: number;
  26740. /** Maximum render texture size */
  26741. maxRenderTextureSize: number;
  26742. /** Maximum number of vertex attributes */
  26743. maxVertexAttribs: number;
  26744. /** Maximum number of varyings */
  26745. maxVaryingVectors: number;
  26746. /** Maximum number of uniforms per vertex shader */
  26747. maxVertexUniformVectors: number;
  26748. /** Maximum number of uniforms per fragment shader */
  26749. maxFragmentUniformVectors: number;
  26750. /** Defines if standard derivates (dx/dy) are supported */
  26751. standardDerivatives: boolean;
  26752. /** Defines if s3tc texture compression is supported */
  26753. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26754. /** Defines if pvrtc texture compression is supported */
  26755. pvrtc: any;
  26756. /** Defines if etc1 texture compression is supported */
  26757. etc1: any;
  26758. /** Defines if etc2 texture compression is supported */
  26759. etc2: any;
  26760. /** Defines if astc texture compression is supported */
  26761. astc: any;
  26762. /** Defines if float textures are supported */
  26763. textureFloat: boolean;
  26764. /** Defines if vertex array objects are supported */
  26765. vertexArrayObject: boolean;
  26766. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26767. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26768. /** Gets the maximum level of anisotropy supported */
  26769. maxAnisotropy: number;
  26770. /** Defines if instancing is supported */
  26771. instancedArrays: boolean;
  26772. /** Defines if 32 bits indices are supported */
  26773. uintIndices: boolean;
  26774. /** Defines if high precision shaders are supported */
  26775. highPrecisionShaderSupported: boolean;
  26776. /** Defines if depth reading in the fragment shader is supported */
  26777. fragmentDepthSupported: boolean;
  26778. /** Defines if float texture linear filtering is supported*/
  26779. textureFloatLinearFiltering: boolean;
  26780. /** Defines if rendering to float textures is supported */
  26781. textureFloatRender: boolean;
  26782. /** Defines if half float textures are supported*/
  26783. textureHalfFloat: boolean;
  26784. /** Defines if half float texture linear filtering is supported*/
  26785. textureHalfFloatLinearFiltering: boolean;
  26786. /** Defines if rendering to half float textures is supported */
  26787. textureHalfFloatRender: boolean;
  26788. /** Defines if textureLOD shader command is supported */
  26789. textureLOD: boolean;
  26790. /** Defines if draw buffers extension is supported */
  26791. drawBuffersExtension: boolean;
  26792. /** Defines if depth textures are supported */
  26793. depthTextureExtension: boolean;
  26794. /** Defines if float color buffer are supported */
  26795. colorBufferFloat: boolean;
  26796. /** Gets disjoint timer query extension (null if not supported) */
  26797. timerQuery: EXT_disjoint_timer_query;
  26798. /** Defines if timestamp can be used with timer query */
  26799. canUseTimestampForTimerQuery: boolean;
  26800. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26801. multiview: any;
  26802. /** Function used to let the system compiles shaders in background */
  26803. parallelShaderCompile: {
  26804. COMPLETION_STATUS_KHR: number;
  26805. };
  26806. }
  26807. /** Interface defining initialization parameters for Engine class */
  26808. export interface EngineOptions extends WebGLContextAttributes {
  26809. /**
  26810. * Defines if the engine should no exceed a specified device ratio
  26811. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26812. */
  26813. limitDeviceRatio?: number;
  26814. /**
  26815. * Defines if webvr should be enabled automatically
  26816. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26817. */
  26818. autoEnableWebVR?: boolean;
  26819. /**
  26820. * Defines if webgl2 should be turned off even if supported
  26821. * @see http://doc.babylonjs.com/features/webgl2
  26822. */
  26823. disableWebGL2Support?: boolean;
  26824. /**
  26825. * Defines if webaudio should be initialized as well
  26826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26827. */
  26828. audioEngine?: boolean;
  26829. /**
  26830. * Defines if animations should run using a deterministic lock step
  26831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26832. */
  26833. deterministicLockstep?: boolean;
  26834. /** Defines the maximum steps to use with deterministic lock step mode */
  26835. lockstepMaxSteps?: number;
  26836. /**
  26837. * Defines that engine should ignore context lost events
  26838. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26839. */
  26840. doNotHandleContextLost?: boolean;
  26841. /**
  26842. * Defines that engine should ignore modifying touch action attribute and style
  26843. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26844. */
  26845. doNotHandleTouchAction?: boolean;
  26846. /**
  26847. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26848. */
  26849. useHighPrecisionFloats?: boolean;
  26850. }
  26851. /**
  26852. * Defines the interface used by display changed events
  26853. */
  26854. export interface IDisplayChangedEventArgs {
  26855. /** Gets the vrDisplay object (if any) */
  26856. vrDisplay: Nullable<any>;
  26857. /** Gets a boolean indicating if webVR is supported */
  26858. vrSupported: boolean;
  26859. }
  26860. /**
  26861. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26862. */
  26863. export class Engine {
  26864. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26865. static ExceptionList: ({
  26866. key: string;
  26867. capture: string;
  26868. captureConstraint: number;
  26869. targets: string[];
  26870. } | {
  26871. key: string;
  26872. capture: null;
  26873. captureConstraint: null;
  26874. targets: string[];
  26875. })[];
  26876. /** Gets the list of created engines */
  26877. static readonly Instances: Engine[];
  26878. /**
  26879. * Gets the latest created engine
  26880. */
  26881. static readonly LastCreatedEngine: Nullable<Engine>;
  26882. /**
  26883. * Gets the latest created scene
  26884. */
  26885. static readonly LastCreatedScene: Nullable<Scene>;
  26886. /**
  26887. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26888. * @param flag defines which part of the materials must be marked as dirty
  26889. * @param predicate defines a predicate used to filter which materials should be affected
  26890. */
  26891. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26892. /**
  26893. * Hidden
  26894. */
  26895. static _TextureLoaders: IInternalTextureLoader[];
  26896. /** Defines that alpha blending is disabled */
  26897. static readonly ALPHA_DISABLE: number;
  26898. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26899. static readonly ALPHA_ADD: number;
  26900. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26901. static readonly ALPHA_COMBINE: number;
  26902. /** Defines that alpha blending to DEST - SRC * DEST */
  26903. static readonly ALPHA_SUBTRACT: number;
  26904. /** Defines that alpha blending to SRC * DEST */
  26905. static readonly ALPHA_MULTIPLY: number;
  26906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26907. static readonly ALPHA_MAXIMIZED: number;
  26908. /** Defines that alpha blending to SRC + DEST */
  26909. static readonly ALPHA_ONEONE: number;
  26910. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26911. static readonly ALPHA_PREMULTIPLIED: number;
  26912. /**
  26913. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26914. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26915. */
  26916. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26917. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26918. static readonly ALPHA_INTERPOLATE: number;
  26919. /**
  26920. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26921. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26922. */
  26923. static readonly ALPHA_SCREENMODE: number;
  26924. /** Defines that the ressource is not delayed*/
  26925. static readonly DELAYLOADSTATE_NONE: number;
  26926. /** Defines that the ressource was successfully delay loaded */
  26927. static readonly DELAYLOADSTATE_LOADED: number;
  26928. /** Defines that the ressource is currently delay loading */
  26929. static readonly DELAYLOADSTATE_LOADING: number;
  26930. /** Defines that the ressource is delayed and has not started loading */
  26931. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26932. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26933. static readonly NEVER: number;
  26934. /** 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 */
  26935. static readonly ALWAYS: number;
  26936. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26937. static readonly LESS: number;
  26938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26939. static readonly EQUAL: number;
  26940. /** 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 */
  26941. static readonly LEQUAL: number;
  26942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26943. static readonly GREATER: number;
  26944. /** 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 */
  26945. static readonly GEQUAL: number;
  26946. /** 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 */
  26947. static readonly NOTEQUAL: number;
  26948. /** Passed to stencilOperation to specify that stencil value must be kept */
  26949. static readonly KEEP: number;
  26950. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26951. static readonly REPLACE: number;
  26952. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26953. static readonly INCR: number;
  26954. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26955. static readonly DECR: number;
  26956. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26957. static readonly INVERT: number;
  26958. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26959. static readonly INCR_WRAP: number;
  26960. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26961. static readonly DECR_WRAP: number;
  26962. /** Texture is not repeating outside of 0..1 UVs */
  26963. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26964. /** Texture is repeating outside of 0..1 UVs */
  26965. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26966. /** Texture is repeating and mirrored */
  26967. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26968. /** ALPHA */
  26969. static readonly TEXTUREFORMAT_ALPHA: number;
  26970. /** LUMINANCE */
  26971. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26972. /** LUMINANCE_ALPHA */
  26973. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26974. /** RGB */
  26975. static readonly TEXTUREFORMAT_RGB: number;
  26976. /** RGBA */
  26977. static readonly TEXTUREFORMAT_RGBA: number;
  26978. /** RED */
  26979. static readonly TEXTUREFORMAT_RED: number;
  26980. /** RED (2nd reference) */
  26981. static readonly TEXTUREFORMAT_R: number;
  26982. /** RG */
  26983. static readonly TEXTUREFORMAT_RG: number;
  26984. /** RED_INTEGER */
  26985. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26986. /** RED_INTEGER (2nd reference) */
  26987. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26988. /** RG_INTEGER */
  26989. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26990. /** RGB_INTEGER */
  26991. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26992. /** RGBA_INTEGER */
  26993. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26994. /** UNSIGNED_BYTE */
  26995. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26996. /** UNSIGNED_BYTE (2nd reference) */
  26997. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26998. /** FLOAT */
  26999. static readonly TEXTURETYPE_FLOAT: number;
  27000. /** HALF_FLOAT */
  27001. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27002. /** BYTE */
  27003. static readonly TEXTURETYPE_BYTE: number;
  27004. /** SHORT */
  27005. static readonly TEXTURETYPE_SHORT: number;
  27006. /** UNSIGNED_SHORT */
  27007. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27008. /** INT */
  27009. static readonly TEXTURETYPE_INT: number;
  27010. /** UNSIGNED_INT */
  27011. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27012. /** UNSIGNED_SHORT_4_4_4_4 */
  27013. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27014. /** UNSIGNED_SHORT_5_5_5_1 */
  27015. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27016. /** UNSIGNED_SHORT_5_6_5 */
  27017. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27018. /** UNSIGNED_INT_2_10_10_10_REV */
  27019. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27020. /** UNSIGNED_INT_24_8 */
  27021. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27022. /** UNSIGNED_INT_10F_11F_11F_REV */
  27023. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27024. /** UNSIGNED_INT_5_9_9_9_REV */
  27025. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27026. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27027. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27028. /** nearest is mag = nearest and min = nearest and mip = linear */
  27029. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27030. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27031. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27032. /** Trilinear is mag = linear and min = linear and mip = linear */
  27033. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27034. /** nearest is mag = nearest and min = nearest and mip = linear */
  27035. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27036. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27037. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27038. /** Trilinear is mag = linear and min = linear and mip = linear */
  27039. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27040. /** mag = nearest and min = nearest and mip = nearest */
  27041. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27042. /** mag = nearest and min = linear and mip = nearest */
  27043. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27044. /** mag = nearest and min = linear and mip = linear */
  27045. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27046. /** mag = nearest and min = linear and mip = none */
  27047. static readonly TEXTURE_NEAREST_LINEAR: number;
  27048. /** mag = nearest and min = nearest and mip = none */
  27049. static readonly TEXTURE_NEAREST_NEAREST: number;
  27050. /** mag = linear and min = nearest and mip = nearest */
  27051. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27052. /** mag = linear and min = nearest and mip = linear */
  27053. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27054. /** mag = linear and min = linear and mip = none */
  27055. static readonly TEXTURE_LINEAR_LINEAR: number;
  27056. /** mag = linear and min = nearest and mip = none */
  27057. static readonly TEXTURE_LINEAR_NEAREST: number;
  27058. /** Explicit coordinates mode */
  27059. static readonly TEXTURE_EXPLICIT_MODE: number;
  27060. /** Spherical coordinates mode */
  27061. static readonly TEXTURE_SPHERICAL_MODE: number;
  27062. /** Planar coordinates mode */
  27063. static readonly TEXTURE_PLANAR_MODE: number;
  27064. /** Cubic coordinates mode */
  27065. static readonly TEXTURE_CUBIC_MODE: number;
  27066. /** Projection coordinates mode */
  27067. static readonly TEXTURE_PROJECTION_MODE: number;
  27068. /** Skybox coordinates mode */
  27069. static readonly TEXTURE_SKYBOX_MODE: number;
  27070. /** Inverse Cubic coordinates mode */
  27071. static readonly TEXTURE_INVCUBIC_MODE: number;
  27072. /** Equirectangular coordinates mode */
  27073. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27074. /** Equirectangular Fixed coordinates mode */
  27075. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27076. /** Equirectangular Fixed Mirrored coordinates mode */
  27077. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27078. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27079. static readonly SCALEMODE_FLOOR: number;
  27080. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27081. static readonly SCALEMODE_NEAREST: number;
  27082. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27083. static readonly SCALEMODE_CEILING: number;
  27084. /**
  27085. * Returns the current npm package of the sdk
  27086. */
  27087. static readonly NpmPackage: string;
  27088. /**
  27089. * Returns the current version of the framework
  27090. */
  27091. static readonly Version: string;
  27092. /**
  27093. * Returns a string describing the current engine
  27094. */
  27095. readonly description: string;
  27096. /**
  27097. * Gets or sets the epsilon value used by collision engine
  27098. */
  27099. static CollisionsEpsilon: number;
  27100. /**
  27101. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27102. */
  27103. static ShadersRepository: string;
  27104. /**
  27105. * Method called to create the default loading screen.
  27106. * This can be overriden in your own app.
  27107. * @param canvas The rendering canvas element
  27108. * @returns The loading screen
  27109. */
  27110. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27111. /**
  27112. * Method called to create the default rescale post process on each engine.
  27113. */
  27114. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27115. /**
  27116. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27117. */
  27118. forcePOTTextures: boolean;
  27119. /**
  27120. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27121. */
  27122. isFullscreen: boolean;
  27123. /**
  27124. * Gets a boolean indicating if the pointer is currently locked
  27125. */
  27126. isPointerLock: boolean;
  27127. /**
  27128. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27129. */
  27130. cullBackFaces: boolean;
  27131. /**
  27132. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27133. */
  27134. renderEvenInBackground: boolean;
  27135. /**
  27136. * Gets or sets a boolean indicating that cache can be kept between frames
  27137. */
  27138. preventCacheWipeBetweenFrames: boolean;
  27139. /**
  27140. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27141. **/
  27142. enableOfflineSupport: boolean;
  27143. /**
  27144. * 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)
  27145. **/
  27146. disableManifestCheck: boolean;
  27147. /**
  27148. * Gets the list of created scenes
  27149. */
  27150. scenes: Scene[];
  27151. /**
  27152. * Event raised when a new scene is created
  27153. */
  27154. onNewSceneAddedObservable: Observable<Scene>;
  27155. /**
  27156. * Gets the list of created postprocesses
  27157. */
  27158. postProcesses: PostProcess[];
  27159. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27160. validateShaderPrograms: boolean;
  27161. /**
  27162. * Observable event triggered each time the rendering canvas is resized
  27163. */
  27164. onResizeObservable: Observable<Engine>;
  27165. /**
  27166. * Observable event triggered each time the canvas loses focus
  27167. */
  27168. onCanvasBlurObservable: Observable<Engine>;
  27169. /**
  27170. * Observable event triggered each time the canvas gains focus
  27171. */
  27172. onCanvasFocusObservable: Observable<Engine>;
  27173. /**
  27174. * Observable event triggered each time the canvas receives pointerout event
  27175. */
  27176. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27177. /**
  27178. * Observable event triggered before each texture is initialized
  27179. */
  27180. onBeforeTextureInitObservable: Observable<Texture>;
  27181. private _vrDisplay;
  27182. private _vrSupported;
  27183. private _oldSize;
  27184. private _oldHardwareScaleFactor;
  27185. private _vrExclusivePointerMode;
  27186. private _webVRInitPromise;
  27187. /**
  27188. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27189. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27190. */
  27191. readonly isInVRExclusivePointerMode: boolean;
  27192. /**
  27193. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27194. */
  27195. disableUniformBuffers: boolean;
  27196. /** @hidden */
  27197. _uniformBuffers: UniformBuffer[];
  27198. /**
  27199. * Gets a boolean indicating that the engine supports uniform buffers
  27200. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27201. */
  27202. readonly supportsUniformBuffers: boolean;
  27203. /**
  27204. * Observable raised when the engine begins a new frame
  27205. */
  27206. onBeginFrameObservable: Observable<Engine>;
  27207. /**
  27208. * If set, will be used to request the next animation frame for the render loop
  27209. */
  27210. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27211. /**
  27212. * Observable raised when the engine ends the current frame
  27213. */
  27214. onEndFrameObservable: Observable<Engine>;
  27215. /**
  27216. * Observable raised when the engine is about to compile a shader
  27217. */
  27218. onBeforeShaderCompilationObservable: Observable<Engine>;
  27219. /**
  27220. * Observable raised when the engine has jsut compiled a shader
  27221. */
  27222. onAfterShaderCompilationObservable: Observable<Engine>;
  27223. /** @hidden */
  27224. _gl: WebGLRenderingContext;
  27225. private _renderingCanvas;
  27226. private _windowIsBackground;
  27227. private _webGLVersion;
  27228. protected _highPrecisionShadersAllowed: boolean;
  27229. /** @hidden */
  27230. readonly _shouldUseHighPrecisionShader: boolean;
  27231. /**
  27232. * Gets a boolean indicating that only power of 2 textures are supported
  27233. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27234. */
  27235. readonly needPOTTextures: boolean;
  27236. /** @hidden */
  27237. _badOS: boolean;
  27238. /** @hidden */
  27239. _badDesktopOS: boolean;
  27240. /**
  27241. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27242. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27243. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27244. */
  27245. disableTextureBindingOptimization: boolean;
  27246. /**
  27247. * Gets the audio engine
  27248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27249. * @ignorenaming
  27250. */
  27251. static audioEngine: IAudioEngine;
  27252. /**
  27253. * Default AudioEngine factory responsible of creating the Audio Engine.
  27254. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27255. */
  27256. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27257. /**
  27258. * Default offline support factory responsible of creating a tool used to store data locally.
  27259. * By default, this will create a Database object if the workload has been embedded.
  27260. */
  27261. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27262. private _onFocus;
  27263. private _onBlur;
  27264. private _onCanvasPointerOut;
  27265. private _onCanvasBlur;
  27266. private _onCanvasFocus;
  27267. private _onFullscreenChange;
  27268. private _onPointerLockChange;
  27269. private _onVRDisplayPointerRestricted;
  27270. private _onVRDisplayPointerUnrestricted;
  27271. private _onVrDisplayConnect;
  27272. private _onVrDisplayDisconnect;
  27273. private _onVrDisplayPresentChange;
  27274. /**
  27275. * Observable signaled when VR display mode changes
  27276. */
  27277. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27278. /**
  27279. * Observable signaled when VR request present is complete
  27280. */
  27281. onVRRequestPresentComplete: Observable<boolean>;
  27282. /**
  27283. * Observable signaled when VR request present starts
  27284. */
  27285. onVRRequestPresentStart: Observable<Engine>;
  27286. private _hardwareScalingLevel;
  27287. /** @hidden */
  27288. protected _caps: EngineCapabilities;
  27289. private _pointerLockRequested;
  27290. private _isStencilEnable;
  27291. private _colorWrite;
  27292. private _loadingScreen;
  27293. /** @hidden */
  27294. _drawCalls: PerfCounter;
  27295. /** @hidden */
  27296. _textureCollisions: PerfCounter;
  27297. private _glVersion;
  27298. private _glRenderer;
  27299. private _glVendor;
  27300. private _videoTextureSupported;
  27301. private _renderingQueueLaunched;
  27302. private _activeRenderLoops;
  27303. private _deterministicLockstep;
  27304. private _lockstepMaxSteps;
  27305. /**
  27306. * Observable signaled when a context lost event is raised
  27307. */
  27308. onContextLostObservable: Observable<Engine>;
  27309. /**
  27310. * Observable signaled when a context restored event is raised
  27311. */
  27312. onContextRestoredObservable: Observable<Engine>;
  27313. private _onContextLost;
  27314. private _onContextRestored;
  27315. private _contextWasLost;
  27316. private _doNotHandleContextLost;
  27317. /**
  27318. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27320. */
  27321. doNotHandleContextLost: boolean;
  27322. private _performanceMonitor;
  27323. private _fps;
  27324. private _deltaTime;
  27325. /**
  27326. * Turn this value on if you want to pause FPS computation when in background
  27327. */
  27328. disablePerformanceMonitorInBackground: boolean;
  27329. /**
  27330. * Gets the performance monitor attached to this engine
  27331. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27332. */
  27333. readonly performanceMonitor: PerformanceMonitor;
  27334. /**
  27335. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27336. */
  27337. disableVertexArrayObjects: boolean;
  27338. /** @hidden */
  27339. protected _depthCullingState: _DepthCullingState;
  27340. /** @hidden */
  27341. protected _stencilState: _StencilState;
  27342. /** @hidden */
  27343. protected _alphaState: _AlphaState;
  27344. /** @hidden */
  27345. protected _alphaMode: number;
  27346. protected _internalTexturesCache: InternalTexture[];
  27347. /** @hidden */
  27348. protected _activeChannel: number;
  27349. private _currentTextureChannel;
  27350. /** @hidden */
  27351. protected _boundTexturesCache: {
  27352. [key: string]: Nullable<InternalTexture>;
  27353. };
  27354. /** @hidden */
  27355. protected _currentEffect: Nullable<Effect>;
  27356. /** @hidden */
  27357. protected _currentProgram: Nullable<WebGLProgram>;
  27358. private _compiledEffects;
  27359. private _vertexAttribArraysEnabled;
  27360. /** @hidden */
  27361. protected _cachedViewport: Nullable<Viewport>;
  27362. private _cachedVertexArrayObject;
  27363. /** @hidden */
  27364. protected _cachedVertexBuffers: any;
  27365. /** @hidden */
  27366. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27367. /** @hidden */
  27368. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27369. /** @hidden */
  27370. protected _currentRenderTarget: Nullable<InternalTexture>;
  27371. private _uintIndicesCurrentlySet;
  27372. private _currentBoundBuffer;
  27373. /** @hidden */
  27374. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27375. private _currentBufferPointers;
  27376. private _currentInstanceLocations;
  27377. private _currentInstanceBuffers;
  27378. private _textureUnits;
  27379. private _firstBoundInternalTextureTracker;
  27380. private _lastBoundInternalTextureTracker;
  27381. private _workingCanvas;
  27382. private _workingContext;
  27383. private _rescalePostProcess;
  27384. private _dummyFramebuffer;
  27385. private _externalData;
  27386. private _bindedRenderFunction;
  27387. private _vaoRecordInProgress;
  27388. private _mustWipeVertexAttributes;
  27389. private _emptyTexture;
  27390. private _emptyCubeTexture;
  27391. private _emptyTexture3D;
  27392. /** @hidden */
  27393. _frameHandler: number;
  27394. private _nextFreeTextureSlots;
  27395. private _maxSimultaneousTextures;
  27396. private _activeRequests;
  27397. private _texturesSupported;
  27398. private _textureFormatInUse;
  27399. /**
  27400. * Gets the list of texture formats supported
  27401. */
  27402. readonly texturesSupported: Array<string>;
  27403. /**
  27404. * Gets the list of texture formats in use
  27405. */
  27406. readonly textureFormatInUse: Nullable<string>;
  27407. /**
  27408. * Gets the current viewport
  27409. */
  27410. readonly currentViewport: Nullable<Viewport>;
  27411. /**
  27412. * Gets the default empty texture
  27413. */
  27414. readonly emptyTexture: InternalTexture;
  27415. /**
  27416. * Gets the default empty 3D texture
  27417. */
  27418. readonly emptyTexture3D: InternalTexture;
  27419. /**
  27420. * Gets the default empty cube texture
  27421. */
  27422. readonly emptyCubeTexture: InternalTexture;
  27423. /**
  27424. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27425. */
  27426. readonly premultipliedAlpha: boolean;
  27427. /**
  27428. * Creates a new engine
  27429. * @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
  27430. * @param antialias defines enable antialiasing (default: false)
  27431. * @param options defines further options to be sent to the getContext() function
  27432. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27433. */
  27434. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27435. private _disableTouchAction;
  27436. private _rebuildInternalTextures;
  27437. private _rebuildEffects;
  27438. /**
  27439. * Gets a boolean indicating if all created effects are ready
  27440. * @returns true if all effects are ready
  27441. */
  27442. areAllEffectsReady(): boolean;
  27443. private _rebuildBuffers;
  27444. private _initGLContext;
  27445. /**
  27446. * Gets version of the current webGL context
  27447. */
  27448. readonly webGLVersion: number;
  27449. /**
  27450. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27451. */
  27452. readonly isStencilEnable: boolean;
  27453. private _prepareWorkingCanvas;
  27454. /**
  27455. * Reset the texture cache to empty state
  27456. */
  27457. resetTextureCache(): void;
  27458. /**
  27459. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27461. * @returns true if engine is in deterministic lock step mode
  27462. */
  27463. isDeterministicLockStep(): boolean;
  27464. /**
  27465. * Gets the max steps when engine is running in deterministic lock step
  27466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27467. * @returns the max steps
  27468. */
  27469. getLockstepMaxSteps(): number;
  27470. /**
  27471. * Gets an object containing information about the current webGL context
  27472. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27473. */
  27474. getGlInfo(): {
  27475. vendor: string;
  27476. renderer: string;
  27477. version: string;
  27478. };
  27479. /**
  27480. * Gets current aspect ratio
  27481. * @param camera defines the camera to use to get the aspect ratio
  27482. * @param useScreen defines if screen size must be used (or the current render target if any)
  27483. * @returns a number defining the aspect ratio
  27484. */
  27485. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27486. /**
  27487. * Gets current screen aspect ratio
  27488. * @returns a number defining the aspect ratio
  27489. */
  27490. getScreenAspectRatio(): number;
  27491. /**
  27492. * Gets the current render width
  27493. * @param useScreen defines if screen size must be used (or the current render target if any)
  27494. * @returns a number defining the current render width
  27495. */
  27496. getRenderWidth(useScreen?: boolean): number;
  27497. /**
  27498. * Gets the current render height
  27499. * @param useScreen defines if screen size must be used (or the current render target if any)
  27500. * @returns a number defining the current render height
  27501. */
  27502. getRenderHeight(useScreen?: boolean): number;
  27503. /**
  27504. * Gets the HTML canvas attached with the current webGL context
  27505. * @returns a HTML canvas
  27506. */
  27507. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27508. /**
  27509. * Gets the client rect of the HTML canvas attached with the current webGL context
  27510. * @returns a client rectanglee
  27511. */
  27512. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27513. /**
  27514. * Defines the hardware scaling level.
  27515. * By default the hardware scaling level is computed from the window device ratio.
  27516. * 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.
  27517. * @param level defines the level to use
  27518. */
  27519. setHardwareScalingLevel(level: number): void;
  27520. /**
  27521. * Gets the current hardware scaling level.
  27522. * By default the hardware scaling level is computed from the window device ratio.
  27523. * 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.
  27524. * @returns a number indicating the current hardware scaling level
  27525. */
  27526. getHardwareScalingLevel(): number;
  27527. /**
  27528. * Gets the list of loaded textures
  27529. * @returns an array containing all loaded textures
  27530. */
  27531. getLoadedTexturesCache(): InternalTexture[];
  27532. /**
  27533. * Gets the object containing all engine capabilities
  27534. * @returns the EngineCapabilities object
  27535. */
  27536. getCaps(): EngineCapabilities;
  27537. /**
  27538. * Gets the current depth function
  27539. * @returns a number defining the depth function
  27540. */
  27541. getDepthFunction(): Nullable<number>;
  27542. /**
  27543. * Sets the current depth function
  27544. * @param depthFunc defines the function to use
  27545. */
  27546. setDepthFunction(depthFunc: number): void;
  27547. /**
  27548. * Sets the current depth function to GREATER
  27549. */
  27550. setDepthFunctionToGreater(): void;
  27551. /**
  27552. * Sets the current depth function to GEQUAL
  27553. */
  27554. setDepthFunctionToGreaterOrEqual(): void;
  27555. /**
  27556. * Sets the current depth function to LESS
  27557. */
  27558. setDepthFunctionToLess(): void;
  27559. private _cachedStencilBuffer;
  27560. private _cachedStencilFunction;
  27561. private _cachedStencilMask;
  27562. private _cachedStencilOperationPass;
  27563. private _cachedStencilOperationFail;
  27564. private _cachedStencilOperationDepthFail;
  27565. private _cachedStencilReference;
  27566. /**
  27567. * Caches the the state of the stencil buffer
  27568. */
  27569. cacheStencilState(): void;
  27570. /**
  27571. * Restores the state of the stencil buffer
  27572. */
  27573. restoreStencilState(): void;
  27574. /**
  27575. * Sets the current depth function to LEQUAL
  27576. */
  27577. setDepthFunctionToLessOrEqual(): void;
  27578. /**
  27579. * Gets a boolean indicating if stencil buffer is enabled
  27580. * @returns the current stencil buffer state
  27581. */
  27582. getStencilBuffer(): boolean;
  27583. /**
  27584. * Enable or disable the stencil buffer
  27585. * @param enable defines if the stencil buffer must be enabled or disabled
  27586. */
  27587. setStencilBuffer(enable: boolean): void;
  27588. /**
  27589. * Gets the current stencil mask
  27590. * @returns a number defining the new stencil mask to use
  27591. */
  27592. getStencilMask(): number;
  27593. /**
  27594. * Sets the current stencil mask
  27595. * @param mask defines the new stencil mask to use
  27596. */
  27597. setStencilMask(mask: number): void;
  27598. /**
  27599. * Gets the current stencil function
  27600. * @returns a number defining the stencil function to use
  27601. */
  27602. getStencilFunction(): number;
  27603. /**
  27604. * Gets the current stencil reference value
  27605. * @returns a number defining the stencil reference value to use
  27606. */
  27607. getStencilFunctionReference(): number;
  27608. /**
  27609. * Gets the current stencil mask
  27610. * @returns a number defining the stencil mask to use
  27611. */
  27612. getStencilFunctionMask(): number;
  27613. /**
  27614. * Sets the current stencil function
  27615. * @param stencilFunc defines the new stencil function to use
  27616. */
  27617. setStencilFunction(stencilFunc: number): void;
  27618. /**
  27619. * Sets the current stencil reference
  27620. * @param reference defines the new stencil reference to use
  27621. */
  27622. setStencilFunctionReference(reference: number): void;
  27623. /**
  27624. * Sets the current stencil mask
  27625. * @param mask defines the new stencil mask to use
  27626. */
  27627. setStencilFunctionMask(mask: number): void;
  27628. /**
  27629. * Gets the current stencil operation when stencil fails
  27630. * @returns a number defining stencil operation to use when stencil fails
  27631. */
  27632. getStencilOperationFail(): number;
  27633. /**
  27634. * Gets the current stencil operation when depth fails
  27635. * @returns a number defining stencil operation to use when depth fails
  27636. */
  27637. getStencilOperationDepthFail(): number;
  27638. /**
  27639. * Gets the current stencil operation when stencil passes
  27640. * @returns a number defining stencil operation to use when stencil passes
  27641. */
  27642. getStencilOperationPass(): number;
  27643. /**
  27644. * Sets the stencil operation to use when stencil fails
  27645. * @param operation defines the stencil operation to use when stencil fails
  27646. */
  27647. setStencilOperationFail(operation: number): void;
  27648. /**
  27649. * Sets the stencil operation to use when depth fails
  27650. * @param operation defines the stencil operation to use when depth fails
  27651. */
  27652. setStencilOperationDepthFail(operation: number): void;
  27653. /**
  27654. * Sets the stencil operation to use when stencil passes
  27655. * @param operation defines the stencil operation to use when stencil passes
  27656. */
  27657. setStencilOperationPass(operation: number): void;
  27658. /**
  27659. * Sets a boolean indicating if the dithering state is enabled or disabled
  27660. * @param value defines the dithering state
  27661. */
  27662. setDitheringState(value: boolean): void;
  27663. /**
  27664. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27665. * @param value defines the rasterizer state
  27666. */
  27667. setRasterizerState(value: boolean): void;
  27668. /**
  27669. * stop executing a render loop function and remove it from the execution array
  27670. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27671. */
  27672. stopRenderLoop(renderFunction?: () => void): void;
  27673. /** @hidden */
  27674. _renderLoop(): void;
  27675. /**
  27676. * Register and execute a render loop. The engine can have more than one render function
  27677. * @param renderFunction defines the function to continuously execute
  27678. */
  27679. runRenderLoop(renderFunction: () => void): void;
  27680. /**
  27681. * Toggle full screen mode
  27682. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27683. */
  27684. switchFullscreen(requestPointerLock: boolean): void;
  27685. /**
  27686. * Enters full screen mode
  27687. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27688. */
  27689. enterFullscreen(requestPointerLock: boolean): void;
  27690. /**
  27691. * Exits full screen mode
  27692. */
  27693. exitFullscreen(): void;
  27694. /**
  27695. * Clear the current render buffer or the current render target (if any is set up)
  27696. * @param color defines the color to use
  27697. * @param backBuffer defines if the back buffer must be cleared
  27698. * @param depth defines if the depth buffer must be cleared
  27699. * @param stencil defines if the stencil buffer must be cleared
  27700. */
  27701. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27702. /**
  27703. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27704. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27705. * @param y defines the y-coordinate of the corner of the clear rectangle
  27706. * @param width defines the width of the clear rectangle
  27707. * @param height defines the height of the clear rectangle
  27708. * @param clearColor defines the clear color
  27709. */
  27710. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27711. /**
  27712. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27713. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27714. * @param y defines the y-coordinate of the corner of the clear rectangle
  27715. * @param width defines the width of the clear rectangle
  27716. * @param height defines the height of the clear rectangle
  27717. */
  27718. enableScissor(x: number, y: number, width: number, height: number): void;
  27719. /**
  27720. * Disable previously set scissor test rectangle
  27721. */
  27722. disableScissor(): void;
  27723. private _viewportCached;
  27724. /** @hidden */
  27725. _viewport(x: number, y: number, width: number, height: number): void;
  27726. /**
  27727. * Set the WebGL's viewport
  27728. * @param viewport defines the viewport element to be used
  27729. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27730. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27731. */
  27732. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27733. /**
  27734. * Directly set the WebGL Viewport
  27735. * @param x defines the x coordinate of the viewport (in screen space)
  27736. * @param y defines the y coordinate of the viewport (in screen space)
  27737. * @param width defines the width of the viewport (in screen space)
  27738. * @param height defines the height of the viewport (in screen space)
  27739. * @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
  27740. */
  27741. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27742. /**
  27743. * Begin a new frame
  27744. */
  27745. beginFrame(): void;
  27746. /**
  27747. * Enf the current frame
  27748. */
  27749. endFrame(): void;
  27750. /**
  27751. * Resize the view according to the canvas' size
  27752. */
  27753. resize(): void;
  27754. /**
  27755. * Force a specific size of the canvas
  27756. * @param width defines the new canvas' width
  27757. * @param height defines the new canvas' height
  27758. */
  27759. setSize(width: number, height: number): void;
  27760. /**
  27761. * Gets a boolean indicating if a webVR device was detected
  27762. * @returns true if a webVR device was detected
  27763. */
  27764. isVRDevicePresent(): boolean;
  27765. /**
  27766. * Gets the current webVR device
  27767. * @returns the current webVR device (or null)
  27768. */
  27769. getVRDevice(): any;
  27770. /**
  27771. * Initializes a webVR display and starts listening to display change events
  27772. * The onVRDisplayChangedObservable will be notified upon these changes
  27773. * @returns The onVRDisplayChangedObservable
  27774. */
  27775. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27776. /**
  27777. * Initializes a webVR display and starts listening to display change events
  27778. * The onVRDisplayChangedObservable will be notified upon these changes
  27779. * @returns A promise containing a VRDisplay and if vr is supported
  27780. */
  27781. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27782. /**
  27783. * Call this function to switch to webVR mode
  27784. * Will do nothing if webVR is not supported or if there is no webVR device
  27785. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27786. */
  27787. enableVR(): void;
  27788. /**
  27789. * Call this function to leave webVR mode
  27790. * Will do nothing if webVR is not supported or if there is no webVR device
  27791. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27792. */
  27793. disableVR(): void;
  27794. private _onVRFullScreenTriggered;
  27795. private _getVRDisplaysAsync;
  27796. /**
  27797. * Binds the frame buffer to the specified texture.
  27798. * @param texture The texture to render to or null for the default canvas
  27799. * @param faceIndex The face of the texture to render to in case of cube texture
  27800. * @param requiredWidth The width of the target to render to
  27801. * @param requiredHeight The height of the target to render to
  27802. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27803. * @param depthStencilTexture The depth stencil texture to use to render
  27804. * @param lodLevel defines le lod level to bind to the frame buffer
  27805. */
  27806. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27807. private bindUnboundFramebuffer;
  27808. /**
  27809. * Unbind the current render target texture from the webGL context
  27810. * @param texture defines the render target texture to unbind
  27811. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27812. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27813. */
  27814. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27815. /**
  27816. * Unbind a list of render target textures from the webGL context
  27817. * This is used only when drawBuffer extension or webGL2 are active
  27818. * @param textures defines the render target textures to unbind
  27819. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27820. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27821. */
  27822. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27823. /**
  27824. * Force the mipmap generation for the given render target texture
  27825. * @param texture defines the render target texture to use
  27826. */
  27827. generateMipMapsForCubemap(texture: InternalTexture): void;
  27828. /**
  27829. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27830. */
  27831. flushFramebuffer(): void;
  27832. /**
  27833. * Unbind the current render target and bind the default framebuffer
  27834. */
  27835. restoreDefaultFramebuffer(): void;
  27836. /**
  27837. * Create an uniform buffer
  27838. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27839. * @param elements defines the content of the uniform buffer
  27840. * @returns the webGL uniform buffer
  27841. */
  27842. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27843. /**
  27844. * Create a dynamic uniform buffer
  27845. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27846. * @param elements defines the content of the uniform buffer
  27847. * @returns the webGL uniform buffer
  27848. */
  27849. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27850. /**
  27851. * Update an existing uniform buffer
  27852. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27853. * @param uniformBuffer defines the target uniform buffer
  27854. * @param elements defines the content to update
  27855. * @param offset defines the offset in the uniform buffer where update should start
  27856. * @param count defines the size of the data to update
  27857. */
  27858. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27859. private _resetVertexBufferBinding;
  27860. /**
  27861. * Creates a vertex buffer
  27862. * @param data the data for the vertex buffer
  27863. * @returns the new WebGL static buffer
  27864. */
  27865. createVertexBuffer(data: DataArray): WebGLBuffer;
  27866. /**
  27867. * Creates a dynamic vertex buffer
  27868. * @param data the data for the dynamic vertex buffer
  27869. * @returns the new WebGL dynamic buffer
  27870. */
  27871. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27872. /**
  27873. * Update a dynamic index buffer
  27874. * @param indexBuffer defines the target index buffer
  27875. * @param indices defines the data to update
  27876. * @param offset defines the offset in the target index buffer where update should start
  27877. */
  27878. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27879. /**
  27880. * Updates a dynamic vertex buffer.
  27881. * @param vertexBuffer the vertex buffer to update
  27882. * @param data the data used to update the vertex buffer
  27883. * @param byteOffset the byte offset of the data
  27884. * @param byteLength the byte length of the data
  27885. */
  27886. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27887. private _resetIndexBufferBinding;
  27888. /**
  27889. * Creates a new index buffer
  27890. * @param indices defines the content of the index buffer
  27891. * @param updatable defines if the index buffer must be updatable
  27892. * @returns a new webGL buffer
  27893. */
  27894. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27895. /**
  27896. * Bind a webGL buffer to the webGL context
  27897. * @param buffer defines the buffer to bind
  27898. */
  27899. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27900. /**
  27901. * Bind an uniform buffer to the current webGL context
  27902. * @param buffer defines the buffer to bind
  27903. */
  27904. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27905. /**
  27906. * Bind a buffer to the current webGL context at a given location
  27907. * @param buffer defines the buffer to bind
  27908. * @param location defines the index where to bind the buffer
  27909. */
  27910. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27911. /**
  27912. * Bind a specific block at a given index in a specific shader program
  27913. * @param shaderProgram defines the shader program
  27914. * @param blockName defines the block name
  27915. * @param index defines the index where to bind the block
  27916. */
  27917. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27918. private bindIndexBuffer;
  27919. private bindBuffer;
  27920. /**
  27921. * update the bound buffer with the given data
  27922. * @param data defines the data to update
  27923. */
  27924. updateArrayBuffer(data: Float32Array): void;
  27925. private _vertexAttribPointer;
  27926. private _bindIndexBufferWithCache;
  27927. private _bindVertexBuffersAttributes;
  27928. /**
  27929. * Records a vertex array object
  27930. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27931. * @param vertexBuffers defines the list of vertex buffers to store
  27932. * @param indexBuffer defines the index buffer to store
  27933. * @param effect defines the effect to store
  27934. * @returns the new vertex array object
  27935. */
  27936. recordVertexArrayObject(vertexBuffers: {
  27937. [key: string]: VertexBuffer;
  27938. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27939. /**
  27940. * Bind a specific vertex array object
  27941. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27942. * @param vertexArrayObject defines the vertex array object to bind
  27943. * @param indexBuffer defines the index buffer to bind
  27944. */
  27945. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27946. /**
  27947. * Bind webGl buffers directly to the webGL context
  27948. * @param vertexBuffer defines the vertex buffer to bind
  27949. * @param indexBuffer defines the index buffer to bind
  27950. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27951. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27952. * @param effect defines the effect associated with the vertex buffer
  27953. */
  27954. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27955. private _unbindVertexArrayObject;
  27956. /**
  27957. * Bind a list of vertex buffers to the webGL context
  27958. * @param vertexBuffers defines the list of vertex buffers to bind
  27959. * @param indexBuffer defines the index buffer to bind
  27960. * @param effect defines the effect associated with the vertex buffers
  27961. */
  27962. bindBuffers(vertexBuffers: {
  27963. [key: string]: Nullable<VertexBuffer>;
  27964. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27965. /**
  27966. * Unbind all instance attributes
  27967. */
  27968. unbindInstanceAttributes(): void;
  27969. /**
  27970. * Release and free the memory of a vertex array object
  27971. * @param vao defines the vertex array object to delete
  27972. */
  27973. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27974. /** @hidden */
  27975. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27976. /**
  27977. * Creates a webGL buffer to use with instanciation
  27978. * @param capacity defines the size of the buffer
  27979. * @returns the webGL buffer
  27980. */
  27981. createInstancesBuffer(capacity: number): WebGLBuffer;
  27982. /**
  27983. * Delete a webGL buffer used with instanciation
  27984. * @param buffer defines the webGL buffer to delete
  27985. */
  27986. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27987. /**
  27988. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27989. * @param instancesBuffer defines the webGL buffer to update and bind
  27990. * @param data defines the data to store in the buffer
  27991. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27992. */
  27993. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27994. /**
  27995. * Apply all cached states (depth, culling, stencil and alpha)
  27996. */
  27997. applyStates(): void;
  27998. /**
  27999. * Send a draw order
  28000. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28001. * @param indexStart defines the starting index
  28002. * @param indexCount defines the number of index to draw
  28003. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28004. */
  28005. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28006. /**
  28007. * Draw a list of points
  28008. * @param verticesStart defines the index of first vertex to draw
  28009. * @param verticesCount defines the count of vertices to draw
  28010. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28011. */
  28012. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28013. /**
  28014. * Draw a list of unindexed primitives
  28015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28016. * @param verticesStart defines the index of first vertex to draw
  28017. * @param verticesCount defines the count of vertices to draw
  28018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28019. */
  28020. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28021. /**
  28022. * Draw a list of indexed primitives
  28023. * @param fillMode defines the primitive to use
  28024. * @param indexStart defines the starting index
  28025. * @param indexCount defines the number of index to draw
  28026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28027. */
  28028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28029. /**
  28030. * Draw a list of unindexed primitives
  28031. * @param fillMode defines the primitive to use
  28032. * @param verticesStart defines the index of first vertex to draw
  28033. * @param verticesCount defines the count of vertices to draw
  28034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28035. */
  28036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28037. private _drawMode;
  28038. /** @hidden */
  28039. _releaseEffect(effect: Effect): void;
  28040. /** @hidden */
  28041. _deleteProgram(program: WebGLProgram): void;
  28042. /**
  28043. * Create a new effect (used to store vertex/fragment shaders)
  28044. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28045. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28046. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28047. * @param samplers defines an array of string used to represent textures
  28048. * @param defines defines the string containing the defines to use to compile the shaders
  28049. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28050. * @param onCompiled defines a function to call when the effect creation is successful
  28051. * @param onError defines a function to call when the effect creation has failed
  28052. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28053. * @returns the new Effect
  28054. */
  28055. 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;
  28056. private _compileShader;
  28057. private _compileRawShader;
  28058. /**
  28059. * Directly creates a webGL program
  28060. * @param vertexCode defines the vertex shader code to use
  28061. * @param fragmentCode defines the fragment shader code to use
  28062. * @param context defines the webGL context to use (if not set, the current one will be used)
  28063. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28064. * @returns the new webGL program
  28065. */
  28066. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28067. /**
  28068. * Creates a webGL program
  28069. * @param vertexCode defines the vertex shader code to use
  28070. * @param fragmentCode defines the fragment shader code to use
  28071. * @param defines defines the string containing the defines to use to compile the shaders
  28072. * @param context defines the webGL context to use (if not set, the current one will be used)
  28073. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28074. * @returns the new webGL program
  28075. */
  28076. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28077. private _createShaderProgram;
  28078. private _finalizeProgram;
  28079. /** @hidden */
  28080. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28081. /** @hidden */
  28082. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28083. /**
  28084. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28085. * @param shaderProgram defines the webGL program to use
  28086. * @param uniformsNames defines the list of uniform names
  28087. * @returns an array of webGL uniform locations
  28088. */
  28089. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28090. /**
  28091. * Gets the lsit of active attributes for a given webGL program
  28092. * @param shaderProgram defines the webGL program to use
  28093. * @param attributesNames defines the list of attribute names to get
  28094. * @returns an array of indices indicating the offset of each attribute
  28095. */
  28096. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28097. /**
  28098. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28099. * @param effect defines the effect to activate
  28100. */
  28101. enableEffect(effect: Nullable<Effect>): void;
  28102. /**
  28103. * Set the value of an uniform to an array of int32
  28104. * @param uniform defines the webGL uniform location where to store the value
  28105. * @param array defines the array of int32 to store
  28106. */
  28107. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28108. /**
  28109. * Set the value of an uniform to an array of int32 (stored as vec2)
  28110. * @param uniform defines the webGL uniform location where to store the value
  28111. * @param array defines the array of int32 to store
  28112. */
  28113. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28114. /**
  28115. * Set the value of an uniform to an array of int32 (stored as vec3)
  28116. * @param uniform defines the webGL uniform location where to store the value
  28117. * @param array defines the array of int32 to store
  28118. */
  28119. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28120. /**
  28121. * Set the value of an uniform to an array of int32 (stored as vec4)
  28122. * @param uniform defines the webGL uniform location where to store the value
  28123. * @param array defines the array of int32 to store
  28124. */
  28125. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28126. /**
  28127. * Set the value of an uniform to an array of float32
  28128. * @param uniform defines the webGL uniform location where to store the value
  28129. * @param array defines the array of float32 to store
  28130. */
  28131. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28132. /**
  28133. * Set the value of an uniform to an array of float32 (stored as vec2)
  28134. * @param uniform defines the webGL uniform location where to store the value
  28135. * @param array defines the array of float32 to store
  28136. */
  28137. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28138. /**
  28139. * Set the value of an uniform to an array of float32 (stored as vec3)
  28140. * @param uniform defines the webGL uniform location where to store the value
  28141. * @param array defines the array of float32 to store
  28142. */
  28143. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28144. /**
  28145. * Set the value of an uniform to an array of float32 (stored as vec4)
  28146. * @param uniform defines the webGL uniform location where to store the value
  28147. * @param array defines the array of float32 to store
  28148. */
  28149. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28150. /**
  28151. * Set the value of an uniform to an array of number
  28152. * @param uniform defines the webGL uniform location where to store the value
  28153. * @param array defines the array of number to store
  28154. */
  28155. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28156. /**
  28157. * Set the value of an uniform to an array of number (stored as vec2)
  28158. * @param uniform defines the webGL uniform location where to store the value
  28159. * @param array defines the array of number to store
  28160. */
  28161. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28162. /**
  28163. * Set the value of an uniform to an array of number (stored as vec3)
  28164. * @param uniform defines the webGL uniform location where to store the value
  28165. * @param array defines the array of number to store
  28166. */
  28167. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28168. /**
  28169. * Set the value of an uniform to an array of number (stored as vec4)
  28170. * @param uniform defines the webGL uniform location where to store the value
  28171. * @param array defines the array of number to store
  28172. */
  28173. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28174. /**
  28175. * Set the value of an uniform to an array of float32 (stored as matrices)
  28176. * @param uniform defines the webGL uniform location where to store the value
  28177. * @param matrices defines the array of float32 to store
  28178. */
  28179. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28180. /**
  28181. * Set the value of an uniform to a matrix
  28182. * @param uniform defines the webGL uniform location where to store the value
  28183. * @param matrix defines the matrix to store
  28184. */
  28185. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28186. /**
  28187. * Set the value of an uniform to a matrix (3x3)
  28188. * @param uniform defines the webGL uniform location where to store the value
  28189. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28190. */
  28191. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28192. /**
  28193. * Set the value of an uniform to a matrix (2x2)
  28194. * @param uniform defines the webGL uniform location where to store the value
  28195. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28196. */
  28197. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28198. /**
  28199. * Set the value of an uniform to a number (int)
  28200. * @param uniform defines the webGL uniform location where to store the value
  28201. * @param value defines the int number to store
  28202. */
  28203. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28204. /**
  28205. * Set the value of an uniform to a number (float)
  28206. * @param uniform defines the webGL uniform location where to store the value
  28207. * @param value defines the float number to store
  28208. */
  28209. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28210. /**
  28211. * Set the value of an uniform to a vec2
  28212. * @param uniform defines the webGL uniform location where to store the value
  28213. * @param x defines the 1st component of the value
  28214. * @param y defines the 2nd component of the value
  28215. */
  28216. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28217. /**
  28218. * Set the value of an uniform to a vec3
  28219. * @param uniform defines the webGL uniform location where to store the value
  28220. * @param x defines the 1st component of the value
  28221. * @param y defines the 2nd component of the value
  28222. * @param z defines the 3rd component of the value
  28223. */
  28224. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28225. /**
  28226. * Set the value of an uniform to a boolean
  28227. * @param uniform defines the webGL uniform location where to store the value
  28228. * @param bool defines the boolean to store
  28229. */
  28230. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28231. /**
  28232. * Set the value of an uniform to a vec4
  28233. * @param uniform defines the webGL uniform location where to store the value
  28234. * @param x defines the 1st component of the value
  28235. * @param y defines the 2nd component of the value
  28236. * @param z defines the 3rd component of the value
  28237. * @param w defines the 4th component of the value
  28238. */
  28239. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28240. /**
  28241. * Set the value of an uniform to a Color3
  28242. * @param uniform defines the webGL uniform location where to store the value
  28243. * @param color3 defines the color to store
  28244. */
  28245. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28246. /**
  28247. * Set the value of an uniform to a Color3 and an alpha value
  28248. * @param uniform defines the webGL uniform location where to store the value
  28249. * @param color3 defines the color to store
  28250. * @param alpha defines the alpha component to store
  28251. */
  28252. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28253. /**
  28254. * Sets a Color4 on a uniform variable
  28255. * @param uniform defines the uniform location
  28256. * @param color4 defines the value to be set
  28257. */
  28258. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28259. /**
  28260. * Set various states to the webGL context
  28261. * @param culling defines backface culling state
  28262. * @param zOffset defines the value to apply to zOffset (0 by default)
  28263. * @param force defines if states must be applied even if cache is up to date
  28264. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28265. */
  28266. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28267. /**
  28268. * Set the z offset to apply to current rendering
  28269. * @param value defines the offset to apply
  28270. */
  28271. setZOffset(value: number): void;
  28272. /**
  28273. * Gets the current value of the zOffset
  28274. * @returns the current zOffset state
  28275. */
  28276. getZOffset(): number;
  28277. /**
  28278. * Enable or disable depth buffering
  28279. * @param enable defines the state to set
  28280. */
  28281. setDepthBuffer(enable: boolean): void;
  28282. /**
  28283. * Gets a boolean indicating if depth writing is enabled
  28284. * @returns the current depth writing state
  28285. */
  28286. getDepthWrite(): boolean;
  28287. /**
  28288. * Enable or disable depth writing
  28289. * @param enable defines the state to set
  28290. */
  28291. setDepthWrite(enable: boolean): void;
  28292. /**
  28293. * Enable or disable color writing
  28294. * @param enable defines the state to set
  28295. */
  28296. setColorWrite(enable: boolean): void;
  28297. /**
  28298. * Gets a boolean indicating if color writing is enabled
  28299. * @returns the current color writing state
  28300. */
  28301. getColorWrite(): boolean;
  28302. /**
  28303. * Sets alpha constants used by some alpha blending modes
  28304. * @param r defines the red component
  28305. * @param g defines the green component
  28306. * @param b defines the blue component
  28307. * @param a defines the alpha component
  28308. */
  28309. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28310. /**
  28311. * Sets the current alpha mode
  28312. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28313. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28314. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28315. */
  28316. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28317. /**
  28318. * Gets the current alpha mode
  28319. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28320. * @returns the current alpha mode
  28321. */
  28322. getAlphaMode(): number;
  28323. /**
  28324. * Clears the list of texture accessible through engine.
  28325. * This can help preventing texture load conflict due to name collision.
  28326. */
  28327. clearInternalTexturesCache(): void;
  28328. /**
  28329. * Force the entire cache to be cleared
  28330. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28331. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28332. */
  28333. wipeCaches(bruteForce?: boolean): void;
  28334. /**
  28335. * Set the compressed texture format to use, based on the formats you have, and the formats
  28336. * supported by the hardware / browser.
  28337. *
  28338. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28339. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28340. * to API arguments needed to compressed textures. This puts the burden on the container
  28341. * generator to house the arcane code for determining these for current & future formats.
  28342. *
  28343. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28344. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28345. *
  28346. * Note: The result of this call is not taken into account when a texture is base64.
  28347. *
  28348. * @param formatsAvailable defines the list of those format families you have created
  28349. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28350. *
  28351. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28352. * @returns The extension selected.
  28353. */
  28354. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28355. private _getSamplingParameters;
  28356. private _partialLoadImg;
  28357. private _cascadeLoadImgs;
  28358. /** @hidden */
  28359. _createTexture(): WebGLTexture;
  28360. /**
  28361. * Usually called from Texture.ts.
  28362. * Passed information to create a WebGLTexture
  28363. * @param urlArg defines a value which contains one of the following:
  28364. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28365. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28366. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28367. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28368. * @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)
  28369. * @param scene needed for loading to the correct scene
  28370. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28371. * @param onLoad optional callback to be called upon successful completion
  28372. * @param onError optional callback to be called upon failure
  28373. * @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
  28374. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28375. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28376. * @param forcedExtension defines the extension to use to pick the right loader
  28377. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28378. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28379. */
  28380. 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;
  28381. private _rescaleTexture;
  28382. /**
  28383. * Update a raw texture
  28384. * @param texture defines the texture to update
  28385. * @param data defines the data to store in the texture
  28386. * @param format defines the format of the data
  28387. * @param invertY defines if data must be stored with Y axis inverted
  28388. * @param compression defines the compression used (null by default)
  28389. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28390. */
  28391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28392. /**
  28393. * Creates a raw texture
  28394. * @param data defines the data to store in the texture
  28395. * @param width defines the width of the texture
  28396. * @param height defines the height of the texture
  28397. * @param format defines the format of the data
  28398. * @param generateMipMaps defines if the engine should generate the mip levels
  28399. * @param invertY defines if data must be stored with Y axis inverted
  28400. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28401. * @param compression defines the compression used (null by default)
  28402. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28403. * @returns the raw texture inside an InternalTexture
  28404. */
  28405. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28406. private _unpackFlipYCached;
  28407. /**
  28408. * In case you are sharing the context with other applications, it might
  28409. * be interested to not cache the unpack flip y state to ensure a consistent
  28410. * value would be set.
  28411. */
  28412. enableUnpackFlipYCached: boolean;
  28413. /** @hidden */
  28414. _unpackFlipY(value: boolean): void;
  28415. /** @hidden */
  28416. _getUnpackAlignement(): number;
  28417. /**
  28418. * Creates a dynamic texture
  28419. * @param width defines the width of the texture
  28420. * @param height defines the height of the texture
  28421. * @param generateMipMaps defines if the engine should generate the mip levels
  28422. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28423. * @returns the dynamic texture inside an InternalTexture
  28424. */
  28425. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28426. /**
  28427. * Update the sampling mode of a given texture
  28428. * @param samplingMode defines the required sampling mode
  28429. * @param texture defines the texture to update
  28430. */
  28431. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28432. /**
  28433. * Update the content of a dynamic texture
  28434. * @param texture defines the texture to update
  28435. * @param canvas defines the canvas containing the source
  28436. * @param invertY defines if data must be stored with Y axis inverted
  28437. * @param premulAlpha defines if alpha is stored as premultiplied
  28438. * @param format defines the format of the data
  28439. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28440. */
  28441. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28442. /**
  28443. * Update a video texture
  28444. * @param texture defines the texture to update
  28445. * @param video defines the video element to use
  28446. * @param invertY defines if data must be stored with Y axis inverted
  28447. */
  28448. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28449. /**
  28450. * Updates a depth texture Comparison Mode and Function.
  28451. * If the comparison Function is equal to 0, the mode will be set to none.
  28452. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28453. * @param texture The texture to set the comparison function for
  28454. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28455. */
  28456. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28457. private _setupDepthStencilTexture;
  28458. /**
  28459. * Creates a depth stencil texture.
  28460. * This is only available in WebGL 2 or with the depth texture extension available.
  28461. * @param size The size of face edge in the texture.
  28462. * @param options The options defining the texture.
  28463. * @returns The texture
  28464. */
  28465. createDepthStencilTexture(size: number | {
  28466. width: number;
  28467. height: number;
  28468. }, options: DepthTextureCreationOptions): InternalTexture;
  28469. /**
  28470. * Creates a depth stencil texture.
  28471. * This is only available in WebGL 2 or with the depth texture extension available.
  28472. * @param size The size of face edge in the texture.
  28473. * @param options The options defining the texture.
  28474. * @returns The texture
  28475. */
  28476. private _createDepthStencilTexture;
  28477. /**
  28478. * Creates a depth stencil cube texture.
  28479. * This is only available in WebGL 2.
  28480. * @param size The size of face edge in the cube texture.
  28481. * @param options The options defining the cube texture.
  28482. * @returns The cube texture
  28483. */
  28484. private _createDepthStencilCubeTexture;
  28485. /**
  28486. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28487. * @param renderTarget The render target to set the frame buffer for
  28488. */
  28489. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28490. /**
  28491. * Creates a new render target texture
  28492. * @param size defines the size of the texture
  28493. * @param options defines the options used to create the texture
  28494. * @returns a new render target texture stored in an InternalTexture
  28495. */
  28496. createRenderTargetTexture(size: number | {
  28497. width: number;
  28498. height: number;
  28499. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28500. /**
  28501. * Create a multi render target texture
  28502. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28503. * @param size defines the size of the texture
  28504. * @param options defines the creation options
  28505. * @returns the cube texture as an InternalTexture
  28506. */
  28507. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28508. private _setupFramebufferDepthAttachments;
  28509. /**
  28510. * Updates the sample count of a render target texture
  28511. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28512. * @param texture defines the texture to update
  28513. * @param samples defines the sample count to set
  28514. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28515. */
  28516. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28517. /**
  28518. * Update the sample count for a given multiple render target texture
  28519. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28520. * @param textures defines the textures to update
  28521. * @param samples defines the sample count to set
  28522. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28523. */
  28524. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28525. /** @hidden */
  28526. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28527. /** @hidden */
  28528. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28529. /** @hidden */
  28530. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28531. /** @hidden */
  28532. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28533. /**
  28534. * Creates a new render target cube texture
  28535. * @param size defines the size of the texture
  28536. * @param options defines the options used to create the texture
  28537. * @returns a new render target cube texture stored in an InternalTexture
  28538. */
  28539. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28540. /**
  28541. * Creates a cube texture
  28542. * @param rootUrl defines the url where the files to load is located
  28543. * @param scene defines the current scene
  28544. * @param files defines the list of files to load (1 per face)
  28545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28546. * @param onLoad defines an optional callback raised when the texture is loaded
  28547. * @param onError defines an optional callback raised if there is an issue to load the texture
  28548. * @param format defines the format of the data
  28549. * @param forcedExtension defines the extension to use to pick the right loader
  28550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28553. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28554. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28555. * @returns the cube texture as an InternalTexture
  28556. */
  28557. 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;
  28558. /**
  28559. * @hidden
  28560. */
  28561. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28562. /**
  28563. * Update a raw cube texture
  28564. * @param texture defines the texture to udpdate
  28565. * @param data defines the data to store
  28566. * @param format defines the data format
  28567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28568. * @param invertY defines if data must be stored with Y axis inverted
  28569. * @param compression defines the compression used (null by default)
  28570. * @param level defines which level of the texture to update
  28571. */
  28572. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28573. /**
  28574. * Creates a new raw cube texture
  28575. * @param data defines the array of data to use to create each face
  28576. * @param size defines the size of the textures
  28577. * @param format defines the format of the data
  28578. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28579. * @param generateMipMaps defines if the engine should generate the mip levels
  28580. * @param invertY defines if data must be stored with Y axis inverted
  28581. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28582. * @param compression defines the compression used (null by default)
  28583. * @returns the cube texture as an InternalTexture
  28584. */
  28585. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28586. /**
  28587. * Creates a new raw cube texture from a specified url
  28588. * @param url defines the url where the data is located
  28589. * @param scene defines the current scene
  28590. * @param size defines the size of the textures
  28591. * @param format defines the format of the data
  28592. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28593. * @param noMipmap defines if the engine should avoid generating the mip levels
  28594. * @param callback defines a callback used to extract texture data from loaded data
  28595. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28596. * @param onLoad defines a callback called when texture is loaded
  28597. * @param onError defines a callback called if there is an error
  28598. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28599. * @param invertY defines if data must be stored with Y axis inverted
  28600. * @returns the cube texture as an InternalTexture
  28601. */
  28602. 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;
  28603. /**
  28604. * Update a raw 3D texture
  28605. * @param texture defines the texture to update
  28606. * @param data defines the data to store
  28607. * @param format defines the data format
  28608. * @param invertY defines if data must be stored with Y axis inverted
  28609. * @param compression defines the used compression (can be null)
  28610. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28611. */
  28612. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28613. /**
  28614. * Creates a new raw 3D texture
  28615. * @param data defines the data used to create the texture
  28616. * @param width defines the width of the texture
  28617. * @param height defines the height of the texture
  28618. * @param depth defines the depth of the texture
  28619. * @param format defines the format of the texture
  28620. * @param generateMipMaps defines if the engine must generate mip levels
  28621. * @param invertY defines if data must be stored with Y axis inverted
  28622. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28623. * @param compression defines the compressed used (can be null)
  28624. * @param textureType defines the compressed used (can be null)
  28625. * @returns a new raw 3D texture (stored in an InternalTexture)
  28626. */
  28627. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28628. private _prepareWebGLTextureContinuation;
  28629. private _prepareWebGLTexture;
  28630. private _convertRGBtoRGBATextureData;
  28631. /** @hidden */
  28632. _releaseFramebufferObjects(texture: InternalTexture): void;
  28633. /** @hidden */
  28634. _releaseTexture(texture: InternalTexture): void;
  28635. private setProgram;
  28636. private _boundUniforms;
  28637. /**
  28638. * Binds an effect to the webGL context
  28639. * @param effect defines the effect to bind
  28640. */
  28641. bindSamplers(effect: Effect): void;
  28642. private _moveBoundTextureOnTop;
  28643. private _getCorrectTextureChannel;
  28644. private _linkTrackers;
  28645. private _removeDesignatedSlot;
  28646. private _activateCurrentTexture;
  28647. /** @hidden */
  28648. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28649. /** @hidden */
  28650. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28651. /**
  28652. * Sets a texture to the webGL context from a postprocess
  28653. * @param channel defines the channel to use
  28654. * @param postProcess defines the source postprocess
  28655. */
  28656. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28657. /**
  28658. * Binds the output of the passed in post process to the texture channel specified
  28659. * @param channel The channel the texture should be bound to
  28660. * @param postProcess The post process which's output should be bound
  28661. */
  28662. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28663. /**
  28664. * Unbind all textures from the webGL context
  28665. */
  28666. unbindAllTextures(): void;
  28667. /**
  28668. * Sets a texture to the according uniform.
  28669. * @param channel The texture channel
  28670. * @param uniform The uniform to set
  28671. * @param texture The texture to apply
  28672. */
  28673. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28674. /**
  28675. * Sets a depth stencil texture from a render target to the according uniform.
  28676. * @param channel The texture channel
  28677. * @param uniform The uniform to set
  28678. * @param texture The render target texture containing the depth stencil texture to apply
  28679. */
  28680. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28681. private _bindSamplerUniformToChannel;
  28682. private _getTextureWrapMode;
  28683. private _setTexture;
  28684. /**
  28685. * Sets an array of texture to the webGL context
  28686. * @param channel defines the channel where the texture array must be set
  28687. * @param uniform defines the associated uniform location
  28688. * @param textures defines the array of textures to bind
  28689. */
  28690. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28691. /** @hidden */
  28692. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28693. private _setTextureParameterFloat;
  28694. private _setTextureParameterInteger;
  28695. /**
  28696. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28697. * @param x defines the x coordinate of the rectangle where pixels must be read
  28698. * @param y defines the y coordinate of the rectangle where pixels must be read
  28699. * @param width defines the width of the rectangle where pixels must be read
  28700. * @param height defines the height of the rectangle where pixels must be read
  28701. * @returns a Uint8Array containing RGBA colors
  28702. */
  28703. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28704. /**
  28705. * Add an externaly attached data from its key.
  28706. * This method call will fail and return false, if such key already exists.
  28707. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28708. * @param key the unique key that identifies the data
  28709. * @param data the data object to associate to the key for this Engine instance
  28710. * @return true if no such key were already present and the data was added successfully, false otherwise
  28711. */
  28712. addExternalData<T>(key: string, data: T): boolean;
  28713. /**
  28714. * Get an externaly attached data from its key
  28715. * @param key the unique key that identifies the data
  28716. * @return the associated data, if present (can be null), or undefined if not present
  28717. */
  28718. getExternalData<T>(key: string): T;
  28719. /**
  28720. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28721. * @param key the unique key that identifies the data
  28722. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28723. * @return the associated data, can be null if the factory returned null.
  28724. */
  28725. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28726. /**
  28727. * Remove an externaly attached data from the Engine instance
  28728. * @param key the unique key that identifies the data
  28729. * @return true if the data was successfully removed, false if it doesn't exist
  28730. */
  28731. removeExternalData(key: string): boolean;
  28732. /**
  28733. * Unbind all vertex attributes from the webGL context
  28734. */
  28735. unbindAllAttributes(): void;
  28736. /**
  28737. * 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
  28738. */
  28739. releaseEffects(): void;
  28740. /**
  28741. * Dispose and release all associated resources
  28742. */
  28743. dispose(): void;
  28744. /**
  28745. * Display the loading screen
  28746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28747. */
  28748. displayLoadingUI(): void;
  28749. /**
  28750. * Hide the loading screen
  28751. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28752. */
  28753. hideLoadingUI(): void;
  28754. /**
  28755. * Gets the current loading screen object
  28756. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28757. */
  28758. /**
  28759. * Sets the current loading screen object
  28760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28761. */
  28762. loadingScreen: ILoadingScreen;
  28763. /**
  28764. * Sets the current loading screen text
  28765. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28766. */
  28767. loadingUIText: string;
  28768. /**
  28769. * Sets the current loading screen background color
  28770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28771. */
  28772. loadingUIBackgroundColor: string;
  28773. /**
  28774. * Attach a new callback raised when context lost event is fired
  28775. * @param callback defines the callback to call
  28776. */
  28777. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28778. /**
  28779. * Attach a new callback raised when context restored event is fired
  28780. * @param callback defines the callback to call
  28781. */
  28782. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28783. /**
  28784. * Gets the source code of the vertex shader associated with a specific webGL program
  28785. * @param program defines the program to use
  28786. * @returns a string containing the source code of the vertex shader associated with the program
  28787. */
  28788. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28789. /**
  28790. * Gets the source code of the fragment shader associated with a specific webGL program
  28791. * @param program defines the program to use
  28792. * @returns a string containing the source code of the fragment shader associated with the program
  28793. */
  28794. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28795. /**
  28796. * Get the current error code of the webGL context
  28797. * @returns the error code
  28798. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28799. */
  28800. getError(): number;
  28801. /**
  28802. * Gets the current framerate
  28803. * @returns a number representing the framerate
  28804. */
  28805. getFps(): number;
  28806. /**
  28807. * Gets the time spent between current and previous frame
  28808. * @returns a number representing the delta time in ms
  28809. */
  28810. getDeltaTime(): number;
  28811. private _measureFps;
  28812. /** @hidden */
  28813. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28814. private _canRenderToFloatFramebuffer;
  28815. private _canRenderToHalfFloatFramebuffer;
  28816. private _canRenderToFramebuffer;
  28817. /** @hidden */
  28818. _getWebGLTextureType(type: number): number;
  28819. private _getInternalFormat;
  28820. /** @hidden */
  28821. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28822. /** @hidden */
  28823. _getRGBAMultiSampleBufferFormat(type: number): number;
  28824. /** @hidden */
  28825. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28826. /** @hidden */
  28827. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28828. private _partialLoadFile;
  28829. private _cascadeLoadFiles;
  28830. /**
  28831. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28832. * @returns true if the engine can be created
  28833. * @ignorenaming
  28834. */
  28835. static isSupported(): boolean;
  28836. }
  28837. }
  28838. declare module BABYLON {
  28839. /**
  28840. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28841. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28842. */
  28843. export class EffectFallbacks {
  28844. private _defines;
  28845. private _currentRank;
  28846. private _maxRank;
  28847. private _mesh;
  28848. /**
  28849. * Removes the fallback from the bound mesh.
  28850. */
  28851. unBindMesh(): void;
  28852. /**
  28853. * Adds a fallback on the specified property.
  28854. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28855. * @param define The name of the define in the shader
  28856. */
  28857. addFallback(rank: number, define: string): void;
  28858. /**
  28859. * Sets the mesh to use CPU skinning when needing to fallback.
  28860. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28861. * @param mesh The mesh to use the fallbacks.
  28862. */
  28863. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28864. /**
  28865. * Checks to see if more fallbacks are still availible.
  28866. */
  28867. readonly isMoreFallbacks: boolean;
  28868. /**
  28869. * Removes the defines that shoould be removed when falling back.
  28870. * @param currentDefines defines the current define statements for the shader.
  28871. * @param effect defines the current effect we try to compile
  28872. * @returns The resulting defines with defines of the current rank removed.
  28873. */
  28874. reduce(currentDefines: string, effect: Effect): string;
  28875. }
  28876. /**
  28877. * Options to be used when creating an effect.
  28878. */
  28879. export class EffectCreationOptions {
  28880. /**
  28881. * Atrributes that will be used in the shader.
  28882. */
  28883. attributes: string[];
  28884. /**
  28885. * Uniform varible names that will be set in the shader.
  28886. */
  28887. uniformsNames: string[];
  28888. /**
  28889. * Uniform buffer varible names that will be set in the shader.
  28890. */
  28891. uniformBuffersNames: string[];
  28892. /**
  28893. * Sampler texture variable names that will be set in the shader.
  28894. */
  28895. samplers: string[];
  28896. /**
  28897. * Define statements that will be set in the shader.
  28898. */
  28899. defines: any;
  28900. /**
  28901. * Possible fallbacks for this effect to improve performance when needed.
  28902. */
  28903. fallbacks: Nullable<EffectFallbacks>;
  28904. /**
  28905. * Callback that will be called when the shader is compiled.
  28906. */
  28907. onCompiled: Nullable<(effect: Effect) => void>;
  28908. /**
  28909. * Callback that will be called if an error occurs during shader compilation.
  28910. */
  28911. onError: Nullable<(effect: Effect, errors: string) => void>;
  28912. /**
  28913. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28914. */
  28915. indexParameters: any;
  28916. /**
  28917. * Max number of lights that can be used in the shader.
  28918. */
  28919. maxSimultaneousLights: number;
  28920. /**
  28921. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28922. */
  28923. transformFeedbackVaryings: Nullable<string[]>;
  28924. }
  28925. /**
  28926. * Effect containing vertex and fragment shader that can be executed on an object.
  28927. */
  28928. export class Effect {
  28929. /**
  28930. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28931. */
  28932. static ShadersRepository: string;
  28933. /**
  28934. * Name of the effect.
  28935. */
  28936. name: any;
  28937. /**
  28938. * String container all the define statements that should be set on the shader.
  28939. */
  28940. defines: string;
  28941. /**
  28942. * Callback that will be called when the shader is compiled.
  28943. */
  28944. onCompiled: Nullable<(effect: Effect) => void>;
  28945. /**
  28946. * Callback that will be called if an error occurs during shader compilation.
  28947. */
  28948. onError: Nullable<(effect: Effect, errors: string) => void>;
  28949. /**
  28950. * Callback that will be called when effect is bound.
  28951. */
  28952. onBind: Nullable<(effect: Effect) => void>;
  28953. /**
  28954. * Unique ID of the effect.
  28955. */
  28956. uniqueId: number;
  28957. /**
  28958. * Observable that will be called when the shader is compiled.
  28959. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28960. */
  28961. onCompileObservable: Observable<Effect>;
  28962. /**
  28963. * Observable that will be called if an error occurs during shader compilation.
  28964. */
  28965. onErrorObservable: Observable<Effect>;
  28966. /** @hidden */
  28967. _onBindObservable: Nullable<Observable<Effect>>;
  28968. /**
  28969. * Observable that will be called when effect is bound.
  28970. */
  28971. readonly onBindObservable: Observable<Effect>;
  28972. /** @hidden */
  28973. _bonesComputationForcedToCPU: boolean;
  28974. private static _uniqueIdSeed;
  28975. private _engine;
  28976. private _uniformBuffersNames;
  28977. private _uniformsNames;
  28978. private _samplers;
  28979. private _isReady;
  28980. private _compilationError;
  28981. private _attributesNames;
  28982. private _attributes;
  28983. private _uniforms;
  28984. /**
  28985. * Key for the effect.
  28986. * @hidden
  28987. */
  28988. _key: string;
  28989. private _indexParameters;
  28990. private _fallbacks;
  28991. private _vertexSourceCode;
  28992. private _fragmentSourceCode;
  28993. private _vertexSourceCodeOverride;
  28994. private _fragmentSourceCodeOverride;
  28995. private _transformFeedbackVaryings;
  28996. /**
  28997. * Compiled shader to webGL program.
  28998. * @hidden
  28999. */
  29000. _program: WebGLProgram;
  29001. private _valueCache;
  29002. private static _baseCache;
  29003. /**
  29004. * Instantiates an effect.
  29005. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29006. * @param baseName Name of the effect.
  29007. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29008. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29009. * @param samplers List of sampler variables that will be passed to the shader.
  29010. * @param engine Engine to be used to render the effect
  29011. * @param defines Define statements to be added to the shader.
  29012. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29013. * @param onCompiled Callback that will be called when the shader is compiled.
  29014. * @param onError Callback that will be called if an error occurs during shader compilation.
  29015. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29016. */
  29017. 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);
  29018. /**
  29019. * Unique key for this effect
  29020. */
  29021. readonly key: string;
  29022. /**
  29023. * If the effect has been compiled and prepared.
  29024. * @returns if the effect is compiled and prepared.
  29025. */
  29026. isReady(): boolean;
  29027. /**
  29028. * The engine the effect was initialized with.
  29029. * @returns the engine.
  29030. */
  29031. getEngine(): Engine;
  29032. /**
  29033. * The compiled webGL program for the effect
  29034. * @returns the webGL program.
  29035. */
  29036. getProgram(): WebGLProgram;
  29037. /**
  29038. * The set of names of attribute variables for the shader.
  29039. * @returns An array of attribute names.
  29040. */
  29041. getAttributesNames(): string[];
  29042. /**
  29043. * Returns the attribute at the given index.
  29044. * @param index The index of the attribute.
  29045. * @returns The location of the attribute.
  29046. */
  29047. getAttributeLocation(index: number): number;
  29048. /**
  29049. * Returns the attribute based on the name of the variable.
  29050. * @param name of the attribute to look up.
  29051. * @returns the attribute location.
  29052. */
  29053. getAttributeLocationByName(name: string): number;
  29054. /**
  29055. * The number of attributes.
  29056. * @returns the numnber of attributes.
  29057. */
  29058. getAttributesCount(): number;
  29059. /**
  29060. * Gets the index of a uniform variable.
  29061. * @param uniformName of the uniform to look up.
  29062. * @returns the index.
  29063. */
  29064. getUniformIndex(uniformName: string): number;
  29065. /**
  29066. * Returns the attribute based on the name of the variable.
  29067. * @param uniformName of the uniform to look up.
  29068. * @returns the location of the uniform.
  29069. */
  29070. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29071. /**
  29072. * Returns an array of sampler variable names
  29073. * @returns The array of sampler variable neames.
  29074. */
  29075. getSamplers(): string[];
  29076. /**
  29077. * The error from the last compilation.
  29078. * @returns the error string.
  29079. */
  29080. getCompilationError(): string;
  29081. /**
  29082. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29083. * @param func The callback to be used.
  29084. */
  29085. executeWhenCompiled(func: (effect: Effect) => void): void;
  29086. private _checkIsReady;
  29087. /** @hidden */
  29088. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29089. /** @hidden */
  29090. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29091. /** @hidden */
  29092. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29093. private _processShaderConversion;
  29094. private _processIncludes;
  29095. private _processPrecision;
  29096. /**
  29097. * Recompiles the webGL program
  29098. * @param vertexSourceCode The source code for the vertex shader.
  29099. * @param fragmentSourceCode The source code for the fragment shader.
  29100. * @param onCompiled Callback called when completed.
  29101. * @param onError Callback called on error.
  29102. * @hidden
  29103. */
  29104. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29105. /**
  29106. * Gets the uniform locations of the the specified variable names
  29107. * @param names THe names of the variables to lookup.
  29108. * @returns Array of locations in the same order as variable names.
  29109. */
  29110. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29111. /**
  29112. * Prepares the effect
  29113. * @hidden
  29114. */
  29115. _prepareEffect(): void;
  29116. /**
  29117. * Checks if the effect is supported. (Must be called after compilation)
  29118. */
  29119. readonly isSupported: boolean;
  29120. /**
  29121. * Binds a texture to the engine to be used as output of the shader.
  29122. * @param channel Name of the output variable.
  29123. * @param texture Texture to bind.
  29124. * @hidden
  29125. */
  29126. _bindTexture(channel: string, texture: InternalTexture): void;
  29127. /**
  29128. * Sets a texture on the engine to be used in the shader.
  29129. * @param channel Name of the sampler variable.
  29130. * @param texture Texture to set.
  29131. */
  29132. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29133. /**
  29134. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29135. * @param channel Name of the sampler variable.
  29136. * @param texture Texture to set.
  29137. */
  29138. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29139. /**
  29140. * Sets an array of textures on the engine to be used in the shader.
  29141. * @param channel Name of the variable.
  29142. * @param textures Textures to set.
  29143. */
  29144. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29145. /**
  29146. * 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)
  29147. * @param channel Name of the sampler variable.
  29148. * @param postProcess Post process to get the input texture from.
  29149. */
  29150. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29151. /**
  29152. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29153. * 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)
  29154. * @param channel Name of the sampler variable.
  29155. * @param postProcess Post process to get the output texture from.
  29156. */
  29157. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29158. /** @hidden */
  29159. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29160. /** @hidden */
  29161. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29162. /** @hidden */
  29163. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29164. /** @hidden */
  29165. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29166. /**
  29167. * Binds a buffer to a uniform.
  29168. * @param buffer Buffer to bind.
  29169. * @param name Name of the uniform variable to bind to.
  29170. */
  29171. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29172. /**
  29173. * Binds block to a uniform.
  29174. * @param blockName Name of the block to bind.
  29175. * @param index Index to bind.
  29176. */
  29177. bindUniformBlock(blockName: string, index: number): void;
  29178. /**
  29179. * Sets an interger value on a uniform variable.
  29180. * @param uniformName Name of the variable.
  29181. * @param value Value to be set.
  29182. * @returns this effect.
  29183. */
  29184. setInt(uniformName: string, value: number): Effect;
  29185. /**
  29186. * Sets an int array on a uniform variable.
  29187. * @param uniformName Name of the variable.
  29188. * @param array array to be set.
  29189. * @returns this effect.
  29190. */
  29191. setIntArray(uniformName: string, array: Int32Array): Effect;
  29192. /**
  29193. * 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)
  29194. * @param uniformName Name of the variable.
  29195. * @param array array to be set.
  29196. * @returns this effect.
  29197. */
  29198. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29199. /**
  29200. * 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)
  29201. * @param uniformName Name of the variable.
  29202. * @param array array to be set.
  29203. * @returns this effect.
  29204. */
  29205. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29206. /**
  29207. * 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)
  29208. * @param uniformName Name of the variable.
  29209. * @param array array to be set.
  29210. * @returns this effect.
  29211. */
  29212. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29213. /**
  29214. * Sets an float array on a uniform variable.
  29215. * @param uniformName Name of the variable.
  29216. * @param array array to be set.
  29217. * @returns this effect.
  29218. */
  29219. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29220. /**
  29221. * 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)
  29222. * @param uniformName Name of the variable.
  29223. * @param array array to be set.
  29224. * @returns this effect.
  29225. */
  29226. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29227. /**
  29228. * 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)
  29229. * @param uniformName Name of the variable.
  29230. * @param array array to be set.
  29231. * @returns this effect.
  29232. */
  29233. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29234. /**
  29235. * 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)
  29236. * @param uniformName Name of the variable.
  29237. * @param array array to be set.
  29238. * @returns this effect.
  29239. */
  29240. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29241. /**
  29242. * Sets an array on a uniform variable.
  29243. * @param uniformName Name of the variable.
  29244. * @param array array to be set.
  29245. * @returns this effect.
  29246. */
  29247. setArray(uniformName: string, array: number[]): Effect;
  29248. /**
  29249. * 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)
  29250. * @param uniformName Name of the variable.
  29251. * @param array array to be set.
  29252. * @returns this effect.
  29253. */
  29254. setArray2(uniformName: string, array: number[]): Effect;
  29255. /**
  29256. * 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)
  29257. * @param uniformName Name of the variable.
  29258. * @param array array to be set.
  29259. * @returns this effect.
  29260. */
  29261. setArray3(uniformName: string, array: number[]): Effect;
  29262. /**
  29263. * 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)
  29264. * @param uniformName Name of the variable.
  29265. * @param array array to be set.
  29266. * @returns this effect.
  29267. */
  29268. setArray4(uniformName: string, array: number[]): Effect;
  29269. /**
  29270. * Sets matrices on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param matrices matrices to be set.
  29273. * @returns this effect.
  29274. */
  29275. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29276. /**
  29277. * Sets matrix on a uniform variable.
  29278. * @param uniformName Name of the variable.
  29279. * @param matrix matrix to be set.
  29280. * @returns this effect.
  29281. */
  29282. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29283. /**
  29284. * 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)
  29285. * @param uniformName Name of the variable.
  29286. * @param matrix matrix to be set.
  29287. * @returns this effect.
  29288. */
  29289. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29290. /**
  29291. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29292. * @param uniformName Name of the variable.
  29293. * @param matrix matrix to be set.
  29294. * @returns this effect.
  29295. */
  29296. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29297. /**
  29298. * Sets a float on a uniform variable.
  29299. * @param uniformName Name of the variable.
  29300. * @param value value to be set.
  29301. * @returns this effect.
  29302. */
  29303. setFloat(uniformName: string, value: number): Effect;
  29304. /**
  29305. * Sets a boolean on a uniform variable.
  29306. * @param uniformName Name of the variable.
  29307. * @param bool value to be set.
  29308. * @returns this effect.
  29309. */
  29310. setBool(uniformName: string, bool: boolean): Effect;
  29311. /**
  29312. * Sets a Vector2 on a uniform variable.
  29313. * @param uniformName Name of the variable.
  29314. * @param vector2 vector2 to be set.
  29315. * @returns this effect.
  29316. */
  29317. setVector2(uniformName: string, vector2: Vector2): Effect;
  29318. /**
  29319. * Sets a float2 on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param x First float in float2.
  29322. * @param y Second float in float2.
  29323. * @returns this effect.
  29324. */
  29325. setFloat2(uniformName: string, x: number, y: number): Effect;
  29326. /**
  29327. * Sets a Vector3 on a uniform variable.
  29328. * @param uniformName Name of the variable.
  29329. * @param vector3 Value to be set.
  29330. * @returns this effect.
  29331. */
  29332. setVector3(uniformName: string, vector3: Vector3): Effect;
  29333. /**
  29334. * Sets a float3 on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param x First float in float3.
  29337. * @param y Second float in float3.
  29338. * @param z Third float in float3.
  29339. * @returns this effect.
  29340. */
  29341. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29342. /**
  29343. * Sets a Vector4 on a uniform variable.
  29344. * @param uniformName Name of the variable.
  29345. * @param vector4 Value to be set.
  29346. * @returns this effect.
  29347. */
  29348. setVector4(uniformName: string, vector4: Vector4): Effect;
  29349. /**
  29350. * Sets a float4 on a uniform variable.
  29351. * @param uniformName Name of the variable.
  29352. * @param x First float in float4.
  29353. * @param y Second float in float4.
  29354. * @param z Third float in float4.
  29355. * @param w Fourth float in float4.
  29356. * @returns this effect.
  29357. */
  29358. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29359. /**
  29360. * Sets a Color3 on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param color3 Value to be set.
  29363. * @returns this effect.
  29364. */
  29365. setColor3(uniformName: string, color3: Color3): Effect;
  29366. /**
  29367. * Sets a Color4 on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param color3 Value to be set.
  29370. * @param alpha Alpha value to be set.
  29371. * @returns this effect.
  29372. */
  29373. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29374. /**
  29375. * Sets a Color4 on a uniform variable
  29376. * @param uniformName defines the name of the variable
  29377. * @param color4 defines the value to be set
  29378. * @returns this effect.
  29379. */
  29380. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29381. /**
  29382. * This function will add a new shader to the shader store
  29383. * @param name the name of the shader
  29384. * @param pixelShader optional pixel shader content
  29385. * @param vertexShader optional vertex shader content
  29386. */
  29387. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29388. /**
  29389. * Store of each shader (The can be looked up using effect.key)
  29390. */
  29391. static ShadersStore: {
  29392. [key: string]: string;
  29393. };
  29394. /**
  29395. * Store of each included file for a shader (The can be looked up using effect.key)
  29396. */
  29397. static IncludesShadersStore: {
  29398. [key: string]: string;
  29399. };
  29400. /**
  29401. * Resets the cache of effects.
  29402. */
  29403. static ResetCache(): void;
  29404. }
  29405. }
  29406. declare module BABYLON {
  29407. /**
  29408. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29409. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29410. * 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;
  29411. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29412. */
  29413. export class ColorCurves {
  29414. private _dirty;
  29415. private _tempColor;
  29416. private _globalCurve;
  29417. private _highlightsCurve;
  29418. private _midtonesCurve;
  29419. private _shadowsCurve;
  29420. private _positiveCurve;
  29421. private _negativeCurve;
  29422. private _globalHue;
  29423. private _globalDensity;
  29424. private _globalSaturation;
  29425. private _globalExposure;
  29426. /**
  29427. * Gets the global Hue value.
  29428. * 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).
  29429. */
  29430. /**
  29431. * Sets the global Hue value.
  29432. * 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).
  29433. */
  29434. globalHue: number;
  29435. /**
  29436. * Gets the global Density value.
  29437. * 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.
  29438. * Values less than zero provide a filter of opposite hue.
  29439. */
  29440. /**
  29441. * Sets the global Density value.
  29442. * 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.
  29443. * Values less than zero provide a filter of opposite hue.
  29444. */
  29445. globalDensity: number;
  29446. /**
  29447. * Gets the global Saturation value.
  29448. * 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.
  29449. */
  29450. /**
  29451. * Sets the global Saturation value.
  29452. * 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.
  29453. */
  29454. globalSaturation: number;
  29455. /**
  29456. * Gets the global Exposure value.
  29457. * 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.
  29458. */
  29459. /**
  29460. * Sets the global Exposure value.
  29461. * 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.
  29462. */
  29463. globalExposure: number;
  29464. private _highlightsHue;
  29465. private _highlightsDensity;
  29466. private _highlightsSaturation;
  29467. private _highlightsExposure;
  29468. /**
  29469. * Gets the highlights Hue value.
  29470. * 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).
  29471. */
  29472. /**
  29473. * Sets the highlights Hue value.
  29474. * 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).
  29475. */
  29476. highlightsHue: number;
  29477. /**
  29478. * Gets the highlights Density value.
  29479. * 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.
  29480. * Values less than zero provide a filter of opposite hue.
  29481. */
  29482. /**
  29483. * Sets the highlights Density value.
  29484. * 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.
  29485. * Values less than zero provide a filter of opposite hue.
  29486. */
  29487. highlightsDensity: number;
  29488. /**
  29489. * Gets the highlights Saturation value.
  29490. * 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.
  29491. */
  29492. /**
  29493. * Sets the highlights Saturation value.
  29494. * 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.
  29495. */
  29496. highlightsSaturation: number;
  29497. /**
  29498. * Gets the highlights Exposure value.
  29499. * 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.
  29500. */
  29501. /**
  29502. * Sets the highlights Exposure value.
  29503. * 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.
  29504. */
  29505. highlightsExposure: number;
  29506. private _midtonesHue;
  29507. private _midtonesDensity;
  29508. private _midtonesSaturation;
  29509. private _midtonesExposure;
  29510. /**
  29511. * Gets the midtones Hue value.
  29512. * 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).
  29513. */
  29514. /**
  29515. * Sets the midtones Hue value.
  29516. * 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).
  29517. */
  29518. midtonesHue: number;
  29519. /**
  29520. * Gets the midtones Density value.
  29521. * 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.
  29522. * Values less than zero provide a filter of opposite hue.
  29523. */
  29524. /**
  29525. * Sets the midtones Density value.
  29526. * 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.
  29527. * Values less than zero provide a filter of opposite hue.
  29528. */
  29529. midtonesDensity: number;
  29530. /**
  29531. * Gets the midtones Saturation value.
  29532. * 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.
  29533. */
  29534. /**
  29535. * Sets the midtones Saturation value.
  29536. * 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.
  29537. */
  29538. midtonesSaturation: number;
  29539. /**
  29540. * Gets the midtones Exposure value.
  29541. * 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.
  29542. */
  29543. /**
  29544. * Sets the midtones Exposure value.
  29545. * 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.
  29546. */
  29547. midtonesExposure: number;
  29548. private _shadowsHue;
  29549. private _shadowsDensity;
  29550. private _shadowsSaturation;
  29551. private _shadowsExposure;
  29552. /**
  29553. * Gets the shadows Hue value.
  29554. * 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).
  29555. */
  29556. /**
  29557. * Sets the shadows Hue value.
  29558. * 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).
  29559. */
  29560. shadowsHue: number;
  29561. /**
  29562. * Gets the shadows Density value.
  29563. * 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.
  29564. * Values less than zero provide a filter of opposite hue.
  29565. */
  29566. /**
  29567. * Sets the shadows Density value.
  29568. * 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.
  29569. * Values less than zero provide a filter of opposite hue.
  29570. */
  29571. shadowsDensity: number;
  29572. /**
  29573. * Gets the shadows Saturation value.
  29574. * 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.
  29575. */
  29576. /**
  29577. * Sets the shadows Saturation value.
  29578. * 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.
  29579. */
  29580. shadowsSaturation: number;
  29581. /**
  29582. * Gets the shadows Exposure value.
  29583. * 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.
  29584. */
  29585. /**
  29586. * Sets the shadows Exposure value.
  29587. * 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.
  29588. */
  29589. shadowsExposure: number;
  29590. /**
  29591. * Returns the class name
  29592. * @returns The class name
  29593. */
  29594. getClassName(): string;
  29595. /**
  29596. * Binds the color curves to the shader.
  29597. * @param colorCurves The color curve to bind
  29598. * @param effect The effect to bind to
  29599. * @param positiveUniform The positive uniform shader parameter
  29600. * @param neutralUniform The neutral uniform shader parameter
  29601. * @param negativeUniform The negative uniform shader parameter
  29602. */
  29603. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29604. /**
  29605. * Prepare the list of uniforms associated with the ColorCurves effects.
  29606. * @param uniformsList The list of uniforms used in the effect
  29607. */
  29608. static PrepareUniforms(uniformsList: string[]): void;
  29609. /**
  29610. * Returns color grading data based on a hue, density, saturation and exposure value.
  29611. * @param filterHue The hue of the color filter.
  29612. * @param filterDensity The density of the color filter.
  29613. * @param saturation The saturation.
  29614. * @param exposure The exposure.
  29615. * @param result The result data container.
  29616. */
  29617. private getColorGradingDataToRef;
  29618. /**
  29619. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29620. * @param value The input slider value in range [-100,100].
  29621. * @returns Adjusted value.
  29622. */
  29623. private static applyColorGradingSliderNonlinear;
  29624. /**
  29625. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29626. * @param hue The hue (H) input.
  29627. * @param saturation The saturation (S) input.
  29628. * @param brightness The brightness (B) input.
  29629. * @result An RGBA color represented as Vector4.
  29630. */
  29631. private static fromHSBToRef;
  29632. /**
  29633. * Returns a value clamped between min and max
  29634. * @param value The value to clamp
  29635. * @param min The minimum of value
  29636. * @param max The maximum of value
  29637. * @returns The clamped value.
  29638. */
  29639. private static clamp;
  29640. /**
  29641. * Clones the current color curve instance.
  29642. * @return The cloned curves
  29643. */
  29644. clone(): ColorCurves;
  29645. /**
  29646. * Serializes the current color curve instance to a json representation.
  29647. * @return a JSON representation
  29648. */
  29649. serialize(): any;
  29650. /**
  29651. * Parses the color curve from a json representation.
  29652. * @param source the JSON source to parse
  29653. * @return The parsed curves
  29654. */
  29655. static Parse(source: any): ColorCurves;
  29656. }
  29657. }
  29658. declare module BABYLON {
  29659. /**
  29660. * Interface to follow in your material defines to integrate easily the
  29661. * Image proccessing functions.
  29662. * @hidden
  29663. */
  29664. export interface IImageProcessingConfigurationDefines {
  29665. IMAGEPROCESSING: boolean;
  29666. VIGNETTE: boolean;
  29667. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29668. VIGNETTEBLENDMODEOPAQUE: boolean;
  29669. TONEMAPPING: boolean;
  29670. TONEMAPPING_ACES: boolean;
  29671. CONTRAST: boolean;
  29672. EXPOSURE: boolean;
  29673. COLORCURVES: boolean;
  29674. COLORGRADING: boolean;
  29675. COLORGRADING3D: boolean;
  29676. SAMPLER3DGREENDEPTH: boolean;
  29677. SAMPLER3DBGRMAP: boolean;
  29678. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29679. }
  29680. /**
  29681. * @hidden
  29682. */
  29683. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29684. IMAGEPROCESSING: boolean;
  29685. VIGNETTE: boolean;
  29686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29687. VIGNETTEBLENDMODEOPAQUE: boolean;
  29688. TONEMAPPING: boolean;
  29689. TONEMAPPING_ACES: boolean;
  29690. CONTRAST: boolean;
  29691. COLORCURVES: boolean;
  29692. COLORGRADING: boolean;
  29693. COLORGRADING3D: boolean;
  29694. SAMPLER3DGREENDEPTH: boolean;
  29695. SAMPLER3DBGRMAP: boolean;
  29696. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29697. EXPOSURE: boolean;
  29698. constructor();
  29699. }
  29700. /**
  29701. * This groups together the common properties used for image processing either in direct forward pass
  29702. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29703. * or not.
  29704. */
  29705. export class ImageProcessingConfiguration {
  29706. /**
  29707. * Default tone mapping applied in BabylonJS.
  29708. */
  29709. static readonly TONEMAPPING_STANDARD: number;
  29710. /**
  29711. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29712. * to other engines rendering to increase portability.
  29713. */
  29714. static readonly TONEMAPPING_ACES: number;
  29715. /**
  29716. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29717. */
  29718. colorCurves: Nullable<ColorCurves>;
  29719. private _colorCurvesEnabled;
  29720. /**
  29721. * Gets wether the color curves effect is enabled.
  29722. */
  29723. /**
  29724. * Sets wether the color curves effect is enabled.
  29725. */
  29726. colorCurvesEnabled: boolean;
  29727. private _colorGradingTexture;
  29728. /**
  29729. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29730. */
  29731. /**
  29732. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29733. */
  29734. colorGradingTexture: Nullable<BaseTexture>;
  29735. private _colorGradingEnabled;
  29736. /**
  29737. * Gets wether the color grading effect is enabled.
  29738. */
  29739. /**
  29740. * Sets wether the color grading effect is enabled.
  29741. */
  29742. colorGradingEnabled: boolean;
  29743. private _colorGradingWithGreenDepth;
  29744. /**
  29745. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29746. */
  29747. /**
  29748. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29749. */
  29750. colorGradingWithGreenDepth: boolean;
  29751. private _colorGradingBGR;
  29752. /**
  29753. * Gets wether the color grading texture contains BGR values.
  29754. */
  29755. /**
  29756. * Sets wether the color grading texture contains BGR values.
  29757. */
  29758. colorGradingBGR: boolean;
  29759. /** @hidden */
  29760. _exposure: number;
  29761. /**
  29762. * Gets the Exposure used in the effect.
  29763. */
  29764. /**
  29765. * Sets the Exposure used in the effect.
  29766. */
  29767. exposure: number;
  29768. private _toneMappingEnabled;
  29769. /**
  29770. * Gets wether the tone mapping effect is enabled.
  29771. */
  29772. /**
  29773. * Sets wether the tone mapping effect is enabled.
  29774. */
  29775. toneMappingEnabled: boolean;
  29776. private _toneMappingType;
  29777. /**
  29778. * Gets the type of tone mapping effect.
  29779. */
  29780. /**
  29781. * Sets the type of tone mapping effect used in BabylonJS.
  29782. */
  29783. toneMappingType: number;
  29784. protected _contrast: number;
  29785. /**
  29786. * Gets the contrast used in the effect.
  29787. */
  29788. /**
  29789. * Sets the contrast used in the effect.
  29790. */
  29791. contrast: number;
  29792. /**
  29793. * Vignette stretch size.
  29794. */
  29795. vignetteStretch: number;
  29796. /**
  29797. * Vignette centre X Offset.
  29798. */
  29799. vignetteCentreX: number;
  29800. /**
  29801. * Vignette centre Y Offset.
  29802. */
  29803. vignetteCentreY: number;
  29804. /**
  29805. * Vignette weight or intensity of the vignette effect.
  29806. */
  29807. vignetteWeight: number;
  29808. /**
  29809. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29810. * if vignetteEnabled is set to true.
  29811. */
  29812. vignetteColor: Color4;
  29813. /**
  29814. * Camera field of view used by the Vignette effect.
  29815. */
  29816. vignetteCameraFov: number;
  29817. private _vignetteBlendMode;
  29818. /**
  29819. * Gets the vignette blend mode allowing different kind of effect.
  29820. */
  29821. /**
  29822. * Sets the vignette blend mode allowing different kind of effect.
  29823. */
  29824. vignetteBlendMode: number;
  29825. private _vignetteEnabled;
  29826. /**
  29827. * Gets wether the vignette effect is enabled.
  29828. */
  29829. /**
  29830. * Sets wether the vignette effect is enabled.
  29831. */
  29832. vignetteEnabled: boolean;
  29833. private _applyByPostProcess;
  29834. /**
  29835. * Gets wether the image processing is applied through a post process or not.
  29836. */
  29837. /**
  29838. * Sets wether the image processing is applied through a post process or not.
  29839. */
  29840. applyByPostProcess: boolean;
  29841. private _isEnabled;
  29842. /**
  29843. * Gets wether the image processing is enabled or not.
  29844. */
  29845. /**
  29846. * Sets wether the image processing is enabled or not.
  29847. */
  29848. isEnabled: boolean;
  29849. /**
  29850. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29851. */
  29852. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29853. /**
  29854. * Method called each time the image processing information changes requires to recompile the effect.
  29855. */
  29856. protected _updateParameters(): void;
  29857. /**
  29858. * Gets the current class name.
  29859. * @return "ImageProcessingConfiguration"
  29860. */
  29861. getClassName(): string;
  29862. /**
  29863. * Prepare the list of uniforms associated with the Image Processing effects.
  29864. * @param uniforms The list of uniforms used in the effect
  29865. * @param defines the list of defines currently in use
  29866. */
  29867. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29868. /**
  29869. * Prepare the list of samplers associated with the Image Processing effects.
  29870. * @param samplersList The list of uniforms used in the effect
  29871. * @param defines the list of defines currently in use
  29872. */
  29873. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29874. /**
  29875. * Prepare the list of defines associated to the shader.
  29876. * @param defines the list of defines to complete
  29877. * @param forPostProcess Define if we are currently in post process mode or not
  29878. */
  29879. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29880. /**
  29881. * Returns true if all the image processing information are ready.
  29882. * @returns True if ready, otherwise, false
  29883. */
  29884. isReady(): boolean;
  29885. /**
  29886. * Binds the image processing to the shader.
  29887. * @param effect The effect to bind to
  29888. * @param aspectRatio Define the current aspect ratio of the effect
  29889. */
  29890. bind(effect: Effect, aspectRatio?: number): void;
  29891. /**
  29892. * Clones the current image processing instance.
  29893. * @return The cloned image processing
  29894. */
  29895. clone(): ImageProcessingConfiguration;
  29896. /**
  29897. * Serializes the current image processing instance to a json representation.
  29898. * @return a JSON representation
  29899. */
  29900. serialize(): any;
  29901. /**
  29902. * Parses the image processing from a json representation.
  29903. * @param source the JSON source to parse
  29904. * @return The parsed image processing
  29905. */
  29906. static Parse(source: any): ImageProcessingConfiguration;
  29907. private static _VIGNETTEMODE_MULTIPLY;
  29908. private static _VIGNETTEMODE_OPAQUE;
  29909. /**
  29910. * Used to apply the vignette as a mix with the pixel color.
  29911. */
  29912. static readonly VIGNETTEMODE_MULTIPLY: number;
  29913. /**
  29914. * Used to apply the vignette as a replacement of the pixel color.
  29915. */
  29916. static readonly VIGNETTEMODE_OPAQUE: number;
  29917. }
  29918. }
  29919. declare module BABYLON {
  29920. /**
  29921. * This represents all the required information to add a fresnel effect on a material:
  29922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29923. */
  29924. export class FresnelParameters {
  29925. private _isEnabled;
  29926. /**
  29927. * Define if the fresnel effect is enable or not.
  29928. */
  29929. isEnabled: boolean;
  29930. /**
  29931. * Define the color used on edges (grazing angle)
  29932. */
  29933. leftColor: Color3;
  29934. /**
  29935. * Define the color used on center
  29936. */
  29937. rightColor: Color3;
  29938. /**
  29939. * Define bias applied to computed fresnel term
  29940. */
  29941. bias: number;
  29942. /**
  29943. * Defined the power exponent applied to fresnel term
  29944. */
  29945. power: number;
  29946. /**
  29947. * Clones the current fresnel and its valuues
  29948. * @returns a clone fresnel configuration
  29949. */
  29950. clone(): FresnelParameters;
  29951. /**
  29952. * Serializes the current fresnel parameters to a JSON representation.
  29953. * @return the JSON serialization
  29954. */
  29955. serialize(): any;
  29956. /**
  29957. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29958. * @param parsedFresnelParameters Define the JSON representation
  29959. * @returns the parsed parameters
  29960. */
  29961. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29962. }
  29963. }
  29964. declare module BABYLON {
  29965. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29966. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29967. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29968. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29969. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29970. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29971. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29972. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29973. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29974. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29975. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29976. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29977. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29978. /**
  29979. * Decorator used to define property that can be serialized as reference to a camera
  29980. * @param sourceName defines the name of the property to decorate
  29981. */
  29982. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29983. /**
  29984. * Class used to help serialization objects
  29985. */
  29986. export class SerializationHelper {
  29987. /** hidden */
  29988. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29989. /** hidden */
  29990. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29991. /** hidden */
  29992. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29993. /** hidden */
  29994. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29995. /**
  29996. * Appends the serialized animations from the source animations
  29997. * @param source Source containing the animations
  29998. * @param destination Target to store the animations
  29999. */
  30000. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30001. /**
  30002. * Static function used to serialized a specific entity
  30003. * @param entity defines the entity to serialize
  30004. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30005. * @returns a JSON compatible object representing the serialization of the entity
  30006. */
  30007. static Serialize<T>(entity: T, serializationObject?: any): any;
  30008. /**
  30009. * Creates a new entity from a serialization data object
  30010. * @param creationFunction defines a function used to instanciated the new entity
  30011. * @param source defines the source serialization data
  30012. * @param scene defines the hosting scene
  30013. * @param rootUrl defines the root url for resources
  30014. * @returns a new entity
  30015. */
  30016. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30017. /**
  30018. * Clones an object
  30019. * @param creationFunction defines the function used to instanciate the new object
  30020. * @param source defines the source object
  30021. * @returns the cloned object
  30022. */
  30023. static Clone<T>(creationFunction: () => T, source: T): T;
  30024. /**
  30025. * Instanciates a new object based on a source one (some data will be shared between both object)
  30026. * @param creationFunction defines the function used to instanciate the new object
  30027. * @param source defines the source object
  30028. * @returns the new object
  30029. */
  30030. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30031. }
  30032. }
  30033. declare module BABYLON {
  30034. /**
  30035. * This is the base class of all the camera used in the application.
  30036. * @see http://doc.babylonjs.com/features/cameras
  30037. */
  30038. export class Camera extends Node {
  30039. /** @hidden */
  30040. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30041. /**
  30042. * This is the default projection mode used by the cameras.
  30043. * It helps recreating a feeling of perspective and better appreciate depth.
  30044. * This is the best way to simulate real life cameras.
  30045. */
  30046. static readonly PERSPECTIVE_CAMERA: number;
  30047. /**
  30048. * This helps creating camera with an orthographic mode.
  30049. * 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.
  30050. */
  30051. static readonly ORTHOGRAPHIC_CAMERA: number;
  30052. /**
  30053. * This is the default FOV mode for perspective cameras.
  30054. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30055. */
  30056. static readonly FOVMODE_VERTICAL_FIXED: number;
  30057. /**
  30058. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30059. */
  30060. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30061. /**
  30062. * This specifies ther is no need for a camera rig.
  30063. * Basically only one eye is rendered corresponding to the camera.
  30064. */
  30065. static readonly RIG_MODE_NONE: number;
  30066. /**
  30067. * Simulates a camera Rig with one blue eye and one red eye.
  30068. * This can be use with 3d blue and red glasses.
  30069. */
  30070. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30071. /**
  30072. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30073. */
  30074. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30075. /**
  30076. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30077. */
  30078. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30079. /**
  30080. * Defines that both eyes of the camera will be rendered over under each other.
  30081. */
  30082. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30083. /**
  30084. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30085. */
  30086. static readonly RIG_MODE_VR: number;
  30087. /**
  30088. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30089. */
  30090. static readonly RIG_MODE_WEBVR: number;
  30091. /**
  30092. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30093. */
  30094. static readonly RIG_MODE_CUSTOM: number;
  30095. /**
  30096. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30097. */
  30098. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30099. /**
  30100. * Define the input manager associated with the camera.
  30101. */
  30102. inputs: CameraInputsManager<Camera>;
  30103. /** @hidden */
  30104. _position: Vector3;
  30105. /**
  30106. * Define the current local position of the camera in the scene
  30107. */
  30108. position: Vector3;
  30109. /**
  30110. * The vector the camera should consider as up.
  30111. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30112. */
  30113. upVector: Vector3;
  30114. /**
  30115. * Define the current limit on the left side for an orthographic camera
  30116. * In scene unit
  30117. */
  30118. orthoLeft: Nullable<number>;
  30119. /**
  30120. * Define the current limit on the right side for an orthographic camera
  30121. * In scene unit
  30122. */
  30123. orthoRight: Nullable<number>;
  30124. /**
  30125. * Define the current limit on the bottom side for an orthographic camera
  30126. * In scene unit
  30127. */
  30128. orthoBottom: Nullable<number>;
  30129. /**
  30130. * Define the current limit on the top side for an orthographic camera
  30131. * In scene unit
  30132. */
  30133. orthoTop: Nullable<number>;
  30134. /**
  30135. * Field Of View is set in Radians. (default is 0.8)
  30136. */
  30137. fov: number;
  30138. /**
  30139. * Define the minimum distance the camera can see from.
  30140. * This is important to note that the depth buffer are not infinite and the closer it starts
  30141. * the more your scene might encounter depth fighting issue.
  30142. */
  30143. minZ: number;
  30144. /**
  30145. * Define the maximum distance the camera can see to.
  30146. * This is important to note that the depth buffer are not infinite and the further it end
  30147. * the more your scene might encounter depth fighting issue.
  30148. */
  30149. maxZ: number;
  30150. /**
  30151. * Define the default inertia of the camera.
  30152. * This helps giving a smooth feeling to the camera movement.
  30153. */
  30154. inertia: number;
  30155. /**
  30156. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30157. */
  30158. mode: number;
  30159. /**
  30160. * Define wether the camera is intermediate.
  30161. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30162. */
  30163. isIntermediate: boolean;
  30164. /**
  30165. * Define the viewport of the camera.
  30166. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30167. */
  30168. viewport: Viewport;
  30169. /**
  30170. * Restricts the camera to viewing objects with the same layerMask.
  30171. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30172. */
  30173. layerMask: number;
  30174. /**
  30175. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30176. */
  30177. fovMode: number;
  30178. /**
  30179. * Rig mode of the camera.
  30180. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30181. * This is normally controlled byt the camera themselves as internal use.
  30182. */
  30183. cameraRigMode: number;
  30184. /**
  30185. * Defines the distance between both "eyes" in case of a RIG
  30186. */
  30187. interaxialDistance: number;
  30188. /**
  30189. * Defines if stereoscopic rendering is done side by side or over under.
  30190. */
  30191. isStereoscopicSideBySide: boolean;
  30192. /**
  30193. * 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
  30194. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30195. * else in the scene.
  30196. */
  30197. customRenderTargets: RenderTargetTexture[];
  30198. /**
  30199. * When set, the camera will render to this render target instead of the default canvas
  30200. */
  30201. outputRenderTarget: Nullable<RenderTargetTexture>;
  30202. /**
  30203. * Observable triggered when the camera view matrix has changed.
  30204. */
  30205. onViewMatrixChangedObservable: Observable<Camera>;
  30206. /**
  30207. * Observable triggered when the camera Projection matrix has changed.
  30208. */
  30209. onProjectionMatrixChangedObservable: Observable<Camera>;
  30210. /**
  30211. * Observable triggered when the inputs have been processed.
  30212. */
  30213. onAfterCheckInputsObservable: Observable<Camera>;
  30214. /**
  30215. * Observable triggered when reset has been called and applied to the camera.
  30216. */
  30217. onRestoreStateObservable: Observable<Camera>;
  30218. /** @hidden */
  30219. _cameraRigParams: any;
  30220. /** @hidden */
  30221. _rigCameras: Camera[];
  30222. /** @hidden */
  30223. _rigPostProcess: Nullable<PostProcess>;
  30224. protected _webvrViewMatrix: Matrix;
  30225. /** @hidden */
  30226. _skipRendering: boolean;
  30227. /** @hidden */
  30228. _projectionMatrix: Matrix;
  30229. /** @hidden */
  30230. _postProcesses: Nullable<PostProcess>[];
  30231. /** @hidden */
  30232. _activeMeshes: SmartArray<AbstractMesh>;
  30233. protected _globalPosition: Vector3;
  30234. /** hidden */
  30235. _computedViewMatrix: Matrix;
  30236. private _doNotComputeProjectionMatrix;
  30237. private _transformMatrix;
  30238. private _frustumPlanes;
  30239. private _refreshFrustumPlanes;
  30240. private _storedFov;
  30241. private _stateStored;
  30242. /**
  30243. * Instantiates a new camera object.
  30244. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30245. * @see http://doc.babylonjs.com/features/cameras
  30246. * @param name Defines the name of the camera in the scene
  30247. * @param position Defines the position of the camera
  30248. * @param scene Defines the scene the camera belongs too
  30249. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30250. */
  30251. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30252. /**
  30253. * Store current camera state (fov, position, etc..)
  30254. * @returns the camera
  30255. */
  30256. storeState(): Camera;
  30257. /**
  30258. * Restores the camera state values if it has been stored. You must call storeState() first
  30259. */
  30260. protected _restoreStateValues(): boolean;
  30261. /**
  30262. * Restored camera state. You must call storeState() first.
  30263. * @returns true if restored and false otherwise
  30264. */
  30265. restoreState(): boolean;
  30266. /**
  30267. * Gets the class name of the camera.
  30268. * @returns the class name
  30269. */
  30270. getClassName(): string;
  30271. /** @hidden */
  30272. readonly _isCamera: boolean;
  30273. /**
  30274. * Gets a string representation of the camera useful for debug purpose.
  30275. * @param fullDetails Defines that a more verboe level of logging is required
  30276. * @returns the string representation
  30277. */
  30278. toString(fullDetails?: boolean): string;
  30279. /**
  30280. * Gets the current world space position of the camera.
  30281. */
  30282. readonly globalPosition: Vector3;
  30283. /**
  30284. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30285. * @returns the active meshe list
  30286. */
  30287. getActiveMeshes(): SmartArray<AbstractMesh>;
  30288. /**
  30289. * Check wether a mesh is part of the current active mesh list of the camera
  30290. * @param mesh Defines the mesh to check
  30291. * @returns true if active, false otherwise
  30292. */
  30293. isActiveMesh(mesh: Mesh): boolean;
  30294. /**
  30295. * Is this camera ready to be used/rendered
  30296. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30297. * @return true if the camera is ready
  30298. */
  30299. isReady(completeCheck?: boolean): boolean;
  30300. /** @hidden */
  30301. _initCache(): void;
  30302. /** @hidden */
  30303. _updateCache(ignoreParentClass?: boolean): void;
  30304. /** @hidden */
  30305. _isSynchronized(): boolean;
  30306. /** @hidden */
  30307. _isSynchronizedViewMatrix(): boolean;
  30308. /** @hidden */
  30309. _isSynchronizedProjectionMatrix(): boolean;
  30310. /**
  30311. * Attach the input controls to a specific dom element to get the input from.
  30312. * @param element Defines the element the controls should be listened from
  30313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30314. */
  30315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30316. /**
  30317. * Detach the current controls from the specified dom element.
  30318. * @param element Defines the element to stop listening the inputs from
  30319. */
  30320. detachControl(element: HTMLElement): void;
  30321. /**
  30322. * Update the camera state according to the different inputs gathered during the frame.
  30323. */
  30324. update(): void;
  30325. /** @hidden */
  30326. _checkInputs(): void;
  30327. /** @hidden */
  30328. readonly rigCameras: Camera[];
  30329. /**
  30330. * Gets the post process used by the rig cameras
  30331. */
  30332. readonly rigPostProcess: Nullable<PostProcess>;
  30333. /**
  30334. * Internal, gets the first post proces.
  30335. * @returns the first post process to be run on this camera.
  30336. */
  30337. _getFirstPostProcess(): Nullable<PostProcess>;
  30338. private _cascadePostProcessesToRigCams;
  30339. /**
  30340. * Attach a post process to the camera.
  30341. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30342. * @param postProcess The post process to attach to the camera
  30343. * @param insertAt The position of the post process in case several of them are in use in the scene
  30344. * @returns the position the post process has been inserted at
  30345. */
  30346. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30347. /**
  30348. * Detach a post process to the camera.
  30349. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30350. * @param postProcess The post process to detach from the camera
  30351. */
  30352. detachPostProcess(postProcess: PostProcess): void;
  30353. /**
  30354. * Gets the current world matrix of the camera
  30355. */
  30356. getWorldMatrix(): Matrix;
  30357. /** @hidden */
  30358. _getViewMatrix(): Matrix;
  30359. /**
  30360. * Gets the current view matrix of the camera.
  30361. * @param force forces the camera to recompute the matrix without looking at the cached state
  30362. * @returns the view matrix
  30363. */
  30364. getViewMatrix(force?: boolean): Matrix;
  30365. /**
  30366. * Freeze the projection matrix.
  30367. * It will prevent the cache check of the camera projection compute and can speed up perf
  30368. * if no parameter of the camera are meant to change
  30369. * @param projection Defines manually a projection if necessary
  30370. */
  30371. freezeProjectionMatrix(projection?: Matrix): void;
  30372. /**
  30373. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30374. */
  30375. unfreezeProjectionMatrix(): void;
  30376. /**
  30377. * Gets the current projection matrix of the camera.
  30378. * @param force forces the camera to recompute the matrix without looking at the cached state
  30379. * @returns the projection matrix
  30380. */
  30381. getProjectionMatrix(force?: boolean): Matrix;
  30382. /**
  30383. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30384. * @returns a Matrix
  30385. */
  30386. getTransformationMatrix(): Matrix;
  30387. private _updateFrustumPlanes;
  30388. /**
  30389. * Checks if a cullable object (mesh...) is in the camera frustum
  30390. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30391. * @param target The object to check
  30392. * @returns true if the object is in frustum otherwise false
  30393. */
  30394. isInFrustum(target: ICullable): boolean;
  30395. /**
  30396. * Checks if a cullable object (mesh...) is in the camera frustum
  30397. * Unlike isInFrustum this cheks the full bounding box
  30398. * @param target The object to check
  30399. * @returns true if the object is in frustum otherwise false
  30400. */
  30401. isCompletelyInFrustum(target: ICullable): boolean;
  30402. /**
  30403. * Gets a ray in the forward direction from the camera.
  30404. * @param length Defines the length of the ray to create
  30405. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30406. * @param origin Defines the start point of the ray which defaults to the camera position
  30407. * @returns the forward ray
  30408. */
  30409. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30410. /**
  30411. * Releases resources associated with this node.
  30412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30414. */
  30415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30416. /** @hidden */
  30417. _isLeftCamera: boolean;
  30418. /**
  30419. * Gets the left camera of a rig setup in case of Rigged Camera
  30420. */
  30421. readonly isLeftCamera: boolean;
  30422. /** @hidden */
  30423. _isRightCamera: boolean;
  30424. /**
  30425. * Gets the right camera of a rig setup in case of Rigged Camera
  30426. */
  30427. readonly isRightCamera: boolean;
  30428. /**
  30429. * Gets the left camera of a rig setup in case of Rigged Camera
  30430. */
  30431. readonly leftCamera: Nullable<FreeCamera>;
  30432. /**
  30433. * Gets the right camera of a rig setup in case of Rigged Camera
  30434. */
  30435. readonly rightCamera: Nullable<FreeCamera>;
  30436. /**
  30437. * Gets the left camera target of a rig setup in case of Rigged Camera
  30438. * @returns the target position
  30439. */
  30440. getLeftTarget(): Nullable<Vector3>;
  30441. /**
  30442. * Gets the right camera target of a rig setup in case of Rigged Camera
  30443. * @returns the target position
  30444. */
  30445. getRightTarget(): Nullable<Vector3>;
  30446. /**
  30447. * @hidden
  30448. */
  30449. setCameraRigMode(mode: number, rigParams: any): void;
  30450. /** @hidden */
  30451. static _setStereoscopicRigMode(camera: Camera): void;
  30452. /** @hidden */
  30453. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30454. /** @hidden */
  30455. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30456. /** @hidden */
  30457. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30458. /** @hidden */
  30459. _getVRProjectionMatrix(): Matrix;
  30460. protected _updateCameraRotationMatrix(): void;
  30461. protected _updateWebVRCameraRotationMatrix(): void;
  30462. /**
  30463. * This function MUST be overwritten by the different WebVR cameras available.
  30464. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30465. * @hidden
  30466. */
  30467. _getWebVRProjectionMatrix(): Matrix;
  30468. /**
  30469. * This function MUST be overwritten by the different WebVR cameras available.
  30470. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30471. * @hidden
  30472. */
  30473. _getWebVRViewMatrix(): Matrix;
  30474. /** @hidden */
  30475. setCameraRigParameter(name: string, value: any): void;
  30476. /**
  30477. * needs to be overridden by children so sub has required properties to be copied
  30478. * @hidden
  30479. */
  30480. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30481. /**
  30482. * May need to be overridden by children
  30483. * @hidden
  30484. */
  30485. _updateRigCameras(): void;
  30486. /** @hidden */
  30487. _setupInputs(): void;
  30488. /**
  30489. * Serialiaze the camera setup to a json represention
  30490. * @returns the JSON representation
  30491. */
  30492. serialize(): any;
  30493. /**
  30494. * Clones the current camera.
  30495. * @param name The cloned camera name
  30496. * @returns the cloned camera
  30497. */
  30498. clone(name: string): Camera;
  30499. /**
  30500. * Gets the direction of the camera relative to a given local axis.
  30501. * @param localAxis Defines the reference axis to provide a relative direction.
  30502. * @return the direction
  30503. */
  30504. getDirection(localAxis: Vector3): Vector3;
  30505. /**
  30506. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30507. * @param localAxis Defines the reference axis to provide a relative direction.
  30508. * @param result Defines the vector to store the result in
  30509. */
  30510. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30511. /**
  30512. * Gets a camera constructor for a given camera type
  30513. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30514. * @param name The name of the camera the result will be able to instantiate
  30515. * @param scene The scene the result will construct the camera in
  30516. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30517. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30518. * @returns a factory method to construc the camera
  30519. */
  30520. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30521. /**
  30522. * Compute the world matrix of the camera.
  30523. * @returns the camera workd matrix
  30524. */
  30525. computeWorldMatrix(): Matrix;
  30526. /**
  30527. * Parse a JSON and creates the camera from the parsed information
  30528. * @param parsedCamera The JSON to parse
  30529. * @param scene The scene to instantiate the camera in
  30530. * @returns the newly constructed camera
  30531. */
  30532. static Parse(parsedCamera: any, scene: Scene): Camera;
  30533. }
  30534. }
  30535. declare module BABYLON {
  30536. /**
  30537. * Interface for any object that can request an animation frame
  30538. */
  30539. export interface ICustomAnimationFrameRequester {
  30540. /**
  30541. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30542. */
  30543. renderFunction?: Function;
  30544. /**
  30545. * Called to request the next frame to render to
  30546. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30547. */
  30548. requestAnimationFrame: Function;
  30549. /**
  30550. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30551. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30552. */
  30553. requestID?: number;
  30554. }
  30555. /**
  30556. * Interface containing an array of animations
  30557. */
  30558. export interface IAnimatable {
  30559. /**
  30560. * Array of animations
  30561. */
  30562. animations: Array<Animation>;
  30563. }
  30564. /** Interface used by value gradients (color, factor, ...) */
  30565. export interface IValueGradient {
  30566. /**
  30567. * Gets or sets the gradient value (between 0 and 1)
  30568. */
  30569. gradient: number;
  30570. }
  30571. /** Class used to store color4 gradient */
  30572. export class ColorGradient implements IValueGradient {
  30573. /**
  30574. * Gets or sets the gradient value (between 0 and 1)
  30575. */
  30576. gradient: number;
  30577. /**
  30578. * Gets or sets first associated color
  30579. */
  30580. color1: Color4;
  30581. /**
  30582. * Gets or sets second associated color
  30583. */
  30584. color2?: Color4;
  30585. /**
  30586. * Will get a color picked randomly between color1 and color2.
  30587. * If color2 is undefined then color1 will be used
  30588. * @param result defines the target Color4 to store the result in
  30589. */
  30590. getColorToRef(result: Color4): void;
  30591. }
  30592. /** Class used to store color 3 gradient */
  30593. export class Color3Gradient implements IValueGradient {
  30594. /**
  30595. * Gets or sets the gradient value (between 0 and 1)
  30596. */
  30597. gradient: number;
  30598. /**
  30599. * Gets or sets the associated color
  30600. */
  30601. color: Color3;
  30602. }
  30603. /** Class used to store factor gradient */
  30604. export class FactorGradient implements IValueGradient {
  30605. /**
  30606. * Gets or sets the gradient value (between 0 and 1)
  30607. */
  30608. gradient: number;
  30609. /**
  30610. * Gets or sets first associated factor
  30611. */
  30612. factor1: number;
  30613. /**
  30614. * Gets or sets second associated factor
  30615. */
  30616. factor2?: number;
  30617. /**
  30618. * Will get a number picked randomly between factor1 and factor2.
  30619. * If factor2 is undefined then factor1 will be used
  30620. * @returns the picked number
  30621. */
  30622. getFactor(): number;
  30623. }
  30624. /**
  30625. * @ignore
  30626. * Application error to support additional information when loading a file
  30627. */
  30628. export class LoadFileError extends Error {
  30629. /** defines the optional web request */
  30630. request?: WebRequest | undefined;
  30631. private static _setPrototypeOf;
  30632. /**
  30633. * Creates a new LoadFileError
  30634. * @param message defines the message of the error
  30635. * @param request defines the optional web request
  30636. */
  30637. constructor(message: string,
  30638. /** defines the optional web request */
  30639. request?: WebRequest | undefined);
  30640. }
  30641. /**
  30642. * Class used to define a retry strategy when error happens while loading assets
  30643. */
  30644. export class RetryStrategy {
  30645. /**
  30646. * Function used to defines an exponential back off strategy
  30647. * @param maxRetries defines the maximum number of retries (3 by default)
  30648. * @param baseInterval defines the interval between retries
  30649. * @returns the strategy function to use
  30650. */
  30651. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30652. }
  30653. /**
  30654. * File request interface
  30655. */
  30656. export interface IFileRequest {
  30657. /**
  30658. * Raised when the request is complete (success or error).
  30659. */
  30660. onCompleteObservable: Observable<IFileRequest>;
  30661. /**
  30662. * Aborts the request for a file.
  30663. */
  30664. abort: () => void;
  30665. }
  30666. /**
  30667. * Class containing a set of static utilities functions
  30668. */
  30669. export class Tools {
  30670. /**
  30671. * Gets or sets the base URL to use to load assets
  30672. */
  30673. static BaseUrl: string;
  30674. /**
  30675. * Enable/Disable Custom HTTP Request Headers globally.
  30676. * default = false
  30677. * @see CustomRequestHeaders
  30678. */
  30679. static UseCustomRequestHeaders: boolean;
  30680. /**
  30681. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30682. * i.e. when loading files, where the server/service expects an Authorization header
  30683. */
  30684. static CustomRequestHeaders: {
  30685. [key: string]: string;
  30686. };
  30687. /**
  30688. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30689. */
  30690. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30691. /**
  30692. * Default behaviour for cors in the application.
  30693. * It can be a string if the expected behavior is identical in the entire app.
  30694. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30695. */
  30696. static CorsBehavior: string | ((url: string | string[]) => string);
  30697. /**
  30698. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30699. * @ignorenaming
  30700. */
  30701. static UseFallbackTexture: boolean;
  30702. /**
  30703. * Use this object to register external classes like custom textures or material
  30704. * to allow the laoders to instantiate them
  30705. */
  30706. static RegisteredExternalClasses: {
  30707. [key: string]: Object;
  30708. };
  30709. /**
  30710. * Texture content used if a texture cannot loaded
  30711. * @ignorenaming
  30712. */
  30713. static fallbackTexture: string;
  30714. /**
  30715. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30716. * @param u defines the coordinate on X axis
  30717. * @param v defines the coordinate on Y axis
  30718. * @param width defines the width of the source data
  30719. * @param height defines the height of the source data
  30720. * @param pixels defines the source byte array
  30721. * @param color defines the output color
  30722. */
  30723. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30724. /**
  30725. * Interpolates between a and b via alpha
  30726. * @param a The lower value (returned when alpha = 0)
  30727. * @param b The upper value (returned when alpha = 1)
  30728. * @param alpha The interpolation-factor
  30729. * @return The mixed value
  30730. */
  30731. static Mix(a: number, b: number, alpha: number): number;
  30732. /**
  30733. * Tries to instantiate a new object from a given class name
  30734. * @param className defines the class name to instantiate
  30735. * @returns the new object or null if the system was not able to do the instantiation
  30736. */
  30737. static Instantiate(className: string): any;
  30738. /**
  30739. * Provides a slice function that will work even on IE
  30740. * @param data defines the array to slice
  30741. * @param start defines the start of the data (optional)
  30742. * @param end defines the end of the data (optional)
  30743. * @returns the new sliced array
  30744. */
  30745. static Slice<T>(data: T, start?: number, end?: number): T;
  30746. /**
  30747. * Polyfill for setImmediate
  30748. * @param action defines the action to execute after the current execution block
  30749. */
  30750. static SetImmediate(action: () => void): void;
  30751. /**
  30752. * Function indicating if a number is an exponent of 2
  30753. * @param value defines the value to test
  30754. * @returns true if the value is an exponent of 2
  30755. */
  30756. static IsExponentOfTwo(value: number): boolean;
  30757. private static _tmpFloatArray;
  30758. /**
  30759. * Returns the nearest 32-bit single precision float representation of a Number
  30760. * @param value A Number. If the parameter is of a different type, it will get converted
  30761. * to a number or to NaN if it cannot be converted
  30762. * @returns number
  30763. */
  30764. static FloatRound(value: number): number;
  30765. /**
  30766. * Find the next highest power of two.
  30767. * @param x Number to start search from.
  30768. * @return Next highest power of two.
  30769. */
  30770. static CeilingPOT(x: number): number;
  30771. /**
  30772. * Find the next lowest power of two.
  30773. * @param x Number to start search from.
  30774. * @return Next lowest power of two.
  30775. */
  30776. static FloorPOT(x: number): number;
  30777. /**
  30778. * Find the nearest power of two.
  30779. * @param x Number to start search from.
  30780. * @return Next nearest power of two.
  30781. */
  30782. static NearestPOT(x: number): number;
  30783. /**
  30784. * Get the closest exponent of two
  30785. * @param value defines the value to approximate
  30786. * @param max defines the maximum value to return
  30787. * @param mode defines how to define the closest value
  30788. * @returns closest exponent of two of the given value
  30789. */
  30790. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30791. /**
  30792. * Extracts the filename from a path
  30793. * @param path defines the path to use
  30794. * @returns the filename
  30795. */
  30796. static GetFilename(path: string): string;
  30797. /**
  30798. * Extracts the "folder" part of a path (everything before the filename).
  30799. * @param uri The URI to extract the info from
  30800. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30801. * @returns The "folder" part of the path
  30802. */
  30803. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30804. /**
  30805. * Extracts text content from a DOM element hierarchy
  30806. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30807. */
  30808. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30809. /**
  30810. * Convert an angle in radians to degrees
  30811. * @param angle defines the angle to convert
  30812. * @returns the angle in degrees
  30813. */
  30814. static ToDegrees(angle: number): number;
  30815. /**
  30816. * Convert an angle in degrees to radians
  30817. * @param angle defines the angle to convert
  30818. * @returns the angle in radians
  30819. */
  30820. static ToRadians(angle: number): number;
  30821. /**
  30822. * Encode a buffer to a base64 string
  30823. * @param buffer defines the buffer to encode
  30824. * @returns the encoded string
  30825. */
  30826. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30827. /**
  30828. * Extracts minimum and maximum values from a list of indexed positions
  30829. * @param positions defines the positions to use
  30830. * @param indices defines the indices to the positions
  30831. * @param indexStart defines the start index
  30832. * @param indexCount defines the end index
  30833. * @param bias defines bias value to add to the result
  30834. * @return minimum and maximum values
  30835. */
  30836. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30837. minimum: Vector3;
  30838. maximum: Vector3;
  30839. };
  30840. /**
  30841. * Extracts minimum and maximum values from a list of positions
  30842. * @param positions defines the positions to use
  30843. * @param start defines the start index in the positions array
  30844. * @param count defines the number of positions to handle
  30845. * @param bias defines bias value to add to the result
  30846. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30847. * @return minimum and maximum values
  30848. */
  30849. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30850. minimum: Vector3;
  30851. maximum: Vector3;
  30852. };
  30853. /**
  30854. * Returns an array if obj is not an array
  30855. * @param obj defines the object to evaluate as an array
  30856. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30857. * @returns either obj directly if obj is an array or a new array containing obj
  30858. */
  30859. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30860. /**
  30861. * Gets the pointer prefix to use
  30862. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30863. */
  30864. static GetPointerPrefix(): string;
  30865. /**
  30866. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30867. * @param func - the function to be called
  30868. * @param requester - the object that will request the next frame. Falls back to window.
  30869. * @returns frame number
  30870. */
  30871. static QueueNewFrame(func: () => void, requester?: any): number;
  30872. /**
  30873. * Ask the browser to promote the current element to fullscreen rendering mode
  30874. * @param element defines the DOM element to promote
  30875. */
  30876. static RequestFullscreen(element: HTMLElement): void;
  30877. /**
  30878. * Asks the browser to exit fullscreen mode
  30879. */
  30880. static ExitFullscreen(): void;
  30881. /**
  30882. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30883. * @param url define the url we are trying
  30884. * @param element define the dom element where to configure the cors policy
  30885. */
  30886. static SetCorsBehavior(url: string | string[], element: {
  30887. crossOrigin: string | null;
  30888. }): void;
  30889. /**
  30890. * Removes unwanted characters from an url
  30891. * @param url defines the url to clean
  30892. * @returns the cleaned url
  30893. */
  30894. static CleanUrl(url: string): string;
  30895. /**
  30896. * Gets or sets a function used to pre-process url before using them to load assets
  30897. */
  30898. static PreprocessUrl: (url: string) => string;
  30899. /**
  30900. * Loads an image as an HTMLImageElement.
  30901. * @param input url string, ArrayBuffer, or Blob to load
  30902. * @param onLoad callback called when the image successfully loads
  30903. * @param onError callback called when the image fails to load
  30904. * @param offlineProvider offline provider for caching
  30905. * @returns the HTMLImageElement of the loaded image
  30906. */
  30907. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30908. /**
  30909. * Loads a file
  30910. * @param url url string, ArrayBuffer, or Blob to load
  30911. * @param onSuccess callback called when the file successfully loads
  30912. * @param onProgress callback called while file is loading (if the server supports this mode)
  30913. * @param offlineProvider defines the offline provider for caching
  30914. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30915. * @param onError callback called when the file fails to load
  30916. * @returns a file request object
  30917. */
  30918. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30919. /**
  30920. * Load a script (identified by an url). When the url returns, the
  30921. * content of this file is added into a new script element, attached to the DOM (body element)
  30922. * @param scriptUrl defines the url of the script to laod
  30923. * @param onSuccess defines the callback called when the script is loaded
  30924. * @param onError defines the callback to call if an error occurs
  30925. * @param scriptId defines the id of the script element
  30926. */
  30927. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30928. /**
  30929. * Load an asynchronous script (identified by an url). When the url returns, the
  30930. * content of this file is added into a new script element, attached to the DOM (body element)
  30931. * @param scriptUrl defines the url of the script to laod
  30932. * @param scriptId defines the id of the script element
  30933. * @returns a promise request object
  30934. */
  30935. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30936. /**
  30937. * Loads a file from a blob
  30938. * @param fileToLoad defines the blob to use
  30939. * @param callback defines the callback to call when data is loaded
  30940. * @param progressCallback defines the callback to call during loading process
  30941. * @returns a file request object
  30942. */
  30943. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30944. /**
  30945. * Loads a file
  30946. * @param fileToLoad defines the file to load
  30947. * @param callback defines the callback to call when data is loaded
  30948. * @param progressCallBack defines the callback to call during loading process
  30949. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30950. * @returns a file request object
  30951. */
  30952. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30953. /**
  30954. * Creates a data url from a given string content
  30955. * @param content defines the content to convert
  30956. * @returns the new data url link
  30957. */
  30958. static FileAsURL(content: string): string;
  30959. /**
  30960. * Format the given number to a specific decimal format
  30961. * @param value defines the number to format
  30962. * @param decimals defines the number of decimals to use
  30963. * @returns the formatted string
  30964. */
  30965. static Format(value: number, decimals?: number): string;
  30966. /**
  30967. * Checks if a given vector is inside a specific range
  30968. * @param v defines the vector to test
  30969. * @param min defines the minimum range
  30970. * @param max defines the maximum range
  30971. */
  30972. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30973. /**
  30974. * Tries to copy an object by duplicating every property
  30975. * @param source defines the source object
  30976. * @param destination defines the target object
  30977. * @param doNotCopyList defines a list of properties to avoid
  30978. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30979. */
  30980. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30981. /**
  30982. * Gets a boolean indicating if the given object has no own property
  30983. * @param obj defines the object to test
  30984. * @returns true if object has no own property
  30985. */
  30986. static IsEmpty(obj: any): boolean;
  30987. /**
  30988. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30989. * @param str Source string
  30990. * @param suffix Suffix to search for in the source string
  30991. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30992. */
  30993. static EndsWith(str: string, suffix: string): boolean;
  30994. /**
  30995. * Function used to register events at window level
  30996. * @param events defines the events to register
  30997. */
  30998. static RegisterTopRootEvents(events: {
  30999. name: string;
  31000. handler: Nullable<(e: FocusEvent) => any>;
  31001. }[]): void;
  31002. /**
  31003. * Function used to unregister events from window level
  31004. * @param events defines the events to unregister
  31005. */
  31006. static UnregisterTopRootEvents(events: {
  31007. name: string;
  31008. handler: Nullable<(e: FocusEvent) => any>;
  31009. }[]): void;
  31010. /**
  31011. * @ignore
  31012. */
  31013. static _ScreenshotCanvas: HTMLCanvasElement;
  31014. /**
  31015. * Dumps the current bound framebuffer
  31016. * @param width defines the rendering width
  31017. * @param height defines the rendering height
  31018. * @param engine defines the hosting engine
  31019. * @param successCallback defines the callback triggered once the data are available
  31020. * @param mimeType defines the mime type of the result
  31021. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31022. */
  31023. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31024. /**
  31025. * Converts the canvas data to blob.
  31026. * This acts as a polyfill for browsers not supporting the to blob function.
  31027. * @param canvas Defines the canvas to extract the data from
  31028. * @param successCallback Defines the callback triggered once the data are available
  31029. * @param mimeType Defines the mime type of the result
  31030. */
  31031. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31032. /**
  31033. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31034. * @param successCallback defines the callback triggered once the data are available
  31035. * @param mimeType defines the mime type of the result
  31036. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31037. */
  31038. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31039. /**
  31040. * Downloads a blob in the browser
  31041. * @param blob defines the blob to download
  31042. * @param fileName defines the name of the downloaded file
  31043. */
  31044. static Download(blob: Blob, fileName: string): void;
  31045. /**
  31046. * Captures a screenshot of the current rendering
  31047. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31048. * @param engine defines the rendering engine
  31049. * @param camera defines the source camera
  31050. * @param size This parameter can be set to a single number or to an object with the
  31051. * following (optional) properties: precision, width, height. If a single number is passed,
  31052. * it will be used for both width and height. If an object is passed, the screenshot size
  31053. * will be derived from the parameters. The precision property is a multiplier allowing
  31054. * rendering at a higher or lower resolution
  31055. * @param successCallback defines the callback receives a single parameter which contains the
  31056. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31057. * src parameter of an <img> to display it
  31058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31059. * Check your browser for supported MIME types
  31060. */
  31061. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31062. /**
  31063. * Generates an image screenshot from the specified camera.
  31064. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31065. * @param engine The engine to use for rendering
  31066. * @param camera The camera to use for rendering
  31067. * @param size This parameter can be set to a single number or to an object with the
  31068. * following (optional) properties: precision, width, height. If a single number is passed,
  31069. * it will be used for both width and height. If an object is passed, the screenshot size
  31070. * will be derived from the parameters. The precision property is a multiplier allowing
  31071. * rendering at a higher or lower resolution
  31072. * @param successCallback The callback receives a single parameter which contains the
  31073. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31074. * src parameter of an <img> to display it
  31075. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31076. * Check your browser for supported MIME types
  31077. * @param samples Texture samples (default: 1)
  31078. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31079. * @param fileName A name for for the downloaded file.
  31080. */
  31081. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31082. /**
  31083. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31084. * Be aware Math.random() could cause collisions, but:
  31085. * "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"
  31086. * @returns a pseudo random id
  31087. */
  31088. static RandomId(): string;
  31089. /**
  31090. * Test if the given uri is a base64 string
  31091. * @param uri The uri to test
  31092. * @return True if the uri is a base64 string or false otherwise
  31093. */
  31094. static IsBase64(uri: string): boolean;
  31095. /**
  31096. * Decode the given base64 uri.
  31097. * @param uri The uri to decode
  31098. * @return The decoded base64 data.
  31099. */
  31100. static DecodeBase64(uri: string): ArrayBuffer;
  31101. /**
  31102. * No log
  31103. */
  31104. static readonly NoneLogLevel: number;
  31105. /**
  31106. * Only message logs
  31107. */
  31108. static readonly MessageLogLevel: number;
  31109. /**
  31110. * Only warning logs
  31111. */
  31112. static readonly WarningLogLevel: number;
  31113. /**
  31114. * Only error logs
  31115. */
  31116. static readonly ErrorLogLevel: number;
  31117. /**
  31118. * All logs
  31119. */
  31120. static readonly AllLogLevel: number;
  31121. /**
  31122. * Gets a value indicating the number of loading errors
  31123. * @ignorenaming
  31124. */
  31125. static readonly errorsCount: number;
  31126. /**
  31127. * Callback called when a new log is added
  31128. */
  31129. static OnNewCacheEntry: (entry: string) => void;
  31130. /**
  31131. * Log a message to the console
  31132. * @param message defines the message to log
  31133. */
  31134. static Log(message: string): void;
  31135. /**
  31136. * Write a warning message to the console
  31137. * @param message defines the message to log
  31138. */
  31139. static Warn(message: string): void;
  31140. /**
  31141. * Write an error message to the console
  31142. * @param message defines the message to log
  31143. */
  31144. static Error(message: string): void;
  31145. /**
  31146. * Gets current log cache (list of logs)
  31147. */
  31148. static readonly LogCache: string;
  31149. /**
  31150. * Clears the log cache
  31151. */
  31152. static ClearLogCache(): void;
  31153. /**
  31154. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31155. */
  31156. static LogLevels: number;
  31157. /**
  31158. * Checks if the loaded document was accessed via `file:`-Protocol.
  31159. * @returns boolean
  31160. */
  31161. static IsFileURL(): boolean;
  31162. /**
  31163. * Checks if the window object exists
  31164. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31165. */
  31166. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31167. /**
  31168. * No performance log
  31169. */
  31170. static readonly PerformanceNoneLogLevel: number;
  31171. /**
  31172. * Use user marks to log performance
  31173. */
  31174. static readonly PerformanceUserMarkLogLevel: number;
  31175. /**
  31176. * Log performance to the console
  31177. */
  31178. static readonly PerformanceConsoleLogLevel: number;
  31179. private static _performance;
  31180. /**
  31181. * Sets the current performance log level
  31182. */
  31183. static PerformanceLogLevel: number;
  31184. private static _StartPerformanceCounterDisabled;
  31185. private static _EndPerformanceCounterDisabled;
  31186. private static _StartUserMark;
  31187. private static _EndUserMark;
  31188. private static _StartPerformanceConsole;
  31189. private static _EndPerformanceConsole;
  31190. /**
  31191. * Starts a performance counter
  31192. */
  31193. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31194. /**
  31195. * Ends a specific performance coutner
  31196. */
  31197. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31198. /**
  31199. * Gets either window.performance.now() if supported or Date.now() else
  31200. */
  31201. static readonly Now: number;
  31202. /**
  31203. * This method will return the name of the class used to create the instance of the given object.
  31204. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31205. * @param object the object to get the class name from
  31206. * @param isType defines if the object is actually a type
  31207. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31208. */
  31209. static GetClassName(object: any, isType?: boolean): string;
  31210. /**
  31211. * Gets the first element of an array satisfying a given predicate
  31212. * @param array defines the array to browse
  31213. * @param predicate defines the predicate to use
  31214. * @returns null if not found or the element
  31215. */
  31216. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31217. /**
  31218. * This method will return the name of the full name of the class, including its owning module (if any).
  31219. * 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).
  31220. * @param object the object to get the class name from
  31221. * @param isType defines if the object is actually a type
  31222. * @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.
  31223. * @ignorenaming
  31224. */
  31225. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31226. /**
  31227. * Returns a promise that resolves after the given amount of time.
  31228. * @param delay Number of milliseconds to delay
  31229. * @returns Promise that resolves after the given amount of time
  31230. */
  31231. static DelayAsync(delay: number): Promise<void>;
  31232. /**
  31233. * Gets the current gradient from an array of IValueGradient
  31234. * @param ratio defines the current ratio to get
  31235. * @param gradients defines the array of IValueGradient
  31236. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31237. */
  31238. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31239. }
  31240. /**
  31241. * This class is used to track a performance counter which is number based.
  31242. * The user has access to many properties which give statistics of different nature.
  31243. *
  31244. * The implementer can track two kinds of Performance Counter: time and count.
  31245. * 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.
  31246. * 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.
  31247. */
  31248. export class PerfCounter {
  31249. /**
  31250. * Gets or sets a global boolean to turn on and off all the counters
  31251. */
  31252. static Enabled: boolean;
  31253. /**
  31254. * Returns the smallest value ever
  31255. */
  31256. readonly min: number;
  31257. /**
  31258. * Returns the biggest value ever
  31259. */
  31260. readonly max: number;
  31261. /**
  31262. * Returns the average value since the performance counter is running
  31263. */
  31264. readonly average: number;
  31265. /**
  31266. * Returns the average value of the last second the counter was monitored
  31267. */
  31268. readonly lastSecAverage: number;
  31269. /**
  31270. * Returns the current value
  31271. */
  31272. readonly current: number;
  31273. /**
  31274. * Gets the accumulated total
  31275. */
  31276. readonly total: number;
  31277. /**
  31278. * Gets the total value count
  31279. */
  31280. readonly count: number;
  31281. /**
  31282. * Creates a new counter
  31283. */
  31284. constructor();
  31285. /**
  31286. * Call this method to start monitoring a new frame.
  31287. * 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.
  31288. */
  31289. fetchNewFrame(): void;
  31290. /**
  31291. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31292. * @param newCount the count value to add to the monitored count
  31293. * @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.
  31294. */
  31295. addCount(newCount: number, fetchResult: boolean): void;
  31296. /**
  31297. * Start monitoring this performance counter
  31298. */
  31299. beginMonitoring(): void;
  31300. /**
  31301. * Compute the time lapsed since the previous beginMonitoring() call.
  31302. * @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
  31303. */
  31304. endMonitoring(newFrame?: boolean): void;
  31305. private _fetchResult;
  31306. private _startMonitoringTime;
  31307. private _min;
  31308. private _max;
  31309. private _average;
  31310. private _current;
  31311. private _totalValueCount;
  31312. private _totalAccumulated;
  31313. private _lastSecAverage;
  31314. private _lastSecAccumulated;
  31315. private _lastSecTime;
  31316. private _lastSecValueCount;
  31317. }
  31318. /**
  31319. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31320. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31321. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31322. * @param name The name of the class, case should be preserved
  31323. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31324. */
  31325. export function className(name: string, module?: string): (target: Object) => void;
  31326. /**
  31327. * An implementation of a loop for asynchronous functions.
  31328. */
  31329. export class AsyncLoop {
  31330. /**
  31331. * Defines the number of iterations for the loop
  31332. */
  31333. iterations: number;
  31334. /**
  31335. * Defines the current index of the loop.
  31336. */
  31337. index: number;
  31338. private _done;
  31339. private _fn;
  31340. private _successCallback;
  31341. /**
  31342. * Constructor.
  31343. * @param iterations the number of iterations.
  31344. * @param func the function to run each iteration
  31345. * @param successCallback the callback that will be called upon succesful execution
  31346. * @param offset starting offset.
  31347. */
  31348. constructor(
  31349. /**
  31350. * Defines the number of iterations for the loop
  31351. */
  31352. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31353. /**
  31354. * Execute the next iteration. Must be called after the last iteration was finished.
  31355. */
  31356. executeNext(): void;
  31357. /**
  31358. * Break the loop and run the success callback.
  31359. */
  31360. breakLoop(): void;
  31361. /**
  31362. * Create and run an async loop.
  31363. * @param iterations the number of iterations.
  31364. * @param fn the function to run each iteration
  31365. * @param successCallback the callback that will be called upon succesful execution
  31366. * @param offset starting offset.
  31367. * @returns the created async loop object
  31368. */
  31369. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31370. /**
  31371. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31372. * @param iterations total number of iterations
  31373. * @param syncedIterations number of synchronous iterations in each async iteration.
  31374. * @param fn the function to call each iteration.
  31375. * @param callback a success call back that will be called when iterating stops.
  31376. * @param breakFunction a break condition (optional)
  31377. * @param timeout timeout settings for the setTimeout function. default - 0.
  31378. * @returns the created async loop object
  31379. */
  31380. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31381. }
  31382. }
  31383. declare module BABYLON {
  31384. /** @hidden */
  31385. export interface ICollisionCoordinator {
  31386. createCollider(): Collider;
  31387. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31388. init(scene: Scene): void;
  31389. }
  31390. /** @hidden */
  31391. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31392. private _scene;
  31393. private _scaledPosition;
  31394. private _scaledVelocity;
  31395. private _finalPosition;
  31396. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31397. createCollider(): Collider;
  31398. init(scene: Scene): void;
  31399. private _collideWithWorld;
  31400. }
  31401. }
  31402. declare module BABYLON {
  31403. /**
  31404. * This class defines the direct association between an animation and a target
  31405. */
  31406. export class TargetedAnimation {
  31407. /**
  31408. * Animation to perform
  31409. */
  31410. animation: Animation;
  31411. /**
  31412. * Target to animate
  31413. */
  31414. target: any;
  31415. }
  31416. /**
  31417. * Use this class to create coordinated animations on multiple targets
  31418. */
  31419. export class AnimationGroup implements IDisposable {
  31420. /** The name of the animation group */
  31421. name: string;
  31422. private _scene;
  31423. private _targetedAnimations;
  31424. private _animatables;
  31425. private _from;
  31426. private _to;
  31427. private _isStarted;
  31428. private _isPaused;
  31429. private _speedRatio;
  31430. /**
  31431. * Gets or sets the unique id of the node
  31432. */
  31433. uniqueId: number;
  31434. /**
  31435. * This observable will notify when one animation have ended
  31436. */
  31437. onAnimationEndObservable: Observable<TargetedAnimation>;
  31438. /**
  31439. * Observer raised when one animation loops
  31440. */
  31441. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31442. /**
  31443. * This observable will notify when all animations have ended.
  31444. */
  31445. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31446. /**
  31447. * This observable will notify when all animations have paused.
  31448. */
  31449. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31450. /**
  31451. * This observable will notify when all animations are playing.
  31452. */
  31453. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31454. /**
  31455. * Gets the first frame
  31456. */
  31457. readonly from: number;
  31458. /**
  31459. * Gets the last frame
  31460. */
  31461. readonly to: number;
  31462. /**
  31463. * Define if the animations are started
  31464. */
  31465. readonly isStarted: boolean;
  31466. /**
  31467. * Gets a value indicating that the current group is playing
  31468. */
  31469. readonly isPlaying: boolean;
  31470. /**
  31471. * Gets or sets the speed ratio to use for all animations
  31472. */
  31473. /**
  31474. * Gets or sets the speed ratio to use for all animations
  31475. */
  31476. speedRatio: number;
  31477. /**
  31478. * Gets the targeted animations for this animation group
  31479. */
  31480. readonly targetedAnimations: Array<TargetedAnimation>;
  31481. /**
  31482. * returning the list of animatables controlled by this animation group.
  31483. */
  31484. readonly animatables: Array<Animatable>;
  31485. /**
  31486. * Instantiates a new Animation Group.
  31487. * This helps managing several animations at once.
  31488. * @see http://doc.babylonjs.com/how_to/group
  31489. * @param name Defines the name of the group
  31490. * @param scene Defines the scene the group belongs to
  31491. */
  31492. constructor(
  31493. /** The name of the animation group */
  31494. name: string, scene?: Nullable<Scene>);
  31495. /**
  31496. * Add an animation (with its target) in the group
  31497. * @param animation defines the animation we want to add
  31498. * @param target defines the target of the animation
  31499. * @returns the TargetedAnimation object
  31500. */
  31501. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31502. /**
  31503. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31504. * It can add constant keys at begin or end
  31505. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31506. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31507. * @returns the animation group
  31508. */
  31509. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31510. /**
  31511. * Start all animations on given targets
  31512. * @param loop defines if animations must loop
  31513. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31514. * @param from defines the from key (optional)
  31515. * @param to defines the to key (optional)
  31516. * @returns the current animation group
  31517. */
  31518. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31519. /**
  31520. * Pause all animations
  31521. * @returns the animation group
  31522. */
  31523. pause(): AnimationGroup;
  31524. /**
  31525. * Play all animations to initial state
  31526. * This function will start() the animations if they were not started or will restart() them if they were paused
  31527. * @param loop defines if animations must loop
  31528. * @returns the animation group
  31529. */
  31530. play(loop?: boolean): AnimationGroup;
  31531. /**
  31532. * Reset all animations to initial state
  31533. * @returns the animation group
  31534. */
  31535. reset(): AnimationGroup;
  31536. /**
  31537. * Restart animations from key 0
  31538. * @returns the animation group
  31539. */
  31540. restart(): AnimationGroup;
  31541. /**
  31542. * Stop all animations
  31543. * @returns the animation group
  31544. */
  31545. stop(): AnimationGroup;
  31546. /**
  31547. * Set animation weight for all animatables
  31548. * @param weight defines the weight to use
  31549. * @return the animationGroup
  31550. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31551. */
  31552. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31553. /**
  31554. * Synchronize and normalize all animatables with a source animatable
  31555. * @param root defines the root animatable to synchronize with
  31556. * @return the animationGroup
  31557. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31558. */
  31559. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31560. /**
  31561. * Goes to a specific frame in this animation group
  31562. * @param frame the frame number to go to
  31563. * @return the animationGroup
  31564. */
  31565. goToFrame(frame: number): AnimationGroup;
  31566. /**
  31567. * Dispose all associated resources
  31568. */
  31569. dispose(): void;
  31570. private _checkAnimationGroupEnded;
  31571. /**
  31572. * Clone the current animation group and returns a copy
  31573. * @param newName defines the name of the new group
  31574. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31575. * @returns the new aniamtion group
  31576. */
  31577. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31578. /**
  31579. * Returns a new AnimationGroup object parsed from the source provided.
  31580. * @param parsedAnimationGroup defines the source
  31581. * @param scene defines the scene that will receive the animationGroup
  31582. * @returns a new AnimationGroup
  31583. */
  31584. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31585. /**
  31586. * Returns the string "AnimationGroup"
  31587. * @returns "AnimationGroup"
  31588. */
  31589. getClassName(): string;
  31590. /**
  31591. * Creates a detailled string about the object
  31592. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31593. * @returns a string representing the object
  31594. */
  31595. toString(fullDetails?: boolean): string;
  31596. }
  31597. }
  31598. declare module BABYLON {
  31599. /**
  31600. * Define an interface for all classes that will hold resources
  31601. */
  31602. export interface IDisposable {
  31603. /**
  31604. * Releases all held resources
  31605. */
  31606. dispose(): void;
  31607. }
  31608. /** Interface defining initialization parameters for Scene class */
  31609. export interface SceneOptions {
  31610. /**
  31611. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31612. * It will improve performance when the number of geometries becomes important.
  31613. */
  31614. useGeometryUniqueIdsMap?: boolean;
  31615. /**
  31616. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31617. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31618. */
  31619. useMaterialMeshMap?: boolean;
  31620. /**
  31621. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31622. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31623. */
  31624. useClonedMeshhMap?: boolean;
  31625. }
  31626. /**
  31627. * Represents a scene to be rendered by the engine.
  31628. * @see http://doc.babylonjs.com/features/scene
  31629. */
  31630. export class Scene extends AbstractScene implements IAnimatable {
  31631. private static _uniqueIdCounter;
  31632. /** The fog is deactivated */
  31633. static readonly FOGMODE_NONE: number;
  31634. /** The fog density is following an exponential function */
  31635. static readonly FOGMODE_EXP: number;
  31636. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31637. static readonly FOGMODE_EXP2: number;
  31638. /** The fog density is following a linear function. */
  31639. static readonly FOGMODE_LINEAR: number;
  31640. /**
  31641. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31642. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31643. */
  31644. static MinDeltaTime: number;
  31645. /**
  31646. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31648. */
  31649. static MaxDeltaTime: number;
  31650. /**
  31651. * Factory used to create the default material.
  31652. * @param name The name of the material to create
  31653. * @param scene The scene to create the material for
  31654. * @returns The default material
  31655. */
  31656. static DefaultMaterialFactory(scene: Scene): Material;
  31657. /**
  31658. * Factory used to create the a collision coordinator.
  31659. * @returns The collision coordinator
  31660. */
  31661. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31662. /** @hidden */
  31663. readonly _isScene: boolean;
  31664. /**
  31665. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31666. */
  31667. autoClear: boolean;
  31668. /**
  31669. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31670. */
  31671. autoClearDepthAndStencil: boolean;
  31672. /**
  31673. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31674. */
  31675. clearColor: Color4;
  31676. /**
  31677. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31678. */
  31679. ambientColor: Color3;
  31680. /**
  31681. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31682. * It should only be one of the following (if not the default embedded one):
  31683. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31684. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31685. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31686. * The material properties need to be setup according to the type of texture in use.
  31687. */
  31688. environmentBRDFTexture: BaseTexture;
  31689. /** @hidden */
  31690. protected _environmentTexture: Nullable<BaseTexture>;
  31691. /**
  31692. * Texture used in all pbr material as the reflection texture.
  31693. * As in the majority of the scene they are the same (exception for multi room and so on),
  31694. * this is easier to reference from here than from all the materials.
  31695. */
  31696. /**
  31697. * Texture used in all pbr material as the reflection texture.
  31698. * As in the majority of the scene they are the same (exception for multi room and so on),
  31699. * this is easier to set here than in all the materials.
  31700. */
  31701. environmentTexture: Nullable<BaseTexture>;
  31702. /** @hidden */
  31703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31704. /**
  31705. * Default image processing configuration used either in the rendering
  31706. * Forward main pass or through the imageProcessingPostProcess if present.
  31707. * As in the majority of the scene they are the same (exception for multi camera),
  31708. * this is easier to reference from here than from all the materials and post process.
  31709. *
  31710. * No setter as we it is a shared configuration, you can set the values instead.
  31711. */
  31712. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31713. private _forceWireframe;
  31714. /**
  31715. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31716. */
  31717. forceWireframe: boolean;
  31718. private _forcePointsCloud;
  31719. /**
  31720. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31721. */
  31722. forcePointsCloud: boolean;
  31723. /**
  31724. * Gets or sets the active clipplane 1
  31725. */
  31726. clipPlane: Nullable<Plane>;
  31727. /**
  31728. * Gets or sets the active clipplane 2
  31729. */
  31730. clipPlane2: Nullable<Plane>;
  31731. /**
  31732. * Gets or sets the active clipplane 3
  31733. */
  31734. clipPlane3: Nullable<Plane>;
  31735. /**
  31736. * Gets or sets the active clipplane 4
  31737. */
  31738. clipPlane4: Nullable<Plane>;
  31739. /**
  31740. * Gets or sets a boolean indicating if animations are enabled
  31741. */
  31742. animationsEnabled: boolean;
  31743. private _animationPropertiesOverride;
  31744. /**
  31745. * Gets or sets the animation properties override
  31746. */
  31747. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31748. /**
  31749. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31750. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31751. */
  31752. useConstantAnimationDeltaTime: boolean;
  31753. /**
  31754. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31755. * Please note that it requires to run a ray cast through the scene on every frame
  31756. */
  31757. constantlyUpdateMeshUnderPointer: boolean;
  31758. /**
  31759. * Defines the HTML cursor to use when hovering over interactive elements
  31760. */
  31761. hoverCursor: string;
  31762. /**
  31763. * Defines the HTML default cursor to use (empty by default)
  31764. */
  31765. defaultCursor: string;
  31766. /**
  31767. * This is used to call preventDefault() on pointer down
  31768. * in order to block unwanted artifacts like system double clicks
  31769. */
  31770. preventDefaultOnPointerDown: boolean;
  31771. /**
  31772. * This is used to call preventDefault() on pointer up
  31773. * in order to block unwanted artifacts like system double clicks
  31774. */
  31775. preventDefaultOnPointerUp: boolean;
  31776. /**
  31777. * Gets or sets user defined metadata
  31778. */
  31779. metadata: any;
  31780. /**
  31781. * For internal use only. Please do not use.
  31782. */
  31783. reservedDataStore: any;
  31784. /**
  31785. * Gets the name of the plugin used to load this scene (null by default)
  31786. */
  31787. loadingPluginName: string;
  31788. /**
  31789. * Use this array to add regular expressions used to disable offline support for specific urls
  31790. */
  31791. disableOfflineSupportExceptionRules: RegExp[];
  31792. /**
  31793. * An event triggered when the scene is disposed.
  31794. */
  31795. onDisposeObservable: Observable<Scene>;
  31796. private _onDisposeObserver;
  31797. /** Sets a function to be executed when this scene is disposed. */
  31798. onDispose: () => void;
  31799. /**
  31800. * An event triggered before rendering the scene (right after animations and physics)
  31801. */
  31802. onBeforeRenderObservable: Observable<Scene>;
  31803. private _onBeforeRenderObserver;
  31804. /** Sets a function to be executed before rendering this scene */
  31805. beforeRender: Nullable<() => void>;
  31806. /**
  31807. * An event triggered after rendering the scene
  31808. */
  31809. onAfterRenderObservable: Observable<Scene>;
  31810. private _onAfterRenderObserver;
  31811. /** Sets a function to be executed after rendering this scene */
  31812. afterRender: Nullable<() => void>;
  31813. /**
  31814. * An event triggered before animating the scene
  31815. */
  31816. onBeforeAnimationsObservable: Observable<Scene>;
  31817. /**
  31818. * An event triggered after animations processing
  31819. */
  31820. onAfterAnimationsObservable: Observable<Scene>;
  31821. /**
  31822. * An event triggered before draw calls are ready to be sent
  31823. */
  31824. onBeforeDrawPhaseObservable: Observable<Scene>;
  31825. /**
  31826. * An event triggered after draw calls have been sent
  31827. */
  31828. onAfterDrawPhaseObservable: Observable<Scene>;
  31829. /**
  31830. * An event triggered when the scene is ready
  31831. */
  31832. onReadyObservable: Observable<Scene>;
  31833. /**
  31834. * An event triggered before rendering a camera
  31835. */
  31836. onBeforeCameraRenderObservable: Observable<Camera>;
  31837. private _onBeforeCameraRenderObserver;
  31838. /** Sets a function to be executed before rendering a camera*/
  31839. beforeCameraRender: () => void;
  31840. /**
  31841. * An event triggered after rendering a camera
  31842. */
  31843. onAfterCameraRenderObservable: Observable<Camera>;
  31844. private _onAfterCameraRenderObserver;
  31845. /** Sets a function to be executed after rendering a camera*/
  31846. afterCameraRender: () => void;
  31847. /**
  31848. * An event triggered when active meshes evaluation is about to start
  31849. */
  31850. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31851. /**
  31852. * An event triggered when active meshes evaluation is done
  31853. */
  31854. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31855. /**
  31856. * An event triggered when particles rendering is about to start
  31857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31858. */
  31859. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31860. /**
  31861. * An event triggered when particles rendering is done
  31862. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31863. */
  31864. onAfterParticlesRenderingObservable: Observable<Scene>;
  31865. /**
  31866. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31867. */
  31868. onDataLoadedObservable: Observable<Scene>;
  31869. /**
  31870. * An event triggered when a camera is created
  31871. */
  31872. onNewCameraAddedObservable: Observable<Camera>;
  31873. /**
  31874. * An event triggered when a camera is removed
  31875. */
  31876. onCameraRemovedObservable: Observable<Camera>;
  31877. /**
  31878. * An event triggered when a light is created
  31879. */
  31880. onNewLightAddedObservable: Observable<Light>;
  31881. /**
  31882. * An event triggered when a light is removed
  31883. */
  31884. onLightRemovedObservable: Observable<Light>;
  31885. /**
  31886. * An event triggered when a geometry is created
  31887. */
  31888. onNewGeometryAddedObservable: Observable<Geometry>;
  31889. /**
  31890. * An event triggered when a geometry is removed
  31891. */
  31892. onGeometryRemovedObservable: Observable<Geometry>;
  31893. /**
  31894. * An event triggered when a transform node is created
  31895. */
  31896. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31897. /**
  31898. * An event triggered when a transform node is removed
  31899. */
  31900. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31901. /**
  31902. * An event triggered when a mesh is created
  31903. */
  31904. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31905. /**
  31906. * An event triggered when a mesh is removed
  31907. */
  31908. onMeshRemovedObservable: Observable<AbstractMesh>;
  31909. /**
  31910. * An event triggered when a skeleton is created
  31911. */
  31912. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31913. /**
  31914. * An event triggered when a skeleton is removed
  31915. */
  31916. onSkeletonRemovedObservable: Observable<Skeleton>;
  31917. /**
  31918. * An event triggered when a material is created
  31919. */
  31920. onNewMaterialAddedObservable: Observable<Material>;
  31921. /**
  31922. * An event triggered when a material is removed
  31923. */
  31924. onMaterialRemovedObservable: Observable<Material>;
  31925. /**
  31926. * An event triggered when a texture is created
  31927. */
  31928. onNewTextureAddedObservable: Observable<BaseTexture>;
  31929. /**
  31930. * An event triggered when a texture is removed
  31931. */
  31932. onTextureRemovedObservable: Observable<BaseTexture>;
  31933. /**
  31934. * An event triggered when render targets are about to be rendered
  31935. * Can happen multiple times per frame.
  31936. */
  31937. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31938. /**
  31939. * An event triggered when render targets were rendered.
  31940. * Can happen multiple times per frame.
  31941. */
  31942. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31943. /**
  31944. * An event triggered before calculating deterministic simulation step
  31945. */
  31946. onBeforeStepObservable: Observable<Scene>;
  31947. /**
  31948. * An event triggered after calculating deterministic simulation step
  31949. */
  31950. onAfterStepObservable: Observable<Scene>;
  31951. /**
  31952. * An event triggered when the activeCamera property is updated
  31953. */
  31954. onActiveCameraChanged: Observable<Scene>;
  31955. /**
  31956. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31957. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31958. * 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)
  31959. */
  31960. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31961. /**
  31962. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31963. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31964. * 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)
  31965. */
  31966. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31967. /**
  31968. * This Observable will when a mesh has been imported into the scene.
  31969. */
  31970. onMeshImportedObservable: Observable<AbstractMesh>;
  31971. /**
  31972. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31973. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31974. */
  31975. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31976. /** @hidden */
  31977. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31978. /**
  31979. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31980. */
  31981. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31982. /**
  31983. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31984. */
  31985. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31986. /**
  31987. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31988. */
  31989. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31990. private _onPointerMove;
  31991. private _onPointerDown;
  31992. private _onPointerUp;
  31993. /** Callback called when a pointer move is detected */
  31994. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31995. /** Callback called when a pointer down is detected */
  31996. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31997. /** Callback called when a pointer up is detected */
  31998. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31999. /** Callback called when a pointer pick is detected */
  32000. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32001. /**
  32002. * 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).
  32003. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32004. */
  32005. onPrePointerObservable: Observable<PointerInfoPre>;
  32006. /**
  32007. * Observable event triggered each time an input event is received from the rendering canvas
  32008. */
  32009. onPointerObservable: Observable<PointerInfo>;
  32010. /**
  32011. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32012. */
  32013. readonly unTranslatedPointer: Vector2;
  32014. /** The distance in pixel that you have to move to prevent some events */
  32015. static DragMovementThreshold: number;
  32016. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32017. static LongPressDelay: number;
  32018. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32019. static DoubleClickDelay: number;
  32020. /** If you need to check double click without raising a single click at first click, enable this flag */
  32021. static ExclusiveDoubleClickMode: boolean;
  32022. private _initClickEvent;
  32023. private _initActionManager;
  32024. private _delayedSimpleClick;
  32025. private _delayedSimpleClickTimeout;
  32026. private _previousDelayedSimpleClickTimeout;
  32027. private _meshPickProceed;
  32028. private _previousButtonPressed;
  32029. private _currentPickResult;
  32030. private _previousPickResult;
  32031. private _totalPointersPressed;
  32032. private _doubleClickOccured;
  32033. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32034. cameraToUseForPointers: Nullable<Camera>;
  32035. private _pointerX;
  32036. private _pointerY;
  32037. private _unTranslatedPointerX;
  32038. private _unTranslatedPointerY;
  32039. private _startingPointerPosition;
  32040. private _previousStartingPointerPosition;
  32041. private _startingPointerTime;
  32042. private _previousStartingPointerTime;
  32043. private _pointerCaptures;
  32044. private _timeAccumulator;
  32045. private _currentStepId;
  32046. private _currentInternalStep;
  32047. /** @hidden */
  32048. _mirroredCameraPosition: Nullable<Vector3>;
  32049. /**
  32050. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32051. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32052. */
  32053. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32054. /**
  32055. * Observable event triggered each time an keyboard event is received from the hosting window
  32056. */
  32057. onKeyboardObservable: Observable<KeyboardInfo>;
  32058. private _onKeyDown;
  32059. private _onKeyUp;
  32060. private _onCanvasFocusObserver;
  32061. private _onCanvasBlurObserver;
  32062. private _useRightHandedSystem;
  32063. /**
  32064. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32065. */
  32066. useRightHandedSystem: boolean;
  32067. /**
  32068. * Sets the step Id used by deterministic lock step
  32069. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32070. * @param newStepId defines the step Id
  32071. */
  32072. setStepId(newStepId: number): void;
  32073. /**
  32074. * Gets the step Id used by deterministic lock step
  32075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32076. * @returns the step Id
  32077. */
  32078. getStepId(): number;
  32079. /**
  32080. * Gets the internal step used by deterministic lock step
  32081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32082. * @returns the internal step
  32083. */
  32084. getInternalStep(): number;
  32085. private _fogEnabled;
  32086. /**
  32087. * Gets or sets a boolean indicating if fog is enabled on this scene
  32088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32089. * (Default is true)
  32090. */
  32091. fogEnabled: boolean;
  32092. private _fogMode;
  32093. /**
  32094. * Gets or sets the fog mode to use
  32095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32096. * | mode | value |
  32097. * | --- | --- |
  32098. * | FOGMODE_NONE | 0 |
  32099. * | FOGMODE_EXP | 1 |
  32100. * | FOGMODE_EXP2 | 2 |
  32101. * | FOGMODE_LINEAR | 3 |
  32102. */
  32103. fogMode: number;
  32104. /**
  32105. * Gets or sets the fog color to use
  32106. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32107. * (Default is Color3(0.2, 0.2, 0.3))
  32108. */
  32109. fogColor: Color3;
  32110. /**
  32111. * Gets or sets the fog density to use
  32112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32113. * (Default is 0.1)
  32114. */
  32115. fogDensity: number;
  32116. /**
  32117. * Gets or sets the fog start distance to use
  32118. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32119. * (Default is 0)
  32120. */
  32121. fogStart: number;
  32122. /**
  32123. * Gets or sets the fog end distance to use
  32124. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32125. * (Default is 1000)
  32126. */
  32127. fogEnd: number;
  32128. private _shadowsEnabled;
  32129. /**
  32130. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32131. */
  32132. shadowsEnabled: boolean;
  32133. private _lightsEnabled;
  32134. /**
  32135. * Gets or sets a boolean indicating if lights are enabled on this scene
  32136. */
  32137. lightsEnabled: boolean;
  32138. /** All of the active cameras added to this scene. */
  32139. activeCameras: Camera[];
  32140. /** @hidden */
  32141. _activeCamera: Nullable<Camera>;
  32142. /** Gets or sets the current active camera */
  32143. activeCamera: Nullable<Camera>;
  32144. private _defaultMaterial;
  32145. /** The default material used on meshes when no material is affected */
  32146. /** The default material used on meshes when no material is affected */
  32147. defaultMaterial: Material;
  32148. private _texturesEnabled;
  32149. /**
  32150. * Gets or sets a boolean indicating if textures are enabled on this scene
  32151. */
  32152. texturesEnabled: boolean;
  32153. /**
  32154. * Gets or sets a boolean indicating if particles are enabled on this scene
  32155. */
  32156. particlesEnabled: boolean;
  32157. /**
  32158. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32159. */
  32160. spritesEnabled: boolean;
  32161. private _skeletonsEnabled;
  32162. /**
  32163. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32164. */
  32165. skeletonsEnabled: boolean;
  32166. /**
  32167. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32168. */
  32169. lensFlaresEnabled: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32173. */
  32174. collisionsEnabled: boolean;
  32175. private _collisionCoordinator;
  32176. /** @hidden */
  32177. readonly collisionCoordinator: ICollisionCoordinator;
  32178. /**
  32179. * Defines the gravity applied to this scene (used only for collisions)
  32180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32181. */
  32182. gravity: Vector3;
  32183. /**
  32184. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32185. */
  32186. postProcessesEnabled: boolean;
  32187. /**
  32188. * The list of postprocesses added to the scene
  32189. */
  32190. postProcesses: PostProcess[];
  32191. /**
  32192. * Gets the current postprocess manager
  32193. */
  32194. postProcessManager: PostProcessManager;
  32195. /**
  32196. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32197. */
  32198. renderTargetsEnabled: boolean;
  32199. /**
  32200. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32201. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32202. */
  32203. dumpNextRenderTargets: boolean;
  32204. /**
  32205. * The list of user defined render targets added to the scene
  32206. */
  32207. customRenderTargets: RenderTargetTexture[];
  32208. /**
  32209. * Defines if texture loading must be delayed
  32210. * If true, textures will only be loaded when they need to be rendered
  32211. */
  32212. useDelayedTextureLoading: boolean;
  32213. /**
  32214. * Gets the list of meshes imported to the scene through SceneLoader
  32215. */
  32216. importedMeshesFiles: String[];
  32217. /**
  32218. * Gets or sets a boolean indicating if probes are enabled on this scene
  32219. */
  32220. probesEnabled: boolean;
  32221. /**
  32222. * Gets or sets the current offline provider to use to store scene data
  32223. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32224. */
  32225. offlineProvider: IOfflineProvider;
  32226. /**
  32227. * Gets or sets the action manager associated with the scene
  32228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32229. */
  32230. actionManager: AbstractActionManager;
  32231. private _meshesForIntersections;
  32232. /**
  32233. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32234. */
  32235. proceduralTexturesEnabled: boolean;
  32236. private _engine;
  32237. private _totalVertices;
  32238. /** @hidden */
  32239. _activeIndices: PerfCounter;
  32240. /** @hidden */
  32241. _activeParticles: PerfCounter;
  32242. /** @hidden */
  32243. _activeBones: PerfCounter;
  32244. private _animationRatio;
  32245. /** @hidden */
  32246. _animationTimeLast: number;
  32247. /** @hidden */
  32248. _animationTime: number;
  32249. /**
  32250. * Gets or sets a general scale for animation speed
  32251. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32252. */
  32253. animationTimeScale: number;
  32254. /** @hidden */
  32255. _cachedMaterial: Nullable<Material>;
  32256. /** @hidden */
  32257. _cachedEffect: Nullable<Effect>;
  32258. /** @hidden */
  32259. _cachedVisibility: Nullable<number>;
  32260. private _renderId;
  32261. private _frameId;
  32262. private _executeWhenReadyTimeoutId;
  32263. private _intermediateRendering;
  32264. private _viewUpdateFlag;
  32265. private _projectionUpdateFlag;
  32266. /** @hidden */
  32267. _toBeDisposed: Nullable<IDisposable>[];
  32268. private _activeRequests;
  32269. /** @hidden */
  32270. _pendingData: any[];
  32271. private _isDisposed;
  32272. /**
  32273. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32274. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32275. */
  32276. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32277. private _activeMeshes;
  32278. private _processedMaterials;
  32279. private _renderTargets;
  32280. /** @hidden */
  32281. _activeParticleSystems: SmartArray<IParticleSystem>;
  32282. private _activeSkeletons;
  32283. private _softwareSkinnedMeshes;
  32284. private _renderingManager;
  32285. /** @hidden */
  32286. _activeAnimatables: Animatable[];
  32287. private _transformMatrix;
  32288. private _sceneUbo;
  32289. /** @hidden */
  32290. _viewMatrix: Matrix;
  32291. private _projectionMatrix;
  32292. private _wheelEventName;
  32293. /** @hidden */
  32294. _forcedViewPosition: Nullable<Vector3>;
  32295. /** @hidden */
  32296. _frustumPlanes: Plane[];
  32297. /**
  32298. * Gets the list of frustum planes (built from the active camera)
  32299. */
  32300. readonly frustumPlanes: Plane[];
  32301. /**
  32302. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32303. * This is useful if there are more lights that the maximum simulteanous authorized
  32304. */
  32305. requireLightSorting: boolean;
  32306. /** @hidden */
  32307. readonly useMaterialMeshMap: boolean;
  32308. /** @hidden */
  32309. readonly useClonedMeshhMap: boolean;
  32310. private _pointerOverMesh;
  32311. private _pickedDownMesh;
  32312. private _pickedUpMesh;
  32313. private _externalData;
  32314. private _uid;
  32315. /**
  32316. * @hidden
  32317. * Backing store of defined scene components.
  32318. */
  32319. _components: ISceneComponent[];
  32320. /**
  32321. * @hidden
  32322. * Backing store of defined scene components.
  32323. */
  32324. _serializableComponents: ISceneSerializableComponent[];
  32325. /**
  32326. * List of components to register on the next registration step.
  32327. */
  32328. private _transientComponents;
  32329. /**
  32330. * Registers the transient components if needed.
  32331. */
  32332. private _registerTransientComponents;
  32333. /**
  32334. * @hidden
  32335. * Add a component to the scene.
  32336. * Note that the ccomponent could be registered on th next frame if this is called after
  32337. * the register component stage.
  32338. * @param component Defines the component to add to the scene
  32339. */
  32340. _addComponent(component: ISceneComponent): void;
  32341. /**
  32342. * @hidden
  32343. * Gets a component from the scene.
  32344. * @param name defines the name of the component to retrieve
  32345. * @returns the component or null if not present
  32346. */
  32347. _getComponent(name: string): Nullable<ISceneComponent>;
  32348. /**
  32349. * @hidden
  32350. * Defines the actions happening before camera updates.
  32351. */
  32352. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32353. /**
  32354. * @hidden
  32355. * Defines the actions happening before clear the canvas.
  32356. */
  32357. _beforeClearStage: Stage<SimpleStageAction>;
  32358. /**
  32359. * @hidden
  32360. * Defines the actions when collecting render targets for the frame.
  32361. */
  32362. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32363. /**
  32364. * @hidden
  32365. * Defines the actions happening for one camera in the frame.
  32366. */
  32367. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32368. /**
  32369. * @hidden
  32370. * Defines the actions happening during the per mesh ready checks.
  32371. */
  32372. _isReadyForMeshStage: Stage<MeshStageAction>;
  32373. /**
  32374. * @hidden
  32375. * Defines the actions happening before evaluate active mesh checks.
  32376. */
  32377. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32378. /**
  32379. * @hidden
  32380. * Defines the actions happening during the evaluate sub mesh checks.
  32381. */
  32382. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32383. /**
  32384. * @hidden
  32385. * Defines the actions happening during the active mesh stage.
  32386. */
  32387. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32388. /**
  32389. * @hidden
  32390. * Defines the actions happening during the per camera render target step.
  32391. */
  32392. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32393. /**
  32394. * @hidden
  32395. * Defines the actions happening just before the active camera is drawing.
  32396. */
  32397. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32398. /**
  32399. * @hidden
  32400. * Defines the actions happening just before a render target is drawing.
  32401. */
  32402. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32403. /**
  32404. * @hidden
  32405. * Defines the actions happening just before a rendering group is drawing.
  32406. */
  32407. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32408. /**
  32409. * @hidden
  32410. * Defines the actions happening just before a mesh is drawing.
  32411. */
  32412. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32413. /**
  32414. * @hidden
  32415. * Defines the actions happening just after a mesh has been drawn.
  32416. */
  32417. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32418. /**
  32419. * @hidden
  32420. * Defines the actions happening just after a rendering group has been drawn.
  32421. */
  32422. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32423. /**
  32424. * @hidden
  32425. * Defines the actions happening just after the active camera has been drawn.
  32426. */
  32427. _afterCameraDrawStage: Stage<CameraStageAction>;
  32428. /**
  32429. * @hidden
  32430. * Defines the actions happening just after a render target has been drawn.
  32431. */
  32432. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32433. /**
  32434. * @hidden
  32435. * Defines the actions happening just after rendering all cameras and computing intersections.
  32436. */
  32437. _afterRenderStage: Stage<SimpleStageAction>;
  32438. /**
  32439. * @hidden
  32440. * Defines the actions happening when a pointer move event happens.
  32441. */
  32442. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32443. /**
  32444. * @hidden
  32445. * Defines the actions happening when a pointer down event happens.
  32446. */
  32447. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32448. /**
  32449. * @hidden
  32450. * Defines the actions happening when a pointer up event happens.
  32451. */
  32452. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32453. /**
  32454. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32455. */
  32456. private geometriesByUniqueId;
  32457. /**
  32458. * Creates a new Scene
  32459. * @param engine defines the engine to use to render this scene
  32460. * @param options defines the scene options
  32461. */
  32462. constructor(engine: Engine, options?: SceneOptions);
  32463. /**
  32464. * Gets a string idenfifying the name of the class
  32465. * @returns "Scene" string
  32466. */
  32467. getClassName(): string;
  32468. private _defaultMeshCandidates;
  32469. /**
  32470. * @hidden
  32471. */
  32472. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32473. private _defaultSubMeshCandidates;
  32474. /**
  32475. * @hidden
  32476. */
  32477. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32478. /**
  32479. * Sets the default candidate providers for the scene.
  32480. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32481. * and getCollidingSubMeshCandidates to their default function
  32482. */
  32483. setDefaultCandidateProviders(): void;
  32484. /**
  32485. * Gets the mesh that is currently under the pointer
  32486. */
  32487. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32488. /**
  32489. * Gets or sets the current on-screen X position of the pointer
  32490. */
  32491. pointerX: number;
  32492. /**
  32493. * Gets or sets the current on-screen Y position of the pointer
  32494. */
  32495. pointerY: number;
  32496. /**
  32497. * Gets the cached material (ie. the latest rendered one)
  32498. * @returns the cached material
  32499. */
  32500. getCachedMaterial(): Nullable<Material>;
  32501. /**
  32502. * Gets the cached effect (ie. the latest rendered one)
  32503. * @returns the cached effect
  32504. */
  32505. getCachedEffect(): Nullable<Effect>;
  32506. /**
  32507. * Gets the cached visibility state (ie. the latest rendered one)
  32508. * @returns the cached visibility state
  32509. */
  32510. getCachedVisibility(): Nullable<number>;
  32511. /**
  32512. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32513. * @param material defines the current material
  32514. * @param effect defines the current effect
  32515. * @param visibility defines the current visibility state
  32516. * @returns true if one parameter is not cached
  32517. */
  32518. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32519. /**
  32520. * Gets the engine associated with the scene
  32521. * @returns an Engine
  32522. */
  32523. getEngine(): Engine;
  32524. /**
  32525. * Gets the total number of vertices rendered per frame
  32526. * @returns the total number of vertices rendered per frame
  32527. */
  32528. getTotalVertices(): number;
  32529. /**
  32530. * Gets the performance counter for total vertices
  32531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32532. */
  32533. readonly totalVerticesPerfCounter: PerfCounter;
  32534. /**
  32535. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32536. * @returns the total number of active indices rendered per frame
  32537. */
  32538. getActiveIndices(): number;
  32539. /**
  32540. * Gets the performance counter for active indices
  32541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32542. */
  32543. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32544. /**
  32545. * Gets the total number of active particles rendered per frame
  32546. * @returns the total number of active particles rendered per frame
  32547. */
  32548. getActiveParticles(): number;
  32549. /**
  32550. * Gets the performance counter for active particles
  32551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32552. */
  32553. readonly activeParticlesPerfCounter: PerfCounter;
  32554. /**
  32555. * Gets the total number of active bones rendered per frame
  32556. * @returns the total number of active bones rendered per frame
  32557. */
  32558. getActiveBones(): number;
  32559. /**
  32560. * Gets the performance counter for active bones
  32561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32562. */
  32563. readonly activeBonesPerfCounter: PerfCounter;
  32564. /**
  32565. * Gets the array of active meshes
  32566. * @returns an array of AbstractMesh
  32567. */
  32568. getActiveMeshes(): SmartArray<AbstractMesh>;
  32569. /**
  32570. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32571. * @returns a number
  32572. */
  32573. getAnimationRatio(): number;
  32574. /**
  32575. * Gets an unique Id for the current render phase
  32576. * @returns a number
  32577. */
  32578. getRenderId(): number;
  32579. /**
  32580. * Gets an unique Id for the current frame
  32581. * @returns a number
  32582. */
  32583. getFrameId(): number;
  32584. /** Call this function if you want to manually increment the render Id*/
  32585. incrementRenderId(): void;
  32586. private _updatePointerPosition;
  32587. private _createUbo;
  32588. private _setRayOnPointerInfo;
  32589. /**
  32590. * Use this method to simulate a pointer move on a mesh
  32591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32594. * @returns the current scene
  32595. */
  32596. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32597. private _processPointerMove;
  32598. private _checkPrePointerObservable;
  32599. /**
  32600. * Use this method to simulate a pointer down on a mesh
  32601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32604. * @returns the current scene
  32605. */
  32606. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32607. private _processPointerDown;
  32608. /**
  32609. * Use this method to simulate a pointer up on a mesh
  32610. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32611. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32612. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32613. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32614. * @returns the current scene
  32615. */
  32616. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32617. private _processPointerUp;
  32618. /**
  32619. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32620. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32621. * @returns true if the pointer was captured
  32622. */
  32623. isPointerCaptured(pointerId?: number): boolean;
  32624. /** @hidden */
  32625. _isPointerSwiping(): boolean;
  32626. /**
  32627. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32628. * @param attachUp defines if you want to attach events to pointerup
  32629. * @param attachDown defines if you want to attach events to pointerdown
  32630. * @param attachMove defines if you want to attach events to pointermove
  32631. */
  32632. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32633. /** Detaches all event handlers*/
  32634. detachControl(): void;
  32635. /**
  32636. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32637. * Delay loaded resources are not taking in account
  32638. * @return true if all required resources are ready
  32639. */
  32640. isReady(): boolean;
  32641. /** Resets all cached information relative to material (including effect and visibility) */
  32642. resetCachedMaterial(): void;
  32643. /**
  32644. * Registers a function to be called before every frame render
  32645. * @param func defines the function to register
  32646. */
  32647. registerBeforeRender(func: () => void): void;
  32648. /**
  32649. * Unregisters a function called before every frame render
  32650. * @param func defines the function to unregister
  32651. */
  32652. unregisterBeforeRender(func: () => void): void;
  32653. /**
  32654. * Registers a function to be called after every frame render
  32655. * @param func defines the function to register
  32656. */
  32657. registerAfterRender(func: () => void): void;
  32658. /**
  32659. * Unregisters a function called after every frame render
  32660. * @param func defines the function to unregister
  32661. */
  32662. unregisterAfterRender(func: () => void): void;
  32663. private _executeOnceBeforeRender;
  32664. /**
  32665. * The provided function will run before render once and will be disposed afterwards.
  32666. * A timeout delay can be provided so that the function will be executed in N ms.
  32667. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32668. * @param func The function to be executed.
  32669. * @param timeout optional delay in ms
  32670. */
  32671. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32672. /** @hidden */
  32673. _addPendingData(data: any): void;
  32674. /** @hidden */
  32675. _removePendingData(data: any): void;
  32676. /**
  32677. * Returns the number of items waiting to be loaded
  32678. * @returns the number of items waiting to be loaded
  32679. */
  32680. getWaitingItemsCount(): number;
  32681. /**
  32682. * Returns a boolean indicating if the scene is still loading data
  32683. */
  32684. readonly isLoading: boolean;
  32685. /**
  32686. * Registers a function to be executed when the scene is ready
  32687. * @param {Function} func - the function to be executed
  32688. */
  32689. executeWhenReady(func: () => void): void;
  32690. /**
  32691. * Returns a promise that resolves when the scene is ready
  32692. * @returns A promise that resolves when the scene is ready
  32693. */
  32694. whenReadyAsync(): Promise<void>;
  32695. /** @hidden */
  32696. _checkIsReady(): void;
  32697. /**
  32698. * Gets all animatable attached to the scene
  32699. */
  32700. readonly animatables: Animatable[];
  32701. /**
  32702. * Resets the last animation time frame.
  32703. * Useful to override when animations start running when loading a scene for the first time.
  32704. */
  32705. resetLastAnimationTimeFrame(): void;
  32706. /**
  32707. * Gets the current view matrix
  32708. * @returns a Matrix
  32709. */
  32710. getViewMatrix(): Matrix;
  32711. /**
  32712. * Gets the current projection matrix
  32713. * @returns a Matrix
  32714. */
  32715. getProjectionMatrix(): Matrix;
  32716. /**
  32717. * Gets the current transform matrix
  32718. * @returns a Matrix made of View * Projection
  32719. */
  32720. getTransformMatrix(): Matrix;
  32721. /**
  32722. * Sets the current transform matrix
  32723. * @param viewL defines the View matrix to use
  32724. * @param projectionL defines the Projection matrix to use
  32725. * @param viewR defines the right View matrix to use (if provided)
  32726. * @param projectionR defines the right Projection matrix to use (if provided)
  32727. */
  32728. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32729. /**
  32730. * Gets the uniform buffer used to store scene data
  32731. * @returns a UniformBuffer
  32732. */
  32733. getSceneUniformBuffer(): UniformBuffer;
  32734. /**
  32735. * Gets an unique (relatively to the current scene) Id
  32736. * @returns an unique number for the scene
  32737. */
  32738. getUniqueId(): number;
  32739. /**
  32740. * Add a mesh to the list of scene's meshes
  32741. * @param newMesh defines the mesh to add
  32742. * @param recursive if all child meshes should also be added to the scene
  32743. */
  32744. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32745. /**
  32746. * Remove a mesh for the list of scene's meshes
  32747. * @param toRemove defines the mesh to remove
  32748. * @param recursive if all child meshes should also be removed from the scene
  32749. * @returns the index where the mesh was in the mesh list
  32750. */
  32751. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32752. /**
  32753. * Add a transform node to the list of scene's transform nodes
  32754. * @param newTransformNode defines the transform node to add
  32755. */
  32756. addTransformNode(newTransformNode: TransformNode): void;
  32757. /**
  32758. * Remove a transform node for the list of scene's transform nodes
  32759. * @param toRemove defines the transform node to remove
  32760. * @returns the index where the transform node was in the transform node list
  32761. */
  32762. removeTransformNode(toRemove: TransformNode): number;
  32763. /**
  32764. * Remove a skeleton for the list of scene's skeletons
  32765. * @param toRemove defines the skeleton to remove
  32766. * @returns the index where the skeleton was in the skeleton list
  32767. */
  32768. removeSkeleton(toRemove: Skeleton): number;
  32769. /**
  32770. * Remove a morph target for the list of scene's morph targets
  32771. * @param toRemove defines the morph target to remove
  32772. * @returns the index where the morph target was in the morph target list
  32773. */
  32774. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32775. /**
  32776. * Remove a light for the list of scene's lights
  32777. * @param toRemove defines the light to remove
  32778. * @returns the index where the light was in the light list
  32779. */
  32780. removeLight(toRemove: Light): number;
  32781. /**
  32782. * Remove a camera for the list of scene's cameras
  32783. * @param toRemove defines the camera to remove
  32784. * @returns the index where the camera was in the camera list
  32785. */
  32786. removeCamera(toRemove: Camera): number;
  32787. /**
  32788. * Remove a particle system for the list of scene's particle systems
  32789. * @param toRemove defines the particle system to remove
  32790. * @returns the index where the particle system was in the particle system list
  32791. */
  32792. removeParticleSystem(toRemove: IParticleSystem): number;
  32793. /**
  32794. * Remove a animation for the list of scene's animations
  32795. * @param toRemove defines the animation to remove
  32796. * @returns the index where the animation was in the animation list
  32797. */
  32798. removeAnimation(toRemove: Animation): number;
  32799. /**
  32800. * Removes the given animation group from this scene.
  32801. * @param toRemove The animation group to remove
  32802. * @returns The index of the removed animation group
  32803. */
  32804. removeAnimationGroup(toRemove: AnimationGroup): number;
  32805. /**
  32806. * Removes the given multi-material from this scene.
  32807. * @param toRemove The multi-material to remove
  32808. * @returns The index of the removed multi-material
  32809. */
  32810. removeMultiMaterial(toRemove: MultiMaterial): number;
  32811. /**
  32812. * Removes the given material from this scene.
  32813. * @param toRemove The material to remove
  32814. * @returns The index of the removed material
  32815. */
  32816. removeMaterial(toRemove: Material): number;
  32817. /**
  32818. * Removes the given action manager from this scene.
  32819. * @param toRemove The action manager to remove
  32820. * @returns The index of the removed action manager
  32821. */
  32822. removeActionManager(toRemove: AbstractActionManager): number;
  32823. /**
  32824. * Removes the given texture from this scene.
  32825. * @param toRemove The texture to remove
  32826. * @returns The index of the removed texture
  32827. */
  32828. removeTexture(toRemove: BaseTexture): number;
  32829. /**
  32830. * Adds the given light to this scene
  32831. * @param newLight The light to add
  32832. */
  32833. addLight(newLight: Light): void;
  32834. /**
  32835. * Sorts the list list based on light priorities
  32836. */
  32837. sortLightsByPriority(): void;
  32838. /**
  32839. * Adds the given camera to this scene
  32840. * @param newCamera The camera to add
  32841. */
  32842. addCamera(newCamera: Camera): void;
  32843. /**
  32844. * Adds the given skeleton to this scene
  32845. * @param newSkeleton The skeleton to add
  32846. */
  32847. addSkeleton(newSkeleton: Skeleton): void;
  32848. /**
  32849. * Adds the given particle system to this scene
  32850. * @param newParticleSystem The particle system to add
  32851. */
  32852. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32853. /**
  32854. * Adds the given animation to this scene
  32855. * @param newAnimation The animation to add
  32856. */
  32857. addAnimation(newAnimation: Animation): void;
  32858. /**
  32859. * Adds the given animation group to this scene.
  32860. * @param newAnimationGroup The animation group to add
  32861. */
  32862. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32863. /**
  32864. * Adds the given multi-material to this scene
  32865. * @param newMultiMaterial The multi-material to add
  32866. */
  32867. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32868. /**
  32869. * Adds the given material to this scene
  32870. * @param newMaterial The material to add
  32871. */
  32872. addMaterial(newMaterial: Material): void;
  32873. /**
  32874. * Adds the given morph target to this scene
  32875. * @param newMorphTargetManager The morph target to add
  32876. */
  32877. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32878. /**
  32879. * Adds the given geometry to this scene
  32880. * @param newGeometry The geometry to add
  32881. */
  32882. addGeometry(newGeometry: Geometry): void;
  32883. /**
  32884. * Adds the given action manager to this scene
  32885. * @param newActionManager The action manager to add
  32886. */
  32887. addActionManager(newActionManager: AbstractActionManager): void;
  32888. /**
  32889. * Adds the given texture to this scene.
  32890. * @param newTexture The texture to add
  32891. */
  32892. addTexture(newTexture: BaseTexture): void;
  32893. /**
  32894. * Switch active camera
  32895. * @param newCamera defines the new active camera
  32896. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32897. */
  32898. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32899. /**
  32900. * sets the active camera of the scene using its ID
  32901. * @param id defines the camera's ID
  32902. * @return the new active camera or null if none found.
  32903. */
  32904. setActiveCameraByID(id: string): Nullable<Camera>;
  32905. /**
  32906. * sets the active camera of the scene using its name
  32907. * @param name defines the camera's name
  32908. * @returns the new active camera or null if none found.
  32909. */
  32910. setActiveCameraByName(name: string): Nullable<Camera>;
  32911. /**
  32912. * get an animation group using its name
  32913. * @param name defines the material's name
  32914. * @return the animation group or null if none found.
  32915. */
  32916. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32917. /**
  32918. * Get a material using its unique id
  32919. * @param uniqueId defines the material's unique id
  32920. * @return the material or null if none found.
  32921. */
  32922. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32923. /**
  32924. * get a material using its id
  32925. * @param id defines the material's ID
  32926. * @return the material or null if none found.
  32927. */
  32928. getMaterialByID(id: string): Nullable<Material>;
  32929. /**
  32930. * Gets a material using its name
  32931. * @param name defines the material's name
  32932. * @return the material or null if none found.
  32933. */
  32934. getMaterialByName(name: string): Nullable<Material>;
  32935. /**
  32936. * Gets a camera using its id
  32937. * @param id defines the id to look for
  32938. * @returns the camera or null if not found
  32939. */
  32940. getCameraByID(id: string): Nullable<Camera>;
  32941. /**
  32942. * Gets a camera using its unique id
  32943. * @param uniqueId defines the unique id to look for
  32944. * @returns the camera or null if not found
  32945. */
  32946. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32947. /**
  32948. * Gets a camera using its name
  32949. * @param name defines the camera's name
  32950. * @return the camera or null if none found.
  32951. */
  32952. getCameraByName(name: string): Nullable<Camera>;
  32953. /**
  32954. * Gets a bone using its id
  32955. * @param id defines the bone's id
  32956. * @return the bone or null if not found
  32957. */
  32958. getBoneByID(id: string): Nullable<Bone>;
  32959. /**
  32960. * Gets a bone using its id
  32961. * @param name defines the bone's name
  32962. * @return the bone or null if not found
  32963. */
  32964. getBoneByName(name: string): Nullable<Bone>;
  32965. /**
  32966. * Gets a light node using its name
  32967. * @param name defines the the light's name
  32968. * @return the light or null if none found.
  32969. */
  32970. getLightByName(name: string): Nullable<Light>;
  32971. /**
  32972. * Gets a light node using its id
  32973. * @param id defines the light's id
  32974. * @return the light or null if none found.
  32975. */
  32976. getLightByID(id: string): Nullable<Light>;
  32977. /**
  32978. * Gets a light node using its scene-generated unique ID
  32979. * @param uniqueId defines the light's unique id
  32980. * @return the light or null if none found.
  32981. */
  32982. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32983. /**
  32984. * Gets a particle system by id
  32985. * @param id defines the particle system id
  32986. * @return the corresponding system or null if none found
  32987. */
  32988. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32989. /**
  32990. * Gets a geometry using its ID
  32991. * @param id defines the geometry's id
  32992. * @return the geometry or null if none found.
  32993. */
  32994. getGeometryByID(id: string): Nullable<Geometry>;
  32995. private _getGeometryByUniqueID;
  32996. /**
  32997. * Add a new geometry to this scene
  32998. * @param geometry defines the geometry to be added to the scene.
  32999. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33000. * @return a boolean defining if the geometry was added or not
  33001. */
  33002. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33003. /**
  33004. * Removes an existing geometry
  33005. * @param geometry defines the geometry to be removed from the scene
  33006. * @return a boolean defining if the geometry was removed or not
  33007. */
  33008. removeGeometry(geometry: Geometry): boolean;
  33009. /**
  33010. * Gets the list of geometries attached to the scene
  33011. * @returns an array of Geometry
  33012. */
  33013. getGeometries(): Geometry[];
  33014. /**
  33015. * Gets the first added mesh found of a given ID
  33016. * @param id defines the id to search for
  33017. * @return the mesh found or null if not found at all
  33018. */
  33019. getMeshByID(id: string): Nullable<AbstractMesh>;
  33020. /**
  33021. * Gets a list of meshes using their id
  33022. * @param id defines the id to search for
  33023. * @returns a list of meshes
  33024. */
  33025. getMeshesByID(id: string): Array<AbstractMesh>;
  33026. /**
  33027. * Gets the first added transform node found of a given ID
  33028. * @param id defines the id to search for
  33029. * @return the found transform node or null if not found at all.
  33030. */
  33031. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33032. /**
  33033. * Gets a transform node with its auto-generated unique id
  33034. * @param uniqueId efines the unique id to search for
  33035. * @return the found transform node or null if not found at all.
  33036. */
  33037. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33038. /**
  33039. * Gets a list of transform nodes using their id
  33040. * @param id defines the id to search for
  33041. * @returns a list of transform nodes
  33042. */
  33043. getTransformNodesByID(id: string): Array<TransformNode>;
  33044. /**
  33045. * Gets a mesh with its auto-generated unique id
  33046. * @param uniqueId defines the unique id to search for
  33047. * @return the found mesh or null if not found at all.
  33048. */
  33049. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33050. /**
  33051. * Gets a the last added mesh using a given id
  33052. * @param id defines the id to search for
  33053. * @return the found mesh or null if not found at all.
  33054. */
  33055. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33056. /**
  33057. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33058. * @param id defines the id to search for
  33059. * @return the found node or null if not found at all
  33060. */
  33061. getLastEntryByID(id: string): Nullable<Node>;
  33062. /**
  33063. * Gets a node (Mesh, Camera, Light) using a given id
  33064. * @param id defines the id to search for
  33065. * @return the found node or null if not found at all
  33066. */
  33067. getNodeByID(id: string): Nullable<Node>;
  33068. /**
  33069. * Gets a node (Mesh, Camera, Light) using a given name
  33070. * @param name defines the name to search for
  33071. * @return the found node or null if not found at all.
  33072. */
  33073. getNodeByName(name: string): Nullable<Node>;
  33074. /**
  33075. * Gets a mesh using a given name
  33076. * @param name defines the name to search for
  33077. * @return the found mesh or null if not found at all.
  33078. */
  33079. getMeshByName(name: string): Nullable<AbstractMesh>;
  33080. /**
  33081. * Gets a transform node using a given name
  33082. * @param name defines the name to search for
  33083. * @return the found transform node or null if not found at all.
  33084. */
  33085. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33086. /**
  33087. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33088. * @param id defines the id to search for
  33089. * @return the found skeleton or null if not found at all.
  33090. */
  33091. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33092. /**
  33093. * Gets a skeleton using a given auto generated unique id
  33094. * @param uniqueId defines the unique id to search for
  33095. * @return the found skeleton or null if not found at all.
  33096. */
  33097. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33098. /**
  33099. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33100. * @param id defines the id to search for
  33101. * @return the found skeleton or null if not found at all.
  33102. */
  33103. getSkeletonById(id: string): Nullable<Skeleton>;
  33104. /**
  33105. * Gets a skeleton using a given name
  33106. * @param name defines the name to search for
  33107. * @return the found skeleton or null if not found at all.
  33108. */
  33109. getSkeletonByName(name: string): Nullable<Skeleton>;
  33110. /**
  33111. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33112. * @param id defines the id to search for
  33113. * @return the found morph target manager or null if not found at all.
  33114. */
  33115. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33116. /**
  33117. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33118. * @param id defines the id to search for
  33119. * @return the found morph target or null if not found at all.
  33120. */
  33121. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33122. /**
  33123. * Gets a boolean indicating if the given mesh is active
  33124. * @param mesh defines the mesh to look for
  33125. * @returns true if the mesh is in the active list
  33126. */
  33127. isActiveMesh(mesh: AbstractMesh): boolean;
  33128. /**
  33129. * Return a unique id as a string which can serve as an identifier for the scene
  33130. */
  33131. readonly uid: string;
  33132. /**
  33133. * Add an externaly attached data from its key.
  33134. * This method call will fail and return false, if such key already exists.
  33135. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33136. * @param key the unique key that identifies the data
  33137. * @param data the data object to associate to the key for this Engine instance
  33138. * @return true if no such key were already present and the data was added successfully, false otherwise
  33139. */
  33140. addExternalData<T>(key: string, data: T): boolean;
  33141. /**
  33142. * Get an externaly attached data from its key
  33143. * @param key the unique key that identifies the data
  33144. * @return the associated data, if present (can be null), or undefined if not present
  33145. */
  33146. getExternalData<T>(key: string): Nullable<T>;
  33147. /**
  33148. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33149. * @param key the unique key that identifies the data
  33150. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33151. * @return the associated data, can be null if the factory returned null.
  33152. */
  33153. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33154. /**
  33155. * Remove an externaly attached data from the Engine instance
  33156. * @param key the unique key that identifies the data
  33157. * @return true if the data was successfully removed, false if it doesn't exist
  33158. */
  33159. removeExternalData(key: string): boolean;
  33160. private _evaluateSubMesh;
  33161. /**
  33162. * Clear the processed materials smart array preventing retention point in material dispose.
  33163. */
  33164. freeProcessedMaterials(): void;
  33165. private _preventFreeActiveMeshesAndRenderingGroups;
  33166. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33167. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33168. * when disposing several meshes in a row or a hierarchy of meshes.
  33169. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33170. */
  33171. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33172. /**
  33173. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33174. */
  33175. freeActiveMeshes(): void;
  33176. /**
  33177. * Clear the info related to rendering groups preventing retention points during dispose.
  33178. */
  33179. freeRenderingGroups(): void;
  33180. /** @hidden */
  33181. _isInIntermediateRendering(): boolean;
  33182. /**
  33183. * Lambda returning the list of potentially active meshes.
  33184. */
  33185. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33186. /**
  33187. * Lambda returning the list of potentially active sub meshes.
  33188. */
  33189. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33190. /**
  33191. * Lambda returning the list of potentially intersecting sub meshes.
  33192. */
  33193. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33194. /**
  33195. * Lambda returning the list of potentially colliding sub meshes.
  33196. */
  33197. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33198. private _activeMeshesFrozen;
  33199. /**
  33200. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33201. * @returns the current scene
  33202. */
  33203. freezeActiveMeshes(): Scene;
  33204. /**
  33205. * Use this function to restart evaluating active meshes on every frame
  33206. * @returns the current scene
  33207. */
  33208. unfreezeActiveMeshes(): Scene;
  33209. private _evaluateActiveMeshes;
  33210. private _activeMesh;
  33211. /**
  33212. * Update the transform matrix to update from the current active camera
  33213. * @param force defines a boolean used to force the update even if cache is up to date
  33214. */
  33215. updateTransformMatrix(force?: boolean): void;
  33216. private _bindFrameBuffer;
  33217. /** @hidden */
  33218. _allowPostProcessClearColor: boolean;
  33219. /** @hidden */
  33220. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33221. private _processSubCameras;
  33222. private _checkIntersections;
  33223. /** @hidden */
  33224. _advancePhysicsEngineStep(step: number): void;
  33225. /**
  33226. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33227. */
  33228. getDeterministicFrameTime: () => number;
  33229. /** @hidden */
  33230. _animate(): void;
  33231. /**
  33232. * Render the scene
  33233. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33234. */
  33235. render(updateCameras?: boolean): void;
  33236. /**
  33237. * Freeze all materials
  33238. * A frozen material will not be updatable but should be faster to render
  33239. */
  33240. freezeMaterials(): void;
  33241. /**
  33242. * Unfreeze all materials
  33243. * A frozen material will not be updatable but should be faster to render
  33244. */
  33245. unfreezeMaterials(): void;
  33246. /**
  33247. * Releases all held ressources
  33248. */
  33249. dispose(): void;
  33250. /**
  33251. * Gets if the scene is already disposed
  33252. */
  33253. readonly isDisposed: boolean;
  33254. /**
  33255. * Call this function to reduce memory footprint of the scene.
  33256. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33257. */
  33258. clearCachedVertexData(): void;
  33259. /**
  33260. * This function will remove the local cached buffer data from texture.
  33261. * It will save memory but will prevent the texture from being rebuilt
  33262. */
  33263. cleanCachedTextureBuffer(): void;
  33264. /**
  33265. * Get the world extend vectors with an optional filter
  33266. *
  33267. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33268. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33269. */
  33270. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33271. min: Vector3;
  33272. max: Vector3;
  33273. };
  33274. /**
  33275. * Creates a ray that can be used to pick in the scene
  33276. * @param x defines the x coordinate of the origin (on-screen)
  33277. * @param y defines the y coordinate of the origin (on-screen)
  33278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33279. * @param camera defines the camera to use for the picking
  33280. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33281. * @returns a Ray
  33282. */
  33283. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33284. /**
  33285. * Creates a ray that can be used to pick in the scene
  33286. * @param x defines the x coordinate of the origin (on-screen)
  33287. * @param y defines the y coordinate of the origin (on-screen)
  33288. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33289. * @param result defines the ray where to store the picking ray
  33290. * @param camera defines the camera to use for the picking
  33291. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33292. * @returns the current scene
  33293. */
  33294. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33295. /**
  33296. * Creates a ray that can be used to pick in the scene
  33297. * @param x defines the x coordinate of the origin (on-screen)
  33298. * @param y defines the y coordinate of the origin (on-screen)
  33299. * @param camera defines the camera to use for the picking
  33300. * @returns a Ray
  33301. */
  33302. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33303. /**
  33304. * Creates a ray that can be used to pick in the scene
  33305. * @param x defines the x coordinate of the origin (on-screen)
  33306. * @param y defines the y coordinate of the origin (on-screen)
  33307. * @param result defines the ray where to store the picking ray
  33308. * @param camera defines the camera to use for the picking
  33309. * @returns the current scene
  33310. */
  33311. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33312. /** Launch a ray to try to pick a mesh in the scene
  33313. * @param x position on screen
  33314. * @param y position on screen
  33315. * @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
  33316. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33317. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33319. * @returns a PickingInfo
  33320. */
  33321. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33322. /** Use the given ray to pick a mesh in the scene
  33323. * @param ray The ray to use to pick meshes
  33324. * @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
  33325. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33326. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33327. * @returns a PickingInfo
  33328. */
  33329. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33330. /**
  33331. * Launch a ray to try to pick a mesh in the scene
  33332. * @param x X position on screen
  33333. * @param y Y position on screen
  33334. * @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
  33335. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33336. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33337. * @returns an array of PickingInfo
  33338. */
  33339. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33340. /**
  33341. * Launch a ray to try to pick a mesh in the scene
  33342. * @param ray Ray to use
  33343. * @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
  33344. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33345. * @returns an array of PickingInfo
  33346. */
  33347. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33348. /**
  33349. * Force the value of meshUnderPointer
  33350. * @param mesh defines the mesh to use
  33351. */
  33352. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33353. /**
  33354. * Gets the mesh under the pointer
  33355. * @returns a Mesh or null if no mesh is under the pointer
  33356. */
  33357. getPointerOverMesh(): Nullable<AbstractMesh>;
  33358. /** @hidden */
  33359. _rebuildGeometries(): void;
  33360. /** @hidden */
  33361. _rebuildTextures(): void;
  33362. private _getByTags;
  33363. /**
  33364. * Get a list of meshes by tags
  33365. * @param tagsQuery defines the tags query to use
  33366. * @param forEach defines a predicate used to filter results
  33367. * @returns an array of Mesh
  33368. */
  33369. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33370. /**
  33371. * Get a list of cameras by tags
  33372. * @param tagsQuery defines the tags query to use
  33373. * @param forEach defines a predicate used to filter results
  33374. * @returns an array of Camera
  33375. */
  33376. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33377. /**
  33378. * Get a list of lights by tags
  33379. * @param tagsQuery defines the tags query to use
  33380. * @param forEach defines a predicate used to filter results
  33381. * @returns an array of Light
  33382. */
  33383. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33384. /**
  33385. * Get a list of materials by tags
  33386. * @param tagsQuery defines the tags query to use
  33387. * @param forEach defines a predicate used to filter results
  33388. * @returns an array of Material
  33389. */
  33390. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33391. /**
  33392. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33393. * This allowed control for front to back rendering or reversly depending of the special needs.
  33394. *
  33395. * @param renderingGroupId The rendering group id corresponding to its index
  33396. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33397. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33398. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33399. */
  33400. 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;
  33401. /**
  33402. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33403. *
  33404. * @param renderingGroupId The rendering group id corresponding to its index
  33405. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33406. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33407. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33408. */
  33409. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33410. /**
  33411. * Gets the current auto clear configuration for one rendering group of the rendering
  33412. * manager.
  33413. * @param index the rendering group index to get the information for
  33414. * @returns The auto clear setup for the requested rendering group
  33415. */
  33416. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33417. private _blockMaterialDirtyMechanism;
  33418. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33419. blockMaterialDirtyMechanism: boolean;
  33420. /**
  33421. * Will flag all materials as dirty to trigger new shader compilation
  33422. * @param flag defines the flag used to specify which material part must be marked as dirty
  33423. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33424. */
  33425. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33426. /** @hidden */
  33427. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33428. /** @hidden */
  33429. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33430. }
  33431. }
  33432. declare module BABYLON {
  33433. /**
  33434. * Set of assets to keep when moving a scene into an asset container.
  33435. */
  33436. export class KeepAssets extends AbstractScene {
  33437. }
  33438. /**
  33439. * Container with a set of assets that can be added or removed from a scene.
  33440. */
  33441. export class AssetContainer extends AbstractScene {
  33442. /**
  33443. * The scene the AssetContainer belongs to.
  33444. */
  33445. scene: Scene;
  33446. /**
  33447. * Instantiates an AssetContainer.
  33448. * @param scene The scene the AssetContainer belongs to.
  33449. */
  33450. constructor(scene: Scene);
  33451. /**
  33452. * Adds all the assets from the container to the scene.
  33453. */
  33454. addAllToScene(): void;
  33455. /**
  33456. * Removes all the assets in the container from the scene
  33457. */
  33458. removeAllFromScene(): void;
  33459. /**
  33460. * Disposes all the assets in the container
  33461. */
  33462. dispose(): void;
  33463. private _moveAssets;
  33464. /**
  33465. * Removes all the assets contained in the scene and adds them to the container.
  33466. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33467. */
  33468. moveAllFromScene(keepAssets?: KeepAssets): void;
  33469. /**
  33470. * 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.
  33471. * @returns the root mesh
  33472. */
  33473. createRootMesh(): Mesh;
  33474. }
  33475. }
  33476. declare module BABYLON {
  33477. /**
  33478. * Defines how the parser contract is defined.
  33479. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33480. */
  33481. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33482. /**
  33483. * Defines how the individual parser contract is defined.
  33484. * These parser can parse an individual asset
  33485. */
  33486. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33487. /**
  33488. * Base class of the scene acting as a container for the different elements composing a scene.
  33489. * This class is dynamically extended by the different components of the scene increasing
  33490. * flexibility and reducing coupling
  33491. */
  33492. export abstract class AbstractScene {
  33493. /**
  33494. * Stores the list of available parsers in the application.
  33495. */
  33496. private static _BabylonFileParsers;
  33497. /**
  33498. * Stores the list of available individual parsers in the application.
  33499. */
  33500. private static _IndividualBabylonFileParsers;
  33501. /**
  33502. * Adds a parser in the list of available ones
  33503. * @param name Defines the name of the parser
  33504. * @param parser Defines the parser to add
  33505. */
  33506. static AddParser(name: string, parser: BabylonFileParser): void;
  33507. /**
  33508. * Gets a general parser from the list of avaialble ones
  33509. * @param name Defines the name of the parser
  33510. * @returns the requested parser or null
  33511. */
  33512. static GetParser(name: string): Nullable<BabylonFileParser>;
  33513. /**
  33514. * Adds n individual parser in the list of available ones
  33515. * @param name Defines the name of the parser
  33516. * @param parser Defines the parser to add
  33517. */
  33518. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33519. /**
  33520. * Gets an individual parser from the list of avaialble ones
  33521. * @param name Defines the name of the parser
  33522. * @returns the requested parser or null
  33523. */
  33524. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33525. /**
  33526. * Parser json data and populate both a scene and its associated container object
  33527. * @param jsonData Defines the data to parse
  33528. * @param scene Defines the scene to parse the data for
  33529. * @param container Defines the container attached to the parsing sequence
  33530. * @param rootUrl Defines the root url of the data
  33531. */
  33532. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33533. /**
  33534. * Gets the list of root nodes (ie. nodes with no parent)
  33535. */
  33536. rootNodes: Node[];
  33537. /** All of the cameras added to this scene
  33538. * @see http://doc.babylonjs.com/babylon101/cameras
  33539. */
  33540. cameras: Camera[];
  33541. /**
  33542. * All of the lights added to this scene
  33543. * @see http://doc.babylonjs.com/babylon101/lights
  33544. */
  33545. lights: Light[];
  33546. /**
  33547. * All of the (abstract) meshes added to this scene
  33548. */
  33549. meshes: AbstractMesh[];
  33550. /**
  33551. * The list of skeletons added to the scene
  33552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33553. */
  33554. skeletons: Skeleton[];
  33555. /**
  33556. * All of the particle systems added to this scene
  33557. * @see http://doc.babylonjs.com/babylon101/particles
  33558. */
  33559. particleSystems: IParticleSystem[];
  33560. /**
  33561. * Gets a list of Animations associated with the scene
  33562. */
  33563. animations: Animation[];
  33564. /**
  33565. * All of the animation groups added to this scene
  33566. * @see http://doc.babylonjs.com/how_to/group
  33567. */
  33568. animationGroups: AnimationGroup[];
  33569. /**
  33570. * All of the multi-materials added to this scene
  33571. * @see http://doc.babylonjs.com/how_to/multi_materials
  33572. */
  33573. multiMaterials: MultiMaterial[];
  33574. /**
  33575. * All of the materials added to this scene
  33576. * In the context of a Scene, it is not supposed to be modified manually.
  33577. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33578. * Note also that the order of the Material wihin the array is not significant and might change.
  33579. * @see http://doc.babylonjs.com/babylon101/materials
  33580. */
  33581. materials: Material[];
  33582. /**
  33583. * The list of morph target managers added to the scene
  33584. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33585. */
  33586. morphTargetManagers: MorphTargetManager[];
  33587. /**
  33588. * The list of geometries used in the scene.
  33589. */
  33590. geometries: Geometry[];
  33591. /**
  33592. * All of the tranform nodes added to this scene
  33593. * In the context of a Scene, it is not supposed to be modified manually.
  33594. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33595. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33596. * @see http://doc.babylonjs.com/how_to/transformnode
  33597. */
  33598. transformNodes: TransformNode[];
  33599. /**
  33600. * ActionManagers available on the scene.
  33601. */
  33602. actionManagers: AbstractActionManager[];
  33603. /**
  33604. * Textures to keep.
  33605. */
  33606. textures: BaseTexture[];
  33607. /**
  33608. * Environment texture for the scene
  33609. */
  33610. environmentTexture: Nullable<BaseTexture>;
  33611. }
  33612. }
  33613. declare module BABYLON {
  33614. /**
  33615. * Defines a sound that can be played in the application.
  33616. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33618. */
  33619. export class Sound {
  33620. /**
  33621. * The name of the sound in the scene.
  33622. */
  33623. name: string;
  33624. /**
  33625. * Does the sound autoplay once loaded.
  33626. */
  33627. autoplay: boolean;
  33628. /**
  33629. * Does the sound loop after it finishes playing once.
  33630. */
  33631. loop: boolean;
  33632. /**
  33633. * Does the sound use a custom attenuation curve to simulate the falloff
  33634. * happening when the source gets further away from the camera.
  33635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33636. */
  33637. useCustomAttenuation: boolean;
  33638. /**
  33639. * The sound track id this sound belongs to.
  33640. */
  33641. soundTrackId: number;
  33642. /**
  33643. * Is this sound currently played.
  33644. */
  33645. isPlaying: boolean;
  33646. /**
  33647. * Is this sound currently paused.
  33648. */
  33649. isPaused: boolean;
  33650. /**
  33651. * Does this sound enables spatial sound.
  33652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33653. */
  33654. spatialSound: boolean;
  33655. /**
  33656. * Define the reference distance the sound should be heard perfectly.
  33657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33658. */
  33659. refDistance: number;
  33660. /**
  33661. * Define the roll off factor of spatial sounds.
  33662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33663. */
  33664. rolloffFactor: number;
  33665. /**
  33666. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33668. */
  33669. maxDistance: number;
  33670. /**
  33671. * Define the distance attenuation model the sound will follow.
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33673. */
  33674. distanceModel: string;
  33675. /**
  33676. * @hidden
  33677. * Back Compat
  33678. **/
  33679. onended: () => any;
  33680. /**
  33681. * Observable event when the current playing sound finishes.
  33682. */
  33683. onEndedObservable: Observable<Sound>;
  33684. private _panningModel;
  33685. private _playbackRate;
  33686. private _streaming;
  33687. private _startTime;
  33688. private _startOffset;
  33689. private _position;
  33690. /** @hidden */
  33691. _positionInEmitterSpace: boolean;
  33692. private _localDirection;
  33693. private _volume;
  33694. private _isReadyToPlay;
  33695. private _isDirectional;
  33696. private _readyToPlayCallback;
  33697. private _audioBuffer;
  33698. private _soundSource;
  33699. private _streamingSource;
  33700. private _soundPanner;
  33701. private _soundGain;
  33702. private _inputAudioNode;
  33703. private _outputAudioNode;
  33704. private _coneInnerAngle;
  33705. private _coneOuterAngle;
  33706. private _coneOuterGain;
  33707. private _scene;
  33708. private _connectedTransformNode;
  33709. private _customAttenuationFunction;
  33710. private _registerFunc;
  33711. private _isOutputConnected;
  33712. private _htmlAudioElement;
  33713. private _urlType;
  33714. /** @hidden */
  33715. static _SceneComponentInitialization: (scene: Scene) => void;
  33716. /**
  33717. * Create a sound and attach it to a scene
  33718. * @param name Name of your sound
  33719. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33720. * @param scene defines the scene the sound belongs to
  33721. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33722. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33723. */
  33724. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33725. /**
  33726. * Release the sound and its associated resources
  33727. */
  33728. dispose(): void;
  33729. /**
  33730. * Gets if the sounds is ready to be played or not.
  33731. * @returns true if ready, otherwise false
  33732. */
  33733. isReady(): boolean;
  33734. private _soundLoaded;
  33735. /**
  33736. * Sets the data of the sound from an audiobuffer
  33737. * @param audioBuffer The audioBuffer containing the data
  33738. */
  33739. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33740. /**
  33741. * Updates the current sounds options such as maxdistance, loop...
  33742. * @param options A JSON object containing values named as the object properties
  33743. */
  33744. updateOptions(options: any): void;
  33745. private _createSpatialParameters;
  33746. private _updateSpatialParameters;
  33747. /**
  33748. * Switch the panning model to HRTF:
  33749. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33751. */
  33752. switchPanningModelToHRTF(): void;
  33753. /**
  33754. * Switch the panning model to Equal Power:
  33755. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33757. */
  33758. switchPanningModelToEqualPower(): void;
  33759. private _switchPanningModel;
  33760. /**
  33761. * Connect this sound to a sound track audio node like gain...
  33762. * @param soundTrackAudioNode the sound track audio node to connect to
  33763. */
  33764. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33765. /**
  33766. * Transform this sound into a directional source
  33767. * @param coneInnerAngle Size of the inner cone in degree
  33768. * @param coneOuterAngle Size of the outer cone in degree
  33769. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33770. */
  33771. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33772. /**
  33773. * Gets or sets the inner angle for the directional cone.
  33774. */
  33775. /**
  33776. * Gets or sets the inner angle for the directional cone.
  33777. */
  33778. directionalConeInnerAngle: number;
  33779. /**
  33780. * Gets or sets the outer angle for the directional cone.
  33781. */
  33782. /**
  33783. * Gets or sets the outer angle for the directional cone.
  33784. */
  33785. directionalConeOuterAngle: number;
  33786. /**
  33787. * Sets the position of the emitter if spatial sound is enabled
  33788. * @param newPosition Defines the new posisiton
  33789. */
  33790. setPosition(newPosition: Vector3): void;
  33791. /**
  33792. * Sets the local direction of the emitter if spatial sound is enabled
  33793. * @param newLocalDirection Defines the new local direction
  33794. */
  33795. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33796. private _updateDirection;
  33797. /** @hidden */
  33798. updateDistanceFromListener(): void;
  33799. /**
  33800. * Sets a new custom attenuation function for the sound.
  33801. * @param callback Defines the function used for the attenuation
  33802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33803. */
  33804. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33805. /**
  33806. * Play the sound
  33807. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33808. * @param offset (optional) Start the sound setting it at a specific time
  33809. */
  33810. play(time?: number, offset?: number): void;
  33811. private _onended;
  33812. /**
  33813. * Stop the sound
  33814. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33815. */
  33816. stop(time?: number): void;
  33817. /**
  33818. * Put the sound in pause
  33819. */
  33820. pause(): void;
  33821. /**
  33822. * Sets a dedicated volume for this sounds
  33823. * @param newVolume Define the new volume of the sound
  33824. * @param time Define in how long the sound should be at this value
  33825. */
  33826. setVolume(newVolume: number, time?: number): void;
  33827. /**
  33828. * Set the sound play back rate
  33829. * @param newPlaybackRate Define the playback rate the sound should be played at
  33830. */
  33831. setPlaybackRate(newPlaybackRate: number): void;
  33832. /**
  33833. * Gets the volume of the sound.
  33834. * @returns the volume of the sound
  33835. */
  33836. getVolume(): number;
  33837. /**
  33838. * Attach the sound to a dedicated mesh
  33839. * @param transformNode The transform node to connect the sound with
  33840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33841. */
  33842. attachToMesh(transformNode: TransformNode): void;
  33843. /**
  33844. * Detach the sound from the previously attached mesh
  33845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33846. */
  33847. detachFromMesh(): void;
  33848. private _onRegisterAfterWorldMatrixUpdate;
  33849. /**
  33850. * Clone the current sound in the scene.
  33851. * @returns the new sound clone
  33852. */
  33853. clone(): Nullable<Sound>;
  33854. /**
  33855. * Gets the current underlying audio buffer containing the data
  33856. * @returns the audio buffer
  33857. */
  33858. getAudioBuffer(): Nullable<AudioBuffer>;
  33859. /**
  33860. * Serializes the Sound in a JSON representation
  33861. * @returns the JSON representation of the sound
  33862. */
  33863. serialize(): any;
  33864. /**
  33865. * Parse a JSON representation of a sound to innstantiate in a given scene
  33866. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33867. * @param scene Define the scene the new parsed sound should be created in
  33868. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33869. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33870. * @returns the newly parsed sound
  33871. */
  33872. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33873. }
  33874. }
  33875. declare module BABYLON {
  33876. /**
  33877. * This defines an action helpful to play a defined sound on a triggered action.
  33878. */
  33879. export class PlaySoundAction extends Action {
  33880. private _sound;
  33881. /**
  33882. * Instantiate the action
  33883. * @param triggerOptions defines the trigger options
  33884. * @param sound defines the sound to play
  33885. * @param condition defines the trigger related conditions
  33886. */
  33887. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33888. /** @hidden */
  33889. _prepare(): void;
  33890. /**
  33891. * Execute the action and play the sound.
  33892. */
  33893. execute(): void;
  33894. /**
  33895. * Serializes the actions and its related information.
  33896. * @param parent defines the object to serialize in
  33897. * @returns the serialized object
  33898. */
  33899. serialize(parent: any): any;
  33900. }
  33901. /**
  33902. * This defines an action helpful to stop a defined sound on a triggered action.
  33903. */
  33904. export class StopSoundAction extends Action {
  33905. private _sound;
  33906. /**
  33907. * Instantiate the action
  33908. * @param triggerOptions defines the trigger options
  33909. * @param sound defines the sound to stop
  33910. * @param condition defines the trigger related conditions
  33911. */
  33912. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33913. /** @hidden */
  33914. _prepare(): void;
  33915. /**
  33916. * Execute the action and stop the sound.
  33917. */
  33918. execute(): void;
  33919. /**
  33920. * Serializes the actions and its related information.
  33921. * @param parent defines the object to serialize in
  33922. * @returns the serialized object
  33923. */
  33924. serialize(parent: any): any;
  33925. }
  33926. }
  33927. declare module BABYLON {
  33928. /**
  33929. * This defines an action responsible to change the value of a property
  33930. * by interpolating between its current value and the newly set one once triggered.
  33931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33932. */
  33933. export class InterpolateValueAction extends Action {
  33934. /**
  33935. * Defines the path of the property where the value should be interpolated
  33936. */
  33937. propertyPath: string;
  33938. /**
  33939. * Defines the target value at the end of the interpolation.
  33940. */
  33941. value: any;
  33942. /**
  33943. * Defines the time it will take for the property to interpolate to the value.
  33944. */
  33945. duration: number;
  33946. /**
  33947. * Defines if the other scene animations should be stopped when the action has been triggered
  33948. */
  33949. stopOtherAnimations?: boolean;
  33950. /**
  33951. * Defines a callback raised once the interpolation animation has been done.
  33952. */
  33953. onInterpolationDone?: () => void;
  33954. /**
  33955. * Observable triggered once the interpolation animation has been done.
  33956. */
  33957. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33958. private _target;
  33959. private _effectiveTarget;
  33960. private _property;
  33961. /**
  33962. * Instantiate the action
  33963. * @param triggerOptions defines the trigger options
  33964. * @param target defines the object containing the value to interpolate
  33965. * @param propertyPath defines the path to the property in the target object
  33966. * @param value defines the target value at the end of the interpolation
  33967. * @param duration deines the time it will take for the property to interpolate to the value.
  33968. * @param condition defines the trigger related conditions
  33969. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33970. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33971. */
  33972. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33973. /** @hidden */
  33974. _prepare(): void;
  33975. /**
  33976. * Execute the action starts the value interpolation.
  33977. */
  33978. execute(): void;
  33979. /**
  33980. * Serializes the actions and its related information.
  33981. * @param parent defines the object to serialize in
  33982. * @returns the serialized object
  33983. */
  33984. serialize(parent: any): any;
  33985. }
  33986. }
  33987. declare module BABYLON {
  33988. /**
  33989. * Options allowed during the creation of a sound track.
  33990. */
  33991. export interface ISoundTrackOptions {
  33992. /**
  33993. * The volume the sound track should take during creation
  33994. */
  33995. volume?: number;
  33996. /**
  33997. * Define if the sound track is the main sound track of the scene
  33998. */
  33999. mainTrack?: boolean;
  34000. }
  34001. /**
  34002. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34003. * It will be also used in a future release to apply effects on a specific track.
  34004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34005. */
  34006. export class SoundTrack {
  34007. /**
  34008. * The unique identifier of the sound track in the scene.
  34009. */
  34010. id: number;
  34011. /**
  34012. * The list of sounds included in the sound track.
  34013. */
  34014. soundCollection: Array<Sound>;
  34015. private _outputAudioNode;
  34016. private _scene;
  34017. private _isMainTrack;
  34018. private _connectedAnalyser;
  34019. private _options;
  34020. private _isInitialized;
  34021. /**
  34022. * Creates a new sound track.
  34023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34024. * @param scene Define the scene the sound track belongs to
  34025. * @param options
  34026. */
  34027. constructor(scene: Scene, options?: ISoundTrackOptions);
  34028. private _initializeSoundTrackAudioGraph;
  34029. /**
  34030. * Release the sound track and its associated resources
  34031. */
  34032. dispose(): void;
  34033. /**
  34034. * Adds a sound to this sound track
  34035. * @param sound define the cound to add
  34036. * @ignoreNaming
  34037. */
  34038. AddSound(sound: Sound): void;
  34039. /**
  34040. * Removes a sound to this sound track
  34041. * @param sound define the cound to remove
  34042. * @ignoreNaming
  34043. */
  34044. RemoveSound(sound: Sound): void;
  34045. /**
  34046. * Set a global volume for the full sound track.
  34047. * @param newVolume Define the new volume of the sound track
  34048. */
  34049. setVolume(newVolume: number): void;
  34050. /**
  34051. * Switch the panning model to HRTF:
  34052. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34054. */
  34055. switchPanningModelToHRTF(): void;
  34056. /**
  34057. * Switch the panning model to Equal Power:
  34058. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34060. */
  34061. switchPanningModelToEqualPower(): void;
  34062. /**
  34063. * Connect the sound track to an audio analyser allowing some amazing
  34064. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34066. * @param analyser The analyser to connect to the engine
  34067. */
  34068. connectToAnalyser(analyser: Analyser): void;
  34069. }
  34070. }
  34071. declare module BABYLON {
  34072. interface AbstractScene {
  34073. /**
  34074. * The list of sounds used in the scene.
  34075. */
  34076. sounds: Nullable<Array<Sound>>;
  34077. }
  34078. interface Scene {
  34079. /**
  34080. * @hidden
  34081. * Backing field
  34082. */
  34083. _mainSoundTrack: SoundTrack;
  34084. /**
  34085. * The main sound track played by the scene.
  34086. * It cotains your primary collection of sounds.
  34087. */
  34088. mainSoundTrack: SoundTrack;
  34089. /**
  34090. * The list of sound tracks added to the scene
  34091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34092. */
  34093. soundTracks: Nullable<Array<SoundTrack>>;
  34094. /**
  34095. * Gets a sound using a given name
  34096. * @param name defines the name to search for
  34097. * @return the found sound or null if not found at all.
  34098. */
  34099. getSoundByName(name: string): Nullable<Sound>;
  34100. /**
  34101. * Gets or sets if audio support is enabled
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34103. */
  34104. audioEnabled: boolean;
  34105. /**
  34106. * Gets or sets if audio will be output to headphones
  34107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34108. */
  34109. headphone: boolean;
  34110. }
  34111. /**
  34112. * Defines the sound scene component responsible to manage any sounds
  34113. * in a given scene.
  34114. */
  34115. export class AudioSceneComponent implements ISceneSerializableComponent {
  34116. /**
  34117. * The component name helpfull to identify the component in the list of scene components.
  34118. */
  34119. readonly name: string;
  34120. /**
  34121. * The scene the component belongs to.
  34122. */
  34123. scene: Scene;
  34124. private _audioEnabled;
  34125. /**
  34126. * Gets whether audio is enabled or not.
  34127. * Please use related enable/disable method to switch state.
  34128. */
  34129. readonly audioEnabled: boolean;
  34130. private _headphone;
  34131. /**
  34132. * Gets whether audio is outputing to headphone or not.
  34133. * Please use the according Switch methods to change output.
  34134. */
  34135. readonly headphone: boolean;
  34136. /**
  34137. * Creates a new instance of the component for the given scene
  34138. * @param scene Defines the scene to register the component in
  34139. */
  34140. constructor(scene: Scene);
  34141. /**
  34142. * Registers the component in a given scene
  34143. */
  34144. register(): void;
  34145. /**
  34146. * Rebuilds the elements related to this component in case of
  34147. * context lost for instance.
  34148. */
  34149. rebuild(): void;
  34150. /**
  34151. * Serializes the component data to the specified json object
  34152. * @param serializationObject The object to serialize to
  34153. */
  34154. serialize(serializationObject: any): void;
  34155. /**
  34156. * Adds all the element from the container to the scene
  34157. * @param container the container holding the elements
  34158. */
  34159. addFromContainer(container: AbstractScene): void;
  34160. /**
  34161. * Removes all the elements in the container from the scene
  34162. * @param container contains the elements to remove
  34163. * @param dispose if the removed element should be disposed (default: false)
  34164. */
  34165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34166. /**
  34167. * Disposes the component and the associated ressources.
  34168. */
  34169. dispose(): void;
  34170. /**
  34171. * Disables audio in the associated scene.
  34172. */
  34173. disableAudio(): void;
  34174. /**
  34175. * Enables audio in the associated scene.
  34176. */
  34177. enableAudio(): void;
  34178. /**
  34179. * Switch audio to headphone output.
  34180. */
  34181. switchAudioModeForHeadphones(): void;
  34182. /**
  34183. * Switch audio to normal speakers.
  34184. */
  34185. switchAudioModeForNormalSpeakers(): void;
  34186. private _afterRender;
  34187. }
  34188. }
  34189. declare module BABYLON {
  34190. /**
  34191. * Wraps one or more Sound objects and selects one with random weight for playback.
  34192. */
  34193. export class WeightedSound {
  34194. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34195. loop: boolean;
  34196. private _coneInnerAngle;
  34197. private _coneOuterAngle;
  34198. private _volume;
  34199. /** A Sound is currently playing. */
  34200. isPlaying: boolean;
  34201. /** A Sound is currently paused. */
  34202. isPaused: boolean;
  34203. private _sounds;
  34204. private _weights;
  34205. private _currentIndex?;
  34206. /**
  34207. * Creates a new WeightedSound from the list of sounds given.
  34208. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34209. * @param sounds Array of Sounds that will be selected from.
  34210. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34211. */
  34212. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34213. /**
  34214. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34215. */
  34216. /**
  34217. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34218. */
  34219. directionalConeInnerAngle: number;
  34220. /**
  34221. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34222. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34223. */
  34224. /**
  34225. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34226. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34227. */
  34228. directionalConeOuterAngle: number;
  34229. /**
  34230. * Playback volume.
  34231. */
  34232. /**
  34233. * Playback volume.
  34234. */
  34235. volume: number;
  34236. private _onended;
  34237. /**
  34238. * Suspend playback
  34239. */
  34240. pause(): void;
  34241. /**
  34242. * Stop playback
  34243. */
  34244. stop(): void;
  34245. /**
  34246. * Start playback.
  34247. * @param startOffset Position the clip head at a specific time in seconds.
  34248. */
  34249. play(startOffset?: number): void;
  34250. }
  34251. }
  34252. declare module BABYLON {
  34253. /**
  34254. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34256. */
  34257. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34258. /**
  34259. * Gets the name of the behavior.
  34260. */
  34261. readonly name: string;
  34262. /**
  34263. * The easing function used by animations
  34264. */
  34265. static EasingFunction: BackEase;
  34266. /**
  34267. * The easing mode used by animations
  34268. */
  34269. static EasingMode: number;
  34270. /**
  34271. * The duration of the animation, in milliseconds
  34272. */
  34273. transitionDuration: number;
  34274. /**
  34275. * Length of the distance animated by the transition when lower radius is reached
  34276. */
  34277. lowerRadiusTransitionRange: number;
  34278. /**
  34279. * Length of the distance animated by the transition when upper radius is reached
  34280. */
  34281. upperRadiusTransitionRange: number;
  34282. private _autoTransitionRange;
  34283. /**
  34284. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34285. */
  34286. /**
  34287. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34288. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34289. */
  34290. autoTransitionRange: boolean;
  34291. private _attachedCamera;
  34292. private _onAfterCheckInputsObserver;
  34293. private _onMeshTargetChangedObserver;
  34294. /**
  34295. * Initializes the behavior.
  34296. */
  34297. init(): void;
  34298. /**
  34299. * Attaches the behavior to its arc rotate camera.
  34300. * @param camera Defines the camera to attach the behavior to
  34301. */
  34302. attach(camera: ArcRotateCamera): void;
  34303. /**
  34304. * Detaches the behavior from its current arc rotate camera.
  34305. */
  34306. detach(): void;
  34307. private _radiusIsAnimating;
  34308. private _radiusBounceTransition;
  34309. private _animatables;
  34310. private _cachedWheelPrecision;
  34311. /**
  34312. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34313. * @param radiusLimit The limit to check against.
  34314. * @return Bool to indicate if at limit.
  34315. */
  34316. private _isRadiusAtLimit;
  34317. /**
  34318. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34319. * @param radiusDelta The delta by which to animate to. Can be negative.
  34320. */
  34321. private _applyBoundRadiusAnimation;
  34322. /**
  34323. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34324. */
  34325. protected _clearAnimationLocks(): void;
  34326. /**
  34327. * Stops and removes all animations that have been applied to the camera
  34328. */
  34329. stopAllAnimations(): void;
  34330. }
  34331. }
  34332. declare module BABYLON {
  34333. /**
  34334. * 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.
  34335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34336. */
  34337. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34338. /**
  34339. * Gets the name of the behavior.
  34340. */
  34341. readonly name: string;
  34342. private _mode;
  34343. private _radiusScale;
  34344. private _positionScale;
  34345. private _defaultElevation;
  34346. private _elevationReturnTime;
  34347. private _elevationReturnWaitTime;
  34348. private _zoomStopsAnimation;
  34349. private _framingTime;
  34350. /**
  34351. * The easing function used by animations
  34352. */
  34353. static EasingFunction: ExponentialEase;
  34354. /**
  34355. * The easing mode used by animations
  34356. */
  34357. static EasingMode: number;
  34358. /**
  34359. * Sets the current mode used by the behavior
  34360. */
  34361. /**
  34362. * Gets current mode used by the behavior.
  34363. */
  34364. mode: number;
  34365. /**
  34366. * Sets the scale applied to the radius (1 by default)
  34367. */
  34368. /**
  34369. * Gets the scale applied to the radius
  34370. */
  34371. radiusScale: number;
  34372. /**
  34373. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34374. */
  34375. /**
  34376. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34377. */
  34378. positionScale: number;
  34379. /**
  34380. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34381. * behaviour is triggered, in radians.
  34382. */
  34383. /**
  34384. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34385. * behaviour is triggered, in radians.
  34386. */
  34387. defaultElevation: number;
  34388. /**
  34389. * Sets the time (in milliseconds) taken to return to the default beta position.
  34390. * Negative value indicates camera should not return to default.
  34391. */
  34392. /**
  34393. * Gets the time (in milliseconds) taken to return to the default beta position.
  34394. * Negative value indicates camera should not return to default.
  34395. */
  34396. elevationReturnTime: number;
  34397. /**
  34398. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34399. */
  34400. /**
  34401. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34402. */
  34403. elevationReturnWaitTime: number;
  34404. /**
  34405. * Sets the flag that indicates if user zooming should stop animation.
  34406. */
  34407. /**
  34408. * Gets the flag that indicates if user zooming should stop animation.
  34409. */
  34410. zoomStopsAnimation: boolean;
  34411. /**
  34412. * Sets the transition time when framing the mesh, in milliseconds
  34413. */
  34414. /**
  34415. * Gets the transition time when framing the mesh, in milliseconds
  34416. */
  34417. framingTime: number;
  34418. /**
  34419. * Define if the behavior should automatically change the configured
  34420. * camera limits and sensibilities.
  34421. */
  34422. autoCorrectCameraLimitsAndSensibility: boolean;
  34423. private _onPrePointerObservableObserver;
  34424. private _onAfterCheckInputsObserver;
  34425. private _onMeshTargetChangedObserver;
  34426. private _attachedCamera;
  34427. private _isPointerDown;
  34428. private _lastInteractionTime;
  34429. /**
  34430. * Initializes the behavior.
  34431. */
  34432. init(): void;
  34433. /**
  34434. * Attaches the behavior to its arc rotate camera.
  34435. * @param camera Defines the camera to attach the behavior to
  34436. */
  34437. attach(camera: ArcRotateCamera): void;
  34438. /**
  34439. * Detaches the behavior from its current arc rotate camera.
  34440. */
  34441. detach(): void;
  34442. private _animatables;
  34443. private _betaIsAnimating;
  34444. private _betaTransition;
  34445. private _radiusTransition;
  34446. private _vectorTransition;
  34447. /**
  34448. * Targets the given mesh and updates zoom level accordingly.
  34449. * @param mesh The mesh to target.
  34450. * @param radius Optional. If a cached radius position already exists, overrides default.
  34451. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34452. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34453. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34454. */
  34455. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34456. /**
  34457. * Targets the given mesh with its children and updates zoom level accordingly.
  34458. * @param mesh The mesh to target.
  34459. * @param radius Optional. If a cached radius position already exists, overrides default.
  34460. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34461. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34462. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34463. */
  34464. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34465. /**
  34466. * Targets the given meshes with their children and updates zoom level accordingly.
  34467. * @param meshes The mesh to target.
  34468. * @param radius Optional. If a cached radius position already exists, overrides default.
  34469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34472. */
  34473. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34474. /**
  34475. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34476. * @param minimumWorld Determines the smaller position of the bounding box extend
  34477. * @param maximumWorld Determines the bigger position of the bounding box extend
  34478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34480. */
  34481. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34482. /**
  34483. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34484. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34485. * frustum width.
  34486. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34487. * to fully enclose the mesh in the viewing frustum.
  34488. */
  34489. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34490. /**
  34491. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34492. * is automatically returned to its default position (expected to be above ground plane).
  34493. */
  34494. private _maintainCameraAboveGround;
  34495. /**
  34496. * Returns the frustum slope based on the canvas ratio and camera FOV
  34497. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34498. */
  34499. private _getFrustumSlope;
  34500. /**
  34501. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34502. */
  34503. private _clearAnimationLocks;
  34504. /**
  34505. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34506. */
  34507. private _applyUserInteraction;
  34508. /**
  34509. * Stops and removes all animations that have been applied to the camera
  34510. */
  34511. stopAllAnimations(): void;
  34512. /**
  34513. * Gets a value indicating if the user is moving the camera
  34514. */
  34515. readonly isUserIsMoving: boolean;
  34516. /**
  34517. * The camera can move all the way towards the mesh.
  34518. */
  34519. static IgnoreBoundsSizeMode: number;
  34520. /**
  34521. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34522. */
  34523. static FitFrustumSidesMode: number;
  34524. }
  34525. }
  34526. declare module BABYLON {
  34527. /**
  34528. * Base class for Camera Pointer Inputs.
  34529. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34530. * for example usage.
  34531. */
  34532. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34533. /**
  34534. * Defines the camera the input is attached to.
  34535. */
  34536. abstract camera: Camera;
  34537. /**
  34538. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34539. */
  34540. protected _altKey: boolean;
  34541. protected _ctrlKey: boolean;
  34542. protected _metaKey: boolean;
  34543. protected _shiftKey: boolean;
  34544. /**
  34545. * Which mouse buttons were pressed at time of last mouse event.
  34546. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34547. */
  34548. protected _buttonsPressed: number;
  34549. /**
  34550. * Defines the buttons associated with the input to handle camera move.
  34551. */
  34552. buttons: number[];
  34553. /**
  34554. * Attach the input controls to a specific dom element to get the input from.
  34555. * @param element Defines the element the controls should be listened from
  34556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34557. */
  34558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34559. /**
  34560. * Detach the current controls from the specified dom element.
  34561. * @param element Defines the element to stop listening the inputs from
  34562. */
  34563. detachControl(element: Nullable<HTMLElement>): void;
  34564. /**
  34565. * Gets the class name of the current input.
  34566. * @returns the class name
  34567. */
  34568. getClassName(): string;
  34569. /**
  34570. * Get the friendly name associated with the input class.
  34571. * @returns the input friendly name
  34572. */
  34573. getSimpleName(): string;
  34574. /**
  34575. * Called on pointer POINTERDOUBLETAP event.
  34576. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34577. */
  34578. protected onDoubleTap(type: string): void;
  34579. /**
  34580. * Called on pointer POINTERMOVE event if only a single touch is active.
  34581. * Override this method to provide functionality.
  34582. */
  34583. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34584. /**
  34585. * Called on pointer POINTERMOVE event if multiple touches are active.
  34586. * Override this method to provide functionality.
  34587. */
  34588. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34589. /**
  34590. * Called on JS contextmenu event.
  34591. * Override this method to provide functionality.
  34592. */
  34593. protected onContextMenu(evt: PointerEvent): void;
  34594. /**
  34595. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34596. * press.
  34597. * Override this method to provide functionality.
  34598. */
  34599. protected onButtonDown(evt: PointerEvent): void;
  34600. /**
  34601. * Called each time a new POINTERUP event occurs. Ie, for each button
  34602. * release.
  34603. * Override this method to provide functionality.
  34604. */
  34605. protected onButtonUp(evt: PointerEvent): void;
  34606. /**
  34607. * Called when window becomes inactive.
  34608. * Override this method to provide functionality.
  34609. */
  34610. protected onLostFocus(): void;
  34611. private _pointerInput;
  34612. private _observer;
  34613. private _onLostFocus;
  34614. private pointA;
  34615. private pointB;
  34616. }
  34617. }
  34618. declare module BABYLON {
  34619. /**
  34620. * Manage the pointers inputs to control an arc rotate camera.
  34621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34622. */
  34623. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34624. /**
  34625. * Defines the camera the input is attached to.
  34626. */
  34627. camera: ArcRotateCamera;
  34628. /**
  34629. * Gets the class name of the current input.
  34630. * @returns the class name
  34631. */
  34632. getClassName(): string;
  34633. /**
  34634. * Defines the buttons associated with the input to handle camera move.
  34635. */
  34636. buttons: number[];
  34637. /**
  34638. * Defines the pointer angular sensibility along the X axis or how fast is
  34639. * the camera rotating.
  34640. */
  34641. angularSensibilityX: number;
  34642. /**
  34643. * Defines the pointer angular sensibility along the Y axis or how fast is
  34644. * the camera rotating.
  34645. */
  34646. angularSensibilityY: number;
  34647. /**
  34648. * Defines the pointer pinch precision or how fast is the camera zooming.
  34649. */
  34650. pinchPrecision: number;
  34651. /**
  34652. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34653. * from 0.
  34654. * It defines the percentage of current camera.radius to use as delta when
  34655. * pinch zoom is used.
  34656. */
  34657. pinchDeltaPercentage: number;
  34658. /**
  34659. * Defines the pointer panning sensibility or how fast is the camera moving.
  34660. */
  34661. panningSensibility: number;
  34662. /**
  34663. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34664. */
  34665. multiTouchPanning: boolean;
  34666. /**
  34667. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34668. * zoom (pinch) through multitouch.
  34669. */
  34670. multiTouchPanAndZoom: boolean;
  34671. /**
  34672. * Revers pinch action direction.
  34673. */
  34674. pinchInwards: boolean;
  34675. private _isPanClick;
  34676. private _twoFingerActivityCount;
  34677. private _isPinching;
  34678. /**
  34679. * Called on pointer POINTERMOVE event if only a single touch is active.
  34680. */
  34681. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34682. /**
  34683. * Called on pointer POINTERDOUBLETAP event.
  34684. */
  34685. protected onDoubleTap(type: string): void;
  34686. /**
  34687. * Called on pointer POINTERMOVE event if multiple touches are active.
  34688. */
  34689. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34690. /**
  34691. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34692. * press.
  34693. */
  34694. protected onButtonDown(evt: PointerEvent): void;
  34695. /**
  34696. * Called each time a new POINTERUP event occurs. Ie, for each button
  34697. * release.
  34698. */
  34699. protected onButtonUp(evt: PointerEvent): void;
  34700. /**
  34701. * Called when window becomes inactive.
  34702. */
  34703. protected onLostFocus(): void;
  34704. }
  34705. }
  34706. declare module BABYLON {
  34707. /**
  34708. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34710. */
  34711. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34712. /**
  34713. * Defines the camera the input is attached to.
  34714. */
  34715. camera: ArcRotateCamera;
  34716. /**
  34717. * Defines the list of key codes associated with the up action (increase alpha)
  34718. */
  34719. keysUp: number[];
  34720. /**
  34721. * Defines the list of key codes associated with the down action (decrease alpha)
  34722. */
  34723. keysDown: number[];
  34724. /**
  34725. * Defines the list of key codes associated with the left action (increase beta)
  34726. */
  34727. keysLeft: number[];
  34728. /**
  34729. * Defines the list of key codes associated with the right action (decrease beta)
  34730. */
  34731. keysRight: number[];
  34732. /**
  34733. * Defines the list of key codes associated with the reset action.
  34734. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34735. */
  34736. keysReset: number[];
  34737. /**
  34738. * Defines the panning sensibility of the inputs.
  34739. * (How fast is the camera paning)
  34740. */
  34741. panningSensibility: number;
  34742. /**
  34743. * Defines the zooming sensibility of the inputs.
  34744. * (How fast is the camera zooming)
  34745. */
  34746. zoomingSensibility: number;
  34747. /**
  34748. * Defines wether maintaining the alt key down switch the movement mode from
  34749. * orientation to zoom.
  34750. */
  34751. useAltToZoom: boolean;
  34752. /**
  34753. * Rotation speed of the camera
  34754. */
  34755. angularSpeed: number;
  34756. private _keys;
  34757. private _ctrlPressed;
  34758. private _altPressed;
  34759. private _onCanvasBlurObserver;
  34760. private _onKeyboardObserver;
  34761. private _engine;
  34762. private _scene;
  34763. /**
  34764. * Attach the input controls to a specific dom element to get the input from.
  34765. * @param element Defines the element the controls should be listened from
  34766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34767. */
  34768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34769. /**
  34770. * Detach the current controls from the specified dom element.
  34771. * @param element Defines the element to stop listening the inputs from
  34772. */
  34773. detachControl(element: Nullable<HTMLElement>): void;
  34774. /**
  34775. * Update the current camera state depending on the inputs that have been used this frame.
  34776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34777. */
  34778. checkInputs(): void;
  34779. /**
  34780. * Gets the class name of the current intput.
  34781. * @returns the class name
  34782. */
  34783. getClassName(): string;
  34784. /**
  34785. * Get the friendly name associated with the input class.
  34786. * @returns the input friendly name
  34787. */
  34788. getSimpleName(): string;
  34789. }
  34790. }
  34791. declare module BABYLON {
  34792. /**
  34793. * Manage the mouse wheel inputs to control an arc rotate camera.
  34794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34795. */
  34796. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34797. /**
  34798. * Defines the camera the input is attached to.
  34799. */
  34800. camera: ArcRotateCamera;
  34801. /**
  34802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34803. */
  34804. wheelPrecision: number;
  34805. /**
  34806. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34807. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34808. */
  34809. wheelDeltaPercentage: number;
  34810. private _wheel;
  34811. private _observer;
  34812. /**
  34813. * Attach the input controls to a specific dom element to get the input from.
  34814. * @param element Defines the element the controls should be listened from
  34815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34816. */
  34817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34818. /**
  34819. * Detach the current controls from the specified dom element.
  34820. * @param element Defines the element to stop listening the inputs from
  34821. */
  34822. detachControl(element: Nullable<HTMLElement>): void;
  34823. /**
  34824. * Gets the class name of the current intput.
  34825. * @returns the class name
  34826. */
  34827. getClassName(): string;
  34828. /**
  34829. * Get the friendly name associated with the input class.
  34830. * @returns the input friendly name
  34831. */
  34832. getSimpleName(): string;
  34833. }
  34834. }
  34835. declare module BABYLON {
  34836. /**
  34837. * Default Inputs manager for the ArcRotateCamera.
  34838. * It groups all the default supported inputs for ease of use.
  34839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34840. */
  34841. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34842. /**
  34843. * Instantiates a new ArcRotateCameraInputsManager.
  34844. * @param camera Defines the camera the inputs belong to
  34845. */
  34846. constructor(camera: ArcRotateCamera);
  34847. /**
  34848. * Add mouse wheel input support to the input manager.
  34849. * @returns the current input manager
  34850. */
  34851. addMouseWheel(): ArcRotateCameraInputsManager;
  34852. /**
  34853. * Add pointers input support to the input manager.
  34854. * @returns the current input manager
  34855. */
  34856. addPointers(): ArcRotateCameraInputsManager;
  34857. /**
  34858. * Add keyboard input support to the input manager.
  34859. * @returns the current input manager
  34860. */
  34861. addKeyboard(): ArcRotateCameraInputsManager;
  34862. }
  34863. }
  34864. declare module BABYLON {
  34865. /**
  34866. * This represents an orbital type of camera.
  34867. *
  34868. * 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.
  34869. * 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.
  34870. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34871. */
  34872. export class ArcRotateCamera extends TargetCamera {
  34873. /**
  34874. * Defines the rotation angle of the camera along the longitudinal axis.
  34875. */
  34876. alpha: number;
  34877. /**
  34878. * Defines the rotation angle of the camera along the latitudinal axis.
  34879. */
  34880. beta: number;
  34881. /**
  34882. * Defines the radius of the camera from it s target point.
  34883. */
  34884. radius: number;
  34885. protected _target: Vector3;
  34886. protected _targetHost: Nullable<AbstractMesh>;
  34887. /**
  34888. * Defines the target point of the camera.
  34889. * The camera looks towards it form the radius distance.
  34890. */
  34891. target: Vector3;
  34892. /**
  34893. * Define the current local position of the camera in the scene
  34894. */
  34895. position: Vector3;
  34896. /**
  34897. * Current inertia value on the longitudinal axis.
  34898. * The bigger this number the longer it will take for the camera to stop.
  34899. */
  34900. inertialAlphaOffset: number;
  34901. /**
  34902. * Current inertia value on the latitudinal axis.
  34903. * The bigger this number the longer it will take for the camera to stop.
  34904. */
  34905. inertialBetaOffset: number;
  34906. /**
  34907. * Current inertia value on the radius axis.
  34908. * The bigger this number the longer it will take for the camera to stop.
  34909. */
  34910. inertialRadiusOffset: number;
  34911. /**
  34912. * Minimum allowed angle on the longitudinal axis.
  34913. * This can help limiting how the Camera is able to move in the scene.
  34914. */
  34915. lowerAlphaLimit: Nullable<number>;
  34916. /**
  34917. * Maximum allowed angle on the longitudinal axis.
  34918. * This can help limiting how the Camera is able to move in the scene.
  34919. */
  34920. upperAlphaLimit: Nullable<number>;
  34921. /**
  34922. * Minimum allowed angle on the latitudinal axis.
  34923. * This can help limiting how the Camera is able to move in the scene.
  34924. */
  34925. lowerBetaLimit: number;
  34926. /**
  34927. * Maximum allowed angle on the latitudinal axis.
  34928. * This can help limiting how the Camera is able to move in the scene.
  34929. */
  34930. upperBetaLimit: number;
  34931. /**
  34932. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34933. * This can help limiting how the Camera is able to move in the scene.
  34934. */
  34935. lowerRadiusLimit: Nullable<number>;
  34936. /**
  34937. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34938. * This can help limiting how the Camera is able to move in the scene.
  34939. */
  34940. upperRadiusLimit: Nullable<number>;
  34941. /**
  34942. * Defines the current inertia value used during panning of the camera along the X axis.
  34943. */
  34944. inertialPanningX: number;
  34945. /**
  34946. * Defines the current inertia value used during panning of the camera along the Y axis.
  34947. */
  34948. inertialPanningY: number;
  34949. /**
  34950. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34951. * Basically if your fingers moves away from more than this distance you will be considered
  34952. * in pinch mode.
  34953. */
  34954. pinchToPanMaxDistance: number;
  34955. /**
  34956. * Defines the maximum distance the camera can pan.
  34957. * This could help keeping the cammera always in your scene.
  34958. */
  34959. panningDistanceLimit: Nullable<number>;
  34960. /**
  34961. * Defines the target of the camera before paning.
  34962. */
  34963. panningOriginTarget: Vector3;
  34964. /**
  34965. * Defines the value of the inertia used during panning.
  34966. * 0 would mean stop inertia and one would mean no decelleration at all.
  34967. */
  34968. panningInertia: number;
  34969. /**
  34970. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34971. */
  34972. angularSensibilityX: number;
  34973. /**
  34974. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34975. */
  34976. angularSensibilityY: number;
  34977. /**
  34978. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34979. */
  34980. pinchPrecision: number;
  34981. /**
  34982. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34983. * It will be used instead of pinchDeltaPrecision if different from 0.
  34984. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34985. */
  34986. pinchDeltaPercentage: number;
  34987. /**
  34988. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34989. */
  34990. panningSensibility: number;
  34991. /**
  34992. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34993. */
  34994. keysUp: number[];
  34995. /**
  34996. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34997. */
  34998. keysDown: number[];
  34999. /**
  35000. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35001. */
  35002. keysLeft: number[];
  35003. /**
  35004. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35005. */
  35006. keysRight: number[];
  35007. /**
  35008. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35009. */
  35010. wheelPrecision: number;
  35011. /**
  35012. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35013. * It will be used instead of pinchDeltaPrecision if different from 0.
  35014. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35015. */
  35016. wheelDeltaPercentage: number;
  35017. /**
  35018. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35019. */
  35020. zoomOnFactor: number;
  35021. /**
  35022. * Defines a screen offset for the camera position.
  35023. */
  35024. targetScreenOffset: Vector2;
  35025. /**
  35026. * Allows the camera to be completely reversed.
  35027. * If false the camera can not arrive upside down.
  35028. */
  35029. allowUpsideDown: boolean;
  35030. /**
  35031. * Define if double tap/click is used to restore the previously saved state of the camera.
  35032. */
  35033. useInputToRestoreState: boolean;
  35034. /** @hidden */
  35035. _viewMatrix: Matrix;
  35036. /** @hidden */
  35037. _useCtrlForPanning: boolean;
  35038. /** @hidden */
  35039. _panningMouseButton: number;
  35040. /**
  35041. * Defines the input associated to the camera.
  35042. */
  35043. inputs: ArcRotateCameraInputsManager;
  35044. /** @hidden */
  35045. _reset: () => void;
  35046. /**
  35047. * Defines the allowed panning axis.
  35048. */
  35049. panningAxis: Vector3;
  35050. protected _localDirection: Vector3;
  35051. protected _transformedDirection: Vector3;
  35052. private _bouncingBehavior;
  35053. /**
  35054. * Gets the bouncing behavior of the camera if it has been enabled.
  35055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35056. */
  35057. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35058. /**
  35059. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35061. */
  35062. useBouncingBehavior: boolean;
  35063. private _framingBehavior;
  35064. /**
  35065. * Gets the framing behavior of the camera if it has been enabled.
  35066. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35067. */
  35068. readonly framingBehavior: Nullable<FramingBehavior>;
  35069. /**
  35070. * Defines if the framing behavior of the camera is enabled on the camera.
  35071. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35072. */
  35073. useFramingBehavior: boolean;
  35074. private _autoRotationBehavior;
  35075. /**
  35076. * Gets the auto rotation behavior of the camera if it has been enabled.
  35077. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35078. */
  35079. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35080. /**
  35081. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35082. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35083. */
  35084. useAutoRotationBehavior: boolean;
  35085. /**
  35086. * Observable triggered when the mesh target has been changed on the camera.
  35087. */
  35088. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35089. /**
  35090. * Event raised when the camera is colliding with a mesh.
  35091. */
  35092. onCollide: (collidedMesh: AbstractMesh) => void;
  35093. /**
  35094. * Defines whether the camera should check collision with the objects oh the scene.
  35095. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35096. */
  35097. checkCollisions: boolean;
  35098. /**
  35099. * Defines the collision radius of the camera.
  35100. * This simulates a sphere around the camera.
  35101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35102. */
  35103. collisionRadius: Vector3;
  35104. protected _collider: Collider;
  35105. protected _previousPosition: Vector3;
  35106. protected _collisionVelocity: Vector3;
  35107. protected _newPosition: Vector3;
  35108. protected _previousAlpha: number;
  35109. protected _previousBeta: number;
  35110. protected _previousRadius: number;
  35111. protected _collisionTriggered: boolean;
  35112. protected _targetBoundingCenter: Nullable<Vector3>;
  35113. private _computationVector;
  35114. private _tempAxisVector;
  35115. private _tempAxisRotationMatrix;
  35116. /**
  35117. * Instantiates a new ArcRotateCamera in a given scene
  35118. * @param name Defines the name of the camera
  35119. * @param alpha Defines the camera rotation along the logitudinal axis
  35120. * @param beta Defines the camera rotation along the latitudinal axis
  35121. * @param radius Defines the camera distance from its target
  35122. * @param target Defines the camera target
  35123. * @param scene Defines the scene the camera belongs to
  35124. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35125. */
  35126. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35127. /** @hidden */
  35128. _initCache(): void;
  35129. /** @hidden */
  35130. _updateCache(ignoreParentClass?: boolean): void;
  35131. protected _getTargetPosition(): Vector3;
  35132. private _storedAlpha;
  35133. private _storedBeta;
  35134. private _storedRadius;
  35135. private _storedTarget;
  35136. /**
  35137. * Stores the current state of the camera (alpha, beta, radius and target)
  35138. * @returns the camera itself
  35139. */
  35140. storeState(): Camera;
  35141. /**
  35142. * @hidden
  35143. * Restored camera state. You must call storeState() first
  35144. */
  35145. _restoreStateValues(): boolean;
  35146. /** @hidden */
  35147. _isSynchronizedViewMatrix(): boolean;
  35148. /**
  35149. * Attached controls to the current camera.
  35150. * @param element Defines the element the controls should be listened from
  35151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35152. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35153. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35154. */
  35155. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35156. /**
  35157. * Detach the current controls from the camera.
  35158. * The camera will stop reacting to inputs.
  35159. * @param element Defines the element to stop listening the inputs from
  35160. */
  35161. detachControl(element: HTMLElement): void;
  35162. /** @hidden */
  35163. _checkInputs(): void;
  35164. protected _checkLimits(): void;
  35165. /**
  35166. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35167. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35168. */
  35169. rebuildAnglesAndRadius(updateView?: boolean): void;
  35170. /**
  35171. * Use a position to define the current camera related information like aplha, beta and radius
  35172. * @param position Defines the position to set the camera at
  35173. */
  35174. setPosition(position: Vector3): void;
  35175. /**
  35176. * Defines the target the camera should look at.
  35177. * This will automatically adapt alpha beta and radius to fit within the new target.
  35178. * @param target Defines the new target as a Vector or a mesh
  35179. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35180. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35181. */
  35182. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35183. /** @hidden */
  35184. _getViewMatrix(): Matrix;
  35185. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35186. /**
  35187. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35188. * @param meshes Defines the mesh to zoom on
  35189. * @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)
  35190. */
  35191. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35192. /**
  35193. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35194. * The target will be changed but the radius
  35195. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35196. * @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)
  35197. */
  35198. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35199. min: Vector3;
  35200. max: Vector3;
  35201. distance: number;
  35202. }, doNotUpdateMaxZ?: boolean): void;
  35203. /**
  35204. * @override
  35205. * Override Camera.createRigCamera
  35206. */
  35207. createRigCamera(name: string, cameraIndex: number): Camera;
  35208. /**
  35209. * @hidden
  35210. * @override
  35211. * Override Camera._updateRigCameras
  35212. */
  35213. _updateRigCameras(): void;
  35214. /**
  35215. * Destroy the camera and release the current resources hold by it.
  35216. */
  35217. dispose(): void;
  35218. /**
  35219. * Gets the current object class name.
  35220. * @return the class name
  35221. */
  35222. getClassName(): string;
  35223. }
  35224. }
  35225. declare module BABYLON {
  35226. /**
  35227. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35228. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35229. */
  35230. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35231. /**
  35232. * Gets the name of the behavior.
  35233. */
  35234. readonly name: string;
  35235. private _zoomStopsAnimation;
  35236. private _idleRotationSpeed;
  35237. private _idleRotationWaitTime;
  35238. private _idleRotationSpinupTime;
  35239. /**
  35240. * Sets the flag that indicates if user zooming should stop animation.
  35241. */
  35242. /**
  35243. * Gets the flag that indicates if user zooming should stop animation.
  35244. */
  35245. zoomStopsAnimation: boolean;
  35246. /**
  35247. * Sets the default speed at which the camera rotates around the model.
  35248. */
  35249. /**
  35250. * Gets the default speed at which the camera rotates around the model.
  35251. */
  35252. idleRotationSpeed: number;
  35253. /**
  35254. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35255. */
  35256. /**
  35257. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35258. */
  35259. idleRotationWaitTime: number;
  35260. /**
  35261. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35262. */
  35263. /**
  35264. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35265. */
  35266. idleRotationSpinupTime: number;
  35267. /**
  35268. * Gets a value indicating if the camera is currently rotating because of this behavior
  35269. */
  35270. readonly rotationInProgress: boolean;
  35271. private _onPrePointerObservableObserver;
  35272. private _onAfterCheckInputsObserver;
  35273. private _attachedCamera;
  35274. private _isPointerDown;
  35275. private _lastFrameTime;
  35276. private _lastInteractionTime;
  35277. private _cameraRotationSpeed;
  35278. /**
  35279. * Initializes the behavior.
  35280. */
  35281. init(): void;
  35282. /**
  35283. * Attaches the behavior to its arc rotate camera.
  35284. * @param camera Defines the camera to attach the behavior to
  35285. */
  35286. attach(camera: ArcRotateCamera): void;
  35287. /**
  35288. * Detaches the behavior from its current arc rotate camera.
  35289. */
  35290. detach(): void;
  35291. /**
  35292. * Returns true if user is scrolling.
  35293. * @return true if user is scrolling.
  35294. */
  35295. private _userIsZooming;
  35296. private _lastFrameRadius;
  35297. private _shouldAnimationStopForInteraction;
  35298. /**
  35299. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35300. */
  35301. private _applyUserInteraction;
  35302. private _userIsMoving;
  35303. }
  35304. }
  35305. declare module BABYLON {
  35306. /**
  35307. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35308. */
  35309. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35310. private ui;
  35311. /**
  35312. * The name of the behavior
  35313. */
  35314. name: string;
  35315. /**
  35316. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35317. */
  35318. distanceAwayFromFace: number;
  35319. /**
  35320. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35321. */
  35322. distanceAwayFromBottomOfFace: number;
  35323. private _faceVectors;
  35324. private _target;
  35325. private _scene;
  35326. private _onRenderObserver;
  35327. private _tmpMatrix;
  35328. private _tmpVector;
  35329. /**
  35330. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35331. * @param ui The transform node that should be attched to the mesh
  35332. */
  35333. constructor(ui: TransformNode);
  35334. /**
  35335. * Initializes the behavior
  35336. */
  35337. init(): void;
  35338. private _closestFace;
  35339. private _zeroVector;
  35340. private _lookAtTmpMatrix;
  35341. private _lookAtToRef;
  35342. /**
  35343. * Attaches the AttachToBoxBehavior to the passed in mesh
  35344. * @param target The mesh that the specified node will be attached to
  35345. */
  35346. attach(target: Mesh): void;
  35347. /**
  35348. * Detaches the behavior from the mesh
  35349. */
  35350. detach(): void;
  35351. }
  35352. }
  35353. declare module BABYLON {
  35354. /**
  35355. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35356. */
  35357. export class FadeInOutBehavior implements Behavior<Mesh> {
  35358. /**
  35359. * Time in milliseconds to delay before fading in (Default: 0)
  35360. */
  35361. delay: number;
  35362. /**
  35363. * Time in milliseconds for the mesh to fade in (Default: 300)
  35364. */
  35365. fadeInTime: number;
  35366. private _millisecondsPerFrame;
  35367. private _hovered;
  35368. private _hoverValue;
  35369. private _ownerNode;
  35370. /**
  35371. * Instatiates the FadeInOutBehavior
  35372. */
  35373. constructor();
  35374. /**
  35375. * The name of the behavior
  35376. */
  35377. readonly name: string;
  35378. /**
  35379. * Initializes the behavior
  35380. */
  35381. init(): void;
  35382. /**
  35383. * Attaches the fade behavior on the passed in mesh
  35384. * @param ownerNode The mesh that will be faded in/out once attached
  35385. */
  35386. attach(ownerNode: Mesh): void;
  35387. /**
  35388. * Detaches the behavior from the mesh
  35389. */
  35390. detach(): void;
  35391. /**
  35392. * Triggers the mesh to begin fading in or out
  35393. * @param value if the object should fade in or out (true to fade in)
  35394. */
  35395. fadeIn(value: boolean): void;
  35396. private _update;
  35397. private _setAllVisibility;
  35398. }
  35399. }
  35400. declare module BABYLON {
  35401. /**
  35402. * Class containing a set of static utilities functions for managing Pivots
  35403. * @hidden
  35404. */
  35405. export class PivotTools {
  35406. private static _PivotCached;
  35407. private static _OldPivotPoint;
  35408. private static _PivotTranslation;
  35409. private static _PivotTmpVector;
  35410. /** @hidden */
  35411. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35412. /** @hidden */
  35413. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35414. }
  35415. }
  35416. declare module BABYLON {
  35417. /**
  35418. * Class containing static functions to help procedurally build meshes
  35419. */
  35420. export class PlaneBuilder {
  35421. /**
  35422. * Creates a plane mesh
  35423. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35424. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35425. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35427. * * 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
  35428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35429. * @param name defines the name of the mesh
  35430. * @param options defines the options used to create the mesh
  35431. * @param scene defines the hosting scene
  35432. * @returns the plane mesh
  35433. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35434. */
  35435. static CreatePlane(name: string, options: {
  35436. size?: number;
  35437. width?: number;
  35438. height?: number;
  35439. sideOrientation?: number;
  35440. frontUVs?: Vector4;
  35441. backUVs?: Vector4;
  35442. updatable?: boolean;
  35443. sourcePlane?: Plane;
  35444. }, scene: Scene): Mesh;
  35445. }
  35446. }
  35447. declare module BABYLON {
  35448. /**
  35449. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35450. */
  35451. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35452. private static _AnyMouseID;
  35453. private _attachedNode;
  35454. private _dragPlane;
  35455. private _scene;
  35456. private _pointerObserver;
  35457. private _beforeRenderObserver;
  35458. private static _planeScene;
  35459. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35460. /**
  35461. * 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)
  35462. */
  35463. maxDragAngle: number;
  35464. /**
  35465. * @hidden
  35466. */
  35467. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35468. /**
  35469. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35470. */
  35471. currentDraggingPointerID: number;
  35472. /**
  35473. * The last position where the pointer hit the drag plane in world space
  35474. */
  35475. lastDragPosition: Vector3;
  35476. /**
  35477. * If the behavior is currently in a dragging state
  35478. */
  35479. dragging: boolean;
  35480. /**
  35481. * 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)
  35482. */
  35483. dragDeltaRatio: number;
  35484. /**
  35485. * If the drag plane orientation should be updated during the dragging (Default: true)
  35486. */
  35487. updateDragPlane: boolean;
  35488. private _debugMode;
  35489. private _moving;
  35490. /**
  35491. * Fires each time the attached mesh is dragged with the pointer
  35492. * * delta between last drag position and current drag position in world space
  35493. * * dragDistance along the drag axis
  35494. * * dragPlaneNormal normal of the current drag plane used during the drag
  35495. * * dragPlanePoint in world space where the drag intersects the drag plane
  35496. */
  35497. onDragObservable: Observable<{
  35498. delta: Vector3;
  35499. dragPlanePoint: Vector3;
  35500. dragPlaneNormal: Vector3;
  35501. dragDistance: number;
  35502. pointerId: number;
  35503. }>;
  35504. /**
  35505. * Fires each time a drag begins (eg. mouse down on mesh)
  35506. */
  35507. onDragStartObservable: Observable<{
  35508. dragPlanePoint: Vector3;
  35509. pointerId: number;
  35510. }>;
  35511. /**
  35512. * Fires each time a drag ends (eg. mouse release after drag)
  35513. */
  35514. onDragEndObservable: Observable<{
  35515. dragPlanePoint: Vector3;
  35516. pointerId: number;
  35517. }>;
  35518. /**
  35519. * If the attached mesh should be moved when dragged
  35520. */
  35521. moveAttached: boolean;
  35522. /**
  35523. * If the drag behavior will react to drag events (Default: true)
  35524. */
  35525. enabled: boolean;
  35526. /**
  35527. * If camera controls should be detached during the drag
  35528. */
  35529. detachCameraControls: boolean;
  35530. /**
  35531. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35532. */
  35533. useObjectOrienationForDragging: boolean;
  35534. private _options;
  35535. /**
  35536. * Creates a pointer drag behavior that can be attached to a mesh
  35537. * @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)
  35538. */
  35539. constructor(options?: {
  35540. dragAxis?: Vector3;
  35541. dragPlaneNormal?: Vector3;
  35542. });
  35543. /**
  35544. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35545. */
  35546. validateDrag: (targetPosition: Vector3) => boolean;
  35547. /**
  35548. * The name of the behavior
  35549. */
  35550. readonly name: string;
  35551. /**
  35552. * Initializes the behavior
  35553. */
  35554. init(): void;
  35555. private _tmpVector;
  35556. private _alternatePickedPoint;
  35557. private _worldDragAxis;
  35558. private _targetPosition;
  35559. private _attachedElement;
  35560. /**
  35561. * Attaches the drag behavior the passed in mesh
  35562. * @param ownerNode The mesh that will be dragged around once attached
  35563. */
  35564. attach(ownerNode: AbstractMesh): void;
  35565. /**
  35566. * Force relase the drag action by code.
  35567. */
  35568. releaseDrag(): void;
  35569. private _startDragRay;
  35570. private _lastPointerRay;
  35571. /**
  35572. * Simulates the start of a pointer drag event on the behavior
  35573. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35574. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35575. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35576. */
  35577. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35578. private _startDrag;
  35579. private _dragDelta;
  35580. private _moveDrag;
  35581. private _pickWithRayOnDragPlane;
  35582. private _pointA;
  35583. private _pointB;
  35584. private _pointC;
  35585. private _lineA;
  35586. private _lineB;
  35587. private _localAxis;
  35588. private _lookAt;
  35589. private _updateDragPlanePosition;
  35590. /**
  35591. * Detaches the behavior from the mesh
  35592. */
  35593. detach(): void;
  35594. }
  35595. }
  35596. declare module BABYLON {
  35597. /**
  35598. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35599. */
  35600. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35601. private _dragBehaviorA;
  35602. private _dragBehaviorB;
  35603. private _startDistance;
  35604. private _initialScale;
  35605. private _targetScale;
  35606. private _ownerNode;
  35607. private _sceneRenderObserver;
  35608. /**
  35609. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35610. */
  35611. constructor();
  35612. /**
  35613. * The name of the behavior
  35614. */
  35615. readonly name: string;
  35616. /**
  35617. * Initializes the behavior
  35618. */
  35619. init(): void;
  35620. private _getCurrentDistance;
  35621. /**
  35622. * Attaches the scale behavior the passed in mesh
  35623. * @param ownerNode The mesh that will be scaled around once attached
  35624. */
  35625. attach(ownerNode: Mesh): void;
  35626. /**
  35627. * Detaches the behavior from the mesh
  35628. */
  35629. detach(): void;
  35630. }
  35631. }
  35632. declare module BABYLON {
  35633. /**
  35634. * 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
  35635. */
  35636. export class SixDofDragBehavior implements Behavior<Mesh> {
  35637. private static _virtualScene;
  35638. private _ownerNode;
  35639. private _sceneRenderObserver;
  35640. private _scene;
  35641. private _targetPosition;
  35642. private _virtualOriginMesh;
  35643. private _virtualDragMesh;
  35644. private _pointerObserver;
  35645. private _moving;
  35646. private _startingOrientation;
  35647. /**
  35648. * 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)
  35649. */
  35650. private zDragFactor;
  35651. /**
  35652. * If the object should rotate to face the drag origin
  35653. */
  35654. rotateDraggedObject: boolean;
  35655. /**
  35656. * If the behavior is currently in a dragging state
  35657. */
  35658. dragging: boolean;
  35659. /**
  35660. * 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)
  35661. */
  35662. dragDeltaRatio: number;
  35663. /**
  35664. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35665. */
  35666. currentDraggingPointerID: number;
  35667. /**
  35668. * If camera controls should be detached during the drag
  35669. */
  35670. detachCameraControls: boolean;
  35671. /**
  35672. * Fires each time a drag starts
  35673. */
  35674. onDragStartObservable: Observable<{}>;
  35675. /**
  35676. * Fires each time a drag ends (eg. mouse release after drag)
  35677. */
  35678. onDragEndObservable: Observable<{}>;
  35679. /**
  35680. * 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
  35681. */
  35682. constructor();
  35683. /**
  35684. * The name of the behavior
  35685. */
  35686. readonly name: string;
  35687. /**
  35688. * Initializes the behavior
  35689. */
  35690. init(): void;
  35691. /**
  35692. * Attaches the scale behavior the passed in mesh
  35693. * @param ownerNode The mesh that will be scaled around once attached
  35694. */
  35695. attach(ownerNode: Mesh): void;
  35696. /**
  35697. * Detaches the behavior from the mesh
  35698. */
  35699. detach(): void;
  35700. }
  35701. }
  35702. declare module BABYLON {
  35703. /**
  35704. * Class used to apply inverse kinematics to bones
  35705. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35706. */
  35707. export class BoneIKController {
  35708. private static _tmpVecs;
  35709. private static _tmpQuat;
  35710. private static _tmpMats;
  35711. /**
  35712. * Gets or sets the target mesh
  35713. */
  35714. targetMesh: AbstractMesh;
  35715. /** Gets or sets the mesh used as pole */
  35716. poleTargetMesh: AbstractMesh;
  35717. /**
  35718. * Gets or sets the bone used as pole
  35719. */
  35720. poleTargetBone: Nullable<Bone>;
  35721. /**
  35722. * Gets or sets the target position
  35723. */
  35724. targetPosition: Vector3;
  35725. /**
  35726. * Gets or sets the pole target position
  35727. */
  35728. poleTargetPosition: Vector3;
  35729. /**
  35730. * Gets or sets the pole target local offset
  35731. */
  35732. poleTargetLocalOffset: Vector3;
  35733. /**
  35734. * Gets or sets the pole angle
  35735. */
  35736. poleAngle: number;
  35737. /**
  35738. * Gets or sets the mesh associated with the controller
  35739. */
  35740. mesh: AbstractMesh;
  35741. /**
  35742. * 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)
  35743. */
  35744. slerpAmount: number;
  35745. private _bone1Quat;
  35746. private _bone1Mat;
  35747. private _bone2Ang;
  35748. private _bone1;
  35749. private _bone2;
  35750. private _bone1Length;
  35751. private _bone2Length;
  35752. private _maxAngle;
  35753. private _maxReach;
  35754. private _rightHandedSystem;
  35755. private _bendAxis;
  35756. private _slerping;
  35757. private _adjustRoll;
  35758. /**
  35759. * Gets or sets maximum allowed angle
  35760. */
  35761. maxAngle: number;
  35762. /**
  35763. * Creates a new BoneIKController
  35764. * @param mesh defines the mesh to control
  35765. * @param bone defines the bone to control
  35766. * @param options defines options to set up the controller
  35767. */
  35768. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35769. targetMesh?: AbstractMesh;
  35770. poleTargetMesh?: AbstractMesh;
  35771. poleTargetBone?: Bone;
  35772. poleTargetLocalOffset?: Vector3;
  35773. poleAngle?: number;
  35774. bendAxis?: Vector3;
  35775. maxAngle?: number;
  35776. slerpAmount?: number;
  35777. });
  35778. private _setMaxAngle;
  35779. /**
  35780. * Force the controller to update the bones
  35781. */
  35782. update(): void;
  35783. }
  35784. }
  35785. declare module BABYLON {
  35786. /**
  35787. * Class used to make a bone look toward a point in space
  35788. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35789. */
  35790. export class BoneLookController {
  35791. private static _tmpVecs;
  35792. private static _tmpQuat;
  35793. private static _tmpMats;
  35794. /**
  35795. * The target Vector3 that the bone will look at
  35796. */
  35797. target: Vector3;
  35798. /**
  35799. * The mesh that the bone is attached to
  35800. */
  35801. mesh: AbstractMesh;
  35802. /**
  35803. * The bone that will be looking to the target
  35804. */
  35805. bone: Bone;
  35806. /**
  35807. * The up axis of the coordinate system that is used when the bone is rotated
  35808. */
  35809. upAxis: Vector3;
  35810. /**
  35811. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35812. */
  35813. upAxisSpace: Space;
  35814. /**
  35815. * Used to make an adjustment to the yaw of the bone
  35816. */
  35817. adjustYaw: number;
  35818. /**
  35819. * Used to make an adjustment to the pitch of the bone
  35820. */
  35821. adjustPitch: number;
  35822. /**
  35823. * Used to make an adjustment to the roll of the bone
  35824. */
  35825. adjustRoll: number;
  35826. /**
  35827. * 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)
  35828. */
  35829. slerpAmount: number;
  35830. private _minYaw;
  35831. private _maxYaw;
  35832. private _minPitch;
  35833. private _maxPitch;
  35834. private _minYawSin;
  35835. private _minYawCos;
  35836. private _maxYawSin;
  35837. private _maxYawCos;
  35838. private _midYawConstraint;
  35839. private _minPitchTan;
  35840. private _maxPitchTan;
  35841. private _boneQuat;
  35842. private _slerping;
  35843. private _transformYawPitch;
  35844. private _transformYawPitchInv;
  35845. private _firstFrameSkipped;
  35846. private _yawRange;
  35847. private _fowardAxis;
  35848. /**
  35849. * Gets or sets the minimum yaw angle that the bone can look to
  35850. */
  35851. minYaw: number;
  35852. /**
  35853. * Gets or sets the maximum yaw angle that the bone can look to
  35854. */
  35855. maxYaw: number;
  35856. /**
  35857. * Gets or sets the minimum pitch angle that the bone can look to
  35858. */
  35859. minPitch: number;
  35860. /**
  35861. * Gets or sets the maximum pitch angle that the bone can look to
  35862. */
  35863. maxPitch: number;
  35864. /**
  35865. * Create a BoneLookController
  35866. * @param mesh the mesh that the bone belongs to
  35867. * @param bone the bone that will be looking to the target
  35868. * @param target the target Vector3 to look at
  35869. * @param options optional settings:
  35870. * * maxYaw: the maximum angle the bone will yaw to
  35871. * * minYaw: the minimum angle the bone will yaw to
  35872. * * maxPitch: the maximum angle the bone will pitch to
  35873. * * minPitch: the minimum angle the bone will yaw to
  35874. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35875. * * upAxis: the up axis of the coordinate system
  35876. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35877. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35878. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35879. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35880. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35881. * * adjustRoll: used to make an adjustment to the roll of the bone
  35882. **/
  35883. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35884. maxYaw?: number;
  35885. minYaw?: number;
  35886. maxPitch?: number;
  35887. minPitch?: number;
  35888. slerpAmount?: number;
  35889. upAxis?: Vector3;
  35890. upAxisSpace?: Space;
  35891. yawAxis?: Vector3;
  35892. pitchAxis?: Vector3;
  35893. adjustYaw?: number;
  35894. adjustPitch?: number;
  35895. adjustRoll?: number;
  35896. });
  35897. /**
  35898. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35899. */
  35900. update(): void;
  35901. private _getAngleDiff;
  35902. private _getAngleBetween;
  35903. private _isAngleBetween;
  35904. }
  35905. }
  35906. declare module BABYLON {
  35907. /**
  35908. * Manage the gamepad inputs to control an arc rotate camera.
  35909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35910. */
  35911. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35912. /**
  35913. * Defines the camera the input is attached to.
  35914. */
  35915. camera: ArcRotateCamera;
  35916. /**
  35917. * Defines the gamepad the input is gathering event from.
  35918. */
  35919. gamepad: Nullable<Gamepad>;
  35920. /**
  35921. * Defines the gamepad rotation sensiblity.
  35922. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35923. */
  35924. gamepadRotationSensibility: number;
  35925. /**
  35926. * Defines the gamepad move sensiblity.
  35927. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35928. */
  35929. gamepadMoveSensibility: number;
  35930. private _onGamepadConnectedObserver;
  35931. private _onGamepadDisconnectedObserver;
  35932. /**
  35933. * Attach the input controls to a specific dom element to get the input from.
  35934. * @param element Defines the element the controls should be listened from
  35935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35936. */
  35937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35938. /**
  35939. * Detach the current controls from the specified dom element.
  35940. * @param element Defines the element to stop listening the inputs from
  35941. */
  35942. detachControl(element: Nullable<HTMLElement>): void;
  35943. /**
  35944. * Update the current camera state depending on the inputs that have been used this frame.
  35945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35946. */
  35947. checkInputs(): void;
  35948. /**
  35949. * Gets the class name of the current intput.
  35950. * @returns the class name
  35951. */
  35952. getClassName(): string;
  35953. /**
  35954. * Get the friendly name associated with the input class.
  35955. * @returns the input friendly name
  35956. */
  35957. getSimpleName(): string;
  35958. }
  35959. }
  35960. declare module BABYLON {
  35961. interface ArcRotateCameraInputsManager {
  35962. /**
  35963. * Add orientation input support to the input manager.
  35964. * @returns the current input manager
  35965. */
  35966. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35967. }
  35968. /**
  35969. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35971. */
  35972. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35973. /**
  35974. * Defines the camera the input is attached to.
  35975. */
  35976. camera: ArcRotateCamera;
  35977. /**
  35978. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35979. */
  35980. alphaCorrection: number;
  35981. /**
  35982. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35983. */
  35984. gammaCorrection: number;
  35985. private _alpha;
  35986. private _gamma;
  35987. private _dirty;
  35988. private _deviceOrientationHandler;
  35989. /**
  35990. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35991. */
  35992. constructor();
  35993. /**
  35994. * Attach the input controls to a specific dom element to get the input from.
  35995. * @param element Defines the element the controls should be listened from
  35996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35997. */
  35998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35999. /** @hidden */
  36000. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36001. /**
  36002. * Update the current camera state depending on the inputs that have been used this frame.
  36003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36004. */
  36005. checkInputs(): void;
  36006. /**
  36007. * Detach the current controls from the specified dom element.
  36008. * @param element Defines the element to stop listening the inputs from
  36009. */
  36010. detachControl(element: Nullable<HTMLElement>): void;
  36011. /**
  36012. * Gets the class name of the current intput.
  36013. * @returns the class name
  36014. */
  36015. getClassName(): string;
  36016. /**
  36017. * Get the friendly name associated with the input class.
  36018. * @returns the input friendly name
  36019. */
  36020. getSimpleName(): string;
  36021. }
  36022. }
  36023. declare module BABYLON {
  36024. /**
  36025. * Listen to mouse events to control the camera.
  36026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36027. */
  36028. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36029. /**
  36030. * Defines the camera the input is attached to.
  36031. */
  36032. camera: FlyCamera;
  36033. /**
  36034. * Defines if touch is enabled. (Default is true.)
  36035. */
  36036. touchEnabled: boolean;
  36037. /**
  36038. * Defines the buttons associated with the input to handle camera rotation.
  36039. */
  36040. buttons: number[];
  36041. /**
  36042. * Assign buttons for Yaw control.
  36043. */
  36044. buttonsYaw: number[];
  36045. /**
  36046. * Assign buttons for Pitch control.
  36047. */
  36048. buttonsPitch: number[];
  36049. /**
  36050. * Assign buttons for Roll control.
  36051. */
  36052. buttonsRoll: number[];
  36053. /**
  36054. * Detect if any button is being pressed while mouse is moved.
  36055. * -1 = Mouse locked.
  36056. * 0 = Left button.
  36057. * 1 = Middle Button.
  36058. * 2 = Right Button.
  36059. */
  36060. activeButton: number;
  36061. /**
  36062. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36063. * Higher values reduce its sensitivity.
  36064. */
  36065. angularSensibility: number;
  36066. private _mousemoveCallback;
  36067. private _observer;
  36068. private _rollObserver;
  36069. private previousPosition;
  36070. private noPreventDefault;
  36071. private element;
  36072. /**
  36073. * Listen to mouse events to control the camera.
  36074. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36076. */
  36077. constructor(touchEnabled?: boolean);
  36078. /**
  36079. * Attach the mouse control to the HTML DOM element.
  36080. * @param element Defines the element that listens to the input events.
  36081. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36082. */
  36083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36084. /**
  36085. * Detach the current controls from the specified dom element.
  36086. * @param element Defines the element to stop listening the inputs from
  36087. */
  36088. detachControl(element: Nullable<HTMLElement>): void;
  36089. /**
  36090. * Gets the class name of the current input.
  36091. * @returns the class name.
  36092. */
  36093. getClassName(): string;
  36094. /**
  36095. * Get the friendly name associated with the input class.
  36096. * @returns the input's friendly name.
  36097. */
  36098. getSimpleName(): string;
  36099. private _pointerInput;
  36100. private _onMouseMove;
  36101. /**
  36102. * Rotate camera by mouse offset.
  36103. */
  36104. private rotateCamera;
  36105. }
  36106. }
  36107. declare module BABYLON {
  36108. /**
  36109. * Default Inputs manager for the FlyCamera.
  36110. * It groups all the default supported inputs for ease of use.
  36111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36112. */
  36113. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36114. /**
  36115. * Instantiates a new FlyCameraInputsManager.
  36116. * @param camera Defines the camera the inputs belong to.
  36117. */
  36118. constructor(camera: FlyCamera);
  36119. /**
  36120. * Add keyboard input support to the input manager.
  36121. * @returns the new FlyCameraKeyboardMoveInput().
  36122. */
  36123. addKeyboard(): FlyCameraInputsManager;
  36124. /**
  36125. * Add mouse input support to the input manager.
  36126. * @param touchEnabled Enable touch screen support.
  36127. * @returns the new FlyCameraMouseInput().
  36128. */
  36129. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36130. }
  36131. }
  36132. declare module BABYLON {
  36133. /**
  36134. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36135. * such as in a 3D Space Shooter or a Flight Simulator.
  36136. */
  36137. export class FlyCamera extends TargetCamera {
  36138. /**
  36139. * Define the collision ellipsoid of the camera.
  36140. * This is helpful for simulating a camera body, like a player's body.
  36141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36142. */
  36143. ellipsoid: Vector3;
  36144. /**
  36145. * Define an offset for the position of the ellipsoid around the camera.
  36146. * This can be helpful if the camera is attached away from the player's body center,
  36147. * such as at its head.
  36148. */
  36149. ellipsoidOffset: Vector3;
  36150. /**
  36151. * Enable or disable collisions of the camera with the rest of the scene objects.
  36152. */
  36153. checkCollisions: boolean;
  36154. /**
  36155. * Enable or disable gravity on the camera.
  36156. */
  36157. applyGravity: boolean;
  36158. /**
  36159. * Define the current direction the camera is moving to.
  36160. */
  36161. cameraDirection: Vector3;
  36162. /**
  36163. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36164. * This overrides and empties cameraRotation.
  36165. */
  36166. rotationQuaternion: Quaternion;
  36167. /**
  36168. * Track Roll to maintain the wanted Rolling when looking around.
  36169. */
  36170. _trackRoll: number;
  36171. /**
  36172. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36173. */
  36174. rollCorrect: number;
  36175. /**
  36176. * Mimic a banked turn, Rolling the camera when Yawing.
  36177. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36178. */
  36179. bankedTurn: boolean;
  36180. /**
  36181. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36182. */
  36183. bankedTurnLimit: number;
  36184. /**
  36185. * Value of 0 disables the banked Roll.
  36186. * Value of 1 is equal to the Yaw angle in radians.
  36187. */
  36188. bankedTurnMultiplier: number;
  36189. /**
  36190. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36191. */
  36192. inputs: FlyCameraInputsManager;
  36193. /**
  36194. * Gets the input sensibility for mouse input.
  36195. * Higher values reduce sensitivity.
  36196. */
  36197. /**
  36198. * Sets the input sensibility for a mouse input.
  36199. * Higher values reduce sensitivity.
  36200. */
  36201. angularSensibility: number;
  36202. /**
  36203. * Get the keys for camera movement forward.
  36204. */
  36205. /**
  36206. * Set the keys for camera movement forward.
  36207. */
  36208. keysForward: number[];
  36209. /**
  36210. * Get the keys for camera movement backward.
  36211. */
  36212. keysBackward: number[];
  36213. /**
  36214. * Get the keys for camera movement up.
  36215. */
  36216. /**
  36217. * Set the keys for camera movement up.
  36218. */
  36219. keysUp: number[];
  36220. /**
  36221. * Get the keys for camera movement down.
  36222. */
  36223. /**
  36224. * Set the keys for camera movement down.
  36225. */
  36226. keysDown: number[];
  36227. /**
  36228. * Get the keys for camera movement left.
  36229. */
  36230. /**
  36231. * Set the keys for camera movement left.
  36232. */
  36233. keysLeft: number[];
  36234. /**
  36235. * Set the keys for camera movement right.
  36236. */
  36237. /**
  36238. * Set the keys for camera movement right.
  36239. */
  36240. keysRight: number[];
  36241. /**
  36242. * Event raised when the camera collides with a mesh in the scene.
  36243. */
  36244. onCollide: (collidedMesh: AbstractMesh) => void;
  36245. private _collider;
  36246. private _needMoveForGravity;
  36247. private _oldPosition;
  36248. private _diffPosition;
  36249. private _newPosition;
  36250. /** @hidden */
  36251. _localDirection: Vector3;
  36252. /** @hidden */
  36253. _transformedDirection: Vector3;
  36254. /**
  36255. * Instantiates a FlyCamera.
  36256. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36257. * such as in a 3D Space Shooter or a Flight Simulator.
  36258. * @param name Define the name of the camera in the scene.
  36259. * @param position Define the starting position of the camera in the scene.
  36260. * @param scene Define the scene the camera belongs to.
  36261. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36262. */
  36263. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36264. /**
  36265. * Attach a control to the HTML DOM element.
  36266. * @param element Defines the element that listens to the input events.
  36267. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36268. */
  36269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36270. /**
  36271. * Detach a control from the HTML DOM element.
  36272. * The camera will stop reacting to that input.
  36273. * @param element Defines the element that listens to the input events.
  36274. */
  36275. detachControl(element: HTMLElement): void;
  36276. private _collisionMask;
  36277. /**
  36278. * Get the mask that the camera ignores in collision events.
  36279. */
  36280. /**
  36281. * Set the mask that the camera ignores in collision events.
  36282. */
  36283. collisionMask: number;
  36284. /** @hidden */
  36285. _collideWithWorld(displacement: Vector3): void;
  36286. /** @hidden */
  36287. private _onCollisionPositionChange;
  36288. /** @hidden */
  36289. _checkInputs(): void;
  36290. /** @hidden */
  36291. _decideIfNeedsToMove(): boolean;
  36292. /** @hidden */
  36293. _updatePosition(): void;
  36294. /**
  36295. * Restore the Roll to its target value at the rate specified.
  36296. * @param rate - Higher means slower restoring.
  36297. * @hidden
  36298. */
  36299. restoreRoll(rate: number): void;
  36300. /**
  36301. * Destroy the camera and release the current resources held by it.
  36302. */
  36303. dispose(): void;
  36304. /**
  36305. * Get the current object class name.
  36306. * @returns the class name.
  36307. */
  36308. getClassName(): string;
  36309. }
  36310. }
  36311. declare module BABYLON {
  36312. /**
  36313. * Listen to keyboard events to control the camera.
  36314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36315. */
  36316. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36317. /**
  36318. * Defines the camera the input is attached to.
  36319. */
  36320. camera: FlyCamera;
  36321. /**
  36322. * The list of keyboard keys used to control the forward move of the camera.
  36323. */
  36324. keysForward: number[];
  36325. /**
  36326. * The list of keyboard keys used to control the backward move of the camera.
  36327. */
  36328. keysBackward: number[];
  36329. /**
  36330. * The list of keyboard keys used to control the forward move of the camera.
  36331. */
  36332. keysUp: number[];
  36333. /**
  36334. * The list of keyboard keys used to control the backward move of the camera.
  36335. */
  36336. keysDown: number[];
  36337. /**
  36338. * The list of keyboard keys used to control the right strafe move of the camera.
  36339. */
  36340. keysRight: number[];
  36341. /**
  36342. * The list of keyboard keys used to control the left strafe move of the camera.
  36343. */
  36344. keysLeft: number[];
  36345. private _keys;
  36346. private _onCanvasBlurObserver;
  36347. private _onKeyboardObserver;
  36348. private _engine;
  36349. private _scene;
  36350. /**
  36351. * Attach the input controls to a specific dom element to get the input from.
  36352. * @param element Defines the element the controls should be listened from
  36353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36354. */
  36355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36356. /**
  36357. * Detach the current controls from the specified dom element.
  36358. * @param element Defines the element to stop listening the inputs from
  36359. */
  36360. detachControl(element: Nullable<HTMLElement>): void;
  36361. /**
  36362. * Gets the class name of the current intput.
  36363. * @returns the class name
  36364. */
  36365. getClassName(): string;
  36366. /** @hidden */
  36367. _onLostFocus(e: FocusEvent): void;
  36368. /**
  36369. * Get the friendly name associated with the input class.
  36370. * @returns the input friendly name
  36371. */
  36372. getSimpleName(): string;
  36373. /**
  36374. * Update the current camera state depending on the inputs that have been used this frame.
  36375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36376. */
  36377. checkInputs(): void;
  36378. }
  36379. }
  36380. declare module BABYLON {
  36381. /**
  36382. * Manage the mouse wheel inputs to control a follow camera.
  36383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36384. */
  36385. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36386. /**
  36387. * Defines the camera the input is attached to.
  36388. */
  36389. camera: FollowCamera;
  36390. /**
  36391. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36392. */
  36393. axisControlRadius: boolean;
  36394. /**
  36395. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36396. */
  36397. axisControlHeight: boolean;
  36398. /**
  36399. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36400. */
  36401. axisControlRotation: boolean;
  36402. /**
  36403. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36404. * relation to mouseWheel events.
  36405. */
  36406. wheelPrecision: number;
  36407. /**
  36408. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36409. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36410. */
  36411. wheelDeltaPercentage: number;
  36412. private _wheel;
  36413. private _observer;
  36414. /**
  36415. * Attach the input controls to a specific dom element to get the input from.
  36416. * @param element Defines the element the controls should be listened from
  36417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36418. */
  36419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36420. /**
  36421. * Detach the current controls from the specified dom element.
  36422. * @param element Defines the element to stop listening the inputs from
  36423. */
  36424. detachControl(element: Nullable<HTMLElement>): void;
  36425. /**
  36426. * Gets the class name of the current intput.
  36427. * @returns the class name
  36428. */
  36429. getClassName(): string;
  36430. /**
  36431. * Get the friendly name associated with the input class.
  36432. * @returns the input friendly name
  36433. */
  36434. getSimpleName(): string;
  36435. }
  36436. }
  36437. declare module BABYLON {
  36438. /**
  36439. * Manage the pointers inputs to control an follow camera.
  36440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36441. */
  36442. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36443. /**
  36444. * Defines the camera the input is attached to.
  36445. */
  36446. camera: FollowCamera;
  36447. /**
  36448. * Gets the class name of the current input.
  36449. * @returns the class name
  36450. */
  36451. getClassName(): string;
  36452. /**
  36453. * Defines the pointer angular sensibility along the X axis or how fast is
  36454. * the camera rotating.
  36455. * A negative number will reverse the axis direction.
  36456. */
  36457. angularSensibilityX: number;
  36458. /**
  36459. * Defines the pointer angular sensibility along the Y axis or how fast is
  36460. * the camera rotating.
  36461. * A negative number will reverse the axis direction.
  36462. */
  36463. angularSensibilityY: number;
  36464. /**
  36465. * Defines the pointer pinch precision or how fast is the camera zooming.
  36466. * A negative number will reverse the axis direction.
  36467. */
  36468. pinchPrecision: number;
  36469. /**
  36470. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36471. * from 0.
  36472. * It defines the percentage of current camera.radius to use as delta when
  36473. * pinch zoom is used.
  36474. */
  36475. pinchDeltaPercentage: number;
  36476. /**
  36477. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36478. */
  36479. axisXControlRadius: boolean;
  36480. /**
  36481. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36482. */
  36483. axisXControlHeight: boolean;
  36484. /**
  36485. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36486. */
  36487. axisXControlRotation: boolean;
  36488. /**
  36489. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36490. */
  36491. axisYControlRadius: boolean;
  36492. /**
  36493. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36494. */
  36495. axisYControlHeight: boolean;
  36496. /**
  36497. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36498. */
  36499. axisYControlRotation: boolean;
  36500. /**
  36501. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36502. */
  36503. axisPinchControlRadius: boolean;
  36504. /**
  36505. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36506. */
  36507. axisPinchControlHeight: boolean;
  36508. /**
  36509. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36510. */
  36511. axisPinchControlRotation: boolean;
  36512. /**
  36513. * Log error messages if basic misconfiguration has occurred.
  36514. */
  36515. warningEnable: boolean;
  36516. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36517. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36518. private _warningCounter;
  36519. private _warning;
  36520. }
  36521. }
  36522. declare module BABYLON {
  36523. /**
  36524. * Default Inputs manager for the FollowCamera.
  36525. * It groups all the default supported inputs for ease of use.
  36526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36527. */
  36528. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36529. /**
  36530. * Instantiates a new FollowCameraInputsManager.
  36531. * @param camera Defines the camera the inputs belong to
  36532. */
  36533. constructor(camera: FollowCamera);
  36534. /**
  36535. * Add keyboard input support to the input manager.
  36536. * @returns the current input manager
  36537. */
  36538. addKeyboard(): FollowCameraInputsManager;
  36539. /**
  36540. * Add mouse wheel input support to the input manager.
  36541. * @returns the current input manager
  36542. */
  36543. addMouseWheel(): FollowCameraInputsManager;
  36544. /**
  36545. * Add pointers input support to the input manager.
  36546. * @returns the current input manager
  36547. */
  36548. addPointers(): FollowCameraInputsManager;
  36549. /**
  36550. * Add orientation input support to the input manager.
  36551. * @returns the current input manager
  36552. */
  36553. addVRDeviceOrientation(): FollowCameraInputsManager;
  36554. }
  36555. }
  36556. declare module BABYLON {
  36557. /**
  36558. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36559. * an arc rotate version arcFollowCamera are available.
  36560. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36561. */
  36562. export class FollowCamera extends TargetCamera {
  36563. /**
  36564. * Distance the follow camera should follow an object at
  36565. */
  36566. radius: number;
  36567. /**
  36568. * Minimum allowed distance of the camera to the axis of rotation
  36569. * (The camera can not get closer).
  36570. * This can help limiting how the Camera is able to move in the scene.
  36571. */
  36572. lowerRadiusLimit: Nullable<number>;
  36573. /**
  36574. * Maximum allowed distance of the camera to the axis of rotation
  36575. * (The camera can not get further).
  36576. * This can help limiting how the Camera is able to move in the scene.
  36577. */
  36578. upperRadiusLimit: Nullable<number>;
  36579. /**
  36580. * Define a rotation offset between the camera and the object it follows
  36581. */
  36582. rotationOffset: number;
  36583. /**
  36584. * Minimum allowed angle to camera position relative to target object.
  36585. * This can help limiting how the Camera is able to move in the scene.
  36586. */
  36587. lowerRotationOffsetLimit: Nullable<number>;
  36588. /**
  36589. * Maximum allowed angle to camera position relative to target object.
  36590. * This can help limiting how the Camera is able to move in the scene.
  36591. */
  36592. upperRotationOffsetLimit: Nullable<number>;
  36593. /**
  36594. * Define a height offset between the camera and the object it follows.
  36595. * It can help following an object from the top (like a car chaing a plane)
  36596. */
  36597. heightOffset: number;
  36598. /**
  36599. * Minimum allowed height of camera position relative to target object.
  36600. * This can help limiting how the Camera is able to move in the scene.
  36601. */
  36602. lowerHeightOffsetLimit: Nullable<number>;
  36603. /**
  36604. * Maximum allowed height of camera position relative to target object.
  36605. * This can help limiting how the Camera is able to move in the scene.
  36606. */
  36607. upperHeightOffsetLimit: Nullable<number>;
  36608. /**
  36609. * Define how fast the camera can accelerate to follow it s target.
  36610. */
  36611. cameraAcceleration: number;
  36612. /**
  36613. * Define the speed limit of the camera following an object.
  36614. */
  36615. maxCameraSpeed: number;
  36616. /**
  36617. * Define the target of the camera.
  36618. */
  36619. lockedTarget: Nullable<AbstractMesh>;
  36620. /**
  36621. * Defines the input associated with the camera.
  36622. */
  36623. inputs: FollowCameraInputsManager;
  36624. /**
  36625. * Instantiates the follow camera.
  36626. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36627. * @param name Define the name of the camera in the scene
  36628. * @param position Define the position of the camera
  36629. * @param scene Define the scene the camera belong to
  36630. * @param lockedTarget Define the target of the camera
  36631. */
  36632. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36633. private _follow;
  36634. /**
  36635. * Attached controls to the current camera.
  36636. * @param element Defines the element the controls should be listened from
  36637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36638. */
  36639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36640. /**
  36641. * Detach the current controls from the camera.
  36642. * The camera will stop reacting to inputs.
  36643. * @param element Defines the element to stop listening the inputs from
  36644. */
  36645. detachControl(element: HTMLElement): void;
  36646. /** @hidden */
  36647. _checkInputs(): void;
  36648. private _checkLimits;
  36649. /**
  36650. * Gets the camera class name.
  36651. * @returns the class name
  36652. */
  36653. getClassName(): string;
  36654. }
  36655. /**
  36656. * Arc Rotate version of the follow camera.
  36657. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36658. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36659. */
  36660. export class ArcFollowCamera extends TargetCamera {
  36661. /** The longitudinal angle of the camera */
  36662. alpha: number;
  36663. /** The latitudinal angle of the camera */
  36664. beta: number;
  36665. /** The radius of the camera from its target */
  36666. radius: number;
  36667. /** Define the camera target (the messh it should follow) */
  36668. target: Nullable<AbstractMesh>;
  36669. private _cartesianCoordinates;
  36670. /**
  36671. * Instantiates a new ArcFollowCamera
  36672. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36673. * @param name Define the name of the camera
  36674. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36675. * @param beta Define the rotation angle of the camera around the elevation axis
  36676. * @param radius Define the radius of the camera from its target point
  36677. * @param target Define the target of the camera
  36678. * @param scene Define the scene the camera belongs to
  36679. */
  36680. constructor(name: string,
  36681. /** The longitudinal angle of the camera */
  36682. alpha: number,
  36683. /** The latitudinal angle of the camera */
  36684. beta: number,
  36685. /** The radius of the camera from its target */
  36686. radius: number,
  36687. /** Define the camera target (the messh it should follow) */
  36688. target: Nullable<AbstractMesh>, scene: Scene);
  36689. private _follow;
  36690. /** @hidden */
  36691. _checkInputs(): void;
  36692. /**
  36693. * Returns the class name of the object.
  36694. * It is mostly used internally for serialization purposes.
  36695. */
  36696. getClassName(): string;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * Manage the keyboard inputs to control the movement of a follow camera.
  36702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36703. */
  36704. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36705. /**
  36706. * Defines the camera the input is attached to.
  36707. */
  36708. camera: FollowCamera;
  36709. /**
  36710. * Defines the list of key codes associated with the up action (increase heightOffset)
  36711. */
  36712. keysHeightOffsetIncr: number[];
  36713. /**
  36714. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36715. */
  36716. keysHeightOffsetDecr: number[];
  36717. /**
  36718. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36719. */
  36720. keysHeightOffsetModifierAlt: boolean;
  36721. /**
  36722. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36723. */
  36724. keysHeightOffsetModifierCtrl: boolean;
  36725. /**
  36726. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36727. */
  36728. keysHeightOffsetModifierShift: boolean;
  36729. /**
  36730. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36731. */
  36732. keysRotationOffsetIncr: number[];
  36733. /**
  36734. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36735. */
  36736. keysRotationOffsetDecr: number[];
  36737. /**
  36738. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36739. */
  36740. keysRotationOffsetModifierAlt: boolean;
  36741. /**
  36742. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36743. */
  36744. keysRotationOffsetModifierCtrl: boolean;
  36745. /**
  36746. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36747. */
  36748. keysRotationOffsetModifierShift: boolean;
  36749. /**
  36750. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36751. */
  36752. keysRadiusIncr: number[];
  36753. /**
  36754. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36755. */
  36756. keysRadiusDecr: number[];
  36757. /**
  36758. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36759. */
  36760. keysRadiusModifierAlt: boolean;
  36761. /**
  36762. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36763. */
  36764. keysRadiusModifierCtrl: boolean;
  36765. /**
  36766. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36767. */
  36768. keysRadiusModifierShift: boolean;
  36769. /**
  36770. * Defines the rate of change of heightOffset.
  36771. */
  36772. heightSensibility: number;
  36773. /**
  36774. * Defines the rate of change of rotationOffset.
  36775. */
  36776. rotationSensibility: number;
  36777. /**
  36778. * Defines the rate of change of radius.
  36779. */
  36780. radiusSensibility: number;
  36781. private _keys;
  36782. private _ctrlPressed;
  36783. private _altPressed;
  36784. private _shiftPressed;
  36785. private _onCanvasBlurObserver;
  36786. private _onKeyboardObserver;
  36787. private _engine;
  36788. private _scene;
  36789. /**
  36790. * Attach the input controls to a specific dom element to get the input from.
  36791. * @param element Defines the element the controls should be listened from
  36792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36793. */
  36794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36795. /**
  36796. * Detach the current controls from the specified dom element.
  36797. * @param element Defines the element to stop listening the inputs from
  36798. */
  36799. detachControl(element: Nullable<HTMLElement>): void;
  36800. /**
  36801. * Update the current camera state depending on the inputs that have been used this frame.
  36802. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36803. */
  36804. checkInputs(): void;
  36805. /**
  36806. * Gets the class name of the current input.
  36807. * @returns the class name
  36808. */
  36809. getClassName(): string;
  36810. /**
  36811. * Get the friendly name associated with the input class.
  36812. * @returns the input friendly name
  36813. */
  36814. getSimpleName(): string;
  36815. /**
  36816. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36817. * allow modification of the heightOffset value.
  36818. */
  36819. private _modifierHeightOffset;
  36820. /**
  36821. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36822. * allow modification of the rotationOffset value.
  36823. */
  36824. private _modifierRotationOffset;
  36825. /**
  36826. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36827. * allow modification of the radius value.
  36828. */
  36829. private _modifierRadius;
  36830. }
  36831. }
  36832. declare module BABYLON {
  36833. interface FreeCameraInputsManager {
  36834. /**
  36835. * @hidden
  36836. */
  36837. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36838. /**
  36839. * Add orientation input support to the input manager.
  36840. * @returns the current input manager
  36841. */
  36842. addDeviceOrientation(): FreeCameraInputsManager;
  36843. }
  36844. /**
  36845. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36846. * Screen rotation is taken into account.
  36847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36848. */
  36849. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36850. private _camera;
  36851. private _screenOrientationAngle;
  36852. private _constantTranform;
  36853. private _screenQuaternion;
  36854. private _alpha;
  36855. private _beta;
  36856. private _gamma;
  36857. /**
  36858. * @hidden
  36859. */
  36860. _onDeviceOrientationChangedObservable: Observable<void>;
  36861. /**
  36862. * Instantiates a new input
  36863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36864. */
  36865. constructor();
  36866. /**
  36867. * Define the camera controlled by the input.
  36868. */
  36869. camera: FreeCamera;
  36870. /**
  36871. * Attach the input controls to a specific dom element to get the input from.
  36872. * @param element Defines the element the controls should be listened from
  36873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36874. */
  36875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36876. private _orientationChanged;
  36877. private _deviceOrientation;
  36878. /**
  36879. * Detach the current controls from the specified dom element.
  36880. * @param element Defines the element to stop listening the inputs from
  36881. */
  36882. detachControl(element: Nullable<HTMLElement>): void;
  36883. /**
  36884. * Update the current camera state depending on the inputs that have been used this frame.
  36885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36886. */
  36887. checkInputs(): void;
  36888. /**
  36889. * Gets the class name of the current intput.
  36890. * @returns the class name
  36891. */
  36892. getClassName(): string;
  36893. /**
  36894. * Get the friendly name associated with the input class.
  36895. * @returns the input friendly name
  36896. */
  36897. getSimpleName(): string;
  36898. }
  36899. }
  36900. declare module BABYLON {
  36901. /**
  36902. * Manage the gamepad inputs to control a free camera.
  36903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36904. */
  36905. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36906. /**
  36907. * Define the camera the input is attached to.
  36908. */
  36909. camera: FreeCamera;
  36910. /**
  36911. * Define the Gamepad controlling the input
  36912. */
  36913. gamepad: Nullable<Gamepad>;
  36914. /**
  36915. * Defines the gamepad rotation sensiblity.
  36916. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36917. */
  36918. gamepadAngularSensibility: number;
  36919. /**
  36920. * Defines the gamepad move sensiblity.
  36921. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36922. */
  36923. gamepadMoveSensibility: number;
  36924. private _onGamepadConnectedObserver;
  36925. private _onGamepadDisconnectedObserver;
  36926. private _cameraTransform;
  36927. private _deltaTransform;
  36928. private _vector3;
  36929. private _vector2;
  36930. /**
  36931. * Attach the input controls to a specific dom element to get the input from.
  36932. * @param element Defines the element the controls should be listened from
  36933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36934. */
  36935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36936. /**
  36937. * Detach the current controls from the specified dom element.
  36938. * @param element Defines the element to stop listening the inputs from
  36939. */
  36940. detachControl(element: Nullable<HTMLElement>): void;
  36941. /**
  36942. * Update the current camera state depending on the inputs that have been used this frame.
  36943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36944. */
  36945. checkInputs(): void;
  36946. /**
  36947. * Gets the class name of the current intput.
  36948. * @returns the class name
  36949. */
  36950. getClassName(): string;
  36951. /**
  36952. * Get the friendly name associated with the input class.
  36953. * @returns the input friendly name
  36954. */
  36955. getSimpleName(): string;
  36956. }
  36957. }
  36958. declare module BABYLON {
  36959. /**
  36960. * Defines the potential axis of a Joystick
  36961. */
  36962. export enum JoystickAxis {
  36963. /** X axis */
  36964. X = 0,
  36965. /** Y axis */
  36966. Y = 1,
  36967. /** Z axis */
  36968. Z = 2
  36969. }
  36970. /**
  36971. * Class used to define virtual joystick (used in touch mode)
  36972. */
  36973. export class VirtualJoystick {
  36974. /**
  36975. * Gets or sets a boolean indicating that left and right values must be inverted
  36976. */
  36977. reverseLeftRight: boolean;
  36978. /**
  36979. * Gets or sets a boolean indicating that up and down values must be inverted
  36980. */
  36981. reverseUpDown: boolean;
  36982. /**
  36983. * Gets the offset value for the position (ie. the change of the position value)
  36984. */
  36985. deltaPosition: Vector3;
  36986. /**
  36987. * Gets a boolean indicating if the virtual joystick was pressed
  36988. */
  36989. pressed: boolean;
  36990. /**
  36991. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36992. */
  36993. static Canvas: Nullable<HTMLCanvasElement>;
  36994. private static _globalJoystickIndex;
  36995. private static vjCanvasContext;
  36996. private static vjCanvasWidth;
  36997. private static vjCanvasHeight;
  36998. private static halfWidth;
  36999. private _action;
  37000. private _axisTargetedByLeftAndRight;
  37001. private _axisTargetedByUpAndDown;
  37002. private _joystickSensibility;
  37003. private _inversedSensibility;
  37004. private _joystickPointerID;
  37005. private _joystickColor;
  37006. private _joystickPointerPos;
  37007. private _joystickPreviousPointerPos;
  37008. private _joystickPointerStartPos;
  37009. private _deltaJoystickVector;
  37010. private _leftJoystick;
  37011. private _touches;
  37012. private _onPointerDownHandlerRef;
  37013. private _onPointerMoveHandlerRef;
  37014. private _onPointerUpHandlerRef;
  37015. private _onResize;
  37016. /**
  37017. * Creates a new virtual joystick
  37018. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37019. */
  37020. constructor(leftJoystick?: boolean);
  37021. /**
  37022. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37023. * @param newJoystickSensibility defines the new sensibility
  37024. */
  37025. setJoystickSensibility(newJoystickSensibility: number): void;
  37026. private _onPointerDown;
  37027. private _onPointerMove;
  37028. private _onPointerUp;
  37029. /**
  37030. * Change the color of the virtual joystick
  37031. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37032. */
  37033. setJoystickColor(newColor: string): void;
  37034. /**
  37035. * Defines a callback to call when the joystick is touched
  37036. * @param action defines the callback
  37037. */
  37038. setActionOnTouch(action: () => any): void;
  37039. /**
  37040. * Defines which axis you'd like to control for left & right
  37041. * @param axis defines the axis to use
  37042. */
  37043. setAxisForLeftRight(axis: JoystickAxis): void;
  37044. /**
  37045. * Defines which axis you'd like to control for up & down
  37046. * @param axis defines the axis to use
  37047. */
  37048. setAxisForUpDown(axis: JoystickAxis): void;
  37049. private _drawVirtualJoystick;
  37050. /**
  37051. * Release internal HTML canvas
  37052. */
  37053. releaseCanvas(): void;
  37054. }
  37055. }
  37056. declare module BABYLON {
  37057. interface FreeCameraInputsManager {
  37058. /**
  37059. * Add virtual joystick input support to the input manager.
  37060. * @returns the current input manager
  37061. */
  37062. addVirtualJoystick(): FreeCameraInputsManager;
  37063. }
  37064. /**
  37065. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37067. */
  37068. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37069. /**
  37070. * Defines the camera the input is attached to.
  37071. */
  37072. camera: FreeCamera;
  37073. private _leftjoystick;
  37074. private _rightjoystick;
  37075. /**
  37076. * Gets the left stick of the virtual joystick.
  37077. * @returns The virtual Joystick
  37078. */
  37079. getLeftJoystick(): VirtualJoystick;
  37080. /**
  37081. * Gets the right stick of the virtual joystick.
  37082. * @returns The virtual Joystick
  37083. */
  37084. getRightJoystick(): VirtualJoystick;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Attach the input controls to a specific dom element to get the input from.
  37092. * @param element Defines the element the controls should be listened from
  37093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37094. */
  37095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37096. /**
  37097. * Detach the current controls from the specified dom element.
  37098. * @param element Defines the element to stop listening the inputs from
  37099. */
  37100. detachControl(element: Nullable<HTMLElement>): void;
  37101. /**
  37102. * Gets the class name of the current intput.
  37103. * @returns the class name
  37104. */
  37105. getClassName(): string;
  37106. /**
  37107. * Get the friendly name associated with the input class.
  37108. * @returns the input friendly name
  37109. */
  37110. getSimpleName(): string;
  37111. }
  37112. }
  37113. declare module BABYLON {
  37114. /**
  37115. * This represents a FPS type of camera controlled by touch.
  37116. * This is like a universal camera minus the Gamepad controls.
  37117. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37118. */
  37119. export class TouchCamera extends FreeCamera {
  37120. /**
  37121. * Defines the touch sensibility for rotation.
  37122. * The higher the faster.
  37123. */
  37124. touchAngularSensibility: number;
  37125. /**
  37126. * Defines the touch sensibility for move.
  37127. * The higher the faster.
  37128. */
  37129. touchMoveSensibility: number;
  37130. /**
  37131. * Instantiates a new touch camera.
  37132. * This represents a FPS type of camera controlled by touch.
  37133. * This is like a universal camera minus the Gamepad controls.
  37134. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37135. * @param name Define the name of the camera in the scene
  37136. * @param position Define the start position of the camera in the scene
  37137. * @param scene Define the scene the camera belongs to
  37138. */
  37139. constructor(name: string, position: Vector3, scene: Scene);
  37140. /**
  37141. * Gets the current object class name.
  37142. * @return the class name
  37143. */
  37144. getClassName(): string;
  37145. /** @hidden */
  37146. _setupInputs(): void;
  37147. }
  37148. }
  37149. declare module BABYLON {
  37150. /**
  37151. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37152. * being tilted forward or back and left or right.
  37153. */
  37154. export class DeviceOrientationCamera extends FreeCamera {
  37155. private _initialQuaternion;
  37156. private _quaternionCache;
  37157. private _tmpDragQuaternion;
  37158. /**
  37159. * Creates a new device orientation camera
  37160. * @param name The name of the camera
  37161. * @param position The start position camera
  37162. * @param scene The scene the camera belongs to
  37163. */
  37164. constructor(name: string, position: Vector3, scene: Scene);
  37165. /**
  37166. * Disabled pointer input on first orientation sensor update (Default: true)
  37167. */
  37168. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37169. private _dragFactor;
  37170. /**
  37171. * Enabled turning on the y axis when the orientation sensor is active
  37172. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37173. */
  37174. enableHorizontalDragging(dragFactor?: number): void;
  37175. /**
  37176. * Gets the current instance class name ("DeviceOrientationCamera").
  37177. * This helps avoiding instanceof at run time.
  37178. * @returns the class name
  37179. */
  37180. getClassName(): string;
  37181. /**
  37182. * @hidden
  37183. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37184. */
  37185. _checkInputs(): void;
  37186. /**
  37187. * Reset the camera to its default orientation on the specified axis only.
  37188. * @param axis The axis to reset
  37189. */
  37190. resetToCurrentRotation(axis?: Axis): void;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. /**
  37195. * 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,
  37196. * which still works and will still be found in many Playgrounds.
  37197. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37198. */
  37199. export class UniversalCamera extends TouchCamera {
  37200. /**
  37201. * Defines the gamepad rotation sensiblity.
  37202. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37203. */
  37204. gamepadAngularSensibility: number;
  37205. /**
  37206. * Defines the gamepad move sensiblity.
  37207. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37208. */
  37209. gamepadMoveSensibility: number;
  37210. /**
  37211. * 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,
  37212. * which still works and will still be found in many Playgrounds.
  37213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37214. * @param name Define the name of the camera in the scene
  37215. * @param position Define the start position of the camera in the scene
  37216. * @param scene Define the scene the camera belongs to
  37217. */
  37218. constructor(name: string, position: Vector3, scene: Scene);
  37219. /**
  37220. * Gets the current object class name.
  37221. * @return the class name
  37222. */
  37223. getClassName(): string;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. /**
  37228. * This represents a FPS type of camera. This is only here for back compat purpose.
  37229. * Please use the UniversalCamera instead as both are identical.
  37230. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37231. */
  37232. export class GamepadCamera extends UniversalCamera {
  37233. /**
  37234. * Instantiates a new Gamepad Camera
  37235. * This represents a FPS type of camera. This is only here for back compat purpose.
  37236. * Please use the UniversalCamera instead as both are identical.
  37237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37238. * @param name Define the name of the camera in the scene
  37239. * @param position Define the start position of the camera in the scene
  37240. * @param scene Define the scene the camera belongs to
  37241. */
  37242. constructor(name: string, position: Vector3, scene: Scene);
  37243. /**
  37244. * Gets the current object class name.
  37245. * @return the class name
  37246. */
  37247. getClassName(): string;
  37248. }
  37249. }
  37250. declare module BABYLON {
  37251. /** @hidden */
  37252. export var passPixelShader: {
  37253. name: string;
  37254. shader: string;
  37255. };
  37256. }
  37257. declare module BABYLON {
  37258. /** @hidden */
  37259. export var passCubePixelShader: {
  37260. name: string;
  37261. shader: string;
  37262. };
  37263. }
  37264. declare module BABYLON {
  37265. /**
  37266. * PassPostProcess which produces an output the same as it's input
  37267. */
  37268. export class PassPostProcess extends PostProcess {
  37269. /**
  37270. * Creates the PassPostProcess
  37271. * @param name The name of the effect.
  37272. * @param options The required width/height ratio to downsize to before computing the render pass.
  37273. * @param camera The camera to apply the render pass to.
  37274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37275. * @param engine The engine which the post process will be applied. (default: current engine)
  37276. * @param reusable If the post process can be reused on the same frame. (default: false)
  37277. * @param textureType The type of texture to be used when performing the post processing.
  37278. * @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)
  37279. */
  37280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37281. }
  37282. /**
  37283. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37284. */
  37285. export class PassCubePostProcess extends PostProcess {
  37286. private _face;
  37287. /**
  37288. * Gets or sets the cube face to display.
  37289. * * 0 is +X
  37290. * * 1 is -X
  37291. * * 2 is +Y
  37292. * * 3 is -Y
  37293. * * 4 is +Z
  37294. * * 5 is -Z
  37295. */
  37296. face: number;
  37297. /**
  37298. * Creates the PassCubePostProcess
  37299. * @param name The name of the effect.
  37300. * @param options The required width/height ratio to downsize to before computing the render pass.
  37301. * @param camera The camera to apply the render pass to.
  37302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37303. * @param engine The engine which the post process will be applied. (default: current engine)
  37304. * @param reusable If the post process can be reused on the same frame. (default: false)
  37305. * @param textureType The type of texture to be used when performing the post processing.
  37306. * @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)
  37307. */
  37308. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /** @hidden */
  37313. export var anaglyphPixelShader: {
  37314. name: string;
  37315. shader: string;
  37316. };
  37317. }
  37318. declare module BABYLON {
  37319. /**
  37320. * Postprocess used to generate anaglyphic rendering
  37321. */
  37322. export class AnaglyphPostProcess extends PostProcess {
  37323. private _passedProcess;
  37324. /**
  37325. * Creates a new AnaglyphPostProcess
  37326. * @param name defines postprocess name
  37327. * @param options defines creation options or target ratio scale
  37328. * @param rigCameras defines cameras using this postprocess
  37329. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37330. * @param engine defines hosting engine
  37331. * @param reusable defines if the postprocess will be reused multiple times per frame
  37332. */
  37333. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37334. }
  37335. }
  37336. declare module BABYLON {
  37337. /**
  37338. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37339. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37340. */
  37341. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37342. /**
  37343. * Creates a new AnaglyphArcRotateCamera
  37344. * @param name defines camera name
  37345. * @param alpha defines alpha angle (in radians)
  37346. * @param beta defines beta angle (in radians)
  37347. * @param radius defines radius
  37348. * @param target defines camera target
  37349. * @param interaxialDistance defines distance between each color axis
  37350. * @param scene defines the hosting scene
  37351. */
  37352. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37353. /**
  37354. * Gets camera class name
  37355. * @returns AnaglyphArcRotateCamera
  37356. */
  37357. getClassName(): string;
  37358. }
  37359. }
  37360. declare module BABYLON {
  37361. /**
  37362. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37363. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37364. */
  37365. export class AnaglyphFreeCamera extends FreeCamera {
  37366. /**
  37367. * Creates a new AnaglyphFreeCamera
  37368. * @param name defines camera name
  37369. * @param position defines initial position
  37370. * @param interaxialDistance defines distance between each color axis
  37371. * @param scene defines the hosting scene
  37372. */
  37373. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37374. /**
  37375. * Gets camera class name
  37376. * @returns AnaglyphFreeCamera
  37377. */
  37378. getClassName(): string;
  37379. }
  37380. }
  37381. declare module BABYLON {
  37382. /**
  37383. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37384. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37385. */
  37386. export class AnaglyphGamepadCamera extends GamepadCamera {
  37387. /**
  37388. * Creates a new AnaglyphGamepadCamera
  37389. * @param name defines camera name
  37390. * @param position defines initial position
  37391. * @param interaxialDistance defines distance between each color axis
  37392. * @param scene defines the hosting scene
  37393. */
  37394. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37395. /**
  37396. * Gets camera class name
  37397. * @returns AnaglyphGamepadCamera
  37398. */
  37399. getClassName(): string;
  37400. }
  37401. }
  37402. declare module BABYLON {
  37403. /**
  37404. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37405. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37406. */
  37407. export class AnaglyphUniversalCamera extends UniversalCamera {
  37408. /**
  37409. * Creates a new AnaglyphUniversalCamera
  37410. * @param name defines camera name
  37411. * @param position defines initial position
  37412. * @param interaxialDistance defines distance between each color axis
  37413. * @param scene defines the hosting scene
  37414. */
  37415. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37416. /**
  37417. * Gets camera class name
  37418. * @returns AnaglyphUniversalCamera
  37419. */
  37420. getClassName(): string;
  37421. }
  37422. }
  37423. declare module BABYLON {
  37424. /** @hidden */
  37425. export var stereoscopicInterlacePixelShader: {
  37426. name: string;
  37427. shader: string;
  37428. };
  37429. }
  37430. declare module BABYLON {
  37431. /**
  37432. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37433. */
  37434. export class StereoscopicInterlacePostProcess extends PostProcess {
  37435. private _stepSize;
  37436. private _passedProcess;
  37437. /**
  37438. * Initializes a StereoscopicInterlacePostProcess
  37439. * @param name The name of the effect.
  37440. * @param rigCameras The rig cameras to be appled to the post process
  37441. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37443. * @param engine The engine which the post process will be applied. (default: current engine)
  37444. * @param reusable If the post process can be reused on the same frame. (default: false)
  37445. */
  37446. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37447. }
  37448. }
  37449. declare module BABYLON {
  37450. /**
  37451. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37452. * @see http://doc.babylonjs.com/features/cameras
  37453. */
  37454. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37455. /**
  37456. * Creates a new StereoscopicArcRotateCamera
  37457. * @param name defines camera name
  37458. * @param alpha defines alpha angle (in radians)
  37459. * @param beta defines beta angle (in radians)
  37460. * @param radius defines radius
  37461. * @param target defines camera target
  37462. * @param interaxialDistance defines distance between each color axis
  37463. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37464. * @param scene defines the hosting scene
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37467. /**
  37468. * Gets camera class name
  37469. * @returns StereoscopicArcRotateCamera
  37470. */
  37471. getClassName(): string;
  37472. }
  37473. }
  37474. declare module BABYLON {
  37475. /**
  37476. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37477. * @see http://doc.babylonjs.com/features/cameras
  37478. */
  37479. export class StereoscopicFreeCamera extends FreeCamera {
  37480. /**
  37481. * Creates a new StereoscopicFreeCamera
  37482. * @param name defines camera name
  37483. * @param position defines initial position
  37484. * @param interaxialDistance defines distance between each color axis
  37485. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37486. * @param scene defines the hosting scene
  37487. */
  37488. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37489. /**
  37490. * Gets camera class name
  37491. * @returns StereoscopicFreeCamera
  37492. */
  37493. getClassName(): string;
  37494. }
  37495. }
  37496. declare module BABYLON {
  37497. /**
  37498. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37499. * @see http://doc.babylonjs.com/features/cameras
  37500. */
  37501. export class StereoscopicGamepadCamera extends GamepadCamera {
  37502. /**
  37503. * Creates a new StereoscopicGamepadCamera
  37504. * @param name defines camera name
  37505. * @param position defines initial position
  37506. * @param interaxialDistance defines distance between each color axis
  37507. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37508. * @param scene defines the hosting scene
  37509. */
  37510. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37511. /**
  37512. * Gets camera class name
  37513. * @returns StereoscopicGamepadCamera
  37514. */
  37515. getClassName(): string;
  37516. }
  37517. }
  37518. declare module BABYLON {
  37519. /**
  37520. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37521. * @see http://doc.babylonjs.com/features/cameras
  37522. */
  37523. export class StereoscopicUniversalCamera extends UniversalCamera {
  37524. /**
  37525. * Creates a new StereoscopicUniversalCamera
  37526. * @param name defines camera name
  37527. * @param position defines initial position
  37528. * @param interaxialDistance defines distance between each color axis
  37529. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37530. * @param scene defines the hosting scene
  37531. */
  37532. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37533. /**
  37534. * Gets camera class name
  37535. * @returns StereoscopicUniversalCamera
  37536. */
  37537. getClassName(): string;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37543. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37544. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37545. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37546. */
  37547. export class VirtualJoysticksCamera extends FreeCamera {
  37548. /**
  37549. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37550. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37551. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37552. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37553. * @param name Define the name of the camera in the scene
  37554. * @param position Define the start position of the camera in the scene
  37555. * @param scene Define the scene the camera belongs to
  37556. */
  37557. constructor(name: string, position: Vector3, scene: Scene);
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module BABYLON {
  37566. /**
  37567. * This represents all the required metrics to create a VR camera.
  37568. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37569. */
  37570. export class VRCameraMetrics {
  37571. /**
  37572. * Define the horizontal resolution off the screen.
  37573. */
  37574. hResolution: number;
  37575. /**
  37576. * Define the vertical resolution off the screen.
  37577. */
  37578. vResolution: number;
  37579. /**
  37580. * Define the horizontal screen size.
  37581. */
  37582. hScreenSize: number;
  37583. /**
  37584. * Define the vertical screen size.
  37585. */
  37586. vScreenSize: number;
  37587. /**
  37588. * Define the vertical screen center position.
  37589. */
  37590. vScreenCenter: number;
  37591. /**
  37592. * Define the distance of the eyes to the screen.
  37593. */
  37594. eyeToScreenDistance: number;
  37595. /**
  37596. * Define the distance between both lenses
  37597. */
  37598. lensSeparationDistance: number;
  37599. /**
  37600. * Define the distance between both viewer's eyes.
  37601. */
  37602. interpupillaryDistance: number;
  37603. /**
  37604. * Define the distortion factor of the VR postprocess.
  37605. * Please, touch with care.
  37606. */
  37607. distortionK: number[];
  37608. /**
  37609. * Define the chromatic aberration correction factors for the VR post process.
  37610. */
  37611. chromaAbCorrection: number[];
  37612. /**
  37613. * Define the scale factor of the post process.
  37614. * The smaller the better but the slower.
  37615. */
  37616. postProcessScaleFactor: number;
  37617. /**
  37618. * Define an offset for the lens center.
  37619. */
  37620. lensCenterOffset: number;
  37621. /**
  37622. * Define if the current vr camera should compensate the distortion of the lense or not.
  37623. */
  37624. compensateDistortion: boolean;
  37625. /**
  37626. * Defines if multiview should be enabled when rendering (Default: false)
  37627. */
  37628. multiviewEnabled: boolean;
  37629. /**
  37630. * Gets the rendering aspect ratio based on the provided resolutions.
  37631. */
  37632. readonly aspectRatio: number;
  37633. /**
  37634. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37635. */
  37636. readonly aspectRatioFov: number;
  37637. /**
  37638. * @hidden
  37639. */
  37640. readonly leftHMatrix: Matrix;
  37641. /**
  37642. * @hidden
  37643. */
  37644. readonly rightHMatrix: Matrix;
  37645. /**
  37646. * @hidden
  37647. */
  37648. readonly leftPreViewMatrix: Matrix;
  37649. /**
  37650. * @hidden
  37651. */
  37652. readonly rightPreViewMatrix: Matrix;
  37653. /**
  37654. * Get the default VRMetrics based on the most generic setup.
  37655. * @returns the default vr metrics
  37656. */
  37657. static GetDefault(): VRCameraMetrics;
  37658. }
  37659. }
  37660. declare module BABYLON {
  37661. /** @hidden */
  37662. export var vrDistortionCorrectionPixelShader: {
  37663. name: string;
  37664. shader: string;
  37665. };
  37666. }
  37667. declare module BABYLON {
  37668. /**
  37669. * VRDistortionCorrectionPostProcess used for mobile VR
  37670. */
  37671. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37672. private _isRightEye;
  37673. private _distortionFactors;
  37674. private _postProcessScaleFactor;
  37675. private _lensCenterOffset;
  37676. private _scaleIn;
  37677. private _scaleFactor;
  37678. private _lensCenter;
  37679. /**
  37680. * Initializes the VRDistortionCorrectionPostProcess
  37681. * @param name The name of the effect.
  37682. * @param camera The camera to apply the render pass to.
  37683. * @param isRightEye If this is for the right eye distortion
  37684. * @param vrMetrics All the required metrics for the VR camera
  37685. */
  37686. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37687. }
  37688. }
  37689. declare module BABYLON {
  37690. /**
  37691. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37692. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37693. */
  37694. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37695. /**
  37696. * Creates a new VRDeviceOrientationArcRotateCamera
  37697. * @param name defines camera name
  37698. * @param alpha defines the camera rotation along the logitudinal axis
  37699. * @param beta defines the camera rotation along the latitudinal axis
  37700. * @param radius defines the camera distance from its target
  37701. * @param target defines the camera target
  37702. * @param scene defines the scene the camera belongs to
  37703. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37704. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37705. */
  37706. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37707. /**
  37708. * Gets camera class name
  37709. * @returns VRDeviceOrientationArcRotateCamera
  37710. */
  37711. getClassName(): string;
  37712. }
  37713. }
  37714. declare module BABYLON {
  37715. /**
  37716. * Camera used to simulate VR rendering (based on FreeCamera)
  37717. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37718. */
  37719. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37720. /**
  37721. * Creates a new VRDeviceOrientationFreeCamera
  37722. * @param name defines camera name
  37723. * @param position defines the start position of the camera
  37724. * @param scene defines the scene the camera belongs to
  37725. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37726. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37727. */
  37728. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37729. /**
  37730. * Gets camera class name
  37731. * @returns VRDeviceOrientationFreeCamera
  37732. */
  37733. getClassName(): string;
  37734. }
  37735. }
  37736. declare module BABYLON {
  37737. /**
  37738. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37739. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37740. */
  37741. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37742. /**
  37743. * Creates a new VRDeviceOrientationGamepadCamera
  37744. * @param name defines camera name
  37745. * @param position defines the start position of the camera
  37746. * @param scene defines the scene the camera belongs to
  37747. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37748. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37749. */
  37750. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37751. /**
  37752. * Gets camera class name
  37753. * @returns VRDeviceOrientationGamepadCamera
  37754. */
  37755. getClassName(): string;
  37756. }
  37757. }
  37758. declare module BABYLON {
  37759. /**
  37760. * Defines supported buttons for XBox360 compatible gamepads
  37761. */
  37762. export enum Xbox360Button {
  37763. /** A */
  37764. A = 0,
  37765. /** B */
  37766. B = 1,
  37767. /** X */
  37768. X = 2,
  37769. /** Y */
  37770. Y = 3,
  37771. /** Start */
  37772. Start = 4,
  37773. /** Back */
  37774. Back = 5,
  37775. /** Left button */
  37776. LB = 6,
  37777. /** Right button */
  37778. RB = 7,
  37779. /** Left stick */
  37780. LeftStick = 8,
  37781. /** Right stick */
  37782. RightStick = 9
  37783. }
  37784. /** Defines values for XBox360 DPad */
  37785. export enum Xbox360Dpad {
  37786. /** Up */
  37787. Up = 0,
  37788. /** Down */
  37789. Down = 1,
  37790. /** Left */
  37791. Left = 2,
  37792. /** Right */
  37793. Right = 3
  37794. }
  37795. /**
  37796. * Defines a XBox360 gamepad
  37797. */
  37798. export class Xbox360Pad extends Gamepad {
  37799. private _leftTrigger;
  37800. private _rightTrigger;
  37801. private _onlefttriggerchanged;
  37802. private _onrighttriggerchanged;
  37803. private _onbuttondown;
  37804. private _onbuttonup;
  37805. private _ondpaddown;
  37806. private _ondpadup;
  37807. /** Observable raised when a button is pressed */
  37808. onButtonDownObservable: Observable<Xbox360Button>;
  37809. /** Observable raised when a button is released */
  37810. onButtonUpObservable: Observable<Xbox360Button>;
  37811. /** Observable raised when a pad is pressed */
  37812. onPadDownObservable: Observable<Xbox360Dpad>;
  37813. /** Observable raised when a pad is released */
  37814. onPadUpObservable: Observable<Xbox360Dpad>;
  37815. private _buttonA;
  37816. private _buttonB;
  37817. private _buttonX;
  37818. private _buttonY;
  37819. private _buttonBack;
  37820. private _buttonStart;
  37821. private _buttonLB;
  37822. private _buttonRB;
  37823. private _buttonLeftStick;
  37824. private _buttonRightStick;
  37825. private _dPadUp;
  37826. private _dPadDown;
  37827. private _dPadLeft;
  37828. private _dPadRight;
  37829. private _isXboxOnePad;
  37830. /**
  37831. * Creates a new XBox360 gamepad object
  37832. * @param id defines the id of this gamepad
  37833. * @param index defines its index
  37834. * @param gamepad defines the internal HTML gamepad object
  37835. * @param xboxOne defines if it is a XBox One gamepad
  37836. */
  37837. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37838. /**
  37839. * Defines the callback to call when left trigger is pressed
  37840. * @param callback defines the callback to use
  37841. */
  37842. onlefttriggerchanged(callback: (value: number) => void): void;
  37843. /**
  37844. * Defines the callback to call when right trigger is pressed
  37845. * @param callback defines the callback to use
  37846. */
  37847. onrighttriggerchanged(callback: (value: number) => void): void;
  37848. /**
  37849. * Gets the left trigger value
  37850. */
  37851. /**
  37852. * Sets the left trigger value
  37853. */
  37854. leftTrigger: number;
  37855. /**
  37856. * Gets the right trigger value
  37857. */
  37858. /**
  37859. * Sets the right trigger value
  37860. */
  37861. rightTrigger: number;
  37862. /**
  37863. * Defines the callback to call when a button is pressed
  37864. * @param callback defines the callback to use
  37865. */
  37866. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37867. /**
  37868. * Defines the callback to call when a button is released
  37869. * @param callback defines the callback to use
  37870. */
  37871. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37872. /**
  37873. * Defines the callback to call when a pad is pressed
  37874. * @param callback defines the callback to use
  37875. */
  37876. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37877. /**
  37878. * Defines the callback to call when a pad is released
  37879. * @param callback defines the callback to use
  37880. */
  37881. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37882. private _setButtonValue;
  37883. private _setDPadValue;
  37884. /**
  37885. * Gets the value of the `A` button
  37886. */
  37887. /**
  37888. * Sets the value of the `A` button
  37889. */
  37890. buttonA: number;
  37891. /**
  37892. * Gets the value of the `B` button
  37893. */
  37894. /**
  37895. * Sets the value of the `B` button
  37896. */
  37897. buttonB: number;
  37898. /**
  37899. * Gets the value of the `X` button
  37900. */
  37901. /**
  37902. * Sets the value of the `X` button
  37903. */
  37904. buttonX: number;
  37905. /**
  37906. * Gets the value of the `Y` button
  37907. */
  37908. /**
  37909. * Sets the value of the `Y` button
  37910. */
  37911. buttonY: number;
  37912. /**
  37913. * Gets the value of the `Start` button
  37914. */
  37915. /**
  37916. * Sets the value of the `Start` button
  37917. */
  37918. buttonStart: number;
  37919. /**
  37920. * Gets the value of the `Back` button
  37921. */
  37922. /**
  37923. * Sets the value of the `Back` button
  37924. */
  37925. buttonBack: number;
  37926. /**
  37927. * Gets the value of the `Left` button
  37928. */
  37929. /**
  37930. * Sets the value of the `Left` button
  37931. */
  37932. buttonLB: number;
  37933. /**
  37934. * Gets the value of the `Right` button
  37935. */
  37936. /**
  37937. * Sets the value of the `Right` button
  37938. */
  37939. buttonRB: number;
  37940. /**
  37941. * Gets the value of the Left joystick
  37942. */
  37943. /**
  37944. * Sets the value of the Left joystick
  37945. */
  37946. buttonLeftStick: number;
  37947. /**
  37948. * Gets the value of the Right joystick
  37949. */
  37950. /**
  37951. * Sets the value of the Right joystick
  37952. */
  37953. buttonRightStick: number;
  37954. /**
  37955. * Gets the value of D-pad up
  37956. */
  37957. /**
  37958. * Sets the value of D-pad up
  37959. */
  37960. dPadUp: number;
  37961. /**
  37962. * Gets the value of D-pad down
  37963. */
  37964. /**
  37965. * Sets the value of D-pad down
  37966. */
  37967. dPadDown: number;
  37968. /**
  37969. * Gets the value of D-pad left
  37970. */
  37971. /**
  37972. * Sets the value of D-pad left
  37973. */
  37974. dPadLeft: number;
  37975. /**
  37976. * Gets the value of D-pad right
  37977. */
  37978. /**
  37979. * Sets the value of D-pad right
  37980. */
  37981. dPadRight: number;
  37982. /**
  37983. * Force the gamepad to synchronize with device values
  37984. */
  37985. update(): void;
  37986. /**
  37987. * Disposes the gamepad
  37988. */
  37989. dispose(): void;
  37990. }
  37991. }
  37992. declare module BABYLON {
  37993. /**
  37994. * Base class of materials working in push mode in babylon JS
  37995. * @hidden
  37996. */
  37997. export class PushMaterial extends Material {
  37998. protected _activeEffect: Effect;
  37999. protected _normalMatrix: Matrix;
  38000. /**
  38001. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38002. * This means that the material can keep using a previous shader while a new one is being compiled.
  38003. * This is mostly used when shader parallel compilation is supported (true by default)
  38004. */
  38005. allowShaderHotSwapping: boolean;
  38006. constructor(name: string, scene: Scene);
  38007. getEffect(): Effect;
  38008. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38009. /**
  38010. * Binds the given world matrix to the active effect
  38011. *
  38012. * @param world the matrix to bind
  38013. */
  38014. bindOnlyWorldMatrix(world: Matrix): void;
  38015. /**
  38016. * Binds the given normal matrix to the active effect
  38017. *
  38018. * @param normalMatrix the matrix to bind
  38019. */
  38020. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38021. bind(world: Matrix, mesh?: Mesh): void;
  38022. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38023. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38024. }
  38025. }
  38026. declare module BABYLON {
  38027. /**
  38028. * This groups all the flags used to control the materials channel.
  38029. */
  38030. export class MaterialFlags {
  38031. private static _DiffuseTextureEnabled;
  38032. /**
  38033. * Are diffuse textures enabled in the application.
  38034. */
  38035. static DiffuseTextureEnabled: boolean;
  38036. private static _AmbientTextureEnabled;
  38037. /**
  38038. * Are ambient textures enabled in the application.
  38039. */
  38040. static AmbientTextureEnabled: boolean;
  38041. private static _OpacityTextureEnabled;
  38042. /**
  38043. * Are opacity textures enabled in the application.
  38044. */
  38045. static OpacityTextureEnabled: boolean;
  38046. private static _ReflectionTextureEnabled;
  38047. /**
  38048. * Are reflection textures enabled in the application.
  38049. */
  38050. static ReflectionTextureEnabled: boolean;
  38051. private static _EmissiveTextureEnabled;
  38052. /**
  38053. * Are emissive textures enabled in the application.
  38054. */
  38055. static EmissiveTextureEnabled: boolean;
  38056. private static _SpecularTextureEnabled;
  38057. /**
  38058. * Are specular textures enabled in the application.
  38059. */
  38060. static SpecularTextureEnabled: boolean;
  38061. private static _BumpTextureEnabled;
  38062. /**
  38063. * Are bump textures enabled in the application.
  38064. */
  38065. static BumpTextureEnabled: boolean;
  38066. private static _LightmapTextureEnabled;
  38067. /**
  38068. * Are lightmap textures enabled in the application.
  38069. */
  38070. static LightmapTextureEnabled: boolean;
  38071. private static _RefractionTextureEnabled;
  38072. /**
  38073. * Are refraction textures enabled in the application.
  38074. */
  38075. static RefractionTextureEnabled: boolean;
  38076. private static _ColorGradingTextureEnabled;
  38077. /**
  38078. * Are color grading textures enabled in the application.
  38079. */
  38080. static ColorGradingTextureEnabled: boolean;
  38081. private static _FresnelEnabled;
  38082. /**
  38083. * Are fresnels enabled in the application.
  38084. */
  38085. static FresnelEnabled: boolean;
  38086. private static _ClearCoatTextureEnabled;
  38087. /**
  38088. * Are clear coat textures enabled in the application.
  38089. */
  38090. static ClearCoatTextureEnabled: boolean;
  38091. private static _ClearCoatBumpTextureEnabled;
  38092. /**
  38093. * Are clear coat bump textures enabled in the application.
  38094. */
  38095. static ClearCoatBumpTextureEnabled: boolean;
  38096. private static _ClearCoatTintTextureEnabled;
  38097. /**
  38098. * Are clear coat tint textures enabled in the application.
  38099. */
  38100. static ClearCoatTintTextureEnabled: boolean;
  38101. private static _SheenTextureEnabled;
  38102. /**
  38103. * Are sheen textures enabled in the application.
  38104. */
  38105. static SheenTextureEnabled: boolean;
  38106. private static _AnisotropicTextureEnabled;
  38107. /**
  38108. * Are anisotropic textures enabled in the application.
  38109. */
  38110. static AnisotropicTextureEnabled: boolean;
  38111. }
  38112. }
  38113. declare module BABYLON {
  38114. /** @hidden */
  38115. export var defaultFragmentDeclaration: {
  38116. name: string;
  38117. shader: string;
  38118. };
  38119. }
  38120. declare module BABYLON {
  38121. /** @hidden */
  38122. export var defaultUboDeclaration: {
  38123. name: string;
  38124. shader: string;
  38125. };
  38126. }
  38127. declare module BABYLON {
  38128. /** @hidden */
  38129. export var lightFragmentDeclaration: {
  38130. name: string;
  38131. shader: string;
  38132. };
  38133. }
  38134. declare module BABYLON {
  38135. /** @hidden */
  38136. export var lightUboDeclaration: {
  38137. name: string;
  38138. shader: string;
  38139. };
  38140. }
  38141. declare module BABYLON {
  38142. /** @hidden */
  38143. export var lightsFragmentFunctions: {
  38144. name: string;
  38145. shader: string;
  38146. };
  38147. }
  38148. declare module BABYLON {
  38149. /** @hidden */
  38150. export var shadowsFragmentFunctions: {
  38151. name: string;
  38152. shader: string;
  38153. };
  38154. }
  38155. declare module BABYLON {
  38156. /** @hidden */
  38157. export var fresnelFunction: {
  38158. name: string;
  38159. shader: string;
  38160. };
  38161. }
  38162. declare module BABYLON {
  38163. /** @hidden */
  38164. export var reflectionFunction: {
  38165. name: string;
  38166. shader: string;
  38167. };
  38168. }
  38169. declare module BABYLON {
  38170. /** @hidden */
  38171. export var bumpFragmentFunctions: {
  38172. name: string;
  38173. shader: string;
  38174. };
  38175. }
  38176. declare module BABYLON {
  38177. /** @hidden */
  38178. export var logDepthDeclaration: {
  38179. name: string;
  38180. shader: string;
  38181. };
  38182. }
  38183. declare module BABYLON {
  38184. /** @hidden */
  38185. export var bumpFragment: {
  38186. name: string;
  38187. shader: string;
  38188. };
  38189. }
  38190. declare module BABYLON {
  38191. /** @hidden */
  38192. export var depthPrePass: {
  38193. name: string;
  38194. shader: string;
  38195. };
  38196. }
  38197. declare module BABYLON {
  38198. /** @hidden */
  38199. export var lightFragment: {
  38200. name: string;
  38201. shader: string;
  38202. };
  38203. }
  38204. declare module BABYLON {
  38205. /** @hidden */
  38206. export var logDepthFragment: {
  38207. name: string;
  38208. shader: string;
  38209. };
  38210. }
  38211. declare module BABYLON {
  38212. /** @hidden */
  38213. export var defaultPixelShader: {
  38214. name: string;
  38215. shader: string;
  38216. };
  38217. }
  38218. declare module BABYLON {
  38219. /** @hidden */
  38220. export var defaultVertexDeclaration: {
  38221. name: string;
  38222. shader: string;
  38223. };
  38224. }
  38225. declare module BABYLON {
  38226. /** @hidden */
  38227. export var bumpVertexDeclaration: {
  38228. name: string;
  38229. shader: string;
  38230. };
  38231. }
  38232. declare module BABYLON {
  38233. /** @hidden */
  38234. export var bumpVertex: {
  38235. name: string;
  38236. shader: string;
  38237. };
  38238. }
  38239. declare module BABYLON {
  38240. /** @hidden */
  38241. export var fogVertex: {
  38242. name: string;
  38243. shader: string;
  38244. };
  38245. }
  38246. declare module BABYLON {
  38247. /** @hidden */
  38248. export var shadowsVertex: {
  38249. name: string;
  38250. shader: string;
  38251. };
  38252. }
  38253. declare module BABYLON {
  38254. /** @hidden */
  38255. export var pointCloudVertex: {
  38256. name: string;
  38257. shader: string;
  38258. };
  38259. }
  38260. declare module BABYLON {
  38261. /** @hidden */
  38262. export var logDepthVertex: {
  38263. name: string;
  38264. shader: string;
  38265. };
  38266. }
  38267. declare module BABYLON {
  38268. /** @hidden */
  38269. export var defaultVertexShader: {
  38270. name: string;
  38271. shader: string;
  38272. };
  38273. }
  38274. declare module BABYLON {
  38275. /** @hidden */
  38276. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38277. MAINUV1: boolean;
  38278. MAINUV2: boolean;
  38279. DIFFUSE: boolean;
  38280. DIFFUSEDIRECTUV: number;
  38281. AMBIENT: boolean;
  38282. AMBIENTDIRECTUV: number;
  38283. OPACITY: boolean;
  38284. OPACITYDIRECTUV: number;
  38285. OPACITYRGB: boolean;
  38286. REFLECTION: boolean;
  38287. EMISSIVE: boolean;
  38288. EMISSIVEDIRECTUV: number;
  38289. SPECULAR: boolean;
  38290. SPECULARDIRECTUV: number;
  38291. BUMP: boolean;
  38292. BUMPDIRECTUV: number;
  38293. PARALLAX: boolean;
  38294. PARALLAXOCCLUSION: boolean;
  38295. SPECULAROVERALPHA: boolean;
  38296. CLIPPLANE: boolean;
  38297. CLIPPLANE2: boolean;
  38298. CLIPPLANE3: boolean;
  38299. CLIPPLANE4: boolean;
  38300. ALPHATEST: boolean;
  38301. DEPTHPREPASS: boolean;
  38302. ALPHAFROMDIFFUSE: boolean;
  38303. POINTSIZE: boolean;
  38304. FOG: boolean;
  38305. SPECULARTERM: boolean;
  38306. DIFFUSEFRESNEL: boolean;
  38307. OPACITYFRESNEL: boolean;
  38308. REFLECTIONFRESNEL: boolean;
  38309. REFRACTIONFRESNEL: boolean;
  38310. EMISSIVEFRESNEL: boolean;
  38311. FRESNEL: boolean;
  38312. NORMAL: boolean;
  38313. UV1: boolean;
  38314. UV2: boolean;
  38315. VERTEXCOLOR: boolean;
  38316. VERTEXALPHA: boolean;
  38317. NUM_BONE_INFLUENCERS: number;
  38318. BonesPerMesh: number;
  38319. BONETEXTURE: boolean;
  38320. INSTANCES: boolean;
  38321. GLOSSINESS: boolean;
  38322. ROUGHNESS: boolean;
  38323. EMISSIVEASILLUMINATION: boolean;
  38324. LINKEMISSIVEWITHDIFFUSE: boolean;
  38325. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38326. LIGHTMAP: boolean;
  38327. LIGHTMAPDIRECTUV: number;
  38328. OBJECTSPACE_NORMALMAP: boolean;
  38329. USELIGHTMAPASSHADOWMAP: boolean;
  38330. REFLECTIONMAP_3D: boolean;
  38331. REFLECTIONMAP_SPHERICAL: boolean;
  38332. REFLECTIONMAP_PLANAR: boolean;
  38333. REFLECTIONMAP_CUBIC: boolean;
  38334. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38335. REFLECTIONMAP_PROJECTION: boolean;
  38336. REFLECTIONMAP_SKYBOX: boolean;
  38337. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38338. REFLECTIONMAP_EXPLICIT: boolean;
  38339. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38340. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38341. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38342. INVERTCUBICMAP: boolean;
  38343. LOGARITHMICDEPTH: boolean;
  38344. REFRACTION: boolean;
  38345. REFRACTIONMAP_3D: boolean;
  38346. REFLECTIONOVERALPHA: boolean;
  38347. TWOSIDEDLIGHTING: boolean;
  38348. SHADOWFLOAT: boolean;
  38349. MORPHTARGETS: boolean;
  38350. MORPHTARGETS_NORMAL: boolean;
  38351. MORPHTARGETS_TANGENT: boolean;
  38352. NUM_MORPH_INFLUENCERS: number;
  38353. NONUNIFORMSCALING: boolean;
  38354. PREMULTIPLYALPHA: boolean;
  38355. IMAGEPROCESSING: boolean;
  38356. VIGNETTE: boolean;
  38357. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38358. VIGNETTEBLENDMODEOPAQUE: boolean;
  38359. TONEMAPPING: boolean;
  38360. TONEMAPPING_ACES: boolean;
  38361. CONTRAST: boolean;
  38362. COLORCURVES: boolean;
  38363. COLORGRADING: boolean;
  38364. COLORGRADING3D: boolean;
  38365. SAMPLER3DGREENDEPTH: boolean;
  38366. SAMPLER3DBGRMAP: boolean;
  38367. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38368. MULTIVIEW: boolean;
  38369. /**
  38370. * If the reflection texture on this material is in linear color space
  38371. * @hidden
  38372. */
  38373. IS_REFLECTION_LINEAR: boolean;
  38374. /**
  38375. * If the refraction texture on this material is in linear color space
  38376. * @hidden
  38377. */
  38378. IS_REFRACTION_LINEAR: boolean;
  38379. EXPOSURE: boolean;
  38380. constructor();
  38381. setReflectionMode(modeToEnable: string): void;
  38382. }
  38383. /**
  38384. * This is the default material used in Babylon. It is the best trade off between quality
  38385. * and performances.
  38386. * @see http://doc.babylonjs.com/babylon101/materials
  38387. */
  38388. export class StandardMaterial extends PushMaterial {
  38389. private _diffuseTexture;
  38390. /**
  38391. * The basic texture of the material as viewed under a light.
  38392. */
  38393. diffuseTexture: Nullable<BaseTexture>;
  38394. private _ambientTexture;
  38395. /**
  38396. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38397. */
  38398. ambientTexture: Nullable<BaseTexture>;
  38399. private _opacityTexture;
  38400. /**
  38401. * Define the transparency of the material from a texture.
  38402. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38403. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38404. */
  38405. opacityTexture: Nullable<BaseTexture>;
  38406. private _reflectionTexture;
  38407. /**
  38408. * Define the texture used to display the reflection.
  38409. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38410. */
  38411. reflectionTexture: Nullable<BaseTexture>;
  38412. private _emissiveTexture;
  38413. /**
  38414. * Define texture of the material as if self lit.
  38415. * This will be mixed in the final result even in the absence of light.
  38416. */
  38417. emissiveTexture: Nullable<BaseTexture>;
  38418. private _specularTexture;
  38419. /**
  38420. * Define how the color and intensity of the highlight given by the light in the material.
  38421. */
  38422. specularTexture: Nullable<BaseTexture>;
  38423. private _bumpTexture;
  38424. /**
  38425. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38426. * 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.
  38427. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38428. */
  38429. bumpTexture: Nullable<BaseTexture>;
  38430. private _lightmapTexture;
  38431. /**
  38432. * Complex lighting can be computationally expensive to compute at runtime.
  38433. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38434. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38435. */
  38436. lightmapTexture: Nullable<BaseTexture>;
  38437. private _refractionTexture;
  38438. /**
  38439. * Define the texture used to display the refraction.
  38440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38441. */
  38442. refractionTexture: Nullable<BaseTexture>;
  38443. /**
  38444. * The color of the material lit by the environmental background lighting.
  38445. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38446. */
  38447. ambientColor: Color3;
  38448. /**
  38449. * The basic color of the material as viewed under a light.
  38450. */
  38451. diffuseColor: Color3;
  38452. /**
  38453. * Define how the color and intensity of the highlight given by the light in the material.
  38454. */
  38455. specularColor: Color3;
  38456. /**
  38457. * Define the color of the material as if self lit.
  38458. * This will be mixed in the final result even in the absence of light.
  38459. */
  38460. emissiveColor: Color3;
  38461. /**
  38462. * Defines how sharp are the highlights in the material.
  38463. * The bigger the value the sharper giving a more glossy feeling to the result.
  38464. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38465. */
  38466. specularPower: number;
  38467. private _useAlphaFromDiffuseTexture;
  38468. /**
  38469. * Does the transparency come from the diffuse texture alpha channel.
  38470. */
  38471. useAlphaFromDiffuseTexture: boolean;
  38472. private _useEmissiveAsIllumination;
  38473. /**
  38474. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38475. */
  38476. useEmissiveAsIllumination: boolean;
  38477. private _linkEmissiveWithDiffuse;
  38478. /**
  38479. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38480. * the emissive level when the final color is close to one.
  38481. */
  38482. linkEmissiveWithDiffuse: boolean;
  38483. private _useSpecularOverAlpha;
  38484. /**
  38485. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38486. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38487. */
  38488. useSpecularOverAlpha: boolean;
  38489. private _useReflectionOverAlpha;
  38490. /**
  38491. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38492. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38493. */
  38494. useReflectionOverAlpha: boolean;
  38495. private _disableLighting;
  38496. /**
  38497. * Does lights from the scene impacts this material.
  38498. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38499. */
  38500. disableLighting: boolean;
  38501. private _useObjectSpaceNormalMap;
  38502. /**
  38503. * Allows using an object space normal map (instead of tangent space).
  38504. */
  38505. useObjectSpaceNormalMap: boolean;
  38506. private _useParallax;
  38507. /**
  38508. * Is parallax enabled or not.
  38509. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38510. */
  38511. useParallax: boolean;
  38512. private _useParallaxOcclusion;
  38513. /**
  38514. * Is parallax occlusion enabled or not.
  38515. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38516. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38517. */
  38518. useParallaxOcclusion: boolean;
  38519. /**
  38520. * 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.
  38521. */
  38522. parallaxScaleBias: number;
  38523. private _roughness;
  38524. /**
  38525. * Helps to define how blurry the reflections should appears in the material.
  38526. */
  38527. roughness: number;
  38528. /**
  38529. * In case of refraction, define the value of the indice of refraction.
  38530. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38531. */
  38532. indexOfRefraction: number;
  38533. /**
  38534. * Invert the refraction texture alongside the y axis.
  38535. * It can be useful with procedural textures or probe for instance.
  38536. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38537. */
  38538. invertRefractionY: boolean;
  38539. /**
  38540. * Defines the alpha limits in alpha test mode.
  38541. */
  38542. alphaCutOff: number;
  38543. private _useLightmapAsShadowmap;
  38544. /**
  38545. * In case of light mapping, define whether the map contains light or shadow informations.
  38546. */
  38547. useLightmapAsShadowmap: boolean;
  38548. private _diffuseFresnelParameters;
  38549. /**
  38550. * Define the diffuse fresnel parameters of the material.
  38551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38552. */
  38553. diffuseFresnelParameters: FresnelParameters;
  38554. private _opacityFresnelParameters;
  38555. /**
  38556. * Define the opacity fresnel parameters of the material.
  38557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38558. */
  38559. opacityFresnelParameters: FresnelParameters;
  38560. private _reflectionFresnelParameters;
  38561. /**
  38562. * Define the reflection fresnel parameters of the material.
  38563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38564. */
  38565. reflectionFresnelParameters: FresnelParameters;
  38566. private _refractionFresnelParameters;
  38567. /**
  38568. * Define the refraction fresnel parameters of the material.
  38569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38570. */
  38571. refractionFresnelParameters: FresnelParameters;
  38572. private _emissiveFresnelParameters;
  38573. /**
  38574. * Define the emissive fresnel parameters of the material.
  38575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38576. */
  38577. emissiveFresnelParameters: FresnelParameters;
  38578. private _useReflectionFresnelFromSpecular;
  38579. /**
  38580. * If true automatically deducts the fresnels values from the material specularity.
  38581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38582. */
  38583. useReflectionFresnelFromSpecular: boolean;
  38584. private _useGlossinessFromSpecularMapAlpha;
  38585. /**
  38586. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38587. */
  38588. useGlossinessFromSpecularMapAlpha: boolean;
  38589. private _maxSimultaneousLights;
  38590. /**
  38591. * Defines the maximum number of lights that can be used in the material
  38592. */
  38593. maxSimultaneousLights: number;
  38594. private _invertNormalMapX;
  38595. /**
  38596. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38597. */
  38598. invertNormalMapX: boolean;
  38599. private _invertNormalMapY;
  38600. /**
  38601. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38602. */
  38603. invertNormalMapY: boolean;
  38604. private _twoSidedLighting;
  38605. /**
  38606. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38607. */
  38608. twoSidedLighting: boolean;
  38609. /**
  38610. * Default configuration related to image processing available in the standard Material.
  38611. */
  38612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38613. /**
  38614. * Gets the image processing configuration used either in this material.
  38615. */
  38616. /**
  38617. * Sets the Default image processing configuration used either in the this material.
  38618. *
  38619. * If sets to null, the scene one is in use.
  38620. */
  38621. imageProcessingConfiguration: ImageProcessingConfiguration;
  38622. /**
  38623. * Keep track of the image processing observer to allow dispose and replace.
  38624. */
  38625. private _imageProcessingObserver;
  38626. /**
  38627. * Attaches a new image processing configuration to the Standard Material.
  38628. * @param configuration
  38629. */
  38630. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38631. /**
  38632. * Gets wether the color curves effect is enabled.
  38633. */
  38634. /**
  38635. * Sets wether the color curves effect is enabled.
  38636. */
  38637. cameraColorCurvesEnabled: boolean;
  38638. /**
  38639. * Gets wether the color grading effect is enabled.
  38640. */
  38641. /**
  38642. * Gets wether the color grading effect is enabled.
  38643. */
  38644. cameraColorGradingEnabled: boolean;
  38645. /**
  38646. * Gets wether tonemapping is enabled or not.
  38647. */
  38648. /**
  38649. * Sets wether tonemapping is enabled or not
  38650. */
  38651. cameraToneMappingEnabled: boolean;
  38652. /**
  38653. * The camera exposure used on this material.
  38654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38655. * This corresponds to a photographic exposure.
  38656. */
  38657. /**
  38658. * The camera exposure used on this material.
  38659. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38660. * This corresponds to a photographic exposure.
  38661. */
  38662. cameraExposure: number;
  38663. /**
  38664. * Gets The camera contrast used on this material.
  38665. */
  38666. /**
  38667. * Sets The camera contrast used on this material.
  38668. */
  38669. cameraContrast: number;
  38670. /**
  38671. * Gets the Color Grading 2D Lookup Texture.
  38672. */
  38673. /**
  38674. * Sets the Color Grading 2D Lookup Texture.
  38675. */
  38676. cameraColorGradingTexture: Nullable<BaseTexture>;
  38677. /**
  38678. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38679. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38680. * 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;
  38681. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38682. */
  38683. /**
  38684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38686. * 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;
  38687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38688. */
  38689. cameraColorCurves: Nullable<ColorCurves>;
  38690. /**
  38691. * Custom callback helping to override the default shader used in the material.
  38692. */
  38693. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38694. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38695. protected _worldViewProjectionMatrix: Matrix;
  38696. protected _globalAmbientColor: Color3;
  38697. protected _useLogarithmicDepth: boolean;
  38698. /**
  38699. * Instantiates a new standard material.
  38700. * This is the default material used in Babylon. It is the best trade off between quality
  38701. * and performances.
  38702. * @see http://doc.babylonjs.com/babylon101/materials
  38703. * @param name Define the name of the material in the scene
  38704. * @param scene Define the scene the material belong to
  38705. */
  38706. constructor(name: string, scene: Scene);
  38707. /**
  38708. * Gets a boolean indicating that current material needs to register RTT
  38709. */
  38710. readonly hasRenderTargetTextures: boolean;
  38711. /**
  38712. * Gets the current class name of the material e.g. "StandardMaterial"
  38713. * Mainly use in serialization.
  38714. * @returns the class name
  38715. */
  38716. getClassName(): string;
  38717. /**
  38718. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38719. * You can try switching to logarithmic depth.
  38720. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38721. */
  38722. useLogarithmicDepth: boolean;
  38723. /**
  38724. * Specifies if the material will require alpha blending
  38725. * @returns a boolean specifying if alpha blending is needed
  38726. */
  38727. needAlphaBlending(): boolean;
  38728. /**
  38729. * Specifies if this material should be rendered in alpha test mode
  38730. * @returns a boolean specifying if an alpha test is needed.
  38731. */
  38732. needAlphaTesting(): boolean;
  38733. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38734. /**
  38735. * Get the texture used for alpha test purpose.
  38736. * @returns the diffuse texture in case of the standard material.
  38737. */
  38738. getAlphaTestTexture(): Nullable<BaseTexture>;
  38739. /**
  38740. * Get if the submesh is ready to be used and all its information available.
  38741. * Child classes can use it to update shaders
  38742. * @param mesh defines the mesh to check
  38743. * @param subMesh defines which submesh to check
  38744. * @param useInstances specifies that instances should be used
  38745. * @returns a boolean indicating that the submesh is ready or not
  38746. */
  38747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38748. /**
  38749. * Builds the material UBO layouts.
  38750. * Used internally during the effect preparation.
  38751. */
  38752. buildUniformLayout(): void;
  38753. /**
  38754. * Unbinds the material from the mesh
  38755. */
  38756. unbind(): void;
  38757. /**
  38758. * Binds the submesh to this material by preparing the effect and shader to draw
  38759. * @param world defines the world transformation matrix
  38760. * @param mesh defines the mesh containing the submesh
  38761. * @param subMesh defines the submesh to bind the material to
  38762. */
  38763. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38764. /**
  38765. * Get the list of animatables in the material.
  38766. * @returns the list of animatables object used in the material
  38767. */
  38768. getAnimatables(): IAnimatable[];
  38769. /**
  38770. * Gets the active textures from the material
  38771. * @returns an array of textures
  38772. */
  38773. getActiveTextures(): BaseTexture[];
  38774. /**
  38775. * Specifies if the material uses a texture
  38776. * @param texture defines the texture to check against the material
  38777. * @returns a boolean specifying if the material uses the texture
  38778. */
  38779. hasTexture(texture: BaseTexture): boolean;
  38780. /**
  38781. * Disposes the material
  38782. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38783. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38784. */
  38785. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38786. /**
  38787. * Makes a duplicate of the material, and gives it a new name
  38788. * @param name defines the new name for the duplicated material
  38789. * @returns the cloned material
  38790. */
  38791. clone(name: string): StandardMaterial;
  38792. /**
  38793. * Serializes this material in a JSON representation
  38794. * @returns the serialized material object
  38795. */
  38796. serialize(): any;
  38797. /**
  38798. * Creates a standard material from parsed material data
  38799. * @param source defines the JSON representation of the material
  38800. * @param scene defines the hosting scene
  38801. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38802. * @returns a new standard material
  38803. */
  38804. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38805. /**
  38806. * Are diffuse textures enabled in the application.
  38807. */
  38808. static DiffuseTextureEnabled: boolean;
  38809. /**
  38810. * Are ambient textures enabled in the application.
  38811. */
  38812. static AmbientTextureEnabled: boolean;
  38813. /**
  38814. * Are opacity textures enabled in the application.
  38815. */
  38816. static OpacityTextureEnabled: boolean;
  38817. /**
  38818. * Are reflection textures enabled in the application.
  38819. */
  38820. static ReflectionTextureEnabled: boolean;
  38821. /**
  38822. * Are emissive textures enabled in the application.
  38823. */
  38824. static EmissiveTextureEnabled: boolean;
  38825. /**
  38826. * Are specular textures enabled in the application.
  38827. */
  38828. static SpecularTextureEnabled: boolean;
  38829. /**
  38830. * Are bump textures enabled in the application.
  38831. */
  38832. static BumpTextureEnabled: boolean;
  38833. /**
  38834. * Are lightmap textures enabled in the application.
  38835. */
  38836. static LightmapTextureEnabled: boolean;
  38837. /**
  38838. * Are refraction textures enabled in the application.
  38839. */
  38840. static RefractionTextureEnabled: boolean;
  38841. /**
  38842. * Are color grading textures enabled in the application.
  38843. */
  38844. static ColorGradingTextureEnabled: boolean;
  38845. /**
  38846. * Are fresnels enabled in the application.
  38847. */
  38848. static FresnelEnabled: boolean;
  38849. }
  38850. }
  38851. declare module BABYLON {
  38852. /**
  38853. * A class extending Texture allowing drawing on a texture
  38854. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38855. */
  38856. export class DynamicTexture extends Texture {
  38857. private _generateMipMaps;
  38858. private _canvas;
  38859. private _context;
  38860. private _engine;
  38861. /**
  38862. * Creates a DynamicTexture
  38863. * @param name defines the name of the texture
  38864. * @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
  38865. * @param scene defines the scene where you want the texture
  38866. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38867. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38868. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38869. */
  38870. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38871. /**
  38872. * Get the current class name of the texture useful for serialization or dynamic coding.
  38873. * @returns "DynamicTexture"
  38874. */
  38875. getClassName(): string;
  38876. /**
  38877. * Gets the current state of canRescale
  38878. */
  38879. readonly canRescale: boolean;
  38880. private _recreate;
  38881. /**
  38882. * Scales the texture
  38883. * @param ratio the scale factor to apply to both width and height
  38884. */
  38885. scale(ratio: number): void;
  38886. /**
  38887. * Resizes the texture
  38888. * @param width the new width
  38889. * @param height the new height
  38890. */
  38891. scaleTo(width: number, height: number): void;
  38892. /**
  38893. * Gets the context of the canvas used by the texture
  38894. * @returns the canvas context of the dynamic texture
  38895. */
  38896. getContext(): CanvasRenderingContext2D;
  38897. /**
  38898. * Clears the texture
  38899. */
  38900. clear(): void;
  38901. /**
  38902. * Updates the texture
  38903. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38904. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38905. */
  38906. update(invertY?: boolean, premulAlpha?: boolean): void;
  38907. /**
  38908. * Draws text onto the texture
  38909. * @param text defines the text to be drawn
  38910. * @param x defines the placement of the text from the left
  38911. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38912. * @param font defines the font to be used with font-style, font-size, font-name
  38913. * @param color defines the color used for the text
  38914. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38915. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38916. * @param update defines whether texture is immediately update (default is true)
  38917. */
  38918. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38919. /**
  38920. * Clones the texture
  38921. * @returns the clone of the texture.
  38922. */
  38923. clone(): DynamicTexture;
  38924. /**
  38925. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38926. * @returns a serialized dynamic texture object
  38927. */
  38928. serialize(): any;
  38929. /** @hidden */
  38930. _rebuild(): void;
  38931. }
  38932. }
  38933. declare module BABYLON {
  38934. /** @hidden */
  38935. export var imageProcessingPixelShader: {
  38936. name: string;
  38937. shader: string;
  38938. };
  38939. }
  38940. declare module BABYLON {
  38941. /**
  38942. * ImageProcessingPostProcess
  38943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38944. */
  38945. export class ImageProcessingPostProcess extends PostProcess {
  38946. /**
  38947. * Default configuration related to image processing available in the PBR Material.
  38948. */
  38949. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38950. /**
  38951. * Gets the image processing configuration used either in this material.
  38952. */
  38953. /**
  38954. * Sets the Default image processing configuration used either in the this material.
  38955. *
  38956. * If sets to null, the scene one is in use.
  38957. */
  38958. imageProcessingConfiguration: ImageProcessingConfiguration;
  38959. /**
  38960. * Keep track of the image processing observer to allow dispose and replace.
  38961. */
  38962. private _imageProcessingObserver;
  38963. /**
  38964. * Attaches a new image processing configuration to the PBR Material.
  38965. * @param configuration
  38966. */
  38967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38968. /**
  38969. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38970. */
  38971. /**
  38972. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38973. */
  38974. colorCurves: Nullable<ColorCurves>;
  38975. /**
  38976. * Gets wether the color curves effect is enabled.
  38977. */
  38978. /**
  38979. * Sets wether the color curves effect is enabled.
  38980. */
  38981. colorCurvesEnabled: boolean;
  38982. /**
  38983. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38984. */
  38985. /**
  38986. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38987. */
  38988. colorGradingTexture: Nullable<BaseTexture>;
  38989. /**
  38990. * Gets wether the color grading effect is enabled.
  38991. */
  38992. /**
  38993. * Gets wether the color grading effect is enabled.
  38994. */
  38995. colorGradingEnabled: boolean;
  38996. /**
  38997. * Gets exposure used in the effect.
  38998. */
  38999. /**
  39000. * Sets exposure used in the effect.
  39001. */
  39002. exposure: number;
  39003. /**
  39004. * Gets wether tonemapping is enabled or not.
  39005. */
  39006. /**
  39007. * Sets wether tonemapping is enabled or not
  39008. */
  39009. toneMappingEnabled: boolean;
  39010. /**
  39011. * Gets the type of tone mapping effect.
  39012. */
  39013. /**
  39014. * Sets the type of tone mapping effect.
  39015. */
  39016. toneMappingType: number;
  39017. /**
  39018. * Gets contrast used in the effect.
  39019. */
  39020. /**
  39021. * Sets contrast used in the effect.
  39022. */
  39023. contrast: number;
  39024. /**
  39025. * Gets Vignette stretch size.
  39026. */
  39027. /**
  39028. * Sets Vignette stretch size.
  39029. */
  39030. vignetteStretch: number;
  39031. /**
  39032. * Gets Vignette centre X Offset.
  39033. */
  39034. /**
  39035. * Sets Vignette centre X Offset.
  39036. */
  39037. vignetteCentreX: number;
  39038. /**
  39039. * Gets Vignette centre Y Offset.
  39040. */
  39041. /**
  39042. * Sets Vignette centre Y Offset.
  39043. */
  39044. vignetteCentreY: number;
  39045. /**
  39046. * Gets Vignette weight or intensity of the vignette effect.
  39047. */
  39048. /**
  39049. * Sets Vignette weight or intensity of the vignette effect.
  39050. */
  39051. vignetteWeight: number;
  39052. /**
  39053. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39054. * if vignetteEnabled is set to true.
  39055. */
  39056. /**
  39057. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39058. * if vignetteEnabled is set to true.
  39059. */
  39060. vignetteColor: Color4;
  39061. /**
  39062. * Gets Camera field of view used by the Vignette effect.
  39063. */
  39064. /**
  39065. * Sets Camera field of view used by the Vignette effect.
  39066. */
  39067. vignetteCameraFov: number;
  39068. /**
  39069. * Gets the vignette blend mode allowing different kind of effect.
  39070. */
  39071. /**
  39072. * Sets the vignette blend mode allowing different kind of effect.
  39073. */
  39074. vignetteBlendMode: number;
  39075. /**
  39076. * Gets wether the vignette effect is enabled.
  39077. */
  39078. /**
  39079. * Sets wether the vignette effect is enabled.
  39080. */
  39081. vignetteEnabled: boolean;
  39082. private _fromLinearSpace;
  39083. /**
  39084. * Gets wether the input of the processing is in Gamma or Linear Space.
  39085. */
  39086. /**
  39087. * Sets wether the input of the processing is in Gamma or Linear Space.
  39088. */
  39089. fromLinearSpace: boolean;
  39090. /**
  39091. * Defines cache preventing GC.
  39092. */
  39093. private _defines;
  39094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39095. /**
  39096. * "ImageProcessingPostProcess"
  39097. * @returns "ImageProcessingPostProcess"
  39098. */
  39099. getClassName(): string;
  39100. protected _updateParameters(): void;
  39101. dispose(camera?: Camera): void;
  39102. }
  39103. }
  39104. declare module BABYLON {
  39105. /**
  39106. * Class containing static functions to help procedurally build meshes
  39107. */
  39108. export class GroundBuilder {
  39109. /**
  39110. * Creates a ground mesh
  39111. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39112. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39114. * @param name defines the name of the mesh
  39115. * @param options defines the options used to create the mesh
  39116. * @param scene defines the hosting scene
  39117. * @returns the ground mesh
  39118. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39119. */
  39120. static CreateGround(name: string, options: {
  39121. width?: number;
  39122. height?: number;
  39123. subdivisions?: number;
  39124. subdivisionsX?: number;
  39125. subdivisionsY?: number;
  39126. updatable?: boolean;
  39127. }, scene: any): Mesh;
  39128. /**
  39129. * Creates a tiled ground mesh
  39130. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39131. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39132. * * 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
  39133. * * 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
  39134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39135. * @param name defines the name of the mesh
  39136. * @param options defines the options used to create the mesh
  39137. * @param scene defines the hosting scene
  39138. * @returns the tiled ground mesh
  39139. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39140. */
  39141. static CreateTiledGround(name: string, options: {
  39142. xmin: number;
  39143. zmin: number;
  39144. xmax: number;
  39145. zmax: number;
  39146. subdivisions?: {
  39147. w: number;
  39148. h: number;
  39149. };
  39150. precision?: {
  39151. w: number;
  39152. h: number;
  39153. };
  39154. updatable?: boolean;
  39155. }, scene: Scene): Mesh;
  39156. /**
  39157. * Creates a ground mesh from a height map
  39158. * * The parameter `url` sets the URL of the height map image resource.
  39159. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39160. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39161. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39162. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39163. * * 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.
  39164. * * 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).
  39165. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39167. * @param name defines the name of the mesh
  39168. * @param url defines the url to the height map
  39169. * @param options defines the options used to create the mesh
  39170. * @param scene defines the hosting scene
  39171. * @returns the ground mesh
  39172. * @see https://doc.babylonjs.com/babylon101/height_map
  39173. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39174. */
  39175. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39176. width?: number;
  39177. height?: number;
  39178. subdivisions?: number;
  39179. minHeight?: number;
  39180. maxHeight?: number;
  39181. colorFilter?: Color3;
  39182. alphaFilter?: number;
  39183. updatable?: boolean;
  39184. onReady?: (mesh: GroundMesh) => void;
  39185. }, scene: Scene): GroundMesh;
  39186. }
  39187. }
  39188. declare module BABYLON {
  39189. /**
  39190. * Class containing static functions to help procedurally build meshes
  39191. */
  39192. export class TorusBuilder {
  39193. /**
  39194. * Creates a torus mesh
  39195. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39196. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39197. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39199. * * 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
  39200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39201. * @param name defines the name of the mesh
  39202. * @param options defines the options used to create the mesh
  39203. * @param scene defines the hosting scene
  39204. * @returns the torus mesh
  39205. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39206. */
  39207. static CreateTorus(name: string, options: {
  39208. diameter?: number;
  39209. thickness?: number;
  39210. tessellation?: number;
  39211. updatable?: boolean;
  39212. sideOrientation?: number;
  39213. frontUVs?: Vector4;
  39214. backUVs?: Vector4;
  39215. }, scene: any): Mesh;
  39216. }
  39217. }
  39218. declare module BABYLON {
  39219. /**
  39220. * Class containing static functions to help procedurally build meshes
  39221. */
  39222. export class CylinderBuilder {
  39223. /**
  39224. * Creates a cylinder or a cone mesh
  39225. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39226. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39227. * * 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.
  39228. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39229. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39230. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39231. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39232. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39233. * * 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).
  39234. * * 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
  39235. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39236. * * 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
  39237. * * 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.
  39238. * * If `enclose` is false, a ring surface is one element.
  39239. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39240. * * 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
  39241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39242. * * 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
  39243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39244. * @param name defines the name of the mesh
  39245. * @param options defines the options used to create the mesh
  39246. * @param scene defines the hosting scene
  39247. * @returns the cylinder mesh
  39248. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39249. */
  39250. static CreateCylinder(name: string, options: {
  39251. height?: number;
  39252. diameterTop?: number;
  39253. diameterBottom?: number;
  39254. diameter?: number;
  39255. tessellation?: number;
  39256. subdivisions?: number;
  39257. arc?: number;
  39258. faceColors?: Color4[];
  39259. faceUV?: Vector4[];
  39260. updatable?: boolean;
  39261. hasRings?: boolean;
  39262. enclose?: boolean;
  39263. sideOrientation?: number;
  39264. frontUVs?: Vector4;
  39265. backUVs?: Vector4;
  39266. }, scene: any): Mesh;
  39267. }
  39268. }
  39269. declare module BABYLON {
  39270. /**
  39271. * Manager for handling gamepads
  39272. */
  39273. export class GamepadManager {
  39274. private _scene?;
  39275. private _babylonGamepads;
  39276. private _oneGamepadConnected;
  39277. /** @hidden */
  39278. _isMonitoring: boolean;
  39279. private _gamepadEventSupported;
  39280. private _gamepadSupport;
  39281. /**
  39282. * observable to be triggered when the gamepad controller has been connected
  39283. */
  39284. onGamepadConnectedObservable: Observable<Gamepad>;
  39285. /**
  39286. * observable to be triggered when the gamepad controller has been disconnected
  39287. */
  39288. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39289. private _onGamepadConnectedEvent;
  39290. private _onGamepadDisconnectedEvent;
  39291. /**
  39292. * Initializes the gamepad manager
  39293. * @param _scene BabylonJS scene
  39294. */
  39295. constructor(_scene?: Scene | undefined);
  39296. /**
  39297. * The gamepads in the game pad manager
  39298. */
  39299. readonly gamepads: Gamepad[];
  39300. /**
  39301. * Get the gamepad controllers based on type
  39302. * @param type The type of gamepad controller
  39303. * @returns Nullable gamepad
  39304. */
  39305. getGamepadByType(type?: number): Nullable<Gamepad>;
  39306. /**
  39307. * Disposes the gamepad manager
  39308. */
  39309. dispose(): void;
  39310. private _addNewGamepad;
  39311. private _startMonitoringGamepads;
  39312. private _stopMonitoringGamepads;
  39313. /** @hidden */
  39314. _checkGamepadsStatus(): void;
  39315. private _updateGamepadObjects;
  39316. }
  39317. }
  39318. declare module BABYLON {
  39319. interface Scene {
  39320. /** @hidden */
  39321. _gamepadManager: Nullable<GamepadManager>;
  39322. /**
  39323. * Gets the gamepad manager associated with the scene
  39324. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39325. */
  39326. gamepadManager: GamepadManager;
  39327. }
  39328. /**
  39329. * Interface representing a free camera inputs manager
  39330. */
  39331. interface FreeCameraInputsManager {
  39332. /**
  39333. * Adds gamepad input support to the FreeCameraInputsManager.
  39334. * @returns the FreeCameraInputsManager
  39335. */
  39336. addGamepad(): FreeCameraInputsManager;
  39337. }
  39338. /**
  39339. * Interface representing an arc rotate camera inputs manager
  39340. */
  39341. interface ArcRotateCameraInputsManager {
  39342. /**
  39343. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39344. * @returns the camera inputs manager
  39345. */
  39346. addGamepad(): ArcRotateCameraInputsManager;
  39347. }
  39348. /**
  39349. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39350. */
  39351. export class GamepadSystemSceneComponent implements ISceneComponent {
  39352. /**
  39353. * The component name helpfull to identify the component in the list of scene components.
  39354. */
  39355. readonly name: string;
  39356. /**
  39357. * The scene the component belongs to.
  39358. */
  39359. scene: Scene;
  39360. /**
  39361. * Creates a new instance of the component for the given scene
  39362. * @param scene Defines the scene to register the component in
  39363. */
  39364. constructor(scene: Scene);
  39365. /**
  39366. * Registers the component in a given scene
  39367. */
  39368. register(): void;
  39369. /**
  39370. * Rebuilds the elements related to this component in case of
  39371. * context lost for instance.
  39372. */
  39373. rebuild(): void;
  39374. /**
  39375. * Disposes the component and the associated ressources
  39376. */
  39377. dispose(): void;
  39378. private _beforeCameraUpdate;
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * Options to modify the vr teleportation behavior.
  39384. */
  39385. export interface VRTeleportationOptions {
  39386. /**
  39387. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39388. */
  39389. floorMeshName?: string;
  39390. /**
  39391. * A list of meshes to be used as the teleportation floor. (default: empty)
  39392. */
  39393. floorMeshes?: Mesh[];
  39394. }
  39395. /**
  39396. * Options to modify the vr experience helper's behavior.
  39397. */
  39398. export interface VRExperienceHelperOptions extends WebVROptions {
  39399. /**
  39400. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39401. */
  39402. createDeviceOrientationCamera?: boolean;
  39403. /**
  39404. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39405. */
  39406. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39407. /**
  39408. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39409. */
  39410. laserToggle?: boolean;
  39411. /**
  39412. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39413. */
  39414. floorMeshes?: Mesh[];
  39415. /**
  39416. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39417. */
  39418. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39419. }
  39420. /**
  39421. * Event containing information after VR has been entered
  39422. */
  39423. export class OnAfterEnteringVRObservableEvent {
  39424. /**
  39425. * If entering vr was successful
  39426. */
  39427. success: boolean;
  39428. }
  39429. /**
  39430. * Helps to quickly add VR support to an existing scene.
  39431. * See http://doc.babylonjs.com/how_to/webvr_helper
  39432. */
  39433. export class VRExperienceHelper {
  39434. /** Options to modify the vr experience helper's behavior. */
  39435. webVROptions: VRExperienceHelperOptions;
  39436. private _scene;
  39437. private _position;
  39438. private _btnVR;
  39439. private _btnVRDisplayed;
  39440. private _webVRsupported;
  39441. private _webVRready;
  39442. private _webVRrequesting;
  39443. private _webVRpresenting;
  39444. private _hasEnteredVR;
  39445. private _fullscreenVRpresenting;
  39446. private _canvas;
  39447. private _webVRCamera;
  39448. private _vrDeviceOrientationCamera;
  39449. private _deviceOrientationCamera;
  39450. private _existingCamera;
  39451. private _onKeyDown;
  39452. private _onVrDisplayPresentChange;
  39453. private _onVRDisplayChanged;
  39454. private _onVRRequestPresentStart;
  39455. private _onVRRequestPresentComplete;
  39456. /**
  39457. * Observable raised right before entering VR.
  39458. */
  39459. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39460. /**
  39461. * Observable raised when entering VR has completed.
  39462. */
  39463. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39464. /**
  39465. * Observable raised when exiting VR.
  39466. */
  39467. onExitingVRObservable: Observable<VRExperienceHelper>;
  39468. /**
  39469. * Observable raised when controller mesh is loaded.
  39470. */
  39471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39472. /** Return this.onEnteringVRObservable
  39473. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39474. */
  39475. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39476. /** Return this.onExitingVRObservable
  39477. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39478. */
  39479. readonly onExitingVR: Observable<VRExperienceHelper>;
  39480. /** Return this.onControllerMeshLoadedObservable
  39481. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39482. */
  39483. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39484. private _rayLength;
  39485. private _useCustomVRButton;
  39486. private _teleportationRequested;
  39487. private _teleportActive;
  39488. private _floorMeshName;
  39489. private _floorMeshesCollection;
  39490. private _rotationAllowed;
  39491. private _teleportBackwardsVector;
  39492. private _teleportationTarget;
  39493. private _isDefaultTeleportationTarget;
  39494. private _postProcessMove;
  39495. private _teleportationFillColor;
  39496. private _teleportationBorderColor;
  39497. private _rotationAngle;
  39498. private _haloCenter;
  39499. private _cameraGazer;
  39500. private _padSensibilityUp;
  39501. private _padSensibilityDown;
  39502. private _leftController;
  39503. private _rightController;
  39504. /**
  39505. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39506. */
  39507. onNewMeshSelected: Observable<AbstractMesh>;
  39508. /**
  39509. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39510. */
  39511. onNewMeshPicked: Observable<PickingInfo>;
  39512. private _circleEase;
  39513. /**
  39514. * Observable raised before camera teleportation
  39515. */
  39516. onBeforeCameraTeleport: Observable<Vector3>;
  39517. /**
  39518. * Observable raised after camera teleportation
  39519. */
  39520. onAfterCameraTeleport: Observable<Vector3>;
  39521. /**
  39522. * Observable raised when current selected mesh gets unselected
  39523. */
  39524. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39525. private _raySelectionPredicate;
  39526. /**
  39527. * To be optionaly changed by user to define custom ray selection
  39528. */
  39529. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39530. /**
  39531. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39532. */
  39533. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39534. /**
  39535. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39536. */
  39537. teleportationEnabled: boolean;
  39538. private _defaultHeight;
  39539. private _teleportationInitialized;
  39540. private _interactionsEnabled;
  39541. private _interactionsRequested;
  39542. private _displayGaze;
  39543. private _displayLaserPointer;
  39544. /**
  39545. * The mesh used to display where the user is going to teleport.
  39546. */
  39547. /**
  39548. * Sets the mesh to be used to display where the user is going to teleport.
  39549. */
  39550. teleportationTarget: Mesh;
  39551. /**
  39552. * 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
  39553. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39554. * See http://doc.babylonjs.com/resources/baking_transformations
  39555. */
  39556. gazeTrackerMesh: Mesh;
  39557. /**
  39558. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39559. */
  39560. updateGazeTrackerScale: boolean;
  39561. /**
  39562. * If the gaze trackers color should be updated when selecting meshes
  39563. */
  39564. updateGazeTrackerColor: boolean;
  39565. /**
  39566. * The gaze tracking mesh corresponding to the left controller
  39567. */
  39568. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39569. /**
  39570. * The gaze tracking mesh corresponding to the right controller
  39571. */
  39572. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39573. /**
  39574. * If the ray of the gaze should be displayed.
  39575. */
  39576. /**
  39577. * Sets if the ray of the gaze should be displayed.
  39578. */
  39579. displayGaze: boolean;
  39580. /**
  39581. * If the ray of the LaserPointer should be displayed.
  39582. */
  39583. /**
  39584. * Sets if the ray of the LaserPointer should be displayed.
  39585. */
  39586. displayLaserPointer: boolean;
  39587. /**
  39588. * The deviceOrientationCamera used as the camera when not in VR.
  39589. */
  39590. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39591. /**
  39592. * Based on the current WebVR support, returns the current VR camera used.
  39593. */
  39594. readonly currentVRCamera: Nullable<Camera>;
  39595. /**
  39596. * The webVRCamera which is used when in VR.
  39597. */
  39598. readonly webVRCamera: WebVRFreeCamera;
  39599. /**
  39600. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39601. */
  39602. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39603. private readonly _teleportationRequestInitiated;
  39604. /**
  39605. * Defines wether or not Pointer lock should be requested when switching to
  39606. * full screen.
  39607. */
  39608. requestPointerLockOnFullScreen: boolean;
  39609. /**
  39610. * Instantiates a VRExperienceHelper.
  39611. * Helps to quickly add VR support to an existing scene.
  39612. * @param scene The scene the VRExperienceHelper belongs to.
  39613. * @param webVROptions Options to modify the vr experience helper's behavior.
  39614. */
  39615. constructor(scene: Scene,
  39616. /** Options to modify the vr experience helper's behavior. */
  39617. webVROptions?: VRExperienceHelperOptions);
  39618. private _onDefaultMeshLoaded;
  39619. private _onResize;
  39620. private _onFullscreenChange;
  39621. /**
  39622. * Gets a value indicating if we are currently in VR mode.
  39623. */
  39624. readonly isInVRMode: boolean;
  39625. private onVrDisplayPresentChange;
  39626. private onVRDisplayChanged;
  39627. private moveButtonToBottomRight;
  39628. private displayVRButton;
  39629. private updateButtonVisibility;
  39630. private _cachedAngularSensibility;
  39631. /**
  39632. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39633. * Otherwise, will use the fullscreen API.
  39634. */
  39635. enterVR(): void;
  39636. /**
  39637. * Attempt to exit VR, or fullscreen.
  39638. */
  39639. exitVR(): void;
  39640. /**
  39641. * The position of the vr experience helper.
  39642. */
  39643. /**
  39644. * Sets the position of the vr experience helper.
  39645. */
  39646. position: Vector3;
  39647. /**
  39648. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39649. */
  39650. enableInteractions(): void;
  39651. private readonly _noControllerIsActive;
  39652. private beforeRender;
  39653. private _isTeleportationFloor;
  39654. /**
  39655. * Adds a floor mesh to be used for teleportation.
  39656. * @param floorMesh the mesh to be used for teleportation.
  39657. */
  39658. addFloorMesh(floorMesh: Mesh): void;
  39659. /**
  39660. * Removes a floor mesh from being used for teleportation.
  39661. * @param floorMesh the mesh to be removed.
  39662. */
  39663. removeFloorMesh(floorMesh: Mesh): void;
  39664. /**
  39665. * Enables interactions and teleportation using the VR controllers and gaze.
  39666. * @param vrTeleportationOptions options to modify teleportation behavior.
  39667. */
  39668. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39669. private _onNewGamepadConnected;
  39670. private _tryEnableInteractionOnController;
  39671. private _onNewGamepadDisconnected;
  39672. private _enableInteractionOnController;
  39673. private _checkTeleportWithRay;
  39674. private _checkRotate;
  39675. private _checkTeleportBackwards;
  39676. private _enableTeleportationOnController;
  39677. private _createTeleportationCircles;
  39678. private _displayTeleportationTarget;
  39679. private _hideTeleportationTarget;
  39680. private _rotateCamera;
  39681. private _moveTeleportationSelectorTo;
  39682. private _workingVector;
  39683. private _workingQuaternion;
  39684. private _workingMatrix;
  39685. /**
  39686. * Teleports the users feet to the desired location
  39687. * @param location The location where the user's feet should be placed
  39688. */
  39689. teleportCamera(location: Vector3): void;
  39690. private _convertNormalToDirectionOfRay;
  39691. private _castRayAndSelectObject;
  39692. private _notifySelectedMeshUnselected;
  39693. /**
  39694. * Sets the color of the laser ray from the vr controllers.
  39695. * @param color new color for the ray.
  39696. */
  39697. changeLaserColor(color: Color3): void;
  39698. /**
  39699. * Sets the color of the ray from the vr headsets gaze.
  39700. * @param color new color for the ray.
  39701. */
  39702. changeGazeColor(color: Color3): void;
  39703. /**
  39704. * Exits VR and disposes of the vr experience helper
  39705. */
  39706. dispose(): void;
  39707. /**
  39708. * Gets the name of the VRExperienceHelper class
  39709. * @returns "VRExperienceHelper"
  39710. */
  39711. getClassName(): string;
  39712. }
  39713. }
  39714. declare module BABYLON {
  39715. /**
  39716. * Manages an XRSession
  39717. * @see https://doc.babylonjs.com/how_to/webxr
  39718. */
  39719. export class WebXRSessionManager implements IDisposable {
  39720. private scene;
  39721. /**
  39722. * Fires every time a new xrFrame arrives which can be used to update the camera
  39723. */
  39724. onXRFrameObservable: Observable<any>;
  39725. /**
  39726. * Fires when the xr session is ended either by the device or manually done
  39727. */
  39728. onXRSessionEnded: Observable<any>;
  39729. /** @hidden */
  39730. _xrSession: XRSession;
  39731. /** @hidden */
  39732. _frameOfReference: XRFrameOfReference;
  39733. /** @hidden */
  39734. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39735. /** @hidden */
  39736. _currentXRFrame: Nullable<XRFrame>;
  39737. private _xrNavigator;
  39738. private _xrDevice;
  39739. private _tmpMatrix;
  39740. /**
  39741. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39742. * @param scene The scene which the session should be created for
  39743. */
  39744. constructor(scene: Scene);
  39745. /**
  39746. * Initializes the manager
  39747. * After initialization enterXR can be called to start an XR session
  39748. * @returns Promise which resolves after it is initialized
  39749. */
  39750. initializeAsync(): Promise<void>;
  39751. /**
  39752. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39753. * @param sessionCreationOptions xr options to create the session with
  39754. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39755. * @returns Promise which resolves after it enters XR
  39756. */
  39757. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39758. /**
  39759. * Stops the xrSession and restores the renderloop
  39760. * @returns Promise which resolves after it exits XR
  39761. */
  39762. exitXRAsync(): Promise<void>;
  39763. /**
  39764. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39765. * @param ray ray to cast into the environment
  39766. * @returns Promise which resolves with a collision point in the environment if it exists
  39767. */
  39768. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39769. /**
  39770. * Checks if a session would be supported for the creation options specified
  39771. * @param options creation options to check if they are supported
  39772. * @returns true if supported
  39773. */
  39774. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39775. /**
  39776. * @hidden
  39777. * Converts the render layer of xrSession to a render target
  39778. * @param session session to create render target for
  39779. * @param scene scene the new render target should be created for
  39780. */
  39781. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39782. /**
  39783. * Disposes of the session manager
  39784. */
  39785. dispose(): void;
  39786. }
  39787. }
  39788. declare module BABYLON {
  39789. /**
  39790. * WebXR Camera which holds the views for the xrSession
  39791. * @see https://doc.babylonjs.com/how_to/webxr
  39792. */
  39793. export class WebXRCamera extends FreeCamera {
  39794. private static _TmpMatrix;
  39795. /**
  39796. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39797. * @param name the name of the camera
  39798. * @param scene the scene to add the camera to
  39799. */
  39800. constructor(name: string, scene: Scene);
  39801. private _updateNumberOfRigCameras;
  39802. /** @hidden */
  39803. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39804. /**
  39805. * Updates the cameras position from the current pose information of the XR session
  39806. * @param xrSessionManager the session containing pose information
  39807. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39808. */
  39809. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39810. }
  39811. }
  39812. declare module BABYLON {
  39813. /**
  39814. * States of the webXR experience
  39815. */
  39816. export enum WebXRState {
  39817. /**
  39818. * Transitioning to being in XR mode
  39819. */
  39820. ENTERING_XR = 0,
  39821. /**
  39822. * Transitioning to non XR mode
  39823. */
  39824. EXITING_XR = 1,
  39825. /**
  39826. * In XR mode and presenting
  39827. */
  39828. IN_XR = 2,
  39829. /**
  39830. * Not entered XR mode
  39831. */
  39832. NOT_IN_XR = 3
  39833. }
  39834. /**
  39835. * Helper class used to enable XR
  39836. * @see https://doc.babylonjs.com/how_to/webxr
  39837. */
  39838. export class WebXRExperienceHelper implements IDisposable {
  39839. private scene;
  39840. /**
  39841. * 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
  39842. */
  39843. container: AbstractMesh;
  39844. /**
  39845. * Camera used to render xr content
  39846. */
  39847. camera: WebXRCamera;
  39848. /**
  39849. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39850. */
  39851. state: WebXRState;
  39852. private _setState;
  39853. private static _TmpVector;
  39854. /**
  39855. * Fires when the state of the experience helper has changed
  39856. */
  39857. onStateChangedObservable: Observable<WebXRState>;
  39858. /** @hidden */
  39859. _sessionManager: WebXRSessionManager;
  39860. private _nonVRCamera;
  39861. private _originalSceneAutoClear;
  39862. private _supported;
  39863. /**
  39864. * Creates the experience helper
  39865. * @param scene the scene to attach the experience helper to
  39866. * @returns a promise for the experience helper
  39867. */
  39868. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39869. /**
  39870. * Creates a WebXRExperienceHelper
  39871. * @param scene The scene the helper should be created in
  39872. */
  39873. private constructor();
  39874. /**
  39875. * Exits XR mode and returns the scene to its original state
  39876. * @returns promise that resolves after xr mode has exited
  39877. */
  39878. exitXRAsync(): Promise<void>;
  39879. /**
  39880. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39881. * @param sessionCreationOptions options for the XR session
  39882. * @param frameOfReference frame of reference of the XR session
  39883. * @returns promise that resolves after xr mode has entered
  39884. */
  39885. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39886. /**
  39887. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39888. * @param ray ray to cast into the environment
  39889. * @returns Promise which resolves with a collision point in the environment if it exists
  39890. */
  39891. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39892. /**
  39893. * Updates the global position of the camera by moving the camera's container
  39894. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39895. * @param position The desired global position of the camera
  39896. */
  39897. setPositionOfCameraUsingContainer(position: Vector3): void;
  39898. /**
  39899. * Rotates the xr camera by rotating the camera's container around the camera's position
  39900. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39901. * @param rotation the desired quaternion rotation to apply to the camera
  39902. */
  39903. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39904. /**
  39905. * Checks if the creation options are supported by the xr session
  39906. * @param options creation options
  39907. * @returns true if supported
  39908. */
  39909. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39910. /**
  39911. * Disposes of the experience helper
  39912. */
  39913. dispose(): void;
  39914. }
  39915. }
  39916. declare module BABYLON {
  39917. /**
  39918. * Button which can be used to enter a different mode of XR
  39919. */
  39920. export class WebXREnterExitUIButton {
  39921. /** button element */
  39922. element: HTMLElement;
  39923. /** XR initialization options for the button */
  39924. initializationOptions: XRSessionCreationOptions;
  39925. /**
  39926. * Creates a WebXREnterExitUIButton
  39927. * @param element button element
  39928. * @param initializationOptions XR initialization options for the button
  39929. */
  39930. constructor(
  39931. /** button element */
  39932. element: HTMLElement,
  39933. /** XR initialization options for the button */
  39934. initializationOptions: XRSessionCreationOptions);
  39935. /**
  39936. * Overwritable function which can be used to update the button's visuals when the state changes
  39937. * @param activeButton the current active button in the UI
  39938. */
  39939. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39940. }
  39941. /**
  39942. * Options to create the webXR UI
  39943. */
  39944. export class WebXREnterExitUIOptions {
  39945. /**
  39946. * Context to enter xr with
  39947. */
  39948. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39949. /**
  39950. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39951. */
  39952. customButtons?: Array<WebXREnterExitUIButton>;
  39953. }
  39954. /**
  39955. * UI to allow the user to enter/exit XR mode
  39956. */
  39957. export class WebXREnterExitUI implements IDisposable {
  39958. private scene;
  39959. private _overlay;
  39960. private _buttons;
  39961. private _activeButton;
  39962. /**
  39963. * Fired every time the active button is changed.
  39964. *
  39965. * When xr is entered via a button that launches xr that button will be the callback parameter
  39966. *
  39967. * When exiting xr the callback parameter will be null)
  39968. */
  39969. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39970. /**
  39971. * Creates UI to allow the user to enter/exit XR mode
  39972. * @param scene the scene to add the ui to
  39973. * @param helper the xr experience helper to enter/exit xr with
  39974. * @param options options to configure the UI
  39975. * @returns the created ui
  39976. */
  39977. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39978. private constructor();
  39979. private _updateButtons;
  39980. /**
  39981. * Disposes of the object
  39982. */
  39983. dispose(): void;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Represents an XR input
  39989. */
  39990. export class WebXRController {
  39991. /**
  39992. * 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
  39993. */
  39994. grip?: AbstractMesh;
  39995. /**
  39996. * Pointer which can be used to select objects or attach a visible laser to
  39997. */
  39998. pointer: AbstractMesh;
  39999. /**
  40000. * Creates the controller
  40001. * @see https://doc.babylonjs.com/how_to/webxr
  40002. * @param scene the scene which the controller should be associated to
  40003. */
  40004. constructor(scene: Scene);
  40005. /**
  40006. * Disposes of the object
  40007. */
  40008. dispose(): void;
  40009. }
  40010. /**
  40011. * XR input used to track XR inputs such as controllers/rays
  40012. */
  40013. export class WebXRInput implements IDisposable {
  40014. private helper;
  40015. /**
  40016. * XR controllers being tracked
  40017. */
  40018. controllers: Array<WebXRController>;
  40019. private _tmpMatrix;
  40020. private _frameObserver;
  40021. /**
  40022. * Initializes the WebXRInput
  40023. * @param helper experience helper which the input should be created for
  40024. */
  40025. constructor(helper: WebXRExperienceHelper);
  40026. /**
  40027. * Disposes of the object
  40028. */
  40029. dispose(): void;
  40030. }
  40031. }
  40032. declare module BABYLON {
  40033. /**
  40034. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40035. */
  40036. export class WebXRManagedOutputCanvas implements IDisposable {
  40037. private _canvas;
  40038. /**
  40039. * xrpresent context of the canvas which can be used to display/mirror xr content
  40040. */
  40041. canvasContext: Nullable<WebGLRenderingContext>;
  40042. /**
  40043. * Initializes the canvas to be added/removed upon entering/exiting xr
  40044. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40045. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40046. */
  40047. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40048. /**
  40049. * Disposes of the object
  40050. */
  40051. dispose(): void;
  40052. private _setManagedOutputCanvas;
  40053. private _addCanvas;
  40054. private _removeCanvas;
  40055. }
  40056. }
  40057. declare module BABYLON {
  40058. /**
  40059. * Contains an array of blocks representing the octree
  40060. */
  40061. export interface IOctreeContainer<T> {
  40062. /**
  40063. * Blocks within the octree
  40064. */
  40065. blocks: Array<OctreeBlock<T>>;
  40066. }
  40067. /**
  40068. * Class used to store a cell in an octree
  40069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40070. */
  40071. export class OctreeBlock<T> {
  40072. /**
  40073. * Gets the content of the current block
  40074. */
  40075. entries: T[];
  40076. /**
  40077. * Gets the list of block children
  40078. */
  40079. blocks: Array<OctreeBlock<T>>;
  40080. private _depth;
  40081. private _maxDepth;
  40082. private _capacity;
  40083. private _minPoint;
  40084. private _maxPoint;
  40085. private _boundingVectors;
  40086. private _creationFunc;
  40087. /**
  40088. * Creates a new block
  40089. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40090. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40091. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40092. * @param depth defines the current depth of this block in the octree
  40093. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40094. * @param creationFunc defines a callback to call when an element is added to the block
  40095. */
  40096. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40097. /**
  40098. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40099. */
  40100. readonly capacity: number;
  40101. /**
  40102. * Gets the minimum vector (in world space) of the block's bounding box
  40103. */
  40104. readonly minPoint: Vector3;
  40105. /**
  40106. * Gets the maximum vector (in world space) of the block's bounding box
  40107. */
  40108. readonly maxPoint: Vector3;
  40109. /**
  40110. * Add a new element to this block
  40111. * @param entry defines the element to add
  40112. */
  40113. addEntry(entry: T): void;
  40114. /**
  40115. * Remove an element from this block
  40116. * @param entry defines the element to remove
  40117. */
  40118. removeEntry(entry: T): void;
  40119. /**
  40120. * Add an array of elements to this block
  40121. * @param entries defines the array of elements to add
  40122. */
  40123. addEntries(entries: T[]): void;
  40124. /**
  40125. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40126. * @param frustumPlanes defines the frustum planes to test
  40127. * @param selection defines the array to store current content if selection is positive
  40128. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40129. */
  40130. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40131. /**
  40132. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40133. * @param sphereCenter defines the bounding sphere center
  40134. * @param sphereRadius defines the bounding sphere radius
  40135. * @param selection defines the array to store current content if selection is positive
  40136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40137. */
  40138. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40139. /**
  40140. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40141. * @param ray defines the ray to test with
  40142. * @param selection defines the array to store current content if selection is positive
  40143. */
  40144. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40145. /**
  40146. * Subdivide the content into child blocks (this block will then be empty)
  40147. */
  40148. createInnerBlocks(): void;
  40149. /**
  40150. * @hidden
  40151. */
  40152. 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;
  40153. }
  40154. }
  40155. declare module BABYLON {
  40156. /**
  40157. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40158. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40159. */
  40160. export class Octree<T> {
  40161. /** 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.) */
  40162. maxDepth: number;
  40163. /**
  40164. * Blocks within the octree containing objects
  40165. */
  40166. blocks: Array<OctreeBlock<T>>;
  40167. /**
  40168. * Content stored in the octree
  40169. */
  40170. dynamicContent: T[];
  40171. private _maxBlockCapacity;
  40172. private _selectionContent;
  40173. private _creationFunc;
  40174. /**
  40175. * Creates a octree
  40176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40177. * @param creationFunc function to be used to instatiate the octree
  40178. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40179. * @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.)
  40180. */
  40181. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40182. /** 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.) */
  40183. maxDepth?: number);
  40184. /**
  40185. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40186. * @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);
  40187. * @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);
  40188. * @param entries meshes to be added to the octree blocks
  40189. */
  40190. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40191. /**
  40192. * Adds a mesh to the octree
  40193. * @param entry Mesh to add to the octree
  40194. */
  40195. addMesh(entry: T): void;
  40196. /**
  40197. * Remove an element from the octree
  40198. * @param entry defines the element to remove
  40199. */
  40200. removeMesh(entry: T): void;
  40201. /**
  40202. * Selects an array of meshes within the frustum
  40203. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40204. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40205. * @returns array of meshes within the frustum
  40206. */
  40207. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40208. /**
  40209. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40210. * @param sphereCenter defines the bounding sphere center
  40211. * @param sphereRadius defines the bounding sphere radius
  40212. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40213. * @returns an array of objects that intersect the sphere
  40214. */
  40215. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40216. /**
  40217. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40218. * @param ray defines the ray to test with
  40219. * @returns array of intersected objects
  40220. */
  40221. intersectsRay(ray: Ray): SmartArray<T>;
  40222. /**
  40223. * Adds a mesh into the octree block if it intersects the block
  40224. */
  40225. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40226. /**
  40227. * Adds a submesh into the octree block if it intersects the block
  40228. */
  40229. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40230. }
  40231. }
  40232. declare module BABYLON {
  40233. interface Scene {
  40234. /**
  40235. * @hidden
  40236. * Backing Filed
  40237. */
  40238. _selectionOctree: Octree<AbstractMesh>;
  40239. /**
  40240. * Gets the octree used to boost mesh selection (picking)
  40241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40242. */
  40243. selectionOctree: Octree<AbstractMesh>;
  40244. /**
  40245. * Creates or updates the octree used to boost selection (picking)
  40246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40247. * @param maxCapacity defines the maximum capacity per leaf
  40248. * @param maxDepth defines the maximum depth of the octree
  40249. * @returns an octree of AbstractMesh
  40250. */
  40251. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40252. }
  40253. interface AbstractMesh {
  40254. /**
  40255. * @hidden
  40256. * Backing Field
  40257. */
  40258. _submeshesOctree: Octree<SubMesh>;
  40259. /**
  40260. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40261. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40262. * @param maxCapacity defines the maximum size of each block (64 by default)
  40263. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40264. * @returns the new octree
  40265. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40267. */
  40268. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40269. }
  40270. /**
  40271. * Defines the octree scene component responsible to manage any octrees
  40272. * in a given scene.
  40273. */
  40274. export class OctreeSceneComponent {
  40275. /**
  40276. * The component name helpfull to identify the component in the list of scene components.
  40277. */
  40278. readonly name: string;
  40279. /**
  40280. * The scene the component belongs to.
  40281. */
  40282. scene: Scene;
  40283. /**
  40284. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40285. */
  40286. readonly checksIsEnabled: boolean;
  40287. /**
  40288. * Creates a new instance of the component for the given scene
  40289. * @param scene Defines the scene to register the component in
  40290. */
  40291. constructor(scene: Scene);
  40292. /**
  40293. * Registers the component in a given scene
  40294. */
  40295. register(): void;
  40296. /**
  40297. * Return the list of active meshes
  40298. * @returns the list of active meshes
  40299. */
  40300. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40301. /**
  40302. * Return the list of active sub meshes
  40303. * @param mesh The mesh to get the candidates sub meshes from
  40304. * @returns the list of active sub meshes
  40305. */
  40306. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40307. private _tempRay;
  40308. /**
  40309. * Return the list of sub meshes intersecting with a given local ray
  40310. * @param mesh defines the mesh to find the submesh for
  40311. * @param localRay defines the ray in local space
  40312. * @returns the list of intersecting sub meshes
  40313. */
  40314. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40315. /**
  40316. * Return the list of sub meshes colliding with a collider
  40317. * @param mesh defines the mesh to find the submesh for
  40318. * @param collider defines the collider to evaluate the collision against
  40319. * @returns the list of colliding sub meshes
  40320. */
  40321. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40322. /**
  40323. * Rebuilds the elements related to this component in case of
  40324. * context lost for instance.
  40325. */
  40326. rebuild(): void;
  40327. /**
  40328. * Disposes the component and the associated ressources.
  40329. */
  40330. dispose(): void;
  40331. }
  40332. }
  40333. declare module BABYLON {
  40334. /**
  40335. * Renders a layer on top of an existing scene
  40336. */
  40337. export class UtilityLayerRenderer implements IDisposable {
  40338. /** the original scene that will be rendered on top of */
  40339. originalScene: Scene;
  40340. private _pointerCaptures;
  40341. private _lastPointerEvents;
  40342. private static _DefaultUtilityLayer;
  40343. private static _DefaultKeepDepthUtilityLayer;
  40344. private _sharedGizmoLight;
  40345. /**
  40346. * @hidden
  40347. * Light which used by gizmos to get light shading
  40348. */
  40349. _getSharedGizmoLight(): HemisphericLight;
  40350. /**
  40351. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40352. */
  40353. pickUtilitySceneFirst: boolean;
  40354. /**
  40355. * 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)
  40356. */
  40357. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40358. /**
  40359. * 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)
  40360. */
  40361. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40362. /**
  40363. * The scene that is rendered on top of the original scene
  40364. */
  40365. utilityLayerScene: Scene;
  40366. /**
  40367. * If the utility layer should automatically be rendered on top of existing scene
  40368. */
  40369. shouldRender: boolean;
  40370. /**
  40371. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40372. */
  40373. onlyCheckPointerDownEvents: boolean;
  40374. /**
  40375. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40376. */
  40377. processAllEvents: boolean;
  40378. /**
  40379. * Observable raised when the pointer move from the utility layer scene to the main scene
  40380. */
  40381. onPointerOutObservable: Observable<number>;
  40382. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40383. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40384. private _afterRenderObserver;
  40385. private _sceneDisposeObserver;
  40386. private _originalPointerObserver;
  40387. /**
  40388. * Instantiates a UtilityLayerRenderer
  40389. * @param originalScene the original scene that will be rendered on top of
  40390. * @param handleEvents boolean indicating if the utility layer should handle events
  40391. */
  40392. constructor(
  40393. /** the original scene that will be rendered on top of */
  40394. originalScene: Scene, handleEvents?: boolean);
  40395. private _notifyObservers;
  40396. /**
  40397. * Renders the utility layers scene on top of the original scene
  40398. */
  40399. render(): void;
  40400. /**
  40401. * Disposes of the renderer
  40402. */
  40403. dispose(): void;
  40404. private _updateCamera;
  40405. }
  40406. }
  40407. declare module BABYLON {
  40408. /**
  40409. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40410. */
  40411. export class Gizmo implements IDisposable {
  40412. /** The utility layer the gizmo will be added to */
  40413. gizmoLayer: UtilityLayerRenderer;
  40414. /**
  40415. * The root mesh of the gizmo
  40416. */
  40417. _rootMesh: Mesh;
  40418. private _attachedMesh;
  40419. /**
  40420. * Ratio for the scale of the gizmo (Default: 1)
  40421. */
  40422. scaleRatio: number;
  40423. private _tmpMatrix;
  40424. /**
  40425. * If a custom mesh has been set (Default: false)
  40426. */
  40427. protected _customMeshSet: boolean;
  40428. /**
  40429. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40430. * * When set, interactions will be enabled
  40431. */
  40432. attachedMesh: Nullable<AbstractMesh>;
  40433. /**
  40434. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40435. * @param mesh The mesh to replace the default mesh of the gizmo
  40436. */
  40437. setCustomMesh(mesh: Mesh): void;
  40438. /**
  40439. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40440. */
  40441. updateGizmoRotationToMatchAttachedMesh: boolean;
  40442. /**
  40443. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40444. */
  40445. updateGizmoPositionToMatchAttachedMesh: boolean;
  40446. /**
  40447. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40448. */
  40449. protected _updateScale: boolean;
  40450. protected _interactionsEnabled: boolean;
  40451. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40452. private _beforeRenderObserver;
  40453. /**
  40454. * Creates a gizmo
  40455. * @param gizmoLayer The utility layer the gizmo will be added to
  40456. */
  40457. constructor(
  40458. /** The utility layer the gizmo will be added to */
  40459. gizmoLayer?: UtilityLayerRenderer);
  40460. private _tempVector;
  40461. /**
  40462. * @hidden
  40463. * Updates the gizmo to match the attached mesh's position/rotation
  40464. */
  40465. protected _update(): void;
  40466. /**
  40467. * Disposes of the gizmo
  40468. */
  40469. dispose(): void;
  40470. }
  40471. }
  40472. declare module BABYLON {
  40473. /**
  40474. * Single axis drag gizmo
  40475. */
  40476. export class AxisDragGizmo extends Gizmo {
  40477. /**
  40478. * Drag behavior responsible for the gizmos dragging interactions
  40479. */
  40480. dragBehavior: PointerDragBehavior;
  40481. private _pointerObserver;
  40482. /**
  40483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40484. */
  40485. snapDistance: number;
  40486. /**
  40487. * Event that fires each time the gizmo snaps to a new location.
  40488. * * snapDistance is the the change in distance
  40489. */
  40490. onSnapObservable: Observable<{
  40491. snapDistance: number;
  40492. }>;
  40493. /** @hidden */
  40494. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40495. /** @hidden */
  40496. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40497. /**
  40498. * Creates an AxisDragGizmo
  40499. * @param gizmoLayer The utility layer the gizmo will be added to
  40500. * @param dragAxis The axis which the gizmo will be able to drag on
  40501. * @param color The color of the gizmo
  40502. */
  40503. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40505. /**
  40506. * Disposes of the gizmo
  40507. */
  40508. dispose(): void;
  40509. }
  40510. }
  40511. declare module BABYLON.Debug {
  40512. /**
  40513. * The Axes viewer will show 3 axes in a specific point in space
  40514. */
  40515. export class AxesViewer {
  40516. private _xAxis;
  40517. private _yAxis;
  40518. private _zAxis;
  40519. private _scaleLinesFactor;
  40520. private _instanced;
  40521. /**
  40522. * Gets the hosting scene
  40523. */
  40524. scene: Scene;
  40525. /**
  40526. * Gets or sets a number used to scale line length
  40527. */
  40528. scaleLines: number;
  40529. /** Gets the node hierarchy used to render x-axis */
  40530. readonly xAxis: TransformNode;
  40531. /** Gets the node hierarchy used to render y-axis */
  40532. readonly yAxis: TransformNode;
  40533. /** Gets the node hierarchy used to render z-axis */
  40534. readonly zAxis: TransformNode;
  40535. /**
  40536. * Creates a new AxesViewer
  40537. * @param scene defines the hosting scene
  40538. * @param scaleLines defines a number used to scale line length (1 by default)
  40539. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40540. * @param xAxis defines the node hierarchy used to render the x-axis
  40541. * @param yAxis defines the node hierarchy used to render the y-axis
  40542. * @param zAxis defines the node hierarchy used to render the z-axis
  40543. */
  40544. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40545. /**
  40546. * Force the viewer to update
  40547. * @param position defines the position of the viewer
  40548. * @param xaxis defines the x axis of the viewer
  40549. * @param yaxis defines the y axis of the viewer
  40550. * @param zaxis defines the z axis of the viewer
  40551. */
  40552. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40553. /**
  40554. * Creates an instance of this axes viewer.
  40555. * @returns a new axes viewer with instanced meshes
  40556. */
  40557. createInstance(): AxesViewer;
  40558. /** Releases resources */
  40559. dispose(): void;
  40560. private static _SetRenderingGroupId;
  40561. }
  40562. }
  40563. declare module BABYLON.Debug {
  40564. /**
  40565. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40566. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40567. */
  40568. export class BoneAxesViewer extends AxesViewer {
  40569. /**
  40570. * Gets or sets the target mesh where to display the axes viewer
  40571. */
  40572. mesh: Nullable<Mesh>;
  40573. /**
  40574. * Gets or sets the target bone where to display the axes viewer
  40575. */
  40576. bone: Nullable<Bone>;
  40577. /** Gets current position */
  40578. pos: Vector3;
  40579. /** Gets direction of X axis */
  40580. xaxis: Vector3;
  40581. /** Gets direction of Y axis */
  40582. yaxis: Vector3;
  40583. /** Gets direction of Z axis */
  40584. zaxis: Vector3;
  40585. /**
  40586. * Creates a new BoneAxesViewer
  40587. * @param scene defines the hosting scene
  40588. * @param bone defines the target bone
  40589. * @param mesh defines the target mesh
  40590. * @param scaleLines defines a scaling factor for line length (1 by default)
  40591. */
  40592. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40593. /**
  40594. * Force the viewer to update
  40595. */
  40596. update(): void;
  40597. /** Releases resources */
  40598. dispose(): void;
  40599. }
  40600. }
  40601. declare module BABYLON {
  40602. /**
  40603. * Interface used to define scene explorer extensibility option
  40604. */
  40605. export interface IExplorerExtensibilityOption {
  40606. /**
  40607. * Define the option label
  40608. */
  40609. label: string;
  40610. /**
  40611. * Defines the action to execute on click
  40612. */
  40613. action: (entity: any) => void;
  40614. }
  40615. /**
  40616. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40617. */
  40618. export interface IExplorerExtensibilityGroup {
  40619. /**
  40620. * Defines a predicate to test if a given type mut be extended
  40621. */
  40622. predicate: (entity: any) => boolean;
  40623. /**
  40624. * Gets the list of options added to a type
  40625. */
  40626. entries: IExplorerExtensibilityOption[];
  40627. }
  40628. /**
  40629. * Interface used to define the options to use to create the Inspector
  40630. */
  40631. export interface IInspectorOptions {
  40632. /**
  40633. * Display in overlay mode (default: false)
  40634. */
  40635. overlay?: boolean;
  40636. /**
  40637. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40638. */
  40639. globalRoot?: HTMLElement;
  40640. /**
  40641. * Display the Scene explorer
  40642. */
  40643. showExplorer?: boolean;
  40644. /**
  40645. * Display the property inspector
  40646. */
  40647. showInspector?: boolean;
  40648. /**
  40649. * Display in embed mode (both panes on the right)
  40650. */
  40651. embedMode?: boolean;
  40652. /**
  40653. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40654. */
  40655. handleResize?: boolean;
  40656. /**
  40657. * Allow the panes to popup (default: true)
  40658. */
  40659. enablePopup?: boolean;
  40660. /**
  40661. * Allow the panes to be closed by users (default: true)
  40662. */
  40663. enableClose?: boolean;
  40664. /**
  40665. * Optional list of extensibility entries
  40666. */
  40667. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40668. /**
  40669. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40670. */
  40671. inspectorURL?: string;
  40672. }
  40673. interface Scene {
  40674. /**
  40675. * @hidden
  40676. * Backing field
  40677. */
  40678. _debugLayer: DebugLayer;
  40679. /**
  40680. * Gets the debug layer (aka Inspector) associated with the scene
  40681. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40682. */
  40683. debugLayer: DebugLayer;
  40684. }
  40685. /**
  40686. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40687. * what is happening in your scene
  40688. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40689. */
  40690. export class DebugLayer {
  40691. /**
  40692. * Define the url to get the inspector script from.
  40693. * By default it uses the babylonjs CDN.
  40694. * @ignoreNaming
  40695. */
  40696. static InspectorURL: string;
  40697. private _scene;
  40698. private BJSINSPECTOR;
  40699. /**
  40700. * Observable triggered when a property is changed through the inspector.
  40701. */
  40702. onPropertyChangedObservable: Observable<{
  40703. object: any;
  40704. property: string;
  40705. value: any;
  40706. initialValue: any;
  40707. }>;
  40708. /**
  40709. * Instantiates a new debug layer.
  40710. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40711. * what is happening in your scene
  40712. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40713. * @param scene Defines the scene to inspect
  40714. */
  40715. constructor(scene: Scene);
  40716. /** Creates the inspector window. */
  40717. private _createInspector;
  40718. /**
  40719. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40720. * @param entity defines the entity to select
  40721. * @param lineContainerTitle defines the specific block to highlight
  40722. */
  40723. select(entity: any, lineContainerTitle?: string): void;
  40724. /** Get the inspector from bundle or global */
  40725. private _getGlobalInspector;
  40726. /**
  40727. * Get if the inspector is visible or not.
  40728. * @returns true if visible otherwise, false
  40729. */
  40730. isVisible(): boolean;
  40731. /**
  40732. * Hide the inspector and close its window.
  40733. */
  40734. hide(): void;
  40735. /**
  40736. * Launch the debugLayer.
  40737. * @param config Define the configuration of the inspector
  40738. * @return a promise fulfilled when the debug layer is visible
  40739. */
  40740. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40741. }
  40742. }
  40743. declare module BABYLON {
  40744. /**
  40745. * Class containing static functions to help procedurally build meshes
  40746. */
  40747. export class BoxBuilder {
  40748. /**
  40749. * Creates a box mesh
  40750. * * The parameter `size` sets the size (float) of each box side (default 1)
  40751. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40752. * * 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)
  40753. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40755. * * 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
  40756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40757. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40758. * @param name defines the name of the mesh
  40759. * @param options defines the options used to create the mesh
  40760. * @param scene defines the hosting scene
  40761. * @returns the box mesh
  40762. */
  40763. static CreateBox(name: string, options: {
  40764. size?: number;
  40765. width?: number;
  40766. height?: number;
  40767. depth?: number;
  40768. faceUV?: Vector4[];
  40769. faceColors?: Color4[];
  40770. sideOrientation?: number;
  40771. frontUVs?: Vector4;
  40772. backUVs?: Vector4;
  40773. updatable?: boolean;
  40774. }, scene?: Nullable<Scene>): Mesh;
  40775. }
  40776. }
  40777. declare module BABYLON {
  40778. /**
  40779. * Class containing static functions to help procedurally build meshes
  40780. */
  40781. export class SphereBuilder {
  40782. /**
  40783. * Creates a sphere mesh
  40784. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40785. * * 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`)
  40786. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40787. * * 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
  40788. * * 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)
  40789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40790. * * 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
  40791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40792. * @param name defines the name of the mesh
  40793. * @param options defines the options used to create the mesh
  40794. * @param scene defines the hosting scene
  40795. * @returns the sphere mesh
  40796. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40797. */
  40798. static CreateSphere(name: string, options: {
  40799. segments?: number;
  40800. diameter?: number;
  40801. diameterX?: number;
  40802. diameterY?: number;
  40803. diameterZ?: number;
  40804. arc?: number;
  40805. slice?: number;
  40806. sideOrientation?: number;
  40807. frontUVs?: Vector4;
  40808. backUVs?: Vector4;
  40809. updatable?: boolean;
  40810. }, scene: any): Mesh;
  40811. }
  40812. }
  40813. declare module BABYLON.Debug {
  40814. /**
  40815. * Used to show the physics impostor around the specific mesh
  40816. */
  40817. export class PhysicsViewer {
  40818. /** @hidden */
  40819. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40820. /** @hidden */
  40821. protected _meshes: Array<Nullable<AbstractMesh>>;
  40822. /** @hidden */
  40823. protected _scene: Nullable<Scene>;
  40824. /** @hidden */
  40825. protected _numMeshes: number;
  40826. /** @hidden */
  40827. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40828. private _renderFunction;
  40829. private _utilityLayer;
  40830. private _debugBoxMesh;
  40831. private _debugSphereMesh;
  40832. private _debugMaterial;
  40833. private _debugMeshMeshes;
  40834. /**
  40835. * Creates a new PhysicsViewer
  40836. * @param scene defines the hosting scene
  40837. */
  40838. constructor(scene: Scene);
  40839. /** @hidden */
  40840. protected _updateDebugMeshes(): void;
  40841. /**
  40842. * Renders a specified physic impostor
  40843. * @param impostor defines the impostor to render
  40844. * @param targetMesh defines the mesh represented by the impostor
  40845. * @returns the new debug mesh used to render the impostor
  40846. */
  40847. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40848. /**
  40849. * Hides a specified physic impostor
  40850. * @param impostor defines the impostor to hide
  40851. */
  40852. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40853. private _getDebugMaterial;
  40854. private _getDebugBoxMesh;
  40855. private _getDebugSphereMesh;
  40856. private _getDebugMeshMesh;
  40857. private _getDebugMesh;
  40858. /** Releases all resources */
  40859. dispose(): void;
  40860. }
  40861. }
  40862. declare module BABYLON {
  40863. /**
  40864. * Class containing static functions to help procedurally build meshes
  40865. */
  40866. export class LinesBuilder {
  40867. /**
  40868. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40869. * * 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
  40870. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40871. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40872. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40873. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40874. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40875. * * 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
  40876. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40879. * @param name defines the name of the new line system
  40880. * @param options defines the options used to create the line system
  40881. * @param scene defines the hosting scene
  40882. * @returns a new line system mesh
  40883. */
  40884. static CreateLineSystem(name: string, options: {
  40885. lines: Vector3[][];
  40886. updatable?: boolean;
  40887. instance?: Nullable<LinesMesh>;
  40888. colors?: Nullable<Color4[][]>;
  40889. useVertexAlpha?: boolean;
  40890. }, scene: Nullable<Scene>): LinesMesh;
  40891. /**
  40892. * Creates a line mesh
  40893. * 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
  40894. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40895. * * The parameter `points` is an array successive Vector3
  40896. * * 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
  40897. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40898. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40899. * * When updating an instance, remember that only point positions can change, not the number of points
  40900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40902. * @param name defines the name of the new line system
  40903. * @param options defines the options used to create the line system
  40904. * @param scene defines the hosting scene
  40905. * @returns a new line mesh
  40906. */
  40907. static CreateLines(name: string, options: {
  40908. points: Vector3[];
  40909. updatable?: boolean;
  40910. instance?: Nullable<LinesMesh>;
  40911. colors?: Color4[];
  40912. useVertexAlpha?: boolean;
  40913. }, scene?: Nullable<Scene>): LinesMesh;
  40914. /**
  40915. * Creates a dashed line mesh
  40916. * * 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
  40917. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40918. * * The parameter `points` is an array successive Vector3
  40919. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40920. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40921. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40922. * * 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
  40923. * * When updating an instance, remember that only point positions can change, not the number of points
  40924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40925. * @param name defines the name of the mesh
  40926. * @param options defines the options used to create the mesh
  40927. * @param scene defines the hosting scene
  40928. * @returns the dashed line mesh
  40929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40930. */
  40931. static CreateDashedLines(name: string, options: {
  40932. points: Vector3[];
  40933. dashSize?: number;
  40934. gapSize?: number;
  40935. dashNb?: number;
  40936. updatable?: boolean;
  40937. instance?: LinesMesh;
  40938. }, scene?: Nullable<Scene>): LinesMesh;
  40939. }
  40940. }
  40941. declare module BABYLON {
  40942. /**
  40943. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40944. * in order to better appreciate the issue one might have.
  40945. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40946. */
  40947. export class RayHelper {
  40948. /**
  40949. * Defines the ray we are currently tryin to visualize.
  40950. */
  40951. ray: Nullable<Ray>;
  40952. private _renderPoints;
  40953. private _renderLine;
  40954. private _renderFunction;
  40955. private _scene;
  40956. private _updateToMeshFunction;
  40957. private _attachedToMesh;
  40958. private _meshSpaceDirection;
  40959. private _meshSpaceOrigin;
  40960. /**
  40961. * Helper function to create a colored helper in a scene in one line.
  40962. * @param ray Defines the ray we are currently tryin to visualize
  40963. * @param scene Defines the scene the ray is used in
  40964. * @param color Defines the color we want to see the ray in
  40965. * @returns The newly created ray helper.
  40966. */
  40967. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40968. /**
  40969. * Instantiate a new ray helper.
  40970. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40971. * in order to better appreciate the issue one might have.
  40972. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40973. * @param ray Defines the ray we are currently tryin to visualize
  40974. */
  40975. constructor(ray: Ray);
  40976. /**
  40977. * Shows the ray we are willing to debug.
  40978. * @param scene Defines the scene the ray needs to be rendered in
  40979. * @param color Defines the color the ray needs to be rendered in
  40980. */
  40981. show(scene: Scene, color?: Color3): void;
  40982. /**
  40983. * Hides the ray we are debugging.
  40984. */
  40985. hide(): void;
  40986. private _render;
  40987. /**
  40988. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40989. * @param mesh Defines the mesh we want the helper attached to
  40990. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40991. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40992. * @param length Defines the length of the ray
  40993. */
  40994. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40995. /**
  40996. * Detach the ray helper from the mesh it has previously been attached to.
  40997. */
  40998. detachFromMesh(): void;
  40999. private _updateToMesh;
  41000. /**
  41001. * Dispose the helper and release its associated resources.
  41002. */
  41003. dispose(): void;
  41004. }
  41005. }
  41006. declare module BABYLON.Debug {
  41007. /**
  41008. * Class used to render a debug view of a given skeleton
  41009. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41010. */
  41011. export class SkeletonViewer {
  41012. /** defines the skeleton to render */
  41013. skeleton: Skeleton;
  41014. /** defines the mesh attached to the skeleton */
  41015. mesh: AbstractMesh;
  41016. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41017. autoUpdateBonesMatrices: boolean;
  41018. /** defines the rendering group id to use with the viewer */
  41019. renderingGroupId: number;
  41020. /** Gets or sets the color used to render the skeleton */
  41021. color: Color3;
  41022. private _scene;
  41023. private _debugLines;
  41024. private _debugMesh;
  41025. private _isEnabled;
  41026. private _renderFunction;
  41027. private _utilityLayer;
  41028. /**
  41029. * Returns the mesh used to render the bones
  41030. */
  41031. readonly debugMesh: Nullable<LinesMesh>;
  41032. /**
  41033. * Creates a new SkeletonViewer
  41034. * @param skeleton defines the skeleton to render
  41035. * @param mesh defines the mesh attached to the skeleton
  41036. * @param scene defines the hosting scene
  41037. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41038. * @param renderingGroupId defines the rendering group id to use with the viewer
  41039. */
  41040. constructor(
  41041. /** defines the skeleton to render */
  41042. skeleton: Skeleton,
  41043. /** defines the mesh attached to the skeleton */
  41044. mesh: AbstractMesh, scene: Scene,
  41045. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41046. autoUpdateBonesMatrices?: boolean,
  41047. /** defines the rendering group id to use with the viewer */
  41048. renderingGroupId?: number);
  41049. /** Gets or sets a boolean indicating if the viewer is enabled */
  41050. isEnabled: boolean;
  41051. private _getBonePosition;
  41052. private _getLinesForBonesWithLength;
  41053. private _getLinesForBonesNoLength;
  41054. /** Update the viewer to sync with current skeleton state */
  41055. update(): void;
  41056. /** Release associated resources */
  41057. dispose(): void;
  41058. }
  41059. }
  41060. declare module BABYLON {
  41061. /**
  41062. * Options to create the null engine
  41063. */
  41064. export class NullEngineOptions {
  41065. /**
  41066. * Render width (Default: 512)
  41067. */
  41068. renderWidth: number;
  41069. /**
  41070. * Render height (Default: 256)
  41071. */
  41072. renderHeight: number;
  41073. /**
  41074. * Texture size (Default: 512)
  41075. */
  41076. textureSize: number;
  41077. /**
  41078. * If delta time between frames should be constant
  41079. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41080. */
  41081. deterministicLockstep: boolean;
  41082. /**
  41083. * Maximum about of steps between frames (Default: 4)
  41084. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41085. */
  41086. lockstepMaxSteps: number;
  41087. }
  41088. /**
  41089. * The null engine class provides support for headless version of babylon.js.
  41090. * This can be used in server side scenario or for testing purposes
  41091. */
  41092. export class NullEngine extends Engine {
  41093. private _options;
  41094. /**
  41095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41096. */
  41097. isDeterministicLockStep(): boolean;
  41098. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41099. getLockstepMaxSteps(): number;
  41100. /**
  41101. * Sets hardware scaling, used to save performance if needed
  41102. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41103. */
  41104. getHardwareScalingLevel(): number;
  41105. constructor(options?: NullEngineOptions);
  41106. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41107. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41108. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41109. getRenderWidth(useScreen?: boolean): number;
  41110. getRenderHeight(useScreen?: boolean): number;
  41111. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41112. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41113. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41114. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41115. bindSamplers(effect: Effect): void;
  41116. enableEffect(effect: Effect): void;
  41117. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41118. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41119. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41120. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41121. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41122. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41123. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41124. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41125. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41126. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41127. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41128. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41129. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41130. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41131. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41132. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41133. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41134. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41135. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41136. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41137. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41138. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41139. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41140. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41141. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41142. bindBuffers(vertexBuffers: {
  41143. [key: string]: VertexBuffer;
  41144. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41145. wipeCaches(bruteForce?: boolean): void;
  41146. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41147. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41148. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41149. /** @hidden */
  41150. _createTexture(): WebGLTexture;
  41151. /** @hidden */
  41152. _releaseTexture(texture: InternalTexture): void;
  41153. 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;
  41154. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41155. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41156. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41157. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41158. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41159. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41160. areAllEffectsReady(): boolean;
  41161. /**
  41162. * @hidden
  41163. * Get the current error code of the webGL context
  41164. * @returns the error code
  41165. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41166. */
  41167. getError(): number;
  41168. /** @hidden */
  41169. _getUnpackAlignement(): number;
  41170. /** @hidden */
  41171. _unpackFlipY(value: boolean): void;
  41172. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41173. /**
  41174. * Updates a dynamic vertex buffer.
  41175. * @param vertexBuffer the vertex buffer to update
  41176. * @param data the data used to update the vertex buffer
  41177. * @param byteOffset the byte offset of the data (optional)
  41178. * @param byteLength the byte length of the data (optional)
  41179. */
  41180. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41181. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41182. /** @hidden */
  41183. _bindTexture(channel: number, texture: InternalTexture): void;
  41184. /** @hidden */
  41185. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41186. releaseEffects(): void;
  41187. displayLoadingUI(): void;
  41188. hideLoadingUI(): void;
  41189. /** @hidden */
  41190. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41191. /** @hidden */
  41192. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41193. /** @hidden */
  41194. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41195. /** @hidden */
  41196. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41197. }
  41198. }
  41199. declare module BABYLON {
  41200. /** @hidden */
  41201. export class _OcclusionDataStorage {
  41202. /** @hidden */
  41203. occlusionInternalRetryCounter: number;
  41204. /** @hidden */
  41205. isOcclusionQueryInProgress: boolean;
  41206. /** @hidden */
  41207. isOccluded: boolean;
  41208. /** @hidden */
  41209. occlusionRetryCount: number;
  41210. /** @hidden */
  41211. occlusionType: number;
  41212. /** @hidden */
  41213. occlusionQueryAlgorithmType: number;
  41214. }
  41215. interface Engine {
  41216. /**
  41217. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41218. * @return the new query
  41219. */
  41220. createQuery(): WebGLQuery;
  41221. /**
  41222. * Delete and release a webGL query
  41223. * @param query defines the query to delete
  41224. * @return the current engine
  41225. */
  41226. deleteQuery(query: WebGLQuery): Engine;
  41227. /**
  41228. * Check if a given query has resolved and got its value
  41229. * @param query defines the query to check
  41230. * @returns true if the query got its value
  41231. */
  41232. isQueryResultAvailable(query: WebGLQuery): boolean;
  41233. /**
  41234. * Gets the value of a given query
  41235. * @param query defines the query to check
  41236. * @returns the value of the query
  41237. */
  41238. getQueryResult(query: WebGLQuery): number;
  41239. /**
  41240. * Initiates an occlusion query
  41241. * @param algorithmType defines the algorithm to use
  41242. * @param query defines the query to use
  41243. * @returns the current engine
  41244. * @see http://doc.babylonjs.com/features/occlusionquery
  41245. */
  41246. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41247. /**
  41248. * Ends an occlusion query
  41249. * @see http://doc.babylonjs.com/features/occlusionquery
  41250. * @param algorithmType defines the algorithm to use
  41251. * @returns the current engine
  41252. */
  41253. endOcclusionQuery(algorithmType: number): Engine;
  41254. /**
  41255. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41256. * Please note that only one query can be issued at a time
  41257. * @returns a time token used to track the time span
  41258. */
  41259. startTimeQuery(): Nullable<_TimeToken>;
  41260. /**
  41261. * Ends a time query
  41262. * @param token defines the token used to measure the time span
  41263. * @returns the time spent (in ns)
  41264. */
  41265. endTimeQuery(token: _TimeToken): int;
  41266. /** @hidden */
  41267. _currentNonTimestampToken: Nullable<_TimeToken>;
  41268. /** @hidden */
  41269. _createTimeQuery(): WebGLQuery;
  41270. /** @hidden */
  41271. _deleteTimeQuery(query: WebGLQuery): void;
  41272. /** @hidden */
  41273. _getGlAlgorithmType(algorithmType: number): number;
  41274. /** @hidden */
  41275. _getTimeQueryResult(query: WebGLQuery): any;
  41276. /** @hidden */
  41277. _getTimeQueryAvailability(query: WebGLQuery): any;
  41278. }
  41279. interface AbstractMesh {
  41280. /**
  41281. * Backing filed
  41282. * @hidden
  41283. */
  41284. __occlusionDataStorage: _OcclusionDataStorage;
  41285. /**
  41286. * Access property
  41287. * @hidden
  41288. */
  41289. _occlusionDataStorage: _OcclusionDataStorage;
  41290. /**
  41291. * 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.
  41292. * The default value is -1 which means don't break the query and wait till the result
  41293. * @see http://doc.babylonjs.com/features/occlusionquery
  41294. */
  41295. occlusionRetryCount: number;
  41296. /**
  41297. * 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:
  41298. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41299. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41300. * * 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.
  41301. * @see http://doc.babylonjs.com/features/occlusionquery
  41302. */
  41303. occlusionType: number;
  41304. /**
  41305. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41306. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41307. * * 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.
  41308. * @see http://doc.babylonjs.com/features/occlusionquery
  41309. */
  41310. occlusionQueryAlgorithmType: number;
  41311. /**
  41312. * 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
  41313. * @see http://doc.babylonjs.com/features/occlusionquery
  41314. */
  41315. isOccluded: boolean;
  41316. /**
  41317. * Flag to check the progress status of the query
  41318. * @see http://doc.babylonjs.com/features/occlusionquery
  41319. */
  41320. isOcclusionQueryInProgress: boolean;
  41321. }
  41322. }
  41323. declare module BABYLON {
  41324. /** @hidden */
  41325. export var _forceTransformFeedbackToBundle: boolean;
  41326. interface Engine {
  41327. /**
  41328. * Creates a webGL transform feedback object
  41329. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41330. * @returns the webGL transform feedback object
  41331. */
  41332. createTransformFeedback(): WebGLTransformFeedback;
  41333. /**
  41334. * Delete a webGL transform feedback object
  41335. * @param value defines the webGL transform feedback object to delete
  41336. */
  41337. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41338. /**
  41339. * Bind a webGL transform feedback object to the webgl context
  41340. * @param value defines the webGL transform feedback object to bind
  41341. */
  41342. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41343. /**
  41344. * Begins a transform feedback operation
  41345. * @param usePoints defines if points or triangles must be used
  41346. */
  41347. beginTransformFeedback(usePoints: boolean): void;
  41348. /**
  41349. * Ends a transform feedback operation
  41350. */
  41351. endTransformFeedback(): void;
  41352. /**
  41353. * Specify the varyings to use with transform feedback
  41354. * @param program defines the associated webGL program
  41355. * @param value defines the list of strings representing the varying names
  41356. */
  41357. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41358. /**
  41359. * Bind a webGL buffer for a transform feedback operation
  41360. * @param value defines the webGL buffer to bind
  41361. */
  41362. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41363. }
  41364. }
  41365. declare module BABYLON {
  41366. /**
  41367. * Gather the list of clipboard event types as constants.
  41368. */
  41369. export class ClipboardEventTypes {
  41370. /**
  41371. * The clipboard event is fired when a copy command is active (pressed).
  41372. */
  41373. static readonly COPY: number;
  41374. /**
  41375. * The clipboard event is fired when a cut command is active (pressed).
  41376. */
  41377. static readonly CUT: number;
  41378. /**
  41379. * The clipboard event is fired when a paste command is active (pressed).
  41380. */
  41381. static readonly PASTE: number;
  41382. }
  41383. /**
  41384. * This class is used to store clipboard related info for the onClipboardObservable event.
  41385. */
  41386. export class ClipboardInfo {
  41387. /**
  41388. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41389. */
  41390. type: number;
  41391. /**
  41392. * Defines the related dom event
  41393. */
  41394. event: ClipboardEvent;
  41395. /**
  41396. *Creates an instance of ClipboardInfo.
  41397. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41398. * @param event Defines the related dom event
  41399. */
  41400. constructor(
  41401. /**
  41402. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41403. */
  41404. type: number,
  41405. /**
  41406. * Defines the related dom event
  41407. */
  41408. event: ClipboardEvent);
  41409. /**
  41410. * Get the clipboard event's type from the keycode.
  41411. * @param keyCode Defines the keyCode for the current keyboard event.
  41412. * @return {number}
  41413. */
  41414. static GetTypeFromCharacter(keyCode: number): number;
  41415. }
  41416. }
  41417. declare module BABYLON {
  41418. /**
  41419. * Class used to represent data loading progression
  41420. */
  41421. export class SceneLoaderProgressEvent {
  41422. /** defines if data length to load can be evaluated */
  41423. readonly lengthComputable: boolean;
  41424. /** defines the loaded data length */
  41425. readonly loaded: number;
  41426. /** defines the data length to load */
  41427. readonly total: number;
  41428. /**
  41429. * Create a new progress event
  41430. * @param lengthComputable defines if data length to load can be evaluated
  41431. * @param loaded defines the loaded data length
  41432. * @param total defines the data length to load
  41433. */
  41434. constructor(
  41435. /** defines if data length to load can be evaluated */
  41436. lengthComputable: boolean,
  41437. /** defines the loaded data length */
  41438. loaded: number,
  41439. /** defines the data length to load */
  41440. total: number);
  41441. /**
  41442. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41443. * @param event defines the source event
  41444. * @returns a new SceneLoaderProgressEvent
  41445. */
  41446. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41447. }
  41448. /**
  41449. * Interface used by SceneLoader plugins to define supported file extensions
  41450. */
  41451. export interface ISceneLoaderPluginExtensions {
  41452. /**
  41453. * Defines the list of supported extensions
  41454. */
  41455. [extension: string]: {
  41456. isBinary: boolean;
  41457. };
  41458. }
  41459. /**
  41460. * Interface used by SceneLoader plugin factory
  41461. */
  41462. export interface ISceneLoaderPluginFactory {
  41463. /**
  41464. * Defines the name of the factory
  41465. */
  41466. name: string;
  41467. /**
  41468. * Function called to create a new plugin
  41469. * @return the new plugin
  41470. */
  41471. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41472. /**
  41473. * Boolean indicating if the plugin can direct load specific data
  41474. */
  41475. canDirectLoad?: (data: string) => boolean;
  41476. }
  41477. /**
  41478. * Interface used to define a SceneLoader plugin
  41479. */
  41480. export interface ISceneLoaderPlugin {
  41481. /**
  41482. * The friendly name of this plugin.
  41483. */
  41484. name: string;
  41485. /**
  41486. * The file extensions supported by this plugin.
  41487. */
  41488. extensions: string | ISceneLoaderPluginExtensions;
  41489. /**
  41490. * Import meshes into a scene.
  41491. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41492. * @param scene The scene to import into
  41493. * @param data The data to import
  41494. * @param rootUrl The root url for scene and resources
  41495. * @param meshes The meshes array to import into
  41496. * @param particleSystems The particle systems array to import into
  41497. * @param skeletons The skeletons array to import into
  41498. * @param onError The callback when import fails
  41499. * @returns True if successful or false otherwise
  41500. */
  41501. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41502. /**
  41503. * Load into a scene.
  41504. * @param scene The scene to load into
  41505. * @param data The data to import
  41506. * @param rootUrl The root url for scene and resources
  41507. * @param onError The callback when import fails
  41508. * @returns true if successful or false otherwise
  41509. */
  41510. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41511. /**
  41512. * The callback that returns true if the data can be directly loaded.
  41513. */
  41514. canDirectLoad?: (data: string) => boolean;
  41515. /**
  41516. * The callback that allows custom handling of the root url based on the response url.
  41517. */
  41518. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41519. /**
  41520. * Load into an asset container.
  41521. * @param scene The scene to load into
  41522. * @param data The data to import
  41523. * @param rootUrl The root url for scene and resources
  41524. * @param onError The callback when import fails
  41525. * @returns The loaded asset container
  41526. */
  41527. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41528. }
  41529. /**
  41530. * Interface used to define an async SceneLoader plugin
  41531. */
  41532. export interface ISceneLoaderPluginAsync {
  41533. /**
  41534. * The friendly name of this plugin.
  41535. */
  41536. name: string;
  41537. /**
  41538. * The file extensions supported by this plugin.
  41539. */
  41540. extensions: string | ISceneLoaderPluginExtensions;
  41541. /**
  41542. * Import meshes into a scene.
  41543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41544. * @param scene The scene to import into
  41545. * @param data The data to import
  41546. * @param rootUrl The root url for scene and resources
  41547. * @param onProgress The callback when the load progresses
  41548. * @param fileName Defines the name of the file to load
  41549. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41550. */
  41551. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41552. meshes: AbstractMesh[];
  41553. particleSystems: IParticleSystem[];
  41554. skeletons: Skeleton[];
  41555. animationGroups: AnimationGroup[];
  41556. }>;
  41557. /**
  41558. * Load into a scene.
  41559. * @param scene The scene to load into
  41560. * @param data The data to import
  41561. * @param rootUrl The root url for scene and resources
  41562. * @param onProgress The callback when the load progresses
  41563. * @param fileName Defines the name of the file to load
  41564. * @returns Nothing
  41565. */
  41566. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41567. /**
  41568. * The callback that returns true if the data can be directly loaded.
  41569. */
  41570. canDirectLoad?: (data: string) => boolean;
  41571. /**
  41572. * The callback that allows custom handling of the root url based on the response url.
  41573. */
  41574. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41575. /**
  41576. * Load into an asset container.
  41577. * @param scene The scene to load into
  41578. * @param data The data to import
  41579. * @param rootUrl The root url for scene and resources
  41580. * @param onProgress The callback when the load progresses
  41581. * @param fileName Defines the name of the file to load
  41582. * @returns The loaded asset container
  41583. */
  41584. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41585. }
  41586. /**
  41587. * Class used to load scene from various file formats using registered plugins
  41588. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41589. */
  41590. export class SceneLoader {
  41591. /**
  41592. * No logging while loading
  41593. */
  41594. static readonly NO_LOGGING: number;
  41595. /**
  41596. * Minimal logging while loading
  41597. */
  41598. static readonly MINIMAL_LOGGING: number;
  41599. /**
  41600. * Summary logging while loading
  41601. */
  41602. static readonly SUMMARY_LOGGING: number;
  41603. /**
  41604. * Detailled logging while loading
  41605. */
  41606. static readonly DETAILED_LOGGING: number;
  41607. /**
  41608. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41609. */
  41610. static ForceFullSceneLoadingForIncremental: boolean;
  41611. /**
  41612. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41613. */
  41614. static ShowLoadingScreen: boolean;
  41615. /**
  41616. * Defines the current logging level (while loading the scene)
  41617. * @ignorenaming
  41618. */
  41619. static loggingLevel: number;
  41620. /**
  41621. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41622. */
  41623. static CleanBoneMatrixWeights: boolean;
  41624. /**
  41625. * Event raised when a plugin is used to load a scene
  41626. */
  41627. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41628. private static _registeredPlugins;
  41629. private static _getDefaultPlugin;
  41630. private static _getPluginForExtension;
  41631. private static _getPluginForDirectLoad;
  41632. private static _getPluginForFilename;
  41633. private static _getDirectLoad;
  41634. private static _loadData;
  41635. private static _getFileInfo;
  41636. /**
  41637. * Gets a plugin that can load the given extension
  41638. * @param extension defines the extension to load
  41639. * @returns a plugin or null if none works
  41640. */
  41641. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41642. /**
  41643. * Gets a boolean indicating that the given extension can be loaded
  41644. * @param extension defines the extension to load
  41645. * @returns true if the extension is supported
  41646. */
  41647. static IsPluginForExtensionAvailable(extension: string): boolean;
  41648. /**
  41649. * Adds a new plugin to the list of registered plugins
  41650. * @param plugin defines the plugin to add
  41651. */
  41652. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41653. /**
  41654. * Import meshes into a scene
  41655. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41656. * @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)
  41657. * @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)
  41658. * @param scene the instance of BABYLON.Scene to append to
  41659. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41660. * @param onProgress a callback with a progress event for each file being loaded
  41661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41662. * @param pluginExtension the extension used to determine the plugin
  41663. * @returns The loaded plugin
  41664. */
  41665. 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>;
  41666. /**
  41667. * Import meshes into a scene
  41668. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41669. * @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)
  41670. * @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)
  41671. * @param scene the instance of BABYLON.Scene to append to
  41672. * @param onProgress a callback with a progress event for each file being loaded
  41673. * @param pluginExtension the extension used to determine the plugin
  41674. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41675. */
  41676. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41677. meshes: AbstractMesh[];
  41678. particleSystems: IParticleSystem[];
  41679. skeletons: Skeleton[];
  41680. animationGroups: AnimationGroup[];
  41681. }>;
  41682. /**
  41683. * Load a scene
  41684. * @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)
  41685. * @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)
  41686. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41687. * @param onSuccess a callback with the scene when import succeeds
  41688. * @param onProgress a callback with a progress event for each file being loaded
  41689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41690. * @param pluginExtension the extension used to determine the plugin
  41691. * @returns The loaded plugin
  41692. */
  41693. 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>;
  41694. /**
  41695. * Load a scene
  41696. * @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)
  41697. * @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)
  41698. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41699. * @param onProgress a callback with a progress event for each file being loaded
  41700. * @param pluginExtension the extension used to determine the plugin
  41701. * @returns The loaded scene
  41702. */
  41703. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41704. /**
  41705. * Append a scene
  41706. * @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)
  41707. * @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)
  41708. * @param scene is the instance of BABYLON.Scene to append to
  41709. * @param onSuccess a callback with the scene when import succeeds
  41710. * @param onProgress a callback with a progress event for each file being loaded
  41711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41712. * @param pluginExtension the extension used to determine the plugin
  41713. * @returns The loaded plugin
  41714. */
  41715. 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>;
  41716. /**
  41717. * Append a scene
  41718. * @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)
  41719. * @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)
  41720. * @param scene is the instance of BABYLON.Scene to append to
  41721. * @param onProgress a callback with a progress event for each file being loaded
  41722. * @param pluginExtension the extension used to determine the plugin
  41723. * @returns The given scene
  41724. */
  41725. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41726. /**
  41727. * Load a scene into an asset container
  41728. * @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)
  41729. * @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)
  41730. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41731. * @param onSuccess a callback with the scene when import succeeds
  41732. * @param onProgress a callback with a progress event for each file being loaded
  41733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41734. * @param pluginExtension the extension used to determine the plugin
  41735. * @returns The loaded plugin
  41736. */
  41737. 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>;
  41738. /**
  41739. * Load a scene into an asset container
  41740. * @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)
  41741. * @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)
  41742. * @param scene is the instance of Scene to append to
  41743. * @param onProgress a callback with a progress event for each file being loaded
  41744. * @param pluginExtension the extension used to determine the plugin
  41745. * @returns The loaded asset container
  41746. */
  41747. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41748. }
  41749. }
  41750. declare module BABYLON {
  41751. /**
  41752. * Google Daydream controller
  41753. */
  41754. export class DaydreamController extends WebVRController {
  41755. /**
  41756. * Base Url for the controller model.
  41757. */
  41758. static MODEL_BASE_URL: string;
  41759. /**
  41760. * File name for the controller model.
  41761. */
  41762. static MODEL_FILENAME: string;
  41763. /**
  41764. * Gamepad Id prefix used to identify Daydream Controller.
  41765. */
  41766. static readonly GAMEPAD_ID_PREFIX: string;
  41767. /**
  41768. * Creates a new DaydreamController from a gamepad
  41769. * @param vrGamepad the gamepad that the controller should be created from
  41770. */
  41771. constructor(vrGamepad: any);
  41772. /**
  41773. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41774. * @param scene scene in which to add meshes
  41775. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41776. */
  41777. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41778. /**
  41779. * Called once for each button that changed state since the last frame
  41780. * @param buttonIdx Which button index changed
  41781. * @param state New state of the button
  41782. * @param changes Which properties on the state changed since last frame
  41783. */
  41784. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41785. }
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * Gear VR Controller
  41790. */
  41791. export class GearVRController extends WebVRController {
  41792. /**
  41793. * Base Url for the controller model.
  41794. */
  41795. static MODEL_BASE_URL: string;
  41796. /**
  41797. * File name for the controller model.
  41798. */
  41799. static MODEL_FILENAME: string;
  41800. /**
  41801. * Gamepad Id prefix used to identify this controller.
  41802. */
  41803. static readonly GAMEPAD_ID_PREFIX: string;
  41804. private readonly _buttonIndexToObservableNameMap;
  41805. /**
  41806. * Creates a new GearVRController from a gamepad
  41807. * @param vrGamepad the gamepad that the controller should be created from
  41808. */
  41809. constructor(vrGamepad: any);
  41810. /**
  41811. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41812. * @param scene scene in which to add meshes
  41813. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41814. */
  41815. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41816. /**
  41817. * Called once for each button that changed state since the last frame
  41818. * @param buttonIdx Which button index changed
  41819. * @param state New state of the button
  41820. * @param changes Which properties on the state changed since last frame
  41821. */
  41822. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41823. }
  41824. }
  41825. declare module BABYLON {
  41826. /**
  41827. * Generic Controller
  41828. */
  41829. export class GenericController extends WebVRController {
  41830. /**
  41831. * Base Url for the controller model.
  41832. */
  41833. static readonly MODEL_BASE_URL: string;
  41834. /**
  41835. * File name for the controller model.
  41836. */
  41837. static readonly MODEL_FILENAME: string;
  41838. /**
  41839. * Creates a new GenericController from a gamepad
  41840. * @param vrGamepad the gamepad that the controller should be created from
  41841. */
  41842. constructor(vrGamepad: any);
  41843. /**
  41844. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41845. * @param scene scene in which to add meshes
  41846. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41847. */
  41848. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41849. /**
  41850. * Called once for each button that changed state since the last frame
  41851. * @param buttonIdx Which button index changed
  41852. * @param state New state of the button
  41853. * @param changes Which properties on the state changed since last frame
  41854. */
  41855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41856. }
  41857. }
  41858. declare module BABYLON {
  41859. /**
  41860. * Oculus Touch Controller
  41861. */
  41862. export class OculusTouchController extends WebVRController {
  41863. /**
  41864. * Base Url for the controller model.
  41865. */
  41866. static MODEL_BASE_URL: string;
  41867. /**
  41868. * File name for the left controller model.
  41869. */
  41870. static MODEL_LEFT_FILENAME: string;
  41871. /**
  41872. * File name for the right controller model.
  41873. */
  41874. static MODEL_RIGHT_FILENAME: string;
  41875. /**
  41876. * Fired when the secondary trigger on this controller is modified
  41877. */
  41878. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41879. /**
  41880. * Fired when the thumb rest on this controller is modified
  41881. */
  41882. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41883. /**
  41884. * Creates a new OculusTouchController from a gamepad
  41885. * @param vrGamepad the gamepad that the controller should be created from
  41886. */
  41887. constructor(vrGamepad: any);
  41888. /**
  41889. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41890. * @param scene scene in which to add meshes
  41891. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41892. */
  41893. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41894. /**
  41895. * Fired when the A button on this controller is modified
  41896. */
  41897. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41898. /**
  41899. * Fired when the B button on this controller is modified
  41900. */
  41901. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41902. /**
  41903. * Fired when the X button on this controller is modified
  41904. */
  41905. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41906. /**
  41907. * Fired when the Y button on this controller is modified
  41908. */
  41909. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41910. /**
  41911. * Called once for each button that changed state since the last frame
  41912. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41913. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41914. * 2) secondary trigger (same)
  41915. * 3) A (right) X (left), touch, pressed = value
  41916. * 4) B / Y
  41917. * 5) thumb rest
  41918. * @param buttonIdx Which button index changed
  41919. * @param state New state of the button
  41920. * @param changes Which properties on the state changed since last frame
  41921. */
  41922. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41923. }
  41924. }
  41925. declare module BABYLON {
  41926. /**
  41927. * Vive Controller
  41928. */
  41929. export class ViveController extends WebVRController {
  41930. /**
  41931. * Base Url for the controller model.
  41932. */
  41933. static MODEL_BASE_URL: string;
  41934. /**
  41935. * File name for the controller model.
  41936. */
  41937. static MODEL_FILENAME: string;
  41938. /**
  41939. * Creates a new ViveController from a gamepad
  41940. * @param vrGamepad the gamepad that the controller should be created from
  41941. */
  41942. constructor(vrGamepad: any);
  41943. /**
  41944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41945. * @param scene scene in which to add meshes
  41946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41947. */
  41948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41949. /**
  41950. * Fired when the left button on this controller is modified
  41951. */
  41952. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41953. /**
  41954. * Fired when the right button on this controller is modified
  41955. */
  41956. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41957. /**
  41958. * Fired when the menu button on this controller is modified
  41959. */
  41960. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41961. /**
  41962. * Called once for each button that changed state since the last frame
  41963. * Vive mapping:
  41964. * 0: touchpad
  41965. * 1: trigger
  41966. * 2: left AND right buttons
  41967. * 3: menu button
  41968. * @param buttonIdx Which button index changed
  41969. * @param state New state of the button
  41970. * @param changes Which properties on the state changed since last frame
  41971. */
  41972. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41973. }
  41974. }
  41975. declare module BABYLON {
  41976. /**
  41977. * Defines the WindowsMotionController object that the state of the windows motion controller
  41978. */
  41979. export class WindowsMotionController extends WebVRController {
  41980. /**
  41981. * The base url used to load the left and right controller models
  41982. */
  41983. static MODEL_BASE_URL: string;
  41984. /**
  41985. * The name of the left controller model file
  41986. */
  41987. static MODEL_LEFT_FILENAME: string;
  41988. /**
  41989. * The name of the right controller model file
  41990. */
  41991. static MODEL_RIGHT_FILENAME: string;
  41992. /**
  41993. * The controller name prefix for this controller type
  41994. */
  41995. static readonly GAMEPAD_ID_PREFIX: string;
  41996. /**
  41997. * The controller id pattern for this controller type
  41998. */
  41999. private static readonly GAMEPAD_ID_PATTERN;
  42000. private _loadedMeshInfo;
  42001. private readonly _mapping;
  42002. /**
  42003. * Fired when the trackpad on this controller is clicked
  42004. */
  42005. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42006. /**
  42007. * Fired when the trackpad on this controller is modified
  42008. */
  42009. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42010. /**
  42011. * The current x and y values of this controller's trackpad
  42012. */
  42013. trackpad: StickValues;
  42014. /**
  42015. * Creates a new WindowsMotionController from a gamepad
  42016. * @param vrGamepad the gamepad that the controller should be created from
  42017. */
  42018. constructor(vrGamepad: any);
  42019. /**
  42020. * Fired when the trigger on this controller is modified
  42021. */
  42022. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42023. /**
  42024. * Fired when the menu button on this controller is modified
  42025. */
  42026. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42027. /**
  42028. * Fired when the grip button on this controller is modified
  42029. */
  42030. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42031. /**
  42032. * Fired when the thumbstick button on this controller is modified
  42033. */
  42034. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42035. /**
  42036. * Fired when the touchpad button on this controller is modified
  42037. */
  42038. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42039. /**
  42040. * Fired when the touchpad values on this controller are modified
  42041. */
  42042. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42043. private _updateTrackpad;
  42044. /**
  42045. * Called once per frame by the engine.
  42046. */
  42047. update(): void;
  42048. /**
  42049. * Called once for each button that changed state since the last frame
  42050. * @param buttonIdx Which button index changed
  42051. * @param state New state of the button
  42052. * @param changes Which properties on the state changed since last frame
  42053. */
  42054. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42055. /**
  42056. * Moves the buttons on the controller mesh based on their current state
  42057. * @param buttonName the name of the button to move
  42058. * @param buttonValue the value of the button which determines the buttons new position
  42059. */
  42060. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42061. /**
  42062. * Moves the axis on the controller mesh based on its current state
  42063. * @param axis the index of the axis
  42064. * @param axisValue the value of the axis which determines the meshes new position
  42065. * @hidden
  42066. */
  42067. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42068. /**
  42069. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42070. * @param scene scene in which to add meshes
  42071. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42072. */
  42073. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42074. /**
  42075. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42076. * can be transformed by button presses and axes values, based on this._mapping.
  42077. *
  42078. * @param scene scene in which the meshes exist
  42079. * @param meshes list of meshes that make up the controller model to process
  42080. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42081. */
  42082. private processModel;
  42083. private createMeshInfo;
  42084. /**
  42085. * Gets the ray of the controller in the direction the controller is pointing
  42086. * @param length the length the resulting ray should be
  42087. * @returns a ray in the direction the controller is pointing
  42088. */
  42089. getForwardRay(length?: number): Ray;
  42090. /**
  42091. * Disposes of the controller
  42092. */
  42093. dispose(): void;
  42094. }
  42095. }
  42096. declare module BABYLON {
  42097. /**
  42098. * Single axis scale gizmo
  42099. */
  42100. export class AxisScaleGizmo extends Gizmo {
  42101. private _coloredMaterial;
  42102. /**
  42103. * Drag behavior responsible for the gizmos dragging interactions
  42104. */
  42105. dragBehavior: PointerDragBehavior;
  42106. private _pointerObserver;
  42107. /**
  42108. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42109. */
  42110. snapDistance: number;
  42111. /**
  42112. * Event that fires each time the gizmo snaps to a new location.
  42113. * * snapDistance is the the change in distance
  42114. */
  42115. onSnapObservable: Observable<{
  42116. snapDistance: number;
  42117. }>;
  42118. /**
  42119. * If the scaling operation should be done on all axis (default: false)
  42120. */
  42121. uniformScaling: boolean;
  42122. /**
  42123. * Creates an AxisScaleGizmo
  42124. * @param gizmoLayer The utility layer the gizmo will be added to
  42125. * @param dragAxis The axis which the gizmo will be able to scale on
  42126. * @param color The color of the gizmo
  42127. */
  42128. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42129. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42130. /**
  42131. * Disposes of the gizmo
  42132. */
  42133. dispose(): void;
  42134. /**
  42135. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42136. * @param mesh The mesh to replace the default mesh of the gizmo
  42137. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42138. */
  42139. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42140. }
  42141. }
  42142. declare module BABYLON {
  42143. /**
  42144. * Bounding box gizmo
  42145. */
  42146. export class BoundingBoxGizmo extends Gizmo {
  42147. private _lineBoundingBox;
  42148. private _rotateSpheresParent;
  42149. private _scaleBoxesParent;
  42150. private _boundingDimensions;
  42151. private _renderObserver;
  42152. private _pointerObserver;
  42153. private _scaleDragSpeed;
  42154. private _tmpQuaternion;
  42155. private _tmpVector;
  42156. private _tmpRotationMatrix;
  42157. /**
  42158. * 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)
  42159. */
  42160. ignoreChildren: boolean;
  42161. /**
  42162. * 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)
  42163. */
  42164. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42165. /**
  42166. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42167. */
  42168. rotationSphereSize: number;
  42169. /**
  42170. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42171. */
  42172. scaleBoxSize: number;
  42173. /**
  42174. * 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)
  42175. */
  42176. fixedDragMeshScreenSize: boolean;
  42177. /**
  42178. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42179. */
  42180. fixedDragMeshScreenSizeDistanceFactor: number;
  42181. /**
  42182. * Fired when a rotation sphere or scale box is dragged
  42183. */
  42184. onDragStartObservable: Observable<{}>;
  42185. /**
  42186. * Fired when a scale box is dragged
  42187. */
  42188. onScaleBoxDragObservable: Observable<{}>;
  42189. /**
  42190. * Fired when a scale box drag is ended
  42191. */
  42192. onScaleBoxDragEndObservable: Observable<{}>;
  42193. /**
  42194. * Fired when a rotation sphere is dragged
  42195. */
  42196. onRotationSphereDragObservable: Observable<{}>;
  42197. /**
  42198. * Fired when a rotation sphere drag is ended
  42199. */
  42200. onRotationSphereDragEndObservable: Observable<{}>;
  42201. /**
  42202. * 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)
  42203. */
  42204. scalePivot: Nullable<Vector3>;
  42205. private _anchorMesh;
  42206. private _existingMeshScale;
  42207. private _dragMesh;
  42208. private pointerDragBehavior;
  42209. private coloredMaterial;
  42210. private hoverColoredMaterial;
  42211. /**
  42212. * Sets the color of the bounding box gizmo
  42213. * @param color the color to set
  42214. */
  42215. setColor(color: Color3): void;
  42216. /**
  42217. * Creates an BoundingBoxGizmo
  42218. * @param gizmoLayer The utility layer the gizmo will be added to
  42219. * @param color The color of the gizmo
  42220. */
  42221. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42223. private _selectNode;
  42224. /**
  42225. * Updates the bounding box information for the Gizmo
  42226. */
  42227. updateBoundingBox(): void;
  42228. private _updateRotationSpheres;
  42229. private _updateScaleBoxes;
  42230. /**
  42231. * Enables rotation on the specified axis and disables rotation on the others
  42232. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42233. */
  42234. setEnabledRotationAxis(axis: string): void;
  42235. /**
  42236. * Enables/disables scaling
  42237. * @param enable if scaling should be enabled
  42238. */
  42239. setEnabledScaling(enable: boolean): void;
  42240. private _updateDummy;
  42241. /**
  42242. * Enables a pointer drag behavior on the bounding box of the gizmo
  42243. */
  42244. enableDragBehavior(): void;
  42245. /**
  42246. * Disposes of the gizmo
  42247. */
  42248. dispose(): void;
  42249. /**
  42250. * 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)
  42251. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42252. * @returns the bounding box mesh with the passed in mesh as a child
  42253. */
  42254. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42255. /**
  42256. * CustomMeshes are not supported by this gizmo
  42257. * @param mesh The mesh to replace the default mesh of the gizmo
  42258. */
  42259. setCustomMesh(mesh: Mesh): void;
  42260. }
  42261. }
  42262. declare module BABYLON {
  42263. /**
  42264. * Single plane rotation gizmo
  42265. */
  42266. export class PlaneRotationGizmo extends Gizmo {
  42267. /**
  42268. * Drag behavior responsible for the gizmos dragging interactions
  42269. */
  42270. dragBehavior: PointerDragBehavior;
  42271. private _pointerObserver;
  42272. /**
  42273. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42274. */
  42275. snapDistance: number;
  42276. /**
  42277. * Event that fires each time the gizmo snaps to a new location.
  42278. * * snapDistance is the the change in distance
  42279. */
  42280. onSnapObservable: Observable<{
  42281. snapDistance: number;
  42282. }>;
  42283. /**
  42284. * Creates a PlaneRotationGizmo
  42285. * @param gizmoLayer The utility layer the gizmo will be added to
  42286. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42287. * @param color The color of the gizmo
  42288. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42289. */
  42290. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42292. /**
  42293. * Disposes of the gizmo
  42294. */
  42295. dispose(): void;
  42296. }
  42297. }
  42298. declare module BABYLON {
  42299. /**
  42300. * Gizmo that enables rotating a mesh along 3 axis
  42301. */
  42302. export class RotationGizmo extends Gizmo {
  42303. /**
  42304. * Internal gizmo used for interactions on the x axis
  42305. */
  42306. xGizmo: PlaneRotationGizmo;
  42307. /**
  42308. * Internal gizmo used for interactions on the y axis
  42309. */
  42310. yGizmo: PlaneRotationGizmo;
  42311. /**
  42312. * Internal gizmo used for interactions on the z axis
  42313. */
  42314. zGizmo: PlaneRotationGizmo;
  42315. /** Fires an event when any of it's sub gizmos are dragged */
  42316. onDragStartObservable: Observable<{}>;
  42317. /** Fires an event when any of it's sub gizmos are released from dragging */
  42318. onDragEndObservable: Observable<{}>;
  42319. attachedMesh: Nullable<AbstractMesh>;
  42320. /**
  42321. * Creates a RotationGizmo
  42322. * @param gizmoLayer The utility layer the gizmo will be added to
  42323. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42324. */
  42325. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42326. updateGizmoRotationToMatchAttachedMesh: boolean;
  42327. /**
  42328. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42329. */
  42330. snapDistance: number;
  42331. /**
  42332. * Ratio for the scale of the gizmo (Default: 1)
  42333. */
  42334. scaleRatio: number;
  42335. /**
  42336. * Disposes of the gizmo
  42337. */
  42338. dispose(): void;
  42339. /**
  42340. * CustomMeshes are not supported by this gizmo
  42341. * @param mesh The mesh to replace the default mesh of the gizmo
  42342. */
  42343. setCustomMesh(mesh: Mesh): void;
  42344. }
  42345. }
  42346. declare module BABYLON {
  42347. /**
  42348. * Gizmo that enables dragging a mesh along 3 axis
  42349. */
  42350. export class PositionGizmo extends Gizmo {
  42351. /**
  42352. * Internal gizmo used for interactions on the x axis
  42353. */
  42354. xGizmo: AxisDragGizmo;
  42355. /**
  42356. * Internal gizmo used for interactions on the y axis
  42357. */
  42358. yGizmo: AxisDragGizmo;
  42359. /**
  42360. * Internal gizmo used for interactions on the z axis
  42361. */
  42362. zGizmo: AxisDragGizmo;
  42363. /** Fires an event when any of it's sub gizmos are dragged */
  42364. onDragStartObservable: Observable<{}>;
  42365. /** Fires an event when any of it's sub gizmos are released from dragging */
  42366. onDragEndObservable: Observable<{}>;
  42367. attachedMesh: Nullable<AbstractMesh>;
  42368. /**
  42369. * Creates a PositionGizmo
  42370. * @param gizmoLayer The utility layer the gizmo will be added to
  42371. */
  42372. constructor(gizmoLayer?: UtilityLayerRenderer);
  42373. updateGizmoRotationToMatchAttachedMesh: boolean;
  42374. /**
  42375. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42376. */
  42377. snapDistance: number;
  42378. /**
  42379. * Ratio for the scale of the gizmo (Default: 1)
  42380. */
  42381. scaleRatio: number;
  42382. /**
  42383. * Disposes of the gizmo
  42384. */
  42385. dispose(): void;
  42386. /**
  42387. * CustomMeshes are not supported by this gizmo
  42388. * @param mesh The mesh to replace the default mesh of the gizmo
  42389. */
  42390. setCustomMesh(mesh: Mesh): void;
  42391. }
  42392. }
  42393. declare module BABYLON {
  42394. /**
  42395. * Class containing static functions to help procedurally build meshes
  42396. */
  42397. export class PolyhedronBuilder {
  42398. /**
  42399. * Creates a polyhedron mesh
  42400. * * 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
  42401. * * The parameter `size` (positive float, default 1) sets the polygon size
  42402. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42403. * * 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`
  42404. * * 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
  42405. * * 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)`)
  42406. * * 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
  42407. * * 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
  42408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42409. * * 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
  42410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42411. * @param name defines the name of the mesh
  42412. * @param options defines the options used to create the mesh
  42413. * @param scene defines the hosting scene
  42414. * @returns the polyhedron mesh
  42415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42416. */
  42417. static CreatePolyhedron(name: string, options: {
  42418. type?: number;
  42419. size?: number;
  42420. sizeX?: number;
  42421. sizeY?: number;
  42422. sizeZ?: number;
  42423. custom?: any;
  42424. faceUV?: Vector4[];
  42425. faceColors?: Color4[];
  42426. flat?: boolean;
  42427. updatable?: boolean;
  42428. sideOrientation?: number;
  42429. frontUVs?: Vector4;
  42430. backUVs?: Vector4;
  42431. }, scene: Scene): Mesh;
  42432. }
  42433. }
  42434. declare module BABYLON {
  42435. /**
  42436. * Gizmo that enables scaling a mesh along 3 axis
  42437. */
  42438. export class ScaleGizmo extends Gizmo {
  42439. /**
  42440. * Internal gizmo used for interactions on the x axis
  42441. */
  42442. xGizmo: AxisScaleGizmo;
  42443. /**
  42444. * Internal gizmo used for interactions on the y axis
  42445. */
  42446. yGizmo: AxisScaleGizmo;
  42447. /**
  42448. * Internal gizmo used for interactions on the z axis
  42449. */
  42450. zGizmo: AxisScaleGizmo;
  42451. /**
  42452. * Internal gizmo used to scale all axis equally
  42453. */
  42454. uniformScaleGizmo: AxisScaleGizmo;
  42455. /** Fires an event when any of it's sub gizmos are dragged */
  42456. onDragStartObservable: Observable<{}>;
  42457. /** Fires an event when any of it's sub gizmos are released from dragging */
  42458. onDragEndObservable: Observable<{}>;
  42459. attachedMesh: Nullable<AbstractMesh>;
  42460. /**
  42461. * Creates a ScaleGizmo
  42462. * @param gizmoLayer The utility layer the gizmo will be added to
  42463. */
  42464. constructor(gizmoLayer?: UtilityLayerRenderer);
  42465. updateGizmoRotationToMatchAttachedMesh: boolean;
  42466. /**
  42467. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42468. */
  42469. snapDistance: number;
  42470. /**
  42471. * Ratio for the scale of the gizmo (Default: 1)
  42472. */
  42473. scaleRatio: number;
  42474. /**
  42475. * Disposes of the gizmo
  42476. */
  42477. dispose(): void;
  42478. }
  42479. }
  42480. declare module BABYLON {
  42481. /**
  42482. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42483. */
  42484. export class GizmoManager implements IDisposable {
  42485. private scene;
  42486. /**
  42487. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42488. */
  42489. gizmos: {
  42490. positionGizmo: Nullable<PositionGizmo>;
  42491. rotationGizmo: Nullable<RotationGizmo>;
  42492. scaleGizmo: Nullable<ScaleGizmo>;
  42493. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42494. };
  42495. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42496. clearGizmoOnEmptyPointerEvent: boolean;
  42497. /** Fires an event when the manager is attached to a mesh */
  42498. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42499. private _gizmosEnabled;
  42500. private _pointerObserver;
  42501. private _attachedMesh;
  42502. private _boundingBoxColor;
  42503. private _defaultUtilityLayer;
  42504. private _defaultKeepDepthUtilityLayer;
  42505. /**
  42506. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42507. */
  42508. boundingBoxDragBehavior: SixDofDragBehavior;
  42509. /**
  42510. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42511. */
  42512. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42513. /**
  42514. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42515. */
  42516. usePointerToAttachGizmos: boolean;
  42517. /**
  42518. * Instatiates a gizmo manager
  42519. * @param scene the scene to overlay the gizmos on top of
  42520. */
  42521. constructor(scene: Scene);
  42522. /**
  42523. * Attaches a set of gizmos to the specified mesh
  42524. * @param mesh The mesh the gizmo's should be attached to
  42525. */
  42526. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42527. /**
  42528. * If the position gizmo is enabled
  42529. */
  42530. positionGizmoEnabled: boolean;
  42531. /**
  42532. * If the rotation gizmo is enabled
  42533. */
  42534. rotationGizmoEnabled: boolean;
  42535. /**
  42536. * If the scale gizmo is enabled
  42537. */
  42538. scaleGizmoEnabled: boolean;
  42539. /**
  42540. * If the boundingBox gizmo is enabled
  42541. */
  42542. boundingBoxGizmoEnabled: boolean;
  42543. /**
  42544. * Disposes of the gizmo manager
  42545. */
  42546. dispose(): void;
  42547. }
  42548. }
  42549. declare module BABYLON {
  42550. /**
  42551. * A directional light is defined by a direction (what a surprise!).
  42552. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42553. * 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.
  42554. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42555. */
  42556. export class DirectionalLight extends ShadowLight {
  42557. private _shadowFrustumSize;
  42558. /**
  42559. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42560. */
  42561. /**
  42562. * Specifies a fix frustum size for the shadow generation.
  42563. */
  42564. shadowFrustumSize: number;
  42565. private _shadowOrthoScale;
  42566. /**
  42567. * Gets the shadow projection scale against the optimal computed one.
  42568. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42569. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42570. */
  42571. /**
  42572. * Sets the shadow projection scale against the optimal computed one.
  42573. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42574. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42575. */
  42576. shadowOrthoScale: number;
  42577. /**
  42578. * Automatically compute the projection matrix to best fit (including all the casters)
  42579. * on each frame.
  42580. */
  42581. autoUpdateExtends: boolean;
  42582. private _orthoLeft;
  42583. private _orthoRight;
  42584. private _orthoTop;
  42585. private _orthoBottom;
  42586. /**
  42587. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42588. * The directional light is emitted from everywhere in the given direction.
  42589. * It can cast shadows.
  42590. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42591. * @param name The friendly name of the light
  42592. * @param direction The direction of the light
  42593. * @param scene The scene the light belongs to
  42594. */
  42595. constructor(name: string, direction: Vector3, scene: Scene);
  42596. /**
  42597. * Returns the string "DirectionalLight".
  42598. * @return The class name
  42599. */
  42600. getClassName(): string;
  42601. /**
  42602. * Returns the integer 1.
  42603. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42604. */
  42605. getTypeID(): number;
  42606. /**
  42607. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42608. * Returns the DirectionalLight Shadow projection matrix.
  42609. */
  42610. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42611. /**
  42612. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42613. * Returns the DirectionalLight Shadow projection matrix.
  42614. */
  42615. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42616. /**
  42617. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42618. * Returns the DirectionalLight Shadow projection matrix.
  42619. */
  42620. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42621. protected _buildUniformLayout(): void;
  42622. /**
  42623. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42624. * @param effect The effect to update
  42625. * @param lightIndex The index of the light in the effect to update
  42626. * @returns The directional light
  42627. */
  42628. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42629. /**
  42630. * Gets the minZ used for shadow according to both the scene and the light.
  42631. *
  42632. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42633. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42634. * @param activeCamera The camera we are returning the min for
  42635. * @returns the depth min z
  42636. */
  42637. getDepthMinZ(activeCamera: Camera): number;
  42638. /**
  42639. * Gets the maxZ used for shadow according to both the scene and the light.
  42640. *
  42641. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42642. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42643. * @param activeCamera The camera we are returning the max for
  42644. * @returns the depth max z
  42645. */
  42646. getDepthMaxZ(activeCamera: Camera): number;
  42647. /**
  42648. * Prepares the list of defines specific to the light type.
  42649. * @param defines the list of defines
  42650. * @param lightIndex defines the index of the light for the effect
  42651. */
  42652. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42653. }
  42654. }
  42655. declare module BABYLON {
  42656. /**
  42657. * Class containing static functions to help procedurally build meshes
  42658. */
  42659. export class HemisphereBuilder {
  42660. /**
  42661. * Creates a hemisphere mesh
  42662. * @param name defines the name of the mesh
  42663. * @param options defines the options used to create the mesh
  42664. * @param scene defines the hosting scene
  42665. * @returns the hemisphere mesh
  42666. */
  42667. static CreateHemisphere(name: string, options: {
  42668. segments?: number;
  42669. diameter?: number;
  42670. sideOrientation?: number;
  42671. }, scene: any): Mesh;
  42672. }
  42673. }
  42674. declare module BABYLON {
  42675. /**
  42676. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42677. * These values define a cone of light starting from the position, emitting toward the direction.
  42678. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42679. * and the exponent defines the speed of the decay of the light with distance (reach).
  42680. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42681. */
  42682. export class SpotLight extends ShadowLight {
  42683. private _angle;
  42684. private _innerAngle;
  42685. private _cosHalfAngle;
  42686. private _lightAngleScale;
  42687. private _lightAngleOffset;
  42688. /**
  42689. * Gets the cone angle of the spot light in Radians.
  42690. */
  42691. /**
  42692. * Sets the cone angle of the spot light in Radians.
  42693. */
  42694. angle: number;
  42695. /**
  42696. * Only used in gltf falloff mode, this defines the angle where
  42697. * the directional falloff will start before cutting at angle which could be seen
  42698. * as outer angle.
  42699. */
  42700. /**
  42701. * Only used in gltf falloff mode, this defines the angle where
  42702. * the directional falloff will start before cutting at angle which could be seen
  42703. * as outer angle.
  42704. */
  42705. innerAngle: number;
  42706. private _shadowAngleScale;
  42707. /**
  42708. * Allows scaling the angle of the light for shadow generation only.
  42709. */
  42710. /**
  42711. * Allows scaling the angle of the light for shadow generation only.
  42712. */
  42713. shadowAngleScale: number;
  42714. /**
  42715. * The light decay speed with the distance from the emission spot.
  42716. */
  42717. exponent: number;
  42718. private _projectionTextureMatrix;
  42719. /**
  42720. * Allows reading the projecton texture
  42721. */
  42722. readonly projectionTextureMatrix: Matrix;
  42723. protected _projectionTextureLightNear: number;
  42724. /**
  42725. * Gets the near clip of the Spotlight for texture projection.
  42726. */
  42727. /**
  42728. * Sets the near clip of the Spotlight for texture projection.
  42729. */
  42730. projectionTextureLightNear: number;
  42731. protected _projectionTextureLightFar: number;
  42732. /**
  42733. * Gets the far clip of the Spotlight for texture projection.
  42734. */
  42735. /**
  42736. * Sets the far clip of the Spotlight for texture projection.
  42737. */
  42738. projectionTextureLightFar: number;
  42739. protected _projectionTextureUpDirection: Vector3;
  42740. /**
  42741. * Gets the Up vector of the Spotlight for texture projection.
  42742. */
  42743. /**
  42744. * Sets the Up vector of the Spotlight for texture projection.
  42745. */
  42746. projectionTextureUpDirection: Vector3;
  42747. private _projectionTexture;
  42748. /**
  42749. * Gets the projection texture of the light.
  42750. */
  42751. /**
  42752. * Sets the projection texture of the light.
  42753. */
  42754. projectionTexture: Nullable<BaseTexture>;
  42755. private _projectionTextureViewLightDirty;
  42756. private _projectionTextureProjectionLightDirty;
  42757. private _projectionTextureDirty;
  42758. private _projectionTextureViewTargetVector;
  42759. private _projectionTextureViewLightMatrix;
  42760. private _projectionTextureProjectionLightMatrix;
  42761. private _projectionTextureScalingMatrix;
  42762. /**
  42763. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42764. * It can cast shadows.
  42765. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42766. * @param name The light friendly name
  42767. * @param position The position of the spot light in the scene
  42768. * @param direction The direction of the light in the scene
  42769. * @param angle The cone angle of the light in Radians
  42770. * @param exponent The light decay speed with the distance from the emission spot
  42771. * @param scene The scene the lights belongs to
  42772. */
  42773. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42774. /**
  42775. * Returns the string "SpotLight".
  42776. * @returns the class name
  42777. */
  42778. getClassName(): string;
  42779. /**
  42780. * Returns the integer 2.
  42781. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42782. */
  42783. getTypeID(): number;
  42784. /**
  42785. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42786. */
  42787. protected _setDirection(value: Vector3): void;
  42788. /**
  42789. * Overrides the position setter to recompute the projection texture view light Matrix.
  42790. */
  42791. protected _setPosition(value: Vector3): void;
  42792. /**
  42793. * 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.
  42794. * Returns the SpotLight.
  42795. */
  42796. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42797. protected _computeProjectionTextureViewLightMatrix(): void;
  42798. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42799. /**
  42800. * Main function for light texture projection matrix computing.
  42801. */
  42802. protected _computeProjectionTextureMatrix(): void;
  42803. protected _buildUniformLayout(): void;
  42804. private _computeAngleValues;
  42805. /**
  42806. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42807. * @param effect The effect to update
  42808. * @param lightIndex The index of the light in the effect to update
  42809. * @returns The spot light
  42810. */
  42811. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42812. /**
  42813. * Disposes the light and the associated resources.
  42814. */
  42815. dispose(): void;
  42816. /**
  42817. * Prepares the list of defines specific to the light type.
  42818. * @param defines the list of defines
  42819. * @param lightIndex defines the index of the light for the effect
  42820. */
  42821. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42822. }
  42823. }
  42824. declare module BABYLON {
  42825. /**
  42826. * Gizmo that enables viewing a light
  42827. */
  42828. export class LightGizmo extends Gizmo {
  42829. private _lightMesh;
  42830. private _material;
  42831. /**
  42832. * Creates a LightGizmo
  42833. * @param gizmoLayer The utility layer the gizmo will be added to
  42834. */
  42835. constructor(gizmoLayer?: UtilityLayerRenderer);
  42836. private _light;
  42837. /**
  42838. * The light that the gizmo is attached to
  42839. */
  42840. light: Nullable<Light>;
  42841. /**
  42842. * @hidden
  42843. * Updates the gizmo to match the attached mesh's position/rotation
  42844. */
  42845. protected _update(): void;
  42846. private static _Scale;
  42847. /**
  42848. * Creates the lines for a light mesh
  42849. */
  42850. private static _createLightLines;
  42851. private static _CreateHemisphericLightMesh;
  42852. private static _CreatePointLightMesh;
  42853. private static _CreateSpotLightMesh;
  42854. private static _CreateDirectionalLightMesh;
  42855. }
  42856. }
  42857. declare module BABYLON {
  42858. /** @hidden */
  42859. export var backgroundFragmentDeclaration: {
  42860. name: string;
  42861. shader: string;
  42862. };
  42863. }
  42864. declare module BABYLON {
  42865. /** @hidden */
  42866. export var backgroundUboDeclaration: {
  42867. name: string;
  42868. shader: string;
  42869. };
  42870. }
  42871. declare module BABYLON {
  42872. /** @hidden */
  42873. export var backgroundPixelShader: {
  42874. name: string;
  42875. shader: string;
  42876. };
  42877. }
  42878. declare module BABYLON {
  42879. /** @hidden */
  42880. export var backgroundVertexDeclaration: {
  42881. name: string;
  42882. shader: string;
  42883. };
  42884. }
  42885. declare module BABYLON {
  42886. /** @hidden */
  42887. export var backgroundVertexShader: {
  42888. name: string;
  42889. shader: string;
  42890. };
  42891. }
  42892. declare module BABYLON {
  42893. /**
  42894. * Background material used to create an efficient environement around your scene.
  42895. */
  42896. export class BackgroundMaterial extends PushMaterial {
  42897. /**
  42898. * Standard reflectance value at parallel view angle.
  42899. */
  42900. static StandardReflectance0: number;
  42901. /**
  42902. * Standard reflectance value at grazing angle.
  42903. */
  42904. static StandardReflectance90: number;
  42905. protected _primaryColor: Color3;
  42906. /**
  42907. * Key light Color (multiply against the environement texture)
  42908. */
  42909. primaryColor: Color3;
  42910. protected __perceptualColor: Nullable<Color3>;
  42911. /**
  42912. * Experimental Internal Use Only.
  42913. *
  42914. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42915. * This acts as a helper to set the primary color to a more "human friendly" value.
  42916. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42917. * output color as close as possible from the chosen value.
  42918. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42919. * part of lighting setup.)
  42920. */
  42921. _perceptualColor: Nullable<Color3>;
  42922. protected _primaryColorShadowLevel: float;
  42923. /**
  42924. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42925. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42926. */
  42927. primaryColorShadowLevel: float;
  42928. protected _primaryColorHighlightLevel: float;
  42929. /**
  42930. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42931. * The primary color is used at the level chosen to define what the white area would look.
  42932. */
  42933. primaryColorHighlightLevel: float;
  42934. protected _reflectionTexture: Nullable<BaseTexture>;
  42935. /**
  42936. * Reflection Texture used in the material.
  42937. * Should be author in a specific way for the best result (refer to the documentation).
  42938. */
  42939. reflectionTexture: Nullable<BaseTexture>;
  42940. protected _reflectionBlur: float;
  42941. /**
  42942. * Reflection Texture level of blur.
  42943. *
  42944. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42945. * texture twice.
  42946. */
  42947. reflectionBlur: float;
  42948. protected _diffuseTexture: Nullable<BaseTexture>;
  42949. /**
  42950. * Diffuse Texture used in the material.
  42951. * Should be author in a specific way for the best result (refer to the documentation).
  42952. */
  42953. diffuseTexture: Nullable<BaseTexture>;
  42954. protected _shadowLights: Nullable<IShadowLight[]>;
  42955. /**
  42956. * Specify the list of lights casting shadow on the material.
  42957. * All scene shadow lights will be included if null.
  42958. */
  42959. shadowLights: Nullable<IShadowLight[]>;
  42960. protected _shadowLevel: float;
  42961. /**
  42962. * Helps adjusting the shadow to a softer level if required.
  42963. * 0 means black shadows and 1 means no shadows.
  42964. */
  42965. shadowLevel: float;
  42966. protected _sceneCenter: Vector3;
  42967. /**
  42968. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42969. * It is usually zero but might be interesting to modify according to your setup.
  42970. */
  42971. sceneCenter: Vector3;
  42972. protected _opacityFresnel: boolean;
  42973. /**
  42974. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42975. * This helps ensuring a nice transition when the camera goes under the ground.
  42976. */
  42977. opacityFresnel: boolean;
  42978. protected _reflectionFresnel: boolean;
  42979. /**
  42980. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42981. * This helps adding a mirror texture on the ground.
  42982. */
  42983. reflectionFresnel: boolean;
  42984. protected _reflectionFalloffDistance: number;
  42985. /**
  42986. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42987. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42988. */
  42989. reflectionFalloffDistance: number;
  42990. protected _reflectionAmount: number;
  42991. /**
  42992. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42993. */
  42994. reflectionAmount: number;
  42995. protected _reflectionReflectance0: number;
  42996. /**
  42997. * This specifies the weight of the reflection at grazing angle.
  42998. */
  42999. reflectionReflectance0: number;
  43000. protected _reflectionReflectance90: number;
  43001. /**
  43002. * This specifies the weight of the reflection at a perpendicular point of view.
  43003. */
  43004. reflectionReflectance90: number;
  43005. /**
  43006. * Sets the reflection reflectance fresnel values according to the default standard
  43007. * empirically know to work well :-)
  43008. */
  43009. reflectionStandardFresnelWeight: number;
  43010. protected _useRGBColor: boolean;
  43011. /**
  43012. * Helps to directly use the maps channels instead of their level.
  43013. */
  43014. useRGBColor: boolean;
  43015. protected _enableNoise: boolean;
  43016. /**
  43017. * This helps reducing the banding effect that could occur on the background.
  43018. */
  43019. enableNoise: boolean;
  43020. /**
  43021. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43022. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43023. * Recommended to be keep at 1.0 except for special cases.
  43024. */
  43025. fovMultiplier: number;
  43026. private _fovMultiplier;
  43027. /**
  43028. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43029. */
  43030. useEquirectangularFOV: boolean;
  43031. private _maxSimultaneousLights;
  43032. /**
  43033. * Number of Simultaneous lights allowed on the material.
  43034. */
  43035. maxSimultaneousLights: int;
  43036. /**
  43037. * Default configuration related to image processing available in the Background Material.
  43038. */
  43039. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43040. /**
  43041. * Keep track of the image processing observer to allow dispose and replace.
  43042. */
  43043. private _imageProcessingObserver;
  43044. /**
  43045. * Attaches a new image processing configuration to the PBR Material.
  43046. * @param configuration (if null the scene configuration will be use)
  43047. */
  43048. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43049. /**
  43050. * Gets the image processing configuration used either in this material.
  43051. */
  43052. /**
  43053. * Sets the Default image processing configuration used either in the this material.
  43054. *
  43055. * If sets to null, the scene one is in use.
  43056. */
  43057. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43058. /**
  43059. * Gets wether the color curves effect is enabled.
  43060. */
  43061. /**
  43062. * Sets wether the color curves effect is enabled.
  43063. */
  43064. cameraColorCurvesEnabled: boolean;
  43065. /**
  43066. * Gets wether the color grading effect is enabled.
  43067. */
  43068. /**
  43069. * Gets wether the color grading effect is enabled.
  43070. */
  43071. cameraColorGradingEnabled: boolean;
  43072. /**
  43073. * Gets wether tonemapping is enabled or not.
  43074. */
  43075. /**
  43076. * Sets wether tonemapping is enabled or not
  43077. */
  43078. cameraToneMappingEnabled: boolean;
  43079. /**
  43080. * The camera exposure used on this material.
  43081. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43082. * This corresponds to a photographic exposure.
  43083. */
  43084. /**
  43085. * The camera exposure used on this material.
  43086. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43087. * This corresponds to a photographic exposure.
  43088. */
  43089. cameraExposure: float;
  43090. /**
  43091. * Gets The camera contrast used on this material.
  43092. */
  43093. /**
  43094. * Sets The camera contrast used on this material.
  43095. */
  43096. cameraContrast: float;
  43097. /**
  43098. * Gets the Color Grading 2D Lookup Texture.
  43099. */
  43100. /**
  43101. * Sets the Color Grading 2D Lookup Texture.
  43102. */
  43103. cameraColorGradingTexture: Nullable<BaseTexture>;
  43104. /**
  43105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43107. * 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;
  43108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43109. */
  43110. /**
  43111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43113. * 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;
  43114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43115. */
  43116. cameraColorCurves: Nullable<ColorCurves>;
  43117. /**
  43118. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43119. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43120. */
  43121. switchToBGR: boolean;
  43122. private _renderTargets;
  43123. private _reflectionControls;
  43124. private _white;
  43125. private _primaryShadowColor;
  43126. private _primaryHighlightColor;
  43127. /**
  43128. * Instantiates a Background Material in the given scene
  43129. * @param name The friendly name of the material
  43130. * @param scene The scene to add the material to
  43131. */
  43132. constructor(name: string, scene: Scene);
  43133. /**
  43134. * Gets a boolean indicating that current material needs to register RTT
  43135. */
  43136. readonly hasRenderTargetTextures: boolean;
  43137. /**
  43138. * The entire material has been created in order to prevent overdraw.
  43139. * @returns false
  43140. */
  43141. needAlphaTesting(): boolean;
  43142. /**
  43143. * The entire material has been created in order to prevent overdraw.
  43144. * @returns true if blending is enable
  43145. */
  43146. needAlphaBlending(): boolean;
  43147. /**
  43148. * Checks wether the material is ready to be rendered for a given mesh.
  43149. * @param mesh The mesh to render
  43150. * @param subMesh The submesh to check against
  43151. * @param useInstances Specify wether or not the material is used with instances
  43152. * @returns true if all the dependencies are ready (Textures, Effects...)
  43153. */
  43154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43155. /**
  43156. * Compute the primary color according to the chosen perceptual color.
  43157. */
  43158. private _computePrimaryColorFromPerceptualColor;
  43159. /**
  43160. * Compute the highlights and shadow colors according to their chosen levels.
  43161. */
  43162. private _computePrimaryColors;
  43163. /**
  43164. * Build the uniform buffer used in the material.
  43165. */
  43166. buildUniformLayout(): void;
  43167. /**
  43168. * Unbind the material.
  43169. */
  43170. unbind(): void;
  43171. /**
  43172. * Bind only the world matrix to the material.
  43173. * @param world The world matrix to bind.
  43174. */
  43175. bindOnlyWorldMatrix(world: Matrix): void;
  43176. /**
  43177. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43178. * @param world The world matrix to bind.
  43179. * @param subMesh The submesh to bind for.
  43180. */
  43181. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43182. /**
  43183. * Dispose the material.
  43184. * @param forceDisposeEffect Force disposal of the associated effect.
  43185. * @param forceDisposeTextures Force disposal of the associated textures.
  43186. */
  43187. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43188. /**
  43189. * Clones the material.
  43190. * @param name The cloned name.
  43191. * @returns The cloned material.
  43192. */
  43193. clone(name: string): BackgroundMaterial;
  43194. /**
  43195. * Serializes the current material to its JSON representation.
  43196. * @returns The JSON representation.
  43197. */
  43198. serialize(): any;
  43199. /**
  43200. * Gets the class name of the material
  43201. * @returns "BackgroundMaterial"
  43202. */
  43203. getClassName(): string;
  43204. /**
  43205. * Parse a JSON input to create back a background material.
  43206. * @param source The JSON data to parse
  43207. * @param scene The scene to create the parsed material in
  43208. * @param rootUrl The root url of the assets the material depends upon
  43209. * @returns the instantiated BackgroundMaterial.
  43210. */
  43211. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Represents the different options available during the creation of
  43217. * a Environment helper.
  43218. *
  43219. * This can control the default ground, skybox and image processing setup of your scene.
  43220. */
  43221. export interface IEnvironmentHelperOptions {
  43222. /**
  43223. * Specifies wether or not to create a ground.
  43224. * True by default.
  43225. */
  43226. createGround: boolean;
  43227. /**
  43228. * Specifies the ground size.
  43229. * 15 by default.
  43230. */
  43231. groundSize: number;
  43232. /**
  43233. * The texture used on the ground for the main color.
  43234. * Comes from the BabylonJS CDN by default.
  43235. *
  43236. * Remarks: Can be either a texture or a url.
  43237. */
  43238. groundTexture: string | BaseTexture;
  43239. /**
  43240. * The color mixed in the ground texture by default.
  43241. * BabylonJS clearColor by default.
  43242. */
  43243. groundColor: Color3;
  43244. /**
  43245. * Specifies the ground opacity.
  43246. * 1 by default.
  43247. */
  43248. groundOpacity: number;
  43249. /**
  43250. * Enables the ground to receive shadows.
  43251. * True by default.
  43252. */
  43253. enableGroundShadow: boolean;
  43254. /**
  43255. * Helps preventing the shadow to be fully black on the ground.
  43256. * 0.5 by default.
  43257. */
  43258. groundShadowLevel: number;
  43259. /**
  43260. * Creates a mirror texture attach to the ground.
  43261. * false by default.
  43262. */
  43263. enableGroundMirror: boolean;
  43264. /**
  43265. * Specifies the ground mirror size ratio.
  43266. * 0.3 by default as the default kernel is 64.
  43267. */
  43268. groundMirrorSizeRatio: number;
  43269. /**
  43270. * Specifies the ground mirror blur kernel size.
  43271. * 64 by default.
  43272. */
  43273. groundMirrorBlurKernel: number;
  43274. /**
  43275. * Specifies the ground mirror visibility amount.
  43276. * 1 by default
  43277. */
  43278. groundMirrorAmount: number;
  43279. /**
  43280. * Specifies the ground mirror reflectance weight.
  43281. * This uses the standard weight of the background material to setup the fresnel effect
  43282. * of the mirror.
  43283. * 1 by default.
  43284. */
  43285. groundMirrorFresnelWeight: number;
  43286. /**
  43287. * Specifies the ground mirror Falloff distance.
  43288. * This can helps reducing the size of the reflection.
  43289. * 0 by Default.
  43290. */
  43291. groundMirrorFallOffDistance: number;
  43292. /**
  43293. * Specifies the ground mirror texture type.
  43294. * Unsigned Int by Default.
  43295. */
  43296. groundMirrorTextureType: number;
  43297. /**
  43298. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43299. * the shown objects.
  43300. */
  43301. groundYBias: number;
  43302. /**
  43303. * Specifies wether or not to create a skybox.
  43304. * True by default.
  43305. */
  43306. createSkybox: boolean;
  43307. /**
  43308. * Specifies the skybox size.
  43309. * 20 by default.
  43310. */
  43311. skyboxSize: number;
  43312. /**
  43313. * The texture used on the skybox for the main color.
  43314. * Comes from the BabylonJS CDN by default.
  43315. *
  43316. * Remarks: Can be either a texture or a url.
  43317. */
  43318. skyboxTexture: string | BaseTexture;
  43319. /**
  43320. * The color mixed in the skybox texture by default.
  43321. * BabylonJS clearColor by default.
  43322. */
  43323. skyboxColor: Color3;
  43324. /**
  43325. * The background rotation around the Y axis of the scene.
  43326. * This helps aligning the key lights of your scene with the background.
  43327. * 0 by default.
  43328. */
  43329. backgroundYRotation: number;
  43330. /**
  43331. * Compute automatically the size of the elements to best fit with the scene.
  43332. */
  43333. sizeAuto: boolean;
  43334. /**
  43335. * Default position of the rootMesh if autoSize is not true.
  43336. */
  43337. rootPosition: Vector3;
  43338. /**
  43339. * Sets up the image processing in the scene.
  43340. * true by default.
  43341. */
  43342. setupImageProcessing: boolean;
  43343. /**
  43344. * The texture used as your environment texture in the scene.
  43345. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43346. *
  43347. * Remarks: Can be either a texture or a url.
  43348. */
  43349. environmentTexture: string | BaseTexture;
  43350. /**
  43351. * The value of the exposure to apply to the scene.
  43352. * 0.6 by default if setupImageProcessing is true.
  43353. */
  43354. cameraExposure: number;
  43355. /**
  43356. * The value of the contrast to apply to the scene.
  43357. * 1.6 by default if setupImageProcessing is true.
  43358. */
  43359. cameraContrast: number;
  43360. /**
  43361. * Specifies wether or not tonemapping should be enabled in the scene.
  43362. * true by default if setupImageProcessing is true.
  43363. */
  43364. toneMappingEnabled: boolean;
  43365. }
  43366. /**
  43367. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43368. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43369. * It also helps with the default setup of your imageProcessing configuration.
  43370. */
  43371. export class EnvironmentHelper {
  43372. /**
  43373. * Default ground texture URL.
  43374. */
  43375. private static _groundTextureCDNUrl;
  43376. /**
  43377. * Default skybox texture URL.
  43378. */
  43379. private static _skyboxTextureCDNUrl;
  43380. /**
  43381. * Default environment texture URL.
  43382. */
  43383. private static _environmentTextureCDNUrl;
  43384. /**
  43385. * Creates the default options for the helper.
  43386. */
  43387. private static _getDefaultOptions;
  43388. private _rootMesh;
  43389. /**
  43390. * Gets the root mesh created by the helper.
  43391. */
  43392. readonly rootMesh: Mesh;
  43393. private _skybox;
  43394. /**
  43395. * Gets the skybox created by the helper.
  43396. */
  43397. readonly skybox: Nullable<Mesh>;
  43398. private _skyboxTexture;
  43399. /**
  43400. * Gets the skybox texture created by the helper.
  43401. */
  43402. readonly skyboxTexture: Nullable<BaseTexture>;
  43403. private _skyboxMaterial;
  43404. /**
  43405. * Gets the skybox material created by the helper.
  43406. */
  43407. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43408. private _ground;
  43409. /**
  43410. * Gets the ground mesh created by the helper.
  43411. */
  43412. readonly ground: Nullable<Mesh>;
  43413. private _groundTexture;
  43414. /**
  43415. * Gets the ground texture created by the helper.
  43416. */
  43417. readonly groundTexture: Nullable<BaseTexture>;
  43418. private _groundMirror;
  43419. /**
  43420. * Gets the ground mirror created by the helper.
  43421. */
  43422. readonly groundMirror: Nullable<MirrorTexture>;
  43423. /**
  43424. * Gets the ground mirror render list to helps pushing the meshes
  43425. * you wish in the ground reflection.
  43426. */
  43427. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43428. private _groundMaterial;
  43429. /**
  43430. * Gets the ground material created by the helper.
  43431. */
  43432. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43433. /**
  43434. * Stores the creation options.
  43435. */
  43436. private readonly _scene;
  43437. private _options;
  43438. /**
  43439. * This observable will be notified with any error during the creation of the environment,
  43440. * mainly texture creation errors.
  43441. */
  43442. onErrorObservable: Observable<{
  43443. message?: string;
  43444. exception?: any;
  43445. }>;
  43446. /**
  43447. * constructor
  43448. * @param options Defines the options we want to customize the helper
  43449. * @param scene The scene to add the material to
  43450. */
  43451. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43452. /**
  43453. * Updates the background according to the new options
  43454. * @param options
  43455. */
  43456. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43457. /**
  43458. * Sets the primary color of all the available elements.
  43459. * @param color the main color to affect to the ground and the background
  43460. */
  43461. setMainColor(color: Color3): void;
  43462. /**
  43463. * Setup the image processing according to the specified options.
  43464. */
  43465. private _setupImageProcessing;
  43466. /**
  43467. * Setup the environment texture according to the specified options.
  43468. */
  43469. private _setupEnvironmentTexture;
  43470. /**
  43471. * Setup the background according to the specified options.
  43472. */
  43473. private _setupBackground;
  43474. /**
  43475. * Get the scene sizes according to the setup.
  43476. */
  43477. private _getSceneSize;
  43478. /**
  43479. * Setup the ground according to the specified options.
  43480. */
  43481. private _setupGround;
  43482. /**
  43483. * Setup the ground material according to the specified options.
  43484. */
  43485. private _setupGroundMaterial;
  43486. /**
  43487. * Setup the ground diffuse texture according to the specified options.
  43488. */
  43489. private _setupGroundDiffuseTexture;
  43490. /**
  43491. * Setup the ground mirror texture according to the specified options.
  43492. */
  43493. private _setupGroundMirrorTexture;
  43494. /**
  43495. * Setup the ground to receive the mirror texture.
  43496. */
  43497. private _setupMirrorInGroundMaterial;
  43498. /**
  43499. * Setup the skybox according to the specified options.
  43500. */
  43501. private _setupSkybox;
  43502. /**
  43503. * Setup the skybox material according to the specified options.
  43504. */
  43505. private _setupSkyboxMaterial;
  43506. /**
  43507. * Setup the skybox reflection texture according to the specified options.
  43508. */
  43509. private _setupSkyboxReflectionTexture;
  43510. private _errorHandler;
  43511. /**
  43512. * Dispose all the elements created by the Helper.
  43513. */
  43514. dispose(): void;
  43515. }
  43516. }
  43517. declare module BABYLON {
  43518. /**
  43519. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43520. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43521. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43522. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43523. */
  43524. export class PhotoDome extends TransformNode {
  43525. private _useDirectMapping;
  43526. /**
  43527. * The texture being displayed on the sphere
  43528. */
  43529. protected _photoTexture: Texture;
  43530. /**
  43531. * Gets or sets the texture being displayed on the sphere
  43532. */
  43533. photoTexture: Texture;
  43534. /**
  43535. * Observable raised when an error occured while loading the 360 image
  43536. */
  43537. onLoadErrorObservable: Observable<string>;
  43538. /**
  43539. * The skybox material
  43540. */
  43541. protected _material: BackgroundMaterial;
  43542. /**
  43543. * The surface used for the skybox
  43544. */
  43545. protected _mesh: Mesh;
  43546. /**
  43547. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43548. * Also see the options.resolution property.
  43549. */
  43550. fovMultiplier: number;
  43551. /**
  43552. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43553. * @param name Element's name, child elements will append suffixes for their own names.
  43554. * @param urlsOfPhoto defines the url of the photo to display
  43555. * @param options defines an object containing optional or exposed sub element properties
  43556. * @param onError defines a callback called when an error occured while loading the texture
  43557. */
  43558. constructor(name: string, urlOfPhoto: string, options: {
  43559. resolution?: number;
  43560. size?: number;
  43561. useDirectMapping?: boolean;
  43562. faceForward?: boolean;
  43563. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43564. /**
  43565. * Releases resources associated with this node.
  43566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43568. */
  43569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43570. }
  43571. }
  43572. declare module BABYLON {
  43573. /**
  43574. * Class used to host texture specific utilities
  43575. */
  43576. export class BRDFTextureTools {
  43577. /**
  43578. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43579. * @param texture the texture to expand.
  43580. */
  43581. private static _ExpandDefaultBRDFTexture;
  43582. /**
  43583. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43584. * @param scene defines the hosting scene
  43585. * @returns the environment BRDF texture
  43586. */
  43587. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43588. private static _environmentBRDFBase64Texture;
  43589. }
  43590. }
  43591. declare module BABYLON {
  43592. /**
  43593. * @hidden
  43594. */
  43595. export interface IMaterialClearCoatDefines {
  43596. CLEARCOAT: boolean;
  43597. CLEARCOAT_DEFAULTIOR: boolean;
  43598. CLEARCOAT_TEXTURE: boolean;
  43599. CLEARCOAT_TEXTUREDIRECTUV: number;
  43600. CLEARCOAT_BUMP: boolean;
  43601. CLEARCOAT_BUMPDIRECTUV: number;
  43602. CLEARCOAT_TINT: boolean;
  43603. CLEARCOAT_TINT_TEXTURE: boolean;
  43604. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43605. /** @hidden */
  43606. _areTexturesDirty: boolean;
  43607. }
  43608. /**
  43609. * Define the code related to the clear coat parameters of the pbr material.
  43610. */
  43611. export class PBRClearCoatConfiguration {
  43612. /**
  43613. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43614. * The default fits with a polyurethane material.
  43615. */
  43616. private static readonly _DefaultIndiceOfRefraction;
  43617. private _isEnabled;
  43618. /**
  43619. * Defines if the clear coat is enabled in the material.
  43620. */
  43621. isEnabled: boolean;
  43622. /**
  43623. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43624. */
  43625. intensity: number;
  43626. /**
  43627. * Defines the clear coat layer roughness.
  43628. */
  43629. roughness: number;
  43630. private _indiceOfRefraction;
  43631. /**
  43632. * Defines the indice of refraction of the clear coat.
  43633. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43634. * The default fits with a polyurethane material.
  43635. * Changing the default value is more performance intensive.
  43636. */
  43637. indiceOfRefraction: number;
  43638. private _texture;
  43639. /**
  43640. * Stores the clear coat values in a texture.
  43641. */
  43642. texture: Nullable<BaseTexture>;
  43643. private _bumpTexture;
  43644. /**
  43645. * Define the clear coat specific bump texture.
  43646. */
  43647. bumpTexture: Nullable<BaseTexture>;
  43648. private _isTintEnabled;
  43649. /**
  43650. * Defines if the clear coat tint is enabled in the material.
  43651. */
  43652. isTintEnabled: boolean;
  43653. /**
  43654. * Defines if the clear coat tint is enabled in the material.
  43655. * This is only use if tint is enabled
  43656. */
  43657. tintColor: Color3;
  43658. /**
  43659. * Defines if the distance at which the tint color should be found in the
  43660. * clear coat media.
  43661. * This is only use if tint is enabled
  43662. */
  43663. tintColorAtDistance: number;
  43664. /**
  43665. * Defines the clear coat layer thickness.
  43666. * This is only use if tint is enabled
  43667. */
  43668. tintThickness: number;
  43669. private _tintTexture;
  43670. /**
  43671. * Stores the clear tint values in a texture.
  43672. * rgb is tint
  43673. * a is a thickness factor
  43674. */
  43675. tintTexture: Nullable<BaseTexture>;
  43676. /** @hidden */
  43677. private _internalMarkAllSubMeshesAsTexturesDirty;
  43678. /** @hidden */
  43679. _markAllSubMeshesAsTexturesDirty(): void;
  43680. /**
  43681. * Instantiate a new istance of clear coat configuration.
  43682. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43683. */
  43684. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43685. /**
  43686. * Specifies that the submesh is ready to be used.
  43687. * @param defines the list of "defines" to update.
  43688. * @param scene defines the scene the material belongs to.
  43689. * @param engine defines the engine the material belongs to.
  43690. * @param disableBumpMap defines wether the material disables bump or not.
  43691. * @returns - boolean indicating that the submesh is ready or not.
  43692. */
  43693. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43694. /**
  43695. * Checks to see if a texture is used in the material.
  43696. * @param defines the list of "defines" to update.
  43697. * @param scene defines the scene to the material belongs to.
  43698. */
  43699. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43700. /**
  43701. * Binds the material data.
  43702. * @param uniformBuffer defines the Uniform buffer to fill in.
  43703. * @param scene defines the scene the material belongs to.
  43704. * @param engine defines the engine the material belongs to.
  43705. * @param disableBumpMap defines wether the material disables bump or not.
  43706. * @param isFrozen defines wether the material is frozen or not.
  43707. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43708. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43709. */
  43710. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43711. /**
  43712. * Checks to see if a texture is used in the material.
  43713. * @param texture - Base texture to use.
  43714. * @returns - Boolean specifying if a texture is used in the material.
  43715. */
  43716. hasTexture(texture: BaseTexture): boolean;
  43717. /**
  43718. * Returns an array of the actively used textures.
  43719. * @param activeTextures Array of BaseTextures
  43720. */
  43721. getActiveTextures(activeTextures: BaseTexture[]): void;
  43722. /**
  43723. * Returns the animatable textures.
  43724. * @param animatables Array of animatable textures.
  43725. */
  43726. getAnimatables(animatables: IAnimatable[]): void;
  43727. /**
  43728. * Disposes the resources of the material.
  43729. * @param forceDisposeTextures - Forces the disposal of all textures.
  43730. */
  43731. dispose(forceDisposeTextures?: boolean): void;
  43732. /**
  43733. * Get the current class name of the texture useful for serialization or dynamic coding.
  43734. * @returns "PBRClearCoatConfiguration"
  43735. */
  43736. getClassName(): string;
  43737. /**
  43738. * Add fallbacks to the effect fallbacks list.
  43739. * @param defines defines the Base texture to use.
  43740. * @param fallbacks defines the current fallback list.
  43741. * @param currentRank defines the current fallback rank.
  43742. * @returns the new fallback rank.
  43743. */
  43744. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43745. /**
  43746. * Add the required uniforms to the current list.
  43747. * @param uniforms defines the current uniform list.
  43748. */
  43749. static AddUniforms(uniforms: string[]): void;
  43750. /**
  43751. * Add the required samplers to the current list.
  43752. * @param samplers defines the current sampler list.
  43753. */
  43754. static AddSamplers(samplers: string[]): void;
  43755. /**
  43756. * Add the required uniforms to the current buffer.
  43757. * @param uniformBuffer defines the current uniform buffer.
  43758. */
  43759. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43760. /**
  43761. * Makes a duplicate of the current configuration into another one.
  43762. * @param clearCoatConfiguration define the config where to copy the info
  43763. */
  43764. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43765. /**
  43766. * Serializes this clear coat configuration.
  43767. * @returns - An object with the serialized config.
  43768. */
  43769. serialize(): any;
  43770. /**
  43771. * Parses a Clear Coat Configuration from a serialized object.
  43772. * @param source - Serialized object.
  43773. */
  43774. parse(source: any): void;
  43775. }
  43776. }
  43777. declare module BABYLON {
  43778. /**
  43779. * @hidden
  43780. */
  43781. export interface IMaterialAnisotropicDefines {
  43782. ANISOTROPIC: boolean;
  43783. ANISOTROPIC_TEXTURE: boolean;
  43784. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43785. MAINUV1: boolean;
  43786. _areTexturesDirty: boolean;
  43787. _needUVs: boolean;
  43788. }
  43789. /**
  43790. * Define the code related to the anisotropic parameters of the pbr material.
  43791. */
  43792. export class PBRAnisotropicConfiguration {
  43793. private _isEnabled;
  43794. /**
  43795. * Defines if the anisotropy is enabled in the material.
  43796. */
  43797. isEnabled: boolean;
  43798. /**
  43799. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43800. */
  43801. intensity: number;
  43802. /**
  43803. * Defines if the effect is along the tangents, bitangents or in between.
  43804. * By default, the effect is "strectching" the highlights along the tangents.
  43805. */
  43806. direction: Vector2;
  43807. private _texture;
  43808. /**
  43809. * Stores the anisotropy values in a texture.
  43810. * rg is direction (like normal from -1 to 1)
  43811. * b is a intensity
  43812. */
  43813. texture: Nullable<BaseTexture>;
  43814. /** @hidden */
  43815. private _internalMarkAllSubMeshesAsTexturesDirty;
  43816. /** @hidden */
  43817. _markAllSubMeshesAsTexturesDirty(): void;
  43818. /**
  43819. * Instantiate a new istance of anisotropy configuration.
  43820. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43821. */
  43822. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43823. /**
  43824. * Specifies that the submesh is ready to be used.
  43825. * @param defines the list of "defines" to update.
  43826. * @param scene defines the scene the material belongs to.
  43827. * @returns - boolean indicating that the submesh is ready or not.
  43828. */
  43829. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43830. /**
  43831. * Checks to see if a texture is used in the material.
  43832. * @param defines the list of "defines" to update.
  43833. * @param mesh the mesh we are preparing the defines for.
  43834. * @param scene defines the scene the material belongs to.
  43835. */
  43836. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43837. /**
  43838. * Binds the material data.
  43839. * @param uniformBuffer defines the Uniform buffer to fill in.
  43840. * @param scene defines the scene the material belongs to.
  43841. * @param isFrozen defines wether the material is frozen or not.
  43842. */
  43843. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43844. /**
  43845. * Checks to see if a texture is used in the material.
  43846. * @param texture - Base texture to use.
  43847. * @returns - Boolean specifying if a texture is used in the material.
  43848. */
  43849. hasTexture(texture: BaseTexture): boolean;
  43850. /**
  43851. * Returns an array of the actively used textures.
  43852. * @param activeTextures Array of BaseTextures
  43853. */
  43854. getActiveTextures(activeTextures: BaseTexture[]): void;
  43855. /**
  43856. * Returns the animatable textures.
  43857. * @param animatables Array of animatable textures.
  43858. */
  43859. getAnimatables(animatables: IAnimatable[]): void;
  43860. /**
  43861. * Disposes the resources of the material.
  43862. * @param forceDisposeTextures - Forces the disposal of all textures.
  43863. */
  43864. dispose(forceDisposeTextures?: boolean): void;
  43865. /**
  43866. * Get the current class name of the texture useful for serialization or dynamic coding.
  43867. * @returns "PBRAnisotropicConfiguration"
  43868. */
  43869. getClassName(): string;
  43870. /**
  43871. * Add fallbacks to the effect fallbacks list.
  43872. * @param defines defines the Base texture to use.
  43873. * @param fallbacks defines the current fallback list.
  43874. * @param currentRank defines the current fallback rank.
  43875. * @returns the new fallback rank.
  43876. */
  43877. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43878. /**
  43879. * Add the required uniforms to the current list.
  43880. * @param uniforms defines the current uniform list.
  43881. */
  43882. static AddUniforms(uniforms: string[]): void;
  43883. /**
  43884. * Add the required uniforms to the current buffer.
  43885. * @param uniformBuffer defines the current uniform buffer.
  43886. */
  43887. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43888. /**
  43889. * Add the required samplers to the current list.
  43890. * @param samplers defines the current sampler list.
  43891. */
  43892. static AddSamplers(samplers: string[]): void;
  43893. /**
  43894. * Makes a duplicate of the current configuration into another one.
  43895. * @param anisotropicConfiguration define the config where to copy the info
  43896. */
  43897. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43898. /**
  43899. * Serializes this anisotropy configuration.
  43900. * @returns - An object with the serialized config.
  43901. */
  43902. serialize(): any;
  43903. /**
  43904. * Parses a anisotropy Configuration from a serialized object.
  43905. * @param source - Serialized object.
  43906. */
  43907. parse(source: any): void;
  43908. }
  43909. }
  43910. declare module BABYLON {
  43911. /**
  43912. * @hidden
  43913. */
  43914. export interface IMaterialBRDFDefines {
  43915. BRDF_V_HEIGHT_CORRELATED: boolean;
  43916. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43917. /** @hidden */
  43918. _areMiscDirty: boolean;
  43919. }
  43920. /**
  43921. * Define the code related to the BRDF parameters of the pbr material.
  43922. */
  43923. export class PBRBRDFConfiguration {
  43924. /**
  43925. * Default value used for the energy conservation.
  43926. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43927. */
  43928. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43929. /**
  43930. * Default value used for the Smith Visibility Height Correlated mode.
  43931. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43932. */
  43933. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43934. private _useEnergyConservation;
  43935. /**
  43936. * Defines if the material uses energy conservation.
  43937. */
  43938. useEnergyConservation: boolean;
  43939. private _useSmithVisibilityHeightCorrelated;
  43940. /**
  43941. * LEGACY Mode set to false
  43942. * Defines if the material uses height smith correlated visibility term.
  43943. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43944. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43945. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43946. * Not relying on height correlated will also disable energy conservation.
  43947. */
  43948. useSmithVisibilityHeightCorrelated: boolean;
  43949. /** @hidden */
  43950. private _internalMarkAllSubMeshesAsMiscDirty;
  43951. /** @hidden */
  43952. _markAllSubMeshesAsMiscDirty(): void;
  43953. /**
  43954. * Instantiate a new istance of clear coat configuration.
  43955. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43956. */
  43957. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43958. /**
  43959. * Checks to see if a texture is used in the material.
  43960. * @param defines the list of "defines" to update.
  43961. */
  43962. prepareDefines(defines: IMaterialBRDFDefines): void;
  43963. /**
  43964. * Get the current class name of the texture useful for serialization or dynamic coding.
  43965. * @returns "PBRClearCoatConfiguration"
  43966. */
  43967. getClassName(): string;
  43968. /**
  43969. * Makes a duplicate of the current configuration into another one.
  43970. * @param brdfConfiguration define the config where to copy the info
  43971. */
  43972. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43973. /**
  43974. * Serializes this BRDF configuration.
  43975. * @returns - An object with the serialized config.
  43976. */
  43977. serialize(): any;
  43978. /**
  43979. * Parses a BRDF Configuration from a serialized object.
  43980. * @param source - Serialized object.
  43981. */
  43982. parse(source: any): void;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. /**
  43987. * @hidden
  43988. */
  43989. export interface IMaterialSheenDefines {
  43990. SHEEN: boolean;
  43991. SHEEN_TEXTURE: boolean;
  43992. SHEEN_TEXTUREDIRECTUV: number;
  43993. SHEEN_LINKWITHALBEDO: boolean;
  43994. /** @hidden */
  43995. _areTexturesDirty: boolean;
  43996. }
  43997. /**
  43998. * Define the code related to the Sheen parameters of the pbr material.
  43999. */
  44000. export class PBRSheenConfiguration {
  44001. private _isEnabled;
  44002. /**
  44003. * Defines if the material uses sheen.
  44004. */
  44005. isEnabled: boolean;
  44006. private _linkSheenWithAlbedo;
  44007. /**
  44008. * Defines if the sheen is linked to the sheen color.
  44009. */
  44010. linkSheenWithAlbedo: boolean;
  44011. /**
  44012. * Defines the sheen intensity.
  44013. */
  44014. intensity: number;
  44015. /**
  44016. * Defines the sheen color.
  44017. */
  44018. color: Color3;
  44019. private _texture;
  44020. /**
  44021. * Stores the sheen tint values in a texture.
  44022. * rgb is tint
  44023. * a is a intensity
  44024. */
  44025. texture: Nullable<BaseTexture>;
  44026. /** @hidden */
  44027. private _internalMarkAllSubMeshesAsTexturesDirty;
  44028. /** @hidden */
  44029. _markAllSubMeshesAsTexturesDirty(): void;
  44030. /**
  44031. * Instantiate a new istance of clear coat configuration.
  44032. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44033. */
  44034. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44035. /**
  44036. * Specifies that the submesh is ready to be used.
  44037. * @param defines the list of "defines" to update.
  44038. * @param scene defines the scene the material belongs to.
  44039. * @returns - boolean indicating that the submesh is ready or not.
  44040. */
  44041. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44042. /**
  44043. * Checks to see if a texture is used in the material.
  44044. * @param defines the list of "defines" to update.
  44045. * @param scene defines the scene the material belongs to.
  44046. */
  44047. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44048. /**
  44049. * Binds the material data.
  44050. * @param uniformBuffer defines the Uniform buffer to fill in.
  44051. * @param scene defines the scene the material belongs to.
  44052. * @param isFrozen defines wether the material is frozen or not.
  44053. */
  44054. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44055. /**
  44056. * Checks to see if a texture is used in the material.
  44057. * @param texture - Base texture to use.
  44058. * @returns - Boolean specifying if a texture is used in the material.
  44059. */
  44060. hasTexture(texture: BaseTexture): boolean;
  44061. /**
  44062. * Returns an array of the actively used textures.
  44063. * @param activeTextures Array of BaseTextures
  44064. */
  44065. getActiveTextures(activeTextures: BaseTexture[]): void;
  44066. /**
  44067. * Returns the animatable textures.
  44068. * @param animatables Array of animatable textures.
  44069. */
  44070. getAnimatables(animatables: IAnimatable[]): void;
  44071. /**
  44072. * Disposes the resources of the material.
  44073. * @param forceDisposeTextures - Forces the disposal of all textures.
  44074. */
  44075. dispose(forceDisposeTextures?: boolean): void;
  44076. /**
  44077. * Get the current class name of the texture useful for serialization or dynamic coding.
  44078. * @returns "PBRSheenConfiguration"
  44079. */
  44080. getClassName(): string;
  44081. /**
  44082. * Add fallbacks to the effect fallbacks list.
  44083. * @param defines defines the Base texture to use.
  44084. * @param fallbacks defines the current fallback list.
  44085. * @param currentRank defines the current fallback rank.
  44086. * @returns the new fallback rank.
  44087. */
  44088. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44089. /**
  44090. * Add the required uniforms to the current list.
  44091. * @param uniforms defines the current uniform list.
  44092. */
  44093. static AddUniforms(uniforms: string[]): void;
  44094. /**
  44095. * Add the required uniforms to the current buffer.
  44096. * @param uniformBuffer defines the current uniform buffer.
  44097. */
  44098. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44099. /**
  44100. * Add the required samplers to the current list.
  44101. * @param samplers defines the current sampler list.
  44102. */
  44103. static AddSamplers(samplers: string[]): void;
  44104. /**
  44105. * Makes a duplicate of the current configuration into another one.
  44106. * @param sheenConfiguration define the config where to copy the info
  44107. */
  44108. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44109. /**
  44110. * Serializes this BRDF configuration.
  44111. * @returns - An object with the serialized config.
  44112. */
  44113. serialize(): any;
  44114. /**
  44115. * Parses a Sheen Configuration from a serialized object.
  44116. * @param source - Serialized object.
  44117. */
  44118. parse(source: any): void;
  44119. }
  44120. }
  44121. declare module BABYLON {
  44122. /** @hidden */
  44123. export var pbrFragmentDeclaration: {
  44124. name: string;
  44125. shader: string;
  44126. };
  44127. }
  44128. declare module BABYLON {
  44129. /** @hidden */
  44130. export var pbrUboDeclaration: {
  44131. name: string;
  44132. shader: string;
  44133. };
  44134. }
  44135. declare module BABYLON {
  44136. /** @hidden */
  44137. export var pbrFragmentExtraDeclaration: {
  44138. name: string;
  44139. shader: string;
  44140. };
  44141. }
  44142. declare module BABYLON {
  44143. /** @hidden */
  44144. export var pbrFragmentSamplersDeclaration: {
  44145. name: string;
  44146. shader: string;
  44147. };
  44148. }
  44149. declare module BABYLON {
  44150. /** @hidden */
  44151. export var pbrHelperFunctions: {
  44152. name: string;
  44153. shader: string;
  44154. };
  44155. }
  44156. declare module BABYLON {
  44157. /** @hidden */
  44158. export var harmonicsFunctions: {
  44159. name: string;
  44160. shader: string;
  44161. };
  44162. }
  44163. declare module BABYLON {
  44164. /** @hidden */
  44165. export var pbrDirectLightingSetupFunctions: {
  44166. name: string;
  44167. shader: string;
  44168. };
  44169. }
  44170. declare module BABYLON {
  44171. /** @hidden */
  44172. export var pbrDirectLightingFalloffFunctions: {
  44173. name: string;
  44174. shader: string;
  44175. };
  44176. }
  44177. declare module BABYLON {
  44178. /** @hidden */
  44179. export var pbrBRDFFunctions: {
  44180. name: string;
  44181. shader: string;
  44182. };
  44183. }
  44184. declare module BABYLON {
  44185. /** @hidden */
  44186. export var pbrDirectLightingFunctions: {
  44187. name: string;
  44188. shader: string;
  44189. };
  44190. }
  44191. declare module BABYLON {
  44192. /** @hidden */
  44193. export var pbrIBLFunctions: {
  44194. name: string;
  44195. shader: string;
  44196. };
  44197. }
  44198. declare module BABYLON {
  44199. /** @hidden */
  44200. export var pbrDebug: {
  44201. name: string;
  44202. shader: string;
  44203. };
  44204. }
  44205. declare module BABYLON {
  44206. /** @hidden */
  44207. export var pbrPixelShader: {
  44208. name: string;
  44209. shader: string;
  44210. };
  44211. }
  44212. declare module BABYLON {
  44213. /** @hidden */
  44214. export var pbrVertexDeclaration: {
  44215. name: string;
  44216. shader: string;
  44217. };
  44218. }
  44219. declare module BABYLON {
  44220. /** @hidden */
  44221. export var pbrVertexShader: {
  44222. name: string;
  44223. shader: string;
  44224. };
  44225. }
  44226. declare module BABYLON {
  44227. /**
  44228. * Manages the defines for the PBR Material.
  44229. * @hidden
  44230. */
  44231. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  44232. PBR: boolean;
  44233. MAINUV1: boolean;
  44234. MAINUV2: boolean;
  44235. UV1: boolean;
  44236. UV2: boolean;
  44237. ALBEDO: boolean;
  44238. ALBEDODIRECTUV: number;
  44239. VERTEXCOLOR: boolean;
  44240. AMBIENT: boolean;
  44241. AMBIENTDIRECTUV: number;
  44242. AMBIENTINGRAYSCALE: boolean;
  44243. OPACITY: boolean;
  44244. VERTEXALPHA: boolean;
  44245. OPACITYDIRECTUV: number;
  44246. OPACITYRGB: boolean;
  44247. ALPHATEST: boolean;
  44248. DEPTHPREPASS: boolean;
  44249. ALPHABLEND: boolean;
  44250. ALPHAFROMALBEDO: boolean;
  44251. ALPHATESTVALUE: string;
  44252. SPECULAROVERALPHA: boolean;
  44253. RADIANCEOVERALPHA: boolean;
  44254. ALPHAFRESNEL: boolean;
  44255. LINEARALPHAFRESNEL: boolean;
  44256. PREMULTIPLYALPHA: boolean;
  44257. EMISSIVE: boolean;
  44258. EMISSIVEDIRECTUV: number;
  44259. REFLECTIVITY: boolean;
  44260. REFLECTIVITYDIRECTUV: number;
  44261. SPECULARTERM: boolean;
  44262. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44263. MICROSURFACEAUTOMATIC: boolean;
  44264. LODBASEDMICROSFURACE: boolean;
  44265. MICROSURFACEMAP: boolean;
  44266. MICROSURFACEMAPDIRECTUV: number;
  44267. METALLICWORKFLOW: boolean;
  44268. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44269. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44270. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44271. AOSTOREINMETALMAPRED: boolean;
  44272. ENVIRONMENTBRDF: boolean;
  44273. ENVIRONMENTBRDF_RGBD: boolean;
  44274. NORMAL: boolean;
  44275. TANGENT: boolean;
  44276. BUMP: boolean;
  44277. BUMPDIRECTUV: number;
  44278. OBJECTSPACE_NORMALMAP: boolean;
  44279. PARALLAX: boolean;
  44280. PARALLAXOCCLUSION: boolean;
  44281. NORMALXYSCALE: boolean;
  44282. LIGHTMAP: boolean;
  44283. LIGHTMAPDIRECTUV: number;
  44284. USELIGHTMAPASSHADOWMAP: boolean;
  44285. GAMMALIGHTMAP: boolean;
  44286. REFLECTION: boolean;
  44287. REFLECTIONMAP_3D: boolean;
  44288. REFLECTIONMAP_SPHERICAL: boolean;
  44289. REFLECTIONMAP_PLANAR: boolean;
  44290. REFLECTIONMAP_CUBIC: boolean;
  44291. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44292. REFLECTIONMAP_PROJECTION: boolean;
  44293. REFLECTIONMAP_SKYBOX: boolean;
  44294. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44295. REFLECTIONMAP_EXPLICIT: boolean;
  44296. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44297. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44298. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44299. INVERTCUBICMAP: boolean;
  44300. USESPHERICALFROMREFLECTIONMAP: boolean;
  44301. USESPHERICALINVERTEX: boolean;
  44302. REFLECTIONMAP_OPPOSITEZ: boolean;
  44303. LODINREFLECTIONALPHA: boolean;
  44304. GAMMAREFLECTION: boolean;
  44305. RGBDREFLECTION: boolean;
  44306. RADIANCEOCCLUSION: boolean;
  44307. HORIZONOCCLUSION: boolean;
  44308. REFRACTION: boolean;
  44309. REFRACTIONMAP_3D: boolean;
  44310. REFRACTIONMAP_OPPOSITEZ: boolean;
  44311. LODINREFRACTIONALPHA: boolean;
  44312. GAMMAREFRACTION: boolean;
  44313. RGBDREFRACTION: boolean;
  44314. LINKREFRACTIONTOTRANSPARENCY: boolean;
  44315. INSTANCES: boolean;
  44316. NUM_BONE_INFLUENCERS: number;
  44317. BonesPerMesh: number;
  44318. BONETEXTURE: boolean;
  44319. NONUNIFORMSCALING: boolean;
  44320. MORPHTARGETS: boolean;
  44321. MORPHTARGETS_NORMAL: boolean;
  44322. MORPHTARGETS_TANGENT: boolean;
  44323. NUM_MORPH_INFLUENCERS: number;
  44324. IMAGEPROCESSING: boolean;
  44325. VIGNETTE: boolean;
  44326. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44327. VIGNETTEBLENDMODEOPAQUE: boolean;
  44328. TONEMAPPING: boolean;
  44329. TONEMAPPING_ACES: boolean;
  44330. CONTRAST: boolean;
  44331. COLORCURVES: boolean;
  44332. COLORGRADING: boolean;
  44333. COLORGRADING3D: boolean;
  44334. SAMPLER3DGREENDEPTH: boolean;
  44335. SAMPLER3DBGRMAP: boolean;
  44336. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44337. EXPOSURE: boolean;
  44338. MULTIVIEW: boolean;
  44339. USEPHYSICALLIGHTFALLOFF: boolean;
  44340. USEGLTFLIGHTFALLOFF: boolean;
  44341. TWOSIDEDLIGHTING: boolean;
  44342. SHADOWFLOAT: boolean;
  44343. CLIPPLANE: boolean;
  44344. CLIPPLANE2: boolean;
  44345. CLIPPLANE3: boolean;
  44346. CLIPPLANE4: boolean;
  44347. POINTSIZE: boolean;
  44348. FOG: boolean;
  44349. LOGARITHMICDEPTH: boolean;
  44350. FORCENORMALFORWARD: boolean;
  44351. SPECULARAA: boolean;
  44352. CLEARCOAT: boolean;
  44353. CLEARCOAT_DEFAULTIOR: boolean;
  44354. CLEARCOAT_TEXTURE: boolean;
  44355. CLEARCOAT_TEXTUREDIRECTUV: number;
  44356. CLEARCOAT_BUMP: boolean;
  44357. CLEARCOAT_BUMPDIRECTUV: number;
  44358. CLEARCOAT_TINT: boolean;
  44359. CLEARCOAT_TINT_TEXTURE: boolean;
  44360. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44361. ANISOTROPIC: boolean;
  44362. ANISOTROPIC_TEXTURE: boolean;
  44363. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44364. BRDF_V_HEIGHT_CORRELATED: boolean;
  44365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44366. SHEEN: boolean;
  44367. SHEEN_TEXTURE: boolean;
  44368. SHEEN_TEXTUREDIRECTUV: number;
  44369. SHEEN_LINKWITHALBEDO: boolean;
  44370. UNLIT: boolean;
  44371. DEBUGMODE: number;
  44372. /**
  44373. * Initializes the PBR Material defines.
  44374. */
  44375. constructor();
  44376. /**
  44377. * Resets the PBR Material defines.
  44378. */
  44379. reset(): void;
  44380. }
  44381. /**
  44382. * The Physically based material base class of BJS.
  44383. *
  44384. * This offers the main features of a standard PBR material.
  44385. * For more information, please refer to the documentation :
  44386. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44387. */
  44388. export abstract class PBRBaseMaterial extends PushMaterial {
  44389. /**
  44390. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44391. */
  44392. static readonly PBRMATERIAL_OPAQUE: number;
  44393. /**
  44394. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44395. */
  44396. static readonly PBRMATERIAL_ALPHATEST: number;
  44397. /**
  44398. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44399. */
  44400. static readonly PBRMATERIAL_ALPHABLEND: number;
  44401. /**
  44402. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44403. * They are also discarded below the alpha cutoff threshold to improve performances.
  44404. */
  44405. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44406. /**
  44407. * Defines the default value of how much AO map is occluding the analytical lights
  44408. * (point spot...).
  44409. */
  44410. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44411. /**
  44412. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44413. */
  44414. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44415. /**
  44416. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44417. * to enhance interoperability with other engines.
  44418. */
  44419. static readonly LIGHTFALLOFF_GLTF: number;
  44420. /**
  44421. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44422. * to enhance interoperability with other materials.
  44423. */
  44424. static readonly LIGHTFALLOFF_STANDARD: number;
  44425. /**
  44426. * Intensity of the direct lights e.g. the four lights available in your scene.
  44427. * This impacts both the direct diffuse and specular highlights.
  44428. */
  44429. protected _directIntensity: number;
  44430. /**
  44431. * Intensity of the emissive part of the material.
  44432. * This helps controlling the emissive effect without modifying the emissive color.
  44433. */
  44434. protected _emissiveIntensity: number;
  44435. /**
  44436. * Intensity of the environment e.g. how much the environment will light the object
  44437. * either through harmonics for rough material or through the refelction for shiny ones.
  44438. */
  44439. protected _environmentIntensity: number;
  44440. /**
  44441. * This is a special control allowing the reduction of the specular highlights coming from the
  44442. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44443. */
  44444. protected _specularIntensity: number;
  44445. /**
  44446. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44447. */
  44448. private _lightingInfos;
  44449. /**
  44450. * Debug Control allowing disabling the bump map on this material.
  44451. */
  44452. protected _disableBumpMap: boolean;
  44453. /**
  44454. * AKA Diffuse Texture in standard nomenclature.
  44455. */
  44456. protected _albedoTexture: BaseTexture;
  44457. /**
  44458. * AKA Occlusion Texture in other nomenclature.
  44459. */
  44460. protected _ambientTexture: BaseTexture;
  44461. /**
  44462. * AKA Occlusion Texture Intensity in other nomenclature.
  44463. */
  44464. protected _ambientTextureStrength: number;
  44465. /**
  44466. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44467. * 1 means it completely occludes it
  44468. * 0 mean it has no impact
  44469. */
  44470. protected _ambientTextureImpactOnAnalyticalLights: number;
  44471. /**
  44472. * Stores the alpha values in a texture.
  44473. */
  44474. protected _opacityTexture: BaseTexture;
  44475. /**
  44476. * Stores the reflection values in a texture.
  44477. */
  44478. protected _reflectionTexture: BaseTexture;
  44479. /**
  44480. * Stores the refraction values in a texture.
  44481. */
  44482. protected _refractionTexture: BaseTexture;
  44483. /**
  44484. * Stores the emissive values in a texture.
  44485. */
  44486. protected _emissiveTexture: BaseTexture;
  44487. /**
  44488. * AKA Specular texture in other nomenclature.
  44489. */
  44490. protected _reflectivityTexture: BaseTexture;
  44491. /**
  44492. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44493. */
  44494. protected _metallicTexture: BaseTexture;
  44495. /**
  44496. * Specifies the metallic scalar of the metallic/roughness workflow.
  44497. * Can also be used to scale the metalness values of the metallic texture.
  44498. */
  44499. protected _metallic: Nullable<number>;
  44500. /**
  44501. * Specifies the roughness scalar of the metallic/roughness workflow.
  44502. * Can also be used to scale the roughness values of the metallic texture.
  44503. */
  44504. protected _roughness: Nullable<number>;
  44505. /**
  44506. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44507. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44508. */
  44509. protected _microSurfaceTexture: BaseTexture;
  44510. /**
  44511. * Stores surface normal data used to displace a mesh in a texture.
  44512. */
  44513. protected _bumpTexture: BaseTexture;
  44514. /**
  44515. * Stores the pre-calculated light information of a mesh in a texture.
  44516. */
  44517. protected _lightmapTexture: BaseTexture;
  44518. /**
  44519. * The color of a material in ambient lighting.
  44520. */
  44521. protected _ambientColor: Color3;
  44522. /**
  44523. * AKA Diffuse Color in other nomenclature.
  44524. */
  44525. protected _albedoColor: Color3;
  44526. /**
  44527. * AKA Specular Color in other nomenclature.
  44528. */
  44529. protected _reflectivityColor: Color3;
  44530. /**
  44531. * The color applied when light is reflected from a material.
  44532. */
  44533. protected _reflectionColor: Color3;
  44534. /**
  44535. * The color applied when light is emitted from a material.
  44536. */
  44537. protected _emissiveColor: Color3;
  44538. /**
  44539. * AKA Glossiness in other nomenclature.
  44540. */
  44541. protected _microSurface: number;
  44542. /**
  44543. * source material index of refraction (IOR)' / 'destination material IOR.
  44544. */
  44545. protected _indexOfRefraction: number;
  44546. /**
  44547. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44548. */
  44549. protected _invertRefractionY: boolean;
  44550. /**
  44551. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44552. * Materials half opaque for instance using refraction could benefit from this control.
  44553. */
  44554. protected _linkRefractionWithTransparency: boolean;
  44555. /**
  44556. * Specifies that the material will use the light map as a show map.
  44557. */
  44558. protected _useLightmapAsShadowmap: boolean;
  44559. /**
  44560. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44561. * makes the reflect vector face the model (under horizon).
  44562. */
  44563. protected _useHorizonOcclusion: boolean;
  44564. /**
  44565. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44566. * too much the area relying on ambient texture to define their ambient occlusion.
  44567. */
  44568. protected _useRadianceOcclusion: boolean;
  44569. /**
  44570. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44571. */
  44572. protected _useAlphaFromAlbedoTexture: boolean;
  44573. /**
  44574. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44575. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44576. */
  44577. protected _useSpecularOverAlpha: boolean;
  44578. /**
  44579. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44580. */
  44581. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44582. /**
  44583. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44584. */
  44585. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44586. /**
  44587. * Specifies if the metallic texture contains the roughness information in its green channel.
  44588. */
  44589. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44590. /**
  44591. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44592. */
  44593. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44594. /**
  44595. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44596. */
  44597. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44598. /**
  44599. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44600. */
  44601. protected _useAmbientInGrayScale: boolean;
  44602. /**
  44603. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44604. * The material will try to infer what glossiness each pixel should be.
  44605. */
  44606. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44607. /**
  44608. * Defines the falloff type used in this material.
  44609. * It by default is Physical.
  44610. */
  44611. protected _lightFalloff: number;
  44612. /**
  44613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44615. */
  44616. protected _useRadianceOverAlpha: boolean;
  44617. /**
  44618. * Allows using an object space normal map (instead of tangent space).
  44619. */
  44620. protected _useObjectSpaceNormalMap: boolean;
  44621. /**
  44622. * Allows using the bump map in parallax mode.
  44623. */
  44624. protected _useParallax: boolean;
  44625. /**
  44626. * Allows using the bump map in parallax occlusion mode.
  44627. */
  44628. protected _useParallaxOcclusion: boolean;
  44629. /**
  44630. * Controls the scale bias of the parallax mode.
  44631. */
  44632. protected _parallaxScaleBias: number;
  44633. /**
  44634. * If sets to true, disables all the lights affecting the material.
  44635. */
  44636. protected _disableLighting: boolean;
  44637. /**
  44638. * Number of Simultaneous lights allowed on the material.
  44639. */
  44640. protected _maxSimultaneousLights: number;
  44641. /**
  44642. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44643. */
  44644. protected _invertNormalMapX: boolean;
  44645. /**
  44646. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44647. */
  44648. protected _invertNormalMapY: boolean;
  44649. /**
  44650. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44651. */
  44652. protected _twoSidedLighting: boolean;
  44653. /**
  44654. * Defines the alpha limits in alpha test mode.
  44655. */
  44656. protected _alphaCutOff: number;
  44657. /**
  44658. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44659. */
  44660. protected _forceAlphaTest: boolean;
  44661. /**
  44662. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44663. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44664. */
  44665. protected _useAlphaFresnel: boolean;
  44666. /**
  44667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44668. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44669. */
  44670. protected _useLinearAlphaFresnel: boolean;
  44671. /**
  44672. * The transparency mode of the material.
  44673. */
  44674. protected _transparencyMode: Nullable<number>;
  44675. /**
  44676. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44677. * from cos thetav and roughness:
  44678. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44679. */
  44680. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44681. /**
  44682. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44683. */
  44684. protected _forceIrradianceInFragment: boolean;
  44685. /**
  44686. * Force normal to face away from face.
  44687. */
  44688. protected _forceNormalForward: boolean;
  44689. /**
  44690. * Enables specular anti aliasing in the PBR shader.
  44691. * It will both interacts on the Geometry for analytical and IBL lighting.
  44692. * It also prefilter the roughness map based on the bump values.
  44693. */
  44694. protected _enableSpecularAntiAliasing: boolean;
  44695. /**
  44696. * Default configuration related to image processing available in the PBR Material.
  44697. */
  44698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44699. /**
  44700. * Keep track of the image processing observer to allow dispose and replace.
  44701. */
  44702. private _imageProcessingObserver;
  44703. /**
  44704. * Attaches a new image processing configuration to the PBR Material.
  44705. * @param configuration
  44706. */
  44707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44708. /**
  44709. * Stores the available render targets.
  44710. */
  44711. private _renderTargets;
  44712. /**
  44713. * Sets the global ambient color for the material used in lighting calculations.
  44714. */
  44715. private _globalAmbientColor;
  44716. /**
  44717. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44718. */
  44719. private _useLogarithmicDepth;
  44720. /**
  44721. * If set to true, no lighting calculations will be applied.
  44722. */
  44723. private _unlit;
  44724. private _debugMode;
  44725. /**
  44726. * @hidden
  44727. * This is reserved for the inspector.
  44728. * Defines the material debug mode.
  44729. * It helps seeing only some components of the material while troubleshooting.
  44730. */
  44731. debugMode: number;
  44732. /**
  44733. * @hidden
  44734. * This is reserved for the inspector.
  44735. * Specify from where on screen the debug mode should start.
  44736. * The value goes from -1 (full screen) to 1 (not visible)
  44737. * It helps with side by side comparison against the final render
  44738. * This defaults to -1
  44739. */
  44740. private debugLimit;
  44741. /**
  44742. * @hidden
  44743. * This is reserved for the inspector.
  44744. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44745. * You can use the factor to better multiply the final value.
  44746. */
  44747. private debugFactor;
  44748. /**
  44749. * Defines the clear coat layer parameters for the material.
  44750. */
  44751. readonly clearCoat: PBRClearCoatConfiguration;
  44752. /**
  44753. * Defines the anisotropic parameters for the material.
  44754. */
  44755. readonly anisotropy: PBRAnisotropicConfiguration;
  44756. /**
  44757. * Defines the BRDF parameters for the material.
  44758. */
  44759. readonly brdf: PBRBRDFConfiguration;
  44760. /**
  44761. * Defines the Sheen parameters for the material.
  44762. */
  44763. readonly sheen: PBRSheenConfiguration;
  44764. /**
  44765. * Custom callback helping to override the default shader used in the material.
  44766. */
  44767. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44768. /**
  44769. * Instantiates a new PBRMaterial instance.
  44770. *
  44771. * @param name The material name
  44772. * @param scene The scene the material will be use in.
  44773. */
  44774. constructor(name: string, scene: Scene);
  44775. /**
  44776. * Gets a boolean indicating that current material needs to register RTT
  44777. */
  44778. readonly hasRenderTargetTextures: boolean;
  44779. /**
  44780. * Gets the name of the material class.
  44781. */
  44782. getClassName(): string;
  44783. /**
  44784. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44785. */
  44786. /**
  44787. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44788. */
  44789. useLogarithmicDepth: boolean;
  44790. /**
  44791. * Gets the current transparency mode.
  44792. */
  44793. /**
  44794. * Sets the transparency mode of the material.
  44795. *
  44796. * | Value | Type | Description |
  44797. * | ----- | ----------------------------------- | ----------- |
  44798. * | 0 | OPAQUE | |
  44799. * | 1 | ALPHATEST | |
  44800. * | 2 | ALPHABLEND | |
  44801. * | 3 | ALPHATESTANDBLEND | |
  44802. *
  44803. */
  44804. transparencyMode: Nullable<number>;
  44805. /**
  44806. * Returns true if alpha blending should be disabled.
  44807. */
  44808. private readonly _disableAlphaBlending;
  44809. /**
  44810. * Specifies whether or not this material should be rendered in alpha blend mode.
  44811. */
  44812. needAlphaBlending(): boolean;
  44813. /**
  44814. * Specifies if the mesh will require alpha blending.
  44815. * @param mesh - BJS mesh.
  44816. */
  44817. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44818. /**
  44819. * Specifies whether or not this material should be rendered in alpha test mode.
  44820. */
  44821. needAlphaTesting(): boolean;
  44822. /**
  44823. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44824. */
  44825. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44826. /**
  44827. * Gets the texture used for the alpha test.
  44828. */
  44829. getAlphaTestTexture(): BaseTexture;
  44830. /**
  44831. * Specifies that the submesh is ready to be used.
  44832. * @param mesh - BJS mesh.
  44833. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44834. * @param useInstances - Specifies that instances should be used.
  44835. * @returns - boolean indicating that the submesh is ready or not.
  44836. */
  44837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44838. /**
  44839. * Specifies if the material uses metallic roughness workflow.
  44840. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44841. */
  44842. isMetallicWorkflow(): boolean;
  44843. private _prepareEffect;
  44844. private _prepareDefines;
  44845. /**
  44846. * Force shader compilation
  44847. */
  44848. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44849. clipPlane: boolean;
  44850. }>): void;
  44851. /**
  44852. * Initializes the uniform buffer layout for the shader.
  44853. */
  44854. buildUniformLayout(): void;
  44855. /**
  44856. * Unbinds the textures.
  44857. */
  44858. unbind(): void;
  44859. /**
  44860. * Binds the submesh data.
  44861. * @param world - The world matrix.
  44862. * @param mesh - The BJS mesh.
  44863. * @param subMesh - A submesh of the BJS mesh.
  44864. */
  44865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44866. /**
  44867. * Returns the animatable textures.
  44868. * @returns - Array of animatable textures.
  44869. */
  44870. getAnimatables(): IAnimatable[];
  44871. /**
  44872. * Returns the texture used for reflections.
  44873. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44874. */
  44875. private _getReflectionTexture;
  44876. /**
  44877. * Returns the texture used for refraction or null if none is used.
  44878. * @returns - Refection texture if present. If no refraction texture and refraction
  44879. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44880. */
  44881. private _getRefractionTexture;
  44882. /**
  44883. * Returns an array of the actively used textures.
  44884. * @returns - Array of BaseTextures
  44885. */
  44886. getActiveTextures(): BaseTexture[];
  44887. /**
  44888. * Checks to see if a texture is used in the material.
  44889. * @param texture - Base texture to use.
  44890. * @returns - Boolean specifying if a texture is used in the material.
  44891. */
  44892. hasTexture(texture: BaseTexture): boolean;
  44893. /**
  44894. * Disposes the resources of the material.
  44895. * @param forceDisposeEffect - Forces the disposal of effects.
  44896. * @param forceDisposeTextures - Forces the disposal of all textures.
  44897. */
  44898. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44899. }
  44900. }
  44901. declare module BABYLON {
  44902. /**
  44903. * The Physically based material of BJS.
  44904. *
  44905. * This offers the main features of a standard PBR material.
  44906. * For more information, please refer to the documentation :
  44907. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44908. */
  44909. export class PBRMaterial extends PBRBaseMaterial {
  44910. /**
  44911. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44912. */
  44913. static readonly PBRMATERIAL_OPAQUE: number;
  44914. /**
  44915. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44916. */
  44917. static readonly PBRMATERIAL_ALPHATEST: number;
  44918. /**
  44919. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44920. */
  44921. static readonly PBRMATERIAL_ALPHABLEND: number;
  44922. /**
  44923. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44924. * They are also discarded below the alpha cutoff threshold to improve performances.
  44925. */
  44926. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44927. /**
  44928. * Defines the default value of how much AO map is occluding the analytical lights
  44929. * (point spot...).
  44930. */
  44931. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44932. /**
  44933. * Intensity of the direct lights e.g. the four lights available in your scene.
  44934. * This impacts both the direct diffuse and specular highlights.
  44935. */
  44936. directIntensity: number;
  44937. /**
  44938. * Intensity of the emissive part of the material.
  44939. * This helps controlling the emissive effect without modifying the emissive color.
  44940. */
  44941. emissiveIntensity: number;
  44942. /**
  44943. * Intensity of the environment e.g. how much the environment will light the object
  44944. * either through harmonics for rough material or through the refelction for shiny ones.
  44945. */
  44946. environmentIntensity: number;
  44947. /**
  44948. * This is a special control allowing the reduction of the specular highlights coming from the
  44949. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44950. */
  44951. specularIntensity: number;
  44952. /**
  44953. * Debug Control allowing disabling the bump map on this material.
  44954. */
  44955. disableBumpMap: boolean;
  44956. /**
  44957. * AKA Diffuse Texture in standard nomenclature.
  44958. */
  44959. albedoTexture: BaseTexture;
  44960. /**
  44961. * AKA Occlusion Texture in other nomenclature.
  44962. */
  44963. ambientTexture: BaseTexture;
  44964. /**
  44965. * AKA Occlusion Texture Intensity in other nomenclature.
  44966. */
  44967. ambientTextureStrength: number;
  44968. /**
  44969. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44970. * 1 means it completely occludes it
  44971. * 0 mean it has no impact
  44972. */
  44973. ambientTextureImpactOnAnalyticalLights: number;
  44974. /**
  44975. * Stores the alpha values in a texture.
  44976. */
  44977. opacityTexture: BaseTexture;
  44978. /**
  44979. * Stores the reflection values in a texture.
  44980. */
  44981. reflectionTexture: Nullable<BaseTexture>;
  44982. /**
  44983. * Stores the emissive values in a texture.
  44984. */
  44985. emissiveTexture: BaseTexture;
  44986. /**
  44987. * AKA Specular texture in other nomenclature.
  44988. */
  44989. reflectivityTexture: BaseTexture;
  44990. /**
  44991. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44992. */
  44993. metallicTexture: BaseTexture;
  44994. /**
  44995. * Specifies the metallic scalar of the metallic/roughness workflow.
  44996. * Can also be used to scale the metalness values of the metallic texture.
  44997. */
  44998. metallic: Nullable<number>;
  44999. /**
  45000. * Specifies the roughness scalar of the metallic/roughness workflow.
  45001. * Can also be used to scale the roughness values of the metallic texture.
  45002. */
  45003. roughness: Nullable<number>;
  45004. /**
  45005. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45006. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45007. */
  45008. microSurfaceTexture: BaseTexture;
  45009. /**
  45010. * Stores surface normal data used to displace a mesh in a texture.
  45011. */
  45012. bumpTexture: BaseTexture;
  45013. /**
  45014. * Stores the pre-calculated light information of a mesh in a texture.
  45015. */
  45016. lightmapTexture: BaseTexture;
  45017. /**
  45018. * Stores the refracted light information in a texture.
  45019. */
  45020. refractionTexture: BaseTexture;
  45021. /**
  45022. * The color of a material in ambient lighting.
  45023. */
  45024. ambientColor: Color3;
  45025. /**
  45026. * AKA Diffuse Color in other nomenclature.
  45027. */
  45028. albedoColor: Color3;
  45029. /**
  45030. * AKA Specular Color in other nomenclature.
  45031. */
  45032. reflectivityColor: Color3;
  45033. /**
  45034. * The color reflected from the material.
  45035. */
  45036. reflectionColor: Color3;
  45037. /**
  45038. * The color emitted from the material.
  45039. */
  45040. emissiveColor: Color3;
  45041. /**
  45042. * AKA Glossiness in other nomenclature.
  45043. */
  45044. microSurface: number;
  45045. /**
  45046. * source material index of refraction (IOR)' / 'destination material IOR.
  45047. */
  45048. indexOfRefraction: number;
  45049. /**
  45050. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45051. */
  45052. invertRefractionY: boolean;
  45053. /**
  45054. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45055. * Materials half opaque for instance using refraction could benefit from this control.
  45056. */
  45057. linkRefractionWithTransparency: boolean;
  45058. /**
  45059. * If true, the light map contains occlusion information instead of lighting info.
  45060. */
  45061. useLightmapAsShadowmap: boolean;
  45062. /**
  45063. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45064. */
  45065. useAlphaFromAlbedoTexture: boolean;
  45066. /**
  45067. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45068. */
  45069. forceAlphaTest: boolean;
  45070. /**
  45071. * Defines the alpha limits in alpha test mode.
  45072. */
  45073. alphaCutOff: number;
  45074. /**
  45075. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45076. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45077. */
  45078. useSpecularOverAlpha: boolean;
  45079. /**
  45080. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45081. */
  45082. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45083. /**
  45084. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45085. */
  45086. useRoughnessFromMetallicTextureAlpha: boolean;
  45087. /**
  45088. * Specifies if the metallic texture contains the roughness information in its green channel.
  45089. */
  45090. useRoughnessFromMetallicTextureGreen: boolean;
  45091. /**
  45092. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45093. */
  45094. useMetallnessFromMetallicTextureBlue: boolean;
  45095. /**
  45096. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45097. */
  45098. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45099. /**
  45100. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45101. */
  45102. useAmbientInGrayScale: boolean;
  45103. /**
  45104. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45105. * The material will try to infer what glossiness each pixel should be.
  45106. */
  45107. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45108. /**
  45109. * BJS is using an harcoded light falloff based on a manually sets up range.
  45110. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45111. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45112. */
  45113. /**
  45114. * BJS is using an harcoded light falloff based on a manually sets up range.
  45115. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45116. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45117. */
  45118. usePhysicalLightFalloff: boolean;
  45119. /**
  45120. * In order to support the falloff compatibility with gltf, a special mode has been added
  45121. * to reproduce the gltf light falloff.
  45122. */
  45123. /**
  45124. * In order to support the falloff compatibility with gltf, a special mode has been added
  45125. * to reproduce the gltf light falloff.
  45126. */
  45127. useGLTFLightFalloff: boolean;
  45128. /**
  45129. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45130. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45131. */
  45132. useRadianceOverAlpha: boolean;
  45133. /**
  45134. * Allows using an object space normal map (instead of tangent space).
  45135. */
  45136. useObjectSpaceNormalMap: boolean;
  45137. /**
  45138. * Allows using the bump map in parallax mode.
  45139. */
  45140. useParallax: boolean;
  45141. /**
  45142. * Allows using the bump map in parallax occlusion mode.
  45143. */
  45144. useParallaxOcclusion: boolean;
  45145. /**
  45146. * Controls the scale bias of the parallax mode.
  45147. */
  45148. parallaxScaleBias: number;
  45149. /**
  45150. * If sets to true, disables all the lights affecting the material.
  45151. */
  45152. disableLighting: boolean;
  45153. /**
  45154. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45155. */
  45156. forceIrradianceInFragment: boolean;
  45157. /**
  45158. * Number of Simultaneous lights allowed on the material.
  45159. */
  45160. maxSimultaneousLights: number;
  45161. /**
  45162. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45163. */
  45164. invertNormalMapX: boolean;
  45165. /**
  45166. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45167. */
  45168. invertNormalMapY: boolean;
  45169. /**
  45170. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45171. */
  45172. twoSidedLighting: boolean;
  45173. /**
  45174. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45175. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45176. */
  45177. useAlphaFresnel: boolean;
  45178. /**
  45179. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45180. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45181. */
  45182. useLinearAlphaFresnel: boolean;
  45183. /**
  45184. * Let user defines the brdf lookup texture used for IBL.
  45185. * A default 8bit version is embedded but you could point at :
  45186. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45187. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45188. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45189. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45190. */
  45191. environmentBRDFTexture: Nullable<BaseTexture>;
  45192. /**
  45193. * Force normal to face away from face.
  45194. */
  45195. forceNormalForward: boolean;
  45196. /**
  45197. * Enables specular anti aliasing in the PBR shader.
  45198. * It will both interacts on the Geometry for analytical and IBL lighting.
  45199. * It also prefilter the roughness map based on the bump values.
  45200. */
  45201. enableSpecularAntiAliasing: boolean;
  45202. /**
  45203. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45204. * makes the reflect vector face the model (under horizon).
  45205. */
  45206. useHorizonOcclusion: boolean;
  45207. /**
  45208. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45209. * too much the area relying on ambient texture to define their ambient occlusion.
  45210. */
  45211. useRadianceOcclusion: boolean;
  45212. /**
  45213. * If set to true, no lighting calculations will be applied.
  45214. */
  45215. unlit: boolean;
  45216. /**
  45217. * Gets the image processing configuration used either in this material.
  45218. */
  45219. /**
  45220. * Sets the Default image processing configuration used either in the this material.
  45221. *
  45222. * If sets to null, the scene one is in use.
  45223. */
  45224. imageProcessingConfiguration: ImageProcessingConfiguration;
  45225. /**
  45226. * Gets wether the color curves effect is enabled.
  45227. */
  45228. /**
  45229. * Sets wether the color curves effect is enabled.
  45230. */
  45231. cameraColorCurvesEnabled: boolean;
  45232. /**
  45233. * Gets wether the color grading effect is enabled.
  45234. */
  45235. /**
  45236. * Gets wether the color grading effect is enabled.
  45237. */
  45238. cameraColorGradingEnabled: boolean;
  45239. /**
  45240. * Gets wether tonemapping is enabled or not.
  45241. */
  45242. /**
  45243. * Sets wether tonemapping is enabled or not
  45244. */
  45245. cameraToneMappingEnabled: boolean;
  45246. /**
  45247. * The camera exposure used on this material.
  45248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45249. * This corresponds to a photographic exposure.
  45250. */
  45251. /**
  45252. * The camera exposure used on this material.
  45253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45254. * This corresponds to a photographic exposure.
  45255. */
  45256. cameraExposure: number;
  45257. /**
  45258. * Gets The camera contrast used on this material.
  45259. */
  45260. /**
  45261. * Sets The camera contrast used on this material.
  45262. */
  45263. cameraContrast: number;
  45264. /**
  45265. * Gets the Color Grading 2D Lookup Texture.
  45266. */
  45267. /**
  45268. * Sets the Color Grading 2D Lookup Texture.
  45269. */
  45270. cameraColorGradingTexture: Nullable<BaseTexture>;
  45271. /**
  45272. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45273. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45274. * 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;
  45275. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45276. */
  45277. /**
  45278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45280. * 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;
  45281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45282. */
  45283. cameraColorCurves: Nullable<ColorCurves>;
  45284. /**
  45285. * Instantiates a new PBRMaterial instance.
  45286. *
  45287. * @param name The material name
  45288. * @param scene The scene the material will be use in.
  45289. */
  45290. constructor(name: string, scene: Scene);
  45291. /**
  45292. * Returns the name of this material class.
  45293. */
  45294. getClassName(): string;
  45295. /**
  45296. * Makes a duplicate of the current material.
  45297. * @param name - name to use for the new material.
  45298. */
  45299. clone(name: string): PBRMaterial;
  45300. /**
  45301. * Serializes this PBR Material.
  45302. * @returns - An object with the serialized material.
  45303. */
  45304. serialize(): any;
  45305. /**
  45306. * Parses a PBR Material from a serialized object.
  45307. * @param source - Serialized object.
  45308. * @param scene - BJS scene instance.
  45309. * @param rootUrl - url for the scene object
  45310. * @returns - PBRMaterial
  45311. */
  45312. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45313. }
  45314. }
  45315. declare module BABYLON {
  45316. /**
  45317. * Direct draw surface info
  45318. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45319. */
  45320. export interface DDSInfo {
  45321. /**
  45322. * Width of the texture
  45323. */
  45324. width: number;
  45325. /**
  45326. * Width of the texture
  45327. */
  45328. height: number;
  45329. /**
  45330. * Number of Mipmaps for the texture
  45331. * @see https://en.wikipedia.org/wiki/Mipmap
  45332. */
  45333. mipmapCount: number;
  45334. /**
  45335. * If the textures format is a known fourCC format
  45336. * @see https://www.fourcc.org/
  45337. */
  45338. isFourCC: boolean;
  45339. /**
  45340. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45341. */
  45342. isRGB: boolean;
  45343. /**
  45344. * If the texture is a lumincance format
  45345. */
  45346. isLuminance: boolean;
  45347. /**
  45348. * If this is a cube texture
  45349. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45350. */
  45351. isCube: boolean;
  45352. /**
  45353. * If the texture is a compressed format eg. FOURCC_DXT1
  45354. */
  45355. isCompressed: boolean;
  45356. /**
  45357. * The dxgiFormat of the texture
  45358. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45359. */
  45360. dxgiFormat: number;
  45361. /**
  45362. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45363. */
  45364. textureType: number;
  45365. /**
  45366. * Sphericle polynomial created for the dds texture
  45367. */
  45368. sphericalPolynomial?: SphericalPolynomial;
  45369. }
  45370. /**
  45371. * Class used to provide DDS decompression tools
  45372. */
  45373. export class DDSTools {
  45374. /**
  45375. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45376. */
  45377. static StoreLODInAlphaChannel: boolean;
  45378. /**
  45379. * Gets DDS information from an array buffer
  45380. * @param arrayBuffer defines the array buffer to read data from
  45381. * @returns the DDS information
  45382. */
  45383. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45384. private static _FloatView;
  45385. private static _Int32View;
  45386. private static _ToHalfFloat;
  45387. private static _FromHalfFloat;
  45388. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45389. private static _GetHalfFloatRGBAArrayBuffer;
  45390. private static _GetFloatRGBAArrayBuffer;
  45391. private static _GetFloatAsUIntRGBAArrayBuffer;
  45392. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45393. private static _GetRGBAArrayBuffer;
  45394. private static _ExtractLongWordOrder;
  45395. private static _GetRGBArrayBuffer;
  45396. private static _GetLuminanceArrayBuffer;
  45397. /**
  45398. * Uploads DDS Levels to a Babylon Texture
  45399. * @hidden
  45400. */
  45401. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45402. }
  45403. interface Engine {
  45404. /**
  45405. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45406. * @param rootUrl defines the url where the file to load is located
  45407. * @param scene defines the current scene
  45408. * @param lodScale defines scale to apply to the mip map selection
  45409. * @param lodOffset defines offset to apply to the mip map selection
  45410. * @param onLoad defines an optional callback raised when the texture is loaded
  45411. * @param onError defines an optional callback raised if there is an issue to load the texture
  45412. * @param format defines the format of the data
  45413. * @param forcedExtension defines the extension to use to pick the right loader
  45414. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45415. * @returns the cube texture as an InternalTexture
  45416. */
  45417. 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;
  45418. }
  45419. }
  45420. declare module BABYLON {
  45421. /**
  45422. * Implementation of the DDS Texture Loader.
  45423. * @hidden
  45424. */
  45425. export class _DDSTextureLoader implements IInternalTextureLoader {
  45426. /**
  45427. * Defines wether the loader supports cascade loading the different faces.
  45428. */
  45429. readonly supportCascades: boolean;
  45430. /**
  45431. * This returns if the loader support the current file information.
  45432. * @param extension defines the file extension of the file being loaded
  45433. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45434. * @param fallback defines the fallback internal texture if any
  45435. * @param isBase64 defines whether the texture is encoded as a base64
  45436. * @param isBuffer defines whether the texture data are stored as a buffer
  45437. * @returns true if the loader can load the specified file
  45438. */
  45439. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45440. /**
  45441. * Transform the url before loading if required.
  45442. * @param rootUrl the url of the texture
  45443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45444. * @returns the transformed texture
  45445. */
  45446. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45447. /**
  45448. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45449. * @param rootUrl the url of the texture
  45450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45451. * @returns the fallback texture
  45452. */
  45453. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45454. /**
  45455. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45456. * @param data contains the texture data
  45457. * @param texture defines the BabylonJS internal texture
  45458. * @param createPolynomials will be true if polynomials have been requested
  45459. * @param onLoad defines the callback to trigger once the texture is ready
  45460. * @param onError defines the callback to trigger in case of error
  45461. */
  45462. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45463. /**
  45464. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45465. * @param data contains the texture data
  45466. * @param texture defines the BabylonJS internal texture
  45467. * @param callback defines the method to call once ready to upload
  45468. */
  45469. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45470. }
  45471. }
  45472. declare module BABYLON {
  45473. /** @hidden */
  45474. export var rgbdEncodePixelShader: {
  45475. name: string;
  45476. shader: string;
  45477. };
  45478. }
  45479. declare module BABYLON {
  45480. /** @hidden */
  45481. export var rgbdDecodePixelShader: {
  45482. name: string;
  45483. shader: string;
  45484. };
  45485. }
  45486. declare module BABYLON {
  45487. /**
  45488. * Raw texture data and descriptor sufficient for WebGL texture upload
  45489. */
  45490. export interface EnvironmentTextureInfo {
  45491. /**
  45492. * Version of the environment map
  45493. */
  45494. version: number;
  45495. /**
  45496. * Width of image
  45497. */
  45498. width: number;
  45499. /**
  45500. * Irradiance information stored in the file.
  45501. */
  45502. irradiance: any;
  45503. /**
  45504. * Specular information stored in the file.
  45505. */
  45506. specular: any;
  45507. }
  45508. /**
  45509. * Sets of helpers addressing the serialization and deserialization of environment texture
  45510. * stored in a BabylonJS env file.
  45511. * Those files are usually stored as .env files.
  45512. */
  45513. export class EnvironmentTextureTools {
  45514. /**
  45515. * Magic number identifying the env file.
  45516. */
  45517. private static _MagicBytes;
  45518. /**
  45519. * Gets the environment info from an env file.
  45520. * @param data The array buffer containing the .env bytes.
  45521. * @returns the environment file info (the json header) if successfully parsed.
  45522. */
  45523. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45524. /**
  45525. * Creates an environment texture from a loaded cube texture.
  45526. * @param texture defines the cube texture to convert in env file
  45527. * @return a promise containing the environment data if succesfull.
  45528. */
  45529. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45530. /**
  45531. * Creates a JSON representation of the spherical data.
  45532. * @param texture defines the texture containing the polynomials
  45533. * @return the JSON representation of the spherical info
  45534. */
  45535. private static _CreateEnvTextureIrradiance;
  45536. /**
  45537. * Uploads the texture info contained in the env file to the GPU.
  45538. * @param texture defines the internal texture to upload to
  45539. * @param arrayBuffer defines the buffer cotaining the data to load
  45540. * @param info defines the texture info retrieved through the GetEnvInfo method
  45541. * @returns a promise
  45542. */
  45543. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45544. /**
  45545. * Uploads the levels of image data to the GPU.
  45546. * @param texture defines the internal texture to upload to
  45547. * @param imageData defines the array buffer views of image data [mipmap][face]
  45548. * @returns a promise
  45549. */
  45550. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45551. /**
  45552. * Uploads spherical polynomials information to the texture.
  45553. * @param texture defines the texture we are trying to upload the information to
  45554. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45555. */
  45556. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45557. /** @hidden */
  45558. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Implementation of the ENV Texture Loader.
  45564. * @hidden
  45565. */
  45566. export class _ENVTextureLoader implements IInternalTextureLoader {
  45567. /**
  45568. * Defines wether the loader supports cascade loading the different faces.
  45569. */
  45570. readonly supportCascades: boolean;
  45571. /**
  45572. * This returns if the loader support the current file information.
  45573. * @param extension defines the file extension of the file being loaded
  45574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45575. * @param fallback defines the fallback internal texture if any
  45576. * @param isBase64 defines whether the texture is encoded as a base64
  45577. * @param isBuffer defines whether the texture data are stored as a buffer
  45578. * @returns true if the loader can load the specified file
  45579. */
  45580. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45581. /**
  45582. * Transform the url before loading if required.
  45583. * @param rootUrl the url of the texture
  45584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45585. * @returns the transformed texture
  45586. */
  45587. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45588. /**
  45589. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45590. * @param rootUrl the url of the texture
  45591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45592. * @returns the fallback texture
  45593. */
  45594. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45595. /**
  45596. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45597. * @param data contains the texture data
  45598. * @param texture defines the BabylonJS internal texture
  45599. * @param createPolynomials will be true if polynomials have been requested
  45600. * @param onLoad defines the callback to trigger once the texture is ready
  45601. * @param onError defines the callback to trigger in case of error
  45602. */
  45603. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45604. /**
  45605. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45606. * @param data contains the texture data
  45607. * @param texture defines the BabylonJS internal texture
  45608. * @param callback defines the method to call once ready to upload
  45609. */
  45610. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45611. }
  45612. }
  45613. declare module BABYLON {
  45614. /**
  45615. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45616. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45617. */
  45618. export class KhronosTextureContainer {
  45619. /** contents of the KTX container file */
  45620. arrayBuffer: any;
  45621. private static HEADER_LEN;
  45622. private static COMPRESSED_2D;
  45623. private static COMPRESSED_3D;
  45624. private static TEX_2D;
  45625. private static TEX_3D;
  45626. /**
  45627. * Gets the openGL type
  45628. */
  45629. glType: number;
  45630. /**
  45631. * Gets the openGL type size
  45632. */
  45633. glTypeSize: number;
  45634. /**
  45635. * Gets the openGL format
  45636. */
  45637. glFormat: number;
  45638. /**
  45639. * Gets the openGL internal format
  45640. */
  45641. glInternalFormat: number;
  45642. /**
  45643. * Gets the base internal format
  45644. */
  45645. glBaseInternalFormat: number;
  45646. /**
  45647. * Gets image width in pixel
  45648. */
  45649. pixelWidth: number;
  45650. /**
  45651. * Gets image height in pixel
  45652. */
  45653. pixelHeight: number;
  45654. /**
  45655. * Gets image depth in pixels
  45656. */
  45657. pixelDepth: number;
  45658. /**
  45659. * Gets the number of array elements
  45660. */
  45661. numberOfArrayElements: number;
  45662. /**
  45663. * Gets the number of faces
  45664. */
  45665. numberOfFaces: number;
  45666. /**
  45667. * Gets the number of mipmap levels
  45668. */
  45669. numberOfMipmapLevels: number;
  45670. /**
  45671. * Gets the bytes of key value data
  45672. */
  45673. bytesOfKeyValueData: number;
  45674. /**
  45675. * Gets the load type
  45676. */
  45677. loadType: number;
  45678. /**
  45679. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45680. */
  45681. isInvalid: boolean;
  45682. /**
  45683. * Creates a new KhronosTextureContainer
  45684. * @param arrayBuffer contents of the KTX container file
  45685. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45686. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45687. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45688. */
  45689. constructor(
  45690. /** contents of the KTX container file */
  45691. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45692. /**
  45693. * Uploads KTX content to a Babylon Texture.
  45694. * It is assumed that the texture has already been created & is currently bound
  45695. * @hidden
  45696. */
  45697. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45698. private _upload2DCompressedLevels;
  45699. }
  45700. }
  45701. declare module BABYLON {
  45702. /**
  45703. * Implementation of the KTX Texture Loader.
  45704. * @hidden
  45705. */
  45706. export class _KTXTextureLoader implements IInternalTextureLoader {
  45707. /**
  45708. * Defines wether the loader supports cascade loading the different faces.
  45709. */
  45710. readonly supportCascades: boolean;
  45711. /**
  45712. * This returns if the loader support the current file information.
  45713. * @param extension defines the file extension of the file being loaded
  45714. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45715. * @param fallback defines the fallback internal texture if any
  45716. * @param isBase64 defines whether the texture is encoded as a base64
  45717. * @param isBuffer defines whether the texture data are stored as a buffer
  45718. * @returns true if the loader can load the specified file
  45719. */
  45720. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45721. /**
  45722. * Transform the url before loading if required.
  45723. * @param rootUrl the url of the texture
  45724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45725. * @returns the transformed texture
  45726. */
  45727. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45728. /**
  45729. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45730. * @param rootUrl the url of the texture
  45731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45732. * @returns the fallback texture
  45733. */
  45734. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45735. /**
  45736. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45737. * @param data contains the texture data
  45738. * @param texture defines the BabylonJS internal texture
  45739. * @param createPolynomials will be true if polynomials have been requested
  45740. * @param onLoad defines the callback to trigger once the texture is ready
  45741. * @param onError defines the callback to trigger in case of error
  45742. */
  45743. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45744. /**
  45745. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45746. * @param data contains the texture data
  45747. * @param texture defines the BabylonJS internal texture
  45748. * @param callback defines the method to call once ready to upload
  45749. */
  45750. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45751. }
  45752. }
  45753. declare module BABYLON {
  45754. /** @hidden */
  45755. export var _forceSceneHelpersToBundle: boolean;
  45756. interface Scene {
  45757. /**
  45758. * Creates a default light for the scene.
  45759. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45760. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45761. */
  45762. createDefaultLight(replace?: boolean): void;
  45763. /**
  45764. * Creates a default camera for the scene.
  45765. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45766. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45767. * @param replace has default false, when true replaces the active camera in the scene
  45768. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45769. */
  45770. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45771. /**
  45772. * Creates a default camera and a default light.
  45773. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45774. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45775. * @param replace has the default false, when true replaces the active camera/light in the scene
  45776. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45777. */
  45778. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45779. /**
  45780. * Creates a new sky box
  45781. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45782. * @param environmentTexture defines the texture to use as environment texture
  45783. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45784. * @param scale defines the overall scale of the skybox
  45785. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45786. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45787. * @returns a new mesh holding the sky box
  45788. */
  45789. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45790. /**
  45791. * Creates a new environment
  45792. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45793. * @param options defines the options you can use to configure the environment
  45794. * @returns the new EnvironmentHelper
  45795. */
  45796. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45797. /**
  45798. * Creates a new VREXperienceHelper
  45799. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45800. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45801. * @returns a new VREXperienceHelper
  45802. */
  45803. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45804. /**
  45805. * Creates a new XREXperienceHelper
  45806. * @see http://doc.babylonjs.com/how_to/webxr
  45807. * @returns a promise for a new XREXperienceHelper
  45808. */
  45809. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45810. }
  45811. }
  45812. declare module BABYLON {
  45813. /**
  45814. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45815. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45816. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45817. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45818. */
  45819. export class VideoDome extends TransformNode {
  45820. /**
  45821. * Define the video source as a Monoscopic panoramic 360 video.
  45822. */
  45823. static readonly MODE_MONOSCOPIC: number;
  45824. /**
  45825. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45826. */
  45827. static readonly MODE_TOPBOTTOM: number;
  45828. /**
  45829. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45830. */
  45831. static readonly MODE_SIDEBYSIDE: number;
  45832. private _useDirectMapping;
  45833. /**
  45834. * The video texture being displayed on the sphere
  45835. */
  45836. protected _videoTexture: VideoTexture;
  45837. /**
  45838. * Gets the video texture being displayed on the sphere
  45839. */
  45840. readonly videoTexture: VideoTexture;
  45841. /**
  45842. * The skybox material
  45843. */
  45844. protected _material: BackgroundMaterial;
  45845. /**
  45846. * The surface used for the skybox
  45847. */
  45848. protected _mesh: Mesh;
  45849. /**
  45850. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45851. * Also see the options.resolution property.
  45852. */
  45853. fovMultiplier: number;
  45854. private _videoMode;
  45855. /**
  45856. * Gets or set the current video mode for the video. It can be:
  45857. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45858. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45859. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45860. */
  45861. videoMode: number;
  45862. /**
  45863. * Oberserver used in Stereoscopic VR Mode.
  45864. */
  45865. private _onBeforeCameraRenderObserver;
  45866. /**
  45867. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45868. * @param name Element's name, child elements will append suffixes for their own names.
  45869. * @param urlsOrVideo defines the url(s) or the video element to use
  45870. * @param options An object containing optional or exposed sub element properties
  45871. */
  45872. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45873. resolution?: number;
  45874. clickToPlay?: boolean;
  45875. autoPlay?: boolean;
  45876. loop?: boolean;
  45877. size?: number;
  45878. poster?: string;
  45879. faceForward?: boolean;
  45880. useDirectMapping?: boolean;
  45881. }, scene: Scene);
  45882. private _changeVideoMode;
  45883. /**
  45884. * Releases resources associated with this node.
  45885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45887. */
  45888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45889. }
  45890. }
  45891. declare module BABYLON {
  45892. /**
  45893. * This class can be used to get instrumentation data from a Babylon engine
  45894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45895. */
  45896. export class EngineInstrumentation implements IDisposable {
  45897. /**
  45898. * Define the instrumented engine.
  45899. */
  45900. engine: Engine;
  45901. private _captureGPUFrameTime;
  45902. private _gpuFrameTimeToken;
  45903. private _gpuFrameTime;
  45904. private _captureShaderCompilationTime;
  45905. private _shaderCompilationTime;
  45906. private _onBeginFrameObserver;
  45907. private _onEndFrameObserver;
  45908. private _onBeforeShaderCompilationObserver;
  45909. private _onAfterShaderCompilationObserver;
  45910. /**
  45911. * Gets the perf counter used for GPU frame time
  45912. */
  45913. readonly gpuFrameTimeCounter: PerfCounter;
  45914. /**
  45915. * Gets the GPU frame time capture status
  45916. */
  45917. /**
  45918. * Enable or disable the GPU frame time capture
  45919. */
  45920. captureGPUFrameTime: boolean;
  45921. /**
  45922. * Gets the perf counter used for shader compilation time
  45923. */
  45924. readonly shaderCompilationTimeCounter: PerfCounter;
  45925. /**
  45926. * Gets the shader compilation time capture status
  45927. */
  45928. /**
  45929. * Enable or disable the shader compilation time capture
  45930. */
  45931. captureShaderCompilationTime: boolean;
  45932. /**
  45933. * Instantiates a new engine instrumentation.
  45934. * This class can be used to get instrumentation data from a Babylon engine
  45935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45936. * @param engine Defines the engine to instrument
  45937. */
  45938. constructor(
  45939. /**
  45940. * Define the instrumented engine.
  45941. */
  45942. engine: Engine);
  45943. /**
  45944. * Dispose and release associated resources.
  45945. */
  45946. dispose(): void;
  45947. }
  45948. }
  45949. declare module BABYLON {
  45950. /**
  45951. * This class can be used to get instrumentation data from a Babylon engine
  45952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45953. */
  45954. export class SceneInstrumentation implements IDisposable {
  45955. /**
  45956. * Defines the scene to instrument
  45957. */
  45958. scene: Scene;
  45959. private _captureActiveMeshesEvaluationTime;
  45960. private _activeMeshesEvaluationTime;
  45961. private _captureRenderTargetsRenderTime;
  45962. private _renderTargetsRenderTime;
  45963. private _captureFrameTime;
  45964. private _frameTime;
  45965. private _captureRenderTime;
  45966. private _renderTime;
  45967. private _captureInterFrameTime;
  45968. private _interFrameTime;
  45969. private _captureParticlesRenderTime;
  45970. private _particlesRenderTime;
  45971. private _captureSpritesRenderTime;
  45972. private _spritesRenderTime;
  45973. private _capturePhysicsTime;
  45974. private _physicsTime;
  45975. private _captureAnimationsTime;
  45976. private _animationsTime;
  45977. private _captureCameraRenderTime;
  45978. private _cameraRenderTime;
  45979. private _onBeforeActiveMeshesEvaluationObserver;
  45980. private _onAfterActiveMeshesEvaluationObserver;
  45981. private _onBeforeRenderTargetsRenderObserver;
  45982. private _onAfterRenderTargetsRenderObserver;
  45983. private _onAfterRenderObserver;
  45984. private _onBeforeDrawPhaseObserver;
  45985. private _onAfterDrawPhaseObserver;
  45986. private _onBeforeAnimationsObserver;
  45987. private _onBeforeParticlesRenderingObserver;
  45988. private _onAfterParticlesRenderingObserver;
  45989. private _onBeforeSpritesRenderingObserver;
  45990. private _onAfterSpritesRenderingObserver;
  45991. private _onBeforePhysicsObserver;
  45992. private _onAfterPhysicsObserver;
  45993. private _onAfterAnimationsObserver;
  45994. private _onBeforeCameraRenderObserver;
  45995. private _onAfterCameraRenderObserver;
  45996. /**
  45997. * Gets the perf counter used for active meshes evaluation time
  45998. */
  45999. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46000. /**
  46001. * Gets the active meshes evaluation time capture status
  46002. */
  46003. /**
  46004. * Enable or disable the active meshes evaluation time capture
  46005. */
  46006. captureActiveMeshesEvaluationTime: boolean;
  46007. /**
  46008. * Gets the perf counter used for render targets render time
  46009. */
  46010. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46011. /**
  46012. * Gets the render targets render time capture status
  46013. */
  46014. /**
  46015. * Enable or disable the render targets render time capture
  46016. */
  46017. captureRenderTargetsRenderTime: boolean;
  46018. /**
  46019. * Gets the perf counter used for particles render time
  46020. */
  46021. readonly particlesRenderTimeCounter: PerfCounter;
  46022. /**
  46023. * Gets the particles render time capture status
  46024. */
  46025. /**
  46026. * Enable or disable the particles render time capture
  46027. */
  46028. captureParticlesRenderTime: boolean;
  46029. /**
  46030. * Gets the perf counter used for sprites render time
  46031. */
  46032. readonly spritesRenderTimeCounter: PerfCounter;
  46033. /**
  46034. * Gets the sprites render time capture status
  46035. */
  46036. /**
  46037. * Enable or disable the sprites render time capture
  46038. */
  46039. captureSpritesRenderTime: boolean;
  46040. /**
  46041. * Gets the perf counter used for physics time
  46042. */
  46043. readonly physicsTimeCounter: PerfCounter;
  46044. /**
  46045. * Gets the physics time capture status
  46046. */
  46047. /**
  46048. * Enable or disable the physics time capture
  46049. */
  46050. capturePhysicsTime: boolean;
  46051. /**
  46052. * Gets the perf counter used for animations time
  46053. */
  46054. readonly animationsTimeCounter: PerfCounter;
  46055. /**
  46056. * Gets the animations time capture status
  46057. */
  46058. /**
  46059. * Enable or disable the animations time capture
  46060. */
  46061. captureAnimationsTime: boolean;
  46062. /**
  46063. * Gets the perf counter used for frame time capture
  46064. */
  46065. readonly frameTimeCounter: PerfCounter;
  46066. /**
  46067. * Gets the frame time capture status
  46068. */
  46069. /**
  46070. * Enable or disable the frame time capture
  46071. */
  46072. captureFrameTime: boolean;
  46073. /**
  46074. * Gets the perf counter used for inter-frames time capture
  46075. */
  46076. readonly interFrameTimeCounter: PerfCounter;
  46077. /**
  46078. * Gets the inter-frames time capture status
  46079. */
  46080. /**
  46081. * Enable or disable the inter-frames time capture
  46082. */
  46083. captureInterFrameTime: boolean;
  46084. /**
  46085. * Gets the perf counter used for render time capture
  46086. */
  46087. readonly renderTimeCounter: PerfCounter;
  46088. /**
  46089. * Gets the render time capture status
  46090. */
  46091. /**
  46092. * Enable or disable the render time capture
  46093. */
  46094. captureRenderTime: boolean;
  46095. /**
  46096. * Gets the perf counter used for camera render time capture
  46097. */
  46098. readonly cameraRenderTimeCounter: PerfCounter;
  46099. /**
  46100. * Gets the camera render time capture status
  46101. */
  46102. /**
  46103. * Enable or disable the camera render time capture
  46104. */
  46105. captureCameraRenderTime: boolean;
  46106. /**
  46107. * Gets the perf counter used for draw calls
  46108. */
  46109. readonly drawCallsCounter: PerfCounter;
  46110. /**
  46111. * Gets the perf counter used for texture collisions
  46112. */
  46113. readonly textureCollisionsCounter: PerfCounter;
  46114. /**
  46115. * Instantiates a new scene instrumentation.
  46116. * This class can be used to get instrumentation data from a Babylon engine
  46117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46118. * @param scene Defines the scene to instrument
  46119. */
  46120. constructor(
  46121. /**
  46122. * Defines the scene to instrument
  46123. */
  46124. scene: Scene);
  46125. /**
  46126. * Dispose and release associated resources.
  46127. */
  46128. dispose(): void;
  46129. }
  46130. }
  46131. declare module BABYLON {
  46132. /** @hidden */
  46133. export var glowMapGenerationPixelShader: {
  46134. name: string;
  46135. shader: string;
  46136. };
  46137. }
  46138. declare module BABYLON {
  46139. /** @hidden */
  46140. export var glowMapGenerationVertexShader: {
  46141. name: string;
  46142. shader: string;
  46143. };
  46144. }
  46145. declare module BABYLON {
  46146. /**
  46147. * Effect layer options. This helps customizing the behaviour
  46148. * of the effect layer.
  46149. */
  46150. export interface IEffectLayerOptions {
  46151. /**
  46152. * Multiplication factor apply to the canvas size to compute the render target size
  46153. * used to generated the objects (the smaller the faster).
  46154. */
  46155. mainTextureRatio: number;
  46156. /**
  46157. * Enforces a fixed size texture to ensure effect stability across devices.
  46158. */
  46159. mainTextureFixedSize?: number;
  46160. /**
  46161. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46162. */
  46163. alphaBlendingMode: number;
  46164. /**
  46165. * The camera attached to the layer.
  46166. */
  46167. camera: Nullable<Camera>;
  46168. /**
  46169. * The rendering group to draw the layer in.
  46170. */
  46171. renderingGroupId: number;
  46172. }
  46173. /**
  46174. * The effect layer Helps adding post process effect blended with the main pass.
  46175. *
  46176. * This can be for instance use to generate glow or higlight effects on the scene.
  46177. *
  46178. * The effect layer class can not be used directly and is intented to inherited from to be
  46179. * customized per effects.
  46180. */
  46181. export abstract class EffectLayer {
  46182. private _vertexBuffers;
  46183. private _indexBuffer;
  46184. private _cachedDefines;
  46185. private _effectLayerMapGenerationEffect;
  46186. private _effectLayerOptions;
  46187. private _mergeEffect;
  46188. protected _scene: Scene;
  46189. protected _engine: Engine;
  46190. protected _maxSize: number;
  46191. protected _mainTextureDesiredSize: ISize;
  46192. protected _mainTexture: RenderTargetTexture;
  46193. protected _shouldRender: boolean;
  46194. protected _postProcesses: PostProcess[];
  46195. protected _textures: BaseTexture[];
  46196. protected _emissiveTextureAndColor: {
  46197. texture: Nullable<BaseTexture>;
  46198. color: Color4;
  46199. };
  46200. /**
  46201. * The name of the layer
  46202. */
  46203. name: string;
  46204. /**
  46205. * The clear color of the texture used to generate the glow map.
  46206. */
  46207. neutralColor: Color4;
  46208. /**
  46209. * Specifies wether the highlight layer is enabled or not.
  46210. */
  46211. isEnabled: boolean;
  46212. /**
  46213. * Gets the camera attached to the layer.
  46214. */
  46215. readonly camera: Nullable<Camera>;
  46216. /**
  46217. * Gets the rendering group id the layer should render in.
  46218. */
  46219. readonly renderingGroupId: number;
  46220. /**
  46221. * An event triggered when the effect layer has been disposed.
  46222. */
  46223. onDisposeObservable: Observable<EffectLayer>;
  46224. /**
  46225. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46226. */
  46227. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46228. /**
  46229. * An event triggered when the generated texture is being merged in the scene.
  46230. */
  46231. onBeforeComposeObservable: Observable<EffectLayer>;
  46232. /**
  46233. * An event triggered when the generated texture has been merged in the scene.
  46234. */
  46235. onAfterComposeObservable: Observable<EffectLayer>;
  46236. /**
  46237. * An event triggered when the efffect layer changes its size.
  46238. */
  46239. onSizeChangedObservable: Observable<EffectLayer>;
  46240. /** @hidden */
  46241. static _SceneComponentInitialization: (scene: Scene) => void;
  46242. /**
  46243. * Instantiates a new effect Layer and references it in the scene.
  46244. * @param name The name of the layer
  46245. * @param scene The scene to use the layer in
  46246. */
  46247. constructor(
  46248. /** The Friendly of the effect in the scene */
  46249. name: string, scene: Scene);
  46250. /**
  46251. * Get the effect name of the layer.
  46252. * @return The effect name
  46253. */
  46254. abstract getEffectName(): string;
  46255. /**
  46256. * Checks for the readiness of the element composing the layer.
  46257. * @param subMesh the mesh to check for
  46258. * @param useInstances specify wether or not to use instances to render the mesh
  46259. * @return true if ready otherwise, false
  46260. */
  46261. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46262. /**
  46263. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46264. * @returns true if the effect requires stencil during the main canvas render pass.
  46265. */
  46266. abstract needStencil(): boolean;
  46267. /**
  46268. * Create the merge effect. This is the shader use to blit the information back
  46269. * to the main canvas at the end of the scene rendering.
  46270. * @returns The effect containing the shader used to merge the effect on the main canvas
  46271. */
  46272. protected abstract _createMergeEffect(): Effect;
  46273. /**
  46274. * Creates the render target textures and post processes used in the effect layer.
  46275. */
  46276. protected abstract _createTextureAndPostProcesses(): void;
  46277. /**
  46278. * Implementation specific of rendering the generating effect on the main canvas.
  46279. * @param effect The effect used to render through
  46280. */
  46281. protected abstract _internalRender(effect: Effect): void;
  46282. /**
  46283. * Sets the required values for both the emissive texture and and the main color.
  46284. */
  46285. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46286. /**
  46287. * Free any resources and references associated to a mesh.
  46288. * Internal use
  46289. * @param mesh The mesh to free.
  46290. */
  46291. abstract _disposeMesh(mesh: Mesh): void;
  46292. /**
  46293. * Serializes this layer (Glow or Highlight for example)
  46294. * @returns a serialized layer object
  46295. */
  46296. abstract serialize?(): any;
  46297. /**
  46298. * Initializes the effect layer with the required options.
  46299. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46300. */
  46301. protected _init(options: Partial<IEffectLayerOptions>): void;
  46302. /**
  46303. * Generates the index buffer of the full screen quad blending to the main canvas.
  46304. */
  46305. private _generateIndexBuffer;
  46306. /**
  46307. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46308. */
  46309. private _genrateVertexBuffer;
  46310. /**
  46311. * Sets the main texture desired size which is the closest power of two
  46312. * of the engine canvas size.
  46313. */
  46314. private _setMainTextureSize;
  46315. /**
  46316. * Creates the main texture for the effect layer.
  46317. */
  46318. protected _createMainTexture(): void;
  46319. /**
  46320. * Adds specific effects defines.
  46321. * @param defines The defines to add specifics to.
  46322. */
  46323. protected _addCustomEffectDefines(defines: string[]): void;
  46324. /**
  46325. * Checks for the readiness of the element composing the layer.
  46326. * @param subMesh the mesh to check for
  46327. * @param useInstances specify wether or not to use instances to render the mesh
  46328. * @param emissiveTexture the associated emissive texture used to generate the glow
  46329. * @return true if ready otherwise, false
  46330. */
  46331. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46332. /**
  46333. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46334. */
  46335. render(): void;
  46336. /**
  46337. * Determine if a given mesh will be used in the current effect.
  46338. * @param mesh mesh to test
  46339. * @returns true if the mesh will be used
  46340. */
  46341. hasMesh(mesh: AbstractMesh): boolean;
  46342. /**
  46343. * Returns true if the layer contains information to display, otherwise false.
  46344. * @returns true if the glow layer should be rendered
  46345. */
  46346. shouldRender(): boolean;
  46347. /**
  46348. * Returns true if the mesh should render, otherwise false.
  46349. * @param mesh The mesh to render
  46350. * @returns true if it should render otherwise false
  46351. */
  46352. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46353. /**
  46354. * Returns true if the mesh can be rendered, otherwise false.
  46355. * @param mesh The mesh to render
  46356. * @param material The material used on the mesh
  46357. * @returns true if it can be rendered otherwise false
  46358. */
  46359. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46360. /**
  46361. * Returns true if the mesh should render, otherwise false.
  46362. * @param mesh The mesh to render
  46363. * @returns true if it should render otherwise false
  46364. */
  46365. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46366. /**
  46367. * Renders the submesh passed in parameter to the generation map.
  46368. */
  46369. protected _renderSubMesh(subMesh: SubMesh): void;
  46370. /**
  46371. * Rebuild the required buffers.
  46372. * @hidden Internal use only.
  46373. */
  46374. _rebuild(): void;
  46375. /**
  46376. * Dispose only the render target textures and post process.
  46377. */
  46378. private _disposeTextureAndPostProcesses;
  46379. /**
  46380. * Dispose the highlight layer and free resources.
  46381. */
  46382. dispose(): void;
  46383. /**
  46384. * Gets the class name of the effect layer
  46385. * @returns the string with the class name of the effect layer
  46386. */
  46387. getClassName(): string;
  46388. /**
  46389. * Creates an effect layer from parsed effect layer data
  46390. * @param parsedEffectLayer defines effect layer data
  46391. * @param scene defines the current scene
  46392. * @param rootUrl defines the root URL containing the effect layer information
  46393. * @returns a parsed effect Layer
  46394. */
  46395. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46396. }
  46397. }
  46398. declare module BABYLON {
  46399. interface AbstractScene {
  46400. /**
  46401. * The list of effect layers (highlights/glow) added to the scene
  46402. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46403. * @see http://doc.babylonjs.com/how_to/glow_layer
  46404. */
  46405. effectLayers: Array<EffectLayer>;
  46406. /**
  46407. * Removes the given effect layer from this scene.
  46408. * @param toRemove defines the effect layer to remove
  46409. * @returns the index of the removed effect layer
  46410. */
  46411. removeEffectLayer(toRemove: EffectLayer): number;
  46412. /**
  46413. * Adds the given effect layer to this scene
  46414. * @param newEffectLayer defines the effect layer to add
  46415. */
  46416. addEffectLayer(newEffectLayer: EffectLayer): void;
  46417. }
  46418. /**
  46419. * Defines the layer scene component responsible to manage any effect layers
  46420. * in a given scene.
  46421. */
  46422. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46423. /**
  46424. * The component name helpfull to identify the component in the list of scene components.
  46425. */
  46426. readonly name: string;
  46427. /**
  46428. * The scene the component belongs to.
  46429. */
  46430. scene: Scene;
  46431. private _engine;
  46432. private _renderEffects;
  46433. private _needStencil;
  46434. private _previousStencilState;
  46435. /**
  46436. * Creates a new instance of the component for the given scene
  46437. * @param scene Defines the scene to register the component in
  46438. */
  46439. constructor(scene: Scene);
  46440. /**
  46441. * Registers the component in a given scene
  46442. */
  46443. register(): void;
  46444. /**
  46445. * Rebuilds the elements related to this component in case of
  46446. * context lost for instance.
  46447. */
  46448. rebuild(): void;
  46449. /**
  46450. * Serializes the component data to the specified json object
  46451. * @param serializationObject The object to serialize to
  46452. */
  46453. serialize(serializationObject: any): void;
  46454. /**
  46455. * Adds all the element from the container to the scene
  46456. * @param container the container holding the elements
  46457. */
  46458. addFromContainer(container: AbstractScene): void;
  46459. /**
  46460. * Removes all the elements in the container from the scene
  46461. * @param container contains the elements to remove
  46462. * @param dispose if the removed element should be disposed (default: false)
  46463. */
  46464. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46465. /**
  46466. * Disposes the component and the associated ressources.
  46467. */
  46468. dispose(): void;
  46469. private _isReadyForMesh;
  46470. private _renderMainTexture;
  46471. private _setStencil;
  46472. private _setStencilBack;
  46473. private _draw;
  46474. private _drawCamera;
  46475. private _drawRenderingGroup;
  46476. }
  46477. }
  46478. declare module BABYLON {
  46479. /** @hidden */
  46480. export var glowMapMergePixelShader: {
  46481. name: string;
  46482. shader: string;
  46483. };
  46484. }
  46485. declare module BABYLON {
  46486. /** @hidden */
  46487. export var glowMapMergeVertexShader: {
  46488. name: string;
  46489. shader: string;
  46490. };
  46491. }
  46492. declare module BABYLON {
  46493. interface AbstractScene {
  46494. /**
  46495. * Return a the first highlight layer of the scene with a given name.
  46496. * @param name The name of the highlight layer to look for.
  46497. * @return The highlight layer if found otherwise null.
  46498. */
  46499. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46500. }
  46501. /**
  46502. * Glow layer options. This helps customizing the behaviour
  46503. * of the glow layer.
  46504. */
  46505. export interface IGlowLayerOptions {
  46506. /**
  46507. * Multiplication factor apply to the canvas size to compute the render target size
  46508. * used to generated the glowing objects (the smaller the faster).
  46509. */
  46510. mainTextureRatio: number;
  46511. /**
  46512. * Enforces a fixed size texture to ensure resize independant blur.
  46513. */
  46514. mainTextureFixedSize?: number;
  46515. /**
  46516. * How big is the kernel of the blur texture.
  46517. */
  46518. blurKernelSize: number;
  46519. /**
  46520. * The camera attached to the layer.
  46521. */
  46522. camera: Nullable<Camera>;
  46523. /**
  46524. * Enable MSAA by chosing the number of samples.
  46525. */
  46526. mainTextureSamples?: number;
  46527. /**
  46528. * The rendering group to draw the layer in.
  46529. */
  46530. renderingGroupId: number;
  46531. }
  46532. /**
  46533. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46534. *
  46535. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46536. * glowy meshes to your scene.
  46537. *
  46538. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46539. */
  46540. export class GlowLayer extends EffectLayer {
  46541. /**
  46542. * Effect Name of the layer.
  46543. */
  46544. static readonly EffectName: string;
  46545. /**
  46546. * The default blur kernel size used for the glow.
  46547. */
  46548. static DefaultBlurKernelSize: number;
  46549. /**
  46550. * The default texture size ratio used for the glow.
  46551. */
  46552. static DefaultTextureRatio: number;
  46553. /**
  46554. * Sets the kernel size of the blur.
  46555. */
  46556. /**
  46557. * Gets the kernel size of the blur.
  46558. */
  46559. blurKernelSize: number;
  46560. /**
  46561. * Sets the glow intensity.
  46562. */
  46563. /**
  46564. * Gets the glow intensity.
  46565. */
  46566. intensity: number;
  46567. private _options;
  46568. private _intensity;
  46569. private _horizontalBlurPostprocess1;
  46570. private _verticalBlurPostprocess1;
  46571. private _horizontalBlurPostprocess2;
  46572. private _verticalBlurPostprocess2;
  46573. private _blurTexture1;
  46574. private _blurTexture2;
  46575. private _postProcesses1;
  46576. private _postProcesses2;
  46577. private _includedOnlyMeshes;
  46578. private _excludedMeshes;
  46579. /**
  46580. * Callback used to let the user override the color selection on a per mesh basis
  46581. */
  46582. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46583. /**
  46584. * Callback used to let the user override the texture selection on a per mesh basis
  46585. */
  46586. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46587. /**
  46588. * Instantiates a new glow Layer and references it to the scene.
  46589. * @param name The name of the layer
  46590. * @param scene The scene to use the layer in
  46591. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46592. */
  46593. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46594. /**
  46595. * Get the effect name of the layer.
  46596. * @return The effect name
  46597. */
  46598. getEffectName(): string;
  46599. /**
  46600. * Create the merge effect. This is the shader use to blit the information back
  46601. * to the main canvas at the end of the scene rendering.
  46602. */
  46603. protected _createMergeEffect(): Effect;
  46604. /**
  46605. * Creates the render target textures and post processes used in the glow layer.
  46606. */
  46607. protected _createTextureAndPostProcesses(): void;
  46608. /**
  46609. * Checks for the readiness of the element composing the layer.
  46610. * @param subMesh the mesh to check for
  46611. * @param useInstances specify wether or not to use instances to render the mesh
  46612. * @param emissiveTexture the associated emissive texture used to generate the glow
  46613. * @return true if ready otherwise, false
  46614. */
  46615. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46616. /**
  46617. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46618. */
  46619. needStencil(): boolean;
  46620. /**
  46621. * Returns true if the mesh can be rendered, otherwise false.
  46622. * @param mesh The mesh to render
  46623. * @param material The material used on the mesh
  46624. * @returns true if it can be rendered otherwise false
  46625. */
  46626. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46627. /**
  46628. * Implementation specific of rendering the generating effect on the main canvas.
  46629. * @param effect The effect used to render through
  46630. */
  46631. protected _internalRender(effect: Effect): void;
  46632. /**
  46633. * Sets the required values for both the emissive texture and and the main color.
  46634. */
  46635. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46636. /**
  46637. * Returns true if the mesh should render, otherwise false.
  46638. * @param mesh The mesh to render
  46639. * @returns true if it should render otherwise false
  46640. */
  46641. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46642. /**
  46643. * Adds specific effects defines.
  46644. * @param defines The defines to add specifics to.
  46645. */
  46646. protected _addCustomEffectDefines(defines: string[]): void;
  46647. /**
  46648. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46649. * @param mesh The mesh to exclude from the glow layer
  46650. */
  46651. addExcludedMesh(mesh: Mesh): void;
  46652. /**
  46653. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46654. * @param mesh The mesh to remove
  46655. */
  46656. removeExcludedMesh(mesh: Mesh): void;
  46657. /**
  46658. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46659. * @param mesh The mesh to include in the glow layer
  46660. */
  46661. addIncludedOnlyMesh(mesh: Mesh): void;
  46662. /**
  46663. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46664. * @param mesh The mesh to remove
  46665. */
  46666. removeIncludedOnlyMesh(mesh: Mesh): void;
  46667. /**
  46668. * Determine if a given mesh will be used in the glow layer
  46669. * @param mesh The mesh to test
  46670. * @returns true if the mesh will be highlighted by the current glow layer
  46671. */
  46672. hasMesh(mesh: AbstractMesh): boolean;
  46673. /**
  46674. * Free any resources and references associated to a mesh.
  46675. * Internal use
  46676. * @param mesh The mesh to free.
  46677. * @hidden
  46678. */
  46679. _disposeMesh(mesh: Mesh): void;
  46680. /**
  46681. * Gets the class name of the effect layer
  46682. * @returns the string with the class name of the effect layer
  46683. */
  46684. getClassName(): string;
  46685. /**
  46686. * Serializes this glow layer
  46687. * @returns a serialized glow layer object
  46688. */
  46689. serialize(): any;
  46690. /**
  46691. * Creates a Glow Layer from parsed glow layer data
  46692. * @param parsedGlowLayer defines glow layer data
  46693. * @param scene defines the current scene
  46694. * @param rootUrl defines the root URL containing the glow layer information
  46695. * @returns a parsed Glow Layer
  46696. */
  46697. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46698. }
  46699. }
  46700. declare module BABYLON {
  46701. /** @hidden */
  46702. export var glowBlurPostProcessPixelShader: {
  46703. name: string;
  46704. shader: string;
  46705. };
  46706. }
  46707. declare module BABYLON {
  46708. interface AbstractScene {
  46709. /**
  46710. * Return a the first highlight layer of the scene with a given name.
  46711. * @param name The name of the highlight layer to look for.
  46712. * @return The highlight layer if found otherwise null.
  46713. */
  46714. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46715. }
  46716. /**
  46717. * Highlight layer options. This helps customizing the behaviour
  46718. * of the highlight layer.
  46719. */
  46720. export interface IHighlightLayerOptions {
  46721. /**
  46722. * Multiplication factor apply to the canvas size to compute the render target size
  46723. * used to generated the glowing objects (the smaller the faster).
  46724. */
  46725. mainTextureRatio: number;
  46726. /**
  46727. * Enforces a fixed size texture to ensure resize independant blur.
  46728. */
  46729. mainTextureFixedSize?: number;
  46730. /**
  46731. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46732. * of the picture to blur (the smaller the faster).
  46733. */
  46734. blurTextureSizeRatio: number;
  46735. /**
  46736. * How big in texel of the blur texture is the vertical blur.
  46737. */
  46738. blurVerticalSize: number;
  46739. /**
  46740. * How big in texel of the blur texture is the horizontal blur.
  46741. */
  46742. blurHorizontalSize: number;
  46743. /**
  46744. * Alpha blending mode used to apply the blur. Default is combine.
  46745. */
  46746. alphaBlendingMode: number;
  46747. /**
  46748. * The camera attached to the layer.
  46749. */
  46750. camera: Nullable<Camera>;
  46751. /**
  46752. * Should we display highlight as a solid stroke?
  46753. */
  46754. isStroke?: boolean;
  46755. /**
  46756. * The rendering group to draw the layer in.
  46757. */
  46758. renderingGroupId: number;
  46759. }
  46760. /**
  46761. * The highlight layer Helps adding a glow effect around a mesh.
  46762. *
  46763. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46764. * glowy meshes to your scene.
  46765. *
  46766. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46767. */
  46768. export class HighlightLayer extends EffectLayer {
  46769. name: string;
  46770. /**
  46771. * Effect Name of the highlight layer.
  46772. */
  46773. static readonly EffectName: string;
  46774. /**
  46775. * The neutral color used during the preparation of the glow effect.
  46776. * This is black by default as the blend operation is a blend operation.
  46777. */
  46778. static NeutralColor: Color4;
  46779. /**
  46780. * Stencil value used for glowing meshes.
  46781. */
  46782. static GlowingMeshStencilReference: number;
  46783. /**
  46784. * Stencil value used for the other meshes in the scene.
  46785. */
  46786. static NormalMeshStencilReference: number;
  46787. /**
  46788. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46789. */
  46790. innerGlow: boolean;
  46791. /**
  46792. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46793. */
  46794. outerGlow: boolean;
  46795. /**
  46796. * Specifies the horizontal size of the blur.
  46797. */
  46798. /**
  46799. * Gets the horizontal size of the blur.
  46800. */
  46801. blurHorizontalSize: number;
  46802. /**
  46803. * Specifies the vertical size of the blur.
  46804. */
  46805. /**
  46806. * Gets the vertical size of the blur.
  46807. */
  46808. blurVerticalSize: number;
  46809. /**
  46810. * An event triggered when the highlight layer is being blurred.
  46811. */
  46812. onBeforeBlurObservable: Observable<HighlightLayer>;
  46813. /**
  46814. * An event triggered when the highlight layer has been blurred.
  46815. */
  46816. onAfterBlurObservable: Observable<HighlightLayer>;
  46817. private _instanceGlowingMeshStencilReference;
  46818. private _options;
  46819. private _downSamplePostprocess;
  46820. private _horizontalBlurPostprocess;
  46821. private _verticalBlurPostprocess;
  46822. private _blurTexture;
  46823. private _meshes;
  46824. private _excludedMeshes;
  46825. /**
  46826. * Instantiates a new highlight Layer and references it to the scene..
  46827. * @param name The name of the layer
  46828. * @param scene The scene to use the layer in
  46829. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46830. */
  46831. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46832. /**
  46833. * Get the effect name of the layer.
  46834. * @return The effect name
  46835. */
  46836. getEffectName(): string;
  46837. /**
  46838. * Create the merge effect. This is the shader use to blit the information back
  46839. * to the main canvas at the end of the scene rendering.
  46840. */
  46841. protected _createMergeEffect(): Effect;
  46842. /**
  46843. * Creates the render target textures and post processes used in the highlight layer.
  46844. */
  46845. protected _createTextureAndPostProcesses(): void;
  46846. /**
  46847. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46848. */
  46849. needStencil(): boolean;
  46850. /**
  46851. * Checks for the readiness of the element composing the layer.
  46852. * @param subMesh the mesh to check for
  46853. * @param useInstances specify wether or not to use instances to render the mesh
  46854. * @param emissiveTexture the associated emissive texture used to generate the glow
  46855. * @return true if ready otherwise, false
  46856. */
  46857. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46858. /**
  46859. * Implementation specific of rendering the generating effect on the main canvas.
  46860. * @param effect The effect used to render through
  46861. */
  46862. protected _internalRender(effect: Effect): void;
  46863. /**
  46864. * Returns true if the layer contains information to display, otherwise false.
  46865. */
  46866. shouldRender(): boolean;
  46867. /**
  46868. * Returns true if the mesh should render, otherwise false.
  46869. * @param mesh The mesh to render
  46870. * @returns true if it should render otherwise false
  46871. */
  46872. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46873. /**
  46874. * Sets the required values for both the emissive texture and and the main color.
  46875. */
  46876. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46877. /**
  46878. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46879. * @param mesh The mesh to exclude from the highlight layer
  46880. */
  46881. addExcludedMesh(mesh: Mesh): void;
  46882. /**
  46883. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46884. * @param mesh The mesh to highlight
  46885. */
  46886. removeExcludedMesh(mesh: Mesh): void;
  46887. /**
  46888. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46889. * @param mesh mesh to test
  46890. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46891. */
  46892. hasMesh(mesh: AbstractMesh): boolean;
  46893. /**
  46894. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46895. * @param mesh The mesh to highlight
  46896. * @param color The color of the highlight
  46897. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46898. */
  46899. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46900. /**
  46901. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46902. * @param mesh The mesh to highlight
  46903. */
  46904. removeMesh(mesh: Mesh): void;
  46905. /**
  46906. * Force the stencil to the normal expected value for none glowing parts
  46907. */
  46908. private _defaultStencilReference;
  46909. /**
  46910. * Free any resources and references associated to a mesh.
  46911. * Internal use
  46912. * @param mesh The mesh to free.
  46913. * @hidden
  46914. */
  46915. _disposeMesh(mesh: Mesh): void;
  46916. /**
  46917. * Dispose the highlight layer and free resources.
  46918. */
  46919. dispose(): void;
  46920. /**
  46921. * Gets the class name of the effect layer
  46922. * @returns the string with the class name of the effect layer
  46923. */
  46924. getClassName(): string;
  46925. /**
  46926. * Serializes this Highlight layer
  46927. * @returns a serialized Highlight layer object
  46928. */
  46929. serialize(): any;
  46930. /**
  46931. * Creates a Highlight layer from parsed Highlight layer data
  46932. * @param parsedHightlightLayer defines the Highlight layer data
  46933. * @param scene defines the current scene
  46934. * @param rootUrl defines the root URL containing the Highlight layer information
  46935. * @returns a parsed Highlight layer
  46936. */
  46937. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46938. }
  46939. }
  46940. declare module BABYLON {
  46941. /** @hidden */
  46942. export var lensFlarePixelShader: {
  46943. name: string;
  46944. shader: string;
  46945. };
  46946. }
  46947. declare module BABYLON {
  46948. /** @hidden */
  46949. export var lensFlareVertexShader: {
  46950. name: string;
  46951. shader: string;
  46952. };
  46953. }
  46954. declare module BABYLON {
  46955. /**
  46956. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46957. * It is usually composed of several `lensFlare`.
  46958. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46959. */
  46960. export class LensFlareSystem {
  46961. /**
  46962. * Define the name of the lens flare system
  46963. */
  46964. name: string;
  46965. /**
  46966. * List of lens flares used in this system.
  46967. */
  46968. lensFlares: LensFlare[];
  46969. /**
  46970. * Define a limit from the border the lens flare can be visible.
  46971. */
  46972. borderLimit: number;
  46973. /**
  46974. * Define a viewport border we do not want to see the lens flare in.
  46975. */
  46976. viewportBorder: number;
  46977. /**
  46978. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46979. */
  46980. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46981. /**
  46982. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46983. */
  46984. layerMask: number;
  46985. /**
  46986. * Define the id of the lens flare system in the scene.
  46987. * (equal to name by default)
  46988. */
  46989. id: string;
  46990. private _scene;
  46991. private _emitter;
  46992. private _vertexBuffers;
  46993. private _indexBuffer;
  46994. private _effect;
  46995. private _positionX;
  46996. private _positionY;
  46997. private _isEnabled;
  46998. /** @hidden */
  46999. static _SceneComponentInitialization: (scene: Scene) => void;
  47000. /**
  47001. * Instantiates a lens flare system.
  47002. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47003. * It is usually composed of several `lensFlare`.
  47004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47005. * @param name Define the name of the lens flare system in the scene
  47006. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47007. * @param scene Define the scene the lens flare system belongs to
  47008. */
  47009. constructor(
  47010. /**
  47011. * Define the name of the lens flare system
  47012. */
  47013. name: string, emitter: any, scene: Scene);
  47014. /**
  47015. * Define if the lens flare system is enabled.
  47016. */
  47017. isEnabled: boolean;
  47018. /**
  47019. * Get the scene the effects belongs to.
  47020. * @returns the scene holding the lens flare system
  47021. */
  47022. getScene(): Scene;
  47023. /**
  47024. * Get the emitter of the lens flare system.
  47025. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47026. * @returns the emitter of the lens flare system
  47027. */
  47028. getEmitter(): any;
  47029. /**
  47030. * Set the emitter of the lens flare system.
  47031. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47032. * @param newEmitter Define the new emitter of the system
  47033. */
  47034. setEmitter(newEmitter: any): void;
  47035. /**
  47036. * Get the lens flare system emitter position.
  47037. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47038. * @returns the position
  47039. */
  47040. getEmitterPosition(): Vector3;
  47041. /**
  47042. * @hidden
  47043. */
  47044. computeEffectivePosition(globalViewport: Viewport): boolean;
  47045. /** @hidden */
  47046. _isVisible(): boolean;
  47047. /**
  47048. * @hidden
  47049. */
  47050. render(): boolean;
  47051. /**
  47052. * Dispose and release the lens flare with its associated resources.
  47053. */
  47054. dispose(): void;
  47055. /**
  47056. * Parse a lens flare system from a JSON repressentation
  47057. * @param parsedLensFlareSystem Define the JSON to parse
  47058. * @param scene Define the scene the parsed system should be instantiated in
  47059. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47060. * @returns the parsed system
  47061. */
  47062. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47063. /**
  47064. * Serialize the current Lens Flare System into a JSON representation.
  47065. * @returns the serialized JSON
  47066. */
  47067. serialize(): any;
  47068. }
  47069. }
  47070. declare module BABYLON {
  47071. /**
  47072. * This represents one of the lens effect in a `lensFlareSystem`.
  47073. * It controls one of the indiviual texture used in the effect.
  47074. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47075. */
  47076. export class LensFlare {
  47077. /**
  47078. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47079. */
  47080. size: number;
  47081. /**
  47082. * 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.
  47083. */
  47084. position: number;
  47085. /**
  47086. * Define the lens color.
  47087. */
  47088. color: Color3;
  47089. /**
  47090. * Define the lens texture.
  47091. */
  47092. texture: Nullable<Texture>;
  47093. /**
  47094. * Define the alpha mode to render this particular lens.
  47095. */
  47096. alphaMode: number;
  47097. private _system;
  47098. /**
  47099. * Creates a new Lens Flare.
  47100. * This represents one of the lens effect in a `lensFlareSystem`.
  47101. * It controls one of the indiviual texture used in the effect.
  47102. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47103. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47104. * @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.
  47105. * @param color Define the lens color
  47106. * @param imgUrl Define the lens texture url
  47107. * @param system Define the `lensFlareSystem` this flare is part of
  47108. * @returns The newly created Lens Flare
  47109. */
  47110. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47111. /**
  47112. * Instantiates a new Lens Flare.
  47113. * This represents one of the lens effect in a `lensFlareSystem`.
  47114. * It controls one of the indiviual texture used in the effect.
  47115. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47116. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47117. * @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.
  47118. * @param color Define the lens color
  47119. * @param imgUrl Define the lens texture url
  47120. * @param system Define the `lensFlareSystem` this flare is part of
  47121. */
  47122. constructor(
  47123. /**
  47124. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47125. */
  47126. size: number,
  47127. /**
  47128. * 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.
  47129. */
  47130. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47131. /**
  47132. * Dispose and release the lens flare with its associated resources.
  47133. */
  47134. dispose(): void;
  47135. }
  47136. }
  47137. declare module BABYLON {
  47138. interface AbstractScene {
  47139. /**
  47140. * The list of lens flare system added to the scene
  47141. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47142. */
  47143. lensFlareSystems: Array<LensFlareSystem>;
  47144. /**
  47145. * Removes the given lens flare system from this scene.
  47146. * @param toRemove The lens flare system to remove
  47147. * @returns The index of the removed lens flare system
  47148. */
  47149. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47150. /**
  47151. * Adds the given lens flare system to this scene
  47152. * @param newLensFlareSystem The lens flare system to add
  47153. */
  47154. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47155. /**
  47156. * Gets a lens flare system using its name
  47157. * @param name defines the name to look for
  47158. * @returns the lens flare system or null if not found
  47159. */
  47160. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47161. /**
  47162. * Gets a lens flare system using its id
  47163. * @param id defines the id to look for
  47164. * @returns the lens flare system or null if not found
  47165. */
  47166. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47167. }
  47168. /**
  47169. * Defines the lens flare scene component responsible to manage any lens flares
  47170. * in a given scene.
  47171. */
  47172. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47173. /**
  47174. * The component name helpfull to identify the component in the list of scene components.
  47175. */
  47176. readonly name: string;
  47177. /**
  47178. * The scene the component belongs to.
  47179. */
  47180. scene: Scene;
  47181. /**
  47182. * Creates a new instance of the component for the given scene
  47183. * @param scene Defines the scene to register the component in
  47184. */
  47185. constructor(scene: Scene);
  47186. /**
  47187. * Registers the component in a given scene
  47188. */
  47189. register(): void;
  47190. /**
  47191. * Rebuilds the elements related to this component in case of
  47192. * context lost for instance.
  47193. */
  47194. rebuild(): void;
  47195. /**
  47196. * Adds all the element from the container to the scene
  47197. * @param container the container holding the elements
  47198. */
  47199. addFromContainer(container: AbstractScene): void;
  47200. /**
  47201. * Removes all the elements in the container from the scene
  47202. * @param container contains the elements to remove
  47203. * @param dispose if the removed element should be disposed (default: false)
  47204. */
  47205. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47206. /**
  47207. * Serializes the component data to the specified json object
  47208. * @param serializationObject The object to serialize to
  47209. */
  47210. serialize(serializationObject: any): void;
  47211. /**
  47212. * Disposes the component and the associated ressources.
  47213. */
  47214. dispose(): void;
  47215. private _draw;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /**
  47220. * Defines the shadow generator component responsible to manage any shadow generators
  47221. * in a given scene.
  47222. */
  47223. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47224. /**
  47225. * The component name helpfull to identify the component in the list of scene components.
  47226. */
  47227. readonly name: string;
  47228. /**
  47229. * The scene the component belongs to.
  47230. */
  47231. scene: Scene;
  47232. /**
  47233. * Creates a new instance of the component for the given scene
  47234. * @param scene Defines the scene to register the component in
  47235. */
  47236. constructor(scene: Scene);
  47237. /**
  47238. * Registers the component in a given scene
  47239. */
  47240. register(): void;
  47241. /**
  47242. * Rebuilds the elements related to this component in case of
  47243. * context lost for instance.
  47244. */
  47245. rebuild(): void;
  47246. /**
  47247. * Serializes the component data to the specified json object
  47248. * @param serializationObject The object to serialize to
  47249. */
  47250. serialize(serializationObject: any): void;
  47251. /**
  47252. * Adds all the element from the container to the scene
  47253. * @param container the container holding the elements
  47254. */
  47255. addFromContainer(container: AbstractScene): void;
  47256. /**
  47257. * Removes all the elements in the container from the scene
  47258. * @param container contains the elements to remove
  47259. * @param dispose if the removed element should be disposed (default: false)
  47260. */
  47261. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47262. /**
  47263. * Rebuilds the elements related to this component in case of
  47264. * context lost for instance.
  47265. */
  47266. dispose(): void;
  47267. private _gatherRenderTargets;
  47268. }
  47269. }
  47270. declare module BABYLON {
  47271. /**
  47272. * A point light is a light defined by an unique point in world space.
  47273. * The light is emitted in every direction from this point.
  47274. * A good example of a point light is a standard light bulb.
  47275. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47276. */
  47277. export class PointLight extends ShadowLight {
  47278. private _shadowAngle;
  47279. /**
  47280. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47281. * This specifies what angle the shadow will use to be created.
  47282. *
  47283. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47284. */
  47285. /**
  47286. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47287. * This specifies what angle the shadow will use to be created.
  47288. *
  47289. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47290. */
  47291. shadowAngle: number;
  47292. /**
  47293. * Gets the direction if it has been set.
  47294. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47295. */
  47296. /**
  47297. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47298. */
  47299. direction: Vector3;
  47300. /**
  47301. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47302. * A PointLight emits the light in every direction.
  47303. * It can cast shadows.
  47304. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47305. * ```javascript
  47306. * var pointLight = new PointLight("pl", camera.position, scene);
  47307. * ```
  47308. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47309. * @param name The light friendly name
  47310. * @param position The position of the point light in the scene
  47311. * @param scene The scene the lights belongs to
  47312. */
  47313. constructor(name: string, position: Vector3, scene: Scene);
  47314. /**
  47315. * Returns the string "PointLight"
  47316. * @returns the class name
  47317. */
  47318. getClassName(): string;
  47319. /**
  47320. * Returns the integer 0.
  47321. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47322. */
  47323. getTypeID(): number;
  47324. /**
  47325. * Specifies wether or not the shadowmap should be a cube texture.
  47326. * @returns true if the shadowmap needs to be a cube texture.
  47327. */
  47328. needCube(): boolean;
  47329. /**
  47330. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47331. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47332. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47333. */
  47334. getShadowDirection(faceIndex?: number): Vector3;
  47335. /**
  47336. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47337. * - fov = PI / 2
  47338. * - aspect ratio : 1.0
  47339. * - z-near and far equal to the active camera minZ and maxZ.
  47340. * Returns the PointLight.
  47341. */
  47342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47343. protected _buildUniformLayout(): void;
  47344. /**
  47345. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47346. * @param effect The effect to update
  47347. * @param lightIndex The index of the light in the effect to update
  47348. * @returns The point light
  47349. */
  47350. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47351. /**
  47352. * Prepares the list of defines specific to the light type.
  47353. * @param defines the list of defines
  47354. * @param lightIndex defines the index of the light for the effect
  47355. */
  47356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47357. }
  47358. }
  47359. declare module BABYLON {
  47360. /**
  47361. * Header information of HDR texture files.
  47362. */
  47363. export interface HDRInfo {
  47364. /**
  47365. * The height of the texture in pixels.
  47366. */
  47367. height: number;
  47368. /**
  47369. * The width of the texture in pixels.
  47370. */
  47371. width: number;
  47372. /**
  47373. * The index of the beginning of the data in the binary file.
  47374. */
  47375. dataPosition: number;
  47376. }
  47377. /**
  47378. * This groups tools to convert HDR texture to native colors array.
  47379. */
  47380. export class HDRTools {
  47381. private static Ldexp;
  47382. private static Rgbe2float;
  47383. private static readStringLine;
  47384. /**
  47385. * Reads header information from an RGBE texture stored in a native array.
  47386. * More information on this format are available here:
  47387. * https://en.wikipedia.org/wiki/RGBE_image_format
  47388. *
  47389. * @param uint8array The binary file stored in native array.
  47390. * @return The header information.
  47391. */
  47392. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47393. /**
  47394. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47395. * This RGBE texture needs to store the information as a panorama.
  47396. *
  47397. * More information on this format are available here:
  47398. * https://en.wikipedia.org/wiki/RGBE_image_format
  47399. *
  47400. * @param buffer The binary file stored in an array buffer.
  47401. * @param size The expected size of the extracted cubemap.
  47402. * @return The Cube Map information.
  47403. */
  47404. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47405. /**
  47406. * Returns the pixels data extracted from an RGBE texture.
  47407. * This pixels will be stored left to right up to down in the R G B order in one array.
  47408. *
  47409. * More information on this format are available here:
  47410. * https://en.wikipedia.org/wiki/RGBE_image_format
  47411. *
  47412. * @param uint8array The binary file stored in an array buffer.
  47413. * @param hdrInfo The header information of the file.
  47414. * @return The pixels data in RGB right to left up to down order.
  47415. */
  47416. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47417. private static RGBE_ReadPixels_RLE;
  47418. }
  47419. }
  47420. declare module BABYLON {
  47421. /**
  47422. * This represents a texture coming from an HDR input.
  47423. *
  47424. * The only supported format is currently panorama picture stored in RGBE format.
  47425. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47426. */
  47427. export class HDRCubeTexture extends BaseTexture {
  47428. private static _facesMapping;
  47429. private _generateHarmonics;
  47430. private _noMipmap;
  47431. private _textureMatrix;
  47432. private _size;
  47433. private _onLoad;
  47434. private _onError;
  47435. /**
  47436. * The texture URL.
  47437. */
  47438. url: string;
  47439. /**
  47440. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47441. */
  47442. coordinatesMode: number;
  47443. protected _isBlocking: boolean;
  47444. /**
  47445. * Sets wether or not the texture is blocking during loading.
  47446. */
  47447. /**
  47448. * Gets wether or not the texture is blocking during loading.
  47449. */
  47450. isBlocking: boolean;
  47451. protected _rotationY: number;
  47452. /**
  47453. * Sets texture matrix rotation angle around Y axis in radians.
  47454. */
  47455. /**
  47456. * Gets texture matrix rotation angle around Y axis radians.
  47457. */
  47458. rotationY: number;
  47459. /**
  47460. * Gets or sets the center of the bounding box associated with the cube texture
  47461. * It must define where the camera used to render the texture was set
  47462. */
  47463. boundingBoxPosition: Vector3;
  47464. private _boundingBoxSize;
  47465. /**
  47466. * Gets or sets the size of the bounding box associated with the cube texture
  47467. * When defined, the cubemap will switch to local mode
  47468. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47469. * @example https://www.babylonjs-playground.com/#RNASML
  47470. */
  47471. boundingBoxSize: Vector3;
  47472. /**
  47473. * Instantiates an HDRTexture from the following parameters.
  47474. *
  47475. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47476. * @param scene The scene the texture will be used in
  47477. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47478. * @param noMipmap Forces to not generate the mipmap if true
  47479. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47480. * @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)
  47481. * @param reserved Reserved flag for internal use.
  47482. */
  47483. 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>);
  47484. /**
  47485. * Get the current class name of the texture useful for serialization or dynamic coding.
  47486. * @returns "HDRCubeTexture"
  47487. */
  47488. getClassName(): string;
  47489. /**
  47490. * Occurs when the file is raw .hdr file.
  47491. */
  47492. private loadTexture;
  47493. clone(): HDRCubeTexture;
  47494. delayLoad(): void;
  47495. /**
  47496. * Get the texture reflection matrix used to rotate/transform the reflection.
  47497. * @returns the reflection matrix
  47498. */
  47499. getReflectionTextureMatrix(): Matrix;
  47500. /**
  47501. * Set the texture reflection matrix used to rotate/transform the reflection.
  47502. * @param value Define the reflection matrix to set
  47503. */
  47504. setReflectionTextureMatrix(value: Matrix): void;
  47505. /**
  47506. * Parses a JSON representation of an HDR Texture in order to create the texture
  47507. * @param parsedTexture Define the JSON representation
  47508. * @param scene Define the scene the texture should be created in
  47509. * @param rootUrl Define the root url in case we need to load relative dependencies
  47510. * @returns the newly created texture after parsing
  47511. */
  47512. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47513. serialize(): any;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. /**
  47518. * Class used to control physics engine
  47519. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47520. */
  47521. export class PhysicsEngine implements IPhysicsEngine {
  47522. private _physicsPlugin;
  47523. /**
  47524. * Global value used to control the smallest number supported by the simulation
  47525. */
  47526. static Epsilon: number;
  47527. private _impostors;
  47528. private _joints;
  47529. /**
  47530. * Gets the gravity vector used by the simulation
  47531. */
  47532. gravity: Vector3;
  47533. /**
  47534. * Factory used to create the default physics plugin.
  47535. * @returns The default physics plugin
  47536. */
  47537. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47538. /**
  47539. * Creates a new Physics Engine
  47540. * @param gravity defines the gravity vector used by the simulation
  47541. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47542. */
  47543. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47544. /**
  47545. * Sets the gravity vector used by the simulation
  47546. * @param gravity defines the gravity vector to use
  47547. */
  47548. setGravity(gravity: Vector3): void;
  47549. /**
  47550. * Set the time step of the physics engine.
  47551. * Default is 1/60.
  47552. * To slow it down, enter 1/600 for example.
  47553. * To speed it up, 1/30
  47554. * @param newTimeStep defines the new timestep to apply to this world.
  47555. */
  47556. setTimeStep(newTimeStep?: number): void;
  47557. /**
  47558. * Get the time step of the physics engine.
  47559. * @returns the current time step
  47560. */
  47561. getTimeStep(): number;
  47562. /**
  47563. * Release all resources
  47564. */
  47565. dispose(): void;
  47566. /**
  47567. * Gets the name of the current physics plugin
  47568. * @returns the name of the plugin
  47569. */
  47570. getPhysicsPluginName(): string;
  47571. /**
  47572. * Adding a new impostor for the impostor tracking.
  47573. * This will be done by the impostor itself.
  47574. * @param impostor the impostor to add
  47575. */
  47576. addImpostor(impostor: PhysicsImpostor): void;
  47577. /**
  47578. * Remove an impostor from the engine.
  47579. * This impostor and its mesh will not longer be updated by the physics engine.
  47580. * @param impostor the impostor to remove
  47581. */
  47582. removeImpostor(impostor: PhysicsImpostor): void;
  47583. /**
  47584. * Add a joint to the physics engine
  47585. * @param mainImpostor defines the main impostor to which the joint is added.
  47586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47587. * @param joint defines the joint that will connect both impostors.
  47588. */
  47589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47590. /**
  47591. * Removes a joint from the simulation
  47592. * @param mainImpostor defines the impostor used with the joint
  47593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47594. * @param joint defines the joint to remove
  47595. */
  47596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47597. /**
  47598. * Called by the scene. No need to call it.
  47599. * @param delta defines the timespam between frames
  47600. */
  47601. _step(delta: number): void;
  47602. /**
  47603. * Gets the current plugin used to run the simulation
  47604. * @returns current plugin
  47605. */
  47606. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47607. /**
  47608. * Gets the list of physic impostors
  47609. * @returns an array of PhysicsImpostor
  47610. */
  47611. getImpostors(): Array<PhysicsImpostor>;
  47612. /**
  47613. * Gets the impostor for a physics enabled object
  47614. * @param object defines the object impersonated by the impostor
  47615. * @returns the PhysicsImpostor or null if not found
  47616. */
  47617. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47618. /**
  47619. * Gets the impostor for a physics body object
  47620. * @param body defines physics body used by the impostor
  47621. * @returns the PhysicsImpostor or null if not found
  47622. */
  47623. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47624. /**
  47625. * Does a raycast in the physics world
  47626. * @param from when should the ray start?
  47627. * @param to when should the ray end?
  47628. * @returns PhysicsRaycastResult
  47629. */
  47630. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47631. }
  47632. }
  47633. declare module BABYLON {
  47634. /** @hidden */
  47635. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47636. private _useDeltaForWorldStep;
  47637. world: any;
  47638. name: string;
  47639. private _physicsMaterials;
  47640. private _fixedTimeStep;
  47641. private _cannonRaycastResult;
  47642. private _raycastResult;
  47643. BJSCANNON: any;
  47644. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47645. setGravity(gravity: Vector3): void;
  47646. setTimeStep(timeStep: number): void;
  47647. getTimeStep(): number;
  47648. executeStep(delta: number): void;
  47649. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47650. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47651. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47652. private _processChildMeshes;
  47653. removePhysicsBody(impostor: PhysicsImpostor): void;
  47654. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47655. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47656. private _addMaterial;
  47657. private _checkWithEpsilon;
  47658. private _createShape;
  47659. private _createHeightmap;
  47660. private _minus90X;
  47661. private _plus90X;
  47662. private _tmpPosition;
  47663. private _tmpDeltaPosition;
  47664. private _tmpUnityRotation;
  47665. private _updatePhysicsBodyTransformation;
  47666. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47667. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47668. isSupported(): boolean;
  47669. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47670. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47671. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47672. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47673. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47674. getBodyMass(impostor: PhysicsImpostor): number;
  47675. getBodyFriction(impostor: PhysicsImpostor): number;
  47676. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47677. getBodyRestitution(impostor: PhysicsImpostor): number;
  47678. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47679. sleepBody(impostor: PhysicsImpostor): void;
  47680. wakeUpBody(impostor: PhysicsImpostor): void;
  47681. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47682. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47683. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47684. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47685. getRadius(impostor: PhysicsImpostor): number;
  47686. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47687. dispose(): void;
  47688. private _extendNamespace;
  47689. /**
  47690. * Does a raycast in the physics world
  47691. * @param from when should the ray start?
  47692. * @param to when should the ray end?
  47693. * @returns PhysicsRaycastResult
  47694. */
  47695. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47696. }
  47697. }
  47698. declare module BABYLON {
  47699. /** @hidden */
  47700. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47701. world: any;
  47702. name: string;
  47703. BJSOIMO: any;
  47704. private _raycastResult;
  47705. constructor(iterations?: number, oimoInjection?: any);
  47706. setGravity(gravity: Vector3): void;
  47707. setTimeStep(timeStep: number): void;
  47708. getTimeStep(): number;
  47709. private _tmpImpostorsArray;
  47710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47714. private _tmpPositionVector;
  47715. removePhysicsBody(impostor: PhysicsImpostor): void;
  47716. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47717. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47718. isSupported(): boolean;
  47719. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47720. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47721. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47724. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47726. getBodyMass(impostor: PhysicsImpostor): number;
  47727. getBodyFriction(impostor: PhysicsImpostor): number;
  47728. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47729. getBodyRestitution(impostor: PhysicsImpostor): number;
  47730. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47731. sleepBody(impostor: PhysicsImpostor): void;
  47732. wakeUpBody(impostor: PhysicsImpostor): void;
  47733. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47734. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47735. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47736. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47737. getRadius(impostor: PhysicsImpostor): number;
  47738. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47739. dispose(): void;
  47740. /**
  47741. * Does a raycast in the physics world
  47742. * @param from when should the ray start?
  47743. * @param to when should the ray end?
  47744. * @returns PhysicsRaycastResult
  47745. */
  47746. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47747. }
  47748. }
  47749. declare module BABYLON {
  47750. /**
  47751. * Class containing static functions to help procedurally build meshes
  47752. */
  47753. export class RibbonBuilder {
  47754. /**
  47755. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47756. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47757. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47758. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47759. * * 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
  47760. * * 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
  47761. * * 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
  47762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47763. * * 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
  47764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47765. * * 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
  47766. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47767. * * 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
  47768. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47770. * @param name defines the name of the mesh
  47771. * @param options defines the options used to create the mesh
  47772. * @param scene defines the hosting scene
  47773. * @returns the ribbon mesh
  47774. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47775. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47776. */
  47777. static CreateRibbon(name: string, options: {
  47778. pathArray: Vector3[][];
  47779. closeArray?: boolean;
  47780. closePath?: boolean;
  47781. offset?: number;
  47782. updatable?: boolean;
  47783. sideOrientation?: number;
  47784. frontUVs?: Vector4;
  47785. backUVs?: Vector4;
  47786. instance?: Mesh;
  47787. invertUV?: boolean;
  47788. uvs?: Vector2[];
  47789. colors?: Color4[];
  47790. }, scene?: Nullable<Scene>): Mesh;
  47791. }
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * Class containing static functions to help procedurally build meshes
  47796. */
  47797. export class ShapeBuilder {
  47798. /**
  47799. * 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.
  47800. * * 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.
  47801. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47802. * * 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.
  47803. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47804. * * 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
  47805. * * 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
  47806. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47808. * * 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
  47809. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47811. * @param name defines the name of the mesh
  47812. * @param options defines the options used to create the mesh
  47813. * @param scene defines the hosting scene
  47814. * @returns the extruded shape mesh
  47815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47817. */
  47818. static ExtrudeShape(name: string, options: {
  47819. shape: Vector3[];
  47820. path: Vector3[];
  47821. scale?: number;
  47822. rotation?: number;
  47823. cap?: number;
  47824. updatable?: boolean;
  47825. sideOrientation?: number;
  47826. frontUVs?: Vector4;
  47827. backUVs?: Vector4;
  47828. instance?: Mesh;
  47829. invertUV?: boolean;
  47830. }, scene?: Nullable<Scene>): Mesh;
  47831. /**
  47832. * Creates an custom extruded shape mesh.
  47833. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47834. * * 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.
  47835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47836. * * 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
  47837. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47838. * * 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
  47839. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47840. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47841. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47842. * * 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
  47843. * * 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
  47844. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47846. * * 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
  47847. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47849. * @param name defines the name of the mesh
  47850. * @param options defines the options used to create the mesh
  47851. * @param scene defines the hosting scene
  47852. * @returns the custom extruded shape mesh
  47853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47856. */
  47857. static ExtrudeShapeCustom(name: string, options: {
  47858. shape: Vector3[];
  47859. path: Vector3[];
  47860. scaleFunction?: any;
  47861. rotationFunction?: any;
  47862. ribbonCloseArray?: boolean;
  47863. ribbonClosePath?: boolean;
  47864. cap?: number;
  47865. updatable?: boolean;
  47866. sideOrientation?: number;
  47867. frontUVs?: Vector4;
  47868. backUVs?: Vector4;
  47869. instance?: Mesh;
  47870. invertUV?: boolean;
  47871. }, scene: Scene): Mesh;
  47872. private static _ExtrudeShapeGeneric;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. /**
  47877. * AmmoJS Physics plugin
  47878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47879. * @see https://github.com/kripken/ammo.js/
  47880. */
  47881. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47882. private _useDeltaForWorldStep;
  47883. /**
  47884. * Reference to the Ammo library
  47885. */
  47886. bjsAMMO: any;
  47887. /**
  47888. * Created ammoJS world which physics bodies are added to
  47889. */
  47890. world: any;
  47891. /**
  47892. * Name of the plugin
  47893. */
  47894. name: string;
  47895. private _timeStep;
  47896. private _fixedTimeStep;
  47897. private _maxSteps;
  47898. private _tmpQuaternion;
  47899. private _tmpAmmoTransform;
  47900. private _tmpAmmoQuaternion;
  47901. private _tmpAmmoConcreteContactResultCallback;
  47902. private _collisionConfiguration;
  47903. private _dispatcher;
  47904. private _overlappingPairCache;
  47905. private _solver;
  47906. private _softBodySolver;
  47907. private _tmpAmmoVectorA;
  47908. private _tmpAmmoVectorB;
  47909. private _tmpAmmoVectorC;
  47910. private _tmpAmmoVectorD;
  47911. private _tmpContactCallbackResult;
  47912. private _tmpAmmoVectorRCA;
  47913. private _tmpAmmoVectorRCB;
  47914. private _raycastResult;
  47915. private static readonly DISABLE_COLLISION_FLAG;
  47916. private static readonly KINEMATIC_FLAG;
  47917. private static readonly DISABLE_DEACTIVATION_FLAG;
  47918. /**
  47919. * Initializes the ammoJS plugin
  47920. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47921. * @param ammoInjection can be used to inject your own ammo reference
  47922. */
  47923. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47924. /**
  47925. * Sets the gravity of the physics world (m/(s^2))
  47926. * @param gravity Gravity to set
  47927. */
  47928. setGravity(gravity: Vector3): void;
  47929. /**
  47930. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47931. * @param timeStep timestep to use in seconds
  47932. */
  47933. setTimeStep(timeStep: number): void;
  47934. /**
  47935. * 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)
  47936. * @param fixedTimeStep fixedTimeStep to use in seconds
  47937. */
  47938. setFixedTimeStep(fixedTimeStep: number): void;
  47939. /**
  47940. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47941. * @param maxSteps the maximum number of steps by the physics engine per frame
  47942. */
  47943. setMaxSteps(maxSteps: number): void;
  47944. /**
  47945. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47946. * @returns the current timestep in seconds
  47947. */
  47948. getTimeStep(): number;
  47949. private _isImpostorInContact;
  47950. private _isImpostorPairInContact;
  47951. private _stepSimulation;
  47952. /**
  47953. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47954. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47955. * After the step the babylon meshes are set to the position of the physics imposters
  47956. * @param delta amount of time to step forward
  47957. * @param impostors array of imposters to update before/after the step
  47958. */
  47959. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47960. /**
  47961. * Update babylon mesh to match physics world object
  47962. * @param impostor imposter to match
  47963. */
  47964. private _afterSoftStep;
  47965. /**
  47966. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47967. * @param impostor imposter to match
  47968. */
  47969. private _ropeStep;
  47970. /**
  47971. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47972. * @param impostor imposter to match
  47973. */
  47974. private _softbodyOrClothStep;
  47975. private _tmpVector;
  47976. private _tmpMatrix;
  47977. /**
  47978. * Applies an impulse on the imposter
  47979. * @param impostor imposter to apply impulse to
  47980. * @param force amount of force to be applied to the imposter
  47981. * @param contactPoint the location to apply the impulse on the imposter
  47982. */
  47983. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47984. /**
  47985. * Applies a force on the imposter
  47986. * @param impostor imposter to apply force
  47987. * @param force amount of force to be applied to the imposter
  47988. * @param contactPoint the location to apply the force on the imposter
  47989. */
  47990. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47991. /**
  47992. * Creates a physics body using the plugin
  47993. * @param impostor the imposter to create the physics body on
  47994. */
  47995. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47996. /**
  47997. * Removes the physics body from the imposter and disposes of the body's memory
  47998. * @param impostor imposter to remove the physics body from
  47999. */
  48000. removePhysicsBody(impostor: PhysicsImpostor): void;
  48001. /**
  48002. * Generates a joint
  48003. * @param impostorJoint the imposter joint to create the joint with
  48004. */
  48005. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48006. /**
  48007. * Removes a joint
  48008. * @param impostorJoint the imposter joint to remove the joint from
  48009. */
  48010. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48011. private _addMeshVerts;
  48012. /**
  48013. * Initialise the soft body vertices to match its object's (mesh) vertices
  48014. * Softbody vertices (nodes) are in world space and to match this
  48015. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48016. * @param impostor to create the softbody for
  48017. */
  48018. private _softVertexData;
  48019. /**
  48020. * Create an impostor's soft body
  48021. * @param impostor to create the softbody for
  48022. */
  48023. private _createSoftbody;
  48024. /**
  48025. * Create cloth for an impostor
  48026. * @param impostor to create the softbody for
  48027. */
  48028. private _createCloth;
  48029. /**
  48030. * Create rope for an impostor
  48031. * @param impostor to create the softbody for
  48032. */
  48033. private _createRope;
  48034. private _addHullVerts;
  48035. private _createShape;
  48036. /**
  48037. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48038. * @param impostor imposter containing the physics body and babylon object
  48039. */
  48040. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48041. /**
  48042. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48043. * @param impostor imposter containing the physics body and babylon object
  48044. * @param newPosition new position
  48045. * @param newRotation new rotation
  48046. */
  48047. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48048. /**
  48049. * If this plugin is supported
  48050. * @returns true if its supported
  48051. */
  48052. isSupported(): boolean;
  48053. /**
  48054. * Sets the linear velocity of the physics body
  48055. * @param impostor imposter to set the velocity on
  48056. * @param velocity velocity to set
  48057. */
  48058. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48059. /**
  48060. * Sets the angular velocity of the physics body
  48061. * @param impostor imposter to set the velocity on
  48062. * @param velocity velocity to set
  48063. */
  48064. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48065. /**
  48066. * gets the linear velocity
  48067. * @param impostor imposter to get linear velocity from
  48068. * @returns linear velocity
  48069. */
  48070. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48071. /**
  48072. * gets the angular velocity
  48073. * @param impostor imposter to get angular velocity from
  48074. * @returns angular velocity
  48075. */
  48076. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48077. /**
  48078. * Sets the mass of physics body
  48079. * @param impostor imposter to set the mass on
  48080. * @param mass mass to set
  48081. */
  48082. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48083. /**
  48084. * Gets the mass of the physics body
  48085. * @param impostor imposter to get the mass from
  48086. * @returns mass
  48087. */
  48088. getBodyMass(impostor: PhysicsImpostor): number;
  48089. /**
  48090. * Gets friction of the impostor
  48091. * @param impostor impostor to get friction from
  48092. * @returns friction value
  48093. */
  48094. getBodyFriction(impostor: PhysicsImpostor): number;
  48095. /**
  48096. * Sets friction of the impostor
  48097. * @param impostor impostor to set friction on
  48098. * @param friction friction value
  48099. */
  48100. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48101. /**
  48102. * Gets restitution of the impostor
  48103. * @param impostor impostor to get restitution from
  48104. * @returns restitution value
  48105. */
  48106. getBodyRestitution(impostor: PhysicsImpostor): number;
  48107. /**
  48108. * Sets resitution of the impostor
  48109. * @param impostor impostor to set resitution on
  48110. * @param restitution resitution value
  48111. */
  48112. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48113. /**
  48114. * Gets pressure inside the impostor
  48115. * @param impostor impostor to get pressure from
  48116. * @returns pressure value
  48117. */
  48118. getBodyPressure(impostor: PhysicsImpostor): number;
  48119. /**
  48120. * Sets pressure inside a soft body impostor
  48121. * Cloth and rope must remain 0 pressure
  48122. * @param impostor impostor to set pressure on
  48123. * @param pressure pressure value
  48124. */
  48125. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48126. /**
  48127. * Gets stiffness of the impostor
  48128. * @param impostor impostor to get stiffness from
  48129. * @returns pressure value
  48130. */
  48131. getBodyStiffness(impostor: PhysicsImpostor): number;
  48132. /**
  48133. * Sets stiffness of the impostor
  48134. * @param impostor impostor to set stiffness on
  48135. * @param stiffness stiffness value from 0 to 1
  48136. */
  48137. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48138. /**
  48139. * Gets velocityIterations of the impostor
  48140. * @param impostor impostor to get velocity iterations from
  48141. * @returns velocityIterations value
  48142. */
  48143. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48144. /**
  48145. * Sets velocityIterations of the impostor
  48146. * @param impostor impostor to set velocity iterations on
  48147. * @param velocityIterations velocityIterations value
  48148. */
  48149. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48150. /**
  48151. * Gets positionIterations of the impostor
  48152. * @param impostor impostor to get position iterations from
  48153. * @returns positionIterations value
  48154. */
  48155. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48156. /**
  48157. * Sets positionIterations of the impostor
  48158. * @param impostor impostor to set position on
  48159. * @param positionIterations positionIterations value
  48160. */
  48161. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48162. /**
  48163. * Append an anchor to a cloth object
  48164. * @param impostor is the cloth impostor to add anchor to
  48165. * @param otherImpostor is the rigid impostor to anchor to
  48166. * @param width ratio across width from 0 to 1
  48167. * @param height ratio up height from 0 to 1
  48168. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48169. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48170. */
  48171. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48172. /**
  48173. * Append an hook to a rope object
  48174. * @param impostor is the rope impostor to add hook to
  48175. * @param otherImpostor is the rigid impostor to hook to
  48176. * @param length ratio along the rope from 0 to 1
  48177. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48179. */
  48180. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48181. /**
  48182. * Sleeps the physics body and stops it from being active
  48183. * @param impostor impostor to sleep
  48184. */
  48185. sleepBody(impostor: PhysicsImpostor): void;
  48186. /**
  48187. * Activates the physics body
  48188. * @param impostor impostor to activate
  48189. */
  48190. wakeUpBody(impostor: PhysicsImpostor): void;
  48191. /**
  48192. * Updates the distance parameters of the joint
  48193. * @param joint joint to update
  48194. * @param maxDistance maximum distance of the joint
  48195. * @param minDistance minimum distance of the joint
  48196. */
  48197. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48198. /**
  48199. * Sets a motor on the joint
  48200. * @param joint joint to set motor on
  48201. * @param speed speed of the motor
  48202. * @param maxForce maximum force of the motor
  48203. * @param motorIndex index of the motor
  48204. */
  48205. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48206. /**
  48207. * Sets the motors limit
  48208. * @param joint joint to set limit on
  48209. * @param upperLimit upper limit
  48210. * @param lowerLimit lower limit
  48211. */
  48212. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48213. /**
  48214. * Syncs the position and rotation of a mesh with the impostor
  48215. * @param mesh mesh to sync
  48216. * @param impostor impostor to update the mesh with
  48217. */
  48218. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48219. /**
  48220. * Gets the radius of the impostor
  48221. * @param impostor impostor to get radius from
  48222. * @returns the radius
  48223. */
  48224. getRadius(impostor: PhysicsImpostor): number;
  48225. /**
  48226. * Gets the box size of the impostor
  48227. * @param impostor impostor to get box size from
  48228. * @param result the resulting box size
  48229. */
  48230. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48231. /**
  48232. * Disposes of the impostor
  48233. */
  48234. dispose(): void;
  48235. /**
  48236. * Does a raycast in the physics world
  48237. * @param from when should the ray start?
  48238. * @param to when should the ray end?
  48239. * @returns PhysicsRaycastResult
  48240. */
  48241. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48242. }
  48243. }
  48244. declare module BABYLON {
  48245. interface AbstractScene {
  48246. /**
  48247. * The list of reflection probes added to the scene
  48248. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48249. */
  48250. reflectionProbes: Array<ReflectionProbe>;
  48251. /**
  48252. * Removes the given reflection probe from this scene.
  48253. * @param toRemove The reflection probe to remove
  48254. * @returns The index of the removed reflection probe
  48255. */
  48256. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48257. /**
  48258. * Adds the given reflection probe to this scene.
  48259. * @param newReflectionProbe The reflection probe to add
  48260. */
  48261. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48262. }
  48263. /**
  48264. * Class used to generate realtime reflection / refraction cube textures
  48265. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48266. */
  48267. export class ReflectionProbe {
  48268. /** defines the name of the probe */
  48269. name: string;
  48270. private _scene;
  48271. private _renderTargetTexture;
  48272. private _projectionMatrix;
  48273. private _viewMatrix;
  48274. private _target;
  48275. private _add;
  48276. private _attachedMesh;
  48277. private _invertYAxis;
  48278. /** Gets or sets probe position (center of the cube map) */
  48279. position: Vector3;
  48280. /**
  48281. * Creates a new reflection probe
  48282. * @param name defines the name of the probe
  48283. * @param size defines the texture resolution (for each face)
  48284. * @param scene defines the hosting scene
  48285. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48286. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48287. */
  48288. constructor(
  48289. /** defines the name of the probe */
  48290. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48291. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48292. samples: number;
  48293. /** Gets or sets the refresh rate to use (on every frame by default) */
  48294. refreshRate: number;
  48295. /**
  48296. * Gets the hosting scene
  48297. * @returns a Scene
  48298. */
  48299. getScene(): Scene;
  48300. /** Gets the internal CubeTexture used to render to */
  48301. readonly cubeTexture: RenderTargetTexture;
  48302. /** Gets the list of meshes to render */
  48303. readonly renderList: Nullable<AbstractMesh[]>;
  48304. /**
  48305. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48306. * @param mesh defines the mesh to attach to
  48307. */
  48308. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48309. /**
  48310. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48311. * @param renderingGroupId The rendering group id corresponding to its index
  48312. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48313. */
  48314. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48315. /**
  48316. * Clean all associated resources
  48317. */
  48318. dispose(): void;
  48319. /**
  48320. * Converts the reflection probe information to a readable string for debug purpose.
  48321. * @param fullDetails Supports for multiple levels of logging within scene loading
  48322. * @returns the human readable reflection probe info
  48323. */
  48324. toString(fullDetails?: boolean): string;
  48325. /**
  48326. * Get the class name of the relfection probe.
  48327. * @returns "ReflectionProbe"
  48328. */
  48329. getClassName(): string;
  48330. /**
  48331. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48332. * @returns The JSON representation of the texture
  48333. */
  48334. serialize(): any;
  48335. /**
  48336. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48337. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48338. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48339. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48340. * @returns The parsed reflection probe if successful
  48341. */
  48342. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48343. }
  48344. }
  48345. declare module BABYLON {
  48346. /** @hidden */
  48347. export var _BabylonLoaderRegistered: boolean;
  48348. }
  48349. declare module BABYLON {
  48350. /**
  48351. * The Physically based simple base material of BJS.
  48352. *
  48353. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48354. * It is used as the base class for both the specGloss and metalRough conventions.
  48355. */
  48356. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48357. /**
  48358. * Number of Simultaneous lights allowed on the material.
  48359. */
  48360. maxSimultaneousLights: number;
  48361. /**
  48362. * If sets to true, disables all the lights affecting the material.
  48363. */
  48364. disableLighting: boolean;
  48365. /**
  48366. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48367. */
  48368. environmentTexture: BaseTexture;
  48369. /**
  48370. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48371. */
  48372. invertNormalMapX: boolean;
  48373. /**
  48374. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48375. */
  48376. invertNormalMapY: boolean;
  48377. /**
  48378. * Normal map used in the model.
  48379. */
  48380. normalTexture: BaseTexture;
  48381. /**
  48382. * Emissivie color used to self-illuminate the model.
  48383. */
  48384. emissiveColor: Color3;
  48385. /**
  48386. * Emissivie texture used to self-illuminate the model.
  48387. */
  48388. emissiveTexture: BaseTexture;
  48389. /**
  48390. * Occlusion Channel Strenght.
  48391. */
  48392. occlusionStrength: number;
  48393. /**
  48394. * Occlusion Texture of the material (adding extra occlusion effects).
  48395. */
  48396. occlusionTexture: BaseTexture;
  48397. /**
  48398. * Defines the alpha limits in alpha test mode.
  48399. */
  48400. alphaCutOff: number;
  48401. /**
  48402. * Gets the current double sided mode.
  48403. */
  48404. /**
  48405. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48406. */
  48407. doubleSided: boolean;
  48408. /**
  48409. * Stores the pre-calculated light information of a mesh in a texture.
  48410. */
  48411. lightmapTexture: BaseTexture;
  48412. /**
  48413. * If true, the light map contains occlusion information instead of lighting info.
  48414. */
  48415. useLightmapAsShadowmap: boolean;
  48416. /**
  48417. * Instantiates a new PBRMaterial instance.
  48418. *
  48419. * @param name The material name
  48420. * @param scene The scene the material will be use in.
  48421. */
  48422. constructor(name: string, scene: Scene);
  48423. getClassName(): string;
  48424. }
  48425. }
  48426. declare module BABYLON {
  48427. /**
  48428. * The PBR material of BJS following the metal roughness convention.
  48429. *
  48430. * This fits to the PBR convention in the GLTF definition:
  48431. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48432. */
  48433. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48434. /**
  48435. * The base color has two different interpretations depending on the value of metalness.
  48436. * When the material is a metal, the base color is the specific measured reflectance value
  48437. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48438. * of the material.
  48439. */
  48440. baseColor: Color3;
  48441. /**
  48442. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48443. * well as opacity information in the alpha channel.
  48444. */
  48445. baseTexture: BaseTexture;
  48446. /**
  48447. * Specifies the metallic scalar value of the material.
  48448. * Can also be used to scale the metalness values of the metallic texture.
  48449. */
  48450. metallic: number;
  48451. /**
  48452. * Specifies the roughness scalar value of the material.
  48453. * Can also be used to scale the roughness values of the metallic texture.
  48454. */
  48455. roughness: number;
  48456. /**
  48457. * Texture containing both the metallic value in the B channel and the
  48458. * roughness value in the G channel to keep better precision.
  48459. */
  48460. metallicRoughnessTexture: BaseTexture;
  48461. /**
  48462. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48463. *
  48464. * @param name The material name
  48465. * @param scene The scene the material will be use in.
  48466. */
  48467. constructor(name: string, scene: Scene);
  48468. /**
  48469. * Return the currrent class name of the material.
  48470. */
  48471. getClassName(): string;
  48472. /**
  48473. * Makes a duplicate of the current material.
  48474. * @param name - name to use for the new material.
  48475. */
  48476. clone(name: string): PBRMetallicRoughnessMaterial;
  48477. /**
  48478. * Serialize the material to a parsable JSON object.
  48479. */
  48480. serialize(): any;
  48481. /**
  48482. * Parses a JSON object correponding to the serialize function.
  48483. */
  48484. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48485. }
  48486. }
  48487. declare module BABYLON {
  48488. /**
  48489. * The PBR material of BJS following the specular glossiness convention.
  48490. *
  48491. * This fits to the PBR convention in the GLTF definition:
  48492. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48493. */
  48494. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48495. /**
  48496. * Specifies the diffuse color of the material.
  48497. */
  48498. diffuseColor: Color3;
  48499. /**
  48500. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48501. * channel.
  48502. */
  48503. diffuseTexture: BaseTexture;
  48504. /**
  48505. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48506. */
  48507. specularColor: Color3;
  48508. /**
  48509. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48510. */
  48511. glossiness: number;
  48512. /**
  48513. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48514. */
  48515. specularGlossinessTexture: BaseTexture;
  48516. /**
  48517. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48518. *
  48519. * @param name The material name
  48520. * @param scene The scene the material will be use in.
  48521. */
  48522. constructor(name: string, scene: Scene);
  48523. /**
  48524. * Return the currrent class name of the material.
  48525. */
  48526. getClassName(): string;
  48527. /**
  48528. * Makes a duplicate of the current material.
  48529. * @param name - name to use for the new material.
  48530. */
  48531. clone(name: string): PBRSpecularGlossinessMaterial;
  48532. /**
  48533. * Serialize the material to a parsable JSON object.
  48534. */
  48535. serialize(): any;
  48536. /**
  48537. * Parses a JSON object correponding to the serialize function.
  48538. */
  48539. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /**
  48544. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48545. * It can help converting any input color in a desired output one. This can then be used to create effects
  48546. * from sepia, black and white to sixties or futuristic rendering...
  48547. *
  48548. * The only supported format is currently 3dl.
  48549. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48550. */
  48551. export class ColorGradingTexture extends BaseTexture {
  48552. /**
  48553. * The current texture matrix. (will always be identity in color grading texture)
  48554. */
  48555. private _textureMatrix;
  48556. /**
  48557. * The texture URL.
  48558. */
  48559. url: string;
  48560. /**
  48561. * Empty line regex stored for GC.
  48562. */
  48563. private static _noneEmptyLineRegex;
  48564. private _engine;
  48565. /**
  48566. * Instantiates a ColorGradingTexture from the following parameters.
  48567. *
  48568. * @param url The location of the color gradind data (currently only supporting 3dl)
  48569. * @param scene The scene the texture will be used in
  48570. */
  48571. constructor(url: string, scene: Scene);
  48572. /**
  48573. * Returns the texture matrix used in most of the material.
  48574. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48575. */
  48576. getTextureMatrix(): Matrix;
  48577. /**
  48578. * Occurs when the file being loaded is a .3dl LUT file.
  48579. */
  48580. private load3dlTexture;
  48581. /**
  48582. * Starts the loading process of the texture.
  48583. */
  48584. private loadTexture;
  48585. /**
  48586. * Clones the color gradind texture.
  48587. */
  48588. clone(): ColorGradingTexture;
  48589. /**
  48590. * Called during delayed load for textures.
  48591. */
  48592. delayLoad(): void;
  48593. /**
  48594. * Parses a color grading texture serialized by Babylon.
  48595. * @param parsedTexture The texture information being parsedTexture
  48596. * @param scene The scene to load the texture in
  48597. * @param rootUrl The root url of the data assets to load
  48598. * @return A color gradind texture
  48599. */
  48600. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48601. /**
  48602. * Serializes the LUT texture to json format.
  48603. */
  48604. serialize(): any;
  48605. }
  48606. }
  48607. declare module BABYLON {
  48608. /**
  48609. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48610. */
  48611. export class EquiRectangularCubeTexture extends BaseTexture {
  48612. /** The six faces of the cube. */
  48613. private static _FacesMapping;
  48614. private _noMipmap;
  48615. private _onLoad;
  48616. private _onError;
  48617. /** The size of the cubemap. */
  48618. private _size;
  48619. /** The buffer of the image. */
  48620. private _buffer;
  48621. /** The width of the input image. */
  48622. private _width;
  48623. /** The height of the input image. */
  48624. private _height;
  48625. /** The URL to the image. */
  48626. url: string;
  48627. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48628. coordinatesMode: number;
  48629. /**
  48630. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48631. * @param url The location of the image
  48632. * @param scene The scene the texture will be used in
  48633. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48634. * @param noMipmap Forces to not generate the mipmap if true
  48635. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48636. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48637. * @param onLoad — defines a callback called when texture is loaded
  48638. * @param onError — defines a callback called if there is an error
  48639. */
  48640. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48641. /**
  48642. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48643. */
  48644. private loadImage;
  48645. /**
  48646. * Convert the image buffer into a cubemap and create a CubeTexture.
  48647. */
  48648. private loadTexture;
  48649. /**
  48650. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48651. * @param buffer The ArrayBuffer that should be converted.
  48652. * @returns The buffer as Float32Array.
  48653. */
  48654. private getFloat32ArrayFromArrayBuffer;
  48655. /**
  48656. * Get the current class name of the texture useful for serialization or dynamic coding.
  48657. * @returns "EquiRectangularCubeTexture"
  48658. */
  48659. getClassName(): string;
  48660. /**
  48661. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48662. * @returns A clone of the current EquiRectangularCubeTexture.
  48663. */
  48664. clone(): EquiRectangularCubeTexture;
  48665. }
  48666. }
  48667. declare module BABYLON {
  48668. /**
  48669. * Based on jsTGALoader - Javascript loader for TGA file
  48670. * By Vincent Thibault
  48671. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48672. */
  48673. export class TGATools {
  48674. private static _TYPE_INDEXED;
  48675. private static _TYPE_RGB;
  48676. private static _TYPE_GREY;
  48677. private static _TYPE_RLE_INDEXED;
  48678. private static _TYPE_RLE_RGB;
  48679. private static _TYPE_RLE_GREY;
  48680. private static _ORIGIN_MASK;
  48681. private static _ORIGIN_SHIFT;
  48682. private static _ORIGIN_BL;
  48683. private static _ORIGIN_BR;
  48684. private static _ORIGIN_UL;
  48685. private static _ORIGIN_UR;
  48686. /**
  48687. * Gets the header of a TGA file
  48688. * @param data defines the TGA data
  48689. * @returns the header
  48690. */
  48691. static GetTGAHeader(data: Uint8Array): any;
  48692. /**
  48693. * Uploads TGA content to a Babylon Texture
  48694. * @hidden
  48695. */
  48696. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48697. /** @hidden */
  48698. 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;
  48699. /** @hidden */
  48700. 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;
  48701. /** @hidden */
  48702. 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;
  48703. /** @hidden */
  48704. 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;
  48705. /** @hidden */
  48706. 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;
  48707. /** @hidden */
  48708. 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;
  48709. }
  48710. }
  48711. declare module BABYLON {
  48712. /**
  48713. * Implementation of the TGA Texture Loader.
  48714. * @hidden
  48715. */
  48716. export class _TGATextureLoader implements IInternalTextureLoader {
  48717. /**
  48718. * Defines wether the loader supports cascade loading the different faces.
  48719. */
  48720. readonly supportCascades: boolean;
  48721. /**
  48722. * This returns if the loader support the current file information.
  48723. * @param extension defines the file extension of the file being loaded
  48724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48725. * @param fallback defines the fallback internal texture if any
  48726. * @param isBase64 defines whether the texture is encoded as a base64
  48727. * @param isBuffer defines whether the texture data are stored as a buffer
  48728. * @returns true if the loader can load the specified file
  48729. */
  48730. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48731. /**
  48732. * Transform the url before loading if required.
  48733. * @param rootUrl the url of the texture
  48734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48735. * @returns the transformed texture
  48736. */
  48737. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48738. /**
  48739. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48740. * @param rootUrl the url of the texture
  48741. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48742. * @returns the fallback texture
  48743. */
  48744. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48745. /**
  48746. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48747. * @param data contains the texture data
  48748. * @param texture defines the BabylonJS internal texture
  48749. * @param createPolynomials will be true if polynomials have been requested
  48750. * @param onLoad defines the callback to trigger once the texture is ready
  48751. * @param onError defines the callback to trigger in case of error
  48752. */
  48753. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48754. /**
  48755. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48756. * @param data contains the texture data
  48757. * @param texture defines the BabylonJS internal texture
  48758. * @param callback defines the method to call once ready to upload
  48759. */
  48760. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48761. }
  48762. }
  48763. declare module BABYLON {
  48764. /**
  48765. * 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.
  48766. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48767. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48768. */
  48769. export class CustomProceduralTexture extends ProceduralTexture {
  48770. private _animate;
  48771. private _time;
  48772. private _config;
  48773. private _texturePath;
  48774. /**
  48775. * Instantiates a new Custom Procedural Texture.
  48776. * 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.
  48777. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48778. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48779. * @param name Define the name of the texture
  48780. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48781. * @param size Define the size of the texture to create
  48782. * @param scene Define the scene the texture belongs to
  48783. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48784. * @param generateMipMaps Define if the texture should creates mip maps or not
  48785. */
  48786. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48787. private _loadJson;
  48788. /**
  48789. * Is the texture ready to be used ? (rendered at least once)
  48790. * @returns true if ready, otherwise, false.
  48791. */
  48792. isReady(): boolean;
  48793. /**
  48794. * Render the texture to its associated render target.
  48795. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48796. */
  48797. render(useCameraPostProcess?: boolean): void;
  48798. /**
  48799. * Update the list of dependant textures samplers in the shader.
  48800. */
  48801. updateTextures(): void;
  48802. /**
  48803. * Update the uniform values of the procedural texture in the shader.
  48804. */
  48805. updateShaderUniforms(): void;
  48806. /**
  48807. * Define if the texture animates or not.
  48808. */
  48809. animate: boolean;
  48810. }
  48811. }
  48812. declare module BABYLON {
  48813. /** @hidden */
  48814. export var noisePixelShader: {
  48815. name: string;
  48816. shader: string;
  48817. };
  48818. }
  48819. declare module BABYLON {
  48820. /**
  48821. * Class used to generate noise procedural textures
  48822. */
  48823. export class NoiseProceduralTexture extends ProceduralTexture {
  48824. private _time;
  48825. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48826. brightness: number;
  48827. /** Defines the number of octaves to process */
  48828. octaves: number;
  48829. /** Defines the level of persistence (0.8 by default) */
  48830. persistence: number;
  48831. /** Gets or sets animation speed factor (default is 1) */
  48832. animationSpeedFactor: number;
  48833. /**
  48834. * Creates a new NoiseProceduralTexture
  48835. * @param name defines the name fo the texture
  48836. * @param size defines the size of the texture (default is 256)
  48837. * @param scene defines the hosting scene
  48838. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48839. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48840. */
  48841. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48842. private _updateShaderUniforms;
  48843. protected _getDefines(): string;
  48844. /** Generate the current state of the procedural texture */
  48845. render(useCameraPostProcess?: boolean): void;
  48846. /**
  48847. * Serializes this noise procedural texture
  48848. * @returns a serialized noise procedural texture object
  48849. */
  48850. serialize(): any;
  48851. /**
  48852. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48853. * @param parsedTexture defines parsed texture data
  48854. * @param scene defines the current scene
  48855. * @param rootUrl defines the root URL containing noise procedural texture information
  48856. * @returns a parsed NoiseProceduralTexture
  48857. */
  48858. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48859. }
  48860. }
  48861. declare module BABYLON {
  48862. /**
  48863. * Raw cube texture where the raw buffers are passed in
  48864. */
  48865. export class RawCubeTexture extends CubeTexture {
  48866. /**
  48867. * Creates a cube texture where the raw buffers are passed in.
  48868. * @param scene defines the scene the texture is attached to
  48869. * @param data defines the array of data to use to create each face
  48870. * @param size defines the size of the textures
  48871. * @param format defines the format of the data
  48872. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48873. * @param generateMipMaps defines if the engine should generate the mip levels
  48874. * @param invertY defines if data must be stored with Y axis inverted
  48875. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48876. * @param compression defines the compression used (null by default)
  48877. */
  48878. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48879. /**
  48880. * Updates the raw cube texture.
  48881. * @param data defines the data to store
  48882. * @param format defines the data format
  48883. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48884. * @param invertY defines if data must be stored with Y axis inverted
  48885. * @param compression defines the compression used (null by default)
  48886. * @param level defines which level of the texture to update
  48887. */
  48888. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48889. /**
  48890. * Updates a raw cube texture with RGBD encoded data.
  48891. * @param data defines the array of data [mipmap][face] to use to create each face
  48892. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48893. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48894. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48895. * @returns a promsie that resolves when the operation is complete
  48896. */
  48897. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48898. /**
  48899. * Clones the raw cube texture.
  48900. * @return a new cube texture
  48901. */
  48902. clone(): CubeTexture;
  48903. /** @hidden */
  48904. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48905. }
  48906. }
  48907. declare module BABYLON {
  48908. /**
  48909. * Class used to store 3D textures containing user data
  48910. */
  48911. export class RawTexture3D extends Texture {
  48912. /** Gets or sets the texture format to use */
  48913. format: number;
  48914. private _engine;
  48915. /**
  48916. * Create a new RawTexture3D
  48917. * @param data defines the data of the texture
  48918. * @param width defines the width of the texture
  48919. * @param height defines the height of the texture
  48920. * @param depth defines the depth of the texture
  48921. * @param format defines the texture format to use
  48922. * @param scene defines the hosting scene
  48923. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48924. * @param invertY defines if texture must be stored with Y axis inverted
  48925. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48926. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48927. */
  48928. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48929. /** Gets or sets the texture format to use */
  48930. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48931. /**
  48932. * Update the texture with new data
  48933. * @param data defines the data to store in the texture
  48934. */
  48935. update(data: ArrayBufferView): void;
  48936. }
  48937. }
  48938. declare module BABYLON {
  48939. /**
  48940. * Creates a refraction texture used by refraction channel of the standard material.
  48941. * It is like a mirror but to see through a material.
  48942. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48943. */
  48944. export class RefractionTexture extends RenderTargetTexture {
  48945. /**
  48946. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48947. * 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.
  48948. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48949. */
  48950. refractionPlane: Plane;
  48951. /**
  48952. * Define how deep under the surface we should see.
  48953. */
  48954. depth: number;
  48955. /**
  48956. * Creates a refraction texture used by refraction channel of the standard material.
  48957. * It is like a mirror but to see through a material.
  48958. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48959. * @param name Define the texture name
  48960. * @param size Define the size of the underlying texture
  48961. * @param scene Define the scene the refraction belongs to
  48962. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48963. */
  48964. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48965. /**
  48966. * Clone the refraction texture.
  48967. * @returns the cloned texture
  48968. */
  48969. clone(): RefractionTexture;
  48970. /**
  48971. * Serialize the texture to a JSON representation you could use in Parse later on
  48972. * @returns the serialized JSON representation
  48973. */
  48974. serialize(): any;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Configuration for Draco compression
  48980. */
  48981. export interface IDracoCompressionConfiguration {
  48982. /**
  48983. * Configuration for the decoder.
  48984. */
  48985. decoder?: {
  48986. /**
  48987. * The url to the WebAssembly module.
  48988. */
  48989. wasmUrl?: string;
  48990. /**
  48991. * The url to the WebAssembly binary.
  48992. */
  48993. wasmBinaryUrl?: string;
  48994. /**
  48995. * The url to the fallback JavaScript module.
  48996. */
  48997. fallbackUrl?: string;
  48998. };
  48999. }
  49000. /**
  49001. * Draco compression (https://google.github.io/draco/)
  49002. *
  49003. * This class wraps the Draco module.
  49004. *
  49005. * **Encoder**
  49006. *
  49007. * The encoder is not currently implemented.
  49008. *
  49009. * **Decoder**
  49010. *
  49011. * 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.
  49012. *
  49013. * To update the configuration, use the following code:
  49014. * ```javascript
  49015. * DracoCompression.Configuration = {
  49016. * decoder: {
  49017. * wasmUrl: "<url to the WebAssembly library>",
  49018. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49019. * fallbackUrl: "<url to the fallback JavaScript library>",
  49020. * }
  49021. * };
  49022. * ```
  49023. *
  49024. * 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.
  49025. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49026. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49027. *
  49028. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49029. * ```javascript
  49030. * var dracoCompression = new DracoCompression();
  49031. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49032. * [VertexBuffer.PositionKind]: 0
  49033. * });
  49034. * ```
  49035. *
  49036. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49037. */
  49038. export class DracoCompression implements IDisposable {
  49039. private static _DecoderModulePromise;
  49040. /**
  49041. * The configuration. Defaults to the following urls:
  49042. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49043. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49044. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49045. */
  49046. static Configuration: IDracoCompressionConfiguration;
  49047. /**
  49048. * Returns true if the decoder is available.
  49049. */
  49050. static readonly DecoderAvailable: boolean;
  49051. /**
  49052. * Constructor
  49053. */
  49054. constructor();
  49055. /**
  49056. * Stop all async operations and release resources.
  49057. */
  49058. dispose(): void;
  49059. /**
  49060. * Decode Draco compressed mesh data to vertex data.
  49061. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49062. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49063. * @returns A promise that resolves with the decoded vertex data
  49064. */
  49065. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49066. [kind: string]: number;
  49067. }): Promise<VertexData>;
  49068. private static _GetDecoderModule;
  49069. private static _LoadScriptAsync;
  49070. private static _LoadFileAsync;
  49071. }
  49072. }
  49073. declare module BABYLON {
  49074. /**
  49075. * Class for building Constructive Solid Geometry
  49076. */
  49077. export class CSG {
  49078. private polygons;
  49079. /**
  49080. * The world matrix
  49081. */
  49082. matrix: Matrix;
  49083. /**
  49084. * Stores the position
  49085. */
  49086. position: Vector3;
  49087. /**
  49088. * Stores the rotation
  49089. */
  49090. rotation: Vector3;
  49091. /**
  49092. * Stores the rotation quaternion
  49093. */
  49094. rotationQuaternion: Nullable<Quaternion>;
  49095. /**
  49096. * Stores the scaling vector
  49097. */
  49098. scaling: Vector3;
  49099. /**
  49100. * Convert the Mesh to CSG
  49101. * @param mesh The Mesh to convert to CSG
  49102. * @returns A new CSG from the Mesh
  49103. */
  49104. static FromMesh(mesh: Mesh): CSG;
  49105. /**
  49106. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49107. * @param polygons Polygons used to construct a CSG solid
  49108. */
  49109. private static FromPolygons;
  49110. /**
  49111. * Clones, or makes a deep copy, of the CSG
  49112. * @returns A new CSG
  49113. */
  49114. clone(): CSG;
  49115. /**
  49116. * Unions this CSG with another CSG
  49117. * @param csg The CSG to union against this CSG
  49118. * @returns The unioned CSG
  49119. */
  49120. union(csg: CSG): CSG;
  49121. /**
  49122. * Unions this CSG with another CSG in place
  49123. * @param csg The CSG to union against this CSG
  49124. */
  49125. unionInPlace(csg: CSG): void;
  49126. /**
  49127. * Subtracts this CSG with another CSG
  49128. * @param csg The CSG to subtract against this CSG
  49129. * @returns A new CSG
  49130. */
  49131. subtract(csg: CSG): CSG;
  49132. /**
  49133. * Subtracts this CSG with another CSG in place
  49134. * @param csg The CSG to subtact against this CSG
  49135. */
  49136. subtractInPlace(csg: CSG): void;
  49137. /**
  49138. * Intersect this CSG with another CSG
  49139. * @param csg The CSG to intersect against this CSG
  49140. * @returns A new CSG
  49141. */
  49142. intersect(csg: CSG): CSG;
  49143. /**
  49144. * Intersects this CSG with another CSG in place
  49145. * @param csg The CSG to intersect against this CSG
  49146. */
  49147. intersectInPlace(csg: CSG): void;
  49148. /**
  49149. * Return a new CSG solid with solid and empty space switched. This solid is
  49150. * not modified.
  49151. * @returns A new CSG solid with solid and empty space switched
  49152. */
  49153. inverse(): CSG;
  49154. /**
  49155. * Inverses the CSG in place
  49156. */
  49157. inverseInPlace(): void;
  49158. /**
  49159. * This is used to keep meshes transformations so they can be restored
  49160. * when we build back a Babylon Mesh
  49161. * NB : All CSG operations are performed in world coordinates
  49162. * @param csg The CSG to copy the transform attributes from
  49163. * @returns This CSG
  49164. */
  49165. copyTransformAttributes(csg: CSG): CSG;
  49166. /**
  49167. * Build Raw mesh from CSG
  49168. * Coordinates here are in world space
  49169. * @param name The name of the mesh geometry
  49170. * @param scene The Scene
  49171. * @param keepSubMeshes Specifies if the submeshes should be kept
  49172. * @returns A new Mesh
  49173. */
  49174. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49175. /**
  49176. * Build Mesh from CSG taking material and transforms into account
  49177. * @param name The name of the Mesh
  49178. * @param material The material of the Mesh
  49179. * @param scene The Scene
  49180. * @param keepSubMeshes Specifies if submeshes should be kept
  49181. * @returns The new Mesh
  49182. */
  49183. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49184. }
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Class used to create a trail following a mesh
  49189. */
  49190. export class TrailMesh extends Mesh {
  49191. private _generator;
  49192. private _autoStart;
  49193. private _running;
  49194. private _diameter;
  49195. private _length;
  49196. private _sectionPolygonPointsCount;
  49197. private _sectionVectors;
  49198. private _sectionNormalVectors;
  49199. private _beforeRenderObserver;
  49200. /**
  49201. * @constructor
  49202. * @param name The value used by scene.getMeshByName() to do a lookup.
  49203. * @param generator The mesh to generate a trail.
  49204. * @param scene The scene to add this mesh to.
  49205. * @param diameter Diameter of trailing mesh. Default is 1.
  49206. * @param length Length of trailing mesh. Default is 60.
  49207. * @param autoStart Automatically start trailing mesh. Default true.
  49208. */
  49209. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49210. /**
  49211. * "TrailMesh"
  49212. * @returns "TrailMesh"
  49213. */
  49214. getClassName(): string;
  49215. private _createMesh;
  49216. /**
  49217. * Start trailing mesh.
  49218. */
  49219. start(): void;
  49220. /**
  49221. * Stop trailing mesh.
  49222. */
  49223. stop(): void;
  49224. /**
  49225. * Update trailing mesh geometry.
  49226. */
  49227. update(): void;
  49228. /**
  49229. * Returns a new TrailMesh object.
  49230. * @param name is a string, the name given to the new mesh
  49231. * @param newGenerator use new generator object for cloned trail mesh
  49232. * @returns a new mesh
  49233. */
  49234. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49235. /**
  49236. * Serializes this trail mesh
  49237. * @param serializationObject object to write serialization to
  49238. */
  49239. serialize(serializationObject: any): void;
  49240. /**
  49241. * Parses a serialized trail mesh
  49242. * @param parsedMesh the serialized mesh
  49243. * @param scene the scene to create the trail mesh in
  49244. * @returns the created trail mesh
  49245. */
  49246. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49247. }
  49248. }
  49249. declare module BABYLON {
  49250. /**
  49251. * Class containing static functions to help procedurally build meshes
  49252. */
  49253. export class TorusKnotBuilder {
  49254. /**
  49255. * Creates a torus knot mesh
  49256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49261. * * 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
  49262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @returns the torus knot mesh
  49267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49268. */
  49269. static CreateTorusKnot(name: string, options: {
  49270. radius?: number;
  49271. tube?: number;
  49272. radialSegments?: number;
  49273. tubularSegments?: number;
  49274. p?: number;
  49275. q?: number;
  49276. updatable?: boolean;
  49277. sideOrientation?: number;
  49278. frontUVs?: Vector4;
  49279. backUVs?: Vector4;
  49280. }, scene: any): Mesh;
  49281. }
  49282. }
  49283. declare module BABYLON {
  49284. /**
  49285. * Polygon
  49286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49287. */
  49288. export class Polygon {
  49289. /**
  49290. * Creates a rectangle
  49291. * @param xmin bottom X coord
  49292. * @param ymin bottom Y coord
  49293. * @param xmax top X coord
  49294. * @param ymax top Y coord
  49295. * @returns points that make the resulting rectation
  49296. */
  49297. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49298. /**
  49299. * Creates a circle
  49300. * @param radius radius of circle
  49301. * @param cx scale in x
  49302. * @param cy scale in y
  49303. * @param numberOfSides number of sides that make up the circle
  49304. * @returns points that make the resulting circle
  49305. */
  49306. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49307. /**
  49308. * Creates a polygon from input string
  49309. * @param input Input polygon data
  49310. * @returns the parsed points
  49311. */
  49312. static Parse(input: string): Vector2[];
  49313. /**
  49314. * Starts building a polygon from x and y coordinates
  49315. * @param x x coordinate
  49316. * @param y y coordinate
  49317. * @returns the started path2
  49318. */
  49319. static StartingAt(x: number, y: number): Path2;
  49320. }
  49321. /**
  49322. * Builds a polygon
  49323. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49324. */
  49325. export class PolygonMeshBuilder {
  49326. private _points;
  49327. private _outlinepoints;
  49328. private _holes;
  49329. private _name;
  49330. private _scene;
  49331. private _epoints;
  49332. private _eholes;
  49333. private _addToepoint;
  49334. /**
  49335. * Babylon reference to the earcut plugin.
  49336. */
  49337. bjsEarcut: any;
  49338. /**
  49339. * Creates a PolygonMeshBuilder
  49340. * @param name name of the builder
  49341. * @param contours Path of the polygon
  49342. * @param scene scene to add to when creating the mesh
  49343. * @param earcutInjection can be used to inject your own earcut reference
  49344. */
  49345. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49346. /**
  49347. * Adds a whole within the polygon
  49348. * @param hole Array of points defining the hole
  49349. * @returns this
  49350. */
  49351. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49352. /**
  49353. * Creates the polygon
  49354. * @param updatable If the mesh should be updatable
  49355. * @param depth The depth of the mesh created
  49356. * @returns the created mesh
  49357. */
  49358. build(updatable?: boolean, depth?: number): Mesh;
  49359. /**
  49360. * Creates the polygon
  49361. * @param depth The depth of the mesh created
  49362. * @returns the created VertexData
  49363. */
  49364. buildVertexData(depth?: number): VertexData;
  49365. /**
  49366. * Adds a side to the polygon
  49367. * @param positions points that make the polygon
  49368. * @param normals normals of the polygon
  49369. * @param uvs uvs of the polygon
  49370. * @param indices indices of the polygon
  49371. * @param bounds bounds of the polygon
  49372. * @param points points of the polygon
  49373. * @param depth depth of the polygon
  49374. * @param flip flip of the polygon
  49375. */
  49376. private addSide;
  49377. }
  49378. }
  49379. declare module BABYLON {
  49380. /**
  49381. * Class containing static functions to help procedurally build meshes
  49382. */
  49383. export class PolygonBuilder {
  49384. /**
  49385. * Creates a polygon mesh
  49386. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49387. * * 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
  49388. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49390. * * 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)
  49391. * * Remember you can only change the shape positions, not their number when updating a polygon
  49392. * @param name defines the name of the mesh
  49393. * @param options defines the options used to create the mesh
  49394. * @param scene defines the hosting scene
  49395. * @param earcutInjection can be used to inject your own earcut reference
  49396. * @returns the polygon mesh
  49397. */
  49398. static CreatePolygon(name: string, options: {
  49399. shape: Vector3[];
  49400. holes?: Vector3[][];
  49401. depth?: number;
  49402. faceUV?: Vector4[];
  49403. faceColors?: Color4[];
  49404. updatable?: boolean;
  49405. sideOrientation?: number;
  49406. frontUVs?: Vector4;
  49407. backUVs?: Vector4;
  49408. }, scene: Scene, earcutInjection?: any): Mesh;
  49409. /**
  49410. * Creates an extruded polygon mesh, with depth in the Y direction.
  49411. * * 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)
  49412. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49413. * @param name defines the name of the mesh
  49414. * @param options defines the options used to create the mesh
  49415. * @param scene defines the hosting scene
  49416. * @param earcutInjection can be used to inject your own earcut reference
  49417. * @returns the polygon mesh
  49418. */
  49419. static ExtrudePolygon(name: string, options: {
  49420. shape: Vector3[];
  49421. holes?: Vector3[][];
  49422. depth?: number;
  49423. faceUV?: Vector4[];
  49424. faceColors?: Color4[];
  49425. updatable?: boolean;
  49426. sideOrientation?: number;
  49427. frontUVs?: Vector4;
  49428. backUVs?: Vector4;
  49429. }, scene: Scene, earcutInjection?: any): Mesh;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * Class containing static functions to help procedurally build meshes
  49435. */
  49436. export class LatheBuilder {
  49437. /**
  49438. * Creates lathe mesh.
  49439. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49440. * * 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
  49441. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49442. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49443. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49444. * * 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
  49445. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49446. * * 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
  49447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49448. * * 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
  49449. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49451. * @param name defines the name of the mesh
  49452. * @param options defines the options used to create the mesh
  49453. * @param scene defines the hosting scene
  49454. * @returns the lathe mesh
  49455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49456. */
  49457. static CreateLathe(name: string, options: {
  49458. shape: Vector3[];
  49459. radius?: number;
  49460. tessellation?: number;
  49461. clip?: number;
  49462. arc?: number;
  49463. closed?: boolean;
  49464. updatable?: boolean;
  49465. sideOrientation?: number;
  49466. frontUVs?: Vector4;
  49467. backUVs?: Vector4;
  49468. cap?: number;
  49469. invertUV?: boolean;
  49470. }, scene: Scene): Mesh;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /**
  49475. * Class containing static functions to help procedurally build meshes
  49476. */
  49477. export class TubeBuilder {
  49478. /**
  49479. * Creates a tube mesh.
  49480. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49481. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49482. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49483. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49484. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49485. * * 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)
  49486. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49487. * * 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
  49488. * * 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
  49489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49490. * * 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
  49491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49493. * @param name defines the name of the mesh
  49494. * @param options defines the options used to create the mesh
  49495. * @param scene defines the hosting scene
  49496. * @returns the tube mesh
  49497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49498. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49499. */
  49500. static CreateTube(name: string, options: {
  49501. path: Vector3[];
  49502. radius?: number;
  49503. tessellation?: number;
  49504. radiusFunction?: {
  49505. (i: number, distance: number): number;
  49506. };
  49507. cap?: number;
  49508. arc?: number;
  49509. updatable?: boolean;
  49510. sideOrientation?: number;
  49511. frontUVs?: Vector4;
  49512. backUVs?: Vector4;
  49513. instance?: Mesh;
  49514. invertUV?: boolean;
  49515. }, scene: Scene): Mesh;
  49516. }
  49517. }
  49518. declare module BABYLON {
  49519. /**
  49520. * Class containing static functions to help procedurally build meshes
  49521. */
  49522. export class IcoSphereBuilder {
  49523. /**
  49524. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49525. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49526. * * 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`)
  49527. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49528. * * 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
  49529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49530. * * 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
  49531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49532. * @param name defines the name of the mesh
  49533. * @param options defines the options used to create the mesh
  49534. * @param scene defines the hosting scene
  49535. * @returns the icosahedron mesh
  49536. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49537. */
  49538. static CreateIcoSphere(name: string, options: {
  49539. radius?: number;
  49540. radiusX?: number;
  49541. radiusY?: number;
  49542. radiusZ?: number;
  49543. flat?: boolean;
  49544. subdivisions?: number;
  49545. sideOrientation?: number;
  49546. frontUVs?: Vector4;
  49547. backUVs?: Vector4;
  49548. updatable?: boolean;
  49549. }, scene: Scene): Mesh;
  49550. }
  49551. }
  49552. declare module BABYLON {
  49553. /**
  49554. * Class containing static functions to help procedurally build meshes
  49555. */
  49556. export class DecalBuilder {
  49557. /**
  49558. * Creates a decal mesh.
  49559. * 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
  49560. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49561. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49562. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49563. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49564. * @param name defines the name of the mesh
  49565. * @param sourceMesh defines the mesh where the decal must be applied
  49566. * @param options defines the options used to create the mesh
  49567. * @param scene defines the hosting scene
  49568. * @returns the decal mesh
  49569. * @see https://doc.babylonjs.com/how_to/decals
  49570. */
  49571. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49572. position?: Vector3;
  49573. normal?: Vector3;
  49574. size?: Vector3;
  49575. angle?: number;
  49576. }): Mesh;
  49577. }
  49578. }
  49579. declare module BABYLON {
  49580. /**
  49581. * Class containing static functions to help procedurally build meshes
  49582. */
  49583. export class MeshBuilder {
  49584. /**
  49585. * Creates a box mesh
  49586. * * The parameter `size` sets the size (float) of each box side (default 1)
  49587. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49588. * * 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)
  49589. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49591. * * 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
  49592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49593. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49594. * @param name defines the name of the mesh
  49595. * @param options defines the options used to create the mesh
  49596. * @param scene defines the hosting scene
  49597. * @returns the box mesh
  49598. */
  49599. static CreateBox(name: string, options: {
  49600. size?: number;
  49601. width?: number;
  49602. height?: number;
  49603. depth?: number;
  49604. faceUV?: Vector4[];
  49605. faceColors?: Color4[];
  49606. sideOrientation?: number;
  49607. frontUVs?: Vector4;
  49608. backUVs?: Vector4;
  49609. updatable?: boolean;
  49610. }, scene?: Nullable<Scene>): Mesh;
  49611. /**
  49612. * Creates a sphere mesh
  49613. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49614. * * 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`)
  49615. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49616. * * 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
  49617. * * 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)
  49618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49619. * * 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
  49620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49621. * @param name defines the name of the mesh
  49622. * @param options defines the options used to create the mesh
  49623. * @param scene defines the hosting scene
  49624. * @returns the sphere mesh
  49625. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49626. */
  49627. static CreateSphere(name: string, options: {
  49628. segments?: number;
  49629. diameter?: number;
  49630. diameterX?: number;
  49631. diameterY?: number;
  49632. diameterZ?: number;
  49633. arc?: number;
  49634. slice?: number;
  49635. sideOrientation?: number;
  49636. frontUVs?: Vector4;
  49637. backUVs?: Vector4;
  49638. updatable?: boolean;
  49639. }, scene: any): Mesh;
  49640. /**
  49641. * Creates a plane polygonal mesh. By default, this is a disc
  49642. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49643. * * 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
  49644. * * 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
  49645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49646. * * 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
  49647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49648. * @param name defines the name of the mesh
  49649. * @param options defines the options used to create the mesh
  49650. * @param scene defines the hosting scene
  49651. * @returns the plane polygonal mesh
  49652. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49653. */
  49654. static CreateDisc(name: string, options: {
  49655. radius?: number;
  49656. tessellation?: number;
  49657. arc?: number;
  49658. updatable?: boolean;
  49659. sideOrientation?: number;
  49660. frontUVs?: Vector4;
  49661. backUVs?: Vector4;
  49662. }, scene?: Nullable<Scene>): Mesh;
  49663. /**
  49664. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49665. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49666. * * 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`)
  49667. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49668. * * 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
  49669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49670. * * 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
  49671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49672. * @param name defines the name of the mesh
  49673. * @param options defines the options used to create the mesh
  49674. * @param scene defines the hosting scene
  49675. * @returns the icosahedron mesh
  49676. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49677. */
  49678. static CreateIcoSphere(name: string, options: {
  49679. radius?: number;
  49680. radiusX?: number;
  49681. radiusY?: number;
  49682. radiusZ?: number;
  49683. flat?: boolean;
  49684. subdivisions?: number;
  49685. sideOrientation?: number;
  49686. frontUVs?: Vector4;
  49687. backUVs?: Vector4;
  49688. updatable?: boolean;
  49689. }, scene: Scene): Mesh;
  49690. /**
  49691. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49692. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49693. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49694. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49695. * * 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
  49696. * * 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
  49697. * * 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
  49698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49699. * * 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
  49700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49701. * * 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
  49702. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49703. * * 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
  49704. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49706. * @param name defines the name of the mesh
  49707. * @param options defines the options used to create the mesh
  49708. * @param scene defines the hosting scene
  49709. * @returns the ribbon mesh
  49710. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49711. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49712. */
  49713. static CreateRibbon(name: string, options: {
  49714. pathArray: Vector3[][];
  49715. closeArray?: boolean;
  49716. closePath?: boolean;
  49717. offset?: number;
  49718. updatable?: boolean;
  49719. sideOrientation?: number;
  49720. frontUVs?: Vector4;
  49721. backUVs?: Vector4;
  49722. instance?: Mesh;
  49723. invertUV?: boolean;
  49724. uvs?: Vector2[];
  49725. colors?: Color4[];
  49726. }, scene?: Nullable<Scene>): Mesh;
  49727. /**
  49728. * Creates a cylinder or a cone mesh
  49729. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49730. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49731. * * 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.
  49732. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49733. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49734. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49735. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49736. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49737. * * 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).
  49738. * * 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
  49739. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49740. * * 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
  49741. * * 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.
  49742. * * If `enclose` is false, a ring surface is one element.
  49743. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49744. * * 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
  49745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49746. * * 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
  49747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49748. * @param name defines the name of the mesh
  49749. * @param options defines the options used to create the mesh
  49750. * @param scene defines the hosting scene
  49751. * @returns the cylinder mesh
  49752. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49753. */
  49754. static CreateCylinder(name: string, options: {
  49755. height?: number;
  49756. diameterTop?: number;
  49757. diameterBottom?: number;
  49758. diameter?: number;
  49759. tessellation?: number;
  49760. subdivisions?: number;
  49761. arc?: number;
  49762. faceColors?: Color4[];
  49763. faceUV?: Vector4[];
  49764. updatable?: boolean;
  49765. hasRings?: boolean;
  49766. enclose?: boolean;
  49767. sideOrientation?: number;
  49768. frontUVs?: Vector4;
  49769. backUVs?: Vector4;
  49770. }, scene: any): Mesh;
  49771. /**
  49772. * Creates a torus mesh
  49773. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49774. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49775. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49777. * * 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
  49778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49779. * @param name defines the name of the mesh
  49780. * @param options defines the options used to create the mesh
  49781. * @param scene defines the hosting scene
  49782. * @returns the torus mesh
  49783. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49784. */
  49785. static CreateTorus(name: string, options: {
  49786. diameter?: number;
  49787. thickness?: number;
  49788. tessellation?: number;
  49789. updatable?: boolean;
  49790. sideOrientation?: number;
  49791. frontUVs?: Vector4;
  49792. backUVs?: Vector4;
  49793. }, scene: any): Mesh;
  49794. /**
  49795. * Creates a torus knot mesh
  49796. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49797. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49798. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49799. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49801. * * 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
  49802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49803. * @param name defines the name of the mesh
  49804. * @param options defines the options used to create the mesh
  49805. * @param scene defines the hosting scene
  49806. * @returns the torus knot mesh
  49807. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49808. */
  49809. static CreateTorusKnot(name: string, options: {
  49810. radius?: number;
  49811. tube?: number;
  49812. radialSegments?: number;
  49813. tubularSegments?: number;
  49814. p?: number;
  49815. q?: number;
  49816. updatable?: boolean;
  49817. sideOrientation?: number;
  49818. frontUVs?: Vector4;
  49819. backUVs?: Vector4;
  49820. }, scene: any): Mesh;
  49821. /**
  49822. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49823. * * 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
  49824. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49825. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49826. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49827. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49828. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49829. * * 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
  49830. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49833. * @param name defines the name of the new line system
  49834. * @param options defines the options used to create the line system
  49835. * @param scene defines the hosting scene
  49836. * @returns a new line system mesh
  49837. */
  49838. static CreateLineSystem(name: string, options: {
  49839. lines: Vector3[][];
  49840. updatable?: boolean;
  49841. instance?: Nullable<LinesMesh>;
  49842. colors?: Nullable<Color4[][]>;
  49843. useVertexAlpha?: boolean;
  49844. }, scene: Nullable<Scene>): LinesMesh;
  49845. /**
  49846. * Creates a line mesh
  49847. * 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
  49848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49849. * * The parameter `points` is an array successive Vector3
  49850. * * 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
  49851. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49852. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49853. * * When updating an instance, remember that only point positions can change, not the number of points
  49854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49856. * @param name defines the name of the new line system
  49857. * @param options defines the options used to create the line system
  49858. * @param scene defines the hosting scene
  49859. * @returns a new line mesh
  49860. */
  49861. static CreateLines(name: string, options: {
  49862. points: Vector3[];
  49863. updatable?: boolean;
  49864. instance?: Nullable<LinesMesh>;
  49865. colors?: Color4[];
  49866. useVertexAlpha?: boolean;
  49867. }, scene?: Nullable<Scene>): LinesMesh;
  49868. /**
  49869. * Creates a dashed line mesh
  49870. * * 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
  49871. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49872. * * The parameter `points` is an array successive Vector3
  49873. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49874. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49875. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49876. * * 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
  49877. * * When updating an instance, remember that only point positions can change, not the number of points
  49878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49879. * @param name defines the name of the mesh
  49880. * @param options defines the options used to create the mesh
  49881. * @param scene defines the hosting scene
  49882. * @returns the dashed line mesh
  49883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49884. */
  49885. static CreateDashedLines(name: string, options: {
  49886. points: Vector3[];
  49887. dashSize?: number;
  49888. gapSize?: number;
  49889. dashNb?: number;
  49890. updatable?: boolean;
  49891. instance?: LinesMesh;
  49892. }, scene?: Nullable<Scene>): LinesMesh;
  49893. /**
  49894. * 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.
  49895. * * 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.
  49896. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49897. * * 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.
  49898. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49899. * * 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
  49900. * * 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
  49901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49903. * * 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
  49904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49906. * @param name defines the name of the mesh
  49907. * @param options defines the options used to create the mesh
  49908. * @param scene defines the hosting scene
  49909. * @returns the extruded shape mesh
  49910. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49912. */
  49913. static ExtrudeShape(name: string, options: {
  49914. shape: Vector3[];
  49915. path: Vector3[];
  49916. scale?: number;
  49917. rotation?: number;
  49918. cap?: number;
  49919. updatable?: boolean;
  49920. sideOrientation?: number;
  49921. frontUVs?: Vector4;
  49922. backUVs?: Vector4;
  49923. instance?: Mesh;
  49924. invertUV?: boolean;
  49925. }, scene?: Nullable<Scene>): Mesh;
  49926. /**
  49927. * Creates an custom extruded shape mesh.
  49928. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49929. * * 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.
  49930. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49931. * * 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
  49932. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49933. * * 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
  49934. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49935. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49936. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49937. * * 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
  49938. * * 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
  49939. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49941. * * 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
  49942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49944. * @param name defines the name of the mesh
  49945. * @param options defines the options used to create the mesh
  49946. * @param scene defines the hosting scene
  49947. * @returns the custom extruded shape mesh
  49948. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49951. */
  49952. static ExtrudeShapeCustom(name: string, options: {
  49953. shape: Vector3[];
  49954. path: Vector3[];
  49955. scaleFunction?: any;
  49956. rotationFunction?: any;
  49957. ribbonCloseArray?: boolean;
  49958. ribbonClosePath?: boolean;
  49959. cap?: number;
  49960. updatable?: boolean;
  49961. sideOrientation?: number;
  49962. frontUVs?: Vector4;
  49963. backUVs?: Vector4;
  49964. instance?: Mesh;
  49965. invertUV?: boolean;
  49966. }, scene: Scene): Mesh;
  49967. /**
  49968. * Creates lathe mesh.
  49969. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49970. * * 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
  49971. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49972. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49973. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49974. * * 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
  49975. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49976. * * 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
  49977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49978. * * 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
  49979. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49981. * @param name defines the name of the mesh
  49982. * @param options defines the options used to create the mesh
  49983. * @param scene defines the hosting scene
  49984. * @returns the lathe mesh
  49985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49986. */
  49987. static CreateLathe(name: string, options: {
  49988. shape: Vector3[];
  49989. radius?: number;
  49990. tessellation?: number;
  49991. clip?: number;
  49992. arc?: number;
  49993. closed?: boolean;
  49994. updatable?: boolean;
  49995. sideOrientation?: number;
  49996. frontUVs?: Vector4;
  49997. backUVs?: Vector4;
  49998. cap?: number;
  49999. invertUV?: boolean;
  50000. }, scene: Scene): Mesh;
  50001. /**
  50002. * Creates a plane mesh
  50003. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50004. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50005. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50007. * * 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
  50008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50009. * @param name defines the name of the mesh
  50010. * @param options defines the options used to create the mesh
  50011. * @param scene defines the hosting scene
  50012. * @returns the plane mesh
  50013. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50014. */
  50015. static CreatePlane(name: string, options: {
  50016. size?: number;
  50017. width?: number;
  50018. height?: number;
  50019. sideOrientation?: number;
  50020. frontUVs?: Vector4;
  50021. backUVs?: Vector4;
  50022. updatable?: boolean;
  50023. sourcePlane?: Plane;
  50024. }, scene: Scene): Mesh;
  50025. /**
  50026. * Creates a ground mesh
  50027. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50028. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50030. * @param name defines the name of the mesh
  50031. * @param options defines the options used to create the mesh
  50032. * @param scene defines the hosting scene
  50033. * @returns the ground mesh
  50034. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50035. */
  50036. static CreateGround(name: string, options: {
  50037. width?: number;
  50038. height?: number;
  50039. subdivisions?: number;
  50040. subdivisionsX?: number;
  50041. subdivisionsY?: number;
  50042. updatable?: boolean;
  50043. }, scene: any): Mesh;
  50044. /**
  50045. * Creates a tiled ground mesh
  50046. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50047. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50048. * * 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
  50049. * * 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
  50050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50051. * @param name defines the name of the mesh
  50052. * @param options defines the options used to create the mesh
  50053. * @param scene defines the hosting scene
  50054. * @returns the tiled ground mesh
  50055. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50056. */
  50057. static CreateTiledGround(name: string, options: {
  50058. xmin: number;
  50059. zmin: number;
  50060. xmax: number;
  50061. zmax: number;
  50062. subdivisions?: {
  50063. w: number;
  50064. h: number;
  50065. };
  50066. precision?: {
  50067. w: number;
  50068. h: number;
  50069. };
  50070. updatable?: boolean;
  50071. }, scene: Scene): Mesh;
  50072. /**
  50073. * Creates a ground mesh from a height map
  50074. * * The parameter `url` sets the URL of the height map image resource.
  50075. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50076. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50077. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50078. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50079. * * 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.
  50080. * * 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).
  50081. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50083. * @param name defines the name of the mesh
  50084. * @param url defines the url to the height map
  50085. * @param options defines the options used to create the mesh
  50086. * @param scene defines the hosting scene
  50087. * @returns the ground mesh
  50088. * @see https://doc.babylonjs.com/babylon101/height_map
  50089. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50090. */
  50091. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50092. width?: number;
  50093. height?: number;
  50094. subdivisions?: number;
  50095. minHeight?: number;
  50096. maxHeight?: number;
  50097. colorFilter?: Color3;
  50098. alphaFilter?: number;
  50099. updatable?: boolean;
  50100. onReady?: (mesh: GroundMesh) => void;
  50101. }, scene: Scene): GroundMesh;
  50102. /**
  50103. * Creates a polygon mesh
  50104. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50105. * * 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
  50106. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50108. * * 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)
  50109. * * Remember you can only change the shape positions, not their number when updating a polygon
  50110. * @param name defines the name of the mesh
  50111. * @param options defines the options used to create the mesh
  50112. * @param scene defines the hosting scene
  50113. * @param earcutInjection can be used to inject your own earcut reference
  50114. * @returns the polygon mesh
  50115. */
  50116. static CreatePolygon(name: string, options: {
  50117. shape: Vector3[];
  50118. holes?: Vector3[][];
  50119. depth?: number;
  50120. faceUV?: Vector4[];
  50121. faceColors?: Color4[];
  50122. updatable?: boolean;
  50123. sideOrientation?: number;
  50124. frontUVs?: Vector4;
  50125. backUVs?: Vector4;
  50126. }, scene: Scene, earcutInjection?: any): Mesh;
  50127. /**
  50128. * Creates an extruded polygon mesh, with depth in the Y direction.
  50129. * * 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)
  50130. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50131. * @param name defines the name of the mesh
  50132. * @param options defines the options used to create the mesh
  50133. * @param scene defines the hosting scene
  50134. * @param earcutInjection can be used to inject your own earcut reference
  50135. * @returns the polygon mesh
  50136. */
  50137. static ExtrudePolygon(name: string, options: {
  50138. shape: Vector3[];
  50139. holes?: Vector3[][];
  50140. depth?: number;
  50141. faceUV?: Vector4[];
  50142. faceColors?: Color4[];
  50143. updatable?: boolean;
  50144. sideOrientation?: number;
  50145. frontUVs?: Vector4;
  50146. backUVs?: Vector4;
  50147. }, scene: Scene, earcutInjection?: any): Mesh;
  50148. /**
  50149. * Creates a tube mesh.
  50150. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50151. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50152. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50153. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50154. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50155. * * 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)
  50156. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50157. * * 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
  50158. * * 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
  50159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50161. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50163. * @param name defines the name of the mesh
  50164. * @param options defines the options used to create the mesh
  50165. * @param scene defines the hosting scene
  50166. * @returns the tube mesh
  50167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50168. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50169. */
  50170. static CreateTube(name: string, options: {
  50171. path: Vector3[];
  50172. radius?: number;
  50173. tessellation?: number;
  50174. radiusFunction?: {
  50175. (i: number, distance: number): number;
  50176. };
  50177. cap?: number;
  50178. arc?: number;
  50179. updatable?: boolean;
  50180. sideOrientation?: number;
  50181. frontUVs?: Vector4;
  50182. backUVs?: Vector4;
  50183. instance?: Mesh;
  50184. invertUV?: boolean;
  50185. }, scene: Scene): Mesh;
  50186. /**
  50187. * Creates a polyhedron mesh
  50188. * * 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
  50189. * * The parameter `size` (positive float, default 1) sets the polygon size
  50190. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50191. * * 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`
  50192. * * 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
  50193. * * 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)`)
  50194. * * 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
  50195. * * 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
  50196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50197. * * 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
  50198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50199. * @param name defines the name of the mesh
  50200. * @param options defines the options used to create the mesh
  50201. * @param scene defines the hosting scene
  50202. * @returns the polyhedron mesh
  50203. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50204. */
  50205. static CreatePolyhedron(name: string, options: {
  50206. type?: number;
  50207. size?: number;
  50208. sizeX?: number;
  50209. sizeY?: number;
  50210. sizeZ?: number;
  50211. custom?: any;
  50212. faceUV?: Vector4[];
  50213. faceColors?: Color4[];
  50214. flat?: boolean;
  50215. updatable?: boolean;
  50216. sideOrientation?: number;
  50217. frontUVs?: Vector4;
  50218. backUVs?: Vector4;
  50219. }, scene: Scene): Mesh;
  50220. /**
  50221. * Creates a decal mesh.
  50222. * 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
  50223. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50224. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50225. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50226. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50227. * @param name defines the name of the mesh
  50228. * @param sourceMesh defines the mesh where the decal must be applied
  50229. * @param options defines the options used to create the mesh
  50230. * @param scene defines the hosting scene
  50231. * @returns the decal mesh
  50232. * @see https://doc.babylonjs.com/how_to/decals
  50233. */
  50234. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50235. position?: Vector3;
  50236. normal?: Vector3;
  50237. size?: Vector3;
  50238. angle?: number;
  50239. }): Mesh;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * A simplifier interface for future simplification implementations
  50245. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50246. */
  50247. export interface ISimplifier {
  50248. /**
  50249. * Simplification of a given mesh according to the given settings.
  50250. * Since this requires computation, it is assumed that the function runs async.
  50251. * @param settings The settings of the simplification, including quality and distance
  50252. * @param successCallback A callback that will be called after the mesh was simplified.
  50253. * @param errorCallback in case of an error, this callback will be called. optional.
  50254. */
  50255. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50256. }
  50257. /**
  50258. * Expected simplification settings.
  50259. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50261. */
  50262. export interface ISimplificationSettings {
  50263. /**
  50264. * Gets or sets the expected quality
  50265. */
  50266. quality: number;
  50267. /**
  50268. * Gets or sets the distance when this optimized version should be used
  50269. */
  50270. distance: number;
  50271. /**
  50272. * Gets an already optimized mesh
  50273. */
  50274. optimizeMesh?: boolean;
  50275. }
  50276. /**
  50277. * Class used to specify simplification options
  50278. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50279. */
  50280. export class SimplificationSettings implements ISimplificationSettings {
  50281. /** expected quality */
  50282. quality: number;
  50283. /** distance when this optimized version should be used */
  50284. distance: number;
  50285. /** already optimized mesh */
  50286. optimizeMesh?: boolean | undefined;
  50287. /**
  50288. * Creates a SimplificationSettings
  50289. * @param quality expected quality
  50290. * @param distance distance when this optimized version should be used
  50291. * @param optimizeMesh already optimized mesh
  50292. */
  50293. constructor(
  50294. /** expected quality */
  50295. quality: number,
  50296. /** distance when this optimized version should be used */
  50297. distance: number,
  50298. /** already optimized mesh */
  50299. optimizeMesh?: boolean | undefined);
  50300. }
  50301. /**
  50302. * Interface used to define a simplification task
  50303. */
  50304. export interface ISimplificationTask {
  50305. /**
  50306. * Array of settings
  50307. */
  50308. settings: Array<ISimplificationSettings>;
  50309. /**
  50310. * Simplification type
  50311. */
  50312. simplificationType: SimplificationType;
  50313. /**
  50314. * Mesh to simplify
  50315. */
  50316. mesh: Mesh;
  50317. /**
  50318. * Callback called on success
  50319. */
  50320. successCallback?: () => void;
  50321. /**
  50322. * Defines if parallel processing can be used
  50323. */
  50324. parallelProcessing: boolean;
  50325. }
  50326. /**
  50327. * Queue used to order the simplification tasks
  50328. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50329. */
  50330. export class SimplificationQueue {
  50331. private _simplificationArray;
  50332. /**
  50333. * Gets a boolean indicating that the process is still running
  50334. */
  50335. running: boolean;
  50336. /**
  50337. * Creates a new queue
  50338. */
  50339. constructor();
  50340. /**
  50341. * Adds a new simplification task
  50342. * @param task defines a task to add
  50343. */
  50344. addTask(task: ISimplificationTask): void;
  50345. /**
  50346. * Execute next task
  50347. */
  50348. executeNext(): void;
  50349. /**
  50350. * Execute a simplification task
  50351. * @param task defines the task to run
  50352. */
  50353. runSimplification(task: ISimplificationTask): void;
  50354. private getSimplifier;
  50355. }
  50356. /**
  50357. * The implemented types of simplification
  50358. * At the moment only Quadratic Error Decimation is implemented
  50359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50360. */
  50361. export enum SimplificationType {
  50362. /** Quadratic error decimation */
  50363. QUADRATIC = 0
  50364. }
  50365. }
  50366. declare module BABYLON {
  50367. interface Scene {
  50368. /** @hidden (Backing field) */
  50369. _simplificationQueue: SimplificationQueue;
  50370. /**
  50371. * Gets or sets the simplification queue attached to the scene
  50372. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50373. */
  50374. simplificationQueue: SimplificationQueue;
  50375. }
  50376. interface Mesh {
  50377. /**
  50378. * Simplify the mesh according to the given array of settings.
  50379. * Function will return immediately and will simplify async
  50380. * @param settings a collection of simplification settings
  50381. * @param parallelProcessing should all levels calculate parallel or one after the other
  50382. * @param simplificationType the type of simplification to run
  50383. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50384. * @returns the current mesh
  50385. */
  50386. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50387. }
  50388. /**
  50389. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50390. * created in a scene
  50391. */
  50392. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50393. /**
  50394. * The component name helpfull to identify the component in the list of scene components.
  50395. */
  50396. readonly name: string;
  50397. /**
  50398. * The scene the component belongs to.
  50399. */
  50400. scene: Scene;
  50401. /**
  50402. * Creates a new instance of the component for the given scene
  50403. * @param scene Defines the scene to register the component in
  50404. */
  50405. constructor(scene: Scene);
  50406. /**
  50407. * Registers the component in a given scene
  50408. */
  50409. register(): void;
  50410. /**
  50411. * Rebuilds the elements related to this component in case of
  50412. * context lost for instance.
  50413. */
  50414. rebuild(): void;
  50415. /**
  50416. * Disposes the component and the associated ressources
  50417. */
  50418. dispose(): void;
  50419. private _beforeCameraUpdate;
  50420. }
  50421. }
  50422. declare module BABYLON {
  50423. /**
  50424. * Class used to enable access to IndexedDB
  50425. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50426. */
  50427. export class Database implements IOfflineProvider {
  50428. private _callbackManifestChecked;
  50429. private _currentSceneUrl;
  50430. private _db;
  50431. private _enableSceneOffline;
  50432. private _enableTexturesOffline;
  50433. private _manifestVersionFound;
  50434. private _mustUpdateRessources;
  50435. private _hasReachedQuota;
  50436. private _isSupported;
  50437. private _idbFactory;
  50438. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50439. private static IsUASupportingBlobStorage;
  50440. /**
  50441. * Gets a boolean indicating if Database storate is enabled (off by default)
  50442. */
  50443. static IDBStorageEnabled: boolean;
  50444. /**
  50445. * Gets a boolean indicating if scene must be saved in the database
  50446. */
  50447. readonly enableSceneOffline: boolean;
  50448. /**
  50449. * Gets a boolean indicating if textures must be saved in the database
  50450. */
  50451. readonly enableTexturesOffline: boolean;
  50452. /**
  50453. * Creates a new Database
  50454. * @param urlToScene defines the url to load the scene
  50455. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50456. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50457. */
  50458. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50459. private static _ParseURL;
  50460. private static _ReturnFullUrlLocation;
  50461. private _checkManifestFile;
  50462. /**
  50463. * Open the database and make it available
  50464. * @param successCallback defines the callback to call on success
  50465. * @param errorCallback defines the callback to call on error
  50466. */
  50467. open(successCallback: () => void, errorCallback: () => void): void;
  50468. /**
  50469. * Loads an image from the database
  50470. * @param url defines the url to load from
  50471. * @param image defines the target DOM image
  50472. */
  50473. loadImage(url: string, image: HTMLImageElement): void;
  50474. private _loadImageFromDBAsync;
  50475. private _saveImageIntoDBAsync;
  50476. private _checkVersionFromDB;
  50477. private _loadVersionFromDBAsync;
  50478. private _saveVersionIntoDBAsync;
  50479. /**
  50480. * Loads a file from database
  50481. * @param url defines the URL to load from
  50482. * @param sceneLoaded defines a callback to call on success
  50483. * @param progressCallBack defines a callback to call when progress changed
  50484. * @param errorCallback defines a callback to call on error
  50485. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50486. */
  50487. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50488. private _loadFileAsync;
  50489. private _saveFileAsync;
  50490. /**
  50491. * Validates if xhr data is correct
  50492. * @param xhr defines the request to validate
  50493. * @param dataType defines the expected data type
  50494. * @returns true if data is correct
  50495. */
  50496. private static _ValidateXHRData;
  50497. }
  50498. }
  50499. declare module BABYLON {
  50500. /** @hidden */
  50501. export var gpuUpdateParticlesPixelShader: {
  50502. name: string;
  50503. shader: string;
  50504. };
  50505. }
  50506. declare module BABYLON {
  50507. /** @hidden */
  50508. export var gpuUpdateParticlesVertexShader: {
  50509. name: string;
  50510. shader: string;
  50511. };
  50512. }
  50513. declare module BABYLON {
  50514. /** @hidden */
  50515. export var clipPlaneFragmentDeclaration2: {
  50516. name: string;
  50517. shader: string;
  50518. };
  50519. }
  50520. declare module BABYLON {
  50521. /** @hidden */
  50522. export var gpuRenderParticlesPixelShader: {
  50523. name: string;
  50524. shader: string;
  50525. };
  50526. }
  50527. declare module BABYLON {
  50528. /** @hidden */
  50529. export var clipPlaneVertexDeclaration2: {
  50530. name: string;
  50531. shader: string;
  50532. };
  50533. }
  50534. declare module BABYLON {
  50535. /** @hidden */
  50536. export var gpuRenderParticlesVertexShader: {
  50537. name: string;
  50538. shader: string;
  50539. };
  50540. }
  50541. declare module BABYLON {
  50542. /**
  50543. * This represents a GPU particle system in Babylon
  50544. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50545. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50546. */
  50547. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50548. /**
  50549. * The layer mask we are rendering the particles through.
  50550. */
  50551. layerMask: number;
  50552. private _capacity;
  50553. private _activeCount;
  50554. private _currentActiveCount;
  50555. private _accumulatedCount;
  50556. private _renderEffect;
  50557. private _updateEffect;
  50558. private _buffer0;
  50559. private _buffer1;
  50560. private _spriteBuffer;
  50561. private _updateVAO;
  50562. private _renderVAO;
  50563. private _targetIndex;
  50564. private _sourceBuffer;
  50565. private _targetBuffer;
  50566. private _engine;
  50567. private _currentRenderId;
  50568. private _started;
  50569. private _stopped;
  50570. private _timeDelta;
  50571. private _randomTexture;
  50572. private _randomTexture2;
  50573. private _attributesStrideSize;
  50574. private _updateEffectOptions;
  50575. private _randomTextureSize;
  50576. private _actualFrame;
  50577. private readonly _rawTextureWidth;
  50578. /**
  50579. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50580. */
  50581. static readonly IsSupported: boolean;
  50582. /**
  50583. * An event triggered when the system is disposed.
  50584. */
  50585. onDisposeObservable: Observable<GPUParticleSystem>;
  50586. /**
  50587. * Gets the maximum number of particles active at the same time.
  50588. * @returns The max number of active particles.
  50589. */
  50590. getCapacity(): number;
  50591. /**
  50592. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50593. * to override the particles.
  50594. */
  50595. forceDepthWrite: boolean;
  50596. /**
  50597. * Gets or set the number of active particles
  50598. */
  50599. activeParticleCount: number;
  50600. private _preWarmDone;
  50601. /**
  50602. * Is this system ready to be used/rendered
  50603. * @return true if the system is ready
  50604. */
  50605. isReady(): boolean;
  50606. /**
  50607. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50608. * @returns True if it has been started, otherwise false.
  50609. */
  50610. isStarted(): boolean;
  50611. /**
  50612. * Starts the particle system and begins to emit
  50613. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50614. */
  50615. start(delay?: number): void;
  50616. /**
  50617. * Stops the particle system.
  50618. */
  50619. stop(): void;
  50620. /**
  50621. * Remove all active particles
  50622. */
  50623. reset(): void;
  50624. /**
  50625. * Returns the string "GPUParticleSystem"
  50626. * @returns a string containing the class name
  50627. */
  50628. getClassName(): string;
  50629. private _colorGradientsTexture;
  50630. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50631. /**
  50632. * Adds a new color gradient
  50633. * @param gradient defines the gradient to use (between 0 and 1)
  50634. * @param color1 defines the color to affect to the specified gradient
  50635. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50636. * @returns the current particle system
  50637. */
  50638. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50639. /**
  50640. * Remove a specific color gradient
  50641. * @param gradient defines the gradient to remove
  50642. * @returns the current particle system
  50643. */
  50644. removeColorGradient(gradient: number): GPUParticleSystem;
  50645. private _angularSpeedGradientsTexture;
  50646. private _sizeGradientsTexture;
  50647. private _velocityGradientsTexture;
  50648. private _limitVelocityGradientsTexture;
  50649. private _dragGradientsTexture;
  50650. private _addFactorGradient;
  50651. /**
  50652. * Adds a new size gradient
  50653. * @param gradient defines the gradient to use (between 0 and 1)
  50654. * @param factor defines the size factor to affect to the specified gradient
  50655. * @returns the current particle system
  50656. */
  50657. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50658. /**
  50659. * Remove a specific size gradient
  50660. * @param gradient defines the gradient to remove
  50661. * @returns the current particle system
  50662. */
  50663. removeSizeGradient(gradient: number): GPUParticleSystem;
  50664. /**
  50665. * Adds a new angular speed gradient
  50666. * @param gradient defines the gradient to use (between 0 and 1)
  50667. * @param factor defines the angular speed to affect to the specified gradient
  50668. * @returns the current particle system
  50669. */
  50670. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50671. /**
  50672. * Remove a specific angular speed gradient
  50673. * @param gradient defines the gradient to remove
  50674. * @returns the current particle system
  50675. */
  50676. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50677. /**
  50678. * Adds a new velocity gradient
  50679. * @param gradient defines the gradient to use (between 0 and 1)
  50680. * @param factor defines the velocity to affect to the specified gradient
  50681. * @returns the current particle system
  50682. */
  50683. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50684. /**
  50685. * Remove a specific velocity gradient
  50686. * @param gradient defines the gradient to remove
  50687. * @returns the current particle system
  50688. */
  50689. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50690. /**
  50691. * Adds a new limit velocity gradient
  50692. * @param gradient defines the gradient to use (between 0 and 1)
  50693. * @param factor defines the limit velocity value to affect to the specified gradient
  50694. * @returns the current particle system
  50695. */
  50696. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50697. /**
  50698. * Remove a specific limit velocity gradient
  50699. * @param gradient defines the gradient to remove
  50700. * @returns the current particle system
  50701. */
  50702. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50703. /**
  50704. * Adds a new drag gradient
  50705. * @param gradient defines the gradient to use (between 0 and 1)
  50706. * @param factor defines the drag value to affect to the specified gradient
  50707. * @returns the current particle system
  50708. */
  50709. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50710. /**
  50711. * Remove a specific drag gradient
  50712. * @param gradient defines the gradient to remove
  50713. * @returns the current particle system
  50714. */
  50715. removeDragGradient(gradient: number): GPUParticleSystem;
  50716. /**
  50717. * Not supported by GPUParticleSystem
  50718. * @param gradient defines the gradient to use (between 0 and 1)
  50719. * @param factor defines the emit rate value to affect to the specified gradient
  50720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50721. * @returns the current particle system
  50722. */
  50723. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50724. /**
  50725. * Not supported by GPUParticleSystem
  50726. * @param gradient defines the gradient to remove
  50727. * @returns the current particle system
  50728. */
  50729. removeEmitRateGradient(gradient: number): IParticleSystem;
  50730. /**
  50731. * Not supported by GPUParticleSystem
  50732. * @param gradient defines the gradient to use (between 0 and 1)
  50733. * @param factor defines the start size value to affect to the specified gradient
  50734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50735. * @returns the current particle system
  50736. */
  50737. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50738. /**
  50739. * Not supported by GPUParticleSystem
  50740. * @param gradient defines the gradient to remove
  50741. * @returns the current particle system
  50742. */
  50743. removeStartSizeGradient(gradient: number): IParticleSystem;
  50744. /**
  50745. * Not supported by GPUParticleSystem
  50746. * @param gradient defines the gradient to use (between 0 and 1)
  50747. * @param min defines the color remap minimal range
  50748. * @param max defines the color remap maximal range
  50749. * @returns the current particle system
  50750. */
  50751. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50752. /**
  50753. * Not supported by GPUParticleSystem
  50754. * @param gradient defines the gradient to remove
  50755. * @returns the current particle system
  50756. */
  50757. removeColorRemapGradient(): IParticleSystem;
  50758. /**
  50759. * Not supported by GPUParticleSystem
  50760. * @param gradient defines the gradient to use (between 0 and 1)
  50761. * @param min defines the alpha remap minimal range
  50762. * @param max defines the alpha remap maximal range
  50763. * @returns the current particle system
  50764. */
  50765. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50766. /**
  50767. * Not supported by GPUParticleSystem
  50768. * @param gradient defines the gradient to remove
  50769. * @returns the current particle system
  50770. */
  50771. removeAlphaRemapGradient(): IParticleSystem;
  50772. /**
  50773. * Not supported by GPUParticleSystem
  50774. * @param gradient defines the gradient to use (between 0 and 1)
  50775. * @param color defines the color to affect to the specified gradient
  50776. * @returns the current particle system
  50777. */
  50778. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50779. /**
  50780. * Not supported by GPUParticleSystem
  50781. * @param gradient defines the gradient to remove
  50782. * @returns the current particle system
  50783. */
  50784. removeRampGradient(): IParticleSystem;
  50785. /**
  50786. * Not supported by GPUParticleSystem
  50787. * @returns the list of ramp gradients
  50788. */
  50789. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50790. /**
  50791. * Not supported by GPUParticleSystem
  50792. * Gets or sets a boolean indicating that ramp gradients must be used
  50793. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50794. */
  50795. useRampGradients: boolean;
  50796. /**
  50797. * Not supported by GPUParticleSystem
  50798. * @param gradient defines the gradient to use (between 0 and 1)
  50799. * @param factor defines the life time factor to affect to the specified gradient
  50800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50801. * @returns the current particle system
  50802. */
  50803. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50804. /**
  50805. * Not supported by GPUParticleSystem
  50806. * @param gradient defines the gradient to remove
  50807. * @returns the current particle system
  50808. */
  50809. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50810. /**
  50811. * Instantiates a GPU particle system.
  50812. * 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.
  50813. * @param name The name of the particle system
  50814. * @param options The options used to create the system
  50815. * @param scene The scene the particle system belongs to
  50816. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50817. */
  50818. constructor(name: string, options: Partial<{
  50819. capacity: number;
  50820. randomTextureSize: number;
  50821. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50822. protected _reset(): void;
  50823. private _createUpdateVAO;
  50824. private _createRenderVAO;
  50825. private _initialize;
  50826. /** @hidden */
  50827. _recreateUpdateEffect(): void;
  50828. /** @hidden */
  50829. _recreateRenderEffect(): void;
  50830. /**
  50831. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50832. * @param preWarm defines if we are in the pre-warmimg phase
  50833. */
  50834. animate(preWarm?: boolean): void;
  50835. private _createFactorGradientTexture;
  50836. private _createSizeGradientTexture;
  50837. private _createAngularSpeedGradientTexture;
  50838. private _createVelocityGradientTexture;
  50839. private _createLimitVelocityGradientTexture;
  50840. private _createDragGradientTexture;
  50841. private _createColorGradientTexture;
  50842. /**
  50843. * Renders the particle system in its current state
  50844. * @param preWarm defines if the system should only update the particles but not render them
  50845. * @returns the current number of particles
  50846. */
  50847. render(preWarm?: boolean): number;
  50848. /**
  50849. * Rebuilds the particle system
  50850. */
  50851. rebuild(): void;
  50852. private _releaseBuffers;
  50853. private _releaseVAOs;
  50854. /**
  50855. * Disposes the particle system and free the associated resources
  50856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50857. */
  50858. dispose(disposeTexture?: boolean): void;
  50859. /**
  50860. * Clones the particle system.
  50861. * @param name The name of the cloned object
  50862. * @param newEmitter The new emitter to use
  50863. * @returns the cloned particle system
  50864. */
  50865. clone(name: string, newEmitter: any): GPUParticleSystem;
  50866. /**
  50867. * Serializes the particle system to a JSON object.
  50868. * @returns the JSON object
  50869. */
  50870. serialize(): any;
  50871. /**
  50872. * Parses a JSON object to create a GPU particle system.
  50873. * @param parsedParticleSystem The JSON object to parse
  50874. * @param scene The scene to create the particle system in
  50875. * @param rootUrl The root url to use to load external dependencies like texture
  50876. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50877. * @returns the parsed GPU particle system
  50878. */
  50879. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50880. }
  50881. }
  50882. declare module BABYLON {
  50883. /**
  50884. * Represents a set of particle systems working together to create a specific effect
  50885. */
  50886. export class ParticleSystemSet implements IDisposable {
  50887. private _emitterCreationOptions;
  50888. private _emitterNode;
  50889. /**
  50890. * Gets the particle system list
  50891. */
  50892. systems: IParticleSystem[];
  50893. /**
  50894. * Gets the emitter node used with this set
  50895. */
  50896. readonly emitterNode: Nullable<TransformNode>;
  50897. /**
  50898. * Creates a new emitter mesh as a sphere
  50899. * @param options defines the options used to create the sphere
  50900. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50901. * @param scene defines the hosting scene
  50902. */
  50903. setEmitterAsSphere(options: {
  50904. diameter: number;
  50905. segments: number;
  50906. color: Color3;
  50907. }, renderingGroupId: number, scene: Scene): void;
  50908. /**
  50909. * Starts all particle systems of the set
  50910. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50911. */
  50912. start(emitter?: AbstractMesh): void;
  50913. /**
  50914. * Release all associated resources
  50915. */
  50916. dispose(): void;
  50917. /**
  50918. * Serialize the set into a JSON compatible object
  50919. * @returns a JSON compatible representation of the set
  50920. */
  50921. serialize(): any;
  50922. /**
  50923. * Parse a new ParticleSystemSet from a serialized source
  50924. * @param data defines a JSON compatible representation of the set
  50925. * @param scene defines the hosting scene
  50926. * @param gpu defines if we want GPU particles or CPU particles
  50927. * @returns a new ParticleSystemSet
  50928. */
  50929. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50930. }
  50931. }
  50932. declare module BABYLON {
  50933. /**
  50934. * This class is made for on one-liner static method to help creating particle system set.
  50935. */
  50936. export class ParticleHelper {
  50937. /**
  50938. * Gets or sets base Assets URL
  50939. */
  50940. static BaseAssetsUrl: string;
  50941. /**
  50942. * Create a default particle system that you can tweak
  50943. * @param emitter defines the emitter to use
  50944. * @param capacity defines the system capacity (default is 500 particles)
  50945. * @param scene defines the hosting scene
  50946. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50947. * @returns the new Particle system
  50948. */
  50949. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50950. /**
  50951. * This is the main static method (one-liner) of this helper to create different particle systems
  50952. * @param type This string represents the type to the particle system to create
  50953. * @param scene The scene where the particle system should live
  50954. * @param gpu If the system will use gpu
  50955. * @returns the ParticleSystemSet created
  50956. */
  50957. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50958. /**
  50959. * Static function used to export a particle system to a ParticleSystemSet variable.
  50960. * Please note that the emitter shape is not exported
  50961. * @param systems defines the particle systems to export
  50962. * @returns the created particle system set
  50963. */
  50964. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50965. }
  50966. }
  50967. declare module BABYLON {
  50968. interface Engine {
  50969. /**
  50970. * Create an effect to use with particle systems.
  50971. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50972. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50973. * @param uniformsNames defines a list of attribute names
  50974. * @param samplers defines an array of string used to represent textures
  50975. * @param defines defines the string containing the defines to use to compile the shaders
  50976. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50977. * @param onCompiled defines a function to call when the effect creation is successful
  50978. * @param onError defines a function to call when the effect creation has failed
  50979. * @returns the new Effect
  50980. */
  50981. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50982. }
  50983. interface Mesh {
  50984. /**
  50985. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50986. * @returns an array of IParticleSystem
  50987. */
  50988. getEmittedParticleSystems(): IParticleSystem[];
  50989. /**
  50990. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50991. * @returns an array of IParticleSystem
  50992. */
  50993. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50994. }
  50995. /**
  50996. * @hidden
  50997. */
  50998. export var _IDoNeedToBeInTheBuild: number;
  50999. }
  51000. declare module BABYLON {
  51001. interface Scene {
  51002. /** @hidden (Backing field) */
  51003. _physicsEngine: Nullable<IPhysicsEngine>;
  51004. /**
  51005. * Gets the current physics engine
  51006. * @returns a IPhysicsEngine or null if none attached
  51007. */
  51008. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51009. /**
  51010. * Enables physics to the current scene
  51011. * @param gravity defines the scene's gravity for the physics engine
  51012. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51013. * @return a boolean indicating if the physics engine was initialized
  51014. */
  51015. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51016. /**
  51017. * Disables and disposes the physics engine associated with the scene
  51018. */
  51019. disablePhysicsEngine(): void;
  51020. /**
  51021. * Gets a boolean indicating if there is an active physics engine
  51022. * @returns a boolean indicating if there is an active physics engine
  51023. */
  51024. isPhysicsEnabled(): boolean;
  51025. /**
  51026. * Deletes a physics compound impostor
  51027. * @param compound defines the compound to delete
  51028. */
  51029. deleteCompoundImpostor(compound: any): void;
  51030. /**
  51031. * An event triggered when physic simulation is about to be run
  51032. */
  51033. onBeforePhysicsObservable: Observable<Scene>;
  51034. /**
  51035. * An event triggered when physic simulation has been done
  51036. */
  51037. onAfterPhysicsObservable: Observable<Scene>;
  51038. }
  51039. interface AbstractMesh {
  51040. /** @hidden */
  51041. _physicsImpostor: Nullable<PhysicsImpostor>;
  51042. /**
  51043. * Gets or sets impostor used for physic simulation
  51044. * @see http://doc.babylonjs.com/features/physics_engine
  51045. */
  51046. physicsImpostor: Nullable<PhysicsImpostor>;
  51047. /**
  51048. * Gets the current physics impostor
  51049. * @see http://doc.babylonjs.com/features/physics_engine
  51050. * @returns a physics impostor or null
  51051. */
  51052. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51053. /** Apply a physic impulse to the mesh
  51054. * @param force defines the force to apply
  51055. * @param contactPoint defines where to apply the force
  51056. * @returns the current mesh
  51057. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51058. */
  51059. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51060. /**
  51061. * Creates a physic joint between two meshes
  51062. * @param otherMesh defines the other mesh to use
  51063. * @param pivot1 defines the pivot to use on this mesh
  51064. * @param pivot2 defines the pivot to use on the other mesh
  51065. * @param options defines additional options (can be plugin dependent)
  51066. * @returns the current mesh
  51067. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51068. */
  51069. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51070. /** @hidden */
  51071. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51072. }
  51073. /**
  51074. * Defines the physics engine scene component responsible to manage a physics engine
  51075. */
  51076. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51077. /**
  51078. * The component name helpful to identify the component in the list of scene components.
  51079. */
  51080. readonly name: string;
  51081. /**
  51082. * The scene the component belongs to.
  51083. */
  51084. scene: Scene;
  51085. /**
  51086. * Creates a new instance of the component for the given scene
  51087. * @param scene Defines the scene to register the component in
  51088. */
  51089. constructor(scene: Scene);
  51090. /**
  51091. * Registers the component in a given scene
  51092. */
  51093. register(): void;
  51094. /**
  51095. * Rebuilds the elements related to this component in case of
  51096. * context lost for instance.
  51097. */
  51098. rebuild(): void;
  51099. /**
  51100. * Disposes the component and the associated ressources
  51101. */
  51102. dispose(): void;
  51103. }
  51104. }
  51105. declare module BABYLON {
  51106. /**
  51107. * A helper for physics simulations
  51108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51109. */
  51110. export class PhysicsHelper {
  51111. private _scene;
  51112. private _physicsEngine;
  51113. /**
  51114. * Initializes the Physics helper
  51115. * @param scene Babylon.js scene
  51116. */
  51117. constructor(scene: Scene);
  51118. /**
  51119. * Applies a radial explosion impulse
  51120. * @param origin the origin of the explosion
  51121. * @param radiusOrEventOptions the radius or the options of radial explosion
  51122. * @param strength the explosion strength
  51123. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51124. * @returns A physics radial explosion event, or null
  51125. */
  51126. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51127. /**
  51128. * Applies a radial explosion force
  51129. * @param origin the origin of the explosion
  51130. * @param radiusOrEventOptions the radius or the options of radial explosion
  51131. * @param strength the explosion strength
  51132. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51133. * @returns A physics radial explosion event, or null
  51134. */
  51135. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51136. /**
  51137. * Creates a gravitational field
  51138. * @param origin the origin of the explosion
  51139. * @param radiusOrEventOptions the radius or the options of radial explosion
  51140. * @param strength the explosion strength
  51141. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51142. * @returns A physics gravitational field event, or null
  51143. */
  51144. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51145. /**
  51146. * Creates a physics updraft event
  51147. * @param origin the origin of the updraft
  51148. * @param radiusOrEventOptions the radius or the options of the updraft
  51149. * @param strength the strength of the updraft
  51150. * @param height the height of the updraft
  51151. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51152. * @returns A physics updraft event, or null
  51153. */
  51154. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51155. /**
  51156. * Creates a physics vortex event
  51157. * @param origin the of the vortex
  51158. * @param radiusOrEventOptions the radius or the options of the vortex
  51159. * @param strength the strength of the vortex
  51160. * @param height the height of the vortex
  51161. * @returns a Physics vortex event, or null
  51162. * A physics vortex event or null
  51163. */
  51164. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51165. }
  51166. /**
  51167. * Represents a physics radial explosion event
  51168. */
  51169. class PhysicsRadialExplosionEvent {
  51170. private _scene;
  51171. private _options;
  51172. private _sphere;
  51173. private _dataFetched;
  51174. /**
  51175. * Initializes a radial explosioin event
  51176. * @param _scene BabylonJS scene
  51177. * @param _options The options for the vortex event
  51178. */
  51179. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51180. /**
  51181. * Returns the data related to the radial explosion event (sphere).
  51182. * @returns The radial explosion event data
  51183. */
  51184. getData(): PhysicsRadialExplosionEventData;
  51185. /**
  51186. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51187. * @param impostor A physics imposter
  51188. * @param origin the origin of the explosion
  51189. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51190. */
  51191. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51192. /**
  51193. * Triggers affecterd impostors callbacks
  51194. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51195. */
  51196. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51197. /**
  51198. * Disposes the sphere.
  51199. * @param force Specifies if the sphere should be disposed by force
  51200. */
  51201. dispose(force?: boolean): void;
  51202. /*** Helpers ***/
  51203. private _prepareSphere;
  51204. private _intersectsWithSphere;
  51205. }
  51206. /**
  51207. * Represents a gravitational field event
  51208. */
  51209. class PhysicsGravitationalFieldEvent {
  51210. private _physicsHelper;
  51211. private _scene;
  51212. private _origin;
  51213. private _options;
  51214. private _tickCallback;
  51215. private _sphere;
  51216. private _dataFetched;
  51217. /**
  51218. * Initializes the physics gravitational field event
  51219. * @param _physicsHelper A physics helper
  51220. * @param _scene BabylonJS scene
  51221. * @param _origin The origin position of the gravitational field event
  51222. * @param _options The options for the vortex event
  51223. */
  51224. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51225. /**
  51226. * Returns the data related to the gravitational field event (sphere).
  51227. * @returns A gravitational field event
  51228. */
  51229. getData(): PhysicsGravitationalFieldEventData;
  51230. /**
  51231. * Enables the gravitational field.
  51232. */
  51233. enable(): void;
  51234. /**
  51235. * Disables the gravitational field.
  51236. */
  51237. disable(): void;
  51238. /**
  51239. * Disposes the sphere.
  51240. * @param force The force to dispose from the gravitational field event
  51241. */
  51242. dispose(force?: boolean): void;
  51243. private _tick;
  51244. }
  51245. /**
  51246. * Represents a physics updraft event
  51247. */
  51248. class PhysicsUpdraftEvent {
  51249. private _scene;
  51250. private _origin;
  51251. private _options;
  51252. private _physicsEngine;
  51253. private _originTop;
  51254. private _originDirection;
  51255. private _tickCallback;
  51256. private _cylinder;
  51257. private _cylinderPosition;
  51258. private _dataFetched;
  51259. /**
  51260. * Initializes the physics updraft event
  51261. * @param _scene BabylonJS scene
  51262. * @param _origin The origin position of the updraft
  51263. * @param _options The options for the updraft event
  51264. */
  51265. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51266. /**
  51267. * Returns the data related to the updraft event (cylinder).
  51268. * @returns A physics updraft event
  51269. */
  51270. getData(): PhysicsUpdraftEventData;
  51271. /**
  51272. * Enables the updraft.
  51273. */
  51274. enable(): void;
  51275. /**
  51276. * Disables the updraft.
  51277. */
  51278. disable(): void;
  51279. /**
  51280. * Disposes the cylinder.
  51281. * @param force Specifies if the updraft should be disposed by force
  51282. */
  51283. dispose(force?: boolean): void;
  51284. private getImpostorHitData;
  51285. private _tick;
  51286. /*** Helpers ***/
  51287. private _prepareCylinder;
  51288. private _intersectsWithCylinder;
  51289. }
  51290. /**
  51291. * Represents a physics vortex event
  51292. */
  51293. class PhysicsVortexEvent {
  51294. private _scene;
  51295. private _origin;
  51296. private _options;
  51297. private _physicsEngine;
  51298. private _originTop;
  51299. private _tickCallback;
  51300. private _cylinder;
  51301. private _cylinderPosition;
  51302. private _dataFetched;
  51303. /**
  51304. * Initializes the physics vortex event
  51305. * @param _scene The BabylonJS scene
  51306. * @param _origin The origin position of the vortex
  51307. * @param _options The options for the vortex event
  51308. */
  51309. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51310. /**
  51311. * Returns the data related to the vortex event (cylinder).
  51312. * @returns The physics vortex event data
  51313. */
  51314. getData(): PhysicsVortexEventData;
  51315. /**
  51316. * Enables the vortex.
  51317. */
  51318. enable(): void;
  51319. /**
  51320. * Disables the cortex.
  51321. */
  51322. disable(): void;
  51323. /**
  51324. * Disposes the sphere.
  51325. * @param force
  51326. */
  51327. dispose(force?: boolean): void;
  51328. private getImpostorHitData;
  51329. private _tick;
  51330. /*** Helpers ***/
  51331. private _prepareCylinder;
  51332. private _intersectsWithCylinder;
  51333. }
  51334. /**
  51335. * Options fot the radial explosion event
  51336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51337. */
  51338. export class PhysicsRadialExplosionEventOptions {
  51339. /**
  51340. * The radius of the sphere for the radial explosion.
  51341. */
  51342. radius: number;
  51343. /**
  51344. * The strenth of the explosion.
  51345. */
  51346. strength: number;
  51347. /**
  51348. * The strenght of the force in correspondence to the distance of the affected object
  51349. */
  51350. falloff: PhysicsRadialImpulseFalloff;
  51351. /**
  51352. * Sphere options for the radial explosion.
  51353. */
  51354. sphere: {
  51355. segments: number;
  51356. diameter: number;
  51357. };
  51358. /**
  51359. * Sphere options for the radial explosion.
  51360. */
  51361. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51362. }
  51363. /**
  51364. * Options fot the updraft event
  51365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51366. */
  51367. export class PhysicsUpdraftEventOptions {
  51368. /**
  51369. * The radius of the cylinder for the vortex
  51370. */
  51371. radius: number;
  51372. /**
  51373. * The strenth of the updraft.
  51374. */
  51375. strength: number;
  51376. /**
  51377. * The height of the cylinder for the updraft.
  51378. */
  51379. height: number;
  51380. /**
  51381. * The mode for the the updraft.
  51382. */
  51383. updraftMode: PhysicsUpdraftMode;
  51384. }
  51385. /**
  51386. * Options fot the vortex event
  51387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51388. */
  51389. export class PhysicsVortexEventOptions {
  51390. /**
  51391. * The radius of the cylinder for the vortex
  51392. */
  51393. radius: number;
  51394. /**
  51395. * The strenth of the vortex.
  51396. */
  51397. strength: number;
  51398. /**
  51399. * The height of the cylinder for the vortex.
  51400. */
  51401. height: number;
  51402. /**
  51403. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51404. */
  51405. centripetalForceThreshold: number;
  51406. /**
  51407. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51408. */
  51409. centripetalForceMultiplier: number;
  51410. /**
  51411. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51412. */
  51413. centrifugalForceMultiplier: number;
  51414. /**
  51415. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51416. */
  51417. updraftForceMultiplier: number;
  51418. }
  51419. /**
  51420. * The strenght of the force in correspondence to the distance of the affected object
  51421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51422. */
  51423. export enum PhysicsRadialImpulseFalloff {
  51424. /** Defines that impulse is constant in strength across it's whole radius */
  51425. Constant = 0,
  51426. /** Defines that impulse gets weaker if it's further from the origin */
  51427. Linear = 1
  51428. }
  51429. /**
  51430. * The strength of the force in correspondence to the distance of the affected object
  51431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51432. */
  51433. export enum PhysicsUpdraftMode {
  51434. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51435. Center = 0,
  51436. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51437. Perpendicular = 1
  51438. }
  51439. /**
  51440. * Interface for a physics hit data
  51441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51442. */
  51443. export interface PhysicsHitData {
  51444. /**
  51445. * The force applied at the contact point
  51446. */
  51447. force: Vector3;
  51448. /**
  51449. * The contact point
  51450. */
  51451. contactPoint: Vector3;
  51452. /**
  51453. * The distance from the origin to the contact point
  51454. */
  51455. distanceFromOrigin: number;
  51456. }
  51457. /**
  51458. * Interface for radial explosion event data
  51459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51460. */
  51461. export interface PhysicsRadialExplosionEventData {
  51462. /**
  51463. * A sphere used for the radial explosion event
  51464. */
  51465. sphere: Mesh;
  51466. }
  51467. /**
  51468. * Interface for gravitational field event data
  51469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51470. */
  51471. export interface PhysicsGravitationalFieldEventData {
  51472. /**
  51473. * A sphere mesh used for the gravitational field event
  51474. */
  51475. sphere: Mesh;
  51476. }
  51477. /**
  51478. * Interface for updraft event data
  51479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51480. */
  51481. export interface PhysicsUpdraftEventData {
  51482. /**
  51483. * A cylinder used for the updraft event
  51484. */
  51485. cylinder: Mesh;
  51486. }
  51487. /**
  51488. * Interface for vortex event data
  51489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51490. */
  51491. export interface PhysicsVortexEventData {
  51492. /**
  51493. * A cylinder used for the vortex event
  51494. */
  51495. cylinder: Mesh;
  51496. }
  51497. /**
  51498. * Interface for an affected physics impostor
  51499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51500. */
  51501. export interface PhysicsAffectedImpostorWithData {
  51502. /**
  51503. * The impostor affected by the effect
  51504. */
  51505. impostor: PhysicsImpostor;
  51506. /**
  51507. * The data about the hit/horce from the explosion
  51508. */
  51509. hitData: PhysicsHitData;
  51510. }
  51511. }
  51512. declare module BABYLON {
  51513. /** @hidden */
  51514. export var blackAndWhitePixelShader: {
  51515. name: string;
  51516. shader: string;
  51517. };
  51518. }
  51519. declare module BABYLON {
  51520. /**
  51521. * Post process used to render in black and white
  51522. */
  51523. export class BlackAndWhitePostProcess extends PostProcess {
  51524. /**
  51525. * Linear about to convert he result to black and white (default: 1)
  51526. */
  51527. degree: number;
  51528. /**
  51529. * Creates a black and white post process
  51530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51531. * @param name The name of the effect.
  51532. * @param options The required width/height ratio to downsize to before computing the render pass.
  51533. * @param camera The camera to apply the render pass to.
  51534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51535. * @param engine The engine which the post process will be applied. (default: current engine)
  51536. * @param reusable If the post process can be reused on the same frame. (default: false)
  51537. */
  51538. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51539. }
  51540. }
  51541. declare module BABYLON {
  51542. /**
  51543. * This represents a set of one or more post processes in Babylon.
  51544. * A post process can be used to apply a shader to a texture after it is rendered.
  51545. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51546. */
  51547. export class PostProcessRenderEffect {
  51548. private _postProcesses;
  51549. private _getPostProcesses;
  51550. private _singleInstance;
  51551. private _cameras;
  51552. private _indicesForCamera;
  51553. /**
  51554. * Name of the effect
  51555. * @hidden
  51556. */
  51557. _name: string;
  51558. /**
  51559. * Instantiates a post process render effect.
  51560. * A post process can be used to apply a shader to a texture after it is rendered.
  51561. * @param engine The engine the effect is tied to
  51562. * @param name The name of the effect
  51563. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51564. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51565. */
  51566. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51567. /**
  51568. * Checks if all the post processes in the effect are supported.
  51569. */
  51570. readonly isSupported: boolean;
  51571. /**
  51572. * Updates the current state of the effect
  51573. * @hidden
  51574. */
  51575. _update(): void;
  51576. /**
  51577. * Attaches the effect on cameras
  51578. * @param cameras The camera to attach to.
  51579. * @hidden
  51580. */
  51581. _attachCameras(cameras: Camera): void;
  51582. /**
  51583. * Attaches the effect on cameras
  51584. * @param cameras The camera to attach to.
  51585. * @hidden
  51586. */
  51587. _attachCameras(cameras: Camera[]): void;
  51588. /**
  51589. * Detatches the effect on cameras
  51590. * @param cameras The camera to detatch from.
  51591. * @hidden
  51592. */
  51593. _detachCameras(cameras: Camera): void;
  51594. /**
  51595. * Detatches the effect on cameras
  51596. * @param cameras The camera to detatch from.
  51597. * @hidden
  51598. */
  51599. _detachCameras(cameras: Camera[]): void;
  51600. /**
  51601. * Enables the effect on given cameras
  51602. * @param cameras The camera to enable.
  51603. * @hidden
  51604. */
  51605. _enable(cameras: Camera): void;
  51606. /**
  51607. * Enables the effect on given cameras
  51608. * @param cameras The camera to enable.
  51609. * @hidden
  51610. */
  51611. _enable(cameras: Nullable<Camera[]>): void;
  51612. /**
  51613. * Disables the effect on the given cameras
  51614. * @param cameras The camera to disable.
  51615. * @hidden
  51616. */
  51617. _disable(cameras: Camera): void;
  51618. /**
  51619. * Disables the effect on the given cameras
  51620. * @param cameras The camera to disable.
  51621. * @hidden
  51622. */
  51623. _disable(cameras: Nullable<Camera[]>): void;
  51624. /**
  51625. * Gets a list of the post processes contained in the effect.
  51626. * @param camera The camera to get the post processes on.
  51627. * @returns The list of the post processes in the effect.
  51628. */
  51629. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51630. }
  51631. }
  51632. declare module BABYLON {
  51633. /** @hidden */
  51634. export var extractHighlightsPixelShader: {
  51635. name: string;
  51636. shader: string;
  51637. };
  51638. }
  51639. declare module BABYLON {
  51640. /**
  51641. * 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.
  51642. */
  51643. export class ExtractHighlightsPostProcess extends PostProcess {
  51644. /**
  51645. * The luminance threshold, pixels below this value will be set to black.
  51646. */
  51647. threshold: number;
  51648. /** @hidden */
  51649. _exposure: number;
  51650. /**
  51651. * Post process which has the input texture to be used when performing highlight extraction
  51652. * @hidden
  51653. */
  51654. _inputPostProcess: Nullable<PostProcess>;
  51655. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51656. }
  51657. }
  51658. declare module BABYLON {
  51659. /** @hidden */
  51660. export var bloomMergePixelShader: {
  51661. name: string;
  51662. shader: string;
  51663. };
  51664. }
  51665. declare module BABYLON {
  51666. /**
  51667. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51668. */
  51669. export class BloomMergePostProcess extends PostProcess {
  51670. /** Weight of the bloom to be added to the original input. */
  51671. weight: number;
  51672. /**
  51673. * Creates a new instance of @see BloomMergePostProcess
  51674. * @param name The name of the effect.
  51675. * @param originalFromInput Post process which's input will be used for the merge.
  51676. * @param blurred Blurred highlights post process which's output will be used.
  51677. * @param weight Weight of the bloom to be added to the original input.
  51678. * @param options The required width/height ratio to downsize to before computing the render pass.
  51679. * @param camera The camera to apply the render pass to.
  51680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51681. * @param engine The engine which the post process will be applied. (default: current engine)
  51682. * @param reusable If the post process can be reused on the same frame. (default: false)
  51683. * @param textureType Type of textures used when performing the post process. (default: 0)
  51684. * @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)
  51685. */
  51686. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51687. /** Weight of the bloom to be added to the original input. */
  51688. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51689. }
  51690. }
  51691. declare module BABYLON {
  51692. /**
  51693. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51694. */
  51695. export class BloomEffect extends PostProcessRenderEffect {
  51696. private bloomScale;
  51697. /**
  51698. * @hidden Internal
  51699. */
  51700. _effects: Array<PostProcess>;
  51701. /**
  51702. * @hidden Internal
  51703. */
  51704. _downscale: ExtractHighlightsPostProcess;
  51705. private _blurX;
  51706. private _blurY;
  51707. private _merge;
  51708. /**
  51709. * The luminance threshold to find bright areas of the image to bloom.
  51710. */
  51711. threshold: number;
  51712. /**
  51713. * The strength of the bloom.
  51714. */
  51715. weight: number;
  51716. /**
  51717. * Specifies the size of the bloom blur kernel, relative to the final output size
  51718. */
  51719. kernel: number;
  51720. /**
  51721. * Creates a new instance of @see BloomEffect
  51722. * @param scene The scene the effect belongs to.
  51723. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51724. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51725. * @param bloomWeight The the strength of bloom.
  51726. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51727. * @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)
  51728. */
  51729. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51730. /**
  51731. * Disposes each of the internal effects for a given camera.
  51732. * @param camera The camera to dispose the effect on.
  51733. */
  51734. disposeEffects(camera: Camera): void;
  51735. /**
  51736. * @hidden Internal
  51737. */
  51738. _updateEffects(): void;
  51739. /**
  51740. * Internal
  51741. * @returns if all the contained post processes are ready.
  51742. * @hidden
  51743. */
  51744. _isReady(): boolean;
  51745. }
  51746. }
  51747. declare module BABYLON {
  51748. /** @hidden */
  51749. export var chromaticAberrationPixelShader: {
  51750. name: string;
  51751. shader: string;
  51752. };
  51753. }
  51754. declare module BABYLON {
  51755. /**
  51756. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51757. */
  51758. export class ChromaticAberrationPostProcess extends PostProcess {
  51759. /**
  51760. * The amount of seperation of rgb channels (default: 30)
  51761. */
  51762. aberrationAmount: number;
  51763. /**
  51764. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51765. */
  51766. radialIntensity: number;
  51767. /**
  51768. * 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))
  51769. */
  51770. direction: Vector2;
  51771. /**
  51772. * 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))
  51773. */
  51774. centerPosition: Vector2;
  51775. /**
  51776. * Creates a new instance ChromaticAberrationPostProcess
  51777. * @param name The name of the effect.
  51778. * @param screenWidth The width of the screen to apply the effect on.
  51779. * @param screenHeight The height of the screen to apply the effect on.
  51780. * @param options The required width/height ratio to downsize to before computing the render pass.
  51781. * @param camera The camera to apply the render pass to.
  51782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51783. * @param engine The engine which the post process will be applied. (default: current engine)
  51784. * @param reusable If the post process can be reused on the same frame. (default: false)
  51785. * @param textureType Type of textures used when performing the post process. (default: 0)
  51786. * @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)
  51787. */
  51788. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51789. }
  51790. }
  51791. declare module BABYLON {
  51792. /** @hidden */
  51793. export var circleOfConfusionPixelShader: {
  51794. name: string;
  51795. shader: string;
  51796. };
  51797. }
  51798. declare module BABYLON {
  51799. /**
  51800. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51801. */
  51802. export class CircleOfConfusionPostProcess extends PostProcess {
  51803. /**
  51804. * 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.
  51805. */
  51806. lensSize: number;
  51807. /**
  51808. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51809. */
  51810. fStop: number;
  51811. /**
  51812. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51813. */
  51814. focusDistance: number;
  51815. /**
  51816. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51817. */
  51818. focalLength: number;
  51819. private _depthTexture;
  51820. /**
  51821. * Creates a new instance CircleOfConfusionPostProcess
  51822. * @param name The name of the effect.
  51823. * @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.
  51824. * @param options The required width/height ratio to downsize to before computing the render pass.
  51825. * @param camera The camera to apply the render pass to.
  51826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51827. * @param engine The engine which the post process will be applied. (default: current engine)
  51828. * @param reusable If the post process can be reused on the same frame. (default: false)
  51829. * @param textureType Type of textures used when performing the post process. (default: 0)
  51830. * @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)
  51831. */
  51832. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51833. /**
  51834. * 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.
  51835. */
  51836. depthTexture: RenderTargetTexture;
  51837. }
  51838. }
  51839. declare module BABYLON {
  51840. /** @hidden */
  51841. export var colorCorrectionPixelShader: {
  51842. name: string;
  51843. shader: string;
  51844. };
  51845. }
  51846. declare module BABYLON {
  51847. /**
  51848. *
  51849. * This post-process allows the modification of rendered colors by using
  51850. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51851. *
  51852. * The object needs to be provided an url to a texture containing the color
  51853. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51854. * Use an image editing software to tweak the LUT to match your needs.
  51855. *
  51856. * For an example of a color LUT, see here:
  51857. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51858. * For explanations on color grading, see here:
  51859. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51860. *
  51861. */
  51862. export class ColorCorrectionPostProcess extends PostProcess {
  51863. private _colorTableTexture;
  51864. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51865. }
  51866. }
  51867. declare module BABYLON {
  51868. /** @hidden */
  51869. export var convolutionPixelShader: {
  51870. name: string;
  51871. shader: string;
  51872. };
  51873. }
  51874. declare module BABYLON {
  51875. /**
  51876. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51877. * input texture to perform effects such as edge detection or sharpening
  51878. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51879. */
  51880. export class ConvolutionPostProcess extends PostProcess {
  51881. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51882. kernel: number[];
  51883. /**
  51884. * Creates a new instance ConvolutionPostProcess
  51885. * @param name The name of the effect.
  51886. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51887. * @param options The required width/height ratio to downsize to before computing the render pass.
  51888. * @param camera The camera to apply the render pass to.
  51889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51890. * @param engine The engine which the post process will be applied. (default: current engine)
  51891. * @param reusable If the post process can be reused on the same frame. (default: false)
  51892. * @param textureType Type of textures used when performing the post process. (default: 0)
  51893. */
  51894. constructor(name: string,
  51895. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51896. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51897. /**
  51898. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51899. */
  51900. static EdgeDetect0Kernel: number[];
  51901. /**
  51902. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51903. */
  51904. static EdgeDetect1Kernel: number[];
  51905. /**
  51906. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51907. */
  51908. static EdgeDetect2Kernel: number[];
  51909. /**
  51910. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51911. */
  51912. static SharpenKernel: number[];
  51913. /**
  51914. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51915. */
  51916. static EmbossKernel: number[];
  51917. /**
  51918. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51919. */
  51920. static GaussianKernel: number[];
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /**
  51925. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51926. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51927. * based on samples that have a large difference in distance than the center pixel.
  51928. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51929. */
  51930. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51931. direction: Vector2;
  51932. /**
  51933. * Creates a new instance CircleOfConfusionPostProcess
  51934. * @param name The name of the effect.
  51935. * @param scene The scene the effect belongs to.
  51936. * @param direction The direction the blur should be applied.
  51937. * @param kernel The size of the kernel used to blur.
  51938. * @param options The required width/height ratio to downsize to before computing the render pass.
  51939. * @param camera The camera to apply the render pass to.
  51940. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51941. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51943. * @param engine The engine which the post process will be applied. (default: current engine)
  51944. * @param reusable If the post process can be reused on the same frame. (default: false)
  51945. * @param textureType Type of textures used when performing the post process. (default: 0)
  51946. * @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)
  51947. */
  51948. 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);
  51949. }
  51950. }
  51951. declare module BABYLON {
  51952. /** @hidden */
  51953. export var depthOfFieldMergePixelShader: {
  51954. name: string;
  51955. shader: string;
  51956. };
  51957. }
  51958. declare module BABYLON {
  51959. /**
  51960. * Options to be set when merging outputs from the default pipeline.
  51961. */
  51962. export class DepthOfFieldMergePostProcessOptions {
  51963. /**
  51964. * The original image to merge on top of
  51965. */
  51966. originalFromInput: PostProcess;
  51967. /**
  51968. * Parameters to perform the merge of the depth of field effect
  51969. */
  51970. depthOfField?: {
  51971. circleOfConfusion: PostProcess;
  51972. blurSteps: Array<PostProcess>;
  51973. };
  51974. /**
  51975. * Parameters to perform the merge of bloom effect
  51976. */
  51977. bloom?: {
  51978. blurred: PostProcess;
  51979. weight: number;
  51980. };
  51981. }
  51982. /**
  51983. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51984. */
  51985. export class DepthOfFieldMergePostProcess extends PostProcess {
  51986. private blurSteps;
  51987. /**
  51988. * Creates a new instance of DepthOfFieldMergePostProcess
  51989. * @param name The name of the effect.
  51990. * @param originalFromInput Post process which's input will be used for the merge.
  51991. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51992. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51993. * @param options The required width/height ratio to downsize to before computing the render pass.
  51994. * @param camera The camera to apply the render pass to.
  51995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51996. * @param engine The engine which the post process will be applied. (default: current engine)
  51997. * @param reusable If the post process can be reused on the same frame. (default: false)
  51998. * @param textureType Type of textures used when performing the post process. (default: 0)
  51999. * @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)
  52000. */
  52001. 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);
  52002. /**
  52003. * Updates the effect with the current post process compile time values and recompiles the shader.
  52004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52007. * @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
  52008. * @param onCompiled Called when the shader has been compiled.
  52009. * @param onError Called if there is an error when compiling a shader.
  52010. */
  52011. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52012. }
  52013. }
  52014. declare module BABYLON {
  52015. /**
  52016. * Specifies the level of max blur that should be applied when using the depth of field effect
  52017. */
  52018. export enum DepthOfFieldEffectBlurLevel {
  52019. /**
  52020. * Subtle blur
  52021. */
  52022. Low = 0,
  52023. /**
  52024. * Medium blur
  52025. */
  52026. Medium = 1,
  52027. /**
  52028. * Large blur
  52029. */
  52030. High = 2
  52031. }
  52032. /**
  52033. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52034. */
  52035. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52036. private _circleOfConfusion;
  52037. /**
  52038. * @hidden Internal, blurs from high to low
  52039. */
  52040. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52041. private _depthOfFieldBlurY;
  52042. private _dofMerge;
  52043. /**
  52044. * @hidden Internal post processes in depth of field effect
  52045. */
  52046. _effects: Array<PostProcess>;
  52047. /**
  52048. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52049. */
  52050. focalLength: number;
  52051. /**
  52052. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52053. */
  52054. fStop: number;
  52055. /**
  52056. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52057. */
  52058. focusDistance: number;
  52059. /**
  52060. * 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.
  52061. */
  52062. lensSize: number;
  52063. /**
  52064. * Creates a new instance DepthOfFieldEffect
  52065. * @param scene The scene the effect belongs to.
  52066. * @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.
  52067. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52068. * @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)
  52069. */
  52070. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52071. /**
  52072. * 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.
  52073. */
  52074. depthTexture: RenderTargetTexture;
  52075. /**
  52076. * Disposes each of the internal effects for a given camera.
  52077. * @param camera The camera to dispose the effect on.
  52078. */
  52079. disposeEffects(camera: Camera): void;
  52080. /**
  52081. * @hidden Internal
  52082. */
  52083. _updateEffects(): void;
  52084. /**
  52085. * Internal
  52086. * @returns if all the contained post processes are ready.
  52087. * @hidden
  52088. */
  52089. _isReady(): boolean;
  52090. }
  52091. }
  52092. declare module BABYLON {
  52093. /** @hidden */
  52094. export var displayPassPixelShader: {
  52095. name: string;
  52096. shader: string;
  52097. };
  52098. }
  52099. declare module BABYLON {
  52100. /**
  52101. * DisplayPassPostProcess which produces an output the same as it's input
  52102. */
  52103. export class DisplayPassPostProcess extends PostProcess {
  52104. /**
  52105. * Creates the DisplayPassPostProcess
  52106. * @param name The name of the effect.
  52107. * @param options The required width/height ratio to downsize to before computing the render pass.
  52108. * @param camera The camera to apply the render pass to.
  52109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52110. * @param engine The engine which the post process will be applied. (default: current engine)
  52111. * @param reusable If the post process can be reused on the same frame. (default: false)
  52112. */
  52113. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52114. }
  52115. }
  52116. declare module BABYLON {
  52117. /** @hidden */
  52118. export var filterPixelShader: {
  52119. name: string;
  52120. shader: string;
  52121. };
  52122. }
  52123. declare module BABYLON {
  52124. /**
  52125. * Applies a kernel filter to the image
  52126. */
  52127. export class FilterPostProcess extends PostProcess {
  52128. /** The matrix to be applied to the image */
  52129. kernelMatrix: Matrix;
  52130. /**
  52131. *
  52132. * @param name The name of the effect.
  52133. * @param kernelMatrix The matrix to be applied to the image
  52134. * @param options The required width/height ratio to downsize to before computing the render pass.
  52135. * @param camera The camera to apply the render pass to.
  52136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52137. * @param engine The engine which the post process will be applied. (default: current engine)
  52138. * @param reusable If the post process can be reused on the same frame. (default: false)
  52139. */
  52140. constructor(name: string,
  52141. /** The matrix to be applied to the image */
  52142. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52143. }
  52144. }
  52145. declare module BABYLON {
  52146. /** @hidden */
  52147. export var fxaaPixelShader: {
  52148. name: string;
  52149. shader: string;
  52150. };
  52151. }
  52152. declare module BABYLON {
  52153. /** @hidden */
  52154. export var fxaaVertexShader: {
  52155. name: string;
  52156. shader: string;
  52157. };
  52158. }
  52159. declare module BABYLON {
  52160. /**
  52161. * Fxaa post process
  52162. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52163. */
  52164. export class FxaaPostProcess extends PostProcess {
  52165. /** @hidden */
  52166. texelWidth: number;
  52167. /** @hidden */
  52168. texelHeight: number;
  52169. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52170. private _getDefines;
  52171. }
  52172. }
  52173. declare module BABYLON {
  52174. /** @hidden */
  52175. export var grainPixelShader: {
  52176. name: string;
  52177. shader: string;
  52178. };
  52179. }
  52180. declare module BABYLON {
  52181. /**
  52182. * The GrainPostProcess adds noise to the image at mid luminance levels
  52183. */
  52184. export class GrainPostProcess extends PostProcess {
  52185. /**
  52186. * The intensity of the grain added (default: 30)
  52187. */
  52188. intensity: number;
  52189. /**
  52190. * If the grain should be randomized on every frame
  52191. */
  52192. animated: boolean;
  52193. /**
  52194. * Creates a new instance of @see GrainPostProcess
  52195. * @param name The name of the effect.
  52196. * @param options The required width/height ratio to downsize to before computing the render pass.
  52197. * @param camera The camera to apply the render pass to.
  52198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52199. * @param engine The engine which the post process will be applied. (default: current engine)
  52200. * @param reusable If the post process can be reused on the same frame. (default: false)
  52201. * @param textureType Type of textures used when performing the post process. (default: 0)
  52202. * @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)
  52203. */
  52204. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52205. }
  52206. }
  52207. declare module BABYLON {
  52208. /** @hidden */
  52209. export var highlightsPixelShader: {
  52210. name: string;
  52211. shader: string;
  52212. };
  52213. }
  52214. declare module BABYLON {
  52215. /**
  52216. * Extracts highlights from the image
  52217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52218. */
  52219. export class HighlightsPostProcess extends PostProcess {
  52220. /**
  52221. * Extracts highlights from the image
  52222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52223. * @param name The name of the effect.
  52224. * @param options The required width/height ratio to downsize to before computing the render pass.
  52225. * @param camera The camera to apply the render pass to.
  52226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52227. * @param engine The engine which the post process will be applied. (default: current engine)
  52228. * @param reusable If the post process can be reused on the same frame. (default: false)
  52229. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52230. */
  52231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52232. }
  52233. }
  52234. declare module BABYLON {
  52235. /** @hidden */
  52236. export var mrtFragmentDeclaration: {
  52237. name: string;
  52238. shader: string;
  52239. };
  52240. }
  52241. declare module BABYLON {
  52242. /** @hidden */
  52243. export var geometryPixelShader: {
  52244. name: string;
  52245. shader: string;
  52246. };
  52247. }
  52248. declare module BABYLON {
  52249. /** @hidden */
  52250. export var geometryVertexShader: {
  52251. name: string;
  52252. shader: string;
  52253. };
  52254. }
  52255. declare module BABYLON {
  52256. /**
  52257. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52258. */
  52259. export class GeometryBufferRenderer {
  52260. /**
  52261. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52262. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52263. */
  52264. static readonly POSITION_TEXTURE_TYPE: number;
  52265. /**
  52266. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52267. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52268. */
  52269. static readonly VELOCITY_TEXTURE_TYPE: number;
  52270. /**
  52271. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52272. * in order to compute objects velocities when enableVelocity is set to "true"
  52273. * @hidden
  52274. */
  52275. _previousTransformationMatrices: {
  52276. [index: number]: Matrix;
  52277. };
  52278. private _scene;
  52279. private _multiRenderTarget;
  52280. private _ratio;
  52281. private _enablePosition;
  52282. private _enableVelocity;
  52283. private _positionIndex;
  52284. private _velocityIndex;
  52285. protected _effect: Effect;
  52286. protected _cachedDefines: string;
  52287. /**
  52288. * Set the render list (meshes to be rendered) used in the G buffer.
  52289. */
  52290. renderList: Mesh[];
  52291. /**
  52292. * Gets wether or not G buffer are supported by the running hardware.
  52293. * This requires draw buffer supports
  52294. */
  52295. readonly isSupported: boolean;
  52296. /**
  52297. * Returns the index of the given texture type in the G-Buffer textures array
  52298. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52299. * @returns the index of the given texture type in the G-Buffer textures array
  52300. */
  52301. getTextureIndex(textureType: number): number;
  52302. /**
  52303. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52304. */
  52305. /**
  52306. * Sets whether or not objects positions are enabled for the G buffer.
  52307. */
  52308. enablePosition: boolean;
  52309. /**
  52310. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52311. */
  52312. /**
  52313. * Sets wether or not objects velocities are enabled for the G buffer.
  52314. */
  52315. enableVelocity: boolean;
  52316. /**
  52317. * Gets the scene associated with the buffer.
  52318. */
  52319. readonly scene: Scene;
  52320. /**
  52321. * Gets the ratio used by the buffer during its creation.
  52322. * How big is the buffer related to the main canvas.
  52323. */
  52324. readonly ratio: number;
  52325. /** @hidden */
  52326. static _SceneComponentInitialization: (scene: Scene) => void;
  52327. /**
  52328. * Creates a new G Buffer for the scene
  52329. * @param scene The scene the buffer belongs to
  52330. * @param ratio How big is the buffer related to the main canvas.
  52331. */
  52332. constructor(scene: Scene, ratio?: number);
  52333. /**
  52334. * Checks wether everything is ready to render a submesh to the G buffer.
  52335. * @param subMesh the submesh to check readiness for
  52336. * @param useInstances is the mesh drawn using instance or not
  52337. * @returns true if ready otherwise false
  52338. */
  52339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52340. /**
  52341. * Gets the current underlying G Buffer.
  52342. * @returns the buffer
  52343. */
  52344. getGBuffer(): MultiRenderTarget;
  52345. /**
  52346. * Gets the number of samples used to render the buffer (anti aliasing).
  52347. */
  52348. /**
  52349. * Sets the number of samples used to render the buffer (anti aliasing).
  52350. */
  52351. samples: number;
  52352. /**
  52353. * Disposes the renderer and frees up associated resources.
  52354. */
  52355. dispose(): void;
  52356. protected _createRenderTargets(): void;
  52357. }
  52358. }
  52359. declare module BABYLON {
  52360. interface Scene {
  52361. /** @hidden (Backing field) */
  52362. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52363. /**
  52364. * Gets or Sets the current geometry buffer associated to the scene.
  52365. */
  52366. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52367. /**
  52368. * Enables a GeometryBufferRender and associates it with the scene
  52369. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52370. * @returns the GeometryBufferRenderer
  52371. */
  52372. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52373. /**
  52374. * Disables the GeometryBufferRender associated with the scene
  52375. */
  52376. disableGeometryBufferRenderer(): void;
  52377. }
  52378. /**
  52379. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52380. * in several rendering techniques.
  52381. */
  52382. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52383. /**
  52384. * The component name helpful to identify the component in the list of scene components.
  52385. */
  52386. readonly name: string;
  52387. /**
  52388. * The scene the component belongs to.
  52389. */
  52390. scene: Scene;
  52391. /**
  52392. * Creates a new instance of the component for the given scene
  52393. * @param scene Defines the scene to register the component in
  52394. */
  52395. constructor(scene: Scene);
  52396. /**
  52397. * Registers the component in a given scene
  52398. */
  52399. register(): void;
  52400. /**
  52401. * Rebuilds the elements related to this component in case of
  52402. * context lost for instance.
  52403. */
  52404. rebuild(): void;
  52405. /**
  52406. * Disposes the component and the associated ressources
  52407. */
  52408. dispose(): void;
  52409. private _gatherRenderTargets;
  52410. }
  52411. }
  52412. declare module BABYLON {
  52413. /** @hidden */
  52414. export var motionBlurPixelShader: {
  52415. name: string;
  52416. shader: string;
  52417. };
  52418. }
  52419. declare module BABYLON {
  52420. /**
  52421. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52422. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52423. * As an example, all you have to do is to create the post-process:
  52424. * var mb = new BABYLON.MotionBlurPostProcess(
  52425. * 'mb', // The name of the effect.
  52426. * scene, // The scene containing the objects to blur according to their velocity.
  52427. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52428. * camera // The camera to apply the render pass to.
  52429. * );
  52430. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52431. */
  52432. export class MotionBlurPostProcess extends PostProcess {
  52433. /**
  52434. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52435. */
  52436. motionStrength: number;
  52437. /**
  52438. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52439. */
  52440. /**
  52441. * Sets the number of iterations to be used for motion blur quality
  52442. */
  52443. motionBlurSamples: number;
  52444. private _motionBlurSamples;
  52445. private _geometryBufferRenderer;
  52446. /**
  52447. * Creates a new instance MotionBlurPostProcess
  52448. * @param name The name of the effect.
  52449. * @param scene The scene containing the objects to blur according to their velocity.
  52450. * @param options The required width/height ratio to downsize to before computing the render pass.
  52451. * @param camera The camera to apply the render pass to.
  52452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52453. * @param engine The engine which the post process will be applied. (default: current engine)
  52454. * @param reusable If the post process can be reused on the same frame. (default: false)
  52455. * @param textureType Type of textures used when performing the post process. (default: 0)
  52456. * @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)
  52457. */
  52458. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52459. /**
  52460. * Disposes the post process.
  52461. * @param camera The camera to dispose the post process on.
  52462. */
  52463. dispose(camera?: Camera): void;
  52464. }
  52465. }
  52466. declare module BABYLON {
  52467. /** @hidden */
  52468. export var refractionPixelShader: {
  52469. name: string;
  52470. shader: string;
  52471. };
  52472. }
  52473. declare module BABYLON {
  52474. /**
  52475. * Post process which applies a refractin texture
  52476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52477. */
  52478. export class RefractionPostProcess extends PostProcess {
  52479. /** the base color of the refraction (used to taint the rendering) */
  52480. color: Color3;
  52481. /** simulated refraction depth */
  52482. depth: number;
  52483. /** the coefficient of the base color (0 to remove base color tainting) */
  52484. colorLevel: number;
  52485. private _refTexture;
  52486. private _ownRefractionTexture;
  52487. /**
  52488. * Gets or sets the refraction texture
  52489. * Please note that you are responsible for disposing the texture if you set it manually
  52490. */
  52491. refractionTexture: Texture;
  52492. /**
  52493. * Initializes the RefractionPostProcess
  52494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52495. * @param name The name of the effect.
  52496. * @param refractionTextureUrl Url of the refraction texture to use
  52497. * @param color the base color of the refraction (used to taint the rendering)
  52498. * @param depth simulated refraction depth
  52499. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52500. * @param camera The camera to apply the render pass to.
  52501. * @param options The required width/height ratio to downsize to before computing the render pass.
  52502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52503. * @param engine The engine which the post process will be applied. (default: current engine)
  52504. * @param reusable If the post process can be reused on the same frame. (default: false)
  52505. */
  52506. constructor(name: string, refractionTextureUrl: string,
  52507. /** the base color of the refraction (used to taint the rendering) */
  52508. color: Color3,
  52509. /** simulated refraction depth */
  52510. depth: number,
  52511. /** the coefficient of the base color (0 to remove base color tainting) */
  52512. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52513. /**
  52514. * Disposes of the post process
  52515. * @param camera Camera to dispose post process on
  52516. */
  52517. dispose(camera: Camera): void;
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /** @hidden */
  52522. export var sharpenPixelShader: {
  52523. name: string;
  52524. shader: string;
  52525. };
  52526. }
  52527. declare module BABYLON {
  52528. /**
  52529. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52530. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52531. */
  52532. export class SharpenPostProcess extends PostProcess {
  52533. /**
  52534. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52535. */
  52536. colorAmount: number;
  52537. /**
  52538. * How much sharpness should be applied (default: 0.3)
  52539. */
  52540. edgeAmount: number;
  52541. /**
  52542. * Creates a new instance ConvolutionPostProcess
  52543. * @param name The name of the effect.
  52544. * @param options The required width/height ratio to downsize to before computing the render pass.
  52545. * @param camera The camera to apply the render pass to.
  52546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52547. * @param engine The engine which the post process will be applied. (default: current engine)
  52548. * @param reusable If the post process can be reused on the same frame. (default: false)
  52549. * @param textureType Type of textures used when performing the post process. (default: 0)
  52550. * @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)
  52551. */
  52552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52553. }
  52554. }
  52555. declare module BABYLON {
  52556. /**
  52557. * PostProcessRenderPipeline
  52558. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52559. */
  52560. export class PostProcessRenderPipeline {
  52561. private engine;
  52562. private _renderEffects;
  52563. private _renderEffectsForIsolatedPass;
  52564. /**
  52565. * List of inspectable custom properties (used by the Inspector)
  52566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52567. */
  52568. inspectableCustomProperties: IInspectable[];
  52569. /**
  52570. * @hidden
  52571. */
  52572. protected _cameras: Camera[];
  52573. /** @hidden */
  52574. _name: string;
  52575. /**
  52576. * Gets pipeline name
  52577. */
  52578. readonly name: string;
  52579. /**
  52580. * Initializes a PostProcessRenderPipeline
  52581. * @param engine engine to add the pipeline to
  52582. * @param name name of the pipeline
  52583. */
  52584. constructor(engine: Engine, name: string);
  52585. /**
  52586. * Gets the class name
  52587. * @returns "PostProcessRenderPipeline"
  52588. */
  52589. getClassName(): string;
  52590. /**
  52591. * If all the render effects in the pipeline are supported
  52592. */
  52593. readonly isSupported: boolean;
  52594. /**
  52595. * Adds an effect to the pipeline
  52596. * @param renderEffect the effect to add
  52597. */
  52598. addEffect(renderEffect: PostProcessRenderEffect): void;
  52599. /** @hidden */
  52600. _rebuild(): void;
  52601. /** @hidden */
  52602. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52603. /** @hidden */
  52604. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52605. /** @hidden */
  52606. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52607. /** @hidden */
  52608. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52609. /** @hidden */
  52610. _attachCameras(cameras: Camera, unique: boolean): void;
  52611. /** @hidden */
  52612. _attachCameras(cameras: Camera[], unique: boolean): void;
  52613. /** @hidden */
  52614. _detachCameras(cameras: Camera): void;
  52615. /** @hidden */
  52616. _detachCameras(cameras: Nullable<Camera[]>): void;
  52617. /** @hidden */
  52618. _update(): void;
  52619. /** @hidden */
  52620. _reset(): void;
  52621. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52622. /**
  52623. * Disposes of the pipeline
  52624. */
  52625. dispose(): void;
  52626. }
  52627. }
  52628. declare module BABYLON {
  52629. /**
  52630. * PostProcessRenderPipelineManager class
  52631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52632. */
  52633. export class PostProcessRenderPipelineManager {
  52634. private _renderPipelines;
  52635. /**
  52636. * Initializes a PostProcessRenderPipelineManager
  52637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52638. */
  52639. constructor();
  52640. /**
  52641. * Gets the list of supported render pipelines
  52642. */
  52643. readonly supportedPipelines: PostProcessRenderPipeline[];
  52644. /**
  52645. * Adds a pipeline to the manager
  52646. * @param renderPipeline The pipeline to add
  52647. */
  52648. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52649. /**
  52650. * Attaches a camera to the pipeline
  52651. * @param renderPipelineName The name of the pipeline to attach to
  52652. * @param cameras the camera to attach
  52653. * @param unique if the camera can be attached multiple times to the pipeline
  52654. */
  52655. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52656. /**
  52657. * Detaches a camera from the pipeline
  52658. * @param renderPipelineName The name of the pipeline to detach from
  52659. * @param cameras the camera to detach
  52660. */
  52661. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52662. /**
  52663. * Enables an effect by name on a pipeline
  52664. * @param renderPipelineName the name of the pipeline to enable the effect in
  52665. * @param renderEffectName the name of the effect to enable
  52666. * @param cameras the cameras that the effect should be enabled on
  52667. */
  52668. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52669. /**
  52670. * Disables an effect by name on a pipeline
  52671. * @param renderPipelineName the name of the pipeline to disable the effect in
  52672. * @param renderEffectName the name of the effect to disable
  52673. * @param cameras the cameras that the effect should be disabled on
  52674. */
  52675. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52676. /**
  52677. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52678. */
  52679. update(): void;
  52680. /** @hidden */
  52681. _rebuild(): void;
  52682. /**
  52683. * Disposes of the manager and pipelines
  52684. */
  52685. dispose(): void;
  52686. }
  52687. }
  52688. declare module BABYLON {
  52689. interface Scene {
  52690. /** @hidden (Backing field) */
  52691. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52692. /**
  52693. * Gets the postprocess render pipeline manager
  52694. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52695. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52696. */
  52697. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52698. }
  52699. /**
  52700. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52701. */
  52702. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52703. /**
  52704. * The component name helpfull to identify the component in the list of scene components.
  52705. */
  52706. readonly name: string;
  52707. /**
  52708. * The scene the component belongs to.
  52709. */
  52710. scene: Scene;
  52711. /**
  52712. * Creates a new instance of the component for the given scene
  52713. * @param scene Defines the scene to register the component in
  52714. */
  52715. constructor(scene: Scene);
  52716. /**
  52717. * Registers the component in a given scene
  52718. */
  52719. register(): void;
  52720. /**
  52721. * Rebuilds the elements related to this component in case of
  52722. * context lost for instance.
  52723. */
  52724. rebuild(): void;
  52725. /**
  52726. * Disposes the component and the associated ressources
  52727. */
  52728. dispose(): void;
  52729. private _gatherRenderTargets;
  52730. }
  52731. }
  52732. declare module BABYLON {
  52733. /**
  52734. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52735. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52736. */
  52737. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52738. private _scene;
  52739. private _camerasToBeAttached;
  52740. /**
  52741. * ID of the sharpen post process,
  52742. */
  52743. private readonly SharpenPostProcessId;
  52744. /**
  52745. * @ignore
  52746. * ID of the image processing post process;
  52747. */
  52748. readonly ImageProcessingPostProcessId: string;
  52749. /**
  52750. * @ignore
  52751. * ID of the Fast Approximate Anti-Aliasing post process;
  52752. */
  52753. readonly FxaaPostProcessId: string;
  52754. /**
  52755. * ID of the chromatic aberration post process,
  52756. */
  52757. private readonly ChromaticAberrationPostProcessId;
  52758. /**
  52759. * ID of the grain post process
  52760. */
  52761. private readonly GrainPostProcessId;
  52762. /**
  52763. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52764. */
  52765. sharpen: SharpenPostProcess;
  52766. private _sharpenEffect;
  52767. private bloom;
  52768. /**
  52769. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52770. */
  52771. depthOfField: DepthOfFieldEffect;
  52772. /**
  52773. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52774. */
  52775. fxaa: FxaaPostProcess;
  52776. /**
  52777. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52778. */
  52779. imageProcessing: ImageProcessingPostProcess;
  52780. /**
  52781. * Chromatic aberration post process which will shift rgb colors in the image
  52782. */
  52783. chromaticAberration: ChromaticAberrationPostProcess;
  52784. private _chromaticAberrationEffect;
  52785. /**
  52786. * Grain post process which add noise to the image
  52787. */
  52788. grain: GrainPostProcess;
  52789. private _grainEffect;
  52790. /**
  52791. * Glow post process which adds a glow to emissive areas of the image
  52792. */
  52793. private _glowLayer;
  52794. /**
  52795. * Animations which can be used to tweak settings over a period of time
  52796. */
  52797. animations: Animation[];
  52798. private _imageProcessingConfigurationObserver;
  52799. private _sharpenEnabled;
  52800. private _bloomEnabled;
  52801. private _depthOfFieldEnabled;
  52802. private _depthOfFieldBlurLevel;
  52803. private _fxaaEnabled;
  52804. private _imageProcessingEnabled;
  52805. private _defaultPipelineTextureType;
  52806. private _bloomScale;
  52807. private _chromaticAberrationEnabled;
  52808. private _grainEnabled;
  52809. private _buildAllowed;
  52810. /**
  52811. * Gets active scene
  52812. */
  52813. readonly scene: Scene;
  52814. /**
  52815. * Enable or disable the sharpen process from the pipeline
  52816. */
  52817. sharpenEnabled: boolean;
  52818. private _resizeObserver;
  52819. private _hardwareScaleLevel;
  52820. private _bloomKernel;
  52821. /**
  52822. * Specifies the size of the bloom blur kernel, relative to the final output size
  52823. */
  52824. bloomKernel: number;
  52825. /**
  52826. * Specifies the weight of the bloom in the final rendering
  52827. */
  52828. private _bloomWeight;
  52829. /**
  52830. * Specifies the luma threshold for the area that will be blurred by the bloom
  52831. */
  52832. private _bloomThreshold;
  52833. private _hdr;
  52834. /**
  52835. * The strength of the bloom.
  52836. */
  52837. bloomWeight: number;
  52838. /**
  52839. * The strength of the bloom.
  52840. */
  52841. bloomThreshold: number;
  52842. /**
  52843. * The scale of the bloom, lower value will provide better performance.
  52844. */
  52845. bloomScale: number;
  52846. /**
  52847. * Enable or disable the bloom from the pipeline
  52848. */
  52849. bloomEnabled: boolean;
  52850. private _rebuildBloom;
  52851. /**
  52852. * If the depth of field is enabled.
  52853. */
  52854. depthOfFieldEnabled: boolean;
  52855. /**
  52856. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52857. */
  52858. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52859. /**
  52860. * If the anti aliasing is enabled.
  52861. */
  52862. fxaaEnabled: boolean;
  52863. private _samples;
  52864. /**
  52865. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52866. */
  52867. samples: number;
  52868. /**
  52869. * If image processing is enabled.
  52870. */
  52871. imageProcessingEnabled: boolean;
  52872. /**
  52873. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52874. */
  52875. glowLayerEnabled: boolean;
  52876. /**
  52877. * Enable or disable the chromaticAberration process from the pipeline
  52878. */
  52879. chromaticAberrationEnabled: boolean;
  52880. /**
  52881. * Enable or disable the grain process from the pipeline
  52882. */
  52883. grainEnabled: boolean;
  52884. /**
  52885. * @constructor
  52886. * @param name - The rendering pipeline name (default: "")
  52887. * @param hdr - If high dynamic range textures should be used (default: true)
  52888. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52889. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52890. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52891. */
  52892. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52893. /**
  52894. * Get the class name
  52895. * @returns "DefaultRenderingPipeline"
  52896. */
  52897. getClassName(): string;
  52898. /**
  52899. * Force the compilation of the entire pipeline.
  52900. */
  52901. prepare(): void;
  52902. private _hasCleared;
  52903. private _prevPostProcess;
  52904. private _prevPrevPostProcess;
  52905. private _setAutoClearAndTextureSharing;
  52906. private _depthOfFieldSceneObserver;
  52907. private _buildPipeline;
  52908. private _disposePostProcesses;
  52909. /**
  52910. * Adds a camera to the pipeline
  52911. * @param camera the camera to be added
  52912. */
  52913. addCamera(camera: Camera): void;
  52914. /**
  52915. * Removes a camera from the pipeline
  52916. * @param camera the camera to remove
  52917. */
  52918. removeCamera(camera: Camera): void;
  52919. /**
  52920. * Dispose of the pipeline and stop all post processes
  52921. */
  52922. dispose(): void;
  52923. /**
  52924. * Serialize the rendering pipeline (Used when exporting)
  52925. * @returns the serialized object
  52926. */
  52927. serialize(): any;
  52928. /**
  52929. * Parse the serialized pipeline
  52930. * @param source Source pipeline.
  52931. * @param scene The scene to load the pipeline to.
  52932. * @param rootUrl The URL of the serialized pipeline.
  52933. * @returns An instantiated pipeline from the serialized object.
  52934. */
  52935. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /** @hidden */
  52940. export var lensHighlightsPixelShader: {
  52941. name: string;
  52942. shader: string;
  52943. };
  52944. }
  52945. declare module BABYLON {
  52946. /** @hidden */
  52947. export var depthOfFieldPixelShader: {
  52948. name: string;
  52949. shader: string;
  52950. };
  52951. }
  52952. declare module BABYLON {
  52953. /**
  52954. * BABYLON.JS Chromatic Aberration GLSL Shader
  52955. * Author: Olivier Guyot
  52956. * Separates very slightly R, G and B colors on the edges of the screen
  52957. * Inspired by Francois Tarlier & Martins Upitis
  52958. */
  52959. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52960. /**
  52961. * @ignore
  52962. * The chromatic aberration PostProcess id in the pipeline
  52963. */
  52964. LensChromaticAberrationEffect: string;
  52965. /**
  52966. * @ignore
  52967. * The highlights enhancing PostProcess id in the pipeline
  52968. */
  52969. HighlightsEnhancingEffect: string;
  52970. /**
  52971. * @ignore
  52972. * The depth-of-field PostProcess id in the pipeline
  52973. */
  52974. LensDepthOfFieldEffect: string;
  52975. private _scene;
  52976. private _depthTexture;
  52977. private _grainTexture;
  52978. private _chromaticAberrationPostProcess;
  52979. private _highlightsPostProcess;
  52980. private _depthOfFieldPostProcess;
  52981. private _edgeBlur;
  52982. private _grainAmount;
  52983. private _chromaticAberration;
  52984. private _distortion;
  52985. private _highlightsGain;
  52986. private _highlightsThreshold;
  52987. private _dofDistance;
  52988. private _dofAperture;
  52989. private _dofDarken;
  52990. private _dofPentagon;
  52991. private _blurNoise;
  52992. /**
  52993. * @constructor
  52994. *
  52995. * Effect parameters are as follow:
  52996. * {
  52997. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52998. * edge_blur: number; // from 0 to x (1 for realism)
  52999. * distortion: number; // from 0 to x (1 for realism)
  53000. * grain_amount: number; // from 0 to 1
  53001. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53002. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53003. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53004. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53005. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53006. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53007. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53008. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53009. * }
  53010. * Note: if an effect parameter is unset, effect is disabled
  53011. *
  53012. * @param name The rendering pipeline name
  53013. * @param parameters - An object containing all parameters (see above)
  53014. * @param scene The scene linked to this pipeline
  53015. * @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)
  53016. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53017. */
  53018. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53019. /**
  53020. * Get the class name
  53021. * @returns "LensRenderingPipeline"
  53022. */
  53023. getClassName(): string;
  53024. /**
  53025. * Gets associated scene
  53026. */
  53027. readonly scene: Scene;
  53028. /**
  53029. * Gets or sets the edge blur
  53030. */
  53031. edgeBlur: number;
  53032. /**
  53033. * Gets or sets the grain amount
  53034. */
  53035. grainAmount: number;
  53036. /**
  53037. * Gets or sets the chromatic aberration amount
  53038. */
  53039. chromaticAberration: number;
  53040. /**
  53041. * Gets or sets the depth of field aperture
  53042. */
  53043. dofAperture: number;
  53044. /**
  53045. * Gets or sets the edge distortion
  53046. */
  53047. edgeDistortion: number;
  53048. /**
  53049. * Gets or sets the depth of field distortion
  53050. */
  53051. dofDistortion: number;
  53052. /**
  53053. * Gets or sets the darken out of focus amount
  53054. */
  53055. darkenOutOfFocus: number;
  53056. /**
  53057. * Gets or sets a boolean indicating if blur noise is enabled
  53058. */
  53059. blurNoise: boolean;
  53060. /**
  53061. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53062. */
  53063. pentagonBokeh: boolean;
  53064. /**
  53065. * Gets or sets the highlight grain amount
  53066. */
  53067. highlightsGain: number;
  53068. /**
  53069. * Gets or sets the highlight threshold
  53070. */
  53071. highlightsThreshold: number;
  53072. /**
  53073. * Sets the amount of blur at the edges
  53074. * @param amount blur amount
  53075. */
  53076. setEdgeBlur(amount: number): void;
  53077. /**
  53078. * Sets edge blur to 0
  53079. */
  53080. disableEdgeBlur(): void;
  53081. /**
  53082. * Sets the amout of grain
  53083. * @param amount Amount of grain
  53084. */
  53085. setGrainAmount(amount: number): void;
  53086. /**
  53087. * Set grain amount to 0
  53088. */
  53089. disableGrain(): void;
  53090. /**
  53091. * Sets the chromatic aberration amount
  53092. * @param amount amount of chromatic aberration
  53093. */
  53094. setChromaticAberration(amount: number): void;
  53095. /**
  53096. * Sets chromatic aberration amount to 0
  53097. */
  53098. disableChromaticAberration(): void;
  53099. /**
  53100. * Sets the EdgeDistortion amount
  53101. * @param amount amount of EdgeDistortion
  53102. */
  53103. setEdgeDistortion(amount: number): void;
  53104. /**
  53105. * Sets edge distortion to 0
  53106. */
  53107. disableEdgeDistortion(): void;
  53108. /**
  53109. * Sets the FocusDistance amount
  53110. * @param amount amount of FocusDistance
  53111. */
  53112. setFocusDistance(amount: number): void;
  53113. /**
  53114. * Disables depth of field
  53115. */
  53116. disableDepthOfField(): void;
  53117. /**
  53118. * Sets the Aperture amount
  53119. * @param amount amount of Aperture
  53120. */
  53121. setAperture(amount: number): void;
  53122. /**
  53123. * Sets the DarkenOutOfFocus amount
  53124. * @param amount amount of DarkenOutOfFocus
  53125. */
  53126. setDarkenOutOfFocus(amount: number): void;
  53127. private _pentagonBokehIsEnabled;
  53128. /**
  53129. * Creates a pentagon bokeh effect
  53130. */
  53131. enablePentagonBokeh(): void;
  53132. /**
  53133. * Disables the pentagon bokeh effect
  53134. */
  53135. disablePentagonBokeh(): void;
  53136. /**
  53137. * Enables noise blur
  53138. */
  53139. enableNoiseBlur(): void;
  53140. /**
  53141. * Disables noise blur
  53142. */
  53143. disableNoiseBlur(): void;
  53144. /**
  53145. * Sets the HighlightsGain amount
  53146. * @param amount amount of HighlightsGain
  53147. */
  53148. setHighlightsGain(amount: number): void;
  53149. /**
  53150. * Sets the HighlightsThreshold amount
  53151. * @param amount amount of HighlightsThreshold
  53152. */
  53153. setHighlightsThreshold(amount: number): void;
  53154. /**
  53155. * Disables highlights
  53156. */
  53157. disableHighlights(): void;
  53158. /**
  53159. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53160. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53161. */
  53162. dispose(disableDepthRender?: boolean): void;
  53163. private _createChromaticAberrationPostProcess;
  53164. private _createHighlightsPostProcess;
  53165. private _createDepthOfFieldPostProcess;
  53166. private _createGrainTexture;
  53167. }
  53168. }
  53169. declare module BABYLON {
  53170. /** @hidden */
  53171. export var ssao2PixelShader: {
  53172. name: string;
  53173. shader: string;
  53174. };
  53175. }
  53176. declare module BABYLON {
  53177. /** @hidden */
  53178. export var ssaoCombinePixelShader: {
  53179. name: string;
  53180. shader: string;
  53181. };
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Render pipeline to produce ssao effect
  53186. */
  53187. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53188. /**
  53189. * @ignore
  53190. * The PassPostProcess id in the pipeline that contains the original scene color
  53191. */
  53192. SSAOOriginalSceneColorEffect: string;
  53193. /**
  53194. * @ignore
  53195. * The SSAO PostProcess id in the pipeline
  53196. */
  53197. SSAORenderEffect: string;
  53198. /**
  53199. * @ignore
  53200. * The horizontal blur PostProcess id in the pipeline
  53201. */
  53202. SSAOBlurHRenderEffect: string;
  53203. /**
  53204. * @ignore
  53205. * The vertical blur PostProcess id in the pipeline
  53206. */
  53207. SSAOBlurVRenderEffect: string;
  53208. /**
  53209. * @ignore
  53210. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53211. */
  53212. SSAOCombineRenderEffect: string;
  53213. /**
  53214. * The output strength of the SSAO post-process. Default value is 1.0.
  53215. */
  53216. totalStrength: number;
  53217. /**
  53218. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53219. */
  53220. maxZ: number;
  53221. /**
  53222. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53223. */
  53224. minZAspect: number;
  53225. private _samples;
  53226. /**
  53227. * Number of samples used for the SSAO calculations. Default value is 8
  53228. */
  53229. samples: number;
  53230. private _textureSamples;
  53231. /**
  53232. * Number of samples to use for antialiasing
  53233. */
  53234. textureSamples: number;
  53235. /**
  53236. * Ratio object used for SSAO ratio and blur ratio
  53237. */
  53238. private _ratio;
  53239. /**
  53240. * Dynamically generated sphere sampler.
  53241. */
  53242. private _sampleSphere;
  53243. /**
  53244. * Blur filter offsets
  53245. */
  53246. private _samplerOffsets;
  53247. private _expensiveBlur;
  53248. /**
  53249. * If bilateral blur should be used
  53250. */
  53251. expensiveBlur: boolean;
  53252. /**
  53253. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53254. */
  53255. radius: number;
  53256. /**
  53257. * The base color of the SSAO post-process
  53258. * The final result is "base + ssao" between [0, 1]
  53259. */
  53260. base: number;
  53261. /**
  53262. * Support test.
  53263. */
  53264. static readonly IsSupported: boolean;
  53265. private _scene;
  53266. private _depthTexture;
  53267. private _normalTexture;
  53268. private _randomTexture;
  53269. private _originalColorPostProcess;
  53270. private _ssaoPostProcess;
  53271. private _blurHPostProcess;
  53272. private _blurVPostProcess;
  53273. private _ssaoCombinePostProcess;
  53274. private _firstUpdate;
  53275. /**
  53276. * Gets active scene
  53277. */
  53278. readonly scene: Scene;
  53279. /**
  53280. * @constructor
  53281. * @param name The rendering pipeline name
  53282. * @param scene The scene linked to this pipeline
  53283. * @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 }
  53284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53285. */
  53286. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53287. /**
  53288. * Get the class name
  53289. * @returns "SSAO2RenderingPipeline"
  53290. */
  53291. getClassName(): string;
  53292. /**
  53293. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53294. */
  53295. dispose(disableGeometryBufferRenderer?: boolean): void;
  53296. private _createBlurPostProcess;
  53297. /** @hidden */
  53298. _rebuild(): void;
  53299. private _bits;
  53300. private _radicalInverse_VdC;
  53301. private _hammersley;
  53302. private _hemisphereSample_uniform;
  53303. private _generateHemisphere;
  53304. private _createSSAOPostProcess;
  53305. private _createSSAOCombinePostProcess;
  53306. private _createRandomTexture;
  53307. /**
  53308. * Serialize the rendering pipeline (Used when exporting)
  53309. * @returns the serialized object
  53310. */
  53311. serialize(): any;
  53312. /**
  53313. * Parse the serialized pipeline
  53314. * @param source Source pipeline.
  53315. * @param scene The scene to load the pipeline to.
  53316. * @param rootUrl The URL of the serialized pipeline.
  53317. * @returns An instantiated pipeline from the serialized object.
  53318. */
  53319. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53320. }
  53321. }
  53322. declare module BABYLON {
  53323. /** @hidden */
  53324. export var ssaoPixelShader: {
  53325. name: string;
  53326. shader: string;
  53327. };
  53328. }
  53329. declare module BABYLON {
  53330. /**
  53331. * Render pipeline to produce ssao effect
  53332. */
  53333. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53334. /**
  53335. * @ignore
  53336. * The PassPostProcess id in the pipeline that contains the original scene color
  53337. */
  53338. SSAOOriginalSceneColorEffect: string;
  53339. /**
  53340. * @ignore
  53341. * The SSAO PostProcess id in the pipeline
  53342. */
  53343. SSAORenderEffect: string;
  53344. /**
  53345. * @ignore
  53346. * The horizontal blur PostProcess id in the pipeline
  53347. */
  53348. SSAOBlurHRenderEffect: string;
  53349. /**
  53350. * @ignore
  53351. * The vertical blur PostProcess id in the pipeline
  53352. */
  53353. SSAOBlurVRenderEffect: string;
  53354. /**
  53355. * @ignore
  53356. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53357. */
  53358. SSAOCombineRenderEffect: string;
  53359. /**
  53360. * The output strength of the SSAO post-process. Default value is 1.0.
  53361. */
  53362. totalStrength: number;
  53363. /**
  53364. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53365. */
  53366. radius: number;
  53367. /**
  53368. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53369. * Must not be equal to fallOff and superior to fallOff.
  53370. * Default value is 0.0075
  53371. */
  53372. area: number;
  53373. /**
  53374. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53375. * Must not be equal to area and inferior to area.
  53376. * Default value is 0.000001
  53377. */
  53378. fallOff: number;
  53379. /**
  53380. * The base color of the SSAO post-process
  53381. * The final result is "base + ssao" between [0, 1]
  53382. */
  53383. base: number;
  53384. private _scene;
  53385. private _depthTexture;
  53386. private _randomTexture;
  53387. private _originalColorPostProcess;
  53388. private _ssaoPostProcess;
  53389. private _blurHPostProcess;
  53390. private _blurVPostProcess;
  53391. private _ssaoCombinePostProcess;
  53392. private _firstUpdate;
  53393. /**
  53394. * Gets active scene
  53395. */
  53396. readonly scene: Scene;
  53397. /**
  53398. * @constructor
  53399. * @param name - The rendering pipeline name
  53400. * @param scene - The scene linked to this pipeline
  53401. * @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 }
  53402. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53403. */
  53404. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53405. /**
  53406. * Get the class name
  53407. * @returns "SSAORenderingPipeline"
  53408. */
  53409. getClassName(): string;
  53410. /**
  53411. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53412. */
  53413. dispose(disableDepthRender?: boolean): void;
  53414. private _createBlurPostProcess;
  53415. /** @hidden */
  53416. _rebuild(): void;
  53417. private _createSSAOPostProcess;
  53418. private _createSSAOCombinePostProcess;
  53419. private _createRandomTexture;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /** @hidden */
  53424. export var standardPixelShader: {
  53425. name: string;
  53426. shader: string;
  53427. };
  53428. }
  53429. declare module BABYLON {
  53430. /**
  53431. * Standard rendering pipeline
  53432. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53433. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53434. */
  53435. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53436. /**
  53437. * Public members
  53438. */
  53439. /**
  53440. * Post-process which contains the original scene color before the pipeline applies all the effects
  53441. */
  53442. originalPostProcess: Nullable<PostProcess>;
  53443. /**
  53444. * Post-process used to down scale an image x4
  53445. */
  53446. downSampleX4PostProcess: Nullable<PostProcess>;
  53447. /**
  53448. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53449. */
  53450. brightPassPostProcess: Nullable<PostProcess>;
  53451. /**
  53452. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53453. */
  53454. blurHPostProcesses: PostProcess[];
  53455. /**
  53456. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53457. */
  53458. blurVPostProcesses: PostProcess[];
  53459. /**
  53460. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53461. */
  53462. textureAdderPostProcess: Nullable<PostProcess>;
  53463. /**
  53464. * Post-process used to create volumetric lighting effect
  53465. */
  53466. volumetricLightPostProcess: Nullable<PostProcess>;
  53467. /**
  53468. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53469. */
  53470. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53471. /**
  53472. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53473. */
  53474. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53475. /**
  53476. * Post-process used to merge the volumetric light effect and the real scene color
  53477. */
  53478. volumetricLightMergePostProces: Nullable<PostProcess>;
  53479. /**
  53480. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53481. */
  53482. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53483. /**
  53484. * Base post-process used to calculate the average luminance of the final image for HDR
  53485. */
  53486. luminancePostProcess: Nullable<PostProcess>;
  53487. /**
  53488. * Post-processes used to create down sample post-processes in order to get
  53489. * the average luminance of the final image for HDR
  53490. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53491. */
  53492. luminanceDownSamplePostProcesses: PostProcess[];
  53493. /**
  53494. * Post-process used to create a HDR effect (light adaptation)
  53495. */
  53496. hdrPostProcess: Nullable<PostProcess>;
  53497. /**
  53498. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53499. */
  53500. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53501. /**
  53502. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53503. */
  53504. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53505. /**
  53506. * Post-process used to merge the final HDR post-process and the real scene color
  53507. */
  53508. hdrFinalPostProcess: Nullable<PostProcess>;
  53509. /**
  53510. * Post-process used to create a lens flare effect
  53511. */
  53512. lensFlarePostProcess: Nullable<PostProcess>;
  53513. /**
  53514. * Post-process that merges the result of the lens flare post-process and the real scene color
  53515. */
  53516. lensFlareComposePostProcess: Nullable<PostProcess>;
  53517. /**
  53518. * Post-process used to create a motion blur effect
  53519. */
  53520. motionBlurPostProcess: Nullable<PostProcess>;
  53521. /**
  53522. * Post-process used to create a depth of field effect
  53523. */
  53524. depthOfFieldPostProcess: Nullable<PostProcess>;
  53525. /**
  53526. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53527. */
  53528. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53529. /**
  53530. * Represents the brightness threshold in order to configure the illuminated surfaces
  53531. */
  53532. brightThreshold: number;
  53533. /**
  53534. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53535. */
  53536. blurWidth: number;
  53537. /**
  53538. * Sets if the blur for highlighted surfaces must be only horizontal
  53539. */
  53540. horizontalBlur: boolean;
  53541. /**
  53542. * Sets the overall exposure used by the pipeline
  53543. */
  53544. exposure: number;
  53545. /**
  53546. * Texture used typically to simulate "dirty" on camera lens
  53547. */
  53548. lensTexture: Nullable<Texture>;
  53549. /**
  53550. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53551. */
  53552. volumetricLightCoefficient: number;
  53553. /**
  53554. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53555. */
  53556. volumetricLightPower: number;
  53557. /**
  53558. * Used the set the blur intensity to smooth the volumetric lights
  53559. */
  53560. volumetricLightBlurScale: number;
  53561. /**
  53562. * Light (spot or directional) used to generate the volumetric lights rays
  53563. * The source light must have a shadow generate so the pipeline can get its
  53564. * depth map
  53565. */
  53566. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53567. /**
  53568. * For eye adaptation, represents the minimum luminance the eye can see
  53569. */
  53570. hdrMinimumLuminance: number;
  53571. /**
  53572. * For eye adaptation, represents the decrease luminance speed
  53573. */
  53574. hdrDecreaseRate: number;
  53575. /**
  53576. * For eye adaptation, represents the increase luminance speed
  53577. */
  53578. hdrIncreaseRate: number;
  53579. /**
  53580. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53581. */
  53582. lensColorTexture: Nullable<Texture>;
  53583. /**
  53584. * The overall strengh for the lens flare effect
  53585. */
  53586. lensFlareStrength: number;
  53587. /**
  53588. * Dispersion coefficient for lens flare ghosts
  53589. */
  53590. lensFlareGhostDispersal: number;
  53591. /**
  53592. * Main lens flare halo width
  53593. */
  53594. lensFlareHaloWidth: number;
  53595. /**
  53596. * Based on the lens distortion effect, defines how much the lens flare result
  53597. * is distorted
  53598. */
  53599. lensFlareDistortionStrength: number;
  53600. /**
  53601. * Lens star texture must be used to simulate rays on the flares and is available
  53602. * in the documentation
  53603. */
  53604. lensStarTexture: Nullable<Texture>;
  53605. /**
  53606. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53607. * flare effect by taking account of the dirt texture
  53608. */
  53609. lensFlareDirtTexture: Nullable<Texture>;
  53610. /**
  53611. * Represents the focal length for the depth of field effect
  53612. */
  53613. depthOfFieldDistance: number;
  53614. /**
  53615. * Represents the blur intensity for the blurred part of the depth of field effect
  53616. */
  53617. depthOfFieldBlurWidth: number;
  53618. /**
  53619. * For motion blur, defines how much the image is blurred by the movement
  53620. */
  53621. motionStrength: number;
  53622. /**
  53623. * List of animations for the pipeline (IAnimatable implementation)
  53624. */
  53625. animations: Animation[];
  53626. /**
  53627. * Private members
  53628. */
  53629. private _scene;
  53630. private _currentDepthOfFieldSource;
  53631. private _basePostProcess;
  53632. private _hdrCurrentLuminance;
  53633. private _floatTextureType;
  53634. private _ratio;
  53635. private _bloomEnabled;
  53636. private _depthOfFieldEnabled;
  53637. private _vlsEnabled;
  53638. private _lensFlareEnabled;
  53639. private _hdrEnabled;
  53640. private _motionBlurEnabled;
  53641. private _fxaaEnabled;
  53642. private _motionBlurSamples;
  53643. private _volumetricLightStepsCount;
  53644. private _samples;
  53645. /**
  53646. * @ignore
  53647. * Specifies if the bloom pipeline is enabled
  53648. */
  53649. BloomEnabled: boolean;
  53650. /**
  53651. * @ignore
  53652. * Specifies if the depth of field pipeline is enabed
  53653. */
  53654. DepthOfFieldEnabled: boolean;
  53655. /**
  53656. * @ignore
  53657. * Specifies if the lens flare pipeline is enabed
  53658. */
  53659. LensFlareEnabled: boolean;
  53660. /**
  53661. * @ignore
  53662. * Specifies if the HDR pipeline is enabled
  53663. */
  53664. HDREnabled: boolean;
  53665. /**
  53666. * @ignore
  53667. * Specifies if the volumetric lights scattering effect is enabled
  53668. */
  53669. VLSEnabled: boolean;
  53670. /**
  53671. * @ignore
  53672. * Specifies if the motion blur effect is enabled
  53673. */
  53674. MotionBlurEnabled: boolean;
  53675. /**
  53676. * Specifies if anti-aliasing is enabled
  53677. */
  53678. fxaaEnabled: boolean;
  53679. /**
  53680. * Specifies the number of steps used to calculate the volumetric lights
  53681. * Typically in interval [50, 200]
  53682. */
  53683. volumetricLightStepsCount: number;
  53684. /**
  53685. * Specifies the number of samples used for the motion blur effect
  53686. * Typically in interval [16, 64]
  53687. */
  53688. motionBlurSamples: number;
  53689. /**
  53690. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53691. */
  53692. samples: number;
  53693. /**
  53694. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53695. * @constructor
  53696. * @param name The rendering pipeline name
  53697. * @param scene The scene linked to this pipeline
  53698. * @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)
  53699. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53700. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53701. */
  53702. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53703. private _buildPipeline;
  53704. private _createDownSampleX4PostProcess;
  53705. private _createBrightPassPostProcess;
  53706. private _createBlurPostProcesses;
  53707. private _createTextureAdderPostProcess;
  53708. private _createVolumetricLightPostProcess;
  53709. private _createLuminancePostProcesses;
  53710. private _createHdrPostProcess;
  53711. private _createLensFlarePostProcess;
  53712. private _createDepthOfFieldPostProcess;
  53713. private _createMotionBlurPostProcess;
  53714. private _getDepthTexture;
  53715. private _disposePostProcesses;
  53716. /**
  53717. * Dispose of the pipeline and stop all post processes
  53718. */
  53719. dispose(): void;
  53720. /**
  53721. * Serialize the rendering pipeline (Used when exporting)
  53722. * @returns the serialized object
  53723. */
  53724. serialize(): any;
  53725. /**
  53726. * Parse the serialized pipeline
  53727. * @param source Source pipeline.
  53728. * @param scene The scene to load the pipeline to.
  53729. * @param rootUrl The URL of the serialized pipeline.
  53730. * @returns An instantiated pipeline from the serialized object.
  53731. */
  53732. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53733. /**
  53734. * Luminance steps
  53735. */
  53736. static LuminanceSteps: number;
  53737. }
  53738. }
  53739. declare module BABYLON {
  53740. /** @hidden */
  53741. export var tonemapPixelShader: {
  53742. name: string;
  53743. shader: string;
  53744. };
  53745. }
  53746. declare module BABYLON {
  53747. /** Defines operator used for tonemapping */
  53748. export enum TonemappingOperator {
  53749. /** Hable */
  53750. Hable = 0,
  53751. /** Reinhard */
  53752. Reinhard = 1,
  53753. /** HejiDawson */
  53754. HejiDawson = 2,
  53755. /** Photographic */
  53756. Photographic = 3
  53757. }
  53758. /**
  53759. * Defines a post process to apply tone mapping
  53760. */
  53761. export class TonemapPostProcess extends PostProcess {
  53762. private _operator;
  53763. /** Defines the required exposure adjustement */
  53764. exposureAdjustment: number;
  53765. /**
  53766. * Creates a new TonemapPostProcess
  53767. * @param name defines the name of the postprocess
  53768. * @param _operator defines the operator to use
  53769. * @param exposureAdjustment defines the required exposure adjustement
  53770. * @param camera defines the camera to use (can be null)
  53771. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53772. * @param engine defines the hosting engine (can be ignore if camera is set)
  53773. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53774. */
  53775. constructor(name: string, _operator: TonemappingOperator,
  53776. /** Defines the required exposure adjustement */
  53777. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53778. }
  53779. }
  53780. declare module BABYLON {
  53781. /** @hidden */
  53782. export var depthVertexShader: {
  53783. name: string;
  53784. shader: string;
  53785. };
  53786. }
  53787. declare module BABYLON {
  53788. /** @hidden */
  53789. export var volumetricLightScatteringPixelShader: {
  53790. name: string;
  53791. shader: string;
  53792. };
  53793. }
  53794. declare module BABYLON {
  53795. /** @hidden */
  53796. export var volumetricLightScatteringPassPixelShader: {
  53797. name: string;
  53798. shader: string;
  53799. };
  53800. }
  53801. declare module BABYLON {
  53802. /**
  53803. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53804. */
  53805. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53806. private _volumetricLightScatteringPass;
  53807. private _volumetricLightScatteringRTT;
  53808. private _viewPort;
  53809. private _screenCoordinates;
  53810. private _cachedDefines;
  53811. /**
  53812. * If not undefined, the mesh position is computed from the attached node position
  53813. */
  53814. attachedNode: {
  53815. position: Vector3;
  53816. };
  53817. /**
  53818. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53819. */
  53820. customMeshPosition: Vector3;
  53821. /**
  53822. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53823. */
  53824. useCustomMeshPosition: boolean;
  53825. /**
  53826. * If the post-process should inverse the light scattering direction
  53827. */
  53828. invert: boolean;
  53829. /**
  53830. * The internal mesh used by the post-process
  53831. */
  53832. mesh: Mesh;
  53833. /**
  53834. * @hidden
  53835. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53836. */
  53837. useDiffuseColor: boolean;
  53838. /**
  53839. * Array containing the excluded meshes not rendered in the internal pass
  53840. */
  53841. excludedMeshes: AbstractMesh[];
  53842. /**
  53843. * Controls the overall intensity of the post-process
  53844. */
  53845. exposure: number;
  53846. /**
  53847. * Dissipates each sample's contribution in range [0, 1]
  53848. */
  53849. decay: number;
  53850. /**
  53851. * Controls the overall intensity of each sample
  53852. */
  53853. weight: number;
  53854. /**
  53855. * Controls the density of each sample
  53856. */
  53857. density: number;
  53858. /**
  53859. * @constructor
  53860. * @param name The post-process name
  53861. * @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)
  53862. * @param camera The camera that the post-process will be attached to
  53863. * @param mesh The mesh used to create the light scattering
  53864. * @param samples The post-process quality, default 100
  53865. * @param samplingModeThe post-process filtering mode
  53866. * @param engine The babylon engine
  53867. * @param reusable If the post-process is reusable
  53868. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53869. */
  53870. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53871. /**
  53872. * Returns the string "VolumetricLightScatteringPostProcess"
  53873. * @returns "VolumetricLightScatteringPostProcess"
  53874. */
  53875. getClassName(): string;
  53876. private _isReady;
  53877. /**
  53878. * Sets the new light position for light scattering effect
  53879. * @param position The new custom light position
  53880. */
  53881. setCustomMeshPosition(position: Vector3): void;
  53882. /**
  53883. * Returns the light position for light scattering effect
  53884. * @return Vector3 The custom light position
  53885. */
  53886. getCustomMeshPosition(): Vector3;
  53887. /**
  53888. * Disposes the internal assets and detaches the post-process from the camera
  53889. */
  53890. dispose(camera: Camera): void;
  53891. /**
  53892. * Returns the render target texture used by the post-process
  53893. * @return the render target texture used by the post-process
  53894. */
  53895. getPass(): RenderTargetTexture;
  53896. private _meshExcluded;
  53897. private _createPass;
  53898. private _updateMeshScreenCoordinates;
  53899. /**
  53900. * Creates a default mesh for the Volumeric Light Scattering post-process
  53901. * @param name The mesh name
  53902. * @param scene The scene where to create the mesh
  53903. * @return the default mesh
  53904. */
  53905. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53906. }
  53907. }
  53908. declare module BABYLON {
  53909. interface Scene {
  53910. /** @hidden (Backing field) */
  53911. _boundingBoxRenderer: BoundingBoxRenderer;
  53912. /** @hidden (Backing field) */
  53913. _forceShowBoundingBoxes: boolean;
  53914. /**
  53915. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53916. */
  53917. forceShowBoundingBoxes: boolean;
  53918. /**
  53919. * Gets the bounding box renderer associated with the scene
  53920. * @returns a BoundingBoxRenderer
  53921. */
  53922. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53923. }
  53924. interface AbstractMesh {
  53925. /** @hidden (Backing field) */
  53926. _showBoundingBox: boolean;
  53927. /**
  53928. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53929. */
  53930. showBoundingBox: boolean;
  53931. }
  53932. /**
  53933. * Component responsible of rendering the bounding box of the meshes in a scene.
  53934. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53935. */
  53936. export class BoundingBoxRenderer implements ISceneComponent {
  53937. /**
  53938. * The component name helpfull to identify the component in the list of scene components.
  53939. */
  53940. readonly name: string;
  53941. /**
  53942. * The scene the component belongs to.
  53943. */
  53944. scene: Scene;
  53945. /**
  53946. * Color of the bounding box lines placed in front of an object
  53947. */
  53948. frontColor: Color3;
  53949. /**
  53950. * Color of the bounding box lines placed behind an object
  53951. */
  53952. backColor: Color3;
  53953. /**
  53954. * Defines if the renderer should show the back lines or not
  53955. */
  53956. showBackLines: boolean;
  53957. /**
  53958. * @hidden
  53959. */
  53960. renderList: SmartArray<BoundingBox>;
  53961. private _colorShader;
  53962. private _vertexBuffers;
  53963. private _indexBuffer;
  53964. /**
  53965. * Instantiates a new bounding box renderer in a scene.
  53966. * @param scene the scene the renderer renders in
  53967. */
  53968. constructor(scene: Scene);
  53969. /**
  53970. * Registers the component in a given scene
  53971. */
  53972. register(): void;
  53973. private _evaluateSubMesh;
  53974. private _activeMesh;
  53975. private _prepareRessources;
  53976. private _createIndexBuffer;
  53977. /**
  53978. * Rebuilds the elements related to this component in case of
  53979. * context lost for instance.
  53980. */
  53981. rebuild(): void;
  53982. /**
  53983. * @hidden
  53984. */
  53985. reset(): void;
  53986. /**
  53987. * Render the bounding boxes of a specific rendering group
  53988. * @param renderingGroupId defines the rendering group to render
  53989. */
  53990. render(renderingGroupId: number): void;
  53991. /**
  53992. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53993. * @param mesh Define the mesh to render the occlusion bounding box for
  53994. */
  53995. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53996. /**
  53997. * Dispose and release the resources attached to this renderer.
  53998. */
  53999. dispose(): void;
  54000. }
  54001. }
  54002. declare module BABYLON {
  54003. /** @hidden */
  54004. export var depthPixelShader: {
  54005. name: string;
  54006. shader: string;
  54007. };
  54008. }
  54009. declare module BABYLON {
  54010. /**
  54011. * This represents a depth renderer in Babylon.
  54012. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54013. */
  54014. export class DepthRenderer {
  54015. private _scene;
  54016. private _depthMap;
  54017. private _effect;
  54018. private _cachedDefines;
  54019. private _camera;
  54020. /**
  54021. * Specifiess that the depth renderer will only be used within
  54022. * the camera it is created for.
  54023. * This can help forcing its rendering during the camera processing.
  54024. */
  54025. useOnlyInActiveCamera: boolean;
  54026. /** @hidden */
  54027. static _SceneComponentInitialization: (scene: Scene) => void;
  54028. /**
  54029. * Instantiates a depth renderer
  54030. * @param scene The scene the renderer belongs to
  54031. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54032. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54033. */
  54034. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54035. /**
  54036. * Creates the depth rendering effect and checks if the effect is ready.
  54037. * @param subMesh The submesh to be used to render the depth map of
  54038. * @param useInstances If multiple world instances should be used
  54039. * @returns if the depth renderer is ready to render the depth map
  54040. */
  54041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54042. /**
  54043. * Gets the texture which the depth map will be written to.
  54044. * @returns The depth map texture
  54045. */
  54046. getDepthMap(): RenderTargetTexture;
  54047. /**
  54048. * Disposes of the depth renderer.
  54049. */
  54050. dispose(): void;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. interface Scene {
  54055. /** @hidden (Backing field) */
  54056. _depthRenderer: {
  54057. [id: string]: DepthRenderer;
  54058. };
  54059. /**
  54060. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54061. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54062. * @returns the created depth renderer
  54063. */
  54064. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54065. /**
  54066. * Disables a depth renderer for a given camera
  54067. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54068. */
  54069. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54070. }
  54071. /**
  54072. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54073. * in several rendering techniques.
  54074. */
  54075. export class DepthRendererSceneComponent implements ISceneComponent {
  54076. /**
  54077. * The component name helpfull to identify the component in the list of scene components.
  54078. */
  54079. readonly name: string;
  54080. /**
  54081. * The scene the component belongs to.
  54082. */
  54083. scene: Scene;
  54084. /**
  54085. * Creates a new instance of the component for the given scene
  54086. * @param scene Defines the scene to register the component in
  54087. */
  54088. constructor(scene: Scene);
  54089. /**
  54090. * Registers the component in a given scene
  54091. */
  54092. register(): void;
  54093. /**
  54094. * Rebuilds the elements related to this component in case of
  54095. * context lost for instance.
  54096. */
  54097. rebuild(): void;
  54098. /**
  54099. * Disposes the component and the associated ressources
  54100. */
  54101. dispose(): void;
  54102. private _gatherRenderTargets;
  54103. private _gatherActiveCameraRenderTargets;
  54104. }
  54105. }
  54106. declare module BABYLON {
  54107. /** @hidden */
  54108. export var outlinePixelShader: {
  54109. name: string;
  54110. shader: string;
  54111. };
  54112. }
  54113. declare module BABYLON {
  54114. /** @hidden */
  54115. export var outlineVertexShader: {
  54116. name: string;
  54117. shader: string;
  54118. };
  54119. }
  54120. declare module BABYLON {
  54121. interface Scene {
  54122. /** @hidden */
  54123. _outlineRenderer: OutlineRenderer;
  54124. /**
  54125. * Gets the outline renderer associated with the scene
  54126. * @returns a OutlineRenderer
  54127. */
  54128. getOutlineRenderer(): OutlineRenderer;
  54129. }
  54130. interface AbstractMesh {
  54131. /** @hidden (Backing field) */
  54132. _renderOutline: boolean;
  54133. /**
  54134. * Gets or sets a boolean indicating if the outline must be rendered as well
  54135. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54136. */
  54137. renderOutline: boolean;
  54138. /** @hidden (Backing field) */
  54139. _renderOverlay: boolean;
  54140. /**
  54141. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54142. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54143. */
  54144. renderOverlay: boolean;
  54145. }
  54146. /**
  54147. * This class is responsible to draw bothe outline/overlay of meshes.
  54148. * It should not be used directly but through the available method on mesh.
  54149. */
  54150. export class OutlineRenderer implements ISceneComponent {
  54151. /**
  54152. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54153. */
  54154. private static _StencilReference;
  54155. /**
  54156. * The name of the component. Each component must have a unique name.
  54157. */
  54158. name: string;
  54159. /**
  54160. * The scene the component belongs to.
  54161. */
  54162. scene: Scene;
  54163. /**
  54164. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54165. */
  54166. zOffset: number;
  54167. private _engine;
  54168. private _effect;
  54169. private _cachedDefines;
  54170. private _savedDepthWrite;
  54171. /**
  54172. * Instantiates a new outline renderer. (There could be only one per scene).
  54173. * @param scene Defines the scene it belongs to
  54174. */
  54175. constructor(scene: Scene);
  54176. /**
  54177. * Register the component to one instance of a scene.
  54178. */
  54179. register(): void;
  54180. /**
  54181. * Rebuilds the elements related to this component in case of
  54182. * context lost for instance.
  54183. */
  54184. rebuild(): void;
  54185. /**
  54186. * Disposes the component and the associated ressources.
  54187. */
  54188. dispose(): void;
  54189. /**
  54190. * Renders the outline in the canvas.
  54191. * @param subMesh Defines the sumesh to render
  54192. * @param batch Defines the batch of meshes in case of instances
  54193. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54194. */
  54195. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54196. /**
  54197. * Returns whether or not the outline renderer is ready for a given submesh.
  54198. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54199. * @param subMesh Defines the submesh to check readyness for
  54200. * @param useInstances Defines wheter wee are trying to render instances or not
  54201. * @returns true if ready otherwise false
  54202. */
  54203. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54204. private _beforeRenderingMesh;
  54205. private _afterRenderingMesh;
  54206. }
  54207. }
  54208. declare module BABYLON {
  54209. /**
  54210. * Defines the list of states available for a task inside a AssetsManager
  54211. */
  54212. export enum AssetTaskState {
  54213. /**
  54214. * Initialization
  54215. */
  54216. INIT = 0,
  54217. /**
  54218. * Running
  54219. */
  54220. RUNNING = 1,
  54221. /**
  54222. * Done
  54223. */
  54224. DONE = 2,
  54225. /**
  54226. * Error
  54227. */
  54228. ERROR = 3
  54229. }
  54230. /**
  54231. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54232. */
  54233. export abstract class AbstractAssetTask {
  54234. /**
  54235. * Task name
  54236. */ name: string;
  54237. /**
  54238. * Callback called when the task is successful
  54239. */
  54240. onSuccess: (task: any) => void;
  54241. /**
  54242. * Callback called when the task is not successful
  54243. */
  54244. onError: (task: any, message?: string, exception?: any) => void;
  54245. /**
  54246. * Creates a new AssetsManager
  54247. * @param name defines the name of the task
  54248. */
  54249. constructor(
  54250. /**
  54251. * Task name
  54252. */ name: string);
  54253. private _isCompleted;
  54254. private _taskState;
  54255. private _errorObject;
  54256. /**
  54257. * Get if the task is completed
  54258. */
  54259. readonly isCompleted: boolean;
  54260. /**
  54261. * Gets the current state of the task
  54262. */
  54263. readonly taskState: AssetTaskState;
  54264. /**
  54265. * Gets the current error object (if task is in error)
  54266. */
  54267. readonly errorObject: {
  54268. message?: string;
  54269. exception?: any;
  54270. };
  54271. /**
  54272. * Internal only
  54273. * @hidden
  54274. */
  54275. _setErrorObject(message?: string, exception?: any): void;
  54276. /**
  54277. * Execute the current task
  54278. * @param scene defines the scene where you want your assets to be loaded
  54279. * @param onSuccess is a callback called when the task is successfully executed
  54280. * @param onError is a callback called if an error occurs
  54281. */
  54282. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54283. /**
  54284. * Execute the current task
  54285. * @param scene defines the scene where you want your assets to be loaded
  54286. * @param onSuccess is a callback called when the task is successfully executed
  54287. * @param onError is a callback called if an error occurs
  54288. */
  54289. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54290. /**
  54291. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54292. * This can be used with failed tasks that have the reason for failure fixed.
  54293. */
  54294. reset(): void;
  54295. private onErrorCallback;
  54296. private onDoneCallback;
  54297. }
  54298. /**
  54299. * Define the interface used by progress events raised during assets loading
  54300. */
  54301. export interface IAssetsProgressEvent {
  54302. /**
  54303. * Defines the number of remaining tasks to process
  54304. */
  54305. remainingCount: number;
  54306. /**
  54307. * Defines the total number of tasks
  54308. */
  54309. totalCount: number;
  54310. /**
  54311. * Defines the task that was just processed
  54312. */
  54313. task: AbstractAssetTask;
  54314. }
  54315. /**
  54316. * Class used to share progress information about assets loading
  54317. */
  54318. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54319. /**
  54320. * Defines the number of remaining tasks to process
  54321. */
  54322. remainingCount: number;
  54323. /**
  54324. * Defines the total number of tasks
  54325. */
  54326. totalCount: number;
  54327. /**
  54328. * Defines the task that was just processed
  54329. */
  54330. task: AbstractAssetTask;
  54331. /**
  54332. * Creates a AssetsProgressEvent
  54333. * @param remainingCount defines the number of remaining tasks to process
  54334. * @param totalCount defines the total number of tasks
  54335. * @param task defines the task that was just processed
  54336. */
  54337. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54338. }
  54339. /**
  54340. * Define a task used by AssetsManager to load meshes
  54341. */
  54342. export class MeshAssetTask extends AbstractAssetTask {
  54343. /**
  54344. * Defines the name of the task
  54345. */
  54346. name: string;
  54347. /**
  54348. * Defines the list of mesh's names you want to load
  54349. */
  54350. meshesNames: any;
  54351. /**
  54352. * Defines the root url to use as a base to load your meshes and associated resources
  54353. */
  54354. rootUrl: string;
  54355. /**
  54356. * Defines the filename of the scene to load from
  54357. */
  54358. sceneFilename: string;
  54359. /**
  54360. * Gets the list of loaded meshes
  54361. */
  54362. loadedMeshes: Array<AbstractMesh>;
  54363. /**
  54364. * Gets the list of loaded particle systems
  54365. */
  54366. loadedParticleSystems: Array<IParticleSystem>;
  54367. /**
  54368. * Gets the list of loaded skeletons
  54369. */
  54370. loadedSkeletons: Array<Skeleton>;
  54371. /**
  54372. * Gets the list of loaded animation groups
  54373. */
  54374. loadedAnimationGroups: Array<AnimationGroup>;
  54375. /**
  54376. * Callback called when the task is successful
  54377. */
  54378. onSuccess: (task: MeshAssetTask) => void;
  54379. /**
  54380. * Callback called when the task is successful
  54381. */
  54382. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54383. /**
  54384. * Creates a new MeshAssetTask
  54385. * @param name defines the name of the task
  54386. * @param meshesNames defines the list of mesh's names you want to load
  54387. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54388. * @param sceneFilename defines the filename of the scene to load from
  54389. */
  54390. constructor(
  54391. /**
  54392. * Defines the name of the task
  54393. */
  54394. name: string,
  54395. /**
  54396. * Defines the list of mesh's names you want to load
  54397. */
  54398. meshesNames: any,
  54399. /**
  54400. * Defines the root url to use as a base to load your meshes and associated resources
  54401. */
  54402. rootUrl: string,
  54403. /**
  54404. * Defines the filename of the scene to load from
  54405. */
  54406. sceneFilename: string);
  54407. /**
  54408. * Execute the current task
  54409. * @param scene defines the scene where you want your assets to be loaded
  54410. * @param onSuccess is a callback called when the task is successfully executed
  54411. * @param onError is a callback called if an error occurs
  54412. */
  54413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54414. }
  54415. /**
  54416. * Define a task used by AssetsManager to load text content
  54417. */
  54418. export class TextFileAssetTask extends AbstractAssetTask {
  54419. /**
  54420. * Defines the name of the task
  54421. */
  54422. name: string;
  54423. /**
  54424. * Defines the location of the file to load
  54425. */
  54426. url: string;
  54427. /**
  54428. * Gets the loaded text string
  54429. */
  54430. text: string;
  54431. /**
  54432. * Callback called when the task is successful
  54433. */
  54434. onSuccess: (task: TextFileAssetTask) => void;
  54435. /**
  54436. * Callback called when the task is successful
  54437. */
  54438. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54439. /**
  54440. * Creates a new TextFileAssetTask object
  54441. * @param name defines the name of the task
  54442. * @param url defines the location of the file to load
  54443. */
  54444. constructor(
  54445. /**
  54446. * Defines the name of the task
  54447. */
  54448. name: string,
  54449. /**
  54450. * Defines the location of the file to load
  54451. */
  54452. url: string);
  54453. /**
  54454. * Execute the current task
  54455. * @param scene defines the scene where you want your assets to be loaded
  54456. * @param onSuccess is a callback called when the task is successfully executed
  54457. * @param onError is a callback called if an error occurs
  54458. */
  54459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54460. }
  54461. /**
  54462. * Define a task used by AssetsManager to load binary data
  54463. */
  54464. export class BinaryFileAssetTask extends AbstractAssetTask {
  54465. /**
  54466. * Defines the name of the task
  54467. */
  54468. name: string;
  54469. /**
  54470. * Defines the location of the file to load
  54471. */
  54472. url: string;
  54473. /**
  54474. * Gets the lodaded data (as an array buffer)
  54475. */
  54476. data: ArrayBuffer;
  54477. /**
  54478. * Callback called when the task is successful
  54479. */
  54480. onSuccess: (task: BinaryFileAssetTask) => void;
  54481. /**
  54482. * Callback called when the task is successful
  54483. */
  54484. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54485. /**
  54486. * Creates a new BinaryFileAssetTask object
  54487. * @param name defines the name of the new task
  54488. * @param url defines the location of the file to load
  54489. */
  54490. constructor(
  54491. /**
  54492. * Defines the name of the task
  54493. */
  54494. name: string,
  54495. /**
  54496. * Defines the location of the file to load
  54497. */
  54498. url: string);
  54499. /**
  54500. * Execute the current task
  54501. * @param scene defines the scene where you want your assets to be loaded
  54502. * @param onSuccess is a callback called when the task is successfully executed
  54503. * @param onError is a callback called if an error occurs
  54504. */
  54505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54506. }
  54507. /**
  54508. * Define a task used by AssetsManager to load images
  54509. */
  54510. export class ImageAssetTask extends AbstractAssetTask {
  54511. /**
  54512. * Defines the name of the task
  54513. */
  54514. name: string;
  54515. /**
  54516. * Defines the location of the image to load
  54517. */
  54518. url: string;
  54519. /**
  54520. * Gets the loaded images
  54521. */
  54522. image: HTMLImageElement;
  54523. /**
  54524. * Callback called when the task is successful
  54525. */
  54526. onSuccess: (task: ImageAssetTask) => void;
  54527. /**
  54528. * Callback called when the task is successful
  54529. */
  54530. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54531. /**
  54532. * Creates a new ImageAssetTask
  54533. * @param name defines the name of the task
  54534. * @param url defines the location of the image to load
  54535. */
  54536. constructor(
  54537. /**
  54538. * Defines the name of the task
  54539. */
  54540. name: string,
  54541. /**
  54542. * Defines the location of the image to load
  54543. */
  54544. url: string);
  54545. /**
  54546. * Execute the current task
  54547. * @param scene defines the scene where you want your assets to be loaded
  54548. * @param onSuccess is a callback called when the task is successfully executed
  54549. * @param onError is a callback called if an error occurs
  54550. */
  54551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54552. }
  54553. /**
  54554. * Defines the interface used by texture loading tasks
  54555. */
  54556. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54557. /**
  54558. * Gets the loaded texture
  54559. */
  54560. texture: TEX;
  54561. }
  54562. /**
  54563. * Define a task used by AssetsManager to load 2D textures
  54564. */
  54565. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54566. /**
  54567. * Defines the name of the task
  54568. */
  54569. name: string;
  54570. /**
  54571. * Defines the location of the file to load
  54572. */
  54573. url: string;
  54574. /**
  54575. * Defines if mipmap should not be generated (default is false)
  54576. */
  54577. noMipmap?: boolean | undefined;
  54578. /**
  54579. * Defines if texture must be inverted on Y axis (default is false)
  54580. */
  54581. invertY?: boolean | undefined;
  54582. /**
  54583. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54584. */
  54585. samplingMode: number;
  54586. /**
  54587. * Gets the loaded texture
  54588. */
  54589. texture: Texture;
  54590. /**
  54591. * Callback called when the task is successful
  54592. */
  54593. onSuccess: (task: TextureAssetTask) => void;
  54594. /**
  54595. * Callback called when the task is successful
  54596. */
  54597. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54598. /**
  54599. * Creates a new TextureAssetTask object
  54600. * @param name defines the name of the task
  54601. * @param url defines the location of the file to load
  54602. * @param noMipmap defines if mipmap should not be generated (default is false)
  54603. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54604. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54605. */
  54606. constructor(
  54607. /**
  54608. * Defines the name of the task
  54609. */
  54610. name: string,
  54611. /**
  54612. * Defines the location of the file to load
  54613. */
  54614. url: string,
  54615. /**
  54616. * Defines if mipmap should not be generated (default is false)
  54617. */
  54618. noMipmap?: boolean | undefined,
  54619. /**
  54620. * Defines if texture must be inverted on Y axis (default is false)
  54621. */
  54622. invertY?: boolean | undefined,
  54623. /**
  54624. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54625. */
  54626. samplingMode?: number);
  54627. /**
  54628. * Execute the current task
  54629. * @param scene defines the scene where you want your assets to be loaded
  54630. * @param onSuccess is a callback called when the task is successfully executed
  54631. * @param onError is a callback called if an error occurs
  54632. */
  54633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54634. }
  54635. /**
  54636. * Define a task used by AssetsManager to load cube textures
  54637. */
  54638. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54639. /**
  54640. * Defines the name of the task
  54641. */
  54642. name: string;
  54643. /**
  54644. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54645. */
  54646. url: string;
  54647. /**
  54648. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54649. */
  54650. extensions?: string[] | undefined;
  54651. /**
  54652. * Defines if mipmaps should not be generated (default is false)
  54653. */
  54654. noMipmap?: boolean | undefined;
  54655. /**
  54656. * Defines the explicit list of files (undefined by default)
  54657. */
  54658. files?: string[] | undefined;
  54659. /**
  54660. * Gets the loaded texture
  54661. */
  54662. texture: CubeTexture;
  54663. /**
  54664. * Callback called when the task is successful
  54665. */
  54666. onSuccess: (task: CubeTextureAssetTask) => void;
  54667. /**
  54668. * Callback called when the task is successful
  54669. */
  54670. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54671. /**
  54672. * Creates a new CubeTextureAssetTask
  54673. * @param name defines the name of the task
  54674. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54675. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54676. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54677. * @param files defines the explicit list of files (undefined by default)
  54678. */
  54679. constructor(
  54680. /**
  54681. * Defines the name of the task
  54682. */
  54683. name: string,
  54684. /**
  54685. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54686. */
  54687. url: string,
  54688. /**
  54689. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54690. */
  54691. extensions?: string[] | undefined,
  54692. /**
  54693. * Defines if mipmaps should not be generated (default is false)
  54694. */
  54695. noMipmap?: boolean | undefined,
  54696. /**
  54697. * Defines the explicit list of files (undefined by default)
  54698. */
  54699. files?: string[] | undefined);
  54700. /**
  54701. * Execute the current task
  54702. * @param scene defines the scene where you want your assets to be loaded
  54703. * @param onSuccess is a callback called when the task is successfully executed
  54704. * @param onError is a callback called if an error occurs
  54705. */
  54706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54707. }
  54708. /**
  54709. * Define a task used by AssetsManager to load HDR cube textures
  54710. */
  54711. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54712. /**
  54713. * Defines the name of the task
  54714. */
  54715. name: string;
  54716. /**
  54717. * Defines the location of the file to load
  54718. */
  54719. url: string;
  54720. /**
  54721. * Defines the desired size (the more it increases the longer the generation will be)
  54722. */
  54723. size: number;
  54724. /**
  54725. * Defines if mipmaps should not be generated (default is false)
  54726. */
  54727. noMipmap: boolean;
  54728. /**
  54729. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54730. */
  54731. generateHarmonics: boolean;
  54732. /**
  54733. * 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)
  54734. */
  54735. gammaSpace: boolean;
  54736. /**
  54737. * Internal Use Only
  54738. */
  54739. reserved: boolean;
  54740. /**
  54741. * Gets the loaded texture
  54742. */
  54743. texture: HDRCubeTexture;
  54744. /**
  54745. * Callback called when the task is successful
  54746. */
  54747. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54748. /**
  54749. * Callback called when the task is successful
  54750. */
  54751. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54752. /**
  54753. * Creates a new HDRCubeTextureAssetTask object
  54754. * @param name defines the name of the task
  54755. * @param url defines the location of the file to load
  54756. * @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.
  54757. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54758. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54759. * @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)
  54760. * @param reserved Internal use only
  54761. */
  54762. constructor(
  54763. /**
  54764. * Defines the name of the task
  54765. */
  54766. name: string,
  54767. /**
  54768. * Defines the location of the file to load
  54769. */
  54770. url: string,
  54771. /**
  54772. * Defines the desired size (the more it increases the longer the generation will be)
  54773. */
  54774. size: number,
  54775. /**
  54776. * Defines if mipmaps should not be generated (default is false)
  54777. */
  54778. noMipmap?: boolean,
  54779. /**
  54780. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54781. */
  54782. generateHarmonics?: boolean,
  54783. /**
  54784. * 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)
  54785. */
  54786. gammaSpace?: boolean,
  54787. /**
  54788. * Internal Use Only
  54789. */
  54790. reserved?: boolean);
  54791. /**
  54792. * Execute the current task
  54793. * @param scene defines the scene where you want your assets to be loaded
  54794. * @param onSuccess is a callback called when the task is successfully executed
  54795. * @param onError is a callback called if an error occurs
  54796. */
  54797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54798. }
  54799. /**
  54800. * Define a task used by AssetsManager to load Equirectangular cube textures
  54801. */
  54802. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54803. /**
  54804. * Defines the name of the task
  54805. */
  54806. name: string;
  54807. /**
  54808. * Defines the location of the file to load
  54809. */
  54810. url: string;
  54811. /**
  54812. * Defines the desired size (the more it increases the longer the generation will be)
  54813. */
  54814. size: number;
  54815. /**
  54816. * Defines if mipmaps should not be generated (default is false)
  54817. */
  54818. noMipmap: boolean;
  54819. /**
  54820. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54821. * but the standard material would require them in Gamma space) (default is true)
  54822. */
  54823. gammaSpace: boolean;
  54824. /**
  54825. * Gets the loaded texture
  54826. */
  54827. texture: EquiRectangularCubeTexture;
  54828. /**
  54829. * Callback called when the task is successful
  54830. */
  54831. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54832. /**
  54833. * Callback called when the task is successful
  54834. */
  54835. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54836. /**
  54837. * Creates a new EquiRectangularCubeTextureAssetTask object
  54838. * @param name defines the name of the task
  54839. * @param url defines the location of the file to load
  54840. * @param size defines the desired size (the more it increases the longer the generation will be)
  54841. * If the size is omitted this implies you are using a preprocessed cubemap.
  54842. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54843. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54844. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54845. * (default is true)
  54846. */
  54847. constructor(
  54848. /**
  54849. * Defines the name of the task
  54850. */
  54851. name: string,
  54852. /**
  54853. * Defines the location of the file to load
  54854. */
  54855. url: string,
  54856. /**
  54857. * Defines the desired size (the more it increases the longer the generation will be)
  54858. */
  54859. size: number,
  54860. /**
  54861. * Defines if mipmaps should not be generated (default is false)
  54862. */
  54863. noMipmap?: boolean,
  54864. /**
  54865. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54866. * but the standard material would require them in Gamma space) (default is true)
  54867. */
  54868. gammaSpace?: boolean);
  54869. /**
  54870. * Execute the current task
  54871. * @param scene defines the scene where you want your assets to be loaded
  54872. * @param onSuccess is a callback called when the task is successfully executed
  54873. * @param onError is a callback called if an error occurs
  54874. */
  54875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54876. }
  54877. /**
  54878. * This class can be used to easily import assets into a scene
  54879. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54880. */
  54881. export class AssetsManager {
  54882. private _scene;
  54883. private _isLoading;
  54884. protected _tasks: AbstractAssetTask[];
  54885. protected _waitingTasksCount: number;
  54886. protected _totalTasksCount: number;
  54887. /**
  54888. * Callback called when all tasks are processed
  54889. */
  54890. onFinish: (tasks: AbstractAssetTask[]) => void;
  54891. /**
  54892. * Callback called when a task is successful
  54893. */
  54894. onTaskSuccess: (task: AbstractAssetTask) => void;
  54895. /**
  54896. * Callback called when a task had an error
  54897. */
  54898. onTaskError: (task: AbstractAssetTask) => void;
  54899. /**
  54900. * Callback called when a task is done (whatever the result is)
  54901. */
  54902. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54903. /**
  54904. * Observable called when all tasks are processed
  54905. */
  54906. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54907. /**
  54908. * Observable called when a task had an error
  54909. */
  54910. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54911. /**
  54912. * Observable called when all tasks were executed
  54913. */
  54914. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54915. /**
  54916. * Observable called when a task is done (whatever the result is)
  54917. */
  54918. onProgressObservable: Observable<IAssetsProgressEvent>;
  54919. /**
  54920. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54922. */
  54923. useDefaultLoadingScreen: boolean;
  54924. /**
  54925. * Creates a new AssetsManager
  54926. * @param scene defines the scene to work on
  54927. */
  54928. constructor(scene: Scene);
  54929. /**
  54930. * Add a MeshAssetTask to the list of active tasks
  54931. * @param taskName defines the name of the new task
  54932. * @param meshesNames defines the name of meshes to load
  54933. * @param rootUrl defines the root url to use to locate files
  54934. * @param sceneFilename defines the filename of the scene file
  54935. * @returns a new MeshAssetTask object
  54936. */
  54937. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54938. /**
  54939. * Add a TextFileAssetTask to the list of active tasks
  54940. * @param taskName defines the name of the new task
  54941. * @param url defines the url of the file to load
  54942. * @returns a new TextFileAssetTask object
  54943. */
  54944. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54945. /**
  54946. * Add a BinaryFileAssetTask to the list of active tasks
  54947. * @param taskName defines the name of the new task
  54948. * @param url defines the url of the file to load
  54949. * @returns a new BinaryFileAssetTask object
  54950. */
  54951. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54952. /**
  54953. * Add a ImageAssetTask to the list of active tasks
  54954. * @param taskName defines the name of the new task
  54955. * @param url defines the url of the file to load
  54956. * @returns a new ImageAssetTask object
  54957. */
  54958. addImageTask(taskName: string, url: string): ImageAssetTask;
  54959. /**
  54960. * Add a TextureAssetTask to the list of active tasks
  54961. * @param taskName defines the name of the new task
  54962. * @param url defines the url of the file to load
  54963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54964. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54965. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54966. * @returns a new TextureAssetTask object
  54967. */
  54968. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54969. /**
  54970. * Add a CubeTextureAssetTask to the list of active tasks
  54971. * @param taskName defines the name of the new task
  54972. * @param url defines the url of the file to load
  54973. * @param extensions defines the extension to use to load the cube map (can be null)
  54974. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54975. * @param files defines the list of files to load (can be null)
  54976. * @returns a new CubeTextureAssetTask object
  54977. */
  54978. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54979. /**
  54980. *
  54981. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54982. * @param taskName defines the name of the new task
  54983. * @param url defines the url of the file to load
  54984. * @param size defines the size you want for the cubemap (can be null)
  54985. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54986. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54987. * @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)
  54988. * @param reserved Internal use only
  54989. * @returns a new HDRCubeTextureAssetTask object
  54990. */
  54991. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54992. /**
  54993. *
  54994. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54995. * @param taskName defines the name of the new task
  54996. * @param url defines the url of the file to load
  54997. * @param size defines the size you want for the cubemap (can be null)
  54998. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54999. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55000. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55001. * @returns a new EquiRectangularCubeTextureAssetTask object
  55002. */
  55003. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55004. /**
  55005. * Remove a task from the assets manager.
  55006. * @param task the task to remove
  55007. */
  55008. removeTask(task: AbstractAssetTask): void;
  55009. private _decreaseWaitingTasksCount;
  55010. private _runTask;
  55011. /**
  55012. * Reset the AssetsManager and remove all tasks
  55013. * @return the current instance of the AssetsManager
  55014. */
  55015. reset(): AssetsManager;
  55016. /**
  55017. * Start the loading process
  55018. * @return the current instance of the AssetsManager
  55019. */
  55020. load(): AssetsManager;
  55021. /**
  55022. * Start the loading process as an async operation
  55023. * @return a promise returning the list of failed tasks
  55024. */
  55025. loadAsync(): Promise<void>;
  55026. }
  55027. }
  55028. declare module BABYLON {
  55029. /**
  55030. * Wrapper class for promise with external resolve and reject.
  55031. */
  55032. export class Deferred<T> {
  55033. /**
  55034. * The promise associated with this deferred object.
  55035. */
  55036. readonly promise: Promise<T>;
  55037. private _resolve;
  55038. private _reject;
  55039. /**
  55040. * The resolve method of the promise associated with this deferred object.
  55041. */
  55042. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55043. /**
  55044. * The reject method of the promise associated with this deferred object.
  55045. */
  55046. readonly reject: (reason?: any) => void;
  55047. /**
  55048. * Constructor for this deferred object.
  55049. */
  55050. constructor();
  55051. }
  55052. }
  55053. declare module BABYLON {
  55054. /**
  55055. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55056. */
  55057. export class MeshExploder {
  55058. private _centerMesh;
  55059. private _meshes;
  55060. private _meshesOrigins;
  55061. private _toCenterVectors;
  55062. private _scaledDirection;
  55063. private _newPosition;
  55064. private _centerPosition;
  55065. /**
  55066. * Explodes meshes from a center mesh.
  55067. * @param meshes The meshes to explode.
  55068. * @param centerMesh The mesh to be center of explosion.
  55069. */
  55070. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55071. private _setCenterMesh;
  55072. /**
  55073. * Get class name
  55074. * @returns "MeshExploder"
  55075. */
  55076. getClassName(): string;
  55077. /**
  55078. * "Exploded meshes"
  55079. * @returns Array of meshes with the centerMesh at index 0.
  55080. */
  55081. getMeshes(): Array<Mesh>;
  55082. /**
  55083. * Explodes meshes giving a specific direction
  55084. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55085. */
  55086. explode(direction?: number): void;
  55087. }
  55088. }
  55089. declare module BABYLON {
  55090. /**
  55091. * Class used to help managing file picking and drag'n'drop
  55092. */
  55093. export class FilesInput {
  55094. /**
  55095. * List of files ready to be loaded
  55096. */
  55097. static readonly FilesToLoad: {
  55098. [key: string]: File;
  55099. };
  55100. /**
  55101. * Callback called when a file is processed
  55102. */
  55103. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55104. private _engine;
  55105. private _currentScene;
  55106. private _sceneLoadedCallback;
  55107. private _progressCallback;
  55108. private _additionalRenderLoopLogicCallback;
  55109. private _textureLoadingCallback;
  55110. private _startingProcessingFilesCallback;
  55111. private _onReloadCallback;
  55112. private _errorCallback;
  55113. private _elementToMonitor;
  55114. private _sceneFileToLoad;
  55115. private _filesToLoad;
  55116. /**
  55117. * Creates a new FilesInput
  55118. * @param engine defines the rendering engine
  55119. * @param scene defines the hosting scene
  55120. * @param sceneLoadedCallback callback called when scene is loaded
  55121. * @param progressCallback callback called to track progress
  55122. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55123. * @param textureLoadingCallback callback called when a texture is loading
  55124. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55125. * @param onReloadCallback callback called when a reload is requested
  55126. * @param errorCallback callback call if an error occurs
  55127. */
  55128. 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);
  55129. private _dragEnterHandler;
  55130. private _dragOverHandler;
  55131. private _dropHandler;
  55132. /**
  55133. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55134. * @param elementToMonitor defines the DOM element to track
  55135. */
  55136. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55137. /**
  55138. * Release all associated resources
  55139. */
  55140. dispose(): void;
  55141. private renderFunction;
  55142. private drag;
  55143. private drop;
  55144. private _traverseFolder;
  55145. private _processFiles;
  55146. /**
  55147. * Load files from a drop event
  55148. * @param event defines the drop event to use as source
  55149. */
  55150. loadFiles(event: any): void;
  55151. private _processReload;
  55152. /**
  55153. * Reload the current scene from the loaded files
  55154. */
  55155. reload(): void;
  55156. }
  55157. }
  55158. declare module BABYLON {
  55159. /**
  55160. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55162. */
  55163. export class SceneOptimization {
  55164. /**
  55165. * Defines the priority of this optimization (0 by default which means first in the list)
  55166. */
  55167. priority: number;
  55168. /**
  55169. * Gets a string describing the action executed by the current optimization
  55170. * @returns description string
  55171. */
  55172. getDescription(): string;
  55173. /**
  55174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55175. * @param scene defines the current scene where to apply this optimization
  55176. * @param optimizer defines the current optimizer
  55177. * @returns true if everything that can be done was applied
  55178. */
  55179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55180. /**
  55181. * Creates the SceneOptimization object
  55182. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55183. * @param desc defines the description associated with the optimization
  55184. */
  55185. constructor(
  55186. /**
  55187. * Defines the priority of this optimization (0 by default which means first in the list)
  55188. */
  55189. priority?: number);
  55190. }
  55191. /**
  55192. * Defines an optimization used to reduce the size of render target textures
  55193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55194. */
  55195. export class TextureOptimization extends SceneOptimization {
  55196. /**
  55197. * Defines the priority of this optimization (0 by default which means first in the list)
  55198. */
  55199. priority: number;
  55200. /**
  55201. * 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
  55202. */
  55203. maximumSize: number;
  55204. /**
  55205. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55206. */
  55207. step: number;
  55208. /**
  55209. * Gets a string describing the action executed by the current optimization
  55210. * @returns description string
  55211. */
  55212. getDescription(): string;
  55213. /**
  55214. * Creates the TextureOptimization object
  55215. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55216. * @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
  55217. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55218. */
  55219. constructor(
  55220. /**
  55221. * Defines the priority of this optimization (0 by default which means first in the list)
  55222. */
  55223. priority?: number,
  55224. /**
  55225. * 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
  55226. */
  55227. maximumSize?: number,
  55228. /**
  55229. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55230. */
  55231. step?: number);
  55232. /**
  55233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55234. * @param scene defines the current scene where to apply this optimization
  55235. * @param optimizer defines the current optimizer
  55236. * @returns true if everything that can be done was applied
  55237. */
  55238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55239. }
  55240. /**
  55241. * Defines an optimization used to increase or decrease the rendering resolution
  55242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55243. */
  55244. export class HardwareScalingOptimization extends SceneOptimization {
  55245. /**
  55246. * Defines the priority of this optimization (0 by default which means first in the list)
  55247. */
  55248. priority: number;
  55249. /**
  55250. * Defines the maximum scale to use (2 by default)
  55251. */
  55252. maximumScale: number;
  55253. /**
  55254. * Defines the step to use between two passes (0.5 by default)
  55255. */
  55256. step: number;
  55257. private _currentScale;
  55258. private _directionOffset;
  55259. /**
  55260. * Gets a string describing the action executed by the current optimization
  55261. * @return description string
  55262. */
  55263. getDescription(): string;
  55264. /**
  55265. * Creates the HardwareScalingOptimization object
  55266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55267. * @param maximumScale defines the maximum scale to use (2 by default)
  55268. * @param step defines the step to use between two passes (0.5 by default)
  55269. */
  55270. constructor(
  55271. /**
  55272. * Defines the priority of this optimization (0 by default which means first in the list)
  55273. */
  55274. priority?: number,
  55275. /**
  55276. * Defines the maximum scale to use (2 by default)
  55277. */
  55278. maximumScale?: number,
  55279. /**
  55280. * Defines the step to use between two passes (0.5 by default)
  55281. */
  55282. step?: number);
  55283. /**
  55284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55285. * @param scene defines the current scene where to apply this optimization
  55286. * @param optimizer defines the current optimizer
  55287. * @returns true if everything that can be done was applied
  55288. */
  55289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55290. }
  55291. /**
  55292. * Defines an optimization used to remove shadows
  55293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55294. */
  55295. export class ShadowsOptimization extends SceneOptimization {
  55296. /**
  55297. * Gets a string describing the action executed by the current optimization
  55298. * @return description string
  55299. */
  55300. getDescription(): string;
  55301. /**
  55302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55303. * @param scene defines the current scene where to apply this optimization
  55304. * @param optimizer defines the current optimizer
  55305. * @returns true if everything that can be done was applied
  55306. */
  55307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55308. }
  55309. /**
  55310. * Defines an optimization used to turn post-processes off
  55311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55312. */
  55313. export class PostProcessesOptimization extends SceneOptimization {
  55314. /**
  55315. * Gets a string describing the action executed by the current optimization
  55316. * @return description string
  55317. */
  55318. getDescription(): string;
  55319. /**
  55320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55321. * @param scene defines the current scene where to apply this optimization
  55322. * @param optimizer defines the current optimizer
  55323. * @returns true if everything that can be done was applied
  55324. */
  55325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55326. }
  55327. /**
  55328. * Defines an optimization used to turn lens flares off
  55329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55330. */
  55331. export class LensFlaresOptimization extends SceneOptimization {
  55332. /**
  55333. * Gets a string describing the action executed by the current optimization
  55334. * @return description string
  55335. */
  55336. getDescription(): string;
  55337. /**
  55338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55339. * @param scene defines the current scene where to apply this optimization
  55340. * @param optimizer defines the current optimizer
  55341. * @returns true if everything that can be done was applied
  55342. */
  55343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55344. }
  55345. /**
  55346. * Defines an optimization based on user defined callback.
  55347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55348. */
  55349. export class CustomOptimization extends SceneOptimization {
  55350. /**
  55351. * Callback called to apply the custom optimization.
  55352. */
  55353. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55354. /**
  55355. * Callback called to get custom description
  55356. */
  55357. onGetDescription: () => string;
  55358. /**
  55359. * Gets a string describing the action executed by the current optimization
  55360. * @returns description string
  55361. */
  55362. getDescription(): string;
  55363. /**
  55364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55365. * @param scene defines the current scene where to apply this optimization
  55366. * @param optimizer defines the current optimizer
  55367. * @returns true if everything that can be done was applied
  55368. */
  55369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55370. }
  55371. /**
  55372. * Defines an optimization used to turn particles off
  55373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55374. */
  55375. export class ParticlesOptimization extends SceneOptimization {
  55376. /**
  55377. * Gets a string describing the action executed by the current optimization
  55378. * @return description string
  55379. */
  55380. getDescription(): string;
  55381. /**
  55382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55383. * @param scene defines the current scene where to apply this optimization
  55384. * @param optimizer defines the current optimizer
  55385. * @returns true if everything that can be done was applied
  55386. */
  55387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55388. }
  55389. /**
  55390. * Defines an optimization used to turn render targets off
  55391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55392. */
  55393. export class RenderTargetsOptimization extends SceneOptimization {
  55394. /**
  55395. * Gets a string describing the action executed by the current optimization
  55396. * @return description string
  55397. */
  55398. getDescription(): string;
  55399. /**
  55400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55401. * @param scene defines the current scene where to apply this optimization
  55402. * @param optimizer defines the current optimizer
  55403. * @returns true if everything that can be done was applied
  55404. */
  55405. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55406. }
  55407. /**
  55408. * Defines an optimization used to merge meshes with compatible materials
  55409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55410. */
  55411. export class MergeMeshesOptimization extends SceneOptimization {
  55412. private static _UpdateSelectionTree;
  55413. /**
  55414. * Gets or sets a boolean which defines if optimization octree has to be updated
  55415. */
  55416. /**
  55417. * Gets or sets a boolean which defines if optimization octree has to be updated
  55418. */
  55419. static UpdateSelectionTree: boolean;
  55420. /**
  55421. * Gets a string describing the action executed by the current optimization
  55422. * @return description string
  55423. */
  55424. getDescription(): string;
  55425. private _canBeMerged;
  55426. /**
  55427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55428. * @param scene defines the current scene where to apply this optimization
  55429. * @param optimizer defines the current optimizer
  55430. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55431. * @returns true if everything that can be done was applied
  55432. */
  55433. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55434. }
  55435. /**
  55436. * Defines a list of options used by SceneOptimizer
  55437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55438. */
  55439. export class SceneOptimizerOptions {
  55440. /**
  55441. * Defines the target frame rate to reach (60 by default)
  55442. */
  55443. targetFrameRate: number;
  55444. /**
  55445. * Defines the interval between two checkes (2000ms by default)
  55446. */
  55447. trackerDuration: number;
  55448. /**
  55449. * Gets the list of optimizations to apply
  55450. */
  55451. optimizations: SceneOptimization[];
  55452. /**
  55453. * Creates a new list of options used by SceneOptimizer
  55454. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55455. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55456. */
  55457. constructor(
  55458. /**
  55459. * Defines the target frame rate to reach (60 by default)
  55460. */
  55461. targetFrameRate?: number,
  55462. /**
  55463. * Defines the interval between two checkes (2000ms by default)
  55464. */
  55465. trackerDuration?: number);
  55466. /**
  55467. * Add a new optimization
  55468. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55469. * @returns the current SceneOptimizerOptions
  55470. */
  55471. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55472. /**
  55473. * Add a new custom optimization
  55474. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55475. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55476. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55477. * @returns the current SceneOptimizerOptions
  55478. */
  55479. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55480. /**
  55481. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55482. * @param targetFrameRate defines the target frame rate (60 by default)
  55483. * @returns a SceneOptimizerOptions object
  55484. */
  55485. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55486. /**
  55487. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55488. * @param targetFrameRate defines the target frame rate (60 by default)
  55489. * @returns a SceneOptimizerOptions object
  55490. */
  55491. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55492. /**
  55493. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55494. * @param targetFrameRate defines the target frame rate (60 by default)
  55495. * @returns a SceneOptimizerOptions object
  55496. */
  55497. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55498. }
  55499. /**
  55500. * Class used to run optimizations in order to reach a target frame rate
  55501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55502. */
  55503. export class SceneOptimizer implements IDisposable {
  55504. private _isRunning;
  55505. private _options;
  55506. private _scene;
  55507. private _currentPriorityLevel;
  55508. private _targetFrameRate;
  55509. private _trackerDuration;
  55510. private _currentFrameRate;
  55511. private _sceneDisposeObserver;
  55512. private _improvementMode;
  55513. /**
  55514. * Defines an observable called when the optimizer reaches the target frame rate
  55515. */
  55516. onSuccessObservable: Observable<SceneOptimizer>;
  55517. /**
  55518. * Defines an observable called when the optimizer enables an optimization
  55519. */
  55520. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55521. /**
  55522. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55523. */
  55524. onFailureObservable: Observable<SceneOptimizer>;
  55525. /**
  55526. * Gets a boolean indicating if the optimizer is in improvement mode
  55527. */
  55528. readonly isInImprovementMode: boolean;
  55529. /**
  55530. * Gets the current priority level (0 at start)
  55531. */
  55532. readonly currentPriorityLevel: number;
  55533. /**
  55534. * Gets the current frame rate checked by the SceneOptimizer
  55535. */
  55536. readonly currentFrameRate: number;
  55537. /**
  55538. * Gets or sets the current target frame rate (60 by default)
  55539. */
  55540. /**
  55541. * Gets or sets the current target frame rate (60 by default)
  55542. */
  55543. targetFrameRate: number;
  55544. /**
  55545. * Gets or sets the current interval between two checks (every 2000ms by default)
  55546. */
  55547. /**
  55548. * Gets or sets the current interval between two checks (every 2000ms by default)
  55549. */
  55550. trackerDuration: number;
  55551. /**
  55552. * Gets the list of active optimizations
  55553. */
  55554. readonly optimizations: SceneOptimization[];
  55555. /**
  55556. * Creates a new SceneOptimizer
  55557. * @param scene defines the scene to work on
  55558. * @param options defines the options to use with the SceneOptimizer
  55559. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55560. * @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)
  55561. */
  55562. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55563. /**
  55564. * Stops the current optimizer
  55565. */
  55566. stop(): void;
  55567. /**
  55568. * Reset the optimizer to initial step (current priority level = 0)
  55569. */
  55570. reset(): void;
  55571. /**
  55572. * Start the optimizer. By default it will try to reach a specific framerate
  55573. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55574. */
  55575. start(): void;
  55576. private _checkCurrentState;
  55577. /**
  55578. * Release all resources
  55579. */
  55580. dispose(): void;
  55581. /**
  55582. * Helper function to create a SceneOptimizer with one single line of code
  55583. * @param scene defines the scene to work on
  55584. * @param options defines the options to use with the SceneOptimizer
  55585. * @param onSuccess defines a callback to call on success
  55586. * @param onFailure defines a callback to call on failure
  55587. * @returns the new SceneOptimizer object
  55588. */
  55589. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55590. }
  55591. }
  55592. declare module BABYLON {
  55593. /**
  55594. * Class used to serialize a scene into a string
  55595. */
  55596. export class SceneSerializer {
  55597. /**
  55598. * Clear cache used by a previous serialization
  55599. */
  55600. static ClearCache(): void;
  55601. /**
  55602. * Serialize a scene into a JSON compatible object
  55603. * @param scene defines the scene to serialize
  55604. * @returns a JSON compatible object
  55605. */
  55606. static Serialize(scene: Scene): any;
  55607. /**
  55608. * Serialize a mesh into a JSON compatible object
  55609. * @param toSerialize defines the mesh to serialize
  55610. * @param withParents defines if parents must be serialized as well
  55611. * @param withChildren defines if children must be serialized as well
  55612. * @returns a JSON compatible object
  55613. */
  55614. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55615. }
  55616. }
  55617. declare module BABYLON {
  55618. /**
  55619. * Class used to host texture specific utilities
  55620. */
  55621. export class TextureTools {
  55622. /**
  55623. * Uses the GPU to create a copy texture rescaled at a given size
  55624. * @param texture Texture to copy from
  55625. * @param width defines the desired width
  55626. * @param height defines the desired height
  55627. * @param useBilinearMode defines if bilinear mode has to be used
  55628. * @return the generated texture
  55629. */
  55630. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55631. }
  55632. }
  55633. declare module BABYLON {
  55634. /**
  55635. * This represents the different options avilable for the video capture.
  55636. */
  55637. export interface VideoRecorderOptions {
  55638. /** Defines the mime type of the video */
  55639. mimeType: string;
  55640. /** Defines the video the video should be recorded at */
  55641. fps: number;
  55642. /** Defines the chunk size for the recording data */
  55643. recordChunckSize: number;
  55644. /** The audio tracks to attach to the record */
  55645. audioTracks?: MediaStreamTrack[];
  55646. }
  55647. /**
  55648. * This can helps recording videos from BabylonJS.
  55649. * This is based on the available WebRTC functionalities of the browser.
  55650. *
  55651. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55652. */
  55653. export class VideoRecorder {
  55654. private static readonly _defaultOptions;
  55655. /**
  55656. * Returns wehther or not the VideoRecorder is available in your browser.
  55657. * @param engine Defines the Babylon Engine to check the support for
  55658. * @returns true if supported otherwise false
  55659. */
  55660. static IsSupported(engine: Engine): boolean;
  55661. private readonly _options;
  55662. private _canvas;
  55663. private _mediaRecorder;
  55664. private _recordedChunks;
  55665. private _fileName;
  55666. private _resolve;
  55667. private _reject;
  55668. /**
  55669. * True wether a recording is already in progress.
  55670. */
  55671. readonly isRecording: boolean;
  55672. /**
  55673. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55674. * a video file.
  55675. * @param engine Defines the BabylonJS Engine you wish to record
  55676. * @param options Defines options that can be used to customized the capture
  55677. */
  55678. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55679. /**
  55680. * Stops the current recording before the default capture timeout passed in the startRecording
  55681. * functions.
  55682. */
  55683. stopRecording(): void;
  55684. /**
  55685. * Starts recording the canvas for a max duration specified in parameters.
  55686. * @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.
  55687. * @param maxDuration Defines the maximum recording time in seconds.
  55688. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55689. * @return a promise callback at the end of the recording with the video data in Blob.
  55690. */
  55691. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55692. /**
  55693. * Releases internal resources used during the recording.
  55694. */
  55695. dispose(): void;
  55696. private _handleDataAvailable;
  55697. private _handleError;
  55698. private _handleStop;
  55699. }
  55700. }
  55701. declare module BABYLON {
  55702. /**
  55703. * Helper class to push actions to a pool of workers.
  55704. */
  55705. export class WorkerPool implements IDisposable {
  55706. private _workerInfos;
  55707. private _pendingActions;
  55708. /**
  55709. * Constructor
  55710. * @param workers Array of workers to use for actions
  55711. */
  55712. constructor(workers: Array<Worker>);
  55713. /**
  55714. * Terminates all workers and clears any pending actions.
  55715. */
  55716. dispose(): void;
  55717. /**
  55718. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55719. * pended until a worker has completed its action.
  55720. * @param action The action to perform. Call onComplete when the action is complete.
  55721. */
  55722. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55723. private _execute;
  55724. }
  55725. }
  55726. declare module BABYLON {
  55727. /**
  55728. * Class containing a set of static utilities functions for screenshots
  55729. */
  55730. export class ScreenshotTools {
  55731. /**
  55732. * Captures a screenshot of the current rendering
  55733. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55734. * @param engine defines the rendering engine
  55735. * @param camera defines the source camera
  55736. * @param size This parameter can be set to a single number or to an object with the
  55737. * following (optional) properties: precision, width, height. If a single number is passed,
  55738. * it will be used for both width and height. If an object is passed, the screenshot size
  55739. * will be derived from the parameters. The precision property is a multiplier allowing
  55740. * rendering at a higher or lower resolution
  55741. * @param successCallback defines the callback receives a single parameter which contains the
  55742. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55743. * src parameter of an <img> to display it
  55744. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55745. * Check your browser for supported MIME types
  55746. */
  55747. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55748. /**
  55749. * Generates an image screenshot from the specified camera.
  55750. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55751. * @param engine The engine to use for rendering
  55752. * @param camera The camera to use for rendering
  55753. * @param size This parameter can be set to a single number or to an object with the
  55754. * following (optional) properties: precision, width, height. If a single number is passed,
  55755. * it will be used for both width and height. If an object is passed, the screenshot size
  55756. * will be derived from the parameters. The precision property is a multiplier allowing
  55757. * rendering at a higher or lower resolution
  55758. * @param successCallback The callback receives a single parameter which contains the
  55759. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55760. * src parameter of an <img> to display it
  55761. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55762. * Check your browser for supported MIME types
  55763. * @param samples Texture samples (default: 1)
  55764. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55765. * @param fileName A name for for the downloaded file.
  55766. */
  55767. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55768. }
  55769. }
  55770. declare module BABYLON {
  55771. /**
  55772. * A cursor which tracks a point on a path
  55773. */
  55774. export class PathCursor {
  55775. private path;
  55776. /**
  55777. * Stores path cursor callbacks for when an onchange event is triggered
  55778. */
  55779. private _onchange;
  55780. /**
  55781. * The value of the path cursor
  55782. */
  55783. value: number;
  55784. /**
  55785. * The animation array of the path cursor
  55786. */
  55787. animations: Animation[];
  55788. /**
  55789. * Initializes the path cursor
  55790. * @param path The path to track
  55791. */
  55792. constructor(path: Path2);
  55793. /**
  55794. * Gets the cursor point on the path
  55795. * @returns A point on the path cursor at the cursor location
  55796. */
  55797. getPoint(): Vector3;
  55798. /**
  55799. * Moves the cursor ahead by the step amount
  55800. * @param step The amount to move the cursor forward
  55801. * @returns This path cursor
  55802. */
  55803. moveAhead(step?: number): PathCursor;
  55804. /**
  55805. * Moves the cursor behind by the step amount
  55806. * @param step The amount to move the cursor back
  55807. * @returns This path cursor
  55808. */
  55809. moveBack(step?: number): PathCursor;
  55810. /**
  55811. * Moves the cursor by the step amount
  55812. * If the step amount is greater than one, an exception is thrown
  55813. * @param step The amount to move the cursor
  55814. * @returns This path cursor
  55815. */
  55816. move(step: number): PathCursor;
  55817. /**
  55818. * Ensures that the value is limited between zero and one
  55819. * @returns This path cursor
  55820. */
  55821. private ensureLimits;
  55822. /**
  55823. * Runs onchange callbacks on change (used by the animation engine)
  55824. * @returns This path cursor
  55825. */
  55826. private raiseOnChange;
  55827. /**
  55828. * Executes a function on change
  55829. * @param f A path cursor onchange callback
  55830. * @returns This path cursor
  55831. */
  55832. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55833. }
  55834. }
  55835. declare module BABYLON {
  55836. /** @hidden */
  55837. export var blurPixelShader: {
  55838. name: string;
  55839. shader: string;
  55840. };
  55841. }
  55842. declare module BABYLON {
  55843. /** @hidden */
  55844. export var bones300Declaration: {
  55845. name: string;
  55846. shader: string;
  55847. };
  55848. }
  55849. declare module BABYLON {
  55850. /** @hidden */
  55851. export var instances300Declaration: {
  55852. name: string;
  55853. shader: string;
  55854. };
  55855. }
  55856. declare module BABYLON {
  55857. /** @hidden */
  55858. export var pointCloudVertexDeclaration: {
  55859. name: string;
  55860. shader: string;
  55861. };
  55862. }
  55863. // Mixins
  55864. interface Window {
  55865. mozIndexedDB: IDBFactory;
  55866. webkitIndexedDB: IDBFactory;
  55867. msIndexedDB: IDBFactory;
  55868. webkitURL: typeof URL;
  55869. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55870. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55871. WebGLRenderingContext: WebGLRenderingContext;
  55872. MSGesture: MSGesture;
  55873. CANNON: any;
  55874. AudioContext: AudioContext;
  55875. webkitAudioContext: AudioContext;
  55876. PointerEvent: any;
  55877. Math: Math;
  55878. Uint8Array: Uint8ArrayConstructor;
  55879. Float32Array: Float32ArrayConstructor;
  55880. mozURL: typeof URL;
  55881. msURL: typeof URL;
  55882. VRFrameData: any; // WebVR, from specs 1.1
  55883. DracoDecoderModule: any;
  55884. setImmediate(handler: (...args: any[]) => void): number;
  55885. }
  55886. interface HTMLCanvasElement {
  55887. requestPointerLock(): void;
  55888. msRequestPointerLock?(): void;
  55889. mozRequestPointerLock?(): void;
  55890. webkitRequestPointerLock?(): void;
  55891. /** Track wether a record is in progress */
  55892. isRecording: boolean;
  55893. /** Capture Stream method defined by some browsers */
  55894. captureStream(fps?: number): MediaStream;
  55895. }
  55896. interface CanvasRenderingContext2D {
  55897. msImageSmoothingEnabled: boolean;
  55898. }
  55899. interface MouseEvent {
  55900. mozMovementX: number;
  55901. mozMovementY: number;
  55902. webkitMovementX: number;
  55903. webkitMovementY: number;
  55904. msMovementX: number;
  55905. msMovementY: number;
  55906. }
  55907. interface Navigator {
  55908. mozGetVRDevices: (any: any) => any;
  55909. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55910. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55911. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55912. webkitGetGamepads(): Gamepad[];
  55913. msGetGamepads(): Gamepad[];
  55914. webkitGamepads(): Gamepad[];
  55915. }
  55916. interface HTMLVideoElement {
  55917. mozSrcObject: any;
  55918. }
  55919. interface Math {
  55920. fround(x: number): number;
  55921. imul(a: number, b: number): number;
  55922. }
  55923. interface WebGLProgram {
  55924. context?: WebGLRenderingContext;
  55925. vertexShader?: WebGLShader;
  55926. fragmentShader?: WebGLShader;
  55927. isParallelCompiled: boolean;
  55928. onCompiled?: () => void;
  55929. }
  55930. interface WebGLRenderingContext {
  55931. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55932. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55933. vertexAttribDivisor(index: number, divisor: number): void;
  55934. createVertexArray(): any;
  55935. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55936. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55937. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55938. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55939. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55940. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55941. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55942. // Queries
  55943. createQuery(): WebGLQuery;
  55944. deleteQuery(query: WebGLQuery): void;
  55945. beginQuery(target: number, query: WebGLQuery): void;
  55946. endQuery(target: number): void;
  55947. getQueryParameter(query: WebGLQuery, pname: number): any;
  55948. getQuery(target: number, pname: number): any;
  55949. MAX_SAMPLES: number;
  55950. RGBA8: number;
  55951. READ_FRAMEBUFFER: number;
  55952. DRAW_FRAMEBUFFER: number;
  55953. UNIFORM_BUFFER: number;
  55954. HALF_FLOAT_OES: number;
  55955. RGBA16F: number;
  55956. RGBA32F: number;
  55957. R32F: number;
  55958. RG32F: number;
  55959. RGB32F: number;
  55960. R16F: number;
  55961. RG16F: number;
  55962. RGB16F: number;
  55963. RED: number;
  55964. RG: number;
  55965. R8: number;
  55966. RG8: number;
  55967. UNSIGNED_INT_24_8: number;
  55968. DEPTH24_STENCIL8: number;
  55969. /* Multiple Render Targets */
  55970. drawBuffers(buffers: number[]): void;
  55971. readBuffer(src: number): void;
  55972. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55973. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55974. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55975. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55976. // Occlusion Query
  55977. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55978. ANY_SAMPLES_PASSED: number;
  55979. QUERY_RESULT_AVAILABLE: number;
  55980. QUERY_RESULT: number;
  55981. }
  55982. interface WebGLBuffer {
  55983. references: number;
  55984. capacity: number;
  55985. is32Bits: boolean;
  55986. }
  55987. interface WebGLProgram {
  55988. transformFeedback?: WebGLTransformFeedback | null;
  55989. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55990. }
  55991. interface EXT_disjoint_timer_query {
  55992. QUERY_COUNTER_BITS_EXT: number;
  55993. TIME_ELAPSED_EXT: number;
  55994. TIMESTAMP_EXT: number;
  55995. GPU_DISJOINT_EXT: number;
  55996. QUERY_RESULT_EXT: number;
  55997. QUERY_RESULT_AVAILABLE_EXT: number;
  55998. queryCounterEXT(query: WebGLQuery, target: number): void;
  55999. createQueryEXT(): WebGLQuery;
  56000. beginQueryEXT(target: number, query: WebGLQuery): void;
  56001. endQueryEXT(target: number): void;
  56002. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56003. deleteQueryEXT(query: WebGLQuery): void;
  56004. }
  56005. interface WebGLUniformLocation {
  56006. _currentState: any;
  56007. }
  56008. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56009. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56010. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56011. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56012. interface WebGLRenderingContext {
  56013. readonly RASTERIZER_DISCARD: number;
  56014. readonly DEPTH_COMPONENT24: number;
  56015. readonly TEXTURE_3D: number;
  56016. readonly TEXTURE_2D_ARRAY: number;
  56017. readonly TEXTURE_COMPARE_FUNC: number;
  56018. readonly TEXTURE_COMPARE_MODE: number;
  56019. readonly COMPARE_REF_TO_TEXTURE: number;
  56020. readonly TEXTURE_WRAP_R: number;
  56021. readonly HALF_FLOAT: number;
  56022. readonly RGB8: number;
  56023. readonly RED_INTEGER: number;
  56024. readonly RG_INTEGER: number;
  56025. readonly RGB_INTEGER: number;
  56026. readonly RGBA_INTEGER: number;
  56027. readonly R8_SNORM: number;
  56028. readonly RG8_SNORM: number;
  56029. readonly RGB8_SNORM: number;
  56030. readonly RGBA8_SNORM: number;
  56031. readonly R8I: number;
  56032. readonly RG8I: number;
  56033. readonly RGB8I: number;
  56034. readonly RGBA8I: number;
  56035. readonly R8UI: number;
  56036. readonly RG8UI: number;
  56037. readonly RGB8UI: number;
  56038. readonly RGBA8UI: number;
  56039. readonly R16I: number;
  56040. readonly RG16I: number;
  56041. readonly RGB16I: number;
  56042. readonly RGBA16I: number;
  56043. readonly R16UI: number;
  56044. readonly RG16UI: number;
  56045. readonly RGB16UI: number;
  56046. readonly RGBA16UI: number;
  56047. readonly R32I: number;
  56048. readonly RG32I: number;
  56049. readonly RGB32I: number;
  56050. readonly RGBA32I: number;
  56051. readonly R32UI: number;
  56052. readonly RG32UI: number;
  56053. readonly RGB32UI: number;
  56054. readonly RGBA32UI: number;
  56055. readonly RGB10_A2UI: number;
  56056. readonly R11F_G11F_B10F: number;
  56057. readonly RGB9_E5: number;
  56058. readonly RGB10_A2: number;
  56059. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56060. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56061. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56062. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56063. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56064. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56065. 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;
  56066. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56067. readonly TRANSFORM_FEEDBACK: number;
  56068. readonly INTERLEAVED_ATTRIBS: number;
  56069. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56070. createTransformFeedback(): WebGLTransformFeedback;
  56071. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56072. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56073. beginTransformFeedback(primitiveMode: number): void;
  56074. endTransformFeedback(): void;
  56075. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56076. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56077. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56078. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56079. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56080. }
  56081. interface ImageBitmap {
  56082. readonly width: number;
  56083. readonly height: number;
  56084. close(): void;
  56085. }
  56086. interface WebGLQuery extends WebGLObject {
  56087. }
  56088. declare var WebGLQuery: {
  56089. prototype: WebGLQuery;
  56090. new(): WebGLQuery;
  56091. };
  56092. interface WebGLSampler extends WebGLObject {
  56093. }
  56094. declare var WebGLSampler: {
  56095. prototype: WebGLSampler;
  56096. new(): WebGLSampler;
  56097. };
  56098. interface WebGLSync extends WebGLObject {
  56099. }
  56100. declare var WebGLSync: {
  56101. prototype: WebGLSync;
  56102. new(): WebGLSync;
  56103. };
  56104. interface WebGLTransformFeedback extends WebGLObject {
  56105. }
  56106. declare var WebGLTransformFeedback: {
  56107. prototype: WebGLTransformFeedback;
  56108. new(): WebGLTransformFeedback;
  56109. };
  56110. interface WebGLVertexArrayObject extends WebGLObject {
  56111. }
  56112. declare var WebGLVertexArrayObject: {
  56113. prototype: WebGLVertexArrayObject;
  56114. new(): WebGLVertexArrayObject;
  56115. };
  56116. // Type definitions for WebVR API
  56117. // Project: https://w3c.github.io/webvr/
  56118. // Definitions by: six a <https://github.com/lostfictions>
  56119. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56120. interface VRDisplay extends EventTarget {
  56121. /**
  56122. * Dictionary of capabilities describing the VRDisplay.
  56123. */
  56124. readonly capabilities: VRDisplayCapabilities;
  56125. /**
  56126. * z-depth defining the far plane of the eye view frustum
  56127. * enables mapping of values in the render target depth
  56128. * attachment to scene coordinates. Initially set to 10000.0.
  56129. */
  56130. depthFar: number;
  56131. /**
  56132. * z-depth defining the near plane of the eye view frustum
  56133. * enables mapping of values in the render target depth
  56134. * attachment to scene coordinates. Initially set to 0.01.
  56135. */
  56136. depthNear: number;
  56137. /**
  56138. * An identifier for this distinct VRDisplay. Used as an
  56139. * association point in the Gamepad API.
  56140. */
  56141. readonly displayId: number;
  56142. /**
  56143. * A display name, a user-readable name identifying it.
  56144. */
  56145. readonly displayName: string;
  56146. readonly isConnected: boolean;
  56147. readonly isPresenting: boolean;
  56148. /**
  56149. * If this VRDisplay supports room-scale experiences, the optional
  56150. * stage attribute contains details on the room-scale parameters.
  56151. */
  56152. readonly stageParameters: VRStageParameters | null;
  56153. /**
  56154. * Passing the value returned by `requestAnimationFrame` to
  56155. * `cancelAnimationFrame` will unregister the callback.
  56156. * @param handle Define the hanle of the request to cancel
  56157. */
  56158. cancelAnimationFrame(handle: number): void;
  56159. /**
  56160. * Stops presenting to the VRDisplay.
  56161. * @returns a promise to know when it stopped
  56162. */
  56163. exitPresent(): Promise<void>;
  56164. /**
  56165. * Return the current VREyeParameters for the given eye.
  56166. * @param whichEye Define the eye we want the parameter for
  56167. * @returns the eye parameters
  56168. */
  56169. getEyeParameters(whichEye: string): VREyeParameters;
  56170. /**
  56171. * Populates the passed VRFrameData with the information required to render
  56172. * the current frame.
  56173. * @param frameData Define the data structure to populate
  56174. * @returns true if ok otherwise false
  56175. */
  56176. getFrameData(frameData: VRFrameData): boolean;
  56177. /**
  56178. * Get the layers currently being presented.
  56179. * @returns the list of VR layers
  56180. */
  56181. getLayers(): VRLayer[];
  56182. /**
  56183. * Return a VRPose containing the future predicted pose of the VRDisplay
  56184. * when the current frame will be presented. The value returned will not
  56185. * change until JavaScript has returned control to the browser.
  56186. *
  56187. * The VRPose will contain the position, orientation, velocity,
  56188. * and acceleration of each of these properties.
  56189. * @returns the pose object
  56190. */
  56191. getPose(): VRPose;
  56192. /**
  56193. * Return the current instantaneous pose of the VRDisplay, with no
  56194. * prediction applied.
  56195. * @returns the current instantaneous pose
  56196. */
  56197. getImmediatePose(): VRPose;
  56198. /**
  56199. * The callback passed to `requestAnimationFrame` will be called
  56200. * any time a new frame should be rendered. When the VRDisplay is
  56201. * presenting the callback will be called at the native refresh
  56202. * rate of the HMD. When not presenting this function acts
  56203. * identically to how window.requestAnimationFrame acts. Content should
  56204. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56205. * asynchronously from other displays and at differing refresh rates.
  56206. * @param callback Define the eaction to run next frame
  56207. * @returns the request handle it
  56208. */
  56209. requestAnimationFrame(callback: FrameRequestCallback): number;
  56210. /**
  56211. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56212. * Repeat calls while already presenting will update the VRLayers being displayed.
  56213. * @param layers Define the list of layer to present
  56214. * @returns a promise to know when the request has been fulfilled
  56215. */
  56216. requestPresent(layers: VRLayer[]): Promise<void>;
  56217. /**
  56218. * Reset the pose for this display, treating its current position and
  56219. * orientation as the "origin/zero" values. VRPose.position,
  56220. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56221. * updated when calling resetPose(). This should be called in only
  56222. * sitting-space experiences.
  56223. */
  56224. resetPose(): void;
  56225. /**
  56226. * The VRLayer provided to the VRDisplay will be captured and presented
  56227. * in the HMD. Calling this function has the same effect on the source
  56228. * canvas as any other operation that uses its source image, and canvases
  56229. * created without preserveDrawingBuffer set to true will be cleared.
  56230. * @param pose Define the pose to submit
  56231. */
  56232. submitFrame(pose?: VRPose): void;
  56233. }
  56234. declare var VRDisplay: {
  56235. prototype: VRDisplay;
  56236. new(): VRDisplay;
  56237. };
  56238. interface VRLayer {
  56239. leftBounds?: number[] | Float32Array | null;
  56240. rightBounds?: number[] | Float32Array | null;
  56241. source?: HTMLCanvasElement | null;
  56242. }
  56243. interface VRDisplayCapabilities {
  56244. readonly canPresent: boolean;
  56245. readonly hasExternalDisplay: boolean;
  56246. readonly hasOrientation: boolean;
  56247. readonly hasPosition: boolean;
  56248. readonly maxLayers: number;
  56249. }
  56250. interface VREyeParameters {
  56251. /** @deprecated */
  56252. readonly fieldOfView: VRFieldOfView;
  56253. readonly offset: Float32Array;
  56254. readonly renderHeight: number;
  56255. readonly renderWidth: number;
  56256. }
  56257. interface VRFieldOfView {
  56258. readonly downDegrees: number;
  56259. readonly leftDegrees: number;
  56260. readonly rightDegrees: number;
  56261. readonly upDegrees: number;
  56262. }
  56263. interface VRFrameData {
  56264. readonly leftProjectionMatrix: Float32Array;
  56265. readonly leftViewMatrix: Float32Array;
  56266. readonly pose: VRPose;
  56267. readonly rightProjectionMatrix: Float32Array;
  56268. readonly rightViewMatrix: Float32Array;
  56269. readonly timestamp: number;
  56270. }
  56271. interface VRPose {
  56272. readonly angularAcceleration: Float32Array | null;
  56273. readonly angularVelocity: Float32Array | null;
  56274. readonly linearAcceleration: Float32Array | null;
  56275. readonly linearVelocity: Float32Array | null;
  56276. readonly orientation: Float32Array | null;
  56277. readonly position: Float32Array | null;
  56278. readonly timestamp: number;
  56279. }
  56280. interface VRStageParameters {
  56281. sittingToStandingTransform?: Float32Array;
  56282. sizeX?: number;
  56283. sizeY?: number;
  56284. }
  56285. interface Navigator {
  56286. getVRDisplays(): Promise<VRDisplay[]>;
  56287. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56288. }
  56289. interface Window {
  56290. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56291. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56292. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56293. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56294. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56295. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56296. }
  56297. interface Gamepad {
  56298. readonly displayId: number;
  56299. }
  56300. interface XRDevice {
  56301. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56302. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56303. }
  56304. interface XRSession {
  56305. getInputSources(): Array<any>;
  56306. baseLayer: XRWebGLLayer;
  56307. requestFrameOfReference(type: string): Promise<void>;
  56308. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56309. end(): Promise<void>;
  56310. requestAnimationFrame: Function;
  56311. addEventListener: Function;
  56312. }
  56313. interface XRSessionCreationOptions {
  56314. outputContext?: WebGLRenderingContext | null;
  56315. immersive?: boolean;
  56316. environmentIntegration?: boolean;
  56317. }
  56318. interface XRLayer {
  56319. getViewport: Function;
  56320. framebufferWidth: number;
  56321. framebufferHeight: number;
  56322. }
  56323. interface XRView {
  56324. projectionMatrix: Float32Array;
  56325. }
  56326. interface XRFrame {
  56327. getDevicePose: Function;
  56328. getInputPose: Function;
  56329. views: Array<XRView>;
  56330. baseLayer: XRLayer;
  56331. }
  56332. interface XRFrameOfReference {
  56333. }
  56334. interface XRWebGLLayer extends XRLayer {
  56335. framebuffer: WebGLFramebuffer;
  56336. }
  56337. declare var XRWebGLLayer: {
  56338. prototype: XRWebGLLayer;
  56339. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56340. };