babylon.d.ts 2.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = nearest */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Classed used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * This function is deprecated. Use FromArray instead
  2671. * @param array defines the source array
  2672. * @param offset defines the offset in the source array
  2673. * @returns the new Vector3
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * This function is deprecated. Use FromArrayToRef instead.
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Creates a right-handed perspective projection matrix
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed perspective projection matrix
  4467. */
  4468. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed perspective projection into a given matrix
  4471. * @param fov defines the horizontal field of view
  4472. * @param aspect defines the aspect ratio
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4477. */
  4478. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4479. /**
  4480. * Stores a perspective projection for WebVR info a given matrix
  4481. * @param fov defines the field of view
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @param result defines the target matrix
  4485. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4486. */
  4487. static PerspectiveFovWebVRToRef(fov: {
  4488. upDegrees: number;
  4489. downDegrees: number;
  4490. leftDegrees: number;
  4491. rightDegrees: number;
  4492. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4493. /**
  4494. * Computes a complete transformation matrix
  4495. * @param viewport defines the viewport to use
  4496. * @param world defines the world matrix
  4497. * @param view defines the view matrix
  4498. * @param projection defines the projection matrix
  4499. * @param zmin defines the near clip plane
  4500. * @param zmax defines the far clip plane
  4501. * @returns the transformation matrix
  4502. */
  4503. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4504. /**
  4505. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4506. * @param matrix defines the matrix to use
  4507. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4508. */
  4509. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4510. /**
  4511. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4512. * @param matrix defines the matrix to use
  4513. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4514. */
  4515. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4516. /**
  4517. * Compute the transpose of a given matrix
  4518. * @param matrix defines the matrix to transpose
  4519. * @returns the new matrix
  4520. */
  4521. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4522. /**
  4523. * Compute the transpose of a matrix and store it in a target matrix
  4524. * @param matrix defines the matrix to transpose
  4525. * @param result defines the target matrix
  4526. */
  4527. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4528. /**
  4529. * Computes a reflection matrix from a plane
  4530. * @param plane defines the reflection plane
  4531. * @returns a new matrix
  4532. */
  4533. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4534. /**
  4535. * Computes a reflection matrix from a plane
  4536. * @param plane defines the reflection plane
  4537. * @param result defines the target matrix
  4538. */
  4539. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4540. /**
  4541. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4542. * @param xaxis defines the value of the 1st axis
  4543. * @param yaxis defines the value of the 2nd axis
  4544. * @param zaxis defines the value of the 3rd axis
  4545. * @param result defines the target matrix
  4546. */
  4547. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4550. * @param quat defines the quaternion to use
  4551. * @param result defines the target matrix
  4552. */
  4553. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4554. }
  4555. /**
  4556. * @hidden
  4557. */
  4558. export class TmpVectors {
  4559. static Vector2: Vector2[];
  4560. static Vector3: Vector3[];
  4561. static Vector4: Vector4[];
  4562. static Quaternion: Quaternion[];
  4563. static Matrix: Matrix[];
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Defines potential orientation for back face culling
  4569. */
  4570. export enum Orientation {
  4571. /**
  4572. * Clockwise
  4573. */
  4574. CW = 0,
  4575. /** Counter clockwise */
  4576. CCW = 1
  4577. }
  4578. /** Class used to represent a Bezier curve */
  4579. export class BezierCurve {
  4580. /**
  4581. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4582. * @param t defines the time
  4583. * @param x1 defines the left coordinate on X axis
  4584. * @param y1 defines the left coordinate on Y axis
  4585. * @param x2 defines the right coordinate on X axis
  4586. * @param y2 defines the right coordinate on Y axis
  4587. * @returns the interpolated value
  4588. */
  4589. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4590. }
  4591. /**
  4592. * Defines angle representation
  4593. */
  4594. export class Angle {
  4595. private _radians;
  4596. /**
  4597. * Creates an Angle object of "radians" radians (float).
  4598. * @param radians the angle in radians
  4599. */
  4600. constructor(radians: number);
  4601. /**
  4602. * Get value in degrees
  4603. * @returns the Angle value in degrees (float)
  4604. */
  4605. degrees(): number;
  4606. /**
  4607. * Get value in radians
  4608. * @returns the Angle value in radians (float)
  4609. */
  4610. radians(): number;
  4611. /**
  4612. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4613. * @param a defines first vector
  4614. * @param b defines second vector
  4615. * @returns a new Angle
  4616. */
  4617. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4618. /**
  4619. * Gets a new Angle object from the given float in radians
  4620. * @param radians defines the angle value in radians
  4621. * @returns a new Angle
  4622. */
  4623. static FromRadians(radians: number): Angle;
  4624. /**
  4625. * Gets a new Angle object from the given float in degrees
  4626. * @param degrees defines the angle value in degrees
  4627. * @returns a new Angle
  4628. */
  4629. static FromDegrees(degrees: number): Angle;
  4630. }
  4631. /**
  4632. * This represents an arc in a 2d space.
  4633. */
  4634. export class Arc2 {
  4635. /** Defines the start point of the arc */
  4636. startPoint: Vector2;
  4637. /** Defines the mid point of the arc */
  4638. midPoint: Vector2;
  4639. /** Defines the end point of the arc */
  4640. endPoint: Vector2;
  4641. /**
  4642. * Defines the center point of the arc.
  4643. */
  4644. centerPoint: Vector2;
  4645. /**
  4646. * Defines the radius of the arc.
  4647. */
  4648. radius: number;
  4649. /**
  4650. * Defines the angle of the arc (from mid point to end point).
  4651. */
  4652. angle: Angle;
  4653. /**
  4654. * Defines the start angle of the arc (from start point to middle point).
  4655. */
  4656. startAngle: Angle;
  4657. /**
  4658. * Defines the orientation of the arc (clock wise/counter clock wise).
  4659. */
  4660. orientation: Orientation;
  4661. /**
  4662. * Creates an Arc object from the three given points : start, middle and end.
  4663. * @param startPoint Defines the start point of the arc
  4664. * @param midPoint Defines the midlle point of the arc
  4665. * @param endPoint Defines the end point of the arc
  4666. */
  4667. constructor(
  4668. /** Defines the start point of the arc */
  4669. startPoint: Vector2,
  4670. /** Defines the mid point of the arc */
  4671. midPoint: Vector2,
  4672. /** Defines the end point of the arc */
  4673. endPoint: Vector2);
  4674. }
  4675. /**
  4676. * Represents a 2D path made up of multiple 2D points
  4677. */
  4678. export class Path2 {
  4679. private _points;
  4680. private _length;
  4681. /**
  4682. * If the path start and end point are the same
  4683. */
  4684. closed: boolean;
  4685. /**
  4686. * Creates a Path2 object from the starting 2D coordinates x and y.
  4687. * @param x the starting points x value
  4688. * @param y the starting points y value
  4689. */
  4690. constructor(x: number, y: number);
  4691. /**
  4692. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4693. * @param x the added points x value
  4694. * @param y the added points y value
  4695. * @returns the updated Path2.
  4696. */
  4697. addLineTo(x: number, y: number): Path2;
  4698. /**
  4699. * 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.
  4700. * @param midX middle point x value
  4701. * @param midY middle point y value
  4702. * @param endX end point x value
  4703. * @param endY end point y value
  4704. * @param numberOfSegments (default: 36)
  4705. * @returns the updated Path2.
  4706. */
  4707. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4708. /**
  4709. * Closes the Path2.
  4710. * @returns the Path2.
  4711. */
  4712. close(): Path2;
  4713. /**
  4714. * Gets the sum of the distance between each sequential point in the path
  4715. * @returns the Path2 total length (float).
  4716. */
  4717. length(): number;
  4718. /**
  4719. * Gets the points which construct the path
  4720. * @returns the Path2 internal array of points.
  4721. */
  4722. getPoints(): Vector2[];
  4723. /**
  4724. * Retreives the point at the distance aways from the starting point
  4725. * @param normalizedLengthPosition the length along the path to retreive the point from
  4726. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4727. */
  4728. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4729. /**
  4730. * Creates a new path starting from an x and y position
  4731. * @param x starting x value
  4732. * @param y starting y value
  4733. * @returns a new Path2 starting at the coordinates (x, y).
  4734. */
  4735. static StartingAt(x: number, y: number): Path2;
  4736. }
  4737. /**
  4738. * Represents a 3D path made up of multiple 3D points
  4739. */
  4740. export class Path3D {
  4741. /**
  4742. * an array of Vector3, the curve axis of the Path3D
  4743. */
  4744. path: Vector3[];
  4745. private _curve;
  4746. private _distances;
  4747. private _tangents;
  4748. private _normals;
  4749. private _binormals;
  4750. private _raw;
  4751. private _alignTangentsWithPath;
  4752. private readonly _pointAtData;
  4753. /**
  4754. * new Path3D(path, normal, raw)
  4755. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4756. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4757. * @param path an array of Vector3, the curve axis of the Path3D
  4758. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4759. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4760. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4761. */
  4762. constructor(
  4763. /**
  4764. * an array of Vector3, the curve axis of the Path3D
  4765. */
  4766. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4767. /**
  4768. * Returns the Path3D array of successive Vector3 designing its curve.
  4769. * @returns the Path3D array of successive Vector3 designing its curve.
  4770. */
  4771. getCurve(): Vector3[];
  4772. /**
  4773. * Returns the Path3D array of successive Vector3 designing its curve.
  4774. * @returns the Path3D array of successive Vector3 designing its curve.
  4775. */
  4776. getPoints(): Vector3[];
  4777. /**
  4778. * @returns the computed length (float) of the path.
  4779. */
  4780. length(): number;
  4781. /**
  4782. * Returns an array populated with tangent vectors on each Path3D curve point.
  4783. * @returns an array populated with tangent vectors on each Path3D curve point.
  4784. */
  4785. getTangents(): Vector3[];
  4786. /**
  4787. * Returns an array populated with normal vectors on each Path3D curve point.
  4788. * @returns an array populated with normal vectors on each Path3D curve point.
  4789. */
  4790. getNormals(): Vector3[];
  4791. /**
  4792. * Returns an array populated with binormal vectors on each Path3D curve point.
  4793. * @returns an array populated with binormal vectors on each Path3D curve point.
  4794. */
  4795. getBinormals(): Vector3[];
  4796. /**
  4797. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4798. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4799. */
  4800. getDistances(): number[];
  4801. /**
  4802. * Returns an interpolated point along this path
  4803. * @param position the position of the point along this path, from 0.0 to 1.0
  4804. * @returns a new Vector3 as the point
  4805. */
  4806. getPointAt(position: number): Vector3;
  4807. /**
  4808. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4809. * @param position the position of the point along this path, from 0.0 to 1.0
  4810. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4811. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4812. */
  4813. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4814. /**
  4815. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4816. * @param position the position of the point along this path, from 0.0 to 1.0
  4817. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4818. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4819. */
  4820. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4821. /**
  4822. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4823. * @param position the position of the point along this path, from 0.0 to 1.0
  4824. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4825. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4826. */
  4827. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4828. /**
  4829. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4830. * @param position the position of the point along this path, from 0.0 to 1.0
  4831. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4832. */
  4833. getDistanceAt(position: number): number;
  4834. /**
  4835. * Returns the array index of the previous point of an interpolated point along this path
  4836. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4837. * @returns the array index
  4838. */
  4839. getPreviousPointIndexAt(position: number): number;
  4840. /**
  4841. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4842. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4843. * @returns the sub position
  4844. */
  4845. getSubPositionAt(position: number): number;
  4846. /**
  4847. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4848. * @param target the vector of which to get the closest position to
  4849. * @returns the position of the closest virtual point on this path to the target vector
  4850. */
  4851. getClosestPositionTo(target: Vector3): number;
  4852. /**
  4853. * Returns a sub path (slice) of this path
  4854. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4855. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4856. * @returns a sub path (slice) of this path
  4857. */
  4858. slice(start?: number, end?: number): Path3D;
  4859. /**
  4860. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4861. * @param path path which all values are copied into the curves points
  4862. * @param firstNormal which should be projected onto the curve
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4864. * @returns the same object updated.
  4865. */
  4866. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4867. private _compute;
  4868. private _getFirstNonNullVector;
  4869. private _getLastNonNullVector;
  4870. private _normalVector;
  4871. /**
  4872. * Updates the point at data for an interpolated point along this curve
  4873. * @param position the position of the point along this curve, from 0.0 to 1.0
  4874. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4875. * @returns the (updated) point at data
  4876. */
  4877. private _updatePointAtData;
  4878. /**
  4879. * Updates the point at data from the specified parameters
  4880. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4881. * @param point the interpolated point
  4882. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4883. */
  4884. private _setPointAtData;
  4885. /**
  4886. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4887. */
  4888. private _updateInterpolationMatrix;
  4889. }
  4890. /**
  4891. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4892. * A Curve3 is designed from a series of successive Vector3.
  4893. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4894. */
  4895. export class Curve3 {
  4896. private _points;
  4897. private _length;
  4898. /**
  4899. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4900. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4901. * @param v1 (Vector3) the control point
  4902. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4903. * @param nbPoints (integer) the wanted number of points in the curve
  4904. * @returns the created Curve3
  4905. */
  4906. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4907. /**
  4908. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4909. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4910. * @param v1 (Vector3) the first control point
  4911. * @param v2 (Vector3) the second control point
  4912. * @param v3 (Vector3) the end point of the Cubic Bezier
  4913. * @param nbPoints (integer) the wanted number of points in the curve
  4914. * @returns the created Curve3
  4915. */
  4916. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4917. /**
  4918. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4919. * @param p1 (Vector3) the origin point of the Hermite Spline
  4920. * @param t1 (Vector3) the tangent vector at the origin point
  4921. * @param p2 (Vector3) the end point of the Hermite Spline
  4922. * @param t2 (Vector3) the tangent vector at the end point
  4923. * @param nbPoints (integer) the wanted number of points in the curve
  4924. * @returns the created Curve3
  4925. */
  4926. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4927. /**
  4928. * Returns a Curve3 object along a CatmullRom Spline curve :
  4929. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4930. * @param nbPoints (integer) the wanted number of points between each curve control points
  4931. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4932. * @returns the created Curve3
  4933. */
  4934. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4935. /**
  4936. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4937. * A Curve3 is designed from a series of successive Vector3.
  4938. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4939. * @param points points which make up the curve
  4940. */
  4941. constructor(points: Vector3[]);
  4942. /**
  4943. * @returns the Curve3 stored array of successive Vector3
  4944. */
  4945. getPoints(): Vector3[];
  4946. /**
  4947. * @returns the computed length (float) of the curve.
  4948. */
  4949. length(): number;
  4950. /**
  4951. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4952. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4953. * curveA and curveB keep unchanged.
  4954. * @param curve the curve to continue from this curve
  4955. * @returns the newly constructed curve
  4956. */
  4957. continue(curve: DeepImmutable<Curve3>): Curve3;
  4958. private _computeLength;
  4959. }
  4960. }
  4961. declare module BABYLON {
  4962. /**
  4963. * This represents the main contract an easing function should follow.
  4964. * Easing functions are used throughout the animation system.
  4965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4966. */
  4967. export interface IEasingFunction {
  4968. /**
  4969. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4970. * of the easing function.
  4971. * The link below provides some of the most common examples of easing functions.
  4972. * @see https://easings.net/
  4973. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4974. * @returns the corresponding value on the curve defined by the easing function
  4975. */
  4976. ease(gradient: number): number;
  4977. }
  4978. /**
  4979. * Base class used for every default easing function.
  4980. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4981. */
  4982. export class EasingFunction implements IEasingFunction {
  4983. /**
  4984. * Interpolation follows the mathematical formula associated with the easing function.
  4985. */
  4986. static readonly EASINGMODE_EASEIN: number;
  4987. /**
  4988. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4989. */
  4990. static readonly EASINGMODE_EASEOUT: number;
  4991. /**
  4992. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4993. */
  4994. static readonly EASINGMODE_EASEINOUT: number;
  4995. private _easingMode;
  4996. /**
  4997. * Sets the easing mode of the current function.
  4998. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4999. */
  5000. setEasingMode(easingMode: number): void;
  5001. /**
  5002. * Gets the current easing mode.
  5003. * @returns the easing mode
  5004. */
  5005. getEasingMode(): number;
  5006. /**
  5007. * @hidden
  5008. */
  5009. easeInCore(gradient: number): number;
  5010. /**
  5011. * Given an input gradient between 0 and 1, this returns the corresponding value
  5012. * of the easing function.
  5013. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5014. * @returns the corresponding value on the curve defined by the easing function
  5015. */
  5016. ease(gradient: number): number;
  5017. }
  5018. /**
  5019. * Easing function with a circle shape (see link below).
  5020. * @see https://easings.net/#easeInCirc
  5021. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5022. */
  5023. export class CircleEase extends EasingFunction implements IEasingFunction {
  5024. /** @hidden */
  5025. easeInCore(gradient: number): number;
  5026. }
  5027. /**
  5028. * Easing function with a ease back shape (see link below).
  5029. * @see https://easings.net/#easeInBack
  5030. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5031. */
  5032. export class BackEase extends EasingFunction implements IEasingFunction {
  5033. /** Defines the amplitude of the function */
  5034. amplitude: number;
  5035. /**
  5036. * Instantiates a back ease easing
  5037. * @see https://easings.net/#easeInBack
  5038. * @param amplitude Defines the amplitude of the function
  5039. */
  5040. constructor(
  5041. /** Defines the amplitude of the function */
  5042. amplitude?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a bouncing shape (see link below).
  5048. * @see https://easings.net/#easeInBounce
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class BounceEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the number of bounces */
  5053. bounces: number;
  5054. /** Defines the amplitude of the bounce */
  5055. bounciness: number;
  5056. /**
  5057. * Instantiates a bounce easing
  5058. * @see https://easings.net/#easeInBounce
  5059. * @param bounces Defines the number of bounces
  5060. * @param bounciness Defines the amplitude of the bounce
  5061. */
  5062. constructor(
  5063. /** Defines the number of bounces */
  5064. bounces?: number,
  5065. /** Defines the amplitude of the bounce */
  5066. bounciness?: number);
  5067. /** @hidden */
  5068. easeInCore(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a power of 3 shape (see link below).
  5072. * @see https://easings.net/#easeInCubic
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CubicEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with an elastic shape (see link below).
  5081. * @see https://easings.net/#easeInElastic
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the number of oscillations*/
  5086. oscillations: number;
  5087. /** Defines the amplitude of the oscillations*/
  5088. springiness: number;
  5089. /**
  5090. * Instantiates an elastic easing function
  5091. * @see https://easings.net/#easeInElastic
  5092. * @param oscillations Defines the number of oscillations
  5093. * @param springiness Defines the amplitude of the oscillations
  5094. */
  5095. constructor(
  5096. /** Defines the number of oscillations*/
  5097. oscillations?: number,
  5098. /** Defines the amplitude of the oscillations*/
  5099. springiness?: number);
  5100. /** @hidden */
  5101. easeInCore(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with an exponential shape (see link below).
  5105. * @see https://easings.net/#easeInExpo
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5109. /** Defines the exponent of the function */
  5110. exponent: number;
  5111. /**
  5112. * Instantiates an exponential easing function
  5113. * @see https://easings.net/#easeInExpo
  5114. * @param exponent Defines the exponent of the function
  5115. */
  5116. constructor(
  5117. /** Defines the exponent of the function */
  5118. exponent?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power shape (see link below).
  5124. * @see https://easings.net/#easeInQuad
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class PowerEase extends EasingFunction implements IEasingFunction {
  5128. /** Defines the power of the function */
  5129. power: number;
  5130. /**
  5131. * Instantiates an power base easing function
  5132. * @see https://easings.net/#easeInQuad
  5133. * @param power Defines the power of the function
  5134. */
  5135. constructor(
  5136. /** Defines the power of the function */
  5137. power?: number);
  5138. /** @hidden */
  5139. easeInCore(gradient: number): number;
  5140. }
  5141. /**
  5142. * Easing function with a power of 2 shape (see link below).
  5143. * @see https://easings.net/#easeInQuad
  5144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5145. */
  5146. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5147. /** @hidden */
  5148. easeInCore(gradient: number): number;
  5149. }
  5150. /**
  5151. * Easing function with a power of 4 shape (see link below).
  5152. * @see https://easings.net/#easeInQuart
  5153. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5154. */
  5155. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5156. /** @hidden */
  5157. easeInCore(gradient: number): number;
  5158. }
  5159. /**
  5160. * Easing function with a power of 5 shape (see link below).
  5161. * @see https://easings.net/#easeInQuint
  5162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5163. */
  5164. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5165. /** @hidden */
  5166. easeInCore(gradient: number): number;
  5167. }
  5168. /**
  5169. * Easing function with a sin shape (see link below).
  5170. * @see https://easings.net/#easeInSine
  5171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5172. */
  5173. export class SineEase extends EasingFunction implements IEasingFunction {
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a bezier shape (see link below).
  5179. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5183. /** Defines the x component of the start tangent in the bezier curve */
  5184. x1: number;
  5185. /** Defines the y component of the start tangent in the bezier curve */
  5186. y1: number;
  5187. /** Defines the x component of the end tangent in the bezier curve */
  5188. x2: number;
  5189. /** Defines the y component of the end tangent in the bezier curve */
  5190. y2: number;
  5191. /**
  5192. * Instantiates a bezier function
  5193. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5194. * @param x1 Defines the x component of the start tangent in the bezier curve
  5195. * @param y1 Defines the y component of the start tangent in the bezier curve
  5196. * @param x2 Defines the x component of the end tangent in the bezier curve
  5197. * @param y2 Defines the y component of the end tangent in the bezier curve
  5198. */
  5199. constructor(
  5200. /** Defines the x component of the start tangent in the bezier curve */
  5201. x1?: number,
  5202. /** Defines the y component of the start tangent in the bezier curve */
  5203. y1?: number,
  5204. /** Defines the x component of the end tangent in the bezier curve */
  5205. x2?: number,
  5206. /** Defines the y component of the end tangent in the bezier curve */
  5207. y2?: number);
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. }
  5212. declare module BABYLON {
  5213. /**
  5214. * Class used to hold a RBG color
  5215. */
  5216. export class Color3 {
  5217. /**
  5218. * Defines the red component (between 0 and 1, default is 0)
  5219. */
  5220. r: number;
  5221. /**
  5222. * Defines the green component (between 0 and 1, default is 0)
  5223. */
  5224. g: number;
  5225. /**
  5226. * Defines the blue component (between 0 and 1, default is 0)
  5227. */
  5228. b: number;
  5229. /**
  5230. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5231. * @param r defines the red component (between 0 and 1, default is 0)
  5232. * @param g defines the green component (between 0 and 1, default is 0)
  5233. * @param b defines the blue component (between 0 and 1, default is 0)
  5234. */
  5235. constructor(
  5236. /**
  5237. * Defines the red component (between 0 and 1, default is 0)
  5238. */
  5239. r?: number,
  5240. /**
  5241. * Defines the green component (between 0 and 1, default is 0)
  5242. */
  5243. g?: number,
  5244. /**
  5245. * Defines the blue component (between 0 and 1, default is 0)
  5246. */
  5247. b?: number);
  5248. /**
  5249. * Creates a string with the Color3 current values
  5250. * @returns the string representation of the Color3 object
  5251. */
  5252. toString(): string;
  5253. /**
  5254. * Returns the string "Color3"
  5255. * @returns "Color3"
  5256. */
  5257. getClassName(): string;
  5258. /**
  5259. * Compute the Color3 hash code
  5260. * @returns an unique number that can be used to hash Color3 objects
  5261. */
  5262. getHashCode(): number;
  5263. /**
  5264. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5265. * @param array defines the array where to store the r,g,b components
  5266. * @param index defines an optional index in the target array to define where to start storing values
  5267. * @returns the current Color3 object
  5268. */
  5269. toArray(array: FloatArray, index?: number): Color3;
  5270. /**
  5271. * Returns a new Color4 object from the current Color3 and the given alpha
  5272. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5273. * @returns a new Color4 object
  5274. */
  5275. toColor4(alpha?: number): Color4;
  5276. /**
  5277. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5278. * @returns the new array
  5279. */
  5280. asArray(): number[];
  5281. /**
  5282. * Returns the luminance value
  5283. * @returns a float value
  5284. */
  5285. toLuminance(): number;
  5286. /**
  5287. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5288. * @param otherColor defines the second operand
  5289. * @returns the new Color3 object
  5290. */
  5291. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5292. /**
  5293. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5294. * @param otherColor defines the second operand
  5295. * @param result defines the Color3 object where to store the result
  5296. * @returns the current Color3
  5297. */
  5298. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5299. /**
  5300. * Determines equality between Color3 objects
  5301. * @param otherColor defines the second operand
  5302. * @returns true if the rgb values are equal to the given ones
  5303. */
  5304. equals(otherColor: DeepImmutable<Color3>): boolean;
  5305. /**
  5306. * Determines equality between the current Color3 object and a set of r,b,g values
  5307. * @param r defines the red component to check
  5308. * @param g defines the green component to check
  5309. * @param b defines the blue component to check
  5310. * @returns true if the rgb values are equal to the given ones
  5311. */
  5312. equalsFloats(r: number, g: number, b: number): boolean;
  5313. /**
  5314. * Multiplies in place each rgb value by scale
  5315. * @param scale defines the scaling factor
  5316. * @returns the updated Color3
  5317. */
  5318. scale(scale: number): Color3;
  5319. /**
  5320. * Multiplies the rgb values by scale and stores the result into "result"
  5321. * @param scale defines the scaling factor
  5322. * @param result defines the Color3 object where to store the result
  5323. * @returns the unmodified current Color3
  5324. */
  5325. scaleToRef(scale: number, result: Color3): Color3;
  5326. /**
  5327. * Scale the current Color3 values by a factor and add the result to a given Color3
  5328. * @param scale defines the scale factor
  5329. * @param result defines color to store the result into
  5330. * @returns the unmodified current Color3
  5331. */
  5332. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5333. /**
  5334. * Clamps the rgb values by the min and max values and stores the result into "result"
  5335. * @param min defines minimum clamping value (default is 0)
  5336. * @param max defines maximum clamping value (default is 1)
  5337. * @param result defines color to store the result into
  5338. * @returns the original Color3
  5339. */
  5340. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5341. /**
  5342. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5343. * @param otherColor defines the second operand
  5344. * @returns the new Color3
  5345. */
  5346. add(otherColor: DeepImmutable<Color3>): Color3;
  5347. /**
  5348. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5349. * @param otherColor defines the second operand
  5350. * @param result defines Color3 object to store the result into
  5351. * @returns the unmodified current Color3
  5352. */
  5353. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5354. /**
  5355. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3
  5358. */
  5359. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines Color3 object to store the result into
  5364. * @returns the unmodified current Color3
  5365. */
  5366. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Copy the current object
  5369. * @returns a new Color3 copied the current one
  5370. */
  5371. clone(): Color3;
  5372. /**
  5373. * Copies the rgb values from the source in the current Color3
  5374. * @param source defines the source Color3 object
  5375. * @returns the updated Color3 object
  5376. */
  5377. copyFrom(source: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Updates the Color3 rgb values from the given floats
  5380. * @param r defines the red component to read from
  5381. * @param g defines the green component to read from
  5382. * @param b defines the blue component to read from
  5383. * @returns the current Color3 object
  5384. */
  5385. copyFromFloats(r: number, g: number, b: number): Color3;
  5386. /**
  5387. * Updates the Color3 rgb values from the given floats
  5388. * @param r defines the red component to read from
  5389. * @param g defines the green component to read from
  5390. * @param b defines the blue component to read from
  5391. * @returns the current Color3 object
  5392. */
  5393. set(r: number, g: number, b: number): Color3;
  5394. /**
  5395. * Compute the Color3 hexadecimal code as a string
  5396. * @returns a string containing the hexadecimal representation of the Color3 object
  5397. */
  5398. toHexString(): string;
  5399. /**
  5400. * Computes a new Color3 converted from the current one to linear space
  5401. * @returns a new Color3 object
  5402. */
  5403. toLinearSpace(): Color3;
  5404. /**
  5405. * Converts current color in rgb space to HSV values
  5406. * @returns a new color3 representing the HSV values
  5407. */
  5408. toHSV(): Color3;
  5409. /**
  5410. * Converts current color in rgb space to HSV values
  5411. * @param result defines the Color3 where to store the HSV values
  5412. */
  5413. toHSVToRef(result: Color3): void;
  5414. /**
  5415. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5416. * @param convertedColor defines the Color3 object where to store the linear space version
  5417. * @returns the unmodified Color3
  5418. */
  5419. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5420. /**
  5421. * Computes a new Color3 converted from the current one to gamma space
  5422. * @returns a new Color3 object
  5423. */
  5424. toGammaSpace(): Color3;
  5425. /**
  5426. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5427. * @param convertedColor defines the Color3 object where to store the gamma space version
  5428. * @returns the unmodified Color3
  5429. */
  5430. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5431. private static _BlackReadOnly;
  5432. /**
  5433. * Convert Hue, saturation and value to a Color3 (RGB)
  5434. * @param hue defines the hue
  5435. * @param saturation defines the saturation
  5436. * @param value defines the value
  5437. * @param result defines the Color3 where to store the RGB values
  5438. */
  5439. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5440. /**
  5441. * Creates a new Color3 from the string containing valid hexadecimal values
  5442. * @param hex defines a string containing valid hexadecimal values
  5443. * @returns a new Color3 object
  5444. */
  5445. static FromHexString(hex: string): Color3;
  5446. /**
  5447. * Creates a new Color3 from the starting index of the given array
  5448. * @param array defines the source array
  5449. * @param offset defines an offset in the source array
  5450. * @returns a new Color3 object
  5451. */
  5452. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5453. /**
  5454. * Creates a new Color3 from integer values (< 256)
  5455. * @param r defines the red component to read from (value between 0 and 255)
  5456. * @param g defines the green component to read from (value between 0 and 255)
  5457. * @param b defines the blue component to read from (value between 0 and 255)
  5458. * @returns a new Color3 object
  5459. */
  5460. static FromInts(r: number, g: number, b: number): Color3;
  5461. /**
  5462. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5463. * @param start defines the start Color3 value
  5464. * @param end defines the end Color3 value
  5465. * @param amount defines the gradient value between start and end
  5466. * @returns a new Color3 object
  5467. */
  5468. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5469. /**
  5470. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5471. * @param left defines the start value
  5472. * @param right defines the end value
  5473. * @param amount defines the gradient factor
  5474. * @param result defines the Color3 object where to store the result
  5475. */
  5476. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5477. /**
  5478. * Returns a Color3 value containing a red color
  5479. * @returns a new Color3 object
  5480. */
  5481. static Red(): Color3;
  5482. /**
  5483. * Returns a Color3 value containing a green color
  5484. * @returns a new Color3 object
  5485. */
  5486. static Green(): Color3;
  5487. /**
  5488. * Returns a Color3 value containing a blue color
  5489. * @returns a new Color3 object
  5490. */
  5491. static Blue(): Color3;
  5492. /**
  5493. * Returns a Color3 value containing a black color
  5494. * @returns a new Color3 object
  5495. */
  5496. static Black(): Color3;
  5497. /**
  5498. * Gets a Color3 value containing a black color that must not be updated
  5499. */
  5500. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5501. /**
  5502. * Returns a Color3 value containing a white color
  5503. * @returns a new Color3 object
  5504. */
  5505. static White(): Color3;
  5506. /**
  5507. * Returns a Color3 value containing a purple color
  5508. * @returns a new Color3 object
  5509. */
  5510. static Purple(): Color3;
  5511. /**
  5512. * Returns a Color3 value containing a magenta color
  5513. * @returns a new Color3 object
  5514. */
  5515. static Magenta(): Color3;
  5516. /**
  5517. * Returns a Color3 value containing a yellow color
  5518. * @returns a new Color3 object
  5519. */
  5520. static Yellow(): Color3;
  5521. /**
  5522. * Returns a Color3 value containing a gray color
  5523. * @returns a new Color3 object
  5524. */
  5525. static Gray(): Color3;
  5526. /**
  5527. * Returns a Color3 value containing a teal color
  5528. * @returns a new Color3 object
  5529. */
  5530. static Teal(): Color3;
  5531. /**
  5532. * Returns a Color3 value containing a random color
  5533. * @returns a new Color3 object
  5534. */
  5535. static Random(): Color3;
  5536. }
  5537. /**
  5538. * Class used to hold a RBGA color
  5539. */
  5540. export class Color4 {
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r: number;
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g: number;
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b: number;
  5553. /**
  5554. * Defines the alpha component (between 0 and 1, default is 1)
  5555. */
  5556. a: number;
  5557. /**
  5558. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5559. * @param r defines the red component (between 0 and 1, default is 0)
  5560. * @param g defines the green component (between 0 and 1, default is 0)
  5561. * @param b defines the blue component (between 0 and 1, default is 0)
  5562. * @param a defines the alpha component (between 0 and 1, default is 1)
  5563. */
  5564. constructor(
  5565. /**
  5566. * Defines the red component (between 0 and 1, default is 0)
  5567. */
  5568. r?: number,
  5569. /**
  5570. * Defines the green component (between 0 and 1, default is 0)
  5571. */
  5572. g?: number,
  5573. /**
  5574. * Defines the blue component (between 0 and 1, default is 0)
  5575. */
  5576. b?: number,
  5577. /**
  5578. * Defines the alpha component (between 0 and 1, default is 1)
  5579. */
  5580. a?: number);
  5581. /**
  5582. * Adds in place the given Color4 values to the current Color4 object
  5583. * @param right defines the second operand
  5584. * @returns the current updated Color4 object
  5585. */
  5586. addInPlace(right: DeepImmutable<Color4>): Color4;
  5587. /**
  5588. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Stores from the starting index in the given array the Color4 successive values
  5594. * @param array defines the array where to store the r,g,b components
  5595. * @param index defines an optional index in the target array to define where to start storing values
  5596. * @returns the current Color4 object
  5597. */
  5598. toArray(array: number[], index?: number): Color4;
  5599. /**
  5600. * Determines equality between Color4 objects
  5601. * @param otherColor defines the second operand
  5602. * @returns true if the rgba values are equal to the given ones
  5603. */
  5604. equals(otherColor: DeepImmutable<Color4>): boolean;
  5605. /**
  5606. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5607. * @param right defines the second operand
  5608. * @returns a new Color4 object
  5609. */
  5610. add(right: DeepImmutable<Color4>): Color4;
  5611. /**
  5612. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5613. * @param right defines the second operand
  5614. * @returns a new Color4 object
  5615. */
  5616. subtract(right: DeepImmutable<Color4>): Color4;
  5617. /**
  5618. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5619. * @param right defines the second operand
  5620. * @param result defines the Color4 object where to store the result
  5621. * @returns the current Color4 object
  5622. */
  5623. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 with the current Color4 values multiplied by scale
  5626. * @param scale defines the scaling factor to apply
  5627. * @returns a new Color4 object
  5628. */
  5629. scale(scale: number): Color4;
  5630. /**
  5631. * Multiplies the current Color4 values by scale and stores the result in "result"
  5632. * @param scale defines the scaling factor to apply
  5633. * @param result defines the Color4 object where to store the result
  5634. * @returns the current unmodified Color4
  5635. */
  5636. scaleToRef(scale: number, result: Color4): Color4;
  5637. /**
  5638. * Scale the current Color4 values by a factor and add the result to a given Color4
  5639. * @param scale defines the scale factor
  5640. * @param result defines the Color4 object where to store the result
  5641. * @returns the unmodified current Color4
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into.
  5649. * @returns the cuurent Color4
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5652. /**
  5653. * Multipy an Color4 value by another and return a new Color4 object
  5654. * @param color defines the Color4 value to multiply by
  5655. * @returns a new Color4 object
  5656. */
  5657. multiply(color: Color4): Color4;
  5658. /**
  5659. * Multipy a Color4 value by another and push the result in a reference value
  5660. * @param color defines the Color4 value to multiply by
  5661. * @param result defines the Color4 to fill the result in
  5662. * @returns the result Color4
  5663. */
  5664. multiplyToRef(color: Color4, result: Color4): Color4;
  5665. /**
  5666. * Creates a string with the Color4 current values
  5667. * @returns the string representation of the Color4 object
  5668. */
  5669. toString(): string;
  5670. /**
  5671. * Returns the string "Color4"
  5672. * @returns "Color4"
  5673. */
  5674. getClassName(): string;
  5675. /**
  5676. * Compute the Color4 hash code
  5677. * @returns an unique number that can be used to hash Color4 objects
  5678. */
  5679. getHashCode(): number;
  5680. /**
  5681. * Creates a new Color4 copied from the current one
  5682. * @returns a new Color4 object
  5683. */
  5684. clone(): Color4;
  5685. /**
  5686. * Copies the given Color4 values into the current one
  5687. * @param source defines the source Color4 object
  5688. * @returns the current updated Color4 object
  5689. */
  5690. copyFrom(source: Color4): Color4;
  5691. /**
  5692. * Copies the given float values into the current one
  5693. * @param r defines the red component to read from
  5694. * @param g defines the green component to read from
  5695. * @param b defines the blue component to read from
  5696. * @param a defines the alpha component to read from
  5697. * @returns the current updated Color4 object
  5698. */
  5699. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5700. /**
  5701. * Copies the given float values into the current one
  5702. * @param r defines the red component to read from
  5703. * @param g defines the green component to read from
  5704. * @param b defines the blue component to read from
  5705. * @param a defines the alpha component to read from
  5706. * @returns the current updated Color4 object
  5707. */
  5708. set(r: number, g: number, b: number, a: number): Color4;
  5709. /**
  5710. * Compute the Color4 hexadecimal code as a string
  5711. * @returns a string containing the hexadecimal representation of the Color4 object
  5712. */
  5713. toHexString(): string;
  5714. /**
  5715. * Computes a new Color4 converted from the current one to linear space
  5716. * @returns a new Color4 object
  5717. */
  5718. toLinearSpace(): Color4;
  5719. /**
  5720. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5721. * @param convertedColor defines the Color4 object where to store the linear space version
  5722. * @returns the unmodified Color4
  5723. */
  5724. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5725. /**
  5726. * Computes a new Color4 converted from the current one to gamma space
  5727. * @returns a new Color4 object
  5728. */
  5729. toGammaSpace(): Color4;
  5730. /**
  5731. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5732. * @param convertedColor defines the Color4 object where to store the gamma space version
  5733. * @returns the unmodified Color4
  5734. */
  5735. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5736. /**
  5737. * Creates a new Color4 from the string containing valid hexadecimal values
  5738. * @param hex defines a string containing valid hexadecimal values
  5739. * @returns a new Color4 object
  5740. */
  5741. static FromHexString(hex: string): Color4;
  5742. /**
  5743. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5744. * @param left defines the start value
  5745. * @param right defines the end value
  5746. * @param amount defines the gradient factor
  5747. * @returns a new Color4 object
  5748. */
  5749. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5750. /**
  5751. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5752. * @param left defines the start value
  5753. * @param right defines the end value
  5754. * @param amount defines the gradient factor
  5755. * @param result defines the Color4 object where to store data
  5756. */
  5757. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5758. /**
  5759. * Creates a new Color4 from a Color3 and an alpha value
  5760. * @param color3 defines the source Color3 to read from
  5761. * @param alpha defines the alpha component (1.0 by default)
  5762. * @returns a new Color4 object
  5763. */
  5764. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5765. /**
  5766. * Creates a new Color4 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @returns a new Color4 object
  5770. */
  5771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @param a defines the alpha component to read from (value between 0 and 255)
  5778. * @returns a new Color3 object
  5779. */
  5780. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5781. /**
  5782. * Check the content of a given array and convert it to an array containing RGBA data
  5783. * If the original array was already containing count * 4 values then it is returned directly
  5784. * @param colors defines the array to check
  5785. * @param count defines the number of RGBA data to expect
  5786. * @returns an array containing count * 4 values (RGBA)
  5787. */
  5788. static CheckColors4(colors: number[], count: number): number[];
  5789. }
  5790. /**
  5791. * @hidden
  5792. */
  5793. export class TmpColors {
  5794. static Color3: Color3[];
  5795. static Color4: Color4[];
  5796. }
  5797. }
  5798. declare module BABYLON {
  5799. /**
  5800. * Defines an interface which represents an animation key frame
  5801. */
  5802. export interface IAnimationKey {
  5803. /**
  5804. * Frame of the key frame
  5805. */
  5806. frame: number;
  5807. /**
  5808. * Value at the specifies key frame
  5809. */
  5810. value: any;
  5811. /**
  5812. * The input tangent for the cubic hermite spline
  5813. */
  5814. inTangent?: any;
  5815. /**
  5816. * The output tangent for the cubic hermite spline
  5817. */
  5818. outTangent?: any;
  5819. /**
  5820. * The animation interpolation type
  5821. */
  5822. interpolation?: AnimationKeyInterpolation;
  5823. }
  5824. /**
  5825. * Enum for the animation key frame interpolation type
  5826. */
  5827. export enum AnimationKeyInterpolation {
  5828. /**
  5829. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5830. */
  5831. STEP = 1
  5832. }
  5833. }
  5834. declare module BABYLON {
  5835. /**
  5836. * Represents the range of an animation
  5837. */
  5838. export class AnimationRange {
  5839. /**The name of the animation range**/
  5840. name: string;
  5841. /**The starting frame of the animation */
  5842. from: number;
  5843. /**The ending frame of the animation*/
  5844. to: number;
  5845. /**
  5846. * Initializes the range of an animation
  5847. * @param name The name of the animation range
  5848. * @param from The starting frame of the animation
  5849. * @param to The ending frame of the animation
  5850. */
  5851. constructor(
  5852. /**The name of the animation range**/
  5853. name: string,
  5854. /**The starting frame of the animation */
  5855. from: number,
  5856. /**The ending frame of the animation*/
  5857. to: number);
  5858. /**
  5859. * Makes a copy of the animation range
  5860. * @returns A copy of the animation range
  5861. */
  5862. clone(): AnimationRange;
  5863. }
  5864. }
  5865. declare module BABYLON {
  5866. /**
  5867. * Composed of a frame, and an action function
  5868. */
  5869. export class AnimationEvent {
  5870. /** The frame for which the event is triggered **/
  5871. frame: number;
  5872. /** The event to perform when triggered **/
  5873. action: (currentFrame: number) => void;
  5874. /** Specifies if the event should be triggered only once**/
  5875. onlyOnce?: boolean | undefined;
  5876. /**
  5877. * Specifies if the animation event is done
  5878. */
  5879. isDone: boolean;
  5880. /**
  5881. * Initializes the animation event
  5882. * @param frame The frame for which the event is triggered
  5883. * @param action The event to perform when triggered
  5884. * @param onlyOnce Specifies if the event should be triggered only once
  5885. */
  5886. constructor(
  5887. /** The frame for which the event is triggered **/
  5888. frame: number,
  5889. /** The event to perform when triggered **/
  5890. action: (currentFrame: number) => void,
  5891. /** Specifies if the event should be triggered only once**/
  5892. onlyOnce?: boolean | undefined);
  5893. /** @hidden */
  5894. _clone(): AnimationEvent;
  5895. }
  5896. }
  5897. declare module BABYLON {
  5898. /**
  5899. * Interface used to define a behavior
  5900. */
  5901. export interface Behavior<T> {
  5902. /** gets or sets behavior's name */
  5903. name: string;
  5904. /**
  5905. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5906. */
  5907. init(): void;
  5908. /**
  5909. * Called when the behavior is attached to a target
  5910. * @param target defines the target where the behavior is attached to
  5911. */
  5912. attach(target: T): void;
  5913. /**
  5914. * Called when the behavior is detached from its target
  5915. */
  5916. detach(): void;
  5917. }
  5918. /**
  5919. * Interface implemented by classes supporting behaviors
  5920. */
  5921. export interface IBehaviorAware<T> {
  5922. /**
  5923. * Attach a behavior
  5924. * @param behavior defines the behavior to attach
  5925. * @returns the current host
  5926. */
  5927. addBehavior(behavior: Behavior<T>): T;
  5928. /**
  5929. * Remove a behavior from the current object
  5930. * @param behavior defines the behavior to detach
  5931. * @returns the current host
  5932. */
  5933. removeBehavior(behavior: Behavior<T>): T;
  5934. /**
  5935. * Gets a behavior using its name to search
  5936. * @param name defines the name to search
  5937. * @returns the behavior or null if not found
  5938. */
  5939. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5940. }
  5941. }
  5942. declare module BABYLON {
  5943. /**
  5944. * Defines an array and its length.
  5945. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5946. */
  5947. export interface ISmartArrayLike<T> {
  5948. /**
  5949. * The data of the array.
  5950. */
  5951. data: Array<T>;
  5952. /**
  5953. * The active length of the array.
  5954. */
  5955. length: number;
  5956. }
  5957. /**
  5958. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5959. */
  5960. export class SmartArray<T> implements ISmartArrayLike<T> {
  5961. /**
  5962. * The full set of data from the array.
  5963. */
  5964. data: Array<T>;
  5965. /**
  5966. * The active length of the array.
  5967. */
  5968. length: number;
  5969. protected _id: number;
  5970. /**
  5971. * Instantiates a Smart Array.
  5972. * @param capacity defines the default capacity of the array.
  5973. */
  5974. constructor(capacity: number);
  5975. /**
  5976. * Pushes a value at the end of the active data.
  5977. * @param value defines the object to push in the array.
  5978. */
  5979. push(value: T): void;
  5980. /**
  5981. * Iterates over the active data and apply the lambda to them.
  5982. * @param func defines the action to apply on each value.
  5983. */
  5984. forEach(func: (content: T) => void): void;
  5985. /**
  5986. * Sorts the full sets of data.
  5987. * @param compareFn defines the comparison function to apply.
  5988. */
  5989. sort(compareFn: (a: T, b: T) => number): void;
  5990. /**
  5991. * Resets the active data to an empty array.
  5992. */
  5993. reset(): void;
  5994. /**
  5995. * Releases all the data from the array as well as the array.
  5996. */
  5997. dispose(): void;
  5998. /**
  5999. * Concats the active data with a given array.
  6000. * @param array defines the data to concatenate with.
  6001. */
  6002. concat(array: any): void;
  6003. /**
  6004. * Returns the position of a value in the active data.
  6005. * @param value defines the value to find the index for
  6006. * @returns the index if found in the active data otherwise -1
  6007. */
  6008. indexOf(value: T): number;
  6009. /**
  6010. * Returns whether an element is part of the active data.
  6011. * @param value defines the value to look for
  6012. * @returns true if found in the active data otherwise false
  6013. */
  6014. contains(value: T): boolean;
  6015. private static _GlobalId;
  6016. }
  6017. /**
  6018. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6019. * The data in this array can only be present once
  6020. */
  6021. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6022. private _duplicateId;
  6023. /**
  6024. * Pushes a value at the end of the active data.
  6025. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6026. * @param value defines the object to push in the array.
  6027. */
  6028. push(value: T): void;
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * If the data is already present, it won t be added again
  6032. * @param value defines the object to push in the array.
  6033. * @returns true if added false if it was already present
  6034. */
  6035. pushNoDuplicate(value: T): boolean;
  6036. /**
  6037. * Resets the active data to an empty array.
  6038. */
  6039. reset(): void;
  6040. /**
  6041. * Concats the active data with a given array.
  6042. * This ensures no dupplicate will be present in the result.
  6043. * @param array defines the data to concatenate with.
  6044. */
  6045. concatWithNoDuplicate(array: any): void;
  6046. }
  6047. }
  6048. declare module BABYLON {
  6049. /**
  6050. * @ignore
  6051. * This is a list of all the different input types that are available in the application.
  6052. * Fo instance: ArcRotateCameraGamepadInput...
  6053. */
  6054. export var CameraInputTypes: {};
  6055. /**
  6056. * This is the contract to implement in order to create a new input class.
  6057. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6058. */
  6059. export interface ICameraInput<TCamera extends Camera> {
  6060. /**
  6061. * Defines the camera the input is attached to.
  6062. */
  6063. camera: Nullable<TCamera>;
  6064. /**
  6065. * Gets the class name of the current intput.
  6066. * @returns the class name
  6067. */
  6068. getClassName(): string;
  6069. /**
  6070. * Get the friendly name associated with the input class.
  6071. * @returns the input friendly name
  6072. */
  6073. getSimpleName(): string;
  6074. /**
  6075. * Attach the input controls to a specific dom element to get the input from.
  6076. * @param element Defines the element the controls should be listened from
  6077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6078. */
  6079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6080. /**
  6081. * Detach the current controls from the specified dom element.
  6082. * @param element Defines the element to stop listening the inputs from
  6083. */
  6084. detachControl(element: Nullable<HTMLElement>): void;
  6085. /**
  6086. * Update the current camera state depending on the inputs that have been used this frame.
  6087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6088. */
  6089. checkInputs?: () => void;
  6090. }
  6091. /**
  6092. * Represents a map of input types to input instance or input index to input instance.
  6093. */
  6094. export interface CameraInputsMap<TCamera extends Camera> {
  6095. /**
  6096. * Accessor to the input by input type.
  6097. */
  6098. [name: string]: ICameraInput<TCamera>;
  6099. /**
  6100. * Accessor to the input by input index.
  6101. */
  6102. [idx: number]: ICameraInput<TCamera>;
  6103. }
  6104. /**
  6105. * This represents the input manager used within a camera.
  6106. * It helps dealing with all the different kind of input attached to a camera.
  6107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6108. */
  6109. export class CameraInputsManager<TCamera extends Camera> {
  6110. /**
  6111. * Defines the list of inputs attahed to the camera.
  6112. */
  6113. attached: CameraInputsMap<TCamera>;
  6114. /**
  6115. * Defines the dom element the camera is collecting inputs from.
  6116. * This is null if the controls have not been attached.
  6117. */
  6118. attachedElement: Nullable<HTMLElement>;
  6119. /**
  6120. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6121. */
  6122. noPreventDefault: boolean;
  6123. /**
  6124. * Defined the camera the input manager belongs to.
  6125. */
  6126. camera: TCamera;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs: () => void;
  6132. /**
  6133. * Instantiate a new Camera Input Manager.
  6134. * @param camera Defines the camera the input manager blongs to
  6135. */
  6136. constructor(camera: TCamera);
  6137. /**
  6138. * Add an input method to a camera
  6139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6140. * @param input camera input method
  6141. */
  6142. add(input: ICameraInput<TCamera>): void;
  6143. /**
  6144. * Remove a specific input method from a camera
  6145. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6146. * @param inputToRemove camera input method
  6147. */
  6148. remove(inputToRemove: ICameraInput<TCamera>): void;
  6149. /**
  6150. * Remove a specific input type from a camera
  6151. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6152. * @param inputType the type of the input to remove
  6153. */
  6154. removeByType(inputType: string): void;
  6155. private _addCheckInputs;
  6156. /**
  6157. * Attach the input controls to the currently attached dom element to listen the events from.
  6158. * @param input Defines the input to attach
  6159. */
  6160. attachInput(input: ICameraInput<TCamera>): void;
  6161. /**
  6162. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6163. * @param element Defines the dom element to collect the events from
  6164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6165. */
  6166. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6167. /**
  6168. * Detach the current manager inputs controls from a specific dom element.
  6169. * @param element Defines the dom element to collect the events from
  6170. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6171. */
  6172. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6173. /**
  6174. * Rebuild the dynamic inputCheck function from the current list of
  6175. * defined inputs in the manager.
  6176. */
  6177. rebuildInputCheck(): void;
  6178. /**
  6179. * Remove all attached input methods from a camera
  6180. */
  6181. clear(): void;
  6182. /**
  6183. * Serialize the current input manager attached to a camera.
  6184. * This ensures than once parsed,
  6185. * the input associated to the camera will be identical to the current ones
  6186. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6187. */
  6188. serialize(serializedCamera: any): void;
  6189. /**
  6190. * Parses an input manager serialized JSON to restore the previous list of inputs
  6191. * and states associated to a camera.
  6192. * @param parsedCamera Defines the JSON to parse
  6193. */
  6194. parse(parsedCamera: any): void;
  6195. }
  6196. }
  6197. declare module BABYLON {
  6198. /**
  6199. * Class used to store data that will be store in GPU memory
  6200. */
  6201. export class Buffer {
  6202. private _engine;
  6203. private _buffer;
  6204. /** @hidden */
  6205. _data: Nullable<DataArray>;
  6206. private _updatable;
  6207. private _instanced;
  6208. private _divisor;
  6209. /**
  6210. * Gets the byte stride.
  6211. */
  6212. readonly byteStride: number;
  6213. /**
  6214. * Constructor
  6215. * @param engine the engine
  6216. * @param data the data to use for this buffer
  6217. * @param updatable whether the data is updatable
  6218. * @param stride the stride (optional)
  6219. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6220. * @param instanced whether the buffer is instanced (optional)
  6221. * @param useBytes set to true if the stride in in bytes (optional)
  6222. * @param divisor sets an optional divisor for instances (1 by default)
  6223. */
  6224. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6225. /**
  6226. * Create a new VertexBuffer based on the current buffer
  6227. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6228. * @param offset defines offset in the buffer (0 by default)
  6229. * @param size defines the size in floats of attributes (position is 3 for instance)
  6230. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6231. * @param instanced defines if the vertex buffer contains indexed data
  6232. * @param useBytes defines if the offset and stride are in bytes *
  6233. * @param divisor sets an optional divisor for instances (1 by default)
  6234. * @returns the new vertex buffer
  6235. */
  6236. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6237. /**
  6238. * Gets a boolean indicating if the Buffer is updatable?
  6239. * @returns true if the buffer is updatable
  6240. */
  6241. isUpdatable(): boolean;
  6242. /**
  6243. * Gets current buffer's data
  6244. * @returns a DataArray or null
  6245. */
  6246. getData(): Nullable<DataArray>;
  6247. /**
  6248. * Gets underlying native buffer
  6249. * @returns underlying native buffer
  6250. */
  6251. getBuffer(): Nullable<DataBuffer>;
  6252. /**
  6253. * Gets the stride in float32 units (i.e. byte stride / 4).
  6254. * May not be an integer if the byte stride is not divisible by 4.
  6255. * DEPRECATED. Use byteStride instead.
  6256. * @returns the stride in float32 units
  6257. */
  6258. getStrideSize(): number;
  6259. /**
  6260. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6261. * @param data defines the data to store
  6262. */
  6263. create(data?: Nullable<DataArray>): void;
  6264. /** @hidden */
  6265. _rebuild(): void;
  6266. /**
  6267. * Update current buffer data
  6268. * @param data defines the data to store
  6269. */
  6270. update(data: DataArray): void;
  6271. /**
  6272. * Updates the data directly.
  6273. * @param data the new data
  6274. * @param offset the new offset
  6275. * @param vertexCount the vertex count (optional)
  6276. * @param useBytes set to true if the offset is in bytes
  6277. */
  6278. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6279. /**
  6280. * Release all resources
  6281. */
  6282. dispose(): void;
  6283. }
  6284. /**
  6285. * Specialized buffer used to store vertex data
  6286. */
  6287. export class VertexBuffer {
  6288. /** @hidden */
  6289. _buffer: Buffer;
  6290. private _kind;
  6291. private _size;
  6292. private _ownsBuffer;
  6293. private _instanced;
  6294. private _instanceDivisor;
  6295. /**
  6296. * The byte type.
  6297. */
  6298. static readonly BYTE: number;
  6299. /**
  6300. * The unsigned byte type.
  6301. */
  6302. static readonly UNSIGNED_BYTE: number;
  6303. /**
  6304. * The short type.
  6305. */
  6306. static readonly SHORT: number;
  6307. /**
  6308. * The unsigned short type.
  6309. */
  6310. static readonly UNSIGNED_SHORT: number;
  6311. /**
  6312. * The integer type.
  6313. */
  6314. static readonly INT: number;
  6315. /**
  6316. * The unsigned integer type.
  6317. */
  6318. static readonly UNSIGNED_INT: number;
  6319. /**
  6320. * The float type.
  6321. */
  6322. static readonly FLOAT: number;
  6323. /**
  6324. * Gets or sets the instance divisor when in instanced mode
  6325. */
  6326. instanceDivisor: number;
  6327. /**
  6328. * Gets the byte stride.
  6329. */
  6330. readonly byteStride: number;
  6331. /**
  6332. * Gets the byte offset.
  6333. */
  6334. readonly byteOffset: number;
  6335. /**
  6336. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6337. */
  6338. readonly normalized: boolean;
  6339. /**
  6340. * Gets the data type of each component in the array.
  6341. */
  6342. readonly type: number;
  6343. /**
  6344. * Constructor
  6345. * @param engine the engine
  6346. * @param data the data to use for this vertex buffer
  6347. * @param kind the vertex buffer kind
  6348. * @param updatable whether the data is updatable
  6349. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6350. * @param stride the stride (optional)
  6351. * @param instanced whether the buffer is instanced (optional)
  6352. * @param offset the offset of the data (optional)
  6353. * @param size the number of components (optional)
  6354. * @param type the type of the component (optional)
  6355. * @param normalized whether the data contains normalized data (optional)
  6356. * @param useBytes set to true if stride and offset are in bytes (optional)
  6357. * @param divisor defines the instance divisor to use (1 by default)
  6358. */
  6359. 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, divisor?: number);
  6360. /** @hidden */
  6361. _rebuild(): void;
  6362. /**
  6363. * Returns the kind of the VertexBuffer (string)
  6364. * @returns a string
  6365. */
  6366. getKind(): string;
  6367. /**
  6368. * Gets a boolean indicating if the VertexBuffer is updatable?
  6369. * @returns true if the buffer is updatable
  6370. */
  6371. isUpdatable(): boolean;
  6372. /**
  6373. * Gets current buffer's data
  6374. * @returns a DataArray or null
  6375. */
  6376. getData(): Nullable<DataArray>;
  6377. /**
  6378. * Gets underlying native buffer
  6379. * @returns underlying native buffer
  6380. */
  6381. getBuffer(): Nullable<DataBuffer>;
  6382. /**
  6383. * Gets the stride in float32 units (i.e. byte stride / 4).
  6384. * May not be an integer if the byte stride is not divisible by 4.
  6385. * DEPRECATED. Use byteStride instead.
  6386. * @returns the stride in float32 units
  6387. */
  6388. getStrideSize(): number;
  6389. /**
  6390. * Returns the offset as a multiple of the type byte length.
  6391. * DEPRECATED. Use byteOffset instead.
  6392. * @returns the offset in bytes
  6393. */
  6394. getOffset(): number;
  6395. /**
  6396. * Returns the number of components per vertex attribute (integer)
  6397. * @returns the size in float
  6398. */
  6399. getSize(): number;
  6400. /**
  6401. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6402. * @returns true if this buffer is instanced
  6403. */
  6404. getIsInstanced(): boolean;
  6405. /**
  6406. * Returns the instancing divisor, zero for non-instanced (integer).
  6407. * @returns a number
  6408. */
  6409. getInstanceDivisor(): number;
  6410. /**
  6411. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6412. * @param data defines the data to store
  6413. */
  6414. create(data?: DataArray): void;
  6415. /**
  6416. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6417. * This function will create a new buffer if the current one is not updatable
  6418. * @param data defines the data to store
  6419. */
  6420. update(data: DataArray): void;
  6421. /**
  6422. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6423. * Returns the directly updated WebGLBuffer.
  6424. * @param data the new data
  6425. * @param offset the new offset
  6426. * @param useBytes set to true if the offset is in bytes
  6427. */
  6428. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6429. /**
  6430. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6431. */
  6432. dispose(): void;
  6433. /**
  6434. * Enumerates each value of this vertex buffer as numbers.
  6435. * @param count the number of values to enumerate
  6436. * @param callback the callback function called for each value
  6437. */
  6438. forEach(count: number, callback: (value: number, index: number) => void): void;
  6439. /**
  6440. * Positions
  6441. */
  6442. static readonly PositionKind: string;
  6443. /**
  6444. * Normals
  6445. */
  6446. static readonly NormalKind: string;
  6447. /**
  6448. * Tangents
  6449. */
  6450. static readonly TangentKind: string;
  6451. /**
  6452. * Texture coordinates
  6453. */
  6454. static readonly UVKind: string;
  6455. /**
  6456. * Texture coordinates 2
  6457. */
  6458. static readonly UV2Kind: string;
  6459. /**
  6460. * Texture coordinates 3
  6461. */
  6462. static readonly UV3Kind: string;
  6463. /**
  6464. * Texture coordinates 4
  6465. */
  6466. static readonly UV4Kind: string;
  6467. /**
  6468. * Texture coordinates 5
  6469. */
  6470. static readonly UV5Kind: string;
  6471. /**
  6472. * Texture coordinates 6
  6473. */
  6474. static readonly UV6Kind: string;
  6475. /**
  6476. * Colors
  6477. */
  6478. static readonly ColorKind: string;
  6479. /**
  6480. * Matrix indices (for bones)
  6481. */
  6482. static readonly MatricesIndicesKind: string;
  6483. /**
  6484. * Matrix weights (for bones)
  6485. */
  6486. static readonly MatricesWeightsKind: string;
  6487. /**
  6488. * Additional matrix indices (for bones)
  6489. */
  6490. static readonly MatricesIndicesExtraKind: string;
  6491. /**
  6492. * Additional matrix weights (for bones)
  6493. */
  6494. static readonly MatricesWeightsExtraKind: string;
  6495. /**
  6496. * Deduces the stride given a kind.
  6497. * @param kind The kind string to deduce
  6498. * @returns The deduced stride
  6499. */
  6500. static DeduceStride(kind: string): number;
  6501. /**
  6502. * Gets the byte length of the given type.
  6503. * @param type the type
  6504. * @returns the number of bytes
  6505. */
  6506. static GetTypeByteLength(type: number): number;
  6507. /**
  6508. * Enumerates each value of the given parameters as numbers.
  6509. * @param data the data to enumerate
  6510. * @param byteOffset the byte offset of the data
  6511. * @param byteStride the byte stride of the data
  6512. * @param componentCount the number of components per element
  6513. * @param componentType the type of the component
  6514. * @param count the number of values to enumerate
  6515. * @param normalized whether the data is normalized
  6516. * @param callback the callback function called for each value
  6517. */
  6518. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6519. private static _GetFloatValue;
  6520. }
  6521. }
  6522. declare module BABYLON {
  6523. /**
  6524. * @hidden
  6525. */
  6526. export class IntersectionInfo {
  6527. bu: Nullable<number>;
  6528. bv: Nullable<number>;
  6529. distance: number;
  6530. faceId: number;
  6531. subMeshId: number;
  6532. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6533. }
  6534. }
  6535. declare module BABYLON {
  6536. /**
  6537. * Represens a plane by the equation ax + by + cz + d = 0
  6538. */
  6539. export class Plane {
  6540. private static _TmpMatrix;
  6541. /**
  6542. * Normal of the plane (a,b,c)
  6543. */
  6544. normal: Vector3;
  6545. /**
  6546. * d component of the plane
  6547. */
  6548. d: number;
  6549. /**
  6550. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6551. * @param a a component of the plane
  6552. * @param b b component of the plane
  6553. * @param c c component of the plane
  6554. * @param d d component of the plane
  6555. */
  6556. constructor(a: number, b: number, c: number, d: number);
  6557. /**
  6558. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6559. */
  6560. asArray(): number[];
  6561. /**
  6562. * @returns a new plane copied from the current Plane.
  6563. */
  6564. clone(): Plane;
  6565. /**
  6566. * @returns the string "Plane".
  6567. */
  6568. getClassName(): string;
  6569. /**
  6570. * @returns the Plane hash code.
  6571. */
  6572. getHashCode(): number;
  6573. /**
  6574. * Normalize the current Plane in place.
  6575. * @returns the updated Plane.
  6576. */
  6577. normalize(): Plane;
  6578. /**
  6579. * Applies a transformation the plane and returns the result
  6580. * @param transformation the transformation matrix to be applied to the plane
  6581. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6582. */
  6583. transform(transformation: DeepImmutable<Matrix>): Plane;
  6584. /**
  6585. * Calcualtte the dot product between the point and the plane normal
  6586. * @param point point to calculate the dot product with
  6587. * @returns the dot product (float) of the point coordinates and the plane normal.
  6588. */
  6589. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6590. /**
  6591. * Updates the current Plane from the plane defined by the three given points.
  6592. * @param point1 one of the points used to contruct the plane
  6593. * @param point2 one of the points used to contruct the plane
  6594. * @param point3 one of the points used to contruct the plane
  6595. * @returns the updated Plane.
  6596. */
  6597. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6598. /**
  6599. * Checks if the plane is facing a given direction
  6600. * @param direction the direction to check if the plane is facing
  6601. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6602. * @returns True is the vector "direction" is the same side than the plane normal.
  6603. */
  6604. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6605. /**
  6606. * Calculates the distance to a point
  6607. * @param point point to calculate distance to
  6608. * @returns the signed distance (float) from the given point to the Plane.
  6609. */
  6610. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6611. /**
  6612. * Creates a plane from an array
  6613. * @param array the array to create a plane from
  6614. * @returns a new Plane from the given array.
  6615. */
  6616. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6617. /**
  6618. * Creates a plane from three points
  6619. * @param point1 point used to create the plane
  6620. * @param point2 point used to create the plane
  6621. * @param point3 point used to create the plane
  6622. * @returns a new Plane defined by the three given points.
  6623. */
  6624. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6625. /**
  6626. * Creates a plane from an origin point and a normal
  6627. * @param origin origin of the plane to be constructed
  6628. * @param normal normal of the plane to be constructed
  6629. * @returns a new Plane the normal vector to this plane at the given origin point.
  6630. * Note : the vector "normal" is updated because normalized.
  6631. */
  6632. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6633. /**
  6634. * Calculates the distance from a plane and a point
  6635. * @param origin origin of the plane to be constructed
  6636. * @param normal normal of the plane to be constructed
  6637. * @param point point to calculate distance to
  6638. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6639. */
  6640. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Class used to store bounding sphere information
  6646. */
  6647. export class BoundingSphere {
  6648. /**
  6649. * Gets the center of the bounding sphere in local space
  6650. */
  6651. readonly center: Vector3;
  6652. /**
  6653. * Radius of the bounding sphere in local space
  6654. */
  6655. radius: number;
  6656. /**
  6657. * Gets the center of the bounding sphere in world space
  6658. */
  6659. readonly centerWorld: Vector3;
  6660. /**
  6661. * Radius of the bounding sphere in world space
  6662. */
  6663. radiusWorld: number;
  6664. /**
  6665. * Gets the minimum vector in local space
  6666. */
  6667. readonly minimum: Vector3;
  6668. /**
  6669. * Gets the maximum vector in local space
  6670. */
  6671. readonly maximum: Vector3;
  6672. private _worldMatrix;
  6673. private static readonly TmpVector3;
  6674. /**
  6675. * Creates a new bounding sphere
  6676. * @param min defines the minimum vector (in local space)
  6677. * @param max defines the maximum vector (in local space)
  6678. * @param worldMatrix defines the new world matrix
  6679. */
  6680. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6681. /**
  6682. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6683. * @param min defines the new minimum vector (in local space)
  6684. * @param max defines the new maximum vector (in local space)
  6685. * @param worldMatrix defines the new world matrix
  6686. */
  6687. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6688. /**
  6689. * Scale the current bounding sphere by applying a scale factor
  6690. * @param factor defines the scale factor to apply
  6691. * @returns the current bounding box
  6692. */
  6693. scale(factor: number): BoundingSphere;
  6694. /**
  6695. * Gets the world matrix of the bounding box
  6696. * @returns a matrix
  6697. */
  6698. getWorldMatrix(): DeepImmutable<Matrix>;
  6699. /** @hidden */
  6700. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6701. /**
  6702. * Tests if the bounding sphere is intersecting the frustum planes
  6703. * @param frustumPlanes defines the frustum planes to test
  6704. * @returns true if there is an intersection
  6705. */
  6706. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6707. /**
  6708. * Tests if the bounding sphere center is in between the frustum planes.
  6709. * Used for optimistic fast inclusion.
  6710. * @param frustumPlanes defines the frustum planes to test
  6711. * @returns true if the sphere center is in between the frustum planes
  6712. */
  6713. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6714. /**
  6715. * Tests if a point is inside the bounding sphere
  6716. * @param point defines the point to test
  6717. * @returns true if the point is inside the bounding sphere
  6718. */
  6719. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6720. /**
  6721. * Checks if two sphere intersct
  6722. * @param sphere0 sphere 0
  6723. * @param sphere1 sphere 1
  6724. * @returns true if the speres intersect
  6725. */
  6726. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Class used to store bounding box information
  6732. */
  6733. export class BoundingBox implements ICullable {
  6734. /**
  6735. * Gets the 8 vectors representing the bounding box in local space
  6736. */
  6737. readonly vectors: Vector3[];
  6738. /**
  6739. * Gets the center of the bounding box in local space
  6740. */
  6741. readonly center: Vector3;
  6742. /**
  6743. * Gets the center of the bounding box in world space
  6744. */
  6745. readonly centerWorld: Vector3;
  6746. /**
  6747. * Gets the extend size in local space
  6748. */
  6749. readonly extendSize: Vector3;
  6750. /**
  6751. * Gets the extend size in world space
  6752. */
  6753. readonly extendSizeWorld: Vector3;
  6754. /**
  6755. * Gets the OBB (object bounding box) directions
  6756. */
  6757. readonly directions: Vector3[];
  6758. /**
  6759. * Gets the 8 vectors representing the bounding box in world space
  6760. */
  6761. readonly vectorsWorld: Vector3[];
  6762. /**
  6763. * Gets the minimum vector in world space
  6764. */
  6765. readonly minimumWorld: Vector3;
  6766. /**
  6767. * Gets the maximum vector in world space
  6768. */
  6769. readonly maximumWorld: Vector3;
  6770. /**
  6771. * Gets the minimum vector in local space
  6772. */
  6773. readonly minimum: Vector3;
  6774. /**
  6775. * Gets the maximum vector in local space
  6776. */
  6777. readonly maximum: Vector3;
  6778. private _worldMatrix;
  6779. private static readonly TmpVector3;
  6780. /**
  6781. * @hidden
  6782. */
  6783. _tag: number;
  6784. /**
  6785. * Creates a new bounding box
  6786. * @param min defines the minimum vector (in local space)
  6787. * @param max defines the maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6791. /**
  6792. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6793. * @param min defines the new minimum vector (in local space)
  6794. * @param max defines the new maximum vector (in local space)
  6795. * @param worldMatrix defines the new world matrix
  6796. */
  6797. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6798. /**
  6799. * Scale the current bounding box by applying a scale factor
  6800. * @param factor defines the scale factor to apply
  6801. * @returns the current bounding box
  6802. */
  6803. scale(factor: number): BoundingBox;
  6804. /**
  6805. * Gets the world matrix of the bounding box
  6806. * @returns a matrix
  6807. */
  6808. getWorldMatrix(): DeepImmutable<Matrix>;
  6809. /** @hidden */
  6810. _update(world: DeepImmutable<Matrix>): void;
  6811. /**
  6812. * Tests if the bounding box is intersecting the frustum planes
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if there is an intersection
  6815. */
  6816. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if the bounding box is entirely inside the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an inclusion
  6821. */
  6822. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if a point is inside the bounding box
  6825. * @param point defines the point to test
  6826. * @returns true if the point is inside the bounding box
  6827. */
  6828. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6829. /**
  6830. * Tests if the bounding box intersects with a bounding sphere
  6831. * @param sphere defines the sphere to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6835. /**
  6836. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6837. * @param min defines the min vector to use
  6838. * @param max defines the max vector to use
  6839. * @returns true if there is an intersection
  6840. */
  6841. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6842. /**
  6843. * Tests if two bounding boxes are intersections
  6844. * @param box0 defines the first box to test
  6845. * @param box1 defines the second box to test
  6846. * @returns true if there is an intersection
  6847. */
  6848. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6849. /**
  6850. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6851. * @param minPoint defines the minimum vector of the bounding box
  6852. * @param maxPoint defines the maximum vector of the bounding box
  6853. * @param sphereCenter defines the sphere center
  6854. * @param sphereRadius defines the sphere radius
  6855. * @returns true if there is an intersection
  6856. */
  6857. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6858. /**
  6859. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6860. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6861. * @param frustumPlanes defines the frustum planes to test
  6862. * @return true if there is an inclusion
  6863. */
  6864. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6865. /**
  6866. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6867. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6868. * @param frustumPlanes defines the frustum planes to test
  6869. * @return true if there is an intersection
  6870. */
  6871. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /** @hidden */
  6876. export class Collider {
  6877. /** Define if a collision was found */
  6878. collisionFound: boolean;
  6879. /**
  6880. * Define last intersection point in local space
  6881. */
  6882. intersectionPoint: Vector3;
  6883. /**
  6884. * Define last collided mesh
  6885. */
  6886. collidedMesh: Nullable<AbstractMesh>;
  6887. private _collisionPoint;
  6888. private _planeIntersectionPoint;
  6889. private _tempVector;
  6890. private _tempVector2;
  6891. private _tempVector3;
  6892. private _tempVector4;
  6893. private _edge;
  6894. private _baseToVertex;
  6895. private _destinationPoint;
  6896. private _slidePlaneNormal;
  6897. private _displacementVector;
  6898. /** @hidden */
  6899. _radius: Vector3;
  6900. /** @hidden */
  6901. _retry: number;
  6902. private _velocity;
  6903. private _basePoint;
  6904. private _epsilon;
  6905. /** @hidden */
  6906. _velocityWorldLength: number;
  6907. /** @hidden */
  6908. _basePointWorld: Vector3;
  6909. private _velocityWorld;
  6910. private _normalizedVelocity;
  6911. /** @hidden */
  6912. _initialVelocity: Vector3;
  6913. /** @hidden */
  6914. _initialPosition: Vector3;
  6915. private _nearestDistance;
  6916. private _collisionMask;
  6917. collisionMask: number;
  6918. /**
  6919. * Gets the plane normal used to compute the sliding response (in local space)
  6920. */
  6921. readonly slidePlaneNormal: Vector3;
  6922. /** @hidden */
  6923. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6924. /** @hidden */
  6925. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6926. /** @hidden */
  6927. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6928. /** @hidden */
  6929. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6930. /** @hidden */
  6931. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6932. /** @hidden */
  6933. _getResponse(pos: Vector3, vel: Vector3): void;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Interface for cullable objects
  6939. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6940. */
  6941. export interface ICullable {
  6942. /**
  6943. * Checks if the object or part of the object is in the frustum
  6944. * @param frustumPlanes Camera near/planes
  6945. * @returns true if the object is in frustum otherwise false
  6946. */
  6947. isInFrustum(frustumPlanes: Plane[]): boolean;
  6948. /**
  6949. * Checks if a cullable object (mesh...) is in the camera frustum
  6950. * Unlike isInFrustum this cheks the full bounding box
  6951. * @param frustumPlanes Camera near/planes
  6952. * @returns true if the object is in frustum otherwise false
  6953. */
  6954. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6955. }
  6956. /**
  6957. * Info for a bounding data of a mesh
  6958. */
  6959. export class BoundingInfo implements ICullable {
  6960. /**
  6961. * Bounding box for the mesh
  6962. */
  6963. readonly boundingBox: BoundingBox;
  6964. /**
  6965. * Bounding sphere for the mesh
  6966. */
  6967. readonly boundingSphere: BoundingSphere;
  6968. private _isLocked;
  6969. private static readonly TmpVector3;
  6970. /**
  6971. * Constructs bounding info
  6972. * @param minimum min vector of the bounding box/sphere
  6973. * @param maximum max vector of the bounding box/sphere
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * min vector of the bounding box/sphere
  6986. */
  6987. readonly minimum: Vector3;
  6988. /**
  6989. * max vector of the bounding box/sphere
  6990. */
  6991. readonly maximum: Vector3;
  6992. /**
  6993. * If the info is locked and won't be updated to avoid perf overhead
  6994. */
  6995. isLocked: boolean;
  6996. /**
  6997. * Updates the bounding sphere and box
  6998. * @param world world matrix to be used to update
  6999. */
  7000. update(world: DeepImmutable<Matrix>): void;
  7001. /**
  7002. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7003. * @param center New center of the bounding info
  7004. * @param extend New extend of the bounding info
  7005. * @returns the current bounding info
  7006. */
  7007. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7008. /**
  7009. * Scale the current bounding info by applying a scale factor
  7010. * @param factor defines the scale factor to apply
  7011. * @returns the current bounding info
  7012. */
  7013. scale(factor: number): BoundingInfo;
  7014. /**
  7015. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7016. * @param frustumPlanes defines the frustum to test
  7017. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7018. * @returns true if the bounding info is in the frustum planes
  7019. */
  7020. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7021. /**
  7022. * Gets the world distance between the min and max points of the bounding box
  7023. */
  7024. readonly diagonalLength: number;
  7025. /**
  7026. * Checks if a cullable object (mesh...) is in the camera frustum
  7027. * Unlike isInFrustum this cheks the full bounding box
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7032. /** @hidden */
  7033. _checkCollision(collider: Collider): boolean;
  7034. /**
  7035. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7036. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7037. * @param point the point to check intersection with
  7038. * @returns if the point intersects
  7039. */
  7040. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7041. /**
  7042. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7043. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7044. * @param boundingInfo the bounding info to check intersection with
  7045. * @param precise if the intersection should be done using OBB
  7046. * @returns if the bounding info intersects
  7047. */
  7048. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7049. }
  7050. }
  7051. declare module BABYLON {
  7052. /**
  7053. * Extracts minimum and maximum values from a list of indexed positions
  7054. * @param positions defines the positions to use
  7055. * @param indices defines the indices to the positions
  7056. * @param indexStart defines the start index
  7057. * @param indexCount defines the end index
  7058. * @param bias defines bias value to add to the result
  7059. * @return minimum and maximum values
  7060. */
  7061. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7062. minimum: Vector3;
  7063. maximum: Vector3;
  7064. };
  7065. /**
  7066. * Extracts minimum and maximum values from a list of positions
  7067. * @param positions defines the positions to use
  7068. * @param start defines the start index in the positions array
  7069. * @param count defines the number of positions to handle
  7070. * @param bias defines bias value to add to the result
  7071. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7072. * @return minimum and maximum values
  7073. */
  7074. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7075. minimum: Vector3;
  7076. maximum: Vector3;
  7077. };
  7078. }
  7079. declare module BABYLON {
  7080. /** @hidden */
  7081. export class WebGLDataBuffer extends DataBuffer {
  7082. private _buffer;
  7083. constructor(resource: WebGLBuffer);
  7084. readonly underlyingResource: any;
  7085. }
  7086. }
  7087. declare module BABYLON {
  7088. /** @hidden */
  7089. export class WebGLPipelineContext implements IPipelineContext {
  7090. engine: ThinEngine;
  7091. program: Nullable<WebGLProgram>;
  7092. context?: WebGLRenderingContext;
  7093. vertexShader?: WebGLShader;
  7094. fragmentShader?: WebGLShader;
  7095. isParallelCompiled: boolean;
  7096. onCompiled?: () => void;
  7097. transformFeedback?: WebGLTransformFeedback | null;
  7098. readonly isAsync: boolean;
  7099. readonly isReady: boolean;
  7100. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7101. }
  7102. }
  7103. declare module BABYLON {
  7104. interface ThinEngine {
  7105. /**
  7106. * Create an uniform buffer
  7107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7108. * @param elements defines the content of the uniform buffer
  7109. * @returns the webGL uniform buffer
  7110. */
  7111. createUniformBuffer(elements: FloatArray): DataBuffer;
  7112. /**
  7113. * Create a dynamic uniform buffer
  7114. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7115. * @param elements defines the content of the uniform buffer
  7116. * @returns the webGL uniform buffer
  7117. */
  7118. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7119. /**
  7120. * Update an existing uniform buffer
  7121. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7122. * @param uniformBuffer defines the target uniform buffer
  7123. * @param elements defines the content to update
  7124. * @param offset defines the offset in the uniform buffer where update should start
  7125. * @param count defines the size of the data to update
  7126. */
  7127. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7128. /**
  7129. * Bind an uniform buffer to the current webGL context
  7130. * @param buffer defines the buffer to bind
  7131. */
  7132. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7133. /**
  7134. * Bind a buffer to the current webGL context at a given location
  7135. * @param buffer defines the buffer to bind
  7136. * @param location defines the index where to bind the buffer
  7137. */
  7138. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7139. /**
  7140. * Bind a specific block at a given index in a specific shader program
  7141. * @param pipelineContext defines the pipeline context to use
  7142. * @param blockName defines the block name
  7143. * @param index defines the index where to bind the block
  7144. */
  7145. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Uniform buffer objects.
  7151. *
  7152. * Handles blocks of uniform on the GPU.
  7153. *
  7154. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7155. *
  7156. * For more information, please refer to :
  7157. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7158. */
  7159. export class UniformBuffer {
  7160. private _engine;
  7161. private _buffer;
  7162. private _data;
  7163. private _bufferData;
  7164. private _dynamic?;
  7165. private _uniformLocations;
  7166. private _uniformSizes;
  7167. private _uniformLocationPointer;
  7168. private _needSync;
  7169. private _noUBO;
  7170. private _currentEffect;
  7171. /** @hidden */
  7172. _alreadyBound: boolean;
  7173. private static _MAX_UNIFORM_SIZE;
  7174. private static _tempBuffer;
  7175. /**
  7176. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7177. * This is dynamic to allow compat with webgl 1 and 2.
  7178. * You will need to pass the name of the uniform as well as the value.
  7179. */
  7180. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7181. /**
  7182. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7183. * This is dynamic to allow compat with webgl 1 and 2.
  7184. * You will need to pass the name of the uniform as well as the value.
  7185. */
  7186. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7187. /**
  7188. * Lambda to Update a single float in a uniform buffer.
  7189. * This is dynamic to allow compat with webgl 1 and 2.
  7190. * You will need to pass the name of the uniform as well as the value.
  7191. */
  7192. updateFloat: (name: string, x: number) => void;
  7193. /**
  7194. * Lambda to Update a vec2 of float in a uniform buffer.
  7195. * This is dynamic to allow compat with webgl 1 and 2.
  7196. * You will need to pass the name of the uniform as well as the value.
  7197. */
  7198. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7199. /**
  7200. * Lambda to Update a vec3 of float in a uniform buffer.
  7201. * This is dynamic to allow compat with webgl 1 and 2.
  7202. * You will need to pass the name of the uniform as well as the value.
  7203. */
  7204. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7205. /**
  7206. * Lambda to Update a vec4 of float in a uniform buffer.
  7207. * This is dynamic to allow compat with webgl 1 and 2.
  7208. * You will need to pass the name of the uniform as well as the value.
  7209. */
  7210. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7211. /**
  7212. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7213. * This is dynamic to allow compat with webgl 1 and 2.
  7214. * You will need to pass the name of the uniform as well as the value.
  7215. */
  7216. updateMatrix: (name: string, mat: Matrix) => void;
  7217. /**
  7218. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7219. * This is dynamic to allow compat with webgl 1 and 2.
  7220. * You will need to pass the name of the uniform as well as the value.
  7221. */
  7222. updateVector3: (name: string, vector: Vector3) => void;
  7223. /**
  7224. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7225. * This is dynamic to allow compat with webgl 1 and 2.
  7226. * You will need to pass the name of the uniform as well as the value.
  7227. */
  7228. updateVector4: (name: string, vector: Vector4) => void;
  7229. /**
  7230. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7231. * This is dynamic to allow compat with webgl 1 and 2.
  7232. * You will need to pass the name of the uniform as well as the value.
  7233. */
  7234. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7235. /**
  7236. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7237. * This is dynamic to allow compat with webgl 1 and 2.
  7238. * You will need to pass the name of the uniform as well as the value.
  7239. */
  7240. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7241. /**
  7242. * Instantiates a new Uniform buffer objects.
  7243. *
  7244. * Handles blocks of uniform on the GPU.
  7245. *
  7246. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7247. *
  7248. * For more information, please refer to :
  7249. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7250. * @param engine Define the engine the buffer is associated with
  7251. * @param data Define the data contained in the buffer
  7252. * @param dynamic Define if the buffer is updatable
  7253. */
  7254. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7255. /**
  7256. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7257. * or just falling back on setUniformXXX calls.
  7258. */
  7259. readonly useUbo: boolean;
  7260. /**
  7261. * Indicates if the WebGL underlying uniform buffer is in sync
  7262. * with the javascript cache data.
  7263. */
  7264. readonly isSync: boolean;
  7265. /**
  7266. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7267. * Also, a dynamic UniformBuffer will disable cache verification and always
  7268. * update the underlying WebGL uniform buffer to the GPU.
  7269. * @returns if Dynamic, otherwise false
  7270. */
  7271. isDynamic(): boolean;
  7272. /**
  7273. * The data cache on JS side.
  7274. * @returns the underlying data as a float array
  7275. */
  7276. getData(): Float32Array;
  7277. /**
  7278. * The underlying WebGL Uniform buffer.
  7279. * @returns the webgl buffer
  7280. */
  7281. getBuffer(): Nullable<DataBuffer>;
  7282. /**
  7283. * std140 layout specifies how to align data within an UBO structure.
  7284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7285. * for specs.
  7286. */
  7287. private _fillAlignment;
  7288. /**
  7289. * Adds an uniform in the buffer.
  7290. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7291. * for the layout to be correct !
  7292. * @param name Name of the uniform, as used in the uniform block in the shader.
  7293. * @param size Data size, or data directly.
  7294. */
  7295. addUniform(name: string, size: number | number[]): void;
  7296. /**
  7297. * Adds a Matrix 4x4 to the uniform buffer.
  7298. * @param name Name of the uniform, as used in the uniform block in the shader.
  7299. * @param mat A 4x4 matrix.
  7300. */
  7301. addMatrix(name: string, mat: Matrix): void;
  7302. /**
  7303. * Adds a vec2 to the uniform buffer.
  7304. * @param name Name of the uniform, as used in the uniform block in the shader.
  7305. * @param x Define the x component value of the vec2
  7306. * @param y Define the y component value of the vec2
  7307. */
  7308. addFloat2(name: string, x: number, y: number): void;
  7309. /**
  7310. * Adds a vec3 to the uniform buffer.
  7311. * @param name Name of the uniform, as used in the uniform block in the shader.
  7312. * @param x Define the x component value of the vec3
  7313. * @param y Define the y component value of the vec3
  7314. * @param z Define the z component value of the vec3
  7315. */
  7316. addFloat3(name: string, x: number, y: number, z: number): void;
  7317. /**
  7318. * Adds a vec3 to the uniform buffer.
  7319. * @param name Name of the uniform, as used in the uniform block in the shader.
  7320. * @param color Define the vec3 from a Color
  7321. */
  7322. addColor3(name: string, color: Color3): void;
  7323. /**
  7324. * Adds a vec4 to the uniform buffer.
  7325. * @param name Name of the uniform, as used in the uniform block in the shader.
  7326. * @param color Define the rgb components from a Color
  7327. * @param alpha Define the a component of the vec4
  7328. */
  7329. addColor4(name: string, color: Color3, alpha: number): void;
  7330. /**
  7331. * Adds a vec3 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. * @param vector Define the vec3 components from a Vector
  7334. */
  7335. addVector3(name: string, vector: Vector3): void;
  7336. /**
  7337. * Adds a Matrix 3x3 to the uniform buffer.
  7338. * @param name Name of the uniform, as used in the uniform block in the shader.
  7339. */
  7340. addMatrix3x3(name: string): void;
  7341. /**
  7342. * Adds a Matrix 2x2 to the uniform buffer.
  7343. * @param name Name of the uniform, as used in the uniform block in the shader.
  7344. */
  7345. addMatrix2x2(name: string): void;
  7346. /**
  7347. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7348. */
  7349. create(): void;
  7350. /** @hidden */
  7351. _rebuild(): void;
  7352. /**
  7353. * Updates the WebGL Uniform Buffer on the GPU.
  7354. * If the `dynamic` flag is set to true, no cache comparison is done.
  7355. * Otherwise, the buffer will be updated only if the cache differs.
  7356. */
  7357. update(): void;
  7358. /**
  7359. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7360. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7361. * @param data Define the flattened data
  7362. * @param size Define the size of the data.
  7363. */
  7364. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7365. private _valueCache;
  7366. private _cacheMatrix;
  7367. private _updateMatrix3x3ForUniform;
  7368. private _updateMatrix3x3ForEffect;
  7369. private _updateMatrix2x2ForEffect;
  7370. private _updateMatrix2x2ForUniform;
  7371. private _updateFloatForEffect;
  7372. private _updateFloatForUniform;
  7373. private _updateFloat2ForEffect;
  7374. private _updateFloat2ForUniform;
  7375. private _updateFloat3ForEffect;
  7376. private _updateFloat3ForUniform;
  7377. private _updateFloat4ForEffect;
  7378. private _updateFloat4ForUniform;
  7379. private _updateMatrixForEffect;
  7380. private _updateMatrixForUniform;
  7381. private _updateVector3ForEffect;
  7382. private _updateVector3ForUniform;
  7383. private _updateVector4ForEffect;
  7384. private _updateVector4ForUniform;
  7385. private _updateColor3ForEffect;
  7386. private _updateColor3ForUniform;
  7387. private _updateColor4ForEffect;
  7388. private _updateColor4ForUniform;
  7389. /**
  7390. * Sets a sampler uniform on the effect.
  7391. * @param name Define the name of the sampler.
  7392. * @param texture Define the texture to set in the sampler
  7393. */
  7394. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7395. /**
  7396. * Directly updates the value of the uniform in the cache AND on the GPU.
  7397. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7398. * @param data Define the flattened data
  7399. */
  7400. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7401. /**
  7402. * Binds this uniform buffer to an effect.
  7403. * @param effect Define the effect to bind the buffer to
  7404. * @param name Name of the uniform block in the shader.
  7405. */
  7406. bindToEffect(effect: Effect, name: string): void;
  7407. /**
  7408. * Disposes the uniform buffer.
  7409. */
  7410. dispose(): void;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Enum that determines the text-wrapping mode to use.
  7416. */
  7417. export enum InspectableType {
  7418. /**
  7419. * Checkbox for booleans
  7420. */
  7421. Checkbox = 0,
  7422. /**
  7423. * Sliders for numbers
  7424. */
  7425. Slider = 1,
  7426. /**
  7427. * Vector3
  7428. */
  7429. Vector3 = 2,
  7430. /**
  7431. * Quaternions
  7432. */
  7433. Quaternion = 3,
  7434. /**
  7435. * Color3
  7436. */
  7437. Color3 = 4,
  7438. /**
  7439. * String
  7440. */
  7441. String = 5
  7442. }
  7443. /**
  7444. * Interface used to define custom inspectable properties.
  7445. * This interface is used by the inspector to display custom property grids
  7446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7447. */
  7448. export interface IInspectable {
  7449. /**
  7450. * Gets the label to display
  7451. */
  7452. label: string;
  7453. /**
  7454. * Gets the name of the property to edit
  7455. */
  7456. propertyName: string;
  7457. /**
  7458. * Gets the type of the editor to use
  7459. */
  7460. type: InspectableType;
  7461. /**
  7462. * Gets the minimum value of the property when using in "slider" mode
  7463. */
  7464. min?: number;
  7465. /**
  7466. * Gets the maximum value of the property when using in "slider" mode
  7467. */
  7468. max?: number;
  7469. /**
  7470. * Gets the setp to use when using in "slider" mode
  7471. */
  7472. step?: number;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class used to provide helper for timing
  7478. */
  7479. export class TimingTools {
  7480. /**
  7481. * Polyfill for setImmediate
  7482. * @param action defines the action to execute after the current execution block
  7483. */
  7484. static SetImmediate(action: () => void): void;
  7485. }
  7486. }
  7487. declare module BABYLON {
  7488. /**
  7489. * Class used to enable instatition of objects by class name
  7490. */
  7491. export class InstantiationTools {
  7492. /**
  7493. * Use this object to register external classes like custom textures or material
  7494. * to allow the laoders to instantiate them
  7495. */
  7496. static RegisteredExternalClasses: {
  7497. [key: string]: Object;
  7498. };
  7499. /**
  7500. * Tries to instantiate a new object from a given class name
  7501. * @param className defines the class name to instantiate
  7502. * @returns the new object or null if the system was not able to do the instantiation
  7503. */
  7504. static Instantiate(className: string): any;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Define options used to create a depth texture
  7510. */
  7511. export class DepthTextureCreationOptions {
  7512. /** Specifies whether or not a stencil should be allocated in the texture */
  7513. generateStencil?: boolean;
  7514. /** Specifies whether or not bilinear filtering is enable on the texture */
  7515. bilinearFiltering?: boolean;
  7516. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7517. comparisonFunction?: number;
  7518. /** Specifies if the created texture is a cube texture */
  7519. isCube?: boolean;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. interface ThinEngine {
  7524. /**
  7525. * Creates a depth stencil cube texture.
  7526. * This is only available in WebGL 2.
  7527. * @param size The size of face edge in the cube texture.
  7528. * @param options The options defining the cube texture.
  7529. * @returns The cube texture
  7530. */
  7531. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7532. /**
  7533. * Creates a cube texture
  7534. * @param rootUrl defines the url where the files to load is located
  7535. * @param scene defines the current scene
  7536. * @param files defines the list of files to load (1 per face)
  7537. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7538. * @param onLoad defines an optional callback raised when the texture is loaded
  7539. * @param onError defines an optional callback raised if there is an issue to load the texture
  7540. * @param format defines the format of the data
  7541. * @param forcedExtension defines the extension to use to pick the right loader
  7542. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7543. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7544. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7545. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7547. * @returns the cube texture as an InternalTexture
  7548. */
  7549. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7550. /**
  7551. * Creates a cube texture
  7552. * @param rootUrl defines the url where the files to load is located
  7553. * @param scene defines the current scene
  7554. * @param files defines the list of files to load (1 per face)
  7555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7556. * @param onLoad defines an optional callback raised when the texture is loaded
  7557. * @param onError defines an optional callback raised if there is an issue to load the texture
  7558. * @param format defines the format of the data
  7559. * @param forcedExtension defines the extension to use to pick the right loader
  7560. * @returns the cube texture as an InternalTexture
  7561. */
  7562. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7563. /**
  7564. * Creates a cube texture
  7565. * @param rootUrl defines the url where the files to load is located
  7566. * @param scene defines the current scene
  7567. * @param files defines the list of files to load (1 per face)
  7568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7569. * @param onLoad defines an optional callback raised when the texture is loaded
  7570. * @param onError defines an optional callback raised if there is an issue to load the texture
  7571. * @param format defines the format of the data
  7572. * @param forcedExtension defines the extension to use to pick the right loader
  7573. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7574. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7575. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7576. * @returns the cube texture as an InternalTexture
  7577. */
  7578. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7579. /** @hidden */
  7580. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7581. /** @hidden */
  7582. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7583. /** @hidden */
  7584. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7585. /** @hidden */
  7586. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7587. /**
  7588. * @hidden
  7589. */
  7590. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7591. }
  7592. }
  7593. declare module BABYLON {
  7594. /**
  7595. * Class for creating a cube texture
  7596. */
  7597. export class CubeTexture extends BaseTexture {
  7598. private _delayedOnLoad;
  7599. /**
  7600. * The url of the texture
  7601. */
  7602. url: string;
  7603. /**
  7604. * Gets or sets the center of the bounding box associated with the cube texture.
  7605. * It must define where the camera used to render the texture was set
  7606. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7607. */
  7608. boundingBoxPosition: Vector3;
  7609. private _boundingBoxSize;
  7610. /**
  7611. * Gets or sets the size of the bounding box associated with the cube texture
  7612. * When defined, the cubemap will switch to local mode
  7613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7614. * @example https://www.babylonjs-playground.com/#RNASML
  7615. */
  7616. /**
  7617. * Returns the bounding box size
  7618. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7619. */
  7620. boundingBoxSize: Vector3;
  7621. protected _rotationY: number;
  7622. /**
  7623. * Sets texture matrix rotation angle around Y axis in radians.
  7624. */
  7625. /**
  7626. * Gets texture matrix rotation angle around Y axis radians.
  7627. */
  7628. rotationY: number;
  7629. /**
  7630. * Are mip maps generated for this texture or not.
  7631. */
  7632. readonly noMipmap: boolean;
  7633. private _noMipmap;
  7634. private _files;
  7635. protected _forcedExtension: Nullable<string>;
  7636. private _extensions;
  7637. private _textureMatrix;
  7638. private _format;
  7639. private _createPolynomials;
  7640. /** @hidden */
  7641. _prefiltered: boolean;
  7642. /**
  7643. * Creates a cube texture from an array of image urls
  7644. * @param files defines an array of image urls
  7645. * @param scene defines the hosting scene
  7646. * @param noMipmap specifies if mip maps are not used
  7647. * @returns a cube texture
  7648. */
  7649. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7650. /**
  7651. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7652. * @param url defines the url of the prefiltered texture
  7653. * @param scene defines the scene the texture is attached to
  7654. * @param forcedExtension defines the extension of the file if different from the url
  7655. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7656. * @return the prefiltered texture
  7657. */
  7658. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7659. /**
  7660. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7661. * as prefiltered data.
  7662. * @param rootUrl defines the url of the texture or the root name of the six images
  7663. * @param scene defines the scene the texture is attached to
  7664. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7665. * @param noMipmap defines if mipmaps should be created or not
  7666. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7667. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7668. * @param onError defines a callback triggered in case of error during load
  7669. * @param format defines the internal format to use for the texture once loaded
  7670. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7671. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7672. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7673. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7674. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7675. * @return the cube texture
  7676. */
  7677. 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);
  7678. /**
  7679. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7680. */
  7681. readonly isPrefiltered: boolean;
  7682. /**
  7683. * Get the current class name of the texture useful for serialization or dynamic coding.
  7684. * @returns "CubeTexture"
  7685. */
  7686. getClassName(): string;
  7687. /**
  7688. * Update the url (and optional buffer) of this texture if url was null during construction.
  7689. * @param url the url of the texture
  7690. * @param forcedExtension defines the extension to use
  7691. * @param onLoad callback called when the texture is loaded (defaults to null)
  7692. */
  7693. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7694. /**
  7695. * Delays loading of the cube texture
  7696. * @param forcedExtension defines the extension to use
  7697. */
  7698. delayLoad(forcedExtension?: string): void;
  7699. /**
  7700. * Returns the reflection texture matrix
  7701. * @returns the reflection texture matrix
  7702. */
  7703. getReflectionTextureMatrix(): Matrix;
  7704. /**
  7705. * Sets the reflection texture matrix
  7706. * @param value Reflection texture matrix
  7707. */
  7708. setReflectionTextureMatrix(value: Matrix): void;
  7709. /**
  7710. * Parses text to create a cube texture
  7711. * @param parsedTexture define the serialized text to read from
  7712. * @param scene defines the hosting scene
  7713. * @param rootUrl defines the root url of the cube texture
  7714. * @returns a cube texture
  7715. */
  7716. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7717. /**
  7718. * Makes a clone, or deep copy, of the cube texture
  7719. * @returns a new cube texture
  7720. */
  7721. clone(): CubeTexture;
  7722. }
  7723. }
  7724. declare module BABYLON {
  7725. /**
  7726. * Manages the defines for the Material
  7727. */
  7728. export class MaterialDefines {
  7729. /** @hidden */
  7730. protected _keys: string[];
  7731. private _isDirty;
  7732. /** @hidden */
  7733. _renderId: number;
  7734. /** @hidden */
  7735. _areLightsDirty: boolean;
  7736. /** @hidden */
  7737. _areLightsDisposed: boolean;
  7738. /** @hidden */
  7739. _areAttributesDirty: boolean;
  7740. /** @hidden */
  7741. _areTexturesDirty: boolean;
  7742. /** @hidden */
  7743. _areFresnelDirty: boolean;
  7744. /** @hidden */
  7745. _areMiscDirty: boolean;
  7746. /** @hidden */
  7747. _areImageProcessingDirty: boolean;
  7748. /** @hidden */
  7749. _normals: boolean;
  7750. /** @hidden */
  7751. _uvs: boolean;
  7752. /** @hidden */
  7753. _needNormals: boolean;
  7754. /** @hidden */
  7755. _needUVs: boolean;
  7756. [id: string]: any;
  7757. /**
  7758. * Specifies if the material needs to be re-calculated
  7759. */
  7760. readonly isDirty: boolean;
  7761. /**
  7762. * Marks the material to indicate that it has been re-calculated
  7763. */
  7764. markAsProcessed(): void;
  7765. /**
  7766. * Marks the material to indicate that it needs to be re-calculated
  7767. */
  7768. markAsUnprocessed(): void;
  7769. /**
  7770. * Marks the material to indicate all of its defines need to be re-calculated
  7771. */
  7772. markAllAsDirty(): void;
  7773. /**
  7774. * Marks the material to indicate that image processing needs to be re-calculated
  7775. */
  7776. markAsImageProcessingDirty(): void;
  7777. /**
  7778. * Marks the material to indicate the lights need to be re-calculated
  7779. * @param disposed Defines whether the light is dirty due to dispose or not
  7780. */
  7781. markAsLightDirty(disposed?: boolean): void;
  7782. /**
  7783. * Marks the attribute state as changed
  7784. */
  7785. markAsAttributesDirty(): void;
  7786. /**
  7787. * Marks the texture state as changed
  7788. */
  7789. markAsTexturesDirty(): void;
  7790. /**
  7791. * Marks the fresnel state as changed
  7792. */
  7793. markAsFresnelDirty(): void;
  7794. /**
  7795. * Marks the misc state as changed
  7796. */
  7797. markAsMiscDirty(): void;
  7798. /**
  7799. * Rebuilds the material defines
  7800. */
  7801. rebuild(): void;
  7802. /**
  7803. * Specifies if two material defines are equal
  7804. * @param other - A material define instance to compare to
  7805. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7806. */
  7807. isEqual(other: MaterialDefines): boolean;
  7808. /**
  7809. * Clones this instance's defines to another instance
  7810. * @param other - material defines to clone values to
  7811. */
  7812. cloneTo(other: MaterialDefines): void;
  7813. /**
  7814. * Resets the material define values
  7815. */
  7816. reset(): void;
  7817. /**
  7818. * Converts the material define values to a string
  7819. * @returns - String of material define information
  7820. */
  7821. toString(): string;
  7822. }
  7823. }
  7824. declare module BABYLON {
  7825. /**
  7826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7828. * 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;
  7829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7830. */
  7831. export class ColorCurves {
  7832. private _dirty;
  7833. private _tempColor;
  7834. private _globalCurve;
  7835. private _highlightsCurve;
  7836. private _midtonesCurve;
  7837. private _shadowsCurve;
  7838. private _positiveCurve;
  7839. private _negativeCurve;
  7840. private _globalHue;
  7841. private _globalDensity;
  7842. private _globalSaturation;
  7843. private _globalExposure;
  7844. /**
  7845. * Gets the global Hue value.
  7846. * 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).
  7847. */
  7848. /**
  7849. * Sets the global Hue value.
  7850. * 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).
  7851. */
  7852. globalHue: number;
  7853. /**
  7854. * Gets the global Density value.
  7855. * 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.
  7856. * Values less than zero provide a filter of opposite hue.
  7857. */
  7858. /**
  7859. * Sets the global Density value.
  7860. * 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.
  7861. * Values less than zero provide a filter of opposite hue.
  7862. */
  7863. globalDensity: number;
  7864. /**
  7865. * Gets the global Saturation value.
  7866. * 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.
  7867. */
  7868. /**
  7869. * Sets the global Saturation value.
  7870. * 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.
  7871. */
  7872. globalSaturation: number;
  7873. /**
  7874. * Gets the global Exposure value.
  7875. * 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.
  7876. */
  7877. /**
  7878. * Sets the global Exposure value.
  7879. * 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.
  7880. */
  7881. globalExposure: number;
  7882. private _highlightsHue;
  7883. private _highlightsDensity;
  7884. private _highlightsSaturation;
  7885. private _highlightsExposure;
  7886. /**
  7887. * Gets the highlights Hue value.
  7888. * 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).
  7889. */
  7890. /**
  7891. * Sets the highlights Hue value.
  7892. * 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).
  7893. */
  7894. highlightsHue: number;
  7895. /**
  7896. * Gets the highlights Density value.
  7897. * 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.
  7898. * Values less than zero provide a filter of opposite hue.
  7899. */
  7900. /**
  7901. * Sets the highlights Density value.
  7902. * 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.
  7903. * Values less than zero provide a filter of opposite hue.
  7904. */
  7905. highlightsDensity: number;
  7906. /**
  7907. * Gets the highlights Saturation value.
  7908. * 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.
  7909. */
  7910. /**
  7911. * Sets the highlights Saturation value.
  7912. * 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.
  7913. */
  7914. highlightsSaturation: number;
  7915. /**
  7916. * Gets the highlights Exposure value.
  7917. * 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.
  7918. */
  7919. /**
  7920. * Sets the highlights Exposure value.
  7921. * 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.
  7922. */
  7923. highlightsExposure: number;
  7924. private _midtonesHue;
  7925. private _midtonesDensity;
  7926. private _midtonesSaturation;
  7927. private _midtonesExposure;
  7928. /**
  7929. * Gets the midtones Hue value.
  7930. * 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).
  7931. */
  7932. /**
  7933. * Sets the midtones Hue value.
  7934. * 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).
  7935. */
  7936. midtonesHue: number;
  7937. /**
  7938. * Gets the midtones Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. /**
  7943. * Sets the midtones Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. midtonesDensity: number;
  7948. /**
  7949. * Gets the midtones Saturation value.
  7950. * 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.
  7951. */
  7952. /**
  7953. * Sets the midtones Saturation value.
  7954. * 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.
  7955. */
  7956. midtonesSaturation: number;
  7957. /**
  7958. * Gets the midtones Exposure value.
  7959. * 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.
  7960. */
  7961. /**
  7962. * Sets the midtones Exposure value.
  7963. * 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.
  7964. */
  7965. midtonesExposure: number;
  7966. private _shadowsHue;
  7967. private _shadowsDensity;
  7968. private _shadowsSaturation;
  7969. private _shadowsExposure;
  7970. /**
  7971. * Gets the shadows Hue value.
  7972. * 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).
  7973. */
  7974. /**
  7975. * Sets the shadows Hue value.
  7976. * 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).
  7977. */
  7978. shadowsHue: number;
  7979. /**
  7980. * Gets the shadows Density value.
  7981. * 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.
  7982. * Values less than zero provide a filter of opposite hue.
  7983. */
  7984. /**
  7985. * Sets the shadows Density value.
  7986. * 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.
  7987. * Values less than zero provide a filter of opposite hue.
  7988. */
  7989. shadowsDensity: number;
  7990. /**
  7991. * Gets the shadows Saturation value.
  7992. * 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.
  7993. */
  7994. /**
  7995. * Sets the shadows Saturation value.
  7996. * 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.
  7997. */
  7998. shadowsSaturation: number;
  7999. /**
  8000. * Gets the shadows Exposure value.
  8001. * 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.
  8002. */
  8003. /**
  8004. * Sets the shadows Exposure value.
  8005. * 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.
  8006. */
  8007. shadowsExposure: number;
  8008. /**
  8009. * Returns the class name
  8010. * @returns The class name
  8011. */
  8012. getClassName(): string;
  8013. /**
  8014. * Binds the color curves to the shader.
  8015. * @param colorCurves The color curve to bind
  8016. * @param effect The effect to bind to
  8017. * @param positiveUniform The positive uniform shader parameter
  8018. * @param neutralUniform The neutral uniform shader parameter
  8019. * @param negativeUniform The negative uniform shader parameter
  8020. */
  8021. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8022. /**
  8023. * Prepare the list of uniforms associated with the ColorCurves effects.
  8024. * @param uniformsList The list of uniforms used in the effect
  8025. */
  8026. static PrepareUniforms(uniformsList: string[]): void;
  8027. /**
  8028. * Returns color grading data based on a hue, density, saturation and exposure value.
  8029. * @param filterHue The hue of the color filter.
  8030. * @param filterDensity The density of the color filter.
  8031. * @param saturation The saturation.
  8032. * @param exposure The exposure.
  8033. * @param result The result data container.
  8034. */
  8035. private getColorGradingDataToRef;
  8036. /**
  8037. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8038. * @param value The input slider value in range [-100,100].
  8039. * @returns Adjusted value.
  8040. */
  8041. private static applyColorGradingSliderNonlinear;
  8042. /**
  8043. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8044. * @param hue The hue (H) input.
  8045. * @param saturation The saturation (S) input.
  8046. * @param brightness The brightness (B) input.
  8047. * @result An RGBA color represented as Vector4.
  8048. */
  8049. private static fromHSBToRef;
  8050. /**
  8051. * Returns a value clamped between min and max
  8052. * @param value The value to clamp
  8053. * @param min The minimum of value
  8054. * @param max The maximum of value
  8055. * @returns The clamped value.
  8056. */
  8057. private static clamp;
  8058. /**
  8059. * Clones the current color curve instance.
  8060. * @return The cloned curves
  8061. */
  8062. clone(): ColorCurves;
  8063. /**
  8064. * Serializes the current color curve instance to a json representation.
  8065. * @return a JSON representation
  8066. */
  8067. serialize(): any;
  8068. /**
  8069. * Parses the color curve from a json representation.
  8070. * @param source the JSON source to parse
  8071. * @return The parsed curves
  8072. */
  8073. static Parse(source: any): ColorCurves;
  8074. }
  8075. }
  8076. declare module BABYLON {
  8077. /**
  8078. * Interface to follow in your material defines to integrate easily the
  8079. * Image proccessing functions.
  8080. * @hidden
  8081. */
  8082. export interface IImageProcessingConfigurationDefines {
  8083. IMAGEPROCESSING: boolean;
  8084. VIGNETTE: boolean;
  8085. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8086. VIGNETTEBLENDMODEOPAQUE: boolean;
  8087. TONEMAPPING: boolean;
  8088. TONEMAPPING_ACES: boolean;
  8089. CONTRAST: boolean;
  8090. EXPOSURE: boolean;
  8091. COLORCURVES: boolean;
  8092. COLORGRADING: boolean;
  8093. COLORGRADING3D: boolean;
  8094. SAMPLER3DGREENDEPTH: boolean;
  8095. SAMPLER3DBGRMAP: boolean;
  8096. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8097. }
  8098. /**
  8099. * @hidden
  8100. */
  8101. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8102. IMAGEPROCESSING: boolean;
  8103. VIGNETTE: boolean;
  8104. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8105. VIGNETTEBLENDMODEOPAQUE: boolean;
  8106. TONEMAPPING: boolean;
  8107. TONEMAPPING_ACES: boolean;
  8108. CONTRAST: boolean;
  8109. COLORCURVES: boolean;
  8110. COLORGRADING: boolean;
  8111. COLORGRADING3D: boolean;
  8112. SAMPLER3DGREENDEPTH: boolean;
  8113. SAMPLER3DBGRMAP: boolean;
  8114. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8115. EXPOSURE: boolean;
  8116. constructor();
  8117. }
  8118. /**
  8119. * This groups together the common properties used for image processing either in direct forward pass
  8120. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8121. * or not.
  8122. */
  8123. export class ImageProcessingConfiguration {
  8124. /**
  8125. * Default tone mapping applied in BabylonJS.
  8126. */
  8127. static readonly TONEMAPPING_STANDARD: number;
  8128. /**
  8129. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8130. * to other engines rendering to increase portability.
  8131. */
  8132. static readonly TONEMAPPING_ACES: number;
  8133. /**
  8134. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8135. */
  8136. colorCurves: Nullable<ColorCurves>;
  8137. private _colorCurvesEnabled;
  8138. /**
  8139. * Gets wether the color curves effect is enabled.
  8140. */
  8141. /**
  8142. * Sets wether the color curves effect is enabled.
  8143. */
  8144. colorCurvesEnabled: boolean;
  8145. private _colorGradingTexture;
  8146. /**
  8147. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8148. */
  8149. /**
  8150. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8151. */
  8152. colorGradingTexture: Nullable<BaseTexture>;
  8153. private _colorGradingEnabled;
  8154. /**
  8155. * Gets wether the color grading effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the color grading effect is enabled.
  8159. */
  8160. colorGradingEnabled: boolean;
  8161. private _colorGradingWithGreenDepth;
  8162. /**
  8163. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8164. */
  8165. /**
  8166. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8167. */
  8168. colorGradingWithGreenDepth: boolean;
  8169. private _colorGradingBGR;
  8170. /**
  8171. * Gets wether the color grading texture contains BGR values.
  8172. */
  8173. /**
  8174. * Sets wether the color grading texture contains BGR values.
  8175. */
  8176. colorGradingBGR: boolean;
  8177. /** @hidden */
  8178. _exposure: number;
  8179. /**
  8180. * Gets the Exposure used in the effect.
  8181. */
  8182. /**
  8183. * Sets the Exposure used in the effect.
  8184. */
  8185. exposure: number;
  8186. private _toneMappingEnabled;
  8187. /**
  8188. * Gets wether the tone mapping effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the tone mapping effect is enabled.
  8192. */
  8193. toneMappingEnabled: boolean;
  8194. private _toneMappingType;
  8195. /**
  8196. * Gets the type of tone mapping effect.
  8197. */
  8198. /**
  8199. * Sets the type of tone mapping effect used in BabylonJS.
  8200. */
  8201. toneMappingType: number;
  8202. protected _contrast: number;
  8203. /**
  8204. * Gets the contrast used in the effect.
  8205. */
  8206. /**
  8207. * Sets the contrast used in the effect.
  8208. */
  8209. contrast: number;
  8210. /**
  8211. * Vignette stretch size.
  8212. */
  8213. vignetteStretch: number;
  8214. /**
  8215. * Vignette centre X Offset.
  8216. */
  8217. vignetteCentreX: number;
  8218. /**
  8219. * Vignette centre Y Offset.
  8220. */
  8221. vignetteCentreY: number;
  8222. /**
  8223. * Vignette weight or intensity of the vignette effect.
  8224. */
  8225. vignetteWeight: number;
  8226. /**
  8227. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8228. * if vignetteEnabled is set to true.
  8229. */
  8230. vignetteColor: Color4;
  8231. /**
  8232. * Camera field of view used by the Vignette effect.
  8233. */
  8234. vignetteCameraFov: number;
  8235. private _vignetteBlendMode;
  8236. /**
  8237. * Gets the vignette blend mode allowing different kind of effect.
  8238. */
  8239. /**
  8240. * Sets the vignette blend mode allowing different kind of effect.
  8241. */
  8242. vignetteBlendMode: number;
  8243. private _vignetteEnabled;
  8244. /**
  8245. * Gets wether the vignette effect is enabled.
  8246. */
  8247. /**
  8248. * Sets wether the vignette effect is enabled.
  8249. */
  8250. vignetteEnabled: boolean;
  8251. private _applyByPostProcess;
  8252. /**
  8253. * Gets wether the image processing is applied through a post process or not.
  8254. */
  8255. /**
  8256. * Sets wether the image processing is applied through a post process or not.
  8257. */
  8258. applyByPostProcess: boolean;
  8259. private _isEnabled;
  8260. /**
  8261. * Gets wether the image processing is enabled or not.
  8262. */
  8263. /**
  8264. * Sets wether the image processing is enabled or not.
  8265. */
  8266. isEnabled: boolean;
  8267. /**
  8268. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8269. */
  8270. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8271. /**
  8272. * Method called each time the image processing information changes requires to recompile the effect.
  8273. */
  8274. protected _updateParameters(): void;
  8275. /**
  8276. * Gets the current class name.
  8277. * @return "ImageProcessingConfiguration"
  8278. */
  8279. getClassName(): string;
  8280. /**
  8281. * Prepare the list of uniforms associated with the Image Processing effects.
  8282. * @param uniforms The list of uniforms used in the effect
  8283. * @param defines the list of defines currently in use
  8284. */
  8285. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8286. /**
  8287. * Prepare the list of samplers associated with the Image Processing effects.
  8288. * @param samplersList The list of uniforms used in the effect
  8289. * @param defines the list of defines currently in use
  8290. */
  8291. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8292. /**
  8293. * Prepare the list of defines associated to the shader.
  8294. * @param defines the list of defines to complete
  8295. * @param forPostProcess Define if we are currently in post process mode or not
  8296. */
  8297. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8298. /**
  8299. * Returns true if all the image processing information are ready.
  8300. * @returns True if ready, otherwise, false
  8301. */
  8302. isReady(): boolean;
  8303. /**
  8304. * Binds the image processing to the shader.
  8305. * @param effect The effect to bind to
  8306. * @param overrideAspectRatio Override the aspect ratio of the effect
  8307. */
  8308. bind(effect: Effect, overrideAspectRatio?: number): void;
  8309. /**
  8310. * Clones the current image processing instance.
  8311. * @return The cloned image processing
  8312. */
  8313. clone(): ImageProcessingConfiguration;
  8314. /**
  8315. * Serializes the current image processing instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the image processing from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed image processing
  8323. */
  8324. static Parse(source: any): ImageProcessingConfiguration;
  8325. private static _VIGNETTEMODE_MULTIPLY;
  8326. private static _VIGNETTEMODE_OPAQUE;
  8327. /**
  8328. * Used to apply the vignette as a mix with the pixel color.
  8329. */
  8330. static readonly VIGNETTEMODE_MULTIPLY: number;
  8331. /**
  8332. * Used to apply the vignette as a replacement of the pixel color.
  8333. */
  8334. static readonly VIGNETTEMODE_OPAQUE: number;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. /** @hidden */
  8339. export var postprocessVertexShader: {
  8340. name: string;
  8341. shader: string;
  8342. };
  8343. }
  8344. declare module BABYLON {
  8345. interface ThinEngine {
  8346. /**
  8347. * Creates a new render target texture
  8348. * @param size defines the size of the texture
  8349. * @param options defines the options used to create the texture
  8350. * @returns a new render target texture stored in an InternalTexture
  8351. */
  8352. createRenderTargetTexture(size: number | {
  8353. width: number;
  8354. height: number;
  8355. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8356. /**
  8357. * Creates a depth stencil texture.
  8358. * This is only available in WebGL 2 or with the depth texture extension available.
  8359. * @param size The size of face edge in the texture.
  8360. * @param options The options defining the texture.
  8361. * @returns The texture
  8362. */
  8363. createDepthStencilTexture(size: number | {
  8364. width: number;
  8365. height: number;
  8366. }, options: DepthTextureCreationOptions): InternalTexture;
  8367. /** @hidden */
  8368. _createDepthStencilTexture(size: number | {
  8369. width: number;
  8370. height: number;
  8371. }, options: DepthTextureCreationOptions): InternalTexture;
  8372. }
  8373. }
  8374. declare module BABYLON {
  8375. /** Defines supported spaces */
  8376. export enum Space {
  8377. /** Local (object) space */
  8378. LOCAL = 0,
  8379. /** World space */
  8380. WORLD = 1,
  8381. /** Bone space */
  8382. BONE = 2
  8383. }
  8384. /** Defines the 3 main axes */
  8385. export class Axis {
  8386. /** X axis */
  8387. static X: Vector3;
  8388. /** Y axis */
  8389. static Y: Vector3;
  8390. /** Z axis */
  8391. static Z: Vector3;
  8392. }
  8393. }
  8394. declare module BABYLON {
  8395. /**
  8396. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. */
  8400. export class TargetCamera extends Camera {
  8401. private static _RigCamTransformMatrix;
  8402. private static _TargetTransformMatrix;
  8403. private static _TargetFocalPoint;
  8404. /**
  8405. * Define the current direction the camera is moving to
  8406. */
  8407. cameraDirection: Vector3;
  8408. /**
  8409. * Define the current rotation the camera is rotating to
  8410. */
  8411. cameraRotation: Vector2;
  8412. /**
  8413. * When set, the up vector of the camera will be updated by the rotation of the camera
  8414. */
  8415. updateUpVectorFromRotation: boolean;
  8416. private _tmpQuaternion;
  8417. /**
  8418. * Define the current rotation of the camera
  8419. */
  8420. rotation: Vector3;
  8421. /**
  8422. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8423. */
  8424. rotationQuaternion: Quaternion;
  8425. /**
  8426. * Define the current speed of the camera
  8427. */
  8428. speed: number;
  8429. /**
  8430. * Add constraint to the camera to prevent it to move freely in all directions and
  8431. * around all axis.
  8432. */
  8433. noRotationConstraint: boolean;
  8434. /**
  8435. * Define the current target of the camera as an object or a position.
  8436. */
  8437. lockedTarget: any;
  8438. /** @hidden */
  8439. _currentTarget: Vector3;
  8440. /** @hidden */
  8441. _initialFocalDistance: number;
  8442. /** @hidden */
  8443. _viewMatrix: Matrix;
  8444. /** @hidden */
  8445. _camMatrix: Matrix;
  8446. /** @hidden */
  8447. _cameraTransformMatrix: Matrix;
  8448. /** @hidden */
  8449. _cameraRotationMatrix: Matrix;
  8450. /** @hidden */
  8451. _referencePoint: Vector3;
  8452. /** @hidden */
  8453. _transformedReferencePoint: Vector3;
  8454. protected _globalCurrentTarget: Vector3;
  8455. protected _globalCurrentUpVector: Vector3;
  8456. /** @hidden */
  8457. _reset: () => void;
  8458. private _defaultUp;
  8459. /**
  8460. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8461. * This is the base of the follow, arc rotate cameras and Free camera
  8462. * @see http://doc.babylonjs.com/features/cameras
  8463. * @param name Defines the name of the camera in the scene
  8464. * @param position Defines the start position of the camera in the scene
  8465. * @param scene Defines the scene the camera belongs to
  8466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8467. */
  8468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8469. /**
  8470. * Gets the position in front of the camera at a given distance.
  8471. * @param distance The distance from the camera we want the position to be
  8472. * @returns the position
  8473. */
  8474. getFrontPosition(distance: number): Vector3;
  8475. /** @hidden */
  8476. _getLockedTargetPosition(): Nullable<Vector3>;
  8477. private _storedPosition;
  8478. private _storedRotation;
  8479. private _storedRotationQuaternion;
  8480. /**
  8481. * Store current camera state of the camera (fov, position, rotation, etc..)
  8482. * @returns the camera
  8483. */
  8484. storeState(): Camera;
  8485. /**
  8486. * Restored camera state. You must call storeState() first
  8487. * @returns whether it was successful or not
  8488. * @hidden
  8489. */
  8490. _restoreStateValues(): boolean;
  8491. /** @hidden */
  8492. _initCache(): void;
  8493. /** @hidden */
  8494. _updateCache(ignoreParentClass?: boolean): void;
  8495. /** @hidden */
  8496. _isSynchronizedViewMatrix(): boolean;
  8497. /** @hidden */
  8498. _computeLocalCameraSpeed(): number;
  8499. /**
  8500. * Defines the target the camera should look at.
  8501. * @param target Defines the new target as a Vector or a mesh
  8502. */
  8503. setTarget(target: Vector3): void;
  8504. /**
  8505. * Return the current target position of the camera. This value is expressed in local space.
  8506. * @returns the target position
  8507. */
  8508. getTarget(): Vector3;
  8509. /** @hidden */
  8510. _decideIfNeedsToMove(): boolean;
  8511. /** @hidden */
  8512. _updatePosition(): void;
  8513. /** @hidden */
  8514. _checkInputs(): void;
  8515. protected _updateCameraRotationMatrix(): void;
  8516. /**
  8517. * 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)
  8518. * @returns the current camera
  8519. */
  8520. private _rotateUpVectorWithCameraRotationMatrix;
  8521. private _cachedRotationZ;
  8522. private _cachedQuaternionRotationZ;
  8523. /** @hidden */
  8524. _getViewMatrix(): Matrix;
  8525. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8526. /**
  8527. * @hidden
  8528. */
  8529. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8530. /**
  8531. * @hidden
  8532. */
  8533. _updateRigCameras(): void;
  8534. private _getRigCamPositionAndTarget;
  8535. /**
  8536. * Gets the current object class name.
  8537. * @return the class name
  8538. */
  8539. getClassName(): string;
  8540. }
  8541. }
  8542. declare module BABYLON {
  8543. /**
  8544. * Gather the list of keyboard event types as constants.
  8545. */
  8546. export class KeyboardEventTypes {
  8547. /**
  8548. * The keydown event is fired when a key becomes active (pressed).
  8549. */
  8550. static readonly KEYDOWN: number;
  8551. /**
  8552. * The keyup event is fired when a key has been released.
  8553. */
  8554. static readonly KEYUP: number;
  8555. }
  8556. /**
  8557. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8558. */
  8559. export class KeyboardInfo {
  8560. /**
  8561. * Defines the type of event (KeyboardEventTypes)
  8562. */
  8563. type: number;
  8564. /**
  8565. * Defines the related dom event
  8566. */
  8567. event: KeyboardEvent;
  8568. /**
  8569. * Instantiates a new keyboard info.
  8570. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8571. * @param type Defines the type of event (KeyboardEventTypes)
  8572. * @param event Defines the related dom event
  8573. */
  8574. constructor(
  8575. /**
  8576. * Defines the type of event (KeyboardEventTypes)
  8577. */
  8578. type: number,
  8579. /**
  8580. * Defines the related dom event
  8581. */
  8582. event: KeyboardEvent);
  8583. }
  8584. /**
  8585. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8586. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8587. */
  8588. export class KeyboardInfoPre extends KeyboardInfo {
  8589. /**
  8590. * Defines the type of event (KeyboardEventTypes)
  8591. */
  8592. type: number;
  8593. /**
  8594. * Defines the related dom event
  8595. */
  8596. event: KeyboardEvent;
  8597. /**
  8598. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8599. */
  8600. skipOnPointerObservable: boolean;
  8601. /**
  8602. * Instantiates a new keyboard pre info.
  8603. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8604. * @param type Defines the type of event (KeyboardEventTypes)
  8605. * @param event Defines the related dom event
  8606. */
  8607. constructor(
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number,
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent);
  8616. }
  8617. }
  8618. declare module BABYLON {
  8619. /**
  8620. * Manage the keyboard inputs to control the movement of a free camera.
  8621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8622. */
  8623. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8624. /**
  8625. * Defines the camera the input is attached to.
  8626. */
  8627. camera: FreeCamera;
  8628. /**
  8629. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8630. */
  8631. keysUp: number[];
  8632. /**
  8633. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8634. */
  8635. keysDown: number[];
  8636. /**
  8637. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8638. */
  8639. keysLeft: number[];
  8640. /**
  8641. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8642. */
  8643. keysRight: number[];
  8644. private _keys;
  8645. private _onCanvasBlurObserver;
  8646. private _onKeyboardObserver;
  8647. private _engine;
  8648. private _scene;
  8649. /**
  8650. * Attach the input controls to a specific dom element to get the input from.
  8651. * @param element Defines the element the controls should be listened from
  8652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8653. */
  8654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8655. /**
  8656. * Detach the current controls from the specified dom element.
  8657. * @param element Defines the element to stop listening the inputs from
  8658. */
  8659. detachControl(element: Nullable<HTMLElement>): void;
  8660. /**
  8661. * Update the current camera state depending on the inputs that have been used this frame.
  8662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8663. */
  8664. checkInputs(): void;
  8665. /**
  8666. * Gets the class name of the current intput.
  8667. * @returns the class name
  8668. */
  8669. getClassName(): string;
  8670. /** @hidden */
  8671. _onLostFocus(): void;
  8672. /**
  8673. * Get the friendly name associated with the input class.
  8674. * @returns the input friendly name
  8675. */
  8676. getSimpleName(): string;
  8677. }
  8678. }
  8679. declare module BABYLON {
  8680. /**
  8681. * Interface describing all the common properties and methods a shadow light needs to implement.
  8682. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8683. * as well as binding the different shadow properties to the effects.
  8684. */
  8685. export interface IShadowLight extends Light {
  8686. /**
  8687. * The light id in the scene (used in scene.findLighById for instance)
  8688. */
  8689. id: string;
  8690. /**
  8691. * The position the shdow will be casted from.
  8692. */
  8693. position: Vector3;
  8694. /**
  8695. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8696. */
  8697. direction: Vector3;
  8698. /**
  8699. * The transformed position. Position of the light in world space taking parenting in account.
  8700. */
  8701. transformedPosition: Vector3;
  8702. /**
  8703. * The transformed direction. Direction of the light in world space taking parenting in account.
  8704. */
  8705. transformedDirection: Vector3;
  8706. /**
  8707. * The friendly name of the light in the scene.
  8708. */
  8709. name: string;
  8710. /**
  8711. * Defines the shadow projection clipping minimum z value.
  8712. */
  8713. shadowMinZ: number;
  8714. /**
  8715. * Defines the shadow projection clipping maximum z value.
  8716. */
  8717. shadowMaxZ: number;
  8718. /**
  8719. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8720. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8721. */
  8722. computeTransformedInformation(): boolean;
  8723. /**
  8724. * Gets the scene the light belongs to.
  8725. * @returns The scene
  8726. */
  8727. getScene(): Scene;
  8728. /**
  8729. * Callback defining a custom Projection Matrix Builder.
  8730. * This can be used to override the default projection matrix computation.
  8731. */
  8732. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8733. /**
  8734. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8735. * @param matrix The materix to updated with the projection information
  8736. * @param viewMatrix The transform matrix of the light
  8737. * @param renderList The list of mesh to render in the map
  8738. * @returns The current light
  8739. */
  8740. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8741. /**
  8742. * Gets the current depth scale used in ESM.
  8743. * @returns The scale
  8744. */
  8745. getDepthScale(): number;
  8746. /**
  8747. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8748. * @returns true if a cube texture needs to be use
  8749. */
  8750. needCube(): boolean;
  8751. /**
  8752. * Detects if the projection matrix requires to be recomputed this frame.
  8753. * @returns true if it requires to be recomputed otherwise, false.
  8754. */
  8755. needProjectionMatrixCompute(): boolean;
  8756. /**
  8757. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8758. */
  8759. forceProjectionMatrixCompute(): void;
  8760. /**
  8761. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8762. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8763. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8764. */
  8765. getShadowDirection(faceIndex?: number): Vector3;
  8766. /**
  8767. * Gets the minZ used for shadow according to both the scene and the light.
  8768. * @param activeCamera The camera we are returning the min for
  8769. * @returns the depth min z
  8770. */
  8771. getDepthMinZ(activeCamera: Camera): number;
  8772. /**
  8773. * Gets the maxZ used for shadow according to both the scene and the light.
  8774. * @param activeCamera The camera we are returning the max for
  8775. * @returns the depth max z
  8776. */
  8777. getDepthMaxZ(activeCamera: Camera): number;
  8778. }
  8779. /**
  8780. * Base implementation IShadowLight
  8781. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8782. */
  8783. export abstract class ShadowLight extends Light implements IShadowLight {
  8784. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8785. protected _position: Vector3;
  8786. protected _setPosition(value: Vector3): void;
  8787. /**
  8788. * Sets the position the shadow will be casted from. Also use as the light position for both
  8789. * point and spot lights.
  8790. */
  8791. /**
  8792. * Sets the position the shadow will be casted from. Also use as the light position for both
  8793. * point and spot lights.
  8794. */
  8795. position: Vector3;
  8796. protected _direction: Vector3;
  8797. protected _setDirection(value: Vector3): void;
  8798. /**
  8799. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8800. * Also use as the light direction on spot and directional lights.
  8801. */
  8802. /**
  8803. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8804. * Also use as the light direction on spot and directional lights.
  8805. */
  8806. direction: Vector3;
  8807. private _shadowMinZ;
  8808. /**
  8809. * Gets the shadow projection clipping minimum z value.
  8810. */
  8811. /**
  8812. * Sets the shadow projection clipping minimum z value.
  8813. */
  8814. shadowMinZ: number;
  8815. private _shadowMaxZ;
  8816. /**
  8817. * Sets the shadow projection clipping maximum z value.
  8818. */
  8819. /**
  8820. * Gets the shadow projection clipping maximum z value.
  8821. */
  8822. shadowMaxZ: number;
  8823. /**
  8824. * Callback defining a custom Projection Matrix Builder.
  8825. * This can be used to override the default projection matrix computation.
  8826. */
  8827. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8828. /**
  8829. * The transformed position. Position of the light in world space taking parenting in account.
  8830. */
  8831. transformedPosition: Vector3;
  8832. /**
  8833. * The transformed direction. Direction of the light in world space taking parenting in account.
  8834. */
  8835. transformedDirection: Vector3;
  8836. private _needProjectionMatrixCompute;
  8837. /**
  8838. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8839. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8840. */
  8841. computeTransformedInformation(): boolean;
  8842. /**
  8843. * Return the depth scale used for the shadow map.
  8844. * @returns the depth scale.
  8845. */
  8846. getDepthScale(): number;
  8847. /**
  8848. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8849. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8850. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8851. */
  8852. getShadowDirection(faceIndex?: number): Vector3;
  8853. /**
  8854. * Returns the ShadowLight absolute position in the World.
  8855. * @returns the position vector in world space
  8856. */
  8857. getAbsolutePosition(): Vector3;
  8858. /**
  8859. * Sets the ShadowLight direction toward the passed target.
  8860. * @param target The point to target in local space
  8861. * @returns the updated ShadowLight direction
  8862. */
  8863. setDirectionToTarget(target: Vector3): Vector3;
  8864. /**
  8865. * Returns the light rotation in euler definition.
  8866. * @returns the x y z rotation in local space.
  8867. */
  8868. getRotation(): Vector3;
  8869. /**
  8870. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8871. * @returns true if a cube texture needs to be use
  8872. */
  8873. needCube(): boolean;
  8874. /**
  8875. * Detects if the projection matrix requires to be recomputed this frame.
  8876. * @returns true if it requires to be recomputed otherwise, false.
  8877. */
  8878. needProjectionMatrixCompute(): boolean;
  8879. /**
  8880. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8881. */
  8882. forceProjectionMatrixCompute(): void;
  8883. /** @hidden */
  8884. _initCache(): void;
  8885. /** @hidden */
  8886. _isSynchronized(): boolean;
  8887. /**
  8888. * Computes the world matrix of the node
  8889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8890. * @returns the world matrix
  8891. */
  8892. computeWorldMatrix(force?: boolean): Matrix;
  8893. /**
  8894. * Gets the minZ used for shadow according to both the scene and the light.
  8895. * @param activeCamera The camera we are returning the min for
  8896. * @returns the depth min z
  8897. */
  8898. getDepthMinZ(activeCamera: Camera): number;
  8899. /**
  8900. * Gets the maxZ used for shadow according to both the scene and the light.
  8901. * @param activeCamera The camera we are returning the max for
  8902. * @returns the depth max z
  8903. */
  8904. getDepthMaxZ(activeCamera: Camera): number;
  8905. /**
  8906. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8907. * @param matrix The materix to updated with the projection information
  8908. * @param viewMatrix The transform matrix of the light
  8909. * @param renderList The list of mesh to render in the map
  8910. * @returns The current light
  8911. */
  8912. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8913. }
  8914. }
  8915. declare module BABYLON {
  8916. /**
  8917. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8918. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8919. */
  8920. export class EffectFallbacks implements IEffectFallbacks {
  8921. private _defines;
  8922. private _currentRank;
  8923. private _maxRank;
  8924. private _mesh;
  8925. /**
  8926. * Removes the fallback from the bound mesh.
  8927. */
  8928. unBindMesh(): void;
  8929. /**
  8930. * Adds a fallback on the specified property.
  8931. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8932. * @param define The name of the define in the shader
  8933. */
  8934. addFallback(rank: number, define: string): void;
  8935. /**
  8936. * Sets the mesh to use CPU skinning when needing to fallback.
  8937. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8938. * @param mesh The mesh to use the fallbacks.
  8939. */
  8940. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8941. /**
  8942. * Checks to see if more fallbacks are still availible.
  8943. */
  8944. readonly hasMoreFallbacks: boolean;
  8945. /**
  8946. * Removes the defines that should be removed when falling back.
  8947. * @param currentDefines defines the current define statements for the shader.
  8948. * @param effect defines the current effect we try to compile
  8949. * @returns The resulting defines with defines of the current rank removed.
  8950. */
  8951. reduce(currentDefines: string, effect: Effect): string;
  8952. }
  8953. }
  8954. declare module BABYLON {
  8955. /**
  8956. * "Static Class" containing the most commonly used helper while dealing with material for
  8957. * rendering purpose.
  8958. *
  8959. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8960. *
  8961. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8962. */
  8963. export class MaterialHelper {
  8964. /**
  8965. * Bind the current view position to an effect.
  8966. * @param effect The effect to be bound
  8967. * @param scene The scene the eyes position is used from
  8968. */
  8969. static BindEyePosition(effect: Effect, scene: Scene): void;
  8970. /**
  8971. * Helps preparing the defines values about the UVs in used in the effect.
  8972. * UVs are shared as much as we can accross channels in the shaders.
  8973. * @param texture The texture we are preparing the UVs for
  8974. * @param defines The defines to update
  8975. * @param key The channel key "diffuse", "specular"... used in the shader
  8976. */
  8977. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8978. /**
  8979. * Binds a texture matrix value to its corrsponding uniform
  8980. * @param texture The texture to bind the matrix for
  8981. * @param uniformBuffer The uniform buffer receivin the data
  8982. * @param key The channel key "diffuse", "specular"... used in the shader
  8983. */
  8984. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8985. /**
  8986. * Gets the current status of the fog (should it be enabled?)
  8987. * @param mesh defines the mesh to evaluate for fog support
  8988. * @param scene defines the hosting scene
  8989. * @returns true if fog must be enabled
  8990. */
  8991. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8992. /**
  8993. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8994. * @param mesh defines the current mesh
  8995. * @param scene defines the current scene
  8996. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8997. * @param pointsCloud defines if point cloud rendering has to be turned on
  8998. * @param fogEnabled defines if fog has to be turned on
  8999. * @param alphaTest defines if alpha testing has to be turned on
  9000. * @param defines defines the current list of defines
  9001. */
  9002. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9003. /**
  9004. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9005. * @param scene defines the current scene
  9006. * @param engine defines the current engine
  9007. * @param defines specifies the list of active defines
  9008. * @param useInstances defines if instances have to be turned on
  9009. * @param useClipPlane defines if clip plane have to be turned on
  9010. */
  9011. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9012. /**
  9013. * Prepares the defines for bones
  9014. * @param mesh The mesh containing the geometry data we will draw
  9015. * @param defines The defines to update
  9016. */
  9017. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9018. /**
  9019. * Prepares the defines for morph targets
  9020. * @param mesh The mesh containing the geometry data we will draw
  9021. * @param defines The defines to update
  9022. */
  9023. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9024. /**
  9025. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9026. * @param mesh The mesh containing the geometry data we will draw
  9027. * @param defines The defines to update
  9028. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9029. * @param useBones Precise whether bones should be used or not (override mesh info)
  9030. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9031. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9032. * @returns false if defines are considered not dirty and have not been checked
  9033. */
  9034. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9035. /**
  9036. * Prepares the defines related to multiview
  9037. * @param scene The scene we are intending to draw
  9038. * @param defines The defines to update
  9039. */
  9040. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9041. /**
  9042. * Prepares the defines related to the light information passed in parameter
  9043. * @param scene The scene we are intending to draw
  9044. * @param mesh The mesh the effect is compiling for
  9045. * @param light The light the effect is compiling for
  9046. * @param lightIndex The index of the light
  9047. * @param defines The defines to update
  9048. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9049. * @param state Defines the current state regarding what is needed (normals, etc...)
  9050. */
  9051. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9052. needNormals: boolean;
  9053. needRebuild: boolean;
  9054. shadowEnabled: boolean;
  9055. specularEnabled: boolean;
  9056. lightmapMode: boolean;
  9057. }): void;
  9058. /**
  9059. * Prepares the defines related to the light information passed in parameter
  9060. * @param scene The scene we are intending to draw
  9061. * @param mesh The mesh the effect is compiling for
  9062. * @param defines The defines to update
  9063. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9064. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9065. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9066. * @returns true if normals will be required for the rest of the effect
  9067. */
  9068. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9069. /**
  9070. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9071. * @param lightIndex defines the light index
  9072. * @param uniformsList The uniform list
  9073. * @param samplersList The sampler list
  9074. * @param projectedLightTexture defines if projected texture must be used
  9075. * @param uniformBuffersList defines an optional list of uniform buffers
  9076. */
  9077. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9078. /**
  9079. * Prepares the uniforms and samplers list to be used in the effect
  9080. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9081. * @param samplersList The sampler list
  9082. * @param defines The defines helping in the list generation
  9083. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9084. */
  9085. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9086. /**
  9087. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9088. * @param defines The defines to update while falling back
  9089. * @param fallbacks The authorized effect fallbacks
  9090. * @param maxSimultaneousLights The maximum number of lights allowed
  9091. * @param rank the current rank of the Effect
  9092. * @returns The newly affected rank
  9093. */
  9094. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9095. private static _TmpMorphInfluencers;
  9096. /**
  9097. * Prepares the list of attributes required for morph targets according to the effect defines.
  9098. * @param attribs The current list of supported attribs
  9099. * @param mesh The mesh to prepare the morph targets attributes for
  9100. * @param influencers The number of influencers
  9101. */
  9102. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9103. /**
  9104. * Prepares the list of attributes required for morph targets according to the effect defines.
  9105. * @param attribs The current list of supported attribs
  9106. * @param mesh The mesh to prepare the morph targets attributes for
  9107. * @param defines The current Defines of the effect
  9108. */
  9109. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9110. /**
  9111. * Prepares the list of attributes required for bones according to the effect defines.
  9112. * @param attribs The current list of supported attribs
  9113. * @param mesh The mesh to prepare the bones attributes for
  9114. * @param defines The current Defines of the effect
  9115. * @param fallbacks The current efffect fallback strategy
  9116. */
  9117. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9118. /**
  9119. * Check and prepare the list of attributes required for instances according to the effect defines.
  9120. * @param attribs The current list of supported attribs
  9121. * @param defines The current MaterialDefines of the effect
  9122. */
  9123. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9124. /**
  9125. * Add the list of attributes required for instances to the attribs array.
  9126. * @param attribs The current list of supported attribs
  9127. */
  9128. static PushAttributesForInstances(attribs: string[]): void;
  9129. /**
  9130. * Binds the light information to the effect.
  9131. * @param light The light containing the generator
  9132. * @param effect The effect we are binding the data to
  9133. * @param lightIndex The light index in the effect used to render
  9134. */
  9135. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9136. /**
  9137. * Binds the lights information from the scene to the effect for the given mesh.
  9138. * @param light Light to bind
  9139. * @param lightIndex Light index
  9140. * @param scene The scene where the light belongs to
  9141. * @param effect The effect we are binding the data to
  9142. * @param useSpecular Defines if specular is supported
  9143. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9145. */
  9146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9147. /**
  9148. * Binds the lights information from the scene to the effect for the given mesh.
  9149. * @param scene The scene the lights belongs to
  9150. * @param mesh The mesh we are binding the information to render
  9151. * @param effect The effect we are binding the data to
  9152. * @param defines The generated defines for the effect
  9153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9154. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9155. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9156. */
  9157. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9158. private static _tempFogColor;
  9159. /**
  9160. * Binds the fog information from the scene to the effect for the given mesh.
  9161. * @param scene The scene the lights belongs to
  9162. * @param mesh The mesh we are binding the information to render
  9163. * @param effect The effect we are binding the data to
  9164. * @param linearSpace Defines if the fog effect is applied in linear space
  9165. */
  9166. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9167. /**
  9168. * Binds the bones information from the mesh to the effect.
  9169. * @param mesh The mesh we are binding the information to render
  9170. * @param effect The effect we are binding the data to
  9171. */
  9172. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9173. /**
  9174. * Binds the morph targets information from the mesh to the effect.
  9175. * @param abstractMesh The mesh we are binding the information to render
  9176. * @param effect The effect we are binding the data to
  9177. */
  9178. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9179. /**
  9180. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9181. * @param defines The generated defines used in the effect
  9182. * @param effect The effect we are binding the data to
  9183. * @param scene The scene we are willing to render with logarithmic scale for
  9184. */
  9185. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9186. /**
  9187. * Binds the clip plane information from the scene to the effect.
  9188. * @param scene The scene the clip plane information are extracted from
  9189. * @param effect The effect we are binding the data to
  9190. */
  9191. static BindClipPlane(effect: Effect, scene: Scene): void;
  9192. }
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var packingFunctions: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var shadowMapPixelShader: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesDeclaration: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var morphTargetsVertexGlobalDeclaration: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var morphTargetsVertexDeclaration: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var instancesDeclaration: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var helperFunctions: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var morphTargetsVertex: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var instancesVertex: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var bonesVertex: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /** @hidden */
  9266. export var shadowMapVertexShader: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module BABYLON {
  9272. /** @hidden */
  9273. export var depthBoxBlurPixelShader: {
  9274. name: string;
  9275. shader: string;
  9276. };
  9277. }
  9278. declare module BABYLON {
  9279. /**
  9280. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9281. */
  9282. export interface ICustomShaderOptions {
  9283. /**
  9284. * Gets or sets the custom shader name to use
  9285. */
  9286. shaderName: string;
  9287. /**
  9288. * The list of attribute names used in the shader
  9289. */
  9290. attributes?: string[];
  9291. /**
  9292. * The list of unifrom names used in the shader
  9293. */
  9294. uniforms?: string[];
  9295. /**
  9296. * The list of sampler names used in the shader
  9297. */
  9298. samplers?: string[];
  9299. /**
  9300. * The list of defines used in the shader
  9301. */
  9302. defines?: string[];
  9303. }
  9304. /**
  9305. * Interface to implement to create a shadow generator compatible with BJS.
  9306. */
  9307. export interface IShadowGenerator {
  9308. /**
  9309. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9310. * @returns The render target texture if present otherwise, null
  9311. */
  9312. getShadowMap(): Nullable<RenderTargetTexture>;
  9313. /**
  9314. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9315. * @returns The render target texture if the shadow map is present otherwise, null
  9316. */
  9317. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9318. /**
  9319. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9320. * @param subMesh The submesh we want to render in the shadow map
  9321. * @param useInstances Defines wether will draw in the map using instances
  9322. * @returns true if ready otherwise, false
  9323. */
  9324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9325. /**
  9326. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9327. * @param defines Defines of the material we want to update
  9328. * @param lightIndex Index of the light in the enabled light list of the material
  9329. */
  9330. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9331. /**
  9332. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9333. * defined in the generator but impacting the effect).
  9334. * It implies the unifroms available on the materials are the standard BJS ones.
  9335. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9336. * @param effect The effect we are binfing the information for
  9337. */
  9338. bindShadowLight(lightIndex: string, effect: Effect): void;
  9339. /**
  9340. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9341. * (eq to shadow prjection matrix * light transform matrix)
  9342. * @returns The transform matrix used to create the shadow map
  9343. */
  9344. getTransformMatrix(): Matrix;
  9345. /**
  9346. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9347. * Cube and 2D textures for instance.
  9348. */
  9349. recreateShadowMap(): void;
  9350. /**
  9351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9352. * @param onCompiled Callback triggered at the and of the effects compilation
  9353. * @param options Sets of optional options forcing the compilation with different modes
  9354. */
  9355. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9356. useInstances: boolean;
  9357. }>): void;
  9358. /**
  9359. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9360. * @param options Sets of optional options forcing the compilation with different modes
  9361. * @returns A promise that resolves when the compilation completes
  9362. */
  9363. forceCompilationAsync(options?: Partial<{
  9364. useInstances: boolean;
  9365. }>): Promise<void>;
  9366. /**
  9367. * Serializes the shadow generator setup to a json object.
  9368. * @returns The serialized JSON object
  9369. */
  9370. serialize(): any;
  9371. /**
  9372. * Disposes the Shadow map and related Textures and effects.
  9373. */
  9374. dispose(): void;
  9375. }
  9376. /**
  9377. * Default implementation IShadowGenerator.
  9378. * This is the main object responsible of generating shadows in the framework.
  9379. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9380. */
  9381. export class ShadowGenerator implements IShadowGenerator {
  9382. /**
  9383. * Shadow generator mode None: no filtering applied.
  9384. */
  9385. static readonly FILTER_NONE: number;
  9386. /**
  9387. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9393. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9394. */
  9395. static readonly FILTER_POISSONSAMPLING: number;
  9396. /**
  9397. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9398. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9399. */
  9400. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9401. /**
  9402. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9403. * edge artifacts on steep falloff.
  9404. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9405. */
  9406. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9407. /**
  9408. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9409. * edge artifacts on steep falloff.
  9410. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9411. */
  9412. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9413. /**
  9414. * Shadow generator mode PCF: Percentage Closer Filtering
  9415. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9416. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9417. */
  9418. static readonly FILTER_PCF: number;
  9419. /**
  9420. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9421. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9422. * Contact Hardening
  9423. */
  9424. static readonly FILTER_PCSS: number;
  9425. /**
  9426. * Reserved for PCF and PCSS
  9427. * Highest Quality.
  9428. *
  9429. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9430. *
  9431. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9432. */
  9433. static readonly QUALITY_HIGH: number;
  9434. /**
  9435. * Reserved for PCF and PCSS
  9436. * Good tradeoff for quality/perf cross devices
  9437. *
  9438. * Execute PCF on a 3*3 kernel.
  9439. *
  9440. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9441. */
  9442. static readonly QUALITY_MEDIUM: number;
  9443. /**
  9444. * Reserved for PCF and PCSS
  9445. * The lowest quality but the fastest.
  9446. *
  9447. * Execute PCF on a 1*1 kernel.
  9448. *
  9449. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9450. */
  9451. static readonly QUALITY_LOW: number;
  9452. /** Gets or sets the custom shader name to use */
  9453. customShaderOptions: ICustomShaderOptions;
  9454. /**
  9455. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9456. */
  9457. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9458. /**
  9459. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9460. */
  9461. onAfterShadowMapRenderObservable: Observable<Effect>;
  9462. /**
  9463. * Observable triggered before a mesh is rendered in the shadow map.
  9464. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9465. */
  9466. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9467. /**
  9468. * Observable triggered after a mesh is rendered in the shadow map.
  9469. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9470. */
  9471. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9472. private _bias;
  9473. /**
  9474. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9475. */
  9476. /**
  9477. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9478. */
  9479. bias: number;
  9480. private _normalBias;
  9481. /**
  9482. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9483. */
  9484. /**
  9485. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9486. */
  9487. normalBias: number;
  9488. private _blurBoxOffset;
  9489. /**
  9490. * Gets the blur box offset: offset applied during the blur pass.
  9491. * Only useful if useKernelBlur = false
  9492. */
  9493. /**
  9494. * Sets the blur box offset: offset applied during the blur pass.
  9495. * Only useful if useKernelBlur = false
  9496. */
  9497. blurBoxOffset: number;
  9498. private _blurScale;
  9499. /**
  9500. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9501. * 2 means half of the size.
  9502. */
  9503. /**
  9504. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9505. * 2 means half of the size.
  9506. */
  9507. blurScale: number;
  9508. private _blurKernel;
  9509. /**
  9510. * Gets the blur kernel: kernel size of the blur pass.
  9511. * Only useful if useKernelBlur = true
  9512. */
  9513. /**
  9514. * Sets the blur kernel: kernel size of the blur pass.
  9515. * Only useful if useKernelBlur = true
  9516. */
  9517. blurKernel: number;
  9518. private _useKernelBlur;
  9519. /**
  9520. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9521. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9522. */
  9523. /**
  9524. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9525. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9526. */
  9527. useKernelBlur: boolean;
  9528. private _depthScale;
  9529. /**
  9530. * Gets the depth scale used in ESM mode.
  9531. */
  9532. /**
  9533. * Sets the depth scale used in ESM mode.
  9534. * This can override the scale stored on the light.
  9535. */
  9536. depthScale: number;
  9537. private _filter;
  9538. /**
  9539. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9540. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9541. */
  9542. /**
  9543. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9544. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9545. */
  9546. filter: number;
  9547. /**
  9548. * Gets if the current filter is set to Poisson Sampling.
  9549. */
  9550. /**
  9551. * Sets the current filter to Poisson Sampling.
  9552. */
  9553. usePoissonSampling: boolean;
  9554. /**
  9555. * Gets if the current filter is set to ESM.
  9556. */
  9557. /**
  9558. * Sets the current filter is to ESM.
  9559. */
  9560. useExponentialShadowMap: boolean;
  9561. /**
  9562. * Gets if the current filter is set to filtered ESM.
  9563. */
  9564. /**
  9565. * Gets if the current filter is set to filtered ESM.
  9566. */
  9567. useBlurExponentialShadowMap: boolean;
  9568. /**
  9569. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9570. * exponential to prevent steep falloff artifacts).
  9571. */
  9572. /**
  9573. * Sets the current filter to "close ESM" (using the inverse of the
  9574. * exponential to prevent steep falloff artifacts).
  9575. */
  9576. useCloseExponentialShadowMap: boolean;
  9577. /**
  9578. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9579. * exponential to prevent steep falloff artifacts).
  9580. */
  9581. /**
  9582. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9583. * exponential to prevent steep falloff artifacts).
  9584. */
  9585. useBlurCloseExponentialShadowMap: boolean;
  9586. /**
  9587. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9588. */
  9589. /**
  9590. * Sets the current filter to "PCF" (percentage closer filtering).
  9591. */
  9592. usePercentageCloserFiltering: boolean;
  9593. private _filteringQuality;
  9594. /**
  9595. * Gets the PCF or PCSS Quality.
  9596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9597. */
  9598. /**
  9599. * Sets the PCF or PCSS Quality.
  9600. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9601. */
  9602. filteringQuality: number;
  9603. /**
  9604. * Gets if the current filter is set to "PCSS" (contact hardening).
  9605. */
  9606. /**
  9607. * Sets the current filter to "PCSS" (contact hardening).
  9608. */
  9609. useContactHardeningShadow: boolean;
  9610. private _contactHardeningLightSizeUVRatio;
  9611. /**
  9612. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9613. * Using a ratio helps keeping shape stability independently of the map size.
  9614. *
  9615. * It does not account for the light projection as it was having too much
  9616. * instability during the light setup or during light position changes.
  9617. *
  9618. * Only valid if useContactHardeningShadow is true.
  9619. */
  9620. /**
  9621. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9622. * Using a ratio helps keeping shape stability independently of the map size.
  9623. *
  9624. * It does not account for the light projection as it was having too much
  9625. * instability during the light setup or during light position changes.
  9626. *
  9627. * Only valid if useContactHardeningShadow is true.
  9628. */
  9629. contactHardeningLightSizeUVRatio: number;
  9630. private _darkness;
  9631. /** Gets or sets the actual darkness of a shadow */
  9632. darkness: number;
  9633. /**
  9634. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9635. * 0 means strongest and 1 would means no shadow.
  9636. * @returns the darkness.
  9637. */
  9638. getDarkness(): number;
  9639. /**
  9640. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9641. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9642. * @returns the shadow generator allowing fluent coding.
  9643. */
  9644. setDarkness(darkness: number): ShadowGenerator;
  9645. private _transparencyShadow;
  9646. /** Gets or sets the ability to have transparent shadow */
  9647. transparencyShadow: boolean;
  9648. /**
  9649. * Sets the ability to have transparent shadow (boolean).
  9650. * @param transparent True if transparent else False
  9651. * @returns the shadow generator allowing fluent coding
  9652. */
  9653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9654. private _shadowMap;
  9655. private _shadowMap2;
  9656. /**
  9657. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9658. * @returns The render target texture if present otherwise, null
  9659. */
  9660. getShadowMap(): Nullable<RenderTargetTexture>;
  9661. /**
  9662. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9663. * @returns The render target texture if the shadow map is present otherwise, null
  9664. */
  9665. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9666. /**
  9667. * Gets the class name of that object
  9668. * @returns "ShadowGenerator"
  9669. */
  9670. getClassName(): string;
  9671. /**
  9672. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9673. * @param mesh Mesh to add
  9674. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9675. * @returns the Shadow Generator itself
  9676. */
  9677. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9678. /**
  9679. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9680. * @param mesh Mesh to remove
  9681. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9682. * @returns the Shadow Generator itself
  9683. */
  9684. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9685. /**
  9686. * Controls the extent to which the shadows fade out at the edge of the frustum
  9687. * Used only by directionals and spots
  9688. */
  9689. frustumEdgeFalloff: number;
  9690. private _light;
  9691. /**
  9692. * Returns the associated light object.
  9693. * @returns the light generating the shadow
  9694. */
  9695. getLight(): IShadowLight;
  9696. /**
  9697. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9698. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9699. * It might on the other hand introduce peter panning.
  9700. */
  9701. forceBackFacesOnly: boolean;
  9702. private _scene;
  9703. private _lightDirection;
  9704. private _effect;
  9705. private _viewMatrix;
  9706. private _projectionMatrix;
  9707. private _transformMatrix;
  9708. private _cachedPosition;
  9709. private _cachedDirection;
  9710. private _cachedDefines;
  9711. private _currentRenderID;
  9712. private _boxBlurPostprocess;
  9713. private _kernelBlurXPostprocess;
  9714. private _kernelBlurYPostprocess;
  9715. private _blurPostProcesses;
  9716. private _mapSize;
  9717. private _currentFaceIndex;
  9718. private _currentFaceIndexCache;
  9719. private _textureType;
  9720. private _defaultTextureMatrix;
  9721. private _storedUniqueId;
  9722. /** @hidden */
  9723. static _SceneComponentInitialization: (scene: Scene) => void;
  9724. /**
  9725. * Creates a ShadowGenerator object.
  9726. * A ShadowGenerator is the required tool to use the shadows.
  9727. * Each light casting shadows needs to use its own ShadowGenerator.
  9728. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9729. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9730. * @param light The light object generating the shadows.
  9731. * @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.
  9732. */
  9733. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9734. private _initializeGenerator;
  9735. private _initializeShadowMap;
  9736. private _initializeBlurRTTAndPostProcesses;
  9737. private _renderForShadowMap;
  9738. private _renderSubMeshForShadowMap;
  9739. private _applyFilterValues;
  9740. /**
  9741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9742. * @param onCompiled Callback triggered at the and of the effects compilation
  9743. * @param options Sets of optional options forcing the compilation with different modes
  9744. */
  9745. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9746. useInstances: boolean;
  9747. }>): void;
  9748. /**
  9749. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9750. * @param options Sets of optional options forcing the compilation with different modes
  9751. * @returns A promise that resolves when the compilation completes
  9752. */
  9753. forceCompilationAsync(options?: Partial<{
  9754. useInstances: boolean;
  9755. }>): Promise<void>;
  9756. /**
  9757. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9758. * @param subMesh The submesh we want to render in the shadow map
  9759. * @param useInstances Defines wether will draw in the map using instances
  9760. * @returns true if ready otherwise, false
  9761. */
  9762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9763. /**
  9764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9765. * @param defines Defines of the material we want to update
  9766. * @param lightIndex Index of the light in the enabled light list of the material
  9767. */
  9768. prepareDefines(defines: any, lightIndex: number): void;
  9769. /**
  9770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9771. * defined in the generator but impacting the effect).
  9772. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9773. * @param effect The effect we are binfing the information for
  9774. */
  9775. bindShadowLight(lightIndex: string, effect: Effect): void;
  9776. /**
  9777. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9778. * (eq to shadow prjection matrix * light transform matrix)
  9779. * @returns The transform matrix used to create the shadow map
  9780. */
  9781. getTransformMatrix(): Matrix;
  9782. /**
  9783. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9784. * Cube and 2D textures for instance.
  9785. */
  9786. recreateShadowMap(): void;
  9787. private _disposeBlurPostProcesses;
  9788. private _disposeRTTandPostProcesses;
  9789. /**
  9790. * Disposes the ShadowGenerator.
  9791. * Returns nothing.
  9792. */
  9793. dispose(): void;
  9794. /**
  9795. * Serializes the shadow generator setup to a json object.
  9796. * @returns The serialized JSON object
  9797. */
  9798. serialize(): any;
  9799. /**
  9800. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9801. * @param parsedShadowGenerator The JSON object to parse
  9802. * @param scene The scene to create the shadow map for
  9803. * @returns The parsed shadow generator
  9804. */
  9805. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9806. }
  9807. }
  9808. declare module BABYLON {
  9809. /**
  9810. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9811. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9812. * 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.
  9813. */
  9814. export abstract class Light extends Node {
  9815. /**
  9816. * Falloff Default: light is falling off following the material specification:
  9817. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9818. */
  9819. static readonly FALLOFF_DEFAULT: number;
  9820. /**
  9821. * Falloff Physical: light is falling off following the inverse squared distance law.
  9822. */
  9823. static readonly FALLOFF_PHYSICAL: number;
  9824. /**
  9825. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9826. * to enhance interoperability with other engines.
  9827. */
  9828. static readonly FALLOFF_GLTF: number;
  9829. /**
  9830. * Falloff Standard: light is falling off like in the standard material
  9831. * to enhance interoperability with other materials.
  9832. */
  9833. static readonly FALLOFF_STANDARD: number;
  9834. /**
  9835. * If every light affecting the material is in this lightmapMode,
  9836. * material.lightmapTexture adds or multiplies
  9837. * (depends on material.useLightmapAsShadowmap)
  9838. * after every other light calculations.
  9839. */
  9840. static readonly LIGHTMAP_DEFAULT: number;
  9841. /**
  9842. * material.lightmapTexture as only diffuse lighting from this light
  9843. * adds only specular lighting from this light
  9844. * adds dynamic shadows
  9845. */
  9846. static readonly LIGHTMAP_SPECULAR: number;
  9847. /**
  9848. * material.lightmapTexture as only lighting
  9849. * no light calculation from this light
  9850. * only adds dynamic shadows from this light
  9851. */
  9852. static readonly LIGHTMAP_SHADOWSONLY: number;
  9853. /**
  9854. * Each light type uses the default quantity according to its type:
  9855. * point/spot lights use luminous intensity
  9856. * directional lights use illuminance
  9857. */
  9858. static readonly INTENSITYMODE_AUTOMATIC: number;
  9859. /**
  9860. * lumen (lm)
  9861. */
  9862. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9863. /**
  9864. * candela (lm/sr)
  9865. */
  9866. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9867. /**
  9868. * lux (lm/m^2)
  9869. */
  9870. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9871. /**
  9872. * nit (cd/m^2)
  9873. */
  9874. static readonly INTENSITYMODE_LUMINANCE: number;
  9875. /**
  9876. * Light type const id of the point light.
  9877. */
  9878. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9879. /**
  9880. * Light type const id of the directional light.
  9881. */
  9882. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9883. /**
  9884. * Light type const id of the spot light.
  9885. */
  9886. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9887. /**
  9888. * Light type const id of the hemispheric light.
  9889. */
  9890. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9891. /**
  9892. * Diffuse gives the basic color to an object.
  9893. */
  9894. diffuse: Color3;
  9895. /**
  9896. * Specular produces a highlight color on an object.
  9897. * Note: This is note affecting PBR materials.
  9898. */
  9899. specular: Color3;
  9900. /**
  9901. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9902. * falling off base on range or angle.
  9903. * This can be set to any values in Light.FALLOFF_x.
  9904. *
  9905. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9906. * other types of materials.
  9907. */
  9908. falloffType: number;
  9909. /**
  9910. * Strength of the light.
  9911. * Note: By default it is define in the framework own unit.
  9912. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9913. */
  9914. intensity: number;
  9915. private _range;
  9916. protected _inverseSquaredRange: number;
  9917. /**
  9918. * Defines how far from the source the light is impacting in scene units.
  9919. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9920. */
  9921. /**
  9922. * Defines how far from the source the light is impacting in scene units.
  9923. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9924. */
  9925. range: number;
  9926. /**
  9927. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9928. * of light.
  9929. */
  9930. private _photometricScale;
  9931. private _intensityMode;
  9932. /**
  9933. * Gets the photometric scale used to interpret the intensity.
  9934. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9935. */
  9936. /**
  9937. * Sets the photometric scale used to interpret the intensity.
  9938. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9939. */
  9940. intensityMode: number;
  9941. private _radius;
  9942. /**
  9943. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9944. */
  9945. /**
  9946. * sets the light radius used by PBR Materials to simulate soft area lights.
  9947. */
  9948. radius: number;
  9949. private _renderPriority;
  9950. /**
  9951. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9952. * exceeding the number allowed of the materials.
  9953. */
  9954. renderPriority: number;
  9955. private _shadowEnabled;
  9956. /**
  9957. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9958. * the current shadow generator.
  9959. */
  9960. /**
  9961. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9962. * the current shadow generator.
  9963. */
  9964. shadowEnabled: boolean;
  9965. private _includedOnlyMeshes;
  9966. /**
  9967. * Gets the only meshes impacted by this light.
  9968. */
  9969. /**
  9970. * Sets the only meshes impacted by this light.
  9971. */
  9972. includedOnlyMeshes: AbstractMesh[];
  9973. private _excludedMeshes;
  9974. /**
  9975. * Gets the meshes not impacted by this light.
  9976. */
  9977. /**
  9978. * Sets the meshes not impacted by this light.
  9979. */
  9980. excludedMeshes: AbstractMesh[];
  9981. private _excludeWithLayerMask;
  9982. /**
  9983. * Gets the layer id use to find what meshes are not impacted by the light.
  9984. * Inactive if 0
  9985. */
  9986. /**
  9987. * Sets the layer id use to find what meshes are not impacted by the light.
  9988. * Inactive if 0
  9989. */
  9990. excludeWithLayerMask: number;
  9991. private _includeOnlyWithLayerMask;
  9992. /**
  9993. * Gets the layer id use to find what meshes are impacted by the light.
  9994. * Inactive if 0
  9995. */
  9996. /**
  9997. * Sets the layer id use to find what meshes are impacted by the light.
  9998. * Inactive if 0
  9999. */
  10000. includeOnlyWithLayerMask: number;
  10001. private _lightmapMode;
  10002. /**
  10003. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10004. */
  10005. /**
  10006. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10007. */
  10008. lightmapMode: number;
  10009. /**
  10010. * Shadow generator associted to the light.
  10011. * @hidden Internal use only.
  10012. */
  10013. _shadowGenerator: Nullable<IShadowGenerator>;
  10014. /**
  10015. * @hidden Internal use only.
  10016. */
  10017. _excludedMeshesIds: string[];
  10018. /**
  10019. * @hidden Internal use only.
  10020. */
  10021. _includedOnlyMeshesIds: string[];
  10022. /**
  10023. * The current light unifom buffer.
  10024. * @hidden Internal use only.
  10025. */
  10026. _uniformBuffer: UniformBuffer;
  10027. /** @hidden */
  10028. _renderId: number;
  10029. /**
  10030. * Creates a Light object in the scene.
  10031. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10032. * @param name The firendly name of the light
  10033. * @param scene The scene the light belongs too
  10034. */
  10035. constructor(name: string, scene: Scene);
  10036. protected abstract _buildUniformLayout(): void;
  10037. /**
  10038. * Sets the passed Effect "effect" with the Light information.
  10039. * @param effect The effect to update
  10040. * @param lightIndex The index of the light in the effect to update
  10041. * @returns The light
  10042. */
  10043. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10044. /**
  10045. * Sets the passed Effect "effect" with the Light information.
  10046. * @param effect The effect to update
  10047. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10048. * @returns The light
  10049. */
  10050. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10051. /**
  10052. * Returns the string "Light".
  10053. * @returns the class name
  10054. */
  10055. getClassName(): string;
  10056. /** @hidden */
  10057. readonly _isLight: boolean;
  10058. /**
  10059. * Converts the light information to a readable string for debug purpose.
  10060. * @param fullDetails Supports for multiple levels of logging within scene loading
  10061. * @returns the human readable light info
  10062. */
  10063. toString(fullDetails?: boolean): string;
  10064. /** @hidden */
  10065. protected _syncParentEnabledState(): void;
  10066. /**
  10067. * Set the enabled state of this node.
  10068. * @param value - the new enabled state
  10069. */
  10070. setEnabled(value: boolean): void;
  10071. /**
  10072. * Returns the Light associated shadow generator if any.
  10073. * @return the associated shadow generator.
  10074. */
  10075. getShadowGenerator(): Nullable<IShadowGenerator>;
  10076. /**
  10077. * Returns a Vector3, the absolute light position in the World.
  10078. * @returns the world space position of the light
  10079. */
  10080. getAbsolutePosition(): Vector3;
  10081. /**
  10082. * Specifies if the light will affect the passed mesh.
  10083. * @param mesh The mesh to test against the light
  10084. * @return true the mesh is affected otherwise, false.
  10085. */
  10086. canAffectMesh(mesh: AbstractMesh): boolean;
  10087. /**
  10088. * Sort function to order lights for rendering.
  10089. * @param a First Light object to compare to second.
  10090. * @param b Second Light object to compare first.
  10091. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10092. */
  10093. static CompareLightsPriority(a: Light, b: Light): number;
  10094. /**
  10095. * Releases resources associated with this node.
  10096. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10097. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10098. */
  10099. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10100. /**
  10101. * Returns the light type ID (integer).
  10102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10103. */
  10104. getTypeID(): number;
  10105. /**
  10106. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10107. * @returns the scaled intensity in intensity mode unit
  10108. */
  10109. getScaledIntensity(): number;
  10110. /**
  10111. * Returns a new Light object, named "name", from the current one.
  10112. * @param name The name of the cloned light
  10113. * @returns the new created light
  10114. */
  10115. clone(name: string): Nullable<Light>;
  10116. /**
  10117. * Serializes the current light into a Serialization object.
  10118. * @returns the serialized object.
  10119. */
  10120. serialize(): any;
  10121. /**
  10122. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10123. * This new light is named "name" and added to the passed scene.
  10124. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10125. * @param name The friendly name of the light
  10126. * @param scene The scene the new light will belong to
  10127. * @returns the constructor function
  10128. */
  10129. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10130. /**
  10131. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10132. * @param parsedLight The JSON representation of the light
  10133. * @param scene The scene to create the parsed light in
  10134. * @returns the created light after parsing
  10135. */
  10136. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10137. private _hookArrayForExcluded;
  10138. private _hookArrayForIncludedOnly;
  10139. private _resyncMeshes;
  10140. /**
  10141. * Forces the meshes to update their light related information in their rendering used effects
  10142. * @hidden Internal Use Only
  10143. */
  10144. _markMeshesAsLightDirty(): void;
  10145. /**
  10146. * Recomputes the cached photometric scale if needed.
  10147. */
  10148. private _computePhotometricScale;
  10149. /**
  10150. * Returns the Photometric Scale according to the light type and intensity mode.
  10151. */
  10152. private _getPhotometricScale;
  10153. /**
  10154. * Reorder the light in the scene according to their defined priority.
  10155. * @hidden Internal Use Only
  10156. */
  10157. _reorderLightsInScene(): void;
  10158. /**
  10159. * Prepares the list of defines specific to the light type.
  10160. * @param defines the list of defines
  10161. * @param lightIndex defines the index of the light for the effect
  10162. */
  10163. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10164. }
  10165. }
  10166. declare module BABYLON {
  10167. /**
  10168. * Interface used to define Action
  10169. */
  10170. export interface IAction {
  10171. /**
  10172. * Trigger for the action
  10173. */
  10174. trigger: number;
  10175. /** Options of the trigger */
  10176. triggerOptions: any;
  10177. /**
  10178. * Gets the trigger parameters
  10179. * @returns the trigger parameters
  10180. */
  10181. getTriggerParameter(): any;
  10182. /**
  10183. * Internal only - executes current action event
  10184. * @hidden
  10185. */
  10186. _executeCurrent(evt?: ActionEvent): void;
  10187. /**
  10188. * Serialize placeholder for child classes
  10189. * @param parent of child
  10190. * @returns the serialized object
  10191. */
  10192. serialize(parent: any): any;
  10193. /**
  10194. * Internal only
  10195. * @hidden
  10196. */
  10197. _prepare(): void;
  10198. /**
  10199. * Internal only - manager for action
  10200. * @hidden
  10201. */
  10202. _actionManager: AbstractActionManager;
  10203. /**
  10204. * Adds action to chain of actions, may be a DoNothingAction
  10205. * @param action defines the next action to execute
  10206. * @returns The action passed in
  10207. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10208. */
  10209. then(action: IAction): IAction;
  10210. }
  10211. /**
  10212. * The action to be carried out following a trigger
  10213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10214. */
  10215. export class Action implements IAction {
  10216. /** the trigger, with or without parameters, for the action */
  10217. triggerOptions: any;
  10218. /**
  10219. * Trigger for the action
  10220. */
  10221. trigger: number;
  10222. /**
  10223. * Internal only - manager for action
  10224. * @hidden
  10225. */
  10226. _actionManager: ActionManager;
  10227. private _nextActiveAction;
  10228. private _child;
  10229. private _condition?;
  10230. private _triggerParameter;
  10231. /**
  10232. * An event triggered prior to action being executed.
  10233. */
  10234. onBeforeExecuteObservable: Observable<Action>;
  10235. /**
  10236. * Creates a new Action
  10237. * @param triggerOptions the trigger, with or without parameters, for the action
  10238. * @param condition an optional determinant of action
  10239. */
  10240. constructor(
  10241. /** the trigger, with or without parameters, for the action */
  10242. triggerOptions: any, condition?: Condition);
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _prepare(): void;
  10248. /**
  10249. * Gets the trigger parameters
  10250. * @returns the trigger parameters
  10251. */
  10252. getTriggerParameter(): any;
  10253. /**
  10254. * Internal only - executes current action event
  10255. * @hidden
  10256. */
  10257. _executeCurrent(evt?: ActionEvent): void;
  10258. /**
  10259. * Execute placeholder for child classes
  10260. * @param evt optional action event
  10261. */
  10262. execute(evt?: ActionEvent): void;
  10263. /**
  10264. * Skips to next active action
  10265. */
  10266. skipToNextActiveAction(): void;
  10267. /**
  10268. * Adds action to chain of actions, may be a DoNothingAction
  10269. * @param action defines the next action to execute
  10270. * @returns The action passed in
  10271. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10272. */
  10273. then(action: Action): Action;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _getProperty(propertyPath: string): string;
  10279. /**
  10280. * Internal only
  10281. * @hidden
  10282. */
  10283. _getEffectiveTarget(target: any, propertyPath: string): any;
  10284. /**
  10285. * Serialize placeholder for child classes
  10286. * @param parent of child
  10287. * @returns the serialized object
  10288. */
  10289. serialize(parent: any): any;
  10290. /**
  10291. * Internal only called by serialize
  10292. * @hidden
  10293. */
  10294. protected _serialize(serializedAction: any, parent?: any): any;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. static _SerializeValueAsString: (value: any) => string;
  10300. /**
  10301. * Internal only
  10302. * @hidden
  10303. */
  10304. static _GetTargetProperty: (target: Node | Scene) => {
  10305. name: string;
  10306. targetType: string;
  10307. value: string;
  10308. };
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * A Condition applied to an Action
  10314. */
  10315. export class Condition {
  10316. /**
  10317. * Internal only - manager for action
  10318. * @hidden
  10319. */
  10320. _actionManager: ActionManager;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. _evaluationId: number;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _currentResult: boolean;
  10331. /**
  10332. * Creates a new Condition
  10333. * @param actionManager the manager of the action the condition is applied to
  10334. */
  10335. constructor(actionManager: ActionManager);
  10336. /**
  10337. * Check if the current condition is valid
  10338. * @returns a boolean
  10339. */
  10340. isValid(): boolean;
  10341. /**
  10342. * Internal only
  10343. * @hidden
  10344. */
  10345. _getProperty(propertyPath: string): string;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. _getEffectiveTarget(target: any, propertyPath: string): any;
  10351. /**
  10352. * Serialize placeholder for child classes
  10353. * @returns the serialized object
  10354. */
  10355. serialize(): any;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. protected _serialize(serializedCondition: any): any;
  10361. }
  10362. /**
  10363. * Defines specific conditional operators as extensions of Condition
  10364. */
  10365. export class ValueCondition extends Condition {
  10366. /** path to specify the property of the target the conditional operator uses */
  10367. propertyPath: string;
  10368. /** the value compared by the conditional operator against the current value of the property */
  10369. value: any;
  10370. /** the conditional operator, default ValueCondition.IsEqual */
  10371. operator: number;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. private static _IsEqual;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. private static _IsDifferent;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. private static _IsGreater;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. private static _IsLesser;
  10392. /**
  10393. * returns the number for IsEqual
  10394. */
  10395. static readonly IsEqual: number;
  10396. /**
  10397. * Returns the number for IsDifferent
  10398. */
  10399. static readonly IsDifferent: number;
  10400. /**
  10401. * Returns the number for IsGreater
  10402. */
  10403. static readonly IsGreater: number;
  10404. /**
  10405. * Returns the number for IsLesser
  10406. */
  10407. static readonly IsLesser: number;
  10408. /**
  10409. * Internal only The action manager for the condition
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. private _target;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. private _effectiveTarget;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. private _property;
  10428. /**
  10429. * Creates a new ValueCondition
  10430. * @param actionManager manager for the action the condition applies to
  10431. * @param target for the action
  10432. * @param propertyPath path to specify the property of the target the conditional operator uses
  10433. * @param value the value compared by the conditional operator against the current value of the property
  10434. * @param operator the conditional operator, default ValueCondition.IsEqual
  10435. */
  10436. constructor(actionManager: ActionManager, target: any,
  10437. /** path to specify the property of the target the conditional operator uses */
  10438. propertyPath: string,
  10439. /** the value compared by the conditional operator against the current value of the property */
  10440. value: any,
  10441. /** the conditional operator, default ValueCondition.IsEqual */
  10442. operator?: number);
  10443. /**
  10444. * Compares the given value with the property value for the specified conditional operator
  10445. * @returns the result of the comparison
  10446. */
  10447. isValid(): boolean;
  10448. /**
  10449. * Serialize the ValueCondition into a JSON compatible object
  10450. * @returns serialization object
  10451. */
  10452. serialize(): any;
  10453. /**
  10454. * Gets the name of the conditional operator for the ValueCondition
  10455. * @param operator the conditional operator
  10456. * @returns the name
  10457. */
  10458. static GetOperatorName(operator: number): string;
  10459. }
  10460. /**
  10461. * Defines a predicate condition as an extension of Condition
  10462. */
  10463. export class PredicateCondition extends Condition {
  10464. /** defines the predicate function used to validate the condition */
  10465. predicate: () => boolean;
  10466. /**
  10467. * Internal only - manager for action
  10468. * @hidden
  10469. */
  10470. _actionManager: ActionManager;
  10471. /**
  10472. * Creates a new PredicateCondition
  10473. * @param actionManager manager for the action the condition applies to
  10474. * @param predicate defines the predicate function used to validate the condition
  10475. */
  10476. constructor(actionManager: ActionManager,
  10477. /** defines the predicate function used to validate the condition */
  10478. predicate: () => boolean);
  10479. /**
  10480. * @returns the validity of the predicate condition
  10481. */
  10482. isValid(): boolean;
  10483. }
  10484. /**
  10485. * Defines a state condition as an extension of Condition
  10486. */
  10487. export class StateCondition extends Condition {
  10488. /** Value to compare with target state */
  10489. value: string;
  10490. /**
  10491. * Internal only - manager for action
  10492. * @hidden
  10493. */
  10494. _actionManager: ActionManager;
  10495. /**
  10496. * Internal only
  10497. * @hidden
  10498. */
  10499. private _target;
  10500. /**
  10501. * Creates a new StateCondition
  10502. * @param actionManager manager for the action the condition applies to
  10503. * @param target of the condition
  10504. * @param value to compare with target state
  10505. */
  10506. constructor(actionManager: ActionManager, target: any,
  10507. /** Value to compare with target state */
  10508. value: string);
  10509. /**
  10510. * Gets a boolean indicating if the current condition is met
  10511. * @returns the validity of the state
  10512. */
  10513. isValid(): boolean;
  10514. /**
  10515. * Serialize the StateCondition into a JSON compatible object
  10516. * @returns serialization object
  10517. */
  10518. serialize(): any;
  10519. }
  10520. }
  10521. declare module BABYLON {
  10522. /**
  10523. * This defines an action responsible to toggle a boolean once triggered.
  10524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10525. */
  10526. export class SwitchBooleanAction extends Action {
  10527. /**
  10528. * The path to the boolean property in the target object
  10529. */
  10530. propertyPath: string;
  10531. private _target;
  10532. private _effectiveTarget;
  10533. private _property;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the boolean
  10538. * @param propertyPath defines the path to the boolean property in the target object
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10542. /** @hidden */
  10543. _prepare(): void;
  10544. /**
  10545. * Execute the action toggle the boolean value.
  10546. */
  10547. execute(): void;
  10548. /**
  10549. * Serializes the actions and its related information.
  10550. * @param parent defines the object to serialize in
  10551. * @returns the serialized object
  10552. */
  10553. serialize(parent: any): any;
  10554. }
  10555. /**
  10556. * This defines an action responsible to set a the state field of the target
  10557. * to a desired value once triggered.
  10558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10559. */
  10560. export class SetStateAction extends Action {
  10561. /**
  10562. * The value to store in the state field.
  10563. */
  10564. value: string;
  10565. private _target;
  10566. /**
  10567. * Instantiate the action
  10568. * @param triggerOptions defines the trigger options
  10569. * @param target defines the object containing the state property
  10570. * @param value defines the value to store in the state field
  10571. * @param condition defines the trigger related conditions
  10572. */
  10573. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10574. /**
  10575. * Execute the action and store the value on the target state property.
  10576. */
  10577. execute(): void;
  10578. /**
  10579. * Serializes the actions and its related information.
  10580. * @param parent defines the object to serialize in
  10581. * @returns the serialized object
  10582. */
  10583. serialize(parent: any): any;
  10584. }
  10585. /**
  10586. * This defines an action responsible to set a property of the target
  10587. * to a desired value once triggered.
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10589. */
  10590. export class SetValueAction extends Action {
  10591. /**
  10592. * The path of the property to set in the target.
  10593. */
  10594. propertyPath: string;
  10595. /**
  10596. * The value to set in the property
  10597. */
  10598. value: any;
  10599. private _target;
  10600. private _effectiveTarget;
  10601. private _property;
  10602. /**
  10603. * Instantiate the action
  10604. * @param triggerOptions defines the trigger options
  10605. * @param target defines the object containing the property
  10606. * @param propertyPath defines the path of the property to set in the target
  10607. * @param value defines the value to set in the property
  10608. * @param condition defines the trigger related conditions
  10609. */
  10610. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10611. /** @hidden */
  10612. _prepare(): void;
  10613. /**
  10614. * Execute the action and set the targetted property to the desired value.
  10615. */
  10616. execute(): void;
  10617. /**
  10618. * Serializes the actions and its related information.
  10619. * @param parent defines the object to serialize in
  10620. * @returns the serialized object
  10621. */
  10622. serialize(parent: any): any;
  10623. }
  10624. /**
  10625. * This defines an action responsible to increment the target value
  10626. * to a desired value once triggered.
  10627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10628. */
  10629. export class IncrementValueAction extends Action {
  10630. /**
  10631. * The path of the property to increment in the target.
  10632. */
  10633. propertyPath: string;
  10634. /**
  10635. * The value we should increment the property by.
  10636. */
  10637. value: any;
  10638. private _target;
  10639. private _effectiveTarget;
  10640. private _property;
  10641. /**
  10642. * Instantiate the action
  10643. * @param triggerOptions defines the trigger options
  10644. * @param target defines the object containing the property
  10645. * @param propertyPath defines the path of the property to increment in the target
  10646. * @param value defines the value value we should increment the property by
  10647. * @param condition defines the trigger related conditions
  10648. */
  10649. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10650. /** @hidden */
  10651. _prepare(): void;
  10652. /**
  10653. * Execute the action and increment the target of the value amount.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to start an animation once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class PlayAnimationAction extends Action {
  10668. /**
  10669. * Where the animation should start (animation frame)
  10670. */
  10671. from: number;
  10672. /**
  10673. * Where the animation should stop (animation frame)
  10674. */
  10675. to: number;
  10676. /**
  10677. * Define if the animation should loop or stop after the first play.
  10678. */
  10679. loop?: boolean;
  10680. private _target;
  10681. /**
  10682. * Instantiate the action
  10683. * @param triggerOptions defines the trigger options
  10684. * @param target defines the target animation or animation name
  10685. * @param from defines from where the animation should start (animation frame)
  10686. * @param end defines where the animation should stop (animation frame)
  10687. * @param loop defines if the animation should loop or stop after the first play
  10688. * @param condition defines the trigger related conditions
  10689. */
  10690. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10691. /** @hidden */
  10692. _prepare(): void;
  10693. /**
  10694. * Execute the action and play the animation.
  10695. */
  10696. execute(): void;
  10697. /**
  10698. * Serializes the actions and its related information.
  10699. * @param parent defines the object to serialize in
  10700. * @returns the serialized object
  10701. */
  10702. serialize(parent: any): any;
  10703. }
  10704. /**
  10705. * This defines an action responsible to stop an animation once triggered.
  10706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10707. */
  10708. export class StopAnimationAction extends Action {
  10709. private _target;
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param target defines the target animation or animation name
  10714. * @param condition defines the trigger related conditions
  10715. */
  10716. constructor(triggerOptions: any, target: any, condition?: Condition);
  10717. /** @hidden */
  10718. _prepare(): void;
  10719. /**
  10720. * Execute the action and stop the animation.
  10721. */
  10722. execute(): void;
  10723. /**
  10724. * Serializes the actions and its related information.
  10725. * @param parent defines the object to serialize in
  10726. * @returns the serialized object
  10727. */
  10728. serialize(parent: any): any;
  10729. }
  10730. /**
  10731. * This defines an action responsible that does nothing once triggered.
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10733. */
  10734. export class DoNothingAction extends Action {
  10735. /**
  10736. * Instantiate the action
  10737. * @param triggerOptions defines the trigger options
  10738. * @param condition defines the trigger related conditions
  10739. */
  10740. constructor(triggerOptions?: any, condition?: Condition);
  10741. /**
  10742. * Execute the action and do nothing.
  10743. */
  10744. execute(): void;
  10745. /**
  10746. * Serializes the actions and its related information.
  10747. * @param parent defines the object to serialize in
  10748. * @returns the serialized object
  10749. */
  10750. serialize(parent: any): any;
  10751. }
  10752. /**
  10753. * This defines an action responsible to trigger several actions once triggered.
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10755. */
  10756. export class CombineAction extends Action {
  10757. /**
  10758. * The list of aggregated animations to run.
  10759. */
  10760. children: Action[];
  10761. /**
  10762. * Instantiate the action
  10763. * @param triggerOptions defines the trigger options
  10764. * @param children defines the list of aggregated animations to run
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and executes all the aggregated actions.
  10772. */
  10773. execute(evt: ActionEvent): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. /**
  10782. * This defines an action responsible to run code (external event) once triggered.
  10783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10784. */
  10785. export class ExecuteCodeAction extends Action {
  10786. /**
  10787. * The callback function to run.
  10788. */
  10789. func: (evt: ActionEvent) => void;
  10790. /**
  10791. * Instantiate the action
  10792. * @param triggerOptions defines the trigger options
  10793. * @param func defines the callback function to run
  10794. * @param condition defines the trigger related conditions
  10795. */
  10796. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10797. /**
  10798. * Execute the action and run the attached code.
  10799. */
  10800. execute(evt: ActionEvent): void;
  10801. }
  10802. /**
  10803. * This defines an action responsible to set the parent property of the target once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class SetParentAction extends Action {
  10807. private _parent;
  10808. private _target;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the target containing the parent property
  10813. * @param parent defines from where the animation should start (animation frame)
  10814. * @param condition defines the trigger related conditions
  10815. */
  10816. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10817. /** @hidden */
  10818. _prepare(): void;
  10819. /**
  10820. * Execute the action and set the parent property.
  10821. */
  10822. execute(): void;
  10823. /**
  10824. * Serializes the actions and its related information.
  10825. * @param parent defines the object to serialize in
  10826. * @returns the serialized object
  10827. */
  10828. serialize(parent: any): any;
  10829. }
  10830. }
  10831. declare module BABYLON {
  10832. /**
  10833. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10834. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class ActionManager extends AbstractActionManager {
  10838. /**
  10839. * Nothing
  10840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10841. */
  10842. static readonly NothingTrigger: number;
  10843. /**
  10844. * On pick
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10846. */
  10847. static readonly OnPickTrigger: number;
  10848. /**
  10849. * On left pick
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10851. */
  10852. static readonly OnLeftPickTrigger: number;
  10853. /**
  10854. * On right pick
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnRightPickTrigger: number;
  10858. /**
  10859. * On center pick
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnCenterPickTrigger: number;
  10863. /**
  10864. * On pick down
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPickDownTrigger: number;
  10868. /**
  10869. * On double pick
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnDoublePickTrigger: number;
  10873. /**
  10874. * On pick up
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnPickUpTrigger: number;
  10878. /**
  10879. * On pick out.
  10880. * This trigger will only be raised if you also declared a OnPickDown
  10881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10882. */
  10883. static readonly OnPickOutTrigger: number;
  10884. /**
  10885. * On long press
  10886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10887. */
  10888. static readonly OnLongPressTrigger: number;
  10889. /**
  10890. * On pointer over
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10892. */
  10893. static readonly OnPointerOverTrigger: number;
  10894. /**
  10895. * On pointer out
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10897. */
  10898. static readonly OnPointerOutTrigger: number;
  10899. /**
  10900. * On every frame
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnEveryFrameTrigger: number;
  10904. /**
  10905. * On intersection enter
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnIntersectionEnterTrigger: number;
  10909. /**
  10910. * On intersection exit
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnIntersectionExitTrigger: number;
  10914. /**
  10915. * On key down
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnKeyDownTrigger: number;
  10919. /**
  10920. * On key up
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnKeyUpTrigger: number;
  10924. private _scene;
  10925. /**
  10926. * Creates a new action manager
  10927. * @param scene defines the hosting scene
  10928. */
  10929. constructor(scene: Scene);
  10930. /**
  10931. * Releases all associated resources
  10932. */
  10933. dispose(): void;
  10934. /**
  10935. * Gets hosting scene
  10936. * @returns the hosting scene
  10937. */
  10938. getScene(): Scene;
  10939. /**
  10940. * Does this action manager handles actions of any of the given triggers
  10941. * @param triggers defines the triggers to be tested
  10942. * @return a boolean indicating whether one (or more) of the triggers is handled
  10943. */
  10944. hasSpecificTriggers(triggers: number[]): boolean;
  10945. /**
  10946. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10947. * speed.
  10948. * @param triggerA defines the trigger to be tested
  10949. * @param triggerB defines the trigger to be tested
  10950. * @return a boolean indicating whether one (or more) of the triggers is handled
  10951. */
  10952. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10953. /**
  10954. * Does this action manager handles actions of a given trigger
  10955. * @param trigger defines the trigger to be tested
  10956. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10957. * @return whether the trigger is handled
  10958. */
  10959. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10960. /**
  10961. * Does this action manager has pointer triggers
  10962. */
  10963. readonly hasPointerTriggers: boolean;
  10964. /**
  10965. * Does this action manager has pick triggers
  10966. */
  10967. readonly hasPickTriggers: boolean;
  10968. /**
  10969. * Registers an action to this action manager
  10970. * @param action defines the action to be registered
  10971. * @return the action amended (prepared) after registration
  10972. */
  10973. registerAction(action: IAction): Nullable<IAction>;
  10974. /**
  10975. * Unregisters an action to this action manager
  10976. * @param action defines the action to be unregistered
  10977. * @return a boolean indicating whether the action has been unregistered
  10978. */
  10979. unregisterAction(action: IAction): Boolean;
  10980. /**
  10981. * Process a specific trigger
  10982. * @param trigger defines the trigger to process
  10983. * @param evt defines the event details to be processed
  10984. */
  10985. processTrigger(trigger: number, evt?: IActionEvent): void;
  10986. /** @hidden */
  10987. _getEffectiveTarget(target: any, propertyPath: string): any;
  10988. /** @hidden */
  10989. _getProperty(propertyPath: string): string;
  10990. /**
  10991. * Serialize this manager to a JSON object
  10992. * @param name defines the property name to store this manager
  10993. * @returns a JSON representation of this manager
  10994. */
  10995. serialize(name: string): any;
  10996. /**
  10997. * Creates a new ActionManager from a JSON data
  10998. * @param parsedActions defines the JSON data to read from
  10999. * @param object defines the hosting mesh
  11000. * @param scene defines the hosting scene
  11001. */
  11002. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11003. /**
  11004. * Get a trigger name by index
  11005. * @param trigger defines the trigger index
  11006. * @returns a trigger name
  11007. */
  11008. static GetTriggerName(trigger: number): string;
  11009. }
  11010. }
  11011. declare module BABYLON {
  11012. /**
  11013. * Class representing a ray with position and direction
  11014. */
  11015. export class Ray {
  11016. /** origin point */
  11017. origin: Vector3;
  11018. /** direction */
  11019. direction: Vector3;
  11020. /** length of the ray */
  11021. length: number;
  11022. private static readonly TmpVector3;
  11023. private _tmpRay;
  11024. /**
  11025. * Creates a new ray
  11026. * @param origin origin point
  11027. * @param direction direction
  11028. * @param length length of the ray
  11029. */
  11030. constructor(
  11031. /** origin point */
  11032. origin: Vector3,
  11033. /** direction */
  11034. direction: Vector3,
  11035. /** length of the ray */
  11036. length?: number);
  11037. /**
  11038. * Checks if the ray intersects a box
  11039. * @param minimum bound of the box
  11040. * @param maximum bound of the box
  11041. * @param intersectionTreshold extra extend to be added to the box in all direction
  11042. * @returns if the box was hit
  11043. */
  11044. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11045. /**
  11046. * Checks if the ray intersects a box
  11047. * @param box the bounding box to check
  11048. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11049. * @returns if the box was hit
  11050. */
  11051. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11052. /**
  11053. * If the ray hits a sphere
  11054. * @param sphere the bounding sphere to check
  11055. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11056. * @returns true if it hits the sphere
  11057. */
  11058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11059. /**
  11060. * If the ray hits a triange
  11061. * @param vertex0 triangle vertex
  11062. * @param vertex1 triangle vertex
  11063. * @param vertex2 triangle vertex
  11064. * @returns intersection information if hit
  11065. */
  11066. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11067. /**
  11068. * Checks if ray intersects a plane
  11069. * @param plane the plane to check
  11070. * @returns the distance away it was hit
  11071. */
  11072. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11073. /**
  11074. * Calculate the intercept of a ray on a given axis
  11075. * @param axis to check 'x' | 'y' | 'z'
  11076. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11077. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11078. */
  11079. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11080. /**
  11081. * Checks if ray intersects a mesh
  11082. * @param mesh the mesh to check
  11083. * @param fastCheck if only the bounding box should checked
  11084. * @returns picking info of the intersecton
  11085. */
  11086. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11087. /**
  11088. * Checks if ray intersects a mesh
  11089. * @param meshes the meshes to check
  11090. * @param fastCheck if only the bounding box should checked
  11091. * @param results array to store result in
  11092. * @returns Array of picking infos
  11093. */
  11094. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11095. private _comparePickingInfo;
  11096. private static smallnum;
  11097. private static rayl;
  11098. /**
  11099. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11100. * @param sega the first point of the segment to test the intersection against
  11101. * @param segb the second point of the segment to test the intersection against
  11102. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11103. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11104. */
  11105. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11106. /**
  11107. * Update the ray from viewport position
  11108. * @param x position
  11109. * @param y y position
  11110. * @param viewportWidth viewport width
  11111. * @param viewportHeight viewport height
  11112. * @param world world matrix
  11113. * @param view view matrix
  11114. * @param projection projection matrix
  11115. * @returns this ray updated
  11116. */
  11117. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11118. /**
  11119. * Creates a ray with origin and direction of 0,0,0
  11120. * @returns the new ray
  11121. */
  11122. static Zero(): Ray;
  11123. /**
  11124. * Creates a new ray from screen space and viewport
  11125. * @param x position
  11126. * @param y y position
  11127. * @param viewportWidth viewport width
  11128. * @param viewportHeight viewport height
  11129. * @param world world matrix
  11130. * @param view view matrix
  11131. * @param projection projection matrix
  11132. * @returns new ray
  11133. */
  11134. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11135. /**
  11136. * 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
  11137. * transformed to the given world matrix.
  11138. * @param origin The origin point
  11139. * @param end The end point
  11140. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11141. * @returns the new ray
  11142. */
  11143. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11144. /**
  11145. * Transforms a ray by a matrix
  11146. * @param ray ray to transform
  11147. * @param matrix matrix to apply
  11148. * @returns the resulting new ray
  11149. */
  11150. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11151. /**
  11152. * Transforms a ray by a matrix
  11153. * @param ray ray to transform
  11154. * @param matrix matrix to apply
  11155. * @param result ray to store result in
  11156. */
  11157. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11158. /**
  11159. * Unproject a ray from screen space to object space
  11160. * @param sourceX defines the screen space x coordinate to use
  11161. * @param sourceY defines the screen space y coordinate to use
  11162. * @param viewportWidth defines the current width of the viewport
  11163. * @param viewportHeight defines the current height of the viewport
  11164. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11165. * @param view defines the view matrix to use
  11166. * @param projection defines the projection matrix to use
  11167. */
  11168. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11169. }
  11170. /**
  11171. * Type used to define predicate used to select faces when a mesh intersection is detected
  11172. */
  11173. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11174. interface Scene {
  11175. /** @hidden */
  11176. _tempPickingRay: Nullable<Ray>;
  11177. /** @hidden */
  11178. _cachedRayForTransform: Ray;
  11179. /** @hidden */
  11180. _pickWithRayInverseMatrix: Matrix;
  11181. /** @hidden */
  11182. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11183. /** @hidden */
  11184. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11185. }
  11186. }
  11187. declare module BABYLON {
  11188. /**
  11189. * Groups all the scene component constants in one place to ease maintenance.
  11190. * @hidden
  11191. */
  11192. export class SceneComponentConstants {
  11193. static readonly NAME_EFFECTLAYER: string;
  11194. static readonly NAME_LAYER: string;
  11195. static readonly NAME_LENSFLARESYSTEM: string;
  11196. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11197. static readonly NAME_PARTICLESYSTEM: string;
  11198. static readonly NAME_GAMEPAD: string;
  11199. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11200. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11201. static readonly NAME_DEPTHRENDERER: string;
  11202. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11203. static readonly NAME_SPRITE: string;
  11204. static readonly NAME_OUTLINERENDERER: string;
  11205. static readonly NAME_PROCEDURALTEXTURE: string;
  11206. static readonly NAME_SHADOWGENERATOR: string;
  11207. static readonly NAME_OCTREE: string;
  11208. static readonly NAME_PHYSICSENGINE: string;
  11209. static readonly NAME_AUDIO: string;
  11210. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11211. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11212. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11215. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11217. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11219. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11222. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11224. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11225. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11226. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11228. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11229. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11230. static readonly STEP_AFTERRENDER_AUDIO: number;
  11231. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11235. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11236. static readonly STEP_POINTERMOVE_SPRITE: number;
  11237. static readonly STEP_POINTERDOWN_SPRITE: number;
  11238. static readonly STEP_POINTERUP_SPRITE: number;
  11239. }
  11240. /**
  11241. * This represents a scene component.
  11242. *
  11243. * This is used to decouple the dependency the scene is having on the different workloads like
  11244. * layers, post processes...
  11245. */
  11246. export interface ISceneComponent {
  11247. /**
  11248. * The name of the component. Each component must have a unique name.
  11249. */
  11250. name: string;
  11251. /**
  11252. * The scene the component belongs to.
  11253. */
  11254. scene: Scene;
  11255. /**
  11256. * Register the component to one instance of a scene.
  11257. */
  11258. register(): void;
  11259. /**
  11260. * Rebuilds the elements related to this component in case of
  11261. * context lost for instance.
  11262. */
  11263. rebuild(): void;
  11264. /**
  11265. * Disposes the component and the associated ressources.
  11266. */
  11267. dispose(): void;
  11268. }
  11269. /**
  11270. * This represents a SERIALIZABLE scene component.
  11271. *
  11272. * This extends Scene Component to add Serialization methods on top.
  11273. */
  11274. export interface ISceneSerializableComponent extends ISceneComponent {
  11275. /**
  11276. * Adds all the elements from the container to the scene
  11277. * @param container the container holding the elements
  11278. */
  11279. addFromContainer(container: AbstractScene): void;
  11280. /**
  11281. * Removes all the elements in the container from the scene
  11282. * @param container contains the elements to remove
  11283. * @param dispose if the removed element should be disposed (default: false)
  11284. */
  11285. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11286. /**
  11287. * Serializes the component data to the specified json object
  11288. * @param serializationObject The object to serialize to
  11289. */
  11290. serialize(serializationObject: any): void;
  11291. }
  11292. /**
  11293. * Strong typing of a Mesh related stage step action
  11294. */
  11295. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11296. /**
  11297. * Strong typing of a Evaluate Sub Mesh related stage step action
  11298. */
  11299. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11300. /**
  11301. * Strong typing of a Active Mesh related stage step action
  11302. */
  11303. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11304. /**
  11305. * Strong typing of a Camera related stage step action
  11306. */
  11307. export type CameraStageAction = (camera: Camera) => void;
  11308. /**
  11309. * Strong typing of a Camera Frame buffer related stage step action
  11310. */
  11311. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11312. /**
  11313. * Strong typing of a Render Target related stage step action
  11314. */
  11315. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11316. /**
  11317. * Strong typing of a RenderingGroup related stage step action
  11318. */
  11319. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11320. /**
  11321. * Strong typing of a Mesh Render related stage step action
  11322. */
  11323. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11324. /**
  11325. * Strong typing of a simple stage step action
  11326. */
  11327. export type SimpleStageAction = () => void;
  11328. /**
  11329. * Strong typing of a render target action.
  11330. */
  11331. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11332. /**
  11333. * Strong typing of a pointer move action.
  11334. */
  11335. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11336. /**
  11337. * Strong typing of a pointer up/down action.
  11338. */
  11339. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11340. /**
  11341. * Representation of a stage in the scene (Basically a list of ordered steps)
  11342. * @hidden
  11343. */
  11344. export class Stage<T extends Function> extends Array<{
  11345. index: number;
  11346. component: ISceneComponent;
  11347. action: T;
  11348. }> {
  11349. /**
  11350. * Hide ctor from the rest of the world.
  11351. * @param items The items to add.
  11352. */
  11353. private constructor();
  11354. /**
  11355. * Creates a new Stage.
  11356. * @returns A new instance of a Stage
  11357. */
  11358. static Create<T extends Function>(): Stage<T>;
  11359. /**
  11360. * Registers a step in an ordered way in the targeted stage.
  11361. * @param index Defines the position to register the step in
  11362. * @param component Defines the component attached to the step
  11363. * @param action Defines the action to launch during the step
  11364. */
  11365. registerStep(index: number, component: ISceneComponent, action: T): void;
  11366. /**
  11367. * Clears all the steps from the stage.
  11368. */
  11369. clear(): void;
  11370. }
  11371. }
  11372. declare module BABYLON {
  11373. interface Scene {
  11374. /** @hidden */
  11375. _pointerOverSprite: Nullable<Sprite>;
  11376. /** @hidden */
  11377. _pickedDownSprite: Nullable<Sprite>;
  11378. /** @hidden */
  11379. _tempSpritePickingRay: Nullable<Ray>;
  11380. /**
  11381. * All of the sprite managers added to this scene
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. spriteManagers: Array<ISpriteManager>;
  11385. /**
  11386. * An event triggered when sprites rendering is about to start
  11387. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11388. */
  11389. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11390. /**
  11391. * An event triggered when sprites rendering is done
  11392. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11393. */
  11394. onAfterSpritesRenderingObservable: Observable<Scene>;
  11395. /** @hidden */
  11396. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11397. /** Launch a ray to try to pick a sprite in the scene
  11398. * @param x position on screen
  11399. * @param y position on screen
  11400. * @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
  11401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11402. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11403. * @returns a PickingInfo
  11404. */
  11405. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11406. /** Use the given ray to pick a sprite in the scene
  11407. * @param ray The ray (in world space) to use to pick meshes
  11408. * @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
  11409. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11410. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11411. * @returns a PickingInfo
  11412. */
  11413. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11414. /** @hidden */
  11415. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11416. /** Launch a ray to try to pick sprites in the scene
  11417. * @param x position on screen
  11418. * @param y position on screen
  11419. * @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
  11420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11421. * @returns a PickingInfo array
  11422. */
  11423. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11424. /** Use the given ray to pick sprites in the scene
  11425. * @param ray The ray (in world space) to use to pick meshes
  11426. * @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
  11427. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11428. * @returns a PickingInfo array
  11429. */
  11430. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11431. /**
  11432. * Force the sprite under the pointer
  11433. * @param sprite defines the sprite to use
  11434. */
  11435. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11436. /**
  11437. * Gets the sprite under the pointer
  11438. * @returns a Sprite or null if no sprite is under the pointer
  11439. */
  11440. getPointerOverSprite(): Nullable<Sprite>;
  11441. }
  11442. /**
  11443. * Defines the sprite scene component responsible to manage sprites
  11444. * in a given scene.
  11445. */
  11446. export class SpriteSceneComponent implements ISceneComponent {
  11447. /**
  11448. * The component name helpfull to identify the component in the list of scene components.
  11449. */
  11450. readonly name: string;
  11451. /**
  11452. * The scene the component belongs to.
  11453. */
  11454. scene: Scene;
  11455. /** @hidden */
  11456. private _spritePredicate;
  11457. /**
  11458. * Creates a new instance of the component for the given scene
  11459. * @param scene Defines the scene to register the component in
  11460. */
  11461. constructor(scene: Scene);
  11462. /**
  11463. * Registers the component in a given scene
  11464. */
  11465. register(): void;
  11466. /**
  11467. * Rebuilds the elements related to this component in case of
  11468. * context lost for instance.
  11469. */
  11470. rebuild(): void;
  11471. /**
  11472. * Disposes the component and the associated ressources.
  11473. */
  11474. dispose(): void;
  11475. private _pickSpriteButKeepRay;
  11476. private _pointerMove;
  11477. private _pointerDown;
  11478. private _pointerUp;
  11479. }
  11480. }
  11481. declare module BABYLON {
  11482. /** @hidden */
  11483. export var fogFragmentDeclaration: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module BABYLON {
  11489. /** @hidden */
  11490. export var fogFragment: {
  11491. name: string;
  11492. shader: string;
  11493. };
  11494. }
  11495. declare module BABYLON {
  11496. /** @hidden */
  11497. export var spritesPixelShader: {
  11498. name: string;
  11499. shader: string;
  11500. };
  11501. }
  11502. declare module BABYLON {
  11503. /** @hidden */
  11504. export var fogVertexDeclaration: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module BABYLON {
  11510. /** @hidden */
  11511. export var spritesVertexShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module BABYLON {
  11517. /**
  11518. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11519. */
  11520. export interface ISpriteManager extends IDisposable {
  11521. /**
  11522. * Restricts the camera to viewing objects with the same layerMask.
  11523. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11524. */
  11525. layerMask: number;
  11526. /**
  11527. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11528. */
  11529. isPickable: boolean;
  11530. /**
  11531. * Specifies the rendering group id for this mesh (0 by default)
  11532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11533. */
  11534. renderingGroupId: number;
  11535. /**
  11536. * Defines the list of sprites managed by the manager.
  11537. */
  11538. sprites: Array<Sprite>;
  11539. /**
  11540. * Tests the intersection of a sprite with a specific ray.
  11541. * @param ray The ray we are sending to test the collision
  11542. * @param camera The camera space we are sending rays in
  11543. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11544. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11545. * @returns picking info or null.
  11546. */
  11547. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11548. /**
  11549. * Intersects the sprites with a ray
  11550. * @param ray defines the ray to intersect with
  11551. * @param camera defines the current active camera
  11552. * @param predicate defines a predicate used to select candidate sprites
  11553. * @returns null if no hit or a PickingInfo array
  11554. */
  11555. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11556. /**
  11557. * Renders the list of sprites on screen.
  11558. */
  11559. render(): void;
  11560. }
  11561. /**
  11562. * Class used to manage multiple sprites on the same spritesheet
  11563. * @see http://doc.babylonjs.com/babylon101/sprites
  11564. */
  11565. export class SpriteManager implements ISpriteManager {
  11566. /** defines the manager's name */
  11567. name: string;
  11568. /** Gets the list of sprites */
  11569. sprites: Sprite[];
  11570. /** Gets or sets the rendering group id (0 by default) */
  11571. renderingGroupId: number;
  11572. /** Gets or sets camera layer mask */
  11573. layerMask: number;
  11574. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11575. fogEnabled: boolean;
  11576. /** Gets or sets a boolean indicating if the sprites are pickable */
  11577. isPickable: boolean;
  11578. /** Defines the default width of a cell in the spritesheet */
  11579. cellWidth: number;
  11580. /** Defines the default height of a cell in the spritesheet */
  11581. cellHeight: number;
  11582. /** Associative array from JSON sprite data file */
  11583. private _cellData;
  11584. /** Array of sprite names from JSON sprite data file */
  11585. private _spriteMap;
  11586. /** True when packed cell data from JSON file is ready*/
  11587. private _packedAndReady;
  11588. /**
  11589. * An event triggered when the manager is disposed.
  11590. */
  11591. onDisposeObservable: Observable<SpriteManager>;
  11592. private _onDisposeObserver;
  11593. /**
  11594. * Callback called when the manager is disposed
  11595. */
  11596. onDispose: () => void;
  11597. private _capacity;
  11598. private _fromPacked;
  11599. private _spriteTexture;
  11600. private _epsilon;
  11601. private _scene;
  11602. private _vertexData;
  11603. private _buffer;
  11604. private _vertexBuffers;
  11605. private _indexBuffer;
  11606. private _effectBase;
  11607. private _effectFog;
  11608. /**
  11609. * Gets or sets the spritesheet texture
  11610. */
  11611. texture: Texture;
  11612. /**
  11613. * Creates a new sprite manager
  11614. * @param name defines the manager's name
  11615. * @param imgUrl defines the sprite sheet url
  11616. * @param capacity defines the maximum allowed number of sprites
  11617. * @param cellSize defines the size of a sprite cell
  11618. * @param scene defines the hosting scene
  11619. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11620. * @param samplingMode defines the smapling mode to use with spritesheet
  11621. * @param fromPacked set to false; do not alter
  11622. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11623. */
  11624. constructor(
  11625. /** defines the manager's name */
  11626. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11627. private _makePacked;
  11628. private _appendSpriteVertex;
  11629. /**
  11630. * Intersects the sprites with a ray
  11631. * @param ray defines the ray to intersect with
  11632. * @param camera defines the current active camera
  11633. * @param predicate defines a predicate used to select candidate sprites
  11634. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11635. * @returns null if no hit or a PickingInfo
  11636. */
  11637. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11638. /**
  11639. * Intersects the sprites with a ray
  11640. * @param ray defines the ray to intersect with
  11641. * @param camera defines the current active camera
  11642. * @param predicate defines a predicate used to select candidate sprites
  11643. * @returns null if no hit or a PickingInfo array
  11644. */
  11645. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11646. /**
  11647. * Render all child sprites
  11648. */
  11649. render(): void;
  11650. /**
  11651. * Release associated resources
  11652. */
  11653. dispose(): void;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /**
  11658. * Class used to represent a sprite
  11659. * @see http://doc.babylonjs.com/babylon101/sprites
  11660. */
  11661. export class Sprite {
  11662. /** defines the name */
  11663. name: string;
  11664. /** Gets or sets the current world position */
  11665. position: Vector3;
  11666. /** Gets or sets the main color */
  11667. color: Color4;
  11668. /** Gets or sets the width */
  11669. width: number;
  11670. /** Gets or sets the height */
  11671. height: number;
  11672. /** Gets or sets rotation angle */
  11673. angle: number;
  11674. /** Gets or sets the cell index in the sprite sheet */
  11675. cellIndex: number;
  11676. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11677. cellRef: string;
  11678. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11679. invertU: number;
  11680. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11681. invertV: number;
  11682. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11683. disposeWhenFinishedAnimating: boolean;
  11684. /** Gets the list of attached animations */
  11685. animations: Animation[];
  11686. /** Gets or sets a boolean indicating if the sprite can be picked */
  11687. isPickable: boolean;
  11688. /**
  11689. * Gets or sets the associated action manager
  11690. */
  11691. actionManager: Nullable<ActionManager>;
  11692. private _animationStarted;
  11693. private _loopAnimation;
  11694. private _fromIndex;
  11695. private _toIndex;
  11696. private _delay;
  11697. private _direction;
  11698. private _manager;
  11699. private _time;
  11700. private _onAnimationEnd;
  11701. /**
  11702. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11703. */
  11704. isVisible: boolean;
  11705. /**
  11706. * Gets or sets the sprite size
  11707. */
  11708. size: number;
  11709. /**
  11710. * Creates a new Sprite
  11711. * @param name defines the name
  11712. * @param manager defines the manager
  11713. */
  11714. constructor(
  11715. /** defines the name */
  11716. name: string, manager: ISpriteManager);
  11717. /**
  11718. * Starts an animation
  11719. * @param from defines the initial key
  11720. * @param to defines the end key
  11721. * @param loop defines if the animation must loop
  11722. * @param delay defines the start delay (in ms)
  11723. * @param onAnimationEnd defines a callback to call when animation ends
  11724. */
  11725. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11726. /** Stops current animation (if any) */
  11727. stopAnimation(): void;
  11728. /** @hidden */
  11729. _animate(deltaTime: number): void;
  11730. /** Release associated resources */
  11731. dispose(): void;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. /**
  11736. * Information about the result of picking within a scene
  11737. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11738. */
  11739. export class PickingInfo {
  11740. /** @hidden */
  11741. _pickingUnavailable: boolean;
  11742. /**
  11743. * If the pick collided with an object
  11744. */
  11745. hit: boolean;
  11746. /**
  11747. * Distance away where the pick collided
  11748. */
  11749. distance: number;
  11750. /**
  11751. * The location of pick collision
  11752. */
  11753. pickedPoint: Nullable<Vector3>;
  11754. /**
  11755. * The mesh corresponding the the pick collision
  11756. */
  11757. pickedMesh: Nullable<AbstractMesh>;
  11758. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11759. bu: number;
  11760. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11761. bv: number;
  11762. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11763. faceId: number;
  11764. /** Id of the the submesh that was picked */
  11765. subMeshId: number;
  11766. /** If a sprite was picked, this will be the sprite the pick collided with */
  11767. pickedSprite: Nullable<Sprite>;
  11768. /**
  11769. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11770. */
  11771. originMesh: Nullable<AbstractMesh>;
  11772. /**
  11773. * The ray that was used to perform the picking.
  11774. */
  11775. ray: Nullable<Ray>;
  11776. /**
  11777. * Gets the normal correspodning to the face the pick collided with
  11778. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11779. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11780. * @returns The normal correspodning to the face the pick collided with
  11781. */
  11782. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11783. /**
  11784. * Gets the texture coordinates of where the pick occured
  11785. * @returns the vector containing the coordnates of the texture
  11786. */
  11787. getTextureCoordinates(): Nullable<Vector2>;
  11788. }
  11789. }
  11790. declare module BABYLON {
  11791. /**
  11792. * Gather the list of pointer event types as constants.
  11793. */
  11794. export class PointerEventTypes {
  11795. /**
  11796. * 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.
  11797. */
  11798. static readonly POINTERDOWN: number;
  11799. /**
  11800. * The pointerup event is fired when a pointer is no longer active.
  11801. */
  11802. static readonly POINTERUP: number;
  11803. /**
  11804. * The pointermove event is fired when a pointer changes coordinates.
  11805. */
  11806. static readonly POINTERMOVE: number;
  11807. /**
  11808. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11809. */
  11810. static readonly POINTERWHEEL: number;
  11811. /**
  11812. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11813. */
  11814. static readonly POINTERPICK: number;
  11815. /**
  11816. * The pointertap event is fired when a the object has been touched and released without drag.
  11817. */
  11818. static readonly POINTERTAP: number;
  11819. /**
  11820. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11821. */
  11822. static readonly POINTERDOUBLETAP: number;
  11823. }
  11824. /**
  11825. * Base class of pointer info types.
  11826. */
  11827. export class PointerInfoBase {
  11828. /**
  11829. * Defines the type of event (PointerEventTypes)
  11830. */
  11831. type: number;
  11832. /**
  11833. * Defines the related dom event
  11834. */
  11835. event: PointerEvent | MouseWheelEvent;
  11836. /**
  11837. * Instantiates the base class of pointers info.
  11838. * @param type Defines the type of event (PointerEventTypes)
  11839. * @param event Defines the related dom event
  11840. */
  11841. constructor(
  11842. /**
  11843. * Defines the type of event (PointerEventTypes)
  11844. */
  11845. type: number,
  11846. /**
  11847. * Defines the related dom event
  11848. */
  11849. event: PointerEvent | MouseWheelEvent);
  11850. }
  11851. /**
  11852. * This class is used to store pointer related info for the onPrePointerObservable event.
  11853. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11854. */
  11855. export class PointerInfoPre extends PointerInfoBase {
  11856. /**
  11857. * Ray from a pointer if availible (eg. 6dof controller)
  11858. */
  11859. ray: Nullable<Ray>;
  11860. /**
  11861. * Defines the local position of the pointer on the canvas.
  11862. */
  11863. localPosition: Vector2;
  11864. /**
  11865. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11866. */
  11867. skipOnPointerObservable: boolean;
  11868. /**
  11869. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. * @param localX Defines the local x coordinates of the pointer when the event occured
  11873. * @param localY Defines the local y coordinates of the pointer when the event occured
  11874. */
  11875. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11876. }
  11877. /**
  11878. * This type contains all the data related to a pointer event in Babylon.js.
  11879. * 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.
  11880. */
  11881. export class PointerInfo extends PointerInfoBase {
  11882. /**
  11883. * Defines the picking info associated to the info (if any)\
  11884. */
  11885. pickInfo: Nullable<PickingInfo>;
  11886. /**
  11887. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11888. * @param type Defines the type of event (PointerEventTypes)
  11889. * @param event Defines the related dom event
  11890. * @param pickInfo Defines the picking info associated to the info (if any)\
  11891. */
  11892. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11893. /**
  11894. * Defines the picking info associated to the info (if any)\
  11895. */
  11896. pickInfo: Nullable<PickingInfo>);
  11897. }
  11898. /**
  11899. * Data relating to a touch event on the screen.
  11900. */
  11901. export interface PointerTouch {
  11902. /**
  11903. * X coordinate of touch.
  11904. */
  11905. x: number;
  11906. /**
  11907. * Y coordinate of touch.
  11908. */
  11909. y: number;
  11910. /**
  11911. * Id of touch. Unique for each finger.
  11912. */
  11913. pointerId: number;
  11914. /**
  11915. * Event type passed from DOM.
  11916. */
  11917. type: any;
  11918. }
  11919. }
  11920. declare module BABYLON {
  11921. /**
  11922. * Manage the mouse inputs to control the movement of a free camera.
  11923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11924. */
  11925. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11926. /**
  11927. * Define if touch is enabled in the mouse input
  11928. */
  11929. touchEnabled: boolean;
  11930. /**
  11931. * Defines the camera the input is attached to.
  11932. */
  11933. camera: FreeCamera;
  11934. /**
  11935. * Defines the buttons associated with the input to handle camera move.
  11936. */
  11937. buttons: number[];
  11938. /**
  11939. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11940. */
  11941. angularSensibility: number;
  11942. private _pointerInput;
  11943. private _onMouseMove;
  11944. private _observer;
  11945. private previousPosition;
  11946. /**
  11947. * Observable for when a pointer move event occurs containing the move offset
  11948. */
  11949. onPointerMovedObservable: Observable<{
  11950. offsetX: number;
  11951. offsetY: number;
  11952. }>;
  11953. /**
  11954. * @hidden
  11955. * If the camera should be rotated automatically based on pointer movement
  11956. */
  11957. _allowCameraRotation: boolean;
  11958. /**
  11959. * Manage the mouse inputs to control the movement of a free camera.
  11960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11961. * @param touchEnabled Defines if touch is enabled or not
  11962. */
  11963. constructor(
  11964. /**
  11965. * Define if touch is enabled in the mouse input
  11966. */
  11967. touchEnabled?: boolean);
  11968. /**
  11969. * Attach the input controls to a specific dom element to get the input from.
  11970. * @param element Defines the element the controls should be listened from
  11971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11972. */
  11973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11974. /**
  11975. * Called on JS contextmenu event.
  11976. * Override this method to provide functionality.
  11977. */
  11978. protected onContextMenu(evt: PointerEvent): void;
  11979. /**
  11980. * Detach the current controls from the specified dom element.
  11981. * @param element Defines the element to stop listening the inputs from
  11982. */
  11983. detachControl(element: Nullable<HTMLElement>): void;
  11984. /**
  11985. * Gets the class name of the current intput.
  11986. * @returns the class name
  11987. */
  11988. getClassName(): string;
  11989. /**
  11990. * Get the friendly name associated with the input class.
  11991. * @returns the input friendly name
  11992. */
  11993. getSimpleName(): string;
  11994. }
  11995. }
  11996. declare module BABYLON {
  11997. /**
  11998. * Manage the touch inputs to control the movement of a free camera.
  11999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12000. */
  12001. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12002. /**
  12003. * Defines the camera the input is attached to.
  12004. */
  12005. camera: FreeCamera;
  12006. /**
  12007. * Defines the touch sensibility for rotation.
  12008. * The higher the faster.
  12009. */
  12010. touchAngularSensibility: number;
  12011. /**
  12012. * Defines the touch sensibility for move.
  12013. * The higher the faster.
  12014. */
  12015. touchMoveSensibility: number;
  12016. private _offsetX;
  12017. private _offsetY;
  12018. private _pointerPressed;
  12019. private _pointerInput;
  12020. private _observer;
  12021. private _onLostFocus;
  12022. /**
  12023. * Attach the input controls to a specific dom element to get the input from.
  12024. * @param element Defines the element the controls should be listened from
  12025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12026. */
  12027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12028. /**
  12029. * Detach the current controls from the specified dom element.
  12030. * @param element Defines the element to stop listening the inputs from
  12031. */
  12032. detachControl(element: Nullable<HTMLElement>): void;
  12033. /**
  12034. * Update the current camera state depending on the inputs that have been used this frame.
  12035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12036. */
  12037. checkInputs(): void;
  12038. /**
  12039. * Gets the class name of the current intput.
  12040. * @returns the class name
  12041. */
  12042. getClassName(): string;
  12043. /**
  12044. * Get the friendly name associated with the input class.
  12045. * @returns the input friendly name
  12046. */
  12047. getSimpleName(): string;
  12048. }
  12049. }
  12050. declare module BABYLON {
  12051. /**
  12052. * Default Inputs manager for the FreeCamera.
  12053. * It groups all the default supported inputs for ease of use.
  12054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12055. */
  12056. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12057. /**
  12058. * @hidden
  12059. */
  12060. _mouseInput: Nullable<FreeCameraMouseInput>;
  12061. /**
  12062. * Instantiates a new FreeCameraInputsManager.
  12063. * @param camera Defines the camera the inputs belong to
  12064. */
  12065. constructor(camera: FreeCamera);
  12066. /**
  12067. * Add keyboard input support to the input manager.
  12068. * @returns the current input manager
  12069. */
  12070. addKeyboard(): FreeCameraInputsManager;
  12071. /**
  12072. * Add mouse input support to the input manager.
  12073. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12074. * @returns the current input manager
  12075. */
  12076. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12077. /**
  12078. * Removes the mouse input support from the manager
  12079. * @returns the current input manager
  12080. */
  12081. removeMouse(): FreeCameraInputsManager;
  12082. /**
  12083. * Add touch input support to the input manager.
  12084. * @returns the current input manager
  12085. */
  12086. addTouch(): FreeCameraInputsManager;
  12087. /**
  12088. * Remove all attached input methods from a camera
  12089. */
  12090. clear(): void;
  12091. }
  12092. }
  12093. declare module BABYLON {
  12094. /**
  12095. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12096. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12097. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12098. */
  12099. export class FreeCamera extends TargetCamera {
  12100. /**
  12101. * Define the collision ellipsoid of the camera.
  12102. * This is helpful to simulate a camera body like the player body around the camera
  12103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12104. */
  12105. ellipsoid: Vector3;
  12106. /**
  12107. * Define an offset for the position of the ellipsoid around the camera.
  12108. * This can be helpful to determine the center of the body near the gravity center of the body
  12109. * instead of its head.
  12110. */
  12111. ellipsoidOffset: Vector3;
  12112. /**
  12113. * Enable or disable collisions of the camera with the rest of the scene objects.
  12114. */
  12115. checkCollisions: boolean;
  12116. /**
  12117. * Enable or disable gravity on the camera.
  12118. */
  12119. applyGravity: boolean;
  12120. /**
  12121. * Define the input manager associated to the camera.
  12122. */
  12123. inputs: FreeCameraInputsManager;
  12124. /**
  12125. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12126. * Higher values reduce sensitivity.
  12127. */
  12128. /**
  12129. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12130. * Higher values reduce sensitivity.
  12131. */
  12132. angularSensibility: number;
  12133. /**
  12134. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12135. */
  12136. keysUp: number[];
  12137. /**
  12138. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12139. */
  12140. keysDown: number[];
  12141. /**
  12142. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12143. */
  12144. keysLeft: number[];
  12145. /**
  12146. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12147. */
  12148. keysRight: number[];
  12149. /**
  12150. * Event raised when the camera collide with a mesh in the scene.
  12151. */
  12152. onCollide: (collidedMesh: AbstractMesh) => void;
  12153. private _collider;
  12154. private _needMoveForGravity;
  12155. private _oldPosition;
  12156. private _diffPosition;
  12157. private _newPosition;
  12158. /** @hidden */
  12159. _localDirection: Vector3;
  12160. /** @hidden */
  12161. _transformedDirection: Vector3;
  12162. /**
  12163. * Instantiates a Free Camera.
  12164. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12165. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12167. * @param name Define the name of the camera in the scene
  12168. * @param position Define the start position of the camera in the scene
  12169. * @param scene Define the scene the camera belongs to
  12170. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12171. */
  12172. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12173. /**
  12174. * Attached controls to the current camera.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Detach the current controls from the camera.
  12181. * The camera will stop reacting to inputs.
  12182. * @param element Defines the element to stop listening the inputs from
  12183. */
  12184. detachControl(element: HTMLElement): void;
  12185. private _collisionMask;
  12186. /**
  12187. * Define a collision mask to limit the list of object the camera can collide with
  12188. */
  12189. collisionMask: number;
  12190. /** @hidden */
  12191. _collideWithWorld(displacement: Vector3): void;
  12192. private _onCollisionPositionChange;
  12193. /** @hidden */
  12194. _checkInputs(): void;
  12195. /** @hidden */
  12196. _decideIfNeedsToMove(): boolean;
  12197. /** @hidden */
  12198. _updatePosition(): void;
  12199. /**
  12200. * Destroy the camera and release the current resources hold by it.
  12201. */
  12202. dispose(): void;
  12203. /**
  12204. * Gets the current object class name.
  12205. * @return the class name
  12206. */
  12207. getClassName(): string;
  12208. }
  12209. }
  12210. declare module BABYLON {
  12211. /**
  12212. * Represents a gamepad control stick position
  12213. */
  12214. export class StickValues {
  12215. /**
  12216. * The x component of the control stick
  12217. */
  12218. x: number;
  12219. /**
  12220. * The y component of the control stick
  12221. */
  12222. y: number;
  12223. /**
  12224. * Initializes the gamepad x and y control stick values
  12225. * @param x The x component of the gamepad control stick value
  12226. * @param y The y component of the gamepad control stick value
  12227. */
  12228. constructor(
  12229. /**
  12230. * The x component of the control stick
  12231. */
  12232. x: number,
  12233. /**
  12234. * The y component of the control stick
  12235. */
  12236. y: number);
  12237. }
  12238. /**
  12239. * An interface which manages callbacks for gamepad button changes
  12240. */
  12241. export interface GamepadButtonChanges {
  12242. /**
  12243. * Called when a gamepad has been changed
  12244. */
  12245. changed: boolean;
  12246. /**
  12247. * Called when a gamepad press event has been triggered
  12248. */
  12249. pressChanged: boolean;
  12250. /**
  12251. * Called when a touch event has been triggered
  12252. */
  12253. touchChanged: boolean;
  12254. /**
  12255. * Called when a value has changed
  12256. */
  12257. valueChanged: boolean;
  12258. }
  12259. /**
  12260. * Represents a gamepad
  12261. */
  12262. export class Gamepad {
  12263. /**
  12264. * The id of the gamepad
  12265. */
  12266. id: string;
  12267. /**
  12268. * The index of the gamepad
  12269. */
  12270. index: number;
  12271. /**
  12272. * The browser gamepad
  12273. */
  12274. browserGamepad: any;
  12275. /**
  12276. * Specifies what type of gamepad this represents
  12277. */
  12278. type: number;
  12279. private _leftStick;
  12280. private _rightStick;
  12281. /** @hidden */
  12282. _isConnected: boolean;
  12283. private _leftStickAxisX;
  12284. private _leftStickAxisY;
  12285. private _rightStickAxisX;
  12286. private _rightStickAxisY;
  12287. /**
  12288. * Triggered when the left control stick has been changed
  12289. */
  12290. private _onleftstickchanged;
  12291. /**
  12292. * Triggered when the right control stick has been changed
  12293. */
  12294. private _onrightstickchanged;
  12295. /**
  12296. * Represents a gamepad controller
  12297. */
  12298. static GAMEPAD: number;
  12299. /**
  12300. * Represents a generic controller
  12301. */
  12302. static GENERIC: number;
  12303. /**
  12304. * Represents an XBox controller
  12305. */
  12306. static XBOX: number;
  12307. /**
  12308. * Represents a pose-enabled controller
  12309. */
  12310. static POSE_ENABLED: number;
  12311. /**
  12312. * Represents an Dual Shock controller
  12313. */
  12314. static DUALSHOCK: number;
  12315. /**
  12316. * Specifies whether the left control stick should be Y-inverted
  12317. */
  12318. protected _invertLeftStickY: boolean;
  12319. /**
  12320. * Specifies if the gamepad has been connected
  12321. */
  12322. readonly isConnected: boolean;
  12323. /**
  12324. * Initializes the gamepad
  12325. * @param id The id of the gamepad
  12326. * @param index The index of the gamepad
  12327. * @param browserGamepad The browser gamepad
  12328. * @param leftStickX The x component of the left joystick
  12329. * @param leftStickY The y component of the left joystick
  12330. * @param rightStickX The x component of the right joystick
  12331. * @param rightStickY The y component of the right joystick
  12332. */
  12333. constructor(
  12334. /**
  12335. * The id of the gamepad
  12336. */
  12337. id: string,
  12338. /**
  12339. * The index of the gamepad
  12340. */
  12341. index: number,
  12342. /**
  12343. * The browser gamepad
  12344. */
  12345. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12346. /**
  12347. * Callback triggered when the left joystick has changed
  12348. * @param callback
  12349. */
  12350. onleftstickchanged(callback: (values: StickValues) => void): void;
  12351. /**
  12352. * Callback triggered when the right joystick has changed
  12353. * @param callback
  12354. */
  12355. onrightstickchanged(callback: (values: StickValues) => void): void;
  12356. /**
  12357. * Gets the left joystick
  12358. */
  12359. /**
  12360. * Sets the left joystick values
  12361. */
  12362. leftStick: StickValues;
  12363. /**
  12364. * Gets the right joystick
  12365. */
  12366. /**
  12367. * Sets the right joystick value
  12368. */
  12369. rightStick: StickValues;
  12370. /**
  12371. * Updates the gamepad joystick positions
  12372. */
  12373. update(): void;
  12374. /**
  12375. * Disposes the gamepad
  12376. */
  12377. dispose(): void;
  12378. }
  12379. /**
  12380. * Represents a generic gamepad
  12381. */
  12382. export class GenericPad extends Gamepad {
  12383. private _buttons;
  12384. private _onbuttondown;
  12385. private _onbuttonup;
  12386. /**
  12387. * Observable triggered when a button has been pressed
  12388. */
  12389. onButtonDownObservable: Observable<number>;
  12390. /**
  12391. * Observable triggered when a button has been released
  12392. */
  12393. onButtonUpObservable: Observable<number>;
  12394. /**
  12395. * Callback triggered when a button has been pressed
  12396. * @param callback Called when a button has been pressed
  12397. */
  12398. onbuttondown(callback: (buttonPressed: number) => void): void;
  12399. /**
  12400. * Callback triggered when a button has been released
  12401. * @param callback Called when a button has been released
  12402. */
  12403. onbuttonup(callback: (buttonReleased: number) => void): void;
  12404. /**
  12405. * Initializes the generic gamepad
  12406. * @param id The id of the generic gamepad
  12407. * @param index The index of the generic gamepad
  12408. * @param browserGamepad The browser gamepad
  12409. */
  12410. constructor(id: string, index: number, browserGamepad: any);
  12411. private _setButtonValue;
  12412. /**
  12413. * Updates the generic gamepad
  12414. */
  12415. update(): void;
  12416. /**
  12417. * Disposes the generic gamepad
  12418. */
  12419. dispose(): void;
  12420. }
  12421. }
  12422. declare module BABYLON {
  12423. interface Engine {
  12424. /**
  12425. * Creates a raw texture
  12426. * @param data defines the data to store in the texture
  12427. * @param width defines the width of the texture
  12428. * @param height defines the height of the texture
  12429. * @param format defines the format of the data
  12430. * @param generateMipMaps defines if the engine should generate the mip levels
  12431. * @param invertY defines if data must be stored with Y axis inverted
  12432. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12433. * @param compression defines the compression used (null by default)
  12434. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12435. * @returns the raw texture inside an InternalTexture
  12436. */
  12437. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12438. /**
  12439. * Update a raw texture
  12440. * @param texture defines the texture to update
  12441. * @param data defines the data to store in the texture
  12442. * @param format defines the format of the data
  12443. * @param invertY defines if data must be stored with Y axis inverted
  12444. */
  12445. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12446. /**
  12447. * Update a raw texture
  12448. * @param texture defines the texture to update
  12449. * @param data defines the data to store in the texture
  12450. * @param format defines the format of the data
  12451. * @param invertY defines if data must be stored with Y axis inverted
  12452. * @param compression defines the compression used (null by default)
  12453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12454. */
  12455. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12456. /**
  12457. * Creates a new raw cube texture
  12458. * @param data defines the array of data to use to create each face
  12459. * @param size defines the size of the textures
  12460. * @param format defines the format of the data
  12461. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12462. * @param generateMipMaps defines if the engine should generate the mip levels
  12463. * @param invertY defines if data must be stored with Y axis inverted
  12464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12465. * @param compression defines the compression used (null by default)
  12466. * @returns the cube texture as an InternalTexture
  12467. */
  12468. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12469. /**
  12470. * Update a raw cube texture
  12471. * @param texture defines the texture to udpdate
  12472. * @param data defines the data to store
  12473. * @param format defines the data format
  12474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12475. * @param invertY defines if data must be stored with Y axis inverted
  12476. */
  12477. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12478. /**
  12479. * Update a raw cube texture
  12480. * @param texture defines the texture to udpdate
  12481. * @param data defines the data to store
  12482. * @param format defines the data format
  12483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param compression defines the compression used (null by default)
  12486. */
  12487. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12488. /**
  12489. * Update a raw cube texture
  12490. * @param texture defines the texture to udpdate
  12491. * @param data defines the data to store
  12492. * @param format defines the data format
  12493. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12494. * @param invertY defines if data must be stored with Y axis inverted
  12495. * @param compression defines the compression used (null by default)
  12496. * @param level defines which level of the texture to update
  12497. */
  12498. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12499. /**
  12500. * Creates a new raw cube texture from a specified url
  12501. * @param url defines the url where the data is located
  12502. * @param scene defines the current scene
  12503. * @param size defines the size of the textures
  12504. * @param format defines the format of the data
  12505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12506. * @param noMipmap defines if the engine should avoid generating the mip levels
  12507. * @param callback defines a callback used to extract texture data from loaded data
  12508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12509. * @param onLoad defines a callback called when texture is loaded
  12510. * @param onError defines a callback called if there is an error
  12511. * @returns the cube texture as an InternalTexture
  12512. */
  12513. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12514. /**
  12515. * Creates a new raw cube texture from a specified url
  12516. * @param url defines the url where the data is located
  12517. * @param scene defines the current scene
  12518. * @param size defines the size of the textures
  12519. * @param format defines the format of the data
  12520. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12521. * @param noMipmap defines if the engine should avoid generating the mip levels
  12522. * @param callback defines a callback used to extract texture data from loaded data
  12523. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12524. * @param onLoad defines a callback called when texture is loaded
  12525. * @param onError defines a callback called if there is an error
  12526. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12527. * @param invertY defines if data must be stored with Y axis inverted
  12528. * @returns the cube texture as an InternalTexture
  12529. */
  12530. 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;
  12531. /**
  12532. * Creates a new raw 3D texture
  12533. * @param data defines the data used to create the texture
  12534. * @param width defines the width of the texture
  12535. * @param height defines the height of the texture
  12536. * @param depth defines the depth of the texture
  12537. * @param format defines the format of the texture
  12538. * @param generateMipMaps defines if the engine must generate mip levels
  12539. * @param invertY defines if data must be stored with Y axis inverted
  12540. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12541. * @param compression defines the compressed used (can be null)
  12542. * @param textureType defines the compressed used (can be null)
  12543. * @returns a new raw 3D texture (stored in an InternalTexture)
  12544. */
  12545. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12546. /**
  12547. * Update a raw 3D texture
  12548. * @param texture defines the texture to update
  12549. * @param data defines the data to store
  12550. * @param format defines the data format
  12551. * @param invertY defines if data must be stored with Y axis inverted
  12552. */
  12553. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12554. /**
  12555. * Update a raw 3D texture
  12556. * @param texture defines the texture to update
  12557. * @param data defines the data to store
  12558. * @param format defines the data format
  12559. * @param invertY defines if data must be stored with Y axis inverted
  12560. * @param compression defines the used compression (can be null)
  12561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12562. */
  12563. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12564. /**
  12565. * Creates a new raw 2D array texture
  12566. * @param data defines the data used to create the texture
  12567. * @param width defines the width of the texture
  12568. * @param height defines the height of the texture
  12569. * @param depth defines the number of layers of the texture
  12570. * @param format defines the format of the texture
  12571. * @param generateMipMaps defines if the engine must generate mip levels
  12572. * @param invertY defines if data must be stored with Y axis inverted
  12573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12574. * @param compression defines the compressed used (can be null)
  12575. * @param textureType defines the compressed used (can be null)
  12576. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12577. */
  12578. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12579. /**
  12580. * Update a raw 2D array texture
  12581. * @param texture defines the texture to update
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param invertY defines if data must be stored with Y axis inverted
  12585. */
  12586. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12587. /**
  12588. * Update a raw 2D array texture
  12589. * @param texture defines the texture to update
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param compression defines the used compression (can be null)
  12594. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12595. */
  12596. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12597. }
  12598. }
  12599. declare module BABYLON {
  12600. /**
  12601. * Raw texture can help creating a texture directly from an array of data.
  12602. * This can be super useful if you either get the data from an uncompressed source or
  12603. * if you wish to create your texture pixel by pixel.
  12604. */
  12605. export class RawTexture extends Texture {
  12606. /**
  12607. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12608. */
  12609. format: number;
  12610. private _engine;
  12611. /**
  12612. * Instantiates a new RawTexture.
  12613. * Raw texture can help creating a texture directly from an array of data.
  12614. * This can be super useful if you either get the data from an uncompressed source or
  12615. * if you wish to create your texture pixel by pixel.
  12616. * @param data define the array of data to use to create the texture
  12617. * @param width define the width of the texture
  12618. * @param height define the height of the texture
  12619. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12620. * @param scene define the scene the texture belongs to
  12621. * @param generateMipMaps define whether mip maps should be generated or not
  12622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12624. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12625. */
  12626. constructor(data: ArrayBufferView, width: number, height: number,
  12627. /**
  12628. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12629. */
  12630. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12631. /**
  12632. * Updates the texture underlying data.
  12633. * @param data Define the new data of the texture
  12634. */
  12635. update(data: ArrayBufferView): void;
  12636. /**
  12637. * Creates a luminance texture from some data.
  12638. * @param data Define the texture data
  12639. * @param width Define the width of the texture
  12640. * @param height Define the height of the texture
  12641. * @param scene Define the scene the texture belongs to
  12642. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12643. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12644. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12645. * @returns the luminance texture
  12646. */
  12647. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12648. /**
  12649. * Creates a luminance alpha texture from some data.
  12650. * @param data Define the texture data
  12651. * @param width Define the width of the texture
  12652. * @param height Define the height of the texture
  12653. * @param scene Define the scene the texture belongs to
  12654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12657. * @returns the luminance alpha texture
  12658. */
  12659. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12660. /**
  12661. * Creates an alpha texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the alpha texture
  12670. */
  12671. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a RGB texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12682. * @returns the RGB alpha texture
  12683. */
  12684. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12685. /**
  12686. * Creates a RGBA texture from some data.
  12687. * @param data Define the texture data
  12688. * @param width Define the width of the texture
  12689. * @param height Define the height of the texture
  12690. * @param scene Define the scene the texture belongs to
  12691. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12695. * @returns the RGBA texture
  12696. */
  12697. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12698. /**
  12699. * Creates a R texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12708. * @returns the R texture
  12709. */
  12710. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12711. }
  12712. }
  12713. declare module BABYLON {
  12714. /**
  12715. * Interface for the size containing width and height
  12716. */
  12717. export interface ISize {
  12718. /**
  12719. * Width
  12720. */
  12721. width: number;
  12722. /**
  12723. * Heighht
  12724. */
  12725. height: number;
  12726. }
  12727. /**
  12728. * Size containing widht and height
  12729. */
  12730. export class Size implements ISize {
  12731. /**
  12732. * Width
  12733. */
  12734. width: number;
  12735. /**
  12736. * Height
  12737. */
  12738. height: number;
  12739. /**
  12740. * Creates a Size object from the given width and height (floats).
  12741. * @param width width of the new size
  12742. * @param height height of the new size
  12743. */
  12744. constructor(width: number, height: number);
  12745. /**
  12746. * Returns a string with the Size width and height
  12747. * @returns a string with the Size width and height
  12748. */
  12749. toString(): string;
  12750. /**
  12751. * "Size"
  12752. * @returns the string "Size"
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Returns the Size hash code.
  12757. * @returns a hash code for a unique width and height
  12758. */
  12759. getHashCode(): number;
  12760. /**
  12761. * Updates the current size from the given one.
  12762. * @param src the given size
  12763. */
  12764. copyFrom(src: Size): void;
  12765. /**
  12766. * Updates in place the current Size from the given floats.
  12767. * @param width width of the new size
  12768. * @param height height of the new size
  12769. * @returns the updated Size.
  12770. */
  12771. copyFromFloats(width: number, height: number): Size;
  12772. /**
  12773. * Updates in place the current Size from the given floats.
  12774. * @param width width to set
  12775. * @param height height to set
  12776. * @returns the updated Size.
  12777. */
  12778. set(width: number, height: number): Size;
  12779. /**
  12780. * Multiplies the width and height by numbers
  12781. * @param w factor to multiple the width by
  12782. * @param h factor to multiple the height by
  12783. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12784. */
  12785. multiplyByFloats(w: number, h: number): Size;
  12786. /**
  12787. * Clones the size
  12788. * @returns a new Size copied from the given one.
  12789. */
  12790. clone(): Size;
  12791. /**
  12792. * True if the current Size and the given one width and height are strictly equal.
  12793. * @param other the other size to compare against
  12794. * @returns True if the current Size and the given one width and height are strictly equal.
  12795. */
  12796. equals(other: Size): boolean;
  12797. /**
  12798. * The surface of the Size : width * height (float).
  12799. */
  12800. readonly surface: number;
  12801. /**
  12802. * Create a new size of zero
  12803. * @returns a new Size set to (0.0, 0.0)
  12804. */
  12805. static Zero(): Size;
  12806. /**
  12807. * Sums the width and height of two sizes
  12808. * @param otherSize size to add to this size
  12809. * @returns a new Size set as the addition result of the current Size and the given one.
  12810. */
  12811. add(otherSize: Size): Size;
  12812. /**
  12813. * Subtracts the width and height of two
  12814. * @param otherSize size to subtract to this size
  12815. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12816. */
  12817. subtract(otherSize: Size): Size;
  12818. /**
  12819. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12820. * @param start starting size to lerp between
  12821. * @param end end size to lerp between
  12822. * @param amount amount to lerp between the start and end values
  12823. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12824. */
  12825. static Lerp(start: Size, end: Size, amount: number): Size;
  12826. }
  12827. }
  12828. declare module BABYLON {
  12829. /**
  12830. * Defines a runtime animation
  12831. */
  12832. export class RuntimeAnimation {
  12833. private _events;
  12834. /**
  12835. * The current frame of the runtime animation
  12836. */
  12837. private _currentFrame;
  12838. /**
  12839. * The animation used by the runtime animation
  12840. */
  12841. private _animation;
  12842. /**
  12843. * The target of the runtime animation
  12844. */
  12845. private _target;
  12846. /**
  12847. * The initiating animatable
  12848. */
  12849. private _host;
  12850. /**
  12851. * The original value of the runtime animation
  12852. */
  12853. private _originalValue;
  12854. /**
  12855. * The original blend value of the runtime animation
  12856. */
  12857. private _originalBlendValue;
  12858. /**
  12859. * The offsets cache of the runtime animation
  12860. */
  12861. private _offsetsCache;
  12862. /**
  12863. * The high limits cache of the runtime animation
  12864. */
  12865. private _highLimitsCache;
  12866. /**
  12867. * Specifies if the runtime animation has been stopped
  12868. */
  12869. private _stopped;
  12870. /**
  12871. * The blending factor of the runtime animation
  12872. */
  12873. private _blendingFactor;
  12874. /**
  12875. * The BabylonJS scene
  12876. */
  12877. private _scene;
  12878. /**
  12879. * The current value of the runtime animation
  12880. */
  12881. private _currentValue;
  12882. /** @hidden */
  12883. _animationState: _IAnimationState;
  12884. /**
  12885. * The active target of the runtime animation
  12886. */
  12887. private _activeTargets;
  12888. private _currentActiveTarget;
  12889. private _directTarget;
  12890. /**
  12891. * The target path of the runtime animation
  12892. */
  12893. private _targetPath;
  12894. /**
  12895. * The weight of the runtime animation
  12896. */
  12897. private _weight;
  12898. /**
  12899. * The ratio offset of the runtime animation
  12900. */
  12901. private _ratioOffset;
  12902. /**
  12903. * The previous delay of the runtime animation
  12904. */
  12905. private _previousDelay;
  12906. /**
  12907. * The previous ratio of the runtime animation
  12908. */
  12909. private _previousRatio;
  12910. private _enableBlending;
  12911. private _keys;
  12912. private _minFrame;
  12913. private _maxFrame;
  12914. private _minValue;
  12915. private _maxValue;
  12916. private _targetIsArray;
  12917. /**
  12918. * Gets the current frame of the runtime animation
  12919. */
  12920. readonly currentFrame: number;
  12921. /**
  12922. * Gets the weight of the runtime animation
  12923. */
  12924. readonly weight: number;
  12925. /**
  12926. * Gets the current value of the runtime animation
  12927. */
  12928. readonly currentValue: any;
  12929. /**
  12930. * Gets the target path of the runtime animation
  12931. */
  12932. readonly targetPath: string;
  12933. /**
  12934. * Gets the actual target of the runtime animation
  12935. */
  12936. readonly target: any;
  12937. /** @hidden */
  12938. _onLoop: () => void;
  12939. /**
  12940. * Create a new RuntimeAnimation object
  12941. * @param target defines the target of the animation
  12942. * @param animation defines the source animation object
  12943. * @param scene defines the hosting scene
  12944. * @param host defines the initiating Animatable
  12945. */
  12946. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12947. private _preparePath;
  12948. /**
  12949. * Gets the animation from the runtime animation
  12950. */
  12951. readonly animation: Animation;
  12952. /**
  12953. * Resets the runtime animation to the beginning
  12954. * @param restoreOriginal defines whether to restore the target property to the original value
  12955. */
  12956. reset(restoreOriginal?: boolean): void;
  12957. /**
  12958. * Specifies if the runtime animation is stopped
  12959. * @returns Boolean specifying if the runtime animation is stopped
  12960. */
  12961. isStopped(): boolean;
  12962. /**
  12963. * Disposes of the runtime animation
  12964. */
  12965. dispose(): void;
  12966. /**
  12967. * Apply the interpolated value to the target
  12968. * @param currentValue defines the value computed by the animation
  12969. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12970. */
  12971. setValue(currentValue: any, weight: number): void;
  12972. private _getOriginalValues;
  12973. private _setValue;
  12974. /**
  12975. * Gets the loop pmode of the runtime animation
  12976. * @returns Loop Mode
  12977. */
  12978. private _getCorrectLoopMode;
  12979. /**
  12980. * Move the current animation to a given frame
  12981. * @param frame defines the frame to move to
  12982. */
  12983. goToFrame(frame: number): void;
  12984. /**
  12985. * @hidden Internal use only
  12986. */
  12987. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12988. /**
  12989. * Execute the current animation
  12990. * @param delay defines the delay to add to the current frame
  12991. * @param from defines the lower bound of the animation range
  12992. * @param to defines the upper bound of the animation range
  12993. * @param loop defines if the current animation must loop
  12994. * @param speedRatio defines the current speed ratio
  12995. * @param weight defines the weight of the animation (default is -1 so no weight)
  12996. * @param onLoop optional callback called when animation loops
  12997. * @returns a boolean indicating if the animation is running
  12998. */
  12999. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13000. }
  13001. }
  13002. declare module BABYLON {
  13003. /**
  13004. * Class used to store an actual running animation
  13005. */
  13006. export class Animatable {
  13007. /** defines the target object */
  13008. target: any;
  13009. /** defines the starting frame number (default is 0) */
  13010. fromFrame: number;
  13011. /** defines the ending frame number (default is 100) */
  13012. toFrame: number;
  13013. /** defines if the animation must loop (default is false) */
  13014. loopAnimation: boolean;
  13015. /** defines a callback to call when animation ends if it is not looping */
  13016. onAnimationEnd?: (() => void) | null | undefined;
  13017. /** defines a callback to call when animation loops */
  13018. onAnimationLoop?: (() => void) | null | undefined;
  13019. private _localDelayOffset;
  13020. private _pausedDelay;
  13021. private _runtimeAnimations;
  13022. private _paused;
  13023. private _scene;
  13024. private _speedRatio;
  13025. private _weight;
  13026. private _syncRoot;
  13027. /**
  13028. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13029. * This will only apply for non looping animation (default is true)
  13030. */
  13031. disposeOnEnd: boolean;
  13032. /**
  13033. * Gets a boolean indicating if the animation has started
  13034. */
  13035. animationStarted: boolean;
  13036. /**
  13037. * Observer raised when the animation ends
  13038. */
  13039. onAnimationEndObservable: Observable<Animatable>;
  13040. /**
  13041. * Observer raised when the animation loops
  13042. */
  13043. onAnimationLoopObservable: Observable<Animatable>;
  13044. /**
  13045. * Gets the root Animatable used to synchronize and normalize animations
  13046. */
  13047. readonly syncRoot: Nullable<Animatable>;
  13048. /**
  13049. * Gets the current frame of the first RuntimeAnimation
  13050. * Used to synchronize Animatables
  13051. */
  13052. readonly masterFrame: number;
  13053. /**
  13054. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13055. */
  13056. weight: number;
  13057. /**
  13058. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13059. */
  13060. speedRatio: number;
  13061. /**
  13062. * Creates a new Animatable
  13063. * @param scene defines the hosting scene
  13064. * @param target defines the target object
  13065. * @param fromFrame defines the starting frame number (default is 0)
  13066. * @param toFrame defines the ending frame number (default is 100)
  13067. * @param loopAnimation defines if the animation must loop (default is false)
  13068. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13069. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13070. * @param animations defines a group of animation to add to the new Animatable
  13071. * @param onAnimationLoop defines a callback to call when animation loops
  13072. */
  13073. constructor(scene: Scene,
  13074. /** defines the target object */
  13075. target: any,
  13076. /** defines the starting frame number (default is 0) */
  13077. fromFrame?: number,
  13078. /** defines the ending frame number (default is 100) */
  13079. toFrame?: number,
  13080. /** defines if the animation must loop (default is false) */
  13081. loopAnimation?: boolean, speedRatio?: number,
  13082. /** defines a callback to call when animation ends if it is not looping */
  13083. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13084. /** defines a callback to call when animation loops */
  13085. onAnimationLoop?: (() => void) | null | undefined);
  13086. /**
  13087. * Synchronize and normalize current Animatable with a source Animatable
  13088. * This is useful when using animation weights and when animations are not of the same length
  13089. * @param root defines the root Animatable to synchronize with
  13090. * @returns the current Animatable
  13091. */
  13092. syncWith(root: Animatable): Animatable;
  13093. /**
  13094. * Gets the list of runtime animations
  13095. * @returns an array of RuntimeAnimation
  13096. */
  13097. getAnimations(): RuntimeAnimation[];
  13098. /**
  13099. * Adds more animations to the current animatable
  13100. * @param target defines the target of the animations
  13101. * @param animations defines the new animations to add
  13102. */
  13103. appendAnimations(target: any, animations: Animation[]): void;
  13104. /**
  13105. * Gets the source animation for a specific property
  13106. * @param property defines the propertyu to look for
  13107. * @returns null or the source animation for the given property
  13108. */
  13109. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13110. /**
  13111. * Gets the runtime animation for a specific property
  13112. * @param property defines the propertyu to look for
  13113. * @returns null or the runtime animation for the given property
  13114. */
  13115. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13116. /**
  13117. * Resets the animatable to its original state
  13118. */
  13119. reset(): void;
  13120. /**
  13121. * Allows the animatable to blend with current running animations
  13122. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13123. * @param blendingSpeed defines the blending speed to use
  13124. */
  13125. enableBlending(blendingSpeed: number): void;
  13126. /**
  13127. * Disable animation blending
  13128. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13129. */
  13130. disableBlending(): void;
  13131. /**
  13132. * Jump directly to a given frame
  13133. * @param frame defines the frame to jump to
  13134. */
  13135. goToFrame(frame: number): void;
  13136. /**
  13137. * Pause the animation
  13138. */
  13139. pause(): void;
  13140. /**
  13141. * Restart the animation
  13142. */
  13143. restart(): void;
  13144. private _raiseOnAnimationEnd;
  13145. /**
  13146. * Stop and delete the current animation
  13147. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13148. * @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)
  13149. */
  13150. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13151. /**
  13152. * Wait asynchronously for the animation to end
  13153. * @returns a promise which will be fullfilled when the animation ends
  13154. */
  13155. waitAsync(): Promise<Animatable>;
  13156. /** @hidden */
  13157. _animate(delay: number): boolean;
  13158. }
  13159. interface Scene {
  13160. /** @hidden */
  13161. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13162. /** @hidden */
  13163. _processLateAnimationBindingsForMatrices(holder: {
  13164. totalWeight: number;
  13165. animations: RuntimeAnimation[];
  13166. originalValue: Matrix;
  13167. }): any;
  13168. /** @hidden */
  13169. _processLateAnimationBindingsForQuaternions(holder: {
  13170. totalWeight: number;
  13171. animations: RuntimeAnimation[];
  13172. originalValue: Quaternion;
  13173. }, refQuaternion: Quaternion): Quaternion;
  13174. /** @hidden */
  13175. _processLateAnimationBindings(): void;
  13176. /**
  13177. * Will start the animation sequence of a given target
  13178. * @param target defines the target
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param weight defines the weight to apply to the animation (1.0 by default)
  13182. * @param loop defines if the animation loops
  13183. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13184. * @param onAnimationEnd defines the function to be executed when the animation ends
  13185. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the animatable object created for this animation
  13189. */
  13190. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13191. /**
  13192. * Will start the animation sequence of a given target
  13193. * @param target defines the target
  13194. * @param from defines from which frame should animation start
  13195. * @param to defines until which frame should animation run.
  13196. * @param loop defines if the animation loops
  13197. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13198. * @param onAnimationEnd defines the function to be executed when the animation ends
  13199. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13200. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13201. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13202. * @param onAnimationLoop defines the callback to call when an animation loops
  13203. * @returns the animatable object created for this animation
  13204. */
  13205. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13206. /**
  13207. * Will start the animation sequence of a given target and its hierarchy
  13208. * @param target defines the target
  13209. * @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.
  13210. * @param from defines from which frame should animation start
  13211. * @param to defines until which frame should animation run.
  13212. * @param loop defines if the animation loops
  13213. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13214. * @param onAnimationEnd defines the function to be executed when the animation ends
  13215. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13216. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13217. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13218. * @param onAnimationLoop defines the callback to call when an animation loops
  13219. * @returns the list of created animatables
  13220. */
  13221. 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[];
  13222. /**
  13223. * Begin a new animation on a given node
  13224. * @param target defines the target where the animation will take place
  13225. * @param animations defines the list of animations to start
  13226. * @param from defines the initial value
  13227. * @param to defines the final value
  13228. * @param loop defines if you want animation to loop (off by default)
  13229. * @param speedRatio defines the speed ratio to apply to all animations
  13230. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13231. * @param onAnimationLoop defines the callback to call when an animation loops
  13232. * @returns the list of created animatables
  13233. */
  13234. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13235. /**
  13236. * Begin a new animation on a given node and its hierarchy
  13237. * @param target defines the root node where the animation will take place
  13238. * @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.
  13239. * @param animations defines the list of animations to start
  13240. * @param from defines the initial value
  13241. * @param to defines the final value
  13242. * @param loop defines if you want animation to loop (off by default)
  13243. * @param speedRatio defines the speed ratio to apply to all animations
  13244. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13245. * @param onAnimationLoop defines the callback to call when an animation loops
  13246. * @returns the list of animatables created for all nodes
  13247. */
  13248. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13249. /**
  13250. * Gets the animatable associated with a specific target
  13251. * @param target defines the target of the animatable
  13252. * @returns the required animatable if found
  13253. */
  13254. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13255. /**
  13256. * Gets all animatables associated with a given target
  13257. * @param target defines the target to look animatables for
  13258. * @returns an array of Animatables
  13259. */
  13260. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13261. /**
  13262. * Stops and removes all animations that have been applied to the scene
  13263. */
  13264. stopAllAnimations(): void;
  13265. /**
  13266. * Gets the current delta time used by animation engine
  13267. */
  13268. deltaTime: number;
  13269. }
  13270. interface Bone {
  13271. /**
  13272. * Copy an animation range from another bone
  13273. * @param source defines the source bone
  13274. * @param rangeName defines the range name to copy
  13275. * @param frameOffset defines the frame offset
  13276. * @param rescaleAsRequired defines if rescaling must be applied if required
  13277. * @param skelDimensionsRatio defines the scaling ratio
  13278. * @returns true if operation was successful
  13279. */
  13280. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13281. }
  13282. }
  13283. declare module BABYLON {
  13284. /**
  13285. * Class used to override all child animations of a given target
  13286. */
  13287. export class AnimationPropertiesOverride {
  13288. /**
  13289. * Gets or sets a value indicating if animation blending must be used
  13290. */
  13291. enableBlending: boolean;
  13292. /**
  13293. * Gets or sets the blending speed to use when enableBlending is true
  13294. */
  13295. blendingSpeed: number;
  13296. /**
  13297. * Gets or sets the default loop mode to use
  13298. */
  13299. loopMode: number;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * Class used to handle skinning animations
  13305. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13306. */
  13307. export class Skeleton implements IAnimatable {
  13308. /** defines the skeleton name */
  13309. name: string;
  13310. /** defines the skeleton Id */
  13311. id: string;
  13312. /**
  13313. * Defines the list of child bones
  13314. */
  13315. bones: Bone[];
  13316. /**
  13317. * Defines an estimate of the dimension of the skeleton at rest
  13318. */
  13319. dimensionsAtRest: Vector3;
  13320. /**
  13321. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13322. */
  13323. needInitialSkinMatrix: boolean;
  13324. /**
  13325. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13326. */
  13327. overrideMesh: Nullable<AbstractMesh>;
  13328. /**
  13329. * Gets the list of animations attached to this skeleton
  13330. */
  13331. animations: Array<Animation>;
  13332. private _scene;
  13333. private _isDirty;
  13334. private _transformMatrices;
  13335. private _transformMatrixTexture;
  13336. private _meshesWithPoseMatrix;
  13337. private _animatables;
  13338. private _identity;
  13339. private _synchronizedWithMesh;
  13340. private _ranges;
  13341. private _lastAbsoluteTransformsUpdateId;
  13342. private _canUseTextureForBones;
  13343. private _uniqueId;
  13344. /** @hidden */
  13345. _numBonesWithLinkedTransformNode: number;
  13346. /** @hidden */
  13347. _hasWaitingData: Nullable<boolean>;
  13348. /**
  13349. * Specifies if the skeleton should be serialized
  13350. */
  13351. doNotSerialize: boolean;
  13352. private _useTextureToStoreBoneMatrices;
  13353. /**
  13354. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13355. * Please note that this option is not available if the hardware does not support it
  13356. */
  13357. useTextureToStoreBoneMatrices: boolean;
  13358. private _animationPropertiesOverride;
  13359. /**
  13360. * Gets or sets the animation properties override
  13361. */
  13362. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13363. /**
  13364. * List of inspectable custom properties (used by the Inspector)
  13365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13366. */
  13367. inspectableCustomProperties: IInspectable[];
  13368. /**
  13369. * An observable triggered before computing the skeleton's matrices
  13370. */
  13371. onBeforeComputeObservable: Observable<Skeleton>;
  13372. /**
  13373. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13374. */
  13375. readonly isUsingTextureForMatrices: boolean;
  13376. /**
  13377. * Gets the unique ID of this skeleton
  13378. */
  13379. readonly uniqueId: number;
  13380. /**
  13381. * Creates a new skeleton
  13382. * @param name defines the skeleton name
  13383. * @param id defines the skeleton Id
  13384. * @param scene defines the hosting scene
  13385. */
  13386. constructor(
  13387. /** defines the skeleton name */
  13388. name: string,
  13389. /** defines the skeleton Id */
  13390. id: string, scene: Scene);
  13391. /**
  13392. * Gets the current object class name.
  13393. * @return the class name
  13394. */
  13395. getClassName(): string;
  13396. /**
  13397. * Returns an array containing the root bones
  13398. * @returns an array containing the root bones
  13399. */
  13400. getChildren(): Array<Bone>;
  13401. /**
  13402. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13403. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13404. * @returns a Float32Array containing matrices data
  13405. */
  13406. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13407. /**
  13408. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13409. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13410. * @returns a raw texture containing the data
  13411. */
  13412. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13413. /**
  13414. * Gets the current hosting scene
  13415. * @returns a scene object
  13416. */
  13417. getScene(): Scene;
  13418. /**
  13419. * Gets a string representing the current skeleton data
  13420. * @param fullDetails defines a boolean indicating if we want a verbose version
  13421. * @returns a string representing the current skeleton data
  13422. */
  13423. toString(fullDetails?: boolean): string;
  13424. /**
  13425. * Get bone's index searching by name
  13426. * @param name defines bone's name to search for
  13427. * @return the indice of the bone. Returns -1 if not found
  13428. */
  13429. getBoneIndexByName(name: string): number;
  13430. /**
  13431. * Creater a new animation range
  13432. * @param name defines the name of the range
  13433. * @param from defines the start key
  13434. * @param to defines the end key
  13435. */
  13436. createAnimationRange(name: string, from: number, to: number): void;
  13437. /**
  13438. * Delete a specific animation range
  13439. * @param name defines the name of the range
  13440. * @param deleteFrames defines if frames must be removed as well
  13441. */
  13442. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13443. /**
  13444. * Gets a specific animation range
  13445. * @param name defines the name of the range to look for
  13446. * @returns the requested animation range or null if not found
  13447. */
  13448. getAnimationRange(name: string): Nullable<AnimationRange>;
  13449. /**
  13450. * Gets the list of all animation ranges defined on this skeleton
  13451. * @returns an array
  13452. */
  13453. getAnimationRanges(): Nullable<AnimationRange>[];
  13454. /**
  13455. * Copy animation range from a source skeleton.
  13456. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13457. * @param source defines the source skeleton
  13458. * @param name defines the name of the range to copy
  13459. * @param rescaleAsRequired defines if rescaling must be applied if required
  13460. * @returns true if operation was successful
  13461. */
  13462. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13463. /**
  13464. * Forces the skeleton to go to rest pose
  13465. */
  13466. returnToRest(): void;
  13467. private _getHighestAnimationFrame;
  13468. /**
  13469. * Begin a specific animation range
  13470. * @param name defines the name of the range to start
  13471. * @param loop defines if looping must be turned on (false by default)
  13472. * @param speedRatio defines the speed ratio to apply (1 by default)
  13473. * @param onAnimationEnd defines a callback which will be called when animation will end
  13474. * @returns a new animatable
  13475. */
  13476. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13477. /** @hidden */
  13478. _markAsDirty(): void;
  13479. /** @hidden */
  13480. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13481. /** @hidden */
  13482. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13483. private _computeTransformMatrices;
  13484. /**
  13485. * Build all resources required to render a skeleton
  13486. */
  13487. prepare(): void;
  13488. /**
  13489. * Gets the list of animatables currently running for this skeleton
  13490. * @returns an array of animatables
  13491. */
  13492. getAnimatables(): IAnimatable[];
  13493. /**
  13494. * Clone the current skeleton
  13495. * @param name defines the name of the new skeleton
  13496. * @param id defines the id of the new skeleton
  13497. * @returns the new skeleton
  13498. */
  13499. clone(name: string, id?: string): Skeleton;
  13500. /**
  13501. * Enable animation blending for this skeleton
  13502. * @param blendingSpeed defines the blending speed to apply
  13503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13504. */
  13505. enableBlending(blendingSpeed?: number): void;
  13506. /**
  13507. * Releases all resources associated with the current skeleton
  13508. */
  13509. dispose(): void;
  13510. /**
  13511. * Serialize the skeleton in a JSON object
  13512. * @returns a JSON object
  13513. */
  13514. serialize(): any;
  13515. /**
  13516. * Creates a new skeleton from serialized data
  13517. * @param parsedSkeleton defines the serialized data
  13518. * @param scene defines the hosting scene
  13519. * @returns a new skeleton
  13520. */
  13521. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13522. /**
  13523. * Compute all node absolute transforms
  13524. * @param forceUpdate defines if computation must be done even if cache is up to date
  13525. */
  13526. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13527. /**
  13528. * Gets the root pose matrix
  13529. * @returns a matrix
  13530. */
  13531. getPoseMatrix(): Nullable<Matrix>;
  13532. /**
  13533. * Sorts bones per internal index
  13534. */
  13535. sortBones(): void;
  13536. private _sortBones;
  13537. }
  13538. }
  13539. declare module BABYLON {
  13540. /**
  13541. * Class used to store bone information
  13542. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13543. */
  13544. export class Bone extends Node {
  13545. /**
  13546. * defines the bone name
  13547. */
  13548. name: string;
  13549. private static _tmpVecs;
  13550. private static _tmpQuat;
  13551. private static _tmpMats;
  13552. /**
  13553. * Gets the list of child bones
  13554. */
  13555. children: Bone[];
  13556. /** Gets the animations associated with this bone */
  13557. animations: Animation[];
  13558. /**
  13559. * Gets or sets bone length
  13560. */
  13561. length: number;
  13562. /**
  13563. * @hidden Internal only
  13564. * Set this value to map this bone to a different index in the transform matrices
  13565. * Set this value to -1 to exclude the bone from the transform matrices
  13566. */
  13567. _index: Nullable<number>;
  13568. private _skeleton;
  13569. private _localMatrix;
  13570. private _restPose;
  13571. private _baseMatrix;
  13572. private _absoluteTransform;
  13573. private _invertedAbsoluteTransform;
  13574. private _parent;
  13575. private _scalingDeterminant;
  13576. private _worldTransform;
  13577. private _localScaling;
  13578. private _localRotation;
  13579. private _localPosition;
  13580. private _needToDecompose;
  13581. private _needToCompose;
  13582. /** @hidden */
  13583. _linkedTransformNode: Nullable<TransformNode>;
  13584. /** @hidden */
  13585. _waitingTransformNodeId: Nullable<string>;
  13586. /** @hidden */
  13587. /** @hidden */
  13588. _matrix: Matrix;
  13589. /**
  13590. * Create a new bone
  13591. * @param name defines the bone name
  13592. * @param skeleton defines the parent skeleton
  13593. * @param parentBone defines the parent (can be null if the bone is the root)
  13594. * @param localMatrix defines the local matrix
  13595. * @param restPose defines the rest pose matrix
  13596. * @param baseMatrix defines the base matrix
  13597. * @param index defines index of the bone in the hiearchy
  13598. */
  13599. constructor(
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13604. /**
  13605. * Gets the current object class name.
  13606. * @return the class name
  13607. */
  13608. getClassName(): string;
  13609. /**
  13610. * Gets the parent skeleton
  13611. * @returns a skeleton
  13612. */
  13613. getSkeleton(): Skeleton;
  13614. /**
  13615. * Gets parent bone
  13616. * @returns a bone or null if the bone is the root of the bone hierarchy
  13617. */
  13618. getParent(): Nullable<Bone>;
  13619. /**
  13620. * Returns an array containing the root bones
  13621. * @returns an array containing the root bones
  13622. */
  13623. getChildren(): Array<Bone>;
  13624. /**
  13625. * Gets the node index in matrix array generated for rendering
  13626. * @returns the node index
  13627. */
  13628. getIndex(): number;
  13629. /**
  13630. * Sets the parent bone
  13631. * @param parent defines the parent (can be null if the bone is the root)
  13632. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13633. */
  13634. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13635. /**
  13636. * Gets the local matrix
  13637. * @returns a matrix
  13638. */
  13639. getLocalMatrix(): Matrix;
  13640. /**
  13641. * Gets the base matrix (initial matrix which remains unchanged)
  13642. * @returns a matrix
  13643. */
  13644. getBaseMatrix(): Matrix;
  13645. /**
  13646. * Gets the rest pose matrix
  13647. * @returns a matrix
  13648. */
  13649. getRestPose(): Matrix;
  13650. /**
  13651. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13652. */
  13653. getWorldMatrix(): Matrix;
  13654. /**
  13655. * Sets the local matrix to rest pose matrix
  13656. */
  13657. returnToRest(): void;
  13658. /**
  13659. * Gets the inverse of the absolute transform matrix.
  13660. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13661. * @returns a matrix
  13662. */
  13663. getInvertedAbsoluteTransform(): Matrix;
  13664. /**
  13665. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13666. * @returns a matrix
  13667. */
  13668. getAbsoluteTransform(): Matrix;
  13669. /**
  13670. * Links with the given transform node.
  13671. * The local matrix of this bone is copied from the transform node every frame.
  13672. * @param transformNode defines the transform node to link to
  13673. */
  13674. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13675. /**
  13676. * Gets the node used to drive the bone's transformation
  13677. * @returns a transform node or null
  13678. */
  13679. getTransformNode(): Nullable<TransformNode>;
  13680. /** Gets or sets current position (in local space) */
  13681. position: Vector3;
  13682. /** Gets or sets current rotation (in local space) */
  13683. rotation: Vector3;
  13684. /** Gets or sets current rotation quaternion (in local space) */
  13685. rotationQuaternion: Quaternion;
  13686. /** Gets or sets current scaling (in local space) */
  13687. scaling: Vector3;
  13688. /**
  13689. * Gets the animation properties override
  13690. */
  13691. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. private _decompose;
  13693. private _compose;
  13694. /**
  13695. * Update the base and local matrices
  13696. * @param matrix defines the new base or local matrix
  13697. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13698. * @param updateLocalMatrix defines if the local matrix should be updated
  13699. */
  13700. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13701. /** @hidden */
  13702. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13703. /**
  13704. * Flag the bone as dirty (Forcing it to update everything)
  13705. */
  13706. markAsDirty(): void;
  13707. /** @hidden */
  13708. _markAsDirtyAndCompose(): void;
  13709. private _markAsDirtyAndDecompose;
  13710. /**
  13711. * Translate the bone in local or world space
  13712. * @param vec The amount to translate the bone
  13713. * @param space The space that the translation is in
  13714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13715. */
  13716. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13717. /**
  13718. * Set the postion of the bone in local or world space
  13719. * @param position The position to set the bone
  13720. * @param space The space that the position is in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. */
  13723. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13724. /**
  13725. * Set the absolute position of the bone (world space)
  13726. * @param position The position to set the bone
  13727. * @param mesh The mesh that this bone is attached to
  13728. */
  13729. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13730. /**
  13731. * Scale the bone on the x, y and z axes (in local space)
  13732. * @param x The amount to scale the bone on the x axis
  13733. * @param y The amount to scale the bone on the y axis
  13734. * @param z The amount to scale the bone on the z axis
  13735. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13736. */
  13737. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13738. /**
  13739. * Set the bone scaling in local space
  13740. * @param scale defines the scaling vector
  13741. */
  13742. setScale(scale: Vector3): void;
  13743. /**
  13744. * Gets the current scaling in local space
  13745. * @returns the current scaling vector
  13746. */
  13747. getScale(): Vector3;
  13748. /**
  13749. * Gets the current scaling in local space and stores it in a target vector
  13750. * @param result defines the target vector
  13751. */
  13752. getScaleToRef(result: Vector3): void;
  13753. /**
  13754. * Set the yaw, pitch, and roll of the bone in local or world space
  13755. * @param yaw The rotation of the bone on the y axis
  13756. * @param pitch The rotation of the bone on the x axis
  13757. * @param roll The rotation of the bone on the z axis
  13758. * @param space The space that the axes of rotation are in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Add a rotation to the bone on an axis in local or world space
  13764. * @param axis The axis to rotate the bone on
  13765. * @param amount The amount to rotate the bone
  13766. * @param space The space that the axis is in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. */
  13769. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13770. /**
  13771. * Set the rotation of the bone to a particular axis angle in local or world space
  13772. * @param axis The axis to rotate the bone on
  13773. * @param angle The angle that the bone should be rotated to
  13774. * @param space The space that the axis is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13778. /**
  13779. * Set the euler rotation of the bone in local of world space
  13780. * @param rotation The euler rotation that the bone should be set to
  13781. * @param space The space that the rotation is in
  13782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13783. */
  13784. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13785. /**
  13786. * Set the quaternion rotation of the bone in local of world space
  13787. * @param quat The quaternion rotation that the bone should be set to
  13788. * @param space The space that the rotation is in
  13789. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13790. */
  13791. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13792. /**
  13793. * Set the rotation matrix of the bone in local of world space
  13794. * @param rotMat The rotation matrix that the bone should be set to
  13795. * @param space The space that the rotation is in
  13796. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13797. */
  13798. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13799. private _rotateWithMatrix;
  13800. private _getNegativeRotationToRef;
  13801. /**
  13802. * Get the position of the bone in local or world space
  13803. * @param space The space that the returned position is in
  13804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13805. * @returns The position of the bone
  13806. */
  13807. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13808. /**
  13809. * Copy the position of the bone to a vector3 in local or world space
  13810. * @param space The space that the returned position is in
  13811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13812. * @param result The vector3 to copy the position to
  13813. */
  13814. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13815. /**
  13816. * Get the absolute position of the bone (world space)
  13817. * @param mesh The mesh that this bone is attached to
  13818. * @returns The absolute position of the bone
  13819. */
  13820. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13821. /**
  13822. * Copy the absolute position of the bone (world space) to the result param
  13823. * @param mesh The mesh that this bone is attached to
  13824. * @param result The vector3 to copy the absolute position to
  13825. */
  13826. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13827. /**
  13828. * Compute the absolute transforms of this bone and its children
  13829. */
  13830. computeAbsoluteTransforms(): void;
  13831. /**
  13832. * Get the world direction from an axis that is in the local space of the bone
  13833. * @param localAxis The local direction that is used to compute the world direction
  13834. * @param mesh The mesh that this bone is attached to
  13835. * @returns The world direction
  13836. */
  13837. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13838. /**
  13839. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13840. * @param localAxis The local direction that is used to compute the world direction
  13841. * @param mesh The mesh that this bone is attached to
  13842. * @param result The vector3 that the world direction will be copied to
  13843. */
  13844. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13845. /**
  13846. * Get the euler rotation of the bone in local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @returns The euler rotation
  13850. */
  13851. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13852. /**
  13853. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @param result The vector3 that the rotation should be copied to
  13857. */
  13858. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13859. /**
  13860. * Get the quaternion rotation of the bone in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @returns The quaternion rotation
  13864. */
  13865. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13866. /**
  13867. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13868. * @param space The space that the rotation should be in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. * @param result The quaternion that the rotation should be copied to
  13871. */
  13872. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13873. /**
  13874. * Get the rotation matrix of the bone in local or world space
  13875. * @param space The space that the rotation should be in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. * @returns The rotation matrix
  13878. */
  13879. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13880. /**
  13881. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13882. * @param space The space that the rotation should be in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. * @param result The quaternion that the rotation should be copied to
  13885. */
  13886. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13887. /**
  13888. * Get the world position of a point that is in the local space of the bone
  13889. * @param position The local position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @returns The world position
  13892. */
  13893. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13894. /**
  13895. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13896. * @param position The local position
  13897. * @param mesh The mesh that this bone is attached to
  13898. * @param result The vector3 that the world position should be copied to
  13899. */
  13900. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13901. /**
  13902. * Get the local position of a point that is in world space
  13903. * @param position The world position
  13904. * @param mesh The mesh that this bone is attached to
  13905. * @returns The local position
  13906. */
  13907. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13908. /**
  13909. * Get the local position of a point that is in world space and copy it to the result param
  13910. * @param position The world position
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @param result The vector3 that the local position should be copied to
  13913. */
  13914. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13915. }
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * 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.
  13920. * @see https://doc.babylonjs.com/how_to/transformnode
  13921. */
  13922. export class TransformNode extends Node {
  13923. /**
  13924. * Object will not rotate to face the camera
  13925. */
  13926. static BILLBOARDMODE_NONE: number;
  13927. /**
  13928. * Object will rotate to face the camera but only on the x axis
  13929. */
  13930. static BILLBOARDMODE_X: number;
  13931. /**
  13932. * Object will rotate to face the camera but only on the y axis
  13933. */
  13934. static BILLBOARDMODE_Y: number;
  13935. /**
  13936. * Object will rotate to face the camera but only on the z axis
  13937. */
  13938. static BILLBOARDMODE_Z: number;
  13939. /**
  13940. * Object will rotate to face the camera
  13941. */
  13942. static BILLBOARDMODE_ALL: number;
  13943. /**
  13944. * Object will rotate to face the camera's position instead of orientation
  13945. */
  13946. static BILLBOARDMODE_USE_POSITION: number;
  13947. private _forward;
  13948. private _forwardInverted;
  13949. private _up;
  13950. private _right;
  13951. private _rightInverted;
  13952. private _position;
  13953. private _rotation;
  13954. private _rotationQuaternion;
  13955. protected _scaling: Vector3;
  13956. protected _isDirty: boolean;
  13957. private _transformToBoneReferal;
  13958. private _isAbsoluteSynced;
  13959. private _billboardMode;
  13960. /**
  13961. * Gets or sets the billboard mode. Default is 0.
  13962. *
  13963. * | Value | Type | Description |
  13964. * | --- | --- | --- |
  13965. * | 0 | BILLBOARDMODE_NONE | |
  13966. * | 1 | BILLBOARDMODE_X | |
  13967. * | 2 | BILLBOARDMODE_Y | |
  13968. * | 4 | BILLBOARDMODE_Z | |
  13969. * | 7 | BILLBOARDMODE_ALL | |
  13970. *
  13971. */
  13972. billboardMode: number;
  13973. private _preserveParentRotationForBillboard;
  13974. /**
  13975. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13976. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13977. */
  13978. preserveParentRotationForBillboard: boolean;
  13979. /**
  13980. * 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
  13981. */
  13982. scalingDeterminant: number;
  13983. private _infiniteDistance;
  13984. /**
  13985. * Gets or sets the distance of the object to max, often used by skybox
  13986. */
  13987. infiniteDistance: boolean;
  13988. /**
  13989. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13990. * By default the system will update normals to compensate
  13991. */
  13992. ignoreNonUniformScaling: boolean;
  13993. /**
  13994. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13995. */
  13996. reIntegrateRotationIntoRotationQuaternion: boolean;
  13997. /** @hidden */
  13998. _poseMatrix: Nullable<Matrix>;
  13999. /** @hidden */
  14000. _localMatrix: Matrix;
  14001. private _usePivotMatrix;
  14002. private _absolutePosition;
  14003. private _absoluteScaling;
  14004. private _absoluteRotationQuaternion;
  14005. private _pivotMatrix;
  14006. private _pivotMatrixInverse;
  14007. protected _postMultiplyPivotMatrix: boolean;
  14008. protected _isWorldMatrixFrozen: boolean;
  14009. /** @hidden */
  14010. _indexInSceneTransformNodesArray: number;
  14011. /**
  14012. * An event triggered after the world matrix is updated
  14013. */
  14014. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14015. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14016. /**
  14017. * Gets a string identifying the name of the class
  14018. * @returns "TransformNode" string
  14019. */
  14020. getClassName(): string;
  14021. /**
  14022. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14023. */
  14024. position: Vector3;
  14025. /**
  14026. * 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)).
  14027. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14028. */
  14029. rotation: Vector3;
  14030. /**
  14031. * 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)).
  14032. */
  14033. scaling: Vector3;
  14034. /**
  14035. * 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).
  14036. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14037. */
  14038. rotationQuaternion: Nullable<Quaternion>;
  14039. /**
  14040. * The forward direction of that transform in world space.
  14041. */
  14042. readonly forward: Vector3;
  14043. /**
  14044. * The up direction of that transform in world space.
  14045. */
  14046. readonly up: Vector3;
  14047. /**
  14048. * The right direction of that transform in world space.
  14049. */
  14050. readonly right: Vector3;
  14051. /**
  14052. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14053. * @param matrix the matrix to copy the pose from
  14054. * @returns this TransformNode.
  14055. */
  14056. updatePoseMatrix(matrix: Matrix): TransformNode;
  14057. /**
  14058. * Returns the mesh Pose matrix.
  14059. * @returns the pose matrix
  14060. */
  14061. getPoseMatrix(): Matrix;
  14062. /** @hidden */
  14063. _isSynchronized(): boolean;
  14064. /** @hidden */
  14065. _initCache(): void;
  14066. /**
  14067. * Flag the transform node as dirty (Forcing it to update everything)
  14068. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14069. * @returns this transform node
  14070. */
  14071. markAsDirty(property: string): TransformNode;
  14072. /**
  14073. * Returns the current mesh absolute position.
  14074. * Returns a Vector3.
  14075. */
  14076. readonly absolutePosition: Vector3;
  14077. /**
  14078. * Returns the current mesh absolute scaling.
  14079. * Returns a Vector3.
  14080. */
  14081. readonly absoluteScaling: Vector3;
  14082. /**
  14083. * Returns the current mesh absolute rotation.
  14084. * Returns a Quaternion.
  14085. */
  14086. readonly absoluteRotationQuaternion: Quaternion;
  14087. /**
  14088. * Sets a new matrix to apply before all other transformation
  14089. * @param matrix defines the transform matrix
  14090. * @returns the current TransformNode
  14091. */
  14092. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14093. /**
  14094. * Sets a new pivot matrix to the current node
  14095. * @param matrix defines the new pivot matrix to use
  14096. * @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
  14097. * @returns the current TransformNode
  14098. */
  14099. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14100. /**
  14101. * Returns the mesh pivot matrix.
  14102. * Default : Identity.
  14103. * @returns the matrix
  14104. */
  14105. getPivotMatrix(): Matrix;
  14106. /**
  14107. * Instantiate (when possible) or clone that node with its hierarchy
  14108. * @param newParent defines the new parent to use for the instance (or clone)
  14109. * @param options defines options to configure how copy is done
  14110. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14111. * @returns an instance (or a clone) of the current node with its hiearchy
  14112. */
  14113. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14114. doNotInstantiate: boolean;
  14115. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14116. /**
  14117. * Prevents the World matrix to be computed any longer
  14118. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14119. * @returns the TransformNode.
  14120. */
  14121. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14122. /**
  14123. * Allows back the World matrix computation.
  14124. * @returns the TransformNode.
  14125. */
  14126. unfreezeWorldMatrix(): this;
  14127. /**
  14128. * True if the World matrix has been frozen.
  14129. */
  14130. readonly isWorldMatrixFrozen: boolean;
  14131. /**
  14132. * Retuns the mesh absolute position in the World.
  14133. * @returns a Vector3.
  14134. */
  14135. getAbsolutePosition(): Vector3;
  14136. /**
  14137. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14138. * @param absolutePosition the absolute position to set
  14139. * @returns the TransformNode.
  14140. */
  14141. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14142. /**
  14143. * Sets the mesh position in its local space.
  14144. * @param vector3 the position to set in localspace
  14145. * @returns the TransformNode.
  14146. */
  14147. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14148. /**
  14149. * Returns the mesh position in the local space from the current World matrix values.
  14150. * @returns a new Vector3.
  14151. */
  14152. getPositionExpressedInLocalSpace(): Vector3;
  14153. /**
  14154. * Translates the mesh along the passed Vector3 in its local space.
  14155. * @param vector3 the distance to translate in localspace
  14156. * @returns the TransformNode.
  14157. */
  14158. locallyTranslate(vector3: Vector3): TransformNode;
  14159. private static _lookAtVectorCache;
  14160. /**
  14161. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14162. * @param targetPoint the position (must be in same space as current mesh) to look at
  14163. * @param yawCor optional yaw (y-axis) correction in radians
  14164. * @param pitchCor optional pitch (x-axis) correction in radians
  14165. * @param rollCor optional roll (z-axis) correction in radians
  14166. * @param space the choosen space of the target
  14167. * @returns the TransformNode.
  14168. */
  14169. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14170. /**
  14171. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14172. * This Vector3 is expressed in the World space.
  14173. * @param localAxis axis to rotate
  14174. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14175. */
  14176. getDirection(localAxis: Vector3): Vector3;
  14177. /**
  14178. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14179. * localAxis is expressed in the mesh local space.
  14180. * result is computed in the Wordl space from the mesh World matrix.
  14181. * @param localAxis axis to rotate
  14182. * @param result the resulting transformnode
  14183. * @returns this TransformNode.
  14184. */
  14185. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14186. /**
  14187. * Sets this transform node rotation to the given local axis.
  14188. * @param localAxis the axis in local space
  14189. * @param yawCor optional yaw (y-axis) correction in radians
  14190. * @param pitchCor optional pitch (x-axis) correction in radians
  14191. * @param rollCor optional roll (z-axis) correction in radians
  14192. * @returns this TransformNode
  14193. */
  14194. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14195. /**
  14196. * Sets a new pivot point to the current node
  14197. * @param point defines the new pivot point to use
  14198. * @param space defines if the point is in world or local space (local by default)
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14202. /**
  14203. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14204. * @returns the pivot point
  14205. */
  14206. getPivotPoint(): Vector3;
  14207. /**
  14208. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14209. * @param result the vector3 to store the result
  14210. * @returns this TransformNode.
  14211. */
  14212. getPivotPointToRef(result: Vector3): TransformNode;
  14213. /**
  14214. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14215. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14216. */
  14217. getAbsolutePivotPoint(): Vector3;
  14218. /**
  14219. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14220. * @param result vector3 to store the result
  14221. * @returns this TransformNode.
  14222. */
  14223. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14224. /**
  14225. * Defines the passed node as the parent of the current node.
  14226. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14227. * @see https://doc.babylonjs.com/how_to/parenting
  14228. * @param node the node ot set as the parent
  14229. * @returns this TransformNode.
  14230. */
  14231. setParent(node: Nullable<Node>): TransformNode;
  14232. private _nonUniformScaling;
  14233. /**
  14234. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14235. */
  14236. readonly nonUniformScaling: boolean;
  14237. /** @hidden */
  14238. _updateNonUniformScalingState(value: boolean): boolean;
  14239. /**
  14240. * Attach the current TransformNode to another TransformNode associated with a bone
  14241. * @param bone Bone affecting the TransformNode
  14242. * @param affectedTransformNode TransformNode associated with the bone
  14243. * @returns this object
  14244. */
  14245. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14246. /**
  14247. * Detach the transform node if its associated with a bone
  14248. * @returns this object
  14249. */
  14250. detachFromBone(): TransformNode;
  14251. private static _rotationAxisCache;
  14252. /**
  14253. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14254. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14255. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14256. * The passed axis is also normalized.
  14257. * @param axis the axis to rotate around
  14258. * @param amount the amount to rotate in radians
  14259. * @param space Space to rotate in (Default: local)
  14260. * @returns the TransformNode.
  14261. */
  14262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14263. /**
  14264. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14265. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14266. * The passed axis is also normalized. .
  14267. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14268. * @param point the point to rotate around
  14269. * @param axis the axis to rotate around
  14270. * @param amount the amount to rotate in radians
  14271. * @returns the TransformNode
  14272. */
  14273. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14274. /**
  14275. * Translates the mesh along the axis vector for the passed distance in the given space.
  14276. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14277. * @param axis the axis to translate in
  14278. * @param distance the distance to translate
  14279. * @param space Space to rotate in (Default: local)
  14280. * @returns the TransformNode.
  14281. */
  14282. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14283. /**
  14284. * Adds a rotation step to the mesh current rotation.
  14285. * x, y, z are Euler angles expressed in radians.
  14286. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14287. * This means this rotation is made in the mesh local space only.
  14288. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14289. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14290. * ```javascript
  14291. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14292. * ```
  14293. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14294. * 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.
  14295. * @param x Rotation to add
  14296. * @param y Rotation to add
  14297. * @param z Rotation to add
  14298. * @returns the TransformNode.
  14299. */
  14300. addRotation(x: number, y: number, z: number): TransformNode;
  14301. /**
  14302. * @hidden
  14303. */
  14304. protected _getEffectiveParent(): Nullable<Node>;
  14305. /**
  14306. * Computes the world matrix of the node
  14307. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14308. * @returns the world matrix
  14309. */
  14310. computeWorldMatrix(force?: boolean): Matrix;
  14311. protected _afterComputeWorldMatrix(): void;
  14312. /**
  14313. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14314. * @param func callback function to add
  14315. *
  14316. * @returns the TransformNode.
  14317. */
  14318. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14319. /**
  14320. * Removes a registered callback function.
  14321. * @param func callback function to remove
  14322. * @returns the TransformNode.
  14323. */
  14324. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14325. /**
  14326. * Gets the position of the current mesh in camera space
  14327. * @param camera defines the camera to use
  14328. * @returns a position
  14329. */
  14330. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14331. /**
  14332. * Returns the distance from the mesh to the active camera
  14333. * @param camera defines the camera to use
  14334. * @returns the distance
  14335. */
  14336. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14337. /**
  14338. * Clone the current transform node
  14339. * @param name Name of the new clone
  14340. * @param newParent New parent for the clone
  14341. * @param doNotCloneChildren Do not clone children hierarchy
  14342. * @returns the new transform node
  14343. */
  14344. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14345. /**
  14346. * Serializes the objects information.
  14347. * @param currentSerializationObject defines the object to serialize in
  14348. * @returns the serialized object
  14349. */
  14350. serialize(currentSerializationObject?: any): any;
  14351. /**
  14352. * Returns a new TransformNode object parsed from the source provided.
  14353. * @param parsedTransformNode is the source.
  14354. * @param scene the scne the object belongs to
  14355. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14356. * @returns a new TransformNode object parsed from the source provided.
  14357. */
  14358. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14359. /**
  14360. * Get all child-transformNodes of this node
  14361. * @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
  14362. * @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
  14363. * @returns an array of TransformNode
  14364. */
  14365. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14366. /**
  14367. * Releases resources associated with this transform node.
  14368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14370. */
  14371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14372. /**
  14373. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14374. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14375. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14376. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14377. * @returns the current mesh
  14378. */
  14379. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14380. private _syncAbsoluteScalingAndRotation;
  14381. }
  14382. }
  14383. declare module BABYLON {
  14384. /**
  14385. * Defines the types of pose enabled controllers that are supported
  14386. */
  14387. export enum PoseEnabledControllerType {
  14388. /**
  14389. * HTC Vive
  14390. */
  14391. VIVE = 0,
  14392. /**
  14393. * Oculus Rift
  14394. */
  14395. OCULUS = 1,
  14396. /**
  14397. * Windows mixed reality
  14398. */
  14399. WINDOWS = 2,
  14400. /**
  14401. * Samsung gear VR
  14402. */
  14403. GEAR_VR = 3,
  14404. /**
  14405. * Google Daydream
  14406. */
  14407. DAYDREAM = 4,
  14408. /**
  14409. * Generic
  14410. */
  14411. GENERIC = 5
  14412. }
  14413. /**
  14414. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14415. */
  14416. export interface MutableGamepadButton {
  14417. /**
  14418. * Value of the button/trigger
  14419. */
  14420. value: number;
  14421. /**
  14422. * If the button/trigger is currently touched
  14423. */
  14424. touched: boolean;
  14425. /**
  14426. * If the button/trigger is currently pressed
  14427. */
  14428. pressed: boolean;
  14429. }
  14430. /**
  14431. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14432. * @hidden
  14433. */
  14434. export interface ExtendedGamepadButton extends GamepadButton {
  14435. /**
  14436. * If the button/trigger is currently pressed
  14437. */
  14438. readonly pressed: boolean;
  14439. /**
  14440. * If the button/trigger is currently touched
  14441. */
  14442. readonly touched: boolean;
  14443. /**
  14444. * Value of the button/trigger
  14445. */
  14446. readonly value: number;
  14447. }
  14448. /** @hidden */
  14449. export interface _GamePadFactory {
  14450. /**
  14451. * Returns wether or not the current gamepad can be created for this type of controller.
  14452. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14453. * @returns true if it can be created, otherwise false
  14454. */
  14455. canCreate(gamepadInfo: any): boolean;
  14456. /**
  14457. * Creates a new instance of the Gamepad.
  14458. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14459. * @returns the new gamepad instance
  14460. */
  14461. create(gamepadInfo: any): Gamepad;
  14462. }
  14463. /**
  14464. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14465. */
  14466. export class PoseEnabledControllerHelper {
  14467. /** @hidden */
  14468. static _ControllerFactories: _GamePadFactory[];
  14469. /** @hidden */
  14470. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14471. /**
  14472. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14473. * @param vrGamepad the gamepad to initialized
  14474. * @returns a vr controller of the type the gamepad identified as
  14475. */
  14476. static InitiateController(vrGamepad: any): Gamepad;
  14477. }
  14478. /**
  14479. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14480. */
  14481. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14482. /**
  14483. * If the controller is used in a webXR session
  14484. */
  14485. isXR: boolean;
  14486. private _deviceRoomPosition;
  14487. private _deviceRoomRotationQuaternion;
  14488. /**
  14489. * The device position in babylon space
  14490. */
  14491. devicePosition: Vector3;
  14492. /**
  14493. * The device rotation in babylon space
  14494. */
  14495. deviceRotationQuaternion: Quaternion;
  14496. /**
  14497. * The scale factor of the device in babylon space
  14498. */
  14499. deviceScaleFactor: number;
  14500. /**
  14501. * (Likely devicePosition should be used instead) The device position in its room space
  14502. */
  14503. position: Vector3;
  14504. /**
  14505. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14506. */
  14507. rotationQuaternion: Quaternion;
  14508. /**
  14509. * The type of controller (Eg. Windows mixed reality)
  14510. */
  14511. controllerType: PoseEnabledControllerType;
  14512. protected _calculatedPosition: Vector3;
  14513. private _calculatedRotation;
  14514. /**
  14515. * The raw pose from the device
  14516. */
  14517. rawPose: DevicePose;
  14518. private _trackPosition;
  14519. private _maxRotationDistFromHeadset;
  14520. private _draggedRoomRotation;
  14521. /**
  14522. * @hidden
  14523. */
  14524. _disableTrackPosition(fixedPosition: Vector3): void;
  14525. /**
  14526. * Internal, the mesh attached to the controller
  14527. * @hidden
  14528. */
  14529. _mesh: Nullable<AbstractMesh>;
  14530. private _poseControlledCamera;
  14531. private _leftHandSystemQuaternion;
  14532. /**
  14533. * Internal, matrix used to convert room space to babylon space
  14534. * @hidden
  14535. */
  14536. _deviceToWorld: Matrix;
  14537. /**
  14538. * Node to be used when casting a ray from the controller
  14539. * @hidden
  14540. */
  14541. _pointingPoseNode: Nullable<TransformNode>;
  14542. /**
  14543. * Name of the child mesh that can be used to cast a ray from the controller
  14544. */
  14545. static readonly POINTING_POSE: string;
  14546. /**
  14547. * Creates a new PoseEnabledController from a gamepad
  14548. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14549. */
  14550. constructor(browserGamepad: any);
  14551. private _workingMatrix;
  14552. /**
  14553. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14554. */
  14555. update(): void;
  14556. /**
  14557. * Updates only the pose device and mesh without doing any button event checking
  14558. */
  14559. protected _updatePoseAndMesh(): void;
  14560. /**
  14561. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14562. * @param poseData raw pose fromthe device
  14563. */
  14564. updateFromDevice(poseData: DevicePose): void;
  14565. /**
  14566. * @hidden
  14567. */
  14568. _meshAttachedObservable: Observable<AbstractMesh>;
  14569. /**
  14570. * Attaches a mesh to the controller
  14571. * @param mesh the mesh to be attached
  14572. */
  14573. attachToMesh(mesh: AbstractMesh): void;
  14574. /**
  14575. * Attaches the controllers mesh to a camera
  14576. * @param camera the camera the mesh should be attached to
  14577. */
  14578. attachToPoseControlledCamera(camera: TargetCamera): void;
  14579. /**
  14580. * Disposes of the controller
  14581. */
  14582. dispose(): void;
  14583. /**
  14584. * The mesh that is attached to the controller
  14585. */
  14586. readonly mesh: Nullable<AbstractMesh>;
  14587. /**
  14588. * Gets the ray of the controller in the direction the controller is pointing
  14589. * @param length the length the resulting ray should be
  14590. * @returns a ray in the direction the controller is pointing
  14591. */
  14592. getForwardRay(length?: number): Ray;
  14593. }
  14594. }
  14595. declare module BABYLON {
  14596. /**
  14597. * Defines the WebVRController object that represents controllers tracked in 3D space
  14598. */
  14599. export abstract class WebVRController extends PoseEnabledController {
  14600. /**
  14601. * Internal, the default controller model for the controller
  14602. */
  14603. protected _defaultModel: Nullable<AbstractMesh>;
  14604. /**
  14605. * Fired when the trigger state has changed
  14606. */
  14607. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14608. /**
  14609. * Fired when the main button state has changed
  14610. */
  14611. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14612. /**
  14613. * Fired when the secondary button state has changed
  14614. */
  14615. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14616. /**
  14617. * Fired when the pad state has changed
  14618. */
  14619. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14620. /**
  14621. * Fired when controllers stick values have changed
  14622. */
  14623. onPadValuesChangedObservable: Observable<StickValues>;
  14624. /**
  14625. * Array of button availible on the controller
  14626. */
  14627. protected _buttons: Array<MutableGamepadButton>;
  14628. private _onButtonStateChange;
  14629. /**
  14630. * Fired when a controller button's state has changed
  14631. * @param callback the callback containing the button that was modified
  14632. */
  14633. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14634. /**
  14635. * X and Y axis corresponding to the controllers joystick
  14636. */
  14637. pad: StickValues;
  14638. /**
  14639. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14640. */
  14641. hand: string;
  14642. /**
  14643. * The default controller model for the controller
  14644. */
  14645. readonly defaultModel: Nullable<AbstractMesh>;
  14646. /**
  14647. * Creates a new WebVRController from a gamepad
  14648. * @param vrGamepad the gamepad that the WebVRController should be created from
  14649. */
  14650. constructor(vrGamepad: any);
  14651. /**
  14652. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14653. */
  14654. update(): void;
  14655. /**
  14656. * Function to be called when a button is modified
  14657. */
  14658. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14659. /**
  14660. * Loads a mesh and attaches it to the controller
  14661. * @param scene the scene the mesh should be added to
  14662. * @param meshLoaded callback for when the mesh has been loaded
  14663. */
  14664. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14665. private _setButtonValue;
  14666. private _changes;
  14667. private _checkChanges;
  14668. /**
  14669. * Disposes of th webVRCOntroller
  14670. */
  14671. dispose(): void;
  14672. }
  14673. }
  14674. declare module BABYLON {
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * 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.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14725. /**
  14726. * Computes the world matrix of the node
  14727. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14728. * @param useWasUpdatedFlag defines a reserved property
  14729. * @returns the world matrix
  14730. */
  14731. computeWorldMatrix(): Matrix;
  14732. /**
  14733. * Returns the integer 3.
  14734. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14735. */
  14736. getTypeID(): number;
  14737. /**
  14738. * Prepares the list of defines specific to the light type.
  14739. * @param defines the list of defines
  14740. * @param lightIndex defines the index of the light for the effect
  14741. */
  14742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14743. }
  14744. }
  14745. declare module BABYLON {
  14746. /** @hidden */
  14747. export var vrMultiviewToSingleviewPixelShader: {
  14748. name: string;
  14749. shader: string;
  14750. };
  14751. }
  14752. declare module BABYLON {
  14753. /**
  14754. * Renders to multiple views with a single draw call
  14755. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14756. */
  14757. export class MultiviewRenderTarget extends RenderTargetTexture {
  14758. /**
  14759. * Creates a multiview render target
  14760. * @param scene scene used with the render target
  14761. * @param size the size of the render target (used for each view)
  14762. */
  14763. constructor(scene: Scene, size?: number | {
  14764. width: number;
  14765. height: number;
  14766. } | {
  14767. ratio: number;
  14768. });
  14769. /**
  14770. * @hidden
  14771. * @param faceIndex the face index, if its a cube texture
  14772. */
  14773. _bindFrameBuffer(faceIndex?: number): void;
  14774. /**
  14775. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14776. * @returns the view count
  14777. */
  14778. getViewCount(): number;
  14779. }
  14780. }
  14781. declare module BABYLON {
  14782. /**
  14783. * Represents a camera frustum
  14784. */
  14785. export class Frustum {
  14786. /**
  14787. * Gets the planes representing the frustum
  14788. * @param transform matrix to be applied to the returned planes
  14789. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14790. */
  14791. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14792. /**
  14793. * Gets the near frustum plane transformed by the transform matrix
  14794. * @param transform transformation matrix to be applied to the resulting frustum plane
  14795. * @param frustumPlane the resuling frustum plane
  14796. */
  14797. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14798. /**
  14799. * Gets the far frustum plane transformed by the transform matrix
  14800. * @param transform transformation matrix to be applied to the resulting frustum plane
  14801. * @param frustumPlane the resuling frustum plane
  14802. */
  14803. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14804. /**
  14805. * Gets the left frustum plane transformed by the transform matrix
  14806. * @param transform transformation matrix to be applied to the resulting frustum plane
  14807. * @param frustumPlane the resuling frustum plane
  14808. */
  14809. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14810. /**
  14811. * Gets the right frustum plane transformed by the transform matrix
  14812. * @param transform transformation matrix to be applied to the resulting frustum plane
  14813. * @param frustumPlane the resuling frustum plane
  14814. */
  14815. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14816. /**
  14817. * Gets the top frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the bottom frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14830. * @param transform transformation matrix to be applied to the resulting frustum planes
  14831. * @param frustumPlanes the resuling frustum planes
  14832. */
  14833. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14834. }
  14835. }
  14836. declare module BABYLON {
  14837. interface Engine {
  14838. /**
  14839. * Creates a new multiview render target
  14840. * @param width defines the width of the texture
  14841. * @param height defines the height of the texture
  14842. * @returns the created multiview texture
  14843. */
  14844. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14845. /**
  14846. * Binds a multiview framebuffer to be drawn to
  14847. * @param multiviewTexture texture to bind
  14848. */
  14849. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14850. }
  14851. interface Camera {
  14852. /**
  14853. * @hidden
  14854. * 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)
  14855. */
  14856. _useMultiviewToSingleView: boolean;
  14857. /**
  14858. * @hidden
  14859. * 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)
  14860. */
  14861. _multiviewTexture: Nullable<RenderTargetTexture>;
  14862. /**
  14863. * @hidden
  14864. * ensures the multiview texture of the camera exists and has the specified width/height
  14865. * @param width height to set on the multiview texture
  14866. * @param height width to set on the multiview texture
  14867. */
  14868. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14869. }
  14870. interface Scene {
  14871. /** @hidden */
  14872. _transformMatrixR: Matrix;
  14873. /** @hidden */
  14874. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14875. /** @hidden */
  14876. _createMultiviewUbo(): void;
  14877. /** @hidden */
  14878. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14879. /** @hidden */
  14880. _renderMultiviewToSingleView(camera: Camera): void;
  14881. }
  14882. }
  14883. declare module BABYLON {
  14884. /**
  14885. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14886. * This will not be used for webXR as it supports displaying texture arrays directly
  14887. */
  14888. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14889. /**
  14890. * Initializes a VRMultiviewToSingleview
  14891. * @param name name of the post process
  14892. * @param camera camera to be applied to
  14893. * @param scaleFactor scaling factor to the size of the output texture
  14894. */
  14895. constructor(name: string, camera: Camera, scaleFactor: number);
  14896. }
  14897. }
  14898. declare module BABYLON {
  14899. /**
  14900. * Interface used to define additional presentation attributes
  14901. */
  14902. export interface IVRPresentationAttributes {
  14903. /**
  14904. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14905. */
  14906. highRefreshRate: boolean;
  14907. /**
  14908. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14909. */
  14910. foveationLevel: number;
  14911. }
  14912. interface Engine {
  14913. /** @hidden */
  14914. _vrDisplay: any;
  14915. /** @hidden */
  14916. _vrSupported: boolean;
  14917. /** @hidden */
  14918. _oldSize: Size;
  14919. /** @hidden */
  14920. _oldHardwareScaleFactor: number;
  14921. /** @hidden */
  14922. _vrExclusivePointerMode: boolean;
  14923. /** @hidden */
  14924. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14925. /** @hidden */
  14926. _onVRDisplayPointerRestricted: () => void;
  14927. /** @hidden */
  14928. _onVRDisplayPointerUnrestricted: () => void;
  14929. /** @hidden */
  14930. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14931. /** @hidden */
  14932. _onVrDisplayDisconnect: Nullable<() => void>;
  14933. /** @hidden */
  14934. _onVrDisplayPresentChange: Nullable<() => void>;
  14935. /**
  14936. * Observable signaled when VR display mode changes
  14937. */
  14938. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14939. /**
  14940. * Observable signaled when VR request present is complete
  14941. */
  14942. onVRRequestPresentComplete: Observable<boolean>;
  14943. /**
  14944. * Observable signaled when VR request present starts
  14945. */
  14946. onVRRequestPresentStart: Observable<Engine>;
  14947. /**
  14948. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14949. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14950. */
  14951. isInVRExclusivePointerMode: boolean;
  14952. /**
  14953. * Gets a boolean indicating if a webVR device was detected
  14954. * @returns true if a webVR device was detected
  14955. */
  14956. isVRDevicePresent(): boolean;
  14957. /**
  14958. * Gets the current webVR device
  14959. * @returns the current webVR device (or null)
  14960. */
  14961. getVRDevice(): any;
  14962. /**
  14963. * Initializes a webVR display and starts listening to display change events
  14964. * The onVRDisplayChangedObservable will be notified upon these changes
  14965. * @returns A promise containing a VRDisplay and if vr is supported
  14966. */
  14967. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14968. /** @hidden */
  14969. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14970. /**
  14971. * Gets or sets the presentation attributes used to configure VR rendering
  14972. */
  14973. vrPresentationAttributes?: IVRPresentationAttributes;
  14974. /**
  14975. * Call this function to switch to webVR mode
  14976. * Will do nothing if webVR is not supported or if there is no webVR device
  14977. * @param options the webvr options provided to the camera. mainly used for multiview
  14978. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14979. */
  14980. enableVR(options: WebVROptions): void;
  14981. /** @hidden */
  14982. _onVRFullScreenTriggered(): void;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. /**
  14987. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14988. * IMPORTANT!! The data is right-hand data.
  14989. * @export
  14990. * @interface DevicePose
  14991. */
  14992. export interface DevicePose {
  14993. /**
  14994. * The position of the device, values in array are [x,y,z].
  14995. */
  14996. readonly position: Nullable<Float32Array>;
  14997. /**
  14998. * The linearVelocity of the device, values in array are [x,y,z].
  14999. */
  15000. readonly linearVelocity: Nullable<Float32Array>;
  15001. /**
  15002. * The linearAcceleration of the device, values in array are [x,y,z].
  15003. */
  15004. readonly linearAcceleration: Nullable<Float32Array>;
  15005. /**
  15006. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15007. */
  15008. readonly orientation: Nullable<Float32Array>;
  15009. /**
  15010. * The angularVelocity of the device, values in array are [x,y,z].
  15011. */
  15012. readonly angularVelocity: Nullable<Float32Array>;
  15013. /**
  15014. * The angularAcceleration of the device, values in array are [x,y,z].
  15015. */
  15016. readonly angularAcceleration: Nullable<Float32Array>;
  15017. }
  15018. /**
  15019. * Interface representing a pose controlled object in Babylon.
  15020. * A pose controlled object has both regular pose values as well as pose values
  15021. * from an external device such as a VR head mounted display
  15022. */
  15023. export interface PoseControlled {
  15024. /**
  15025. * The position of the object in babylon space.
  15026. */
  15027. position: Vector3;
  15028. /**
  15029. * The rotation quaternion of the object in babylon space.
  15030. */
  15031. rotationQuaternion: Quaternion;
  15032. /**
  15033. * The position of the device in babylon space.
  15034. */
  15035. devicePosition?: Vector3;
  15036. /**
  15037. * The rotation quaternion of the device in babylon space.
  15038. */
  15039. deviceRotationQuaternion: Quaternion;
  15040. /**
  15041. * The raw pose coming from the device.
  15042. */
  15043. rawPose: Nullable<DevicePose>;
  15044. /**
  15045. * The scale of the device to be used when translating from device space to babylon space.
  15046. */
  15047. deviceScaleFactor: number;
  15048. /**
  15049. * Updates the poseControlled values based on the input device pose.
  15050. * @param poseData the pose data to update the object with
  15051. */
  15052. updateFromDevice(poseData: DevicePose): void;
  15053. }
  15054. /**
  15055. * Set of options to customize the webVRCamera
  15056. */
  15057. export interface WebVROptions {
  15058. /**
  15059. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15060. */
  15061. trackPosition?: boolean;
  15062. /**
  15063. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15064. */
  15065. positionScale?: number;
  15066. /**
  15067. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15068. */
  15069. displayName?: string;
  15070. /**
  15071. * Should the native controller meshes be initialized. (default: true)
  15072. */
  15073. controllerMeshes?: boolean;
  15074. /**
  15075. * Creating a default HemiLight only on controllers. (default: true)
  15076. */
  15077. defaultLightingOnControllers?: boolean;
  15078. /**
  15079. * If you don't want to use the default VR button of the helper. (default: false)
  15080. */
  15081. useCustomVRButton?: boolean;
  15082. /**
  15083. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15084. */
  15085. customVRButton?: HTMLButtonElement;
  15086. /**
  15087. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15088. */
  15089. rayLength?: number;
  15090. /**
  15091. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15092. */
  15093. defaultHeight?: number;
  15094. /**
  15095. * If multiview should be used if availible (default: false)
  15096. */
  15097. useMultiview?: boolean;
  15098. }
  15099. /**
  15100. * This represents a WebVR camera.
  15101. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15102. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15103. */
  15104. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15105. private webVROptions;
  15106. /**
  15107. * @hidden
  15108. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15109. */
  15110. _vrDevice: any;
  15111. /**
  15112. * The rawPose of the vrDevice.
  15113. */
  15114. rawPose: Nullable<DevicePose>;
  15115. private _onVREnabled;
  15116. private _specsVersion;
  15117. private _attached;
  15118. private _frameData;
  15119. protected _descendants: Array<Node>;
  15120. private _deviceRoomPosition;
  15121. /** @hidden */
  15122. _deviceRoomRotationQuaternion: Quaternion;
  15123. private _standingMatrix;
  15124. /**
  15125. * Represents device position in babylon space.
  15126. */
  15127. devicePosition: Vector3;
  15128. /**
  15129. * Represents device rotation in babylon space.
  15130. */
  15131. deviceRotationQuaternion: Quaternion;
  15132. /**
  15133. * The scale of the device to be used when translating from device space to babylon space.
  15134. */
  15135. deviceScaleFactor: number;
  15136. private _deviceToWorld;
  15137. private _worldToDevice;
  15138. /**
  15139. * References to the webVR controllers for the vrDevice.
  15140. */
  15141. controllers: Array<WebVRController>;
  15142. /**
  15143. * Emits an event when a controller is attached.
  15144. */
  15145. onControllersAttachedObservable: Observable<WebVRController[]>;
  15146. /**
  15147. * Emits an event when a controller's mesh has been loaded;
  15148. */
  15149. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15150. /**
  15151. * Emits an event when the HMD's pose has been updated.
  15152. */
  15153. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15154. private _poseSet;
  15155. /**
  15156. * If the rig cameras be used as parent instead of this camera.
  15157. */
  15158. rigParenting: boolean;
  15159. private _lightOnControllers;
  15160. private _defaultHeight?;
  15161. /**
  15162. * Instantiates a WebVRFreeCamera.
  15163. * @param name The name of the WebVRFreeCamera
  15164. * @param position The starting anchor position for the camera
  15165. * @param scene The scene the camera belongs to
  15166. * @param webVROptions a set of customizable options for the webVRCamera
  15167. */
  15168. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15169. /**
  15170. * Gets the device distance from the ground in meters.
  15171. * @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.
  15172. */
  15173. deviceDistanceToRoomGround(): number;
  15174. /**
  15175. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15176. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15177. */
  15178. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15179. /**
  15180. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15181. * @returns A promise with a boolean set to if the standing matrix is supported.
  15182. */
  15183. useStandingMatrixAsync(): Promise<boolean>;
  15184. /**
  15185. * Disposes the camera
  15186. */
  15187. dispose(): void;
  15188. /**
  15189. * Gets a vrController by name.
  15190. * @param name The name of the controller to retreive
  15191. * @returns the controller matching the name specified or null if not found
  15192. */
  15193. getControllerByName(name: string): Nullable<WebVRController>;
  15194. private _leftController;
  15195. /**
  15196. * The controller corresponding to the users left hand.
  15197. */
  15198. readonly leftController: Nullable<WebVRController>;
  15199. private _rightController;
  15200. /**
  15201. * The controller corresponding to the users right hand.
  15202. */
  15203. readonly rightController: Nullable<WebVRController>;
  15204. /**
  15205. * Casts a ray forward from the vrCamera's gaze.
  15206. * @param length Length of the ray (default: 100)
  15207. * @returns the ray corresponding to the gaze
  15208. */
  15209. getForwardRay(length?: number): Ray;
  15210. /**
  15211. * @hidden
  15212. * Updates the camera based on device's frame data
  15213. */
  15214. _checkInputs(): void;
  15215. /**
  15216. * Updates the poseControlled values based on the input device pose.
  15217. * @param poseData Pose coming from the device
  15218. */
  15219. updateFromDevice(poseData: DevicePose): void;
  15220. private _htmlElementAttached;
  15221. private _detachIfAttached;
  15222. /**
  15223. * WebVR's attach control will start broadcasting frames to the device.
  15224. * Note that in certain browsers (chrome for example) this function must be called
  15225. * within a user-interaction callback. Example:
  15226. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15227. *
  15228. * @param element html element to attach the vrDevice to
  15229. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15230. */
  15231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15232. /**
  15233. * Detaches the camera from the html element and disables VR
  15234. *
  15235. * @param element html element to detach from
  15236. */
  15237. detachControl(element: HTMLElement): void;
  15238. /**
  15239. * @returns the name of this class
  15240. */
  15241. getClassName(): string;
  15242. /**
  15243. * Calls resetPose on the vrDisplay
  15244. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15245. */
  15246. resetToCurrentRotation(): void;
  15247. /**
  15248. * @hidden
  15249. * Updates the rig cameras (left and right eye)
  15250. */
  15251. _updateRigCameras(): void;
  15252. private _workingVector;
  15253. private _oneVector;
  15254. private _workingMatrix;
  15255. private updateCacheCalled;
  15256. private _correctPositionIfNotTrackPosition;
  15257. /**
  15258. * @hidden
  15259. * Updates the cached values of the camera
  15260. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15261. */
  15262. _updateCache(ignoreParentClass?: boolean): void;
  15263. /**
  15264. * @hidden
  15265. * Get current device position in babylon world
  15266. */
  15267. _computeDevicePosition(): void;
  15268. /**
  15269. * Updates the current device position and rotation in the babylon world
  15270. */
  15271. update(): void;
  15272. /**
  15273. * @hidden
  15274. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15275. * @returns an identity matrix
  15276. */
  15277. _getViewMatrix(): Matrix;
  15278. private _tmpMatrix;
  15279. /**
  15280. * This function is called by the two RIG cameras.
  15281. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15282. * @hidden
  15283. */
  15284. _getWebVRViewMatrix(): Matrix;
  15285. /** @hidden */
  15286. _getWebVRProjectionMatrix(): Matrix;
  15287. private _onGamepadConnectedObserver;
  15288. private _onGamepadDisconnectedObserver;
  15289. private _updateCacheWhenTrackingDisabledObserver;
  15290. /**
  15291. * Initializes the controllers and their meshes
  15292. */
  15293. initControllers(): void;
  15294. }
  15295. }
  15296. declare module BABYLON {
  15297. /**
  15298. * Size options for a post process
  15299. */
  15300. export type PostProcessOptions = {
  15301. width: number;
  15302. height: number;
  15303. };
  15304. /**
  15305. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15306. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15307. */
  15308. export class PostProcess {
  15309. /** Name of the PostProcess. */
  15310. name: string;
  15311. /**
  15312. * Gets or sets the unique id of the post process
  15313. */
  15314. uniqueId: number;
  15315. /**
  15316. * Width of the texture to apply the post process on
  15317. */
  15318. width: number;
  15319. /**
  15320. * Height of the texture to apply the post process on
  15321. */
  15322. height: number;
  15323. /**
  15324. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15325. * @hidden
  15326. */
  15327. _outputTexture: Nullable<InternalTexture>;
  15328. /**
  15329. * Sampling mode used by the shader
  15330. * See https://doc.babylonjs.com/classes/3.1/texture
  15331. */
  15332. renderTargetSamplingMode: number;
  15333. /**
  15334. * Clear color to use when screen clearing
  15335. */
  15336. clearColor: Color4;
  15337. /**
  15338. * If the buffer needs to be cleared before applying the post process. (default: true)
  15339. * Should be set to false if shader will overwrite all previous pixels.
  15340. */
  15341. autoClear: boolean;
  15342. /**
  15343. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15344. */
  15345. alphaMode: number;
  15346. /**
  15347. * Sets the setAlphaBlendConstants of the babylon engine
  15348. */
  15349. alphaConstants: Color4;
  15350. /**
  15351. * Animations to be used for the post processing
  15352. */
  15353. animations: Animation[];
  15354. /**
  15355. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15356. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15357. */
  15358. enablePixelPerfectMode: boolean;
  15359. /**
  15360. * Force the postprocess to be applied without taking in account viewport
  15361. */
  15362. forceFullscreenViewport: boolean;
  15363. /**
  15364. * List of inspectable custom properties (used by the Inspector)
  15365. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15366. */
  15367. inspectableCustomProperties: IInspectable[];
  15368. /**
  15369. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15370. *
  15371. * | Value | Type | Description |
  15372. * | ----- | ----------------------------------- | ----------- |
  15373. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15374. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15375. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15376. *
  15377. */
  15378. scaleMode: number;
  15379. /**
  15380. * Force textures to be a power of two (default: false)
  15381. */
  15382. alwaysForcePOT: boolean;
  15383. private _samples;
  15384. /**
  15385. * Number of sample textures (default: 1)
  15386. */
  15387. samples: number;
  15388. /**
  15389. * Modify the scale of the post process to be the same as the viewport (default: false)
  15390. */
  15391. adaptScaleToCurrentViewport: boolean;
  15392. private _camera;
  15393. private _scene;
  15394. private _engine;
  15395. private _options;
  15396. private _reusable;
  15397. private _textureType;
  15398. /**
  15399. * Smart array of input and output textures for the post process.
  15400. * @hidden
  15401. */
  15402. _textures: SmartArray<InternalTexture>;
  15403. /**
  15404. * The index in _textures that corresponds to the output texture.
  15405. * @hidden
  15406. */
  15407. _currentRenderTextureInd: number;
  15408. private _effect;
  15409. private _samplers;
  15410. private _fragmentUrl;
  15411. private _vertexUrl;
  15412. private _parameters;
  15413. private _scaleRatio;
  15414. protected _indexParameters: any;
  15415. private _shareOutputWithPostProcess;
  15416. private _texelSize;
  15417. private _forcedOutputTexture;
  15418. /**
  15419. * Returns the fragment url or shader name used in the post process.
  15420. * @returns the fragment url or name in the shader store.
  15421. */
  15422. getEffectName(): string;
  15423. /**
  15424. * An event triggered when the postprocess is activated.
  15425. */
  15426. onActivateObservable: Observable<Camera>;
  15427. private _onActivateObserver;
  15428. /**
  15429. * A function that is added to the onActivateObservable
  15430. */
  15431. onActivate: Nullable<(camera: Camera) => void>;
  15432. /**
  15433. * An event triggered when the postprocess changes its size.
  15434. */
  15435. onSizeChangedObservable: Observable<PostProcess>;
  15436. private _onSizeChangedObserver;
  15437. /**
  15438. * A function that is added to the onSizeChangedObservable
  15439. */
  15440. onSizeChanged: (postProcess: PostProcess) => void;
  15441. /**
  15442. * An event triggered when the postprocess applies its effect.
  15443. */
  15444. onApplyObservable: Observable<Effect>;
  15445. private _onApplyObserver;
  15446. /**
  15447. * A function that is added to the onApplyObservable
  15448. */
  15449. onApply: (effect: Effect) => void;
  15450. /**
  15451. * An event triggered before rendering the postprocess
  15452. */
  15453. onBeforeRenderObservable: Observable<Effect>;
  15454. private _onBeforeRenderObserver;
  15455. /**
  15456. * A function that is added to the onBeforeRenderObservable
  15457. */
  15458. onBeforeRender: (effect: Effect) => void;
  15459. /**
  15460. * An event triggered after rendering the postprocess
  15461. */
  15462. onAfterRenderObservable: Observable<Effect>;
  15463. private _onAfterRenderObserver;
  15464. /**
  15465. * A function that is added to the onAfterRenderObservable
  15466. */
  15467. onAfterRender: (efect: Effect) => void;
  15468. /**
  15469. * 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
  15470. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15471. */
  15472. inputTexture: InternalTexture;
  15473. /**
  15474. * Gets the camera which post process is applied to.
  15475. * @returns The camera the post process is applied to.
  15476. */
  15477. getCamera(): Camera;
  15478. /**
  15479. * Gets the texel size of the postprocess.
  15480. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15481. */
  15482. readonly texelSize: Vector2;
  15483. /**
  15484. * Creates a new instance PostProcess
  15485. * @param name The name of the PostProcess.
  15486. * @param fragmentUrl The url of the fragment shader to be used.
  15487. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15488. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15489. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15490. * @param camera The camera to apply the render pass to.
  15491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15492. * @param engine The engine which the post process will be applied. (default: current engine)
  15493. * @param reusable If the post process can be reused on the same frame. (default: false)
  15494. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15495. * @param textureType Type of textures used when performing the post process. (default: 0)
  15496. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15497. * @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
  15498. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15499. */
  15500. constructor(
  15501. /** Name of the PostProcess. */
  15502. 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);
  15503. /**
  15504. * Gets a string idenfifying the name of the class
  15505. * @returns "PostProcess" string
  15506. */
  15507. getClassName(): string;
  15508. /**
  15509. * Gets the engine which this post process belongs to.
  15510. * @returns The engine the post process was enabled with.
  15511. */
  15512. getEngine(): Engine;
  15513. /**
  15514. * The effect that is created when initializing the post process.
  15515. * @returns The created effect corresponding the the postprocess.
  15516. */
  15517. getEffect(): Effect;
  15518. /**
  15519. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15520. * @param postProcess The post process to share the output with.
  15521. * @returns This post process.
  15522. */
  15523. shareOutputWith(postProcess: PostProcess): PostProcess;
  15524. /**
  15525. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15526. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15527. */
  15528. useOwnOutput(): void;
  15529. /**
  15530. * Updates the effect with the current post process compile time values and recompiles the shader.
  15531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15534. * @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
  15535. * @param onCompiled Called when the shader has been compiled.
  15536. * @param onError Called if there is an error when compiling a shader.
  15537. */
  15538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15539. /**
  15540. * The post process is reusable if it can be used multiple times within one frame.
  15541. * @returns If the post process is reusable
  15542. */
  15543. isReusable(): boolean;
  15544. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15545. markTextureDirty(): void;
  15546. /**
  15547. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15548. * 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.
  15549. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15550. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15551. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15552. * @returns The target texture that was bound to be written to.
  15553. */
  15554. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15555. /**
  15556. * If the post process is supported.
  15557. */
  15558. readonly isSupported: boolean;
  15559. /**
  15560. * The aspect ratio of the output texture.
  15561. */
  15562. readonly aspectRatio: number;
  15563. /**
  15564. * Get a value indicating if the post-process is ready to be used
  15565. * @returns true if the post-process is ready (shader is compiled)
  15566. */
  15567. isReady(): boolean;
  15568. /**
  15569. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15570. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15571. */
  15572. apply(): Nullable<Effect>;
  15573. private _disposeTextures;
  15574. /**
  15575. * Disposes the post process.
  15576. * @param camera The camera to dispose the post process on.
  15577. */
  15578. dispose(camera?: Camera): void;
  15579. }
  15580. }
  15581. declare module BABYLON {
  15582. /** @hidden */
  15583. export var kernelBlurVaryingDeclaration: {
  15584. name: string;
  15585. shader: string;
  15586. };
  15587. }
  15588. declare module BABYLON {
  15589. /** @hidden */
  15590. export var kernelBlurFragment: {
  15591. name: string;
  15592. shader: string;
  15593. };
  15594. }
  15595. declare module BABYLON {
  15596. /** @hidden */
  15597. export var kernelBlurFragment2: {
  15598. name: string;
  15599. shader: string;
  15600. };
  15601. }
  15602. declare module BABYLON {
  15603. /** @hidden */
  15604. export var kernelBlurPixelShader: {
  15605. name: string;
  15606. shader: string;
  15607. };
  15608. }
  15609. declare module BABYLON {
  15610. /** @hidden */
  15611. export var kernelBlurVertex: {
  15612. name: string;
  15613. shader: string;
  15614. };
  15615. }
  15616. declare module BABYLON {
  15617. /** @hidden */
  15618. export var kernelBlurVertexShader: {
  15619. name: string;
  15620. shader: string;
  15621. };
  15622. }
  15623. declare module BABYLON {
  15624. /**
  15625. * The Blur Post Process which blurs an image based on a kernel and direction.
  15626. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15627. */
  15628. export class BlurPostProcess extends PostProcess {
  15629. /** The direction in which to blur the image. */
  15630. direction: Vector2;
  15631. private blockCompilation;
  15632. protected _kernel: number;
  15633. protected _idealKernel: number;
  15634. protected _packedFloat: boolean;
  15635. private _staticDefines;
  15636. /**
  15637. * Sets the length in pixels of the blur sample region
  15638. */
  15639. /**
  15640. * Gets the length in pixels of the blur sample region
  15641. */
  15642. kernel: number;
  15643. /**
  15644. * Sets wether or not the blur needs to unpack/repack floats
  15645. */
  15646. /**
  15647. * Gets wether or not the blur is unpacking/repacking floats
  15648. */
  15649. packedFloat: boolean;
  15650. /**
  15651. * Creates a new instance BlurPostProcess
  15652. * @param name The name of the effect.
  15653. * @param direction The direction in which to blur the image.
  15654. * @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.
  15655. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15656. * @param camera The camera to apply the render pass to.
  15657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15658. * @param engine The engine which the post process will be applied. (default: current engine)
  15659. * @param reusable If the post process can be reused on the same frame. (default: false)
  15660. * @param textureType Type of textures used when performing the post process. (default: 0)
  15661. * @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)
  15662. */
  15663. constructor(name: string,
  15664. /** The direction in which to blur the image. */
  15665. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15666. /**
  15667. * Updates the effect with the current post process compile time values and recompiles the shader.
  15668. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15669. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15670. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15671. * @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
  15672. * @param onCompiled Called when the shader has been compiled.
  15673. * @param onError Called if there is an error when compiling a shader.
  15674. */
  15675. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15676. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15677. /**
  15678. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15679. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15680. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15681. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15682. * The gaps between physical kernels are compensated for in the weighting of the samples
  15683. * @param idealKernel Ideal blur kernel.
  15684. * @return Nearest best kernel.
  15685. */
  15686. protected _nearestBestKernel(idealKernel: number): number;
  15687. /**
  15688. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15689. * @param x The point on the Gaussian distribution to sample.
  15690. * @return the value of the Gaussian function at x.
  15691. */
  15692. protected _gaussianWeight(x: number): number;
  15693. /**
  15694. * Generates a string that can be used as a floating point number in GLSL.
  15695. * @param x Value to print.
  15696. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15697. * @return GLSL float string.
  15698. */
  15699. protected _glslFloat(x: number, decimalFigures?: number): string;
  15700. }
  15701. }
  15702. declare module BABYLON {
  15703. /**
  15704. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15705. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15706. * You can then easily use it as a reflectionTexture on a flat surface.
  15707. * In case the surface is not a plane, please consider relying on reflection probes.
  15708. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15709. */
  15710. export class MirrorTexture extends RenderTargetTexture {
  15711. private scene;
  15712. /**
  15713. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15714. * 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.
  15715. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15716. */
  15717. mirrorPlane: Plane;
  15718. /**
  15719. * Define the blur ratio used to blur the reflection if needed.
  15720. */
  15721. blurRatio: number;
  15722. /**
  15723. * Define the adaptive blur kernel used to blur the reflection if needed.
  15724. * This will autocompute the closest best match for the `blurKernel`
  15725. */
  15726. adaptiveBlurKernel: number;
  15727. /**
  15728. * Define the blur kernel used to blur the reflection if needed.
  15729. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15730. */
  15731. blurKernel: number;
  15732. /**
  15733. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15734. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15735. */
  15736. blurKernelX: number;
  15737. /**
  15738. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15739. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15740. */
  15741. blurKernelY: number;
  15742. private _autoComputeBlurKernel;
  15743. protected _onRatioRescale(): void;
  15744. private _updateGammaSpace;
  15745. private _imageProcessingConfigChangeObserver;
  15746. private _transformMatrix;
  15747. private _mirrorMatrix;
  15748. private _savedViewMatrix;
  15749. private _blurX;
  15750. private _blurY;
  15751. private _adaptiveBlurKernel;
  15752. private _blurKernelX;
  15753. private _blurKernelY;
  15754. private _blurRatio;
  15755. /**
  15756. * Instantiates a Mirror Texture.
  15757. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15758. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15759. * You can then easily use it as a reflectionTexture on a flat surface.
  15760. * In case the surface is not a plane, please consider relying on reflection probes.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. * @param name
  15763. * @param size
  15764. * @param scene
  15765. * @param generateMipMaps
  15766. * @param type
  15767. * @param samplingMode
  15768. * @param generateDepthBuffer
  15769. */
  15770. constructor(name: string, size: number | {
  15771. width: number;
  15772. height: number;
  15773. } | {
  15774. ratio: number;
  15775. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15776. private _preparePostProcesses;
  15777. /**
  15778. * Clone the mirror texture.
  15779. * @returns the cloned texture
  15780. */
  15781. clone(): MirrorTexture;
  15782. /**
  15783. * Serialize the texture to a JSON representation you could use in Parse later on
  15784. * @returns the serialized JSON representation
  15785. */
  15786. serialize(): any;
  15787. /**
  15788. * Dispose the texture and release its associated resources.
  15789. */
  15790. dispose(): void;
  15791. }
  15792. }
  15793. declare module BABYLON {
  15794. /**
  15795. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15796. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15797. */
  15798. export class Texture extends BaseTexture {
  15799. /**
  15800. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15801. */
  15802. static SerializeBuffers: boolean;
  15803. /** @hidden */
  15804. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15805. /** @hidden */
  15806. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15807. /** @hidden */
  15808. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15809. /** nearest is mag = nearest and min = nearest and mip = linear */
  15810. static readonly NEAREST_SAMPLINGMODE: number;
  15811. /** nearest is mag = nearest and min = nearest and mip = linear */
  15812. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15813. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15814. static readonly BILINEAR_SAMPLINGMODE: number;
  15815. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15816. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15817. /** Trilinear is mag = linear and min = linear and mip = linear */
  15818. static readonly TRILINEAR_SAMPLINGMODE: number;
  15819. /** Trilinear is mag = linear and min = linear and mip = linear */
  15820. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15821. /** mag = nearest and min = nearest and mip = nearest */
  15822. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15823. /** mag = nearest and min = linear and mip = nearest */
  15824. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15825. /** mag = nearest and min = linear and mip = linear */
  15826. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15827. /** mag = nearest and min = linear and mip = none */
  15828. static readonly NEAREST_LINEAR: number;
  15829. /** mag = nearest and min = nearest and mip = none */
  15830. static readonly NEAREST_NEAREST: number;
  15831. /** mag = linear and min = nearest and mip = nearest */
  15832. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15833. /** mag = linear and min = nearest and mip = linear */
  15834. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15835. /** mag = linear and min = linear and mip = none */
  15836. static readonly LINEAR_LINEAR: number;
  15837. /** mag = linear and min = nearest and mip = none */
  15838. static readonly LINEAR_NEAREST: number;
  15839. /** Explicit coordinates mode */
  15840. static readonly EXPLICIT_MODE: number;
  15841. /** Spherical coordinates mode */
  15842. static readonly SPHERICAL_MODE: number;
  15843. /** Planar coordinates mode */
  15844. static readonly PLANAR_MODE: number;
  15845. /** Cubic coordinates mode */
  15846. static readonly CUBIC_MODE: number;
  15847. /** Projection coordinates mode */
  15848. static readonly PROJECTION_MODE: number;
  15849. /** Inverse Cubic coordinates mode */
  15850. static readonly SKYBOX_MODE: number;
  15851. /** Inverse Cubic coordinates mode */
  15852. static readonly INVCUBIC_MODE: number;
  15853. /** Equirectangular coordinates mode */
  15854. static readonly EQUIRECTANGULAR_MODE: number;
  15855. /** Equirectangular Fixed coordinates mode */
  15856. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15857. /** Equirectangular Fixed Mirrored coordinates mode */
  15858. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15859. /** Texture is not repeating outside of 0..1 UVs */
  15860. static readonly CLAMP_ADDRESSMODE: number;
  15861. /** Texture is repeating outside of 0..1 UVs */
  15862. static readonly WRAP_ADDRESSMODE: number;
  15863. /** Texture is repeating and mirrored */
  15864. static readonly MIRROR_ADDRESSMODE: number;
  15865. /**
  15866. * 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
  15867. */
  15868. static UseSerializedUrlIfAny: boolean;
  15869. /**
  15870. * Define the url of the texture.
  15871. */
  15872. url: Nullable<string>;
  15873. /**
  15874. * Define an offset on the texture to offset the u coordinates of the UVs
  15875. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15876. */
  15877. uOffset: number;
  15878. /**
  15879. * Define an offset on the texture to offset the v coordinates of the UVs
  15880. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15881. */
  15882. vOffset: number;
  15883. /**
  15884. * Define an offset on the texture to scale the u coordinates of the UVs
  15885. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15886. */
  15887. uScale: number;
  15888. /**
  15889. * Define an offset on the texture to scale the v coordinates of the UVs
  15890. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15891. */
  15892. vScale: number;
  15893. /**
  15894. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15895. * @see http://doc.babylonjs.com/how_to/more_materials
  15896. */
  15897. uAng: number;
  15898. /**
  15899. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15900. * @see http://doc.babylonjs.com/how_to/more_materials
  15901. */
  15902. vAng: number;
  15903. /**
  15904. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15905. * @see http://doc.babylonjs.com/how_to/more_materials
  15906. */
  15907. wAng: number;
  15908. /**
  15909. * Defines the center of rotation (U)
  15910. */
  15911. uRotationCenter: number;
  15912. /**
  15913. * Defines the center of rotation (V)
  15914. */
  15915. vRotationCenter: number;
  15916. /**
  15917. * Defines the center of rotation (W)
  15918. */
  15919. wRotationCenter: number;
  15920. /**
  15921. * Are mip maps generated for this texture or not.
  15922. */
  15923. readonly noMipmap: boolean;
  15924. /**
  15925. * List of inspectable custom properties (used by the Inspector)
  15926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15927. */
  15928. inspectableCustomProperties: Nullable<IInspectable[]>;
  15929. private _noMipmap;
  15930. /** @hidden */
  15931. _invertY: boolean;
  15932. private _rowGenerationMatrix;
  15933. private _cachedTextureMatrix;
  15934. private _projectionModeMatrix;
  15935. private _t0;
  15936. private _t1;
  15937. private _t2;
  15938. private _cachedUOffset;
  15939. private _cachedVOffset;
  15940. private _cachedUScale;
  15941. private _cachedVScale;
  15942. private _cachedUAng;
  15943. private _cachedVAng;
  15944. private _cachedWAng;
  15945. private _cachedProjectionMatrixId;
  15946. private _cachedCoordinatesMode;
  15947. /** @hidden */
  15948. protected _initialSamplingMode: number;
  15949. /** @hidden */
  15950. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15951. private _deleteBuffer;
  15952. protected _format: Nullable<number>;
  15953. private _delayedOnLoad;
  15954. private _delayedOnError;
  15955. private _mimeType?;
  15956. /**
  15957. * Observable triggered once the texture has been loaded.
  15958. */
  15959. onLoadObservable: Observable<Texture>;
  15960. protected _isBlocking: boolean;
  15961. /**
  15962. * Is the texture preventing material to render while loading.
  15963. * If false, a default texture will be used instead of the loading one during the preparation step.
  15964. */
  15965. isBlocking: boolean;
  15966. /**
  15967. * Get the current sampling mode associated with the texture.
  15968. */
  15969. readonly samplingMode: number;
  15970. /**
  15971. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15972. */
  15973. readonly invertY: boolean;
  15974. /**
  15975. * Instantiates a new texture.
  15976. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15977. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15978. * @param url defines the url of the picture to load as a texture
  15979. * @param scene defines the scene or engine the texture will belong to
  15980. * @param noMipmap defines if the texture will require mip maps or not
  15981. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15982. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15983. * @param onLoad defines a callback triggered when the texture has been loaded
  15984. * @param onError defines a callback triggered when an error occurred during the loading session
  15985. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15986. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15987. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15988. * @param mimeType defines an optional mime type information
  15989. */
  15990. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15991. /**
  15992. * Update the url (and optional buffer) of this texture if url was null during construction.
  15993. * @param url the url of the texture
  15994. * @param buffer the buffer of the texture (defaults to null)
  15995. * @param onLoad callback called when the texture is loaded (defaults to null)
  15996. */
  15997. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15998. /**
  15999. * Finish the loading sequence of a texture flagged as delayed load.
  16000. * @hidden
  16001. */
  16002. delayLoad(): void;
  16003. private _prepareRowForTextureGeneration;
  16004. /**
  16005. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16006. * @returns the transform matrix of the texture.
  16007. */
  16008. getTextureMatrix(): Matrix;
  16009. /**
  16010. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16011. * @returns The reflection texture transform
  16012. */
  16013. getReflectionTextureMatrix(): Matrix;
  16014. /**
  16015. * Clones the texture.
  16016. * @returns the cloned texture
  16017. */
  16018. clone(): Texture;
  16019. /**
  16020. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16021. * @returns The JSON representation of the texture
  16022. */
  16023. serialize(): any;
  16024. /**
  16025. * Get the current class name of the texture useful for serialization or dynamic coding.
  16026. * @returns "Texture"
  16027. */
  16028. getClassName(): string;
  16029. /**
  16030. * Dispose the texture and release its associated resources.
  16031. */
  16032. dispose(): void;
  16033. /**
  16034. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16035. * @param parsedTexture Define the JSON representation of the texture
  16036. * @param scene Define the scene the parsed texture should be instantiated in
  16037. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16038. * @returns The parsed texture if successful
  16039. */
  16040. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16041. /**
  16042. * Creates a texture from its base 64 representation.
  16043. * @param data Define the base64 payload without the data: prefix
  16044. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16045. * @param scene Define the scene the texture should belong to
  16046. * @param noMipmap Forces the texture to not create mip map information if true
  16047. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16048. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16049. * @param onLoad define a callback triggered when the texture has been loaded
  16050. * @param onError define a callback triggered when an error occurred during the loading session
  16051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16052. * @returns the created texture
  16053. */
  16054. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16055. /**
  16056. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16057. * @param data Define the base64 payload without the data: prefix
  16058. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16059. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16060. * @param scene Define the scene the texture should belong to
  16061. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16062. * @param noMipmap Forces the texture to not create mip map information if true
  16063. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16064. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16065. * @param onLoad define a callback triggered when the texture has been loaded
  16066. * @param onError define a callback triggered when an error occurred during the loading session
  16067. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16068. * @returns the created texture
  16069. */
  16070. 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;
  16071. }
  16072. }
  16073. declare module BABYLON {
  16074. /**
  16075. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16076. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16077. */
  16078. export class PostProcessManager {
  16079. private _scene;
  16080. private _indexBuffer;
  16081. private _vertexBuffers;
  16082. /**
  16083. * Creates a new instance PostProcess
  16084. * @param scene The scene that the post process is associated with.
  16085. */
  16086. constructor(scene: Scene);
  16087. private _prepareBuffers;
  16088. private _buildIndexBuffer;
  16089. /**
  16090. * Rebuilds the vertex buffers of the manager.
  16091. * @hidden
  16092. */
  16093. _rebuild(): void;
  16094. /**
  16095. * Prepares a frame to be run through a post process.
  16096. * @param sourceTexture The input texture to the post procesess. (default: null)
  16097. * @param postProcesses An array of post processes to be run. (default: null)
  16098. * @returns True if the post processes were able to be run.
  16099. * @hidden
  16100. */
  16101. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16102. /**
  16103. * Manually render a set of post processes to a texture.
  16104. * @param postProcesses An array of post processes to be run.
  16105. * @param targetTexture The target texture to render to.
  16106. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16107. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16108. * @param lodLevel defines which lod of the texture to render to
  16109. */
  16110. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16111. /**
  16112. * Finalize the result of the output of the postprocesses.
  16113. * @param doNotPresent If true the result will not be displayed to the screen.
  16114. * @param targetTexture The target texture to render to.
  16115. * @param faceIndex The index of the face to bind the target texture to.
  16116. * @param postProcesses The array of post processes to render.
  16117. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16118. * @hidden
  16119. */
  16120. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16121. /**
  16122. * Disposes of the post process manager.
  16123. */
  16124. dispose(): void;
  16125. }
  16126. }
  16127. declare module BABYLON {
  16128. /** Interface used by value gradients (color, factor, ...) */
  16129. export interface IValueGradient {
  16130. /**
  16131. * Gets or sets the gradient value (between 0 and 1)
  16132. */
  16133. gradient: number;
  16134. }
  16135. /** Class used to store color4 gradient */
  16136. export class ColorGradient implements IValueGradient {
  16137. /**
  16138. * Gets or sets the gradient value (between 0 and 1)
  16139. */
  16140. gradient: number;
  16141. /**
  16142. * Gets or sets first associated color
  16143. */
  16144. color1: Color4;
  16145. /**
  16146. * Gets or sets second associated color
  16147. */
  16148. color2?: Color4;
  16149. /**
  16150. * Will get a color picked randomly between color1 and color2.
  16151. * If color2 is undefined then color1 will be used
  16152. * @param result defines the target Color4 to store the result in
  16153. */
  16154. getColorToRef(result: Color4): void;
  16155. }
  16156. /** Class used to store color 3 gradient */
  16157. export class Color3Gradient implements IValueGradient {
  16158. /**
  16159. * Gets or sets the gradient value (between 0 and 1)
  16160. */
  16161. gradient: number;
  16162. /**
  16163. * Gets or sets the associated color
  16164. */
  16165. color: Color3;
  16166. }
  16167. /** Class used to store factor gradient */
  16168. export class FactorGradient implements IValueGradient {
  16169. /**
  16170. * Gets or sets the gradient value (between 0 and 1)
  16171. */
  16172. gradient: number;
  16173. /**
  16174. * Gets or sets first associated factor
  16175. */
  16176. factor1: number;
  16177. /**
  16178. * Gets or sets second associated factor
  16179. */
  16180. factor2?: number;
  16181. /**
  16182. * Will get a number picked randomly between factor1 and factor2.
  16183. * If factor2 is undefined then factor1 will be used
  16184. * @returns the picked number
  16185. */
  16186. getFactor(): number;
  16187. }
  16188. /**
  16189. * Helper used to simplify some generic gradient tasks
  16190. */
  16191. export class GradientHelper {
  16192. /**
  16193. * Gets the current gradient from an array of IValueGradient
  16194. * @param ratio defines the current ratio to get
  16195. * @param gradients defines the array of IValueGradient
  16196. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16197. */
  16198. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16199. }
  16200. }
  16201. declare module BABYLON {
  16202. interface ThinEngine {
  16203. /**
  16204. * Creates a dynamic texture
  16205. * @param width defines the width of the texture
  16206. * @param height defines the height of the texture
  16207. * @param generateMipMaps defines if the engine should generate the mip levels
  16208. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16209. * @returns the dynamic texture inside an InternalTexture
  16210. */
  16211. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16212. /**
  16213. * Update the content of a dynamic texture
  16214. * @param texture defines the texture to update
  16215. * @param canvas defines the canvas containing the source
  16216. * @param invertY defines if data must be stored with Y axis inverted
  16217. * @param premulAlpha defines if alpha is stored as premultiplied
  16218. * @param format defines the format of the data
  16219. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16220. */
  16221. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16222. }
  16223. }
  16224. declare module BABYLON {
  16225. /**
  16226. * Helper class used to generate a canvas to manipulate images
  16227. */
  16228. export class CanvasGenerator {
  16229. /**
  16230. * Create a new canvas (or offscreen canvas depending on the context)
  16231. * @param width defines the expected width
  16232. * @param height defines the expected height
  16233. * @return a new canvas or offscreen canvas
  16234. */
  16235. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16236. }
  16237. }
  16238. declare module BABYLON {
  16239. /**
  16240. * A class extending Texture allowing drawing on a texture
  16241. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16242. */
  16243. export class DynamicTexture extends Texture {
  16244. private _generateMipMaps;
  16245. private _canvas;
  16246. private _context;
  16247. private _engine;
  16248. /**
  16249. * Creates a DynamicTexture
  16250. * @param name defines the name of the texture
  16251. * @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
  16252. * @param scene defines the scene where you want the texture
  16253. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16254. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16255. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16256. */
  16257. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16258. /**
  16259. * Get the current class name of the texture useful for serialization or dynamic coding.
  16260. * @returns "DynamicTexture"
  16261. */
  16262. getClassName(): string;
  16263. /**
  16264. * Gets the current state of canRescale
  16265. */
  16266. readonly canRescale: boolean;
  16267. private _recreate;
  16268. /**
  16269. * Scales the texture
  16270. * @param ratio the scale factor to apply to both width and height
  16271. */
  16272. scale(ratio: number): void;
  16273. /**
  16274. * Resizes the texture
  16275. * @param width the new width
  16276. * @param height the new height
  16277. */
  16278. scaleTo(width: number, height: number): void;
  16279. /**
  16280. * Gets the context of the canvas used by the texture
  16281. * @returns the canvas context of the dynamic texture
  16282. */
  16283. getContext(): CanvasRenderingContext2D;
  16284. /**
  16285. * Clears the texture
  16286. */
  16287. clear(): void;
  16288. /**
  16289. * Updates the texture
  16290. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16291. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16292. */
  16293. update(invertY?: boolean, premulAlpha?: boolean): void;
  16294. /**
  16295. * Draws text onto the texture
  16296. * @param text defines the text to be drawn
  16297. * @param x defines the placement of the text from the left
  16298. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16299. * @param font defines the font to be used with font-style, font-size, font-name
  16300. * @param color defines the color used for the text
  16301. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16302. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16303. * @param update defines whether texture is immediately update (default is true)
  16304. */
  16305. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16306. /**
  16307. * Clones the texture
  16308. * @returns the clone of the texture.
  16309. */
  16310. clone(): DynamicTexture;
  16311. /**
  16312. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16313. * @returns a serialized dynamic texture object
  16314. */
  16315. serialize(): any;
  16316. /** @hidden */
  16317. _rebuild(): void;
  16318. }
  16319. }
  16320. declare module BABYLON {
  16321. interface AbstractScene {
  16322. /**
  16323. * The list of procedural textures added to the scene
  16324. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16325. */
  16326. proceduralTextures: Array<ProceduralTexture>;
  16327. }
  16328. /**
  16329. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16330. * in a given scene.
  16331. */
  16332. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16333. /**
  16334. * The component name helpfull to identify the component in the list of scene components.
  16335. */
  16336. readonly name: string;
  16337. /**
  16338. * The scene the component belongs to.
  16339. */
  16340. scene: Scene;
  16341. /**
  16342. * Creates a new instance of the component for the given scene
  16343. * @param scene Defines the scene to register the component in
  16344. */
  16345. constructor(scene: Scene);
  16346. /**
  16347. * Registers the component in a given scene
  16348. */
  16349. register(): void;
  16350. /**
  16351. * Rebuilds the elements related to this component in case of
  16352. * context lost for instance.
  16353. */
  16354. rebuild(): void;
  16355. /**
  16356. * Disposes the component and the associated ressources.
  16357. */
  16358. dispose(): void;
  16359. private _beforeClear;
  16360. }
  16361. }
  16362. declare module BABYLON {
  16363. interface ThinEngine {
  16364. /**
  16365. * Creates a new render target cube texture
  16366. * @param size defines the size of the texture
  16367. * @param options defines the options used to create the texture
  16368. * @returns a new render target cube texture stored in an InternalTexture
  16369. */
  16370. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16371. }
  16372. }
  16373. declare module BABYLON {
  16374. /** @hidden */
  16375. export var proceduralVertexShader: {
  16376. name: string;
  16377. shader: string;
  16378. };
  16379. }
  16380. declare module BABYLON {
  16381. /**
  16382. * 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.
  16383. * This is the base class of any Procedural texture and contains most of the shareable code.
  16384. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16385. */
  16386. export class ProceduralTexture extends Texture {
  16387. isCube: boolean;
  16388. /**
  16389. * Define if the texture is enabled or not (disabled texture will not render)
  16390. */
  16391. isEnabled: boolean;
  16392. /**
  16393. * Define if the texture must be cleared before rendering (default is true)
  16394. */
  16395. autoClear: boolean;
  16396. /**
  16397. * Callback called when the texture is generated
  16398. */
  16399. onGenerated: () => void;
  16400. /**
  16401. * Event raised when the texture is generated
  16402. */
  16403. onGeneratedObservable: Observable<ProceduralTexture>;
  16404. /** @hidden */
  16405. _generateMipMaps: boolean;
  16406. /** @hidden **/
  16407. _effect: Effect;
  16408. /** @hidden */
  16409. _textures: {
  16410. [key: string]: Texture;
  16411. };
  16412. private _size;
  16413. private _currentRefreshId;
  16414. private _refreshRate;
  16415. private _vertexBuffers;
  16416. private _indexBuffer;
  16417. private _uniforms;
  16418. private _samplers;
  16419. private _fragment;
  16420. private _floats;
  16421. private _ints;
  16422. private _floatsArrays;
  16423. private _colors3;
  16424. private _colors4;
  16425. private _vectors2;
  16426. private _vectors3;
  16427. private _matrices;
  16428. private _fallbackTexture;
  16429. private _fallbackTextureUsed;
  16430. private _engine;
  16431. private _cachedDefines;
  16432. private _contentUpdateId;
  16433. private _contentData;
  16434. /**
  16435. * Instantiates a new procedural texture.
  16436. * 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.
  16437. * This is the base class of any Procedural texture and contains most of the shareable code.
  16438. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16439. * @param name Define the name of the texture
  16440. * @param size Define the size of the texture to create
  16441. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16442. * @param scene Define the scene the texture belongs to
  16443. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16444. * @param generateMipMaps Define if the texture should creates mip maps or not
  16445. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16446. */
  16447. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16448. /**
  16449. * The effect that is created when initializing the post process.
  16450. * @returns The created effect corresponding the the postprocess.
  16451. */
  16452. getEffect(): Effect;
  16453. /**
  16454. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16455. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16456. */
  16457. getContent(): Nullable<ArrayBufferView>;
  16458. private _createIndexBuffer;
  16459. /** @hidden */
  16460. _rebuild(): void;
  16461. /**
  16462. * Resets the texture in order to recreate its associated resources.
  16463. * This can be called in case of context loss
  16464. */
  16465. reset(): void;
  16466. protected _getDefines(): string;
  16467. /**
  16468. * Is the texture ready to be used ? (rendered at least once)
  16469. * @returns true if ready, otherwise, false.
  16470. */
  16471. isReady(): boolean;
  16472. /**
  16473. * Resets the refresh counter of the texture and start bak from scratch.
  16474. * Could be useful to regenerate the texture if it is setup to render only once.
  16475. */
  16476. resetRefreshCounter(): void;
  16477. /**
  16478. * Set the fragment shader to use in order to render the texture.
  16479. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16480. */
  16481. setFragment(fragment: any): void;
  16482. /**
  16483. * Define the refresh rate of the texture or the rendering frequency.
  16484. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16485. */
  16486. refreshRate: number;
  16487. /** @hidden */
  16488. _shouldRender(): boolean;
  16489. /**
  16490. * Get the size the texture is rendering at.
  16491. * @returns the size (texture is always squared)
  16492. */
  16493. getRenderSize(): number;
  16494. /**
  16495. * Resize the texture to new value.
  16496. * @param size Define the new size the texture should have
  16497. * @param generateMipMaps Define whether the new texture should create mip maps
  16498. */
  16499. resize(size: number, generateMipMaps: boolean): void;
  16500. private _checkUniform;
  16501. /**
  16502. * Set a texture in the shader program used to render.
  16503. * @param name Define the name of the uniform samplers as defined in the shader
  16504. * @param texture Define the texture to bind to this sampler
  16505. * @return the texture itself allowing "fluent" like uniform updates
  16506. */
  16507. setTexture(name: string, texture: Texture): ProceduralTexture;
  16508. /**
  16509. * Set a float in the shader.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the texture itself allowing "fluent" like uniform updates
  16513. */
  16514. setFloat(name: string, value: number): ProceduralTexture;
  16515. /**
  16516. * Set a int in the shader.
  16517. * @param name Define the name of the uniform as defined in the shader
  16518. * @param value Define the value to give to the uniform
  16519. * @return the texture itself allowing "fluent" like uniform updates
  16520. */
  16521. setInt(name: string, value: number): ProceduralTexture;
  16522. /**
  16523. * Set an array of floats in the shader.
  16524. * @param name Define the name of the uniform as defined in the shader
  16525. * @param value Define the value to give to the uniform
  16526. * @return the texture itself allowing "fluent" like uniform updates
  16527. */
  16528. setFloats(name: string, value: number[]): ProceduralTexture;
  16529. /**
  16530. * Set a vec3 in the shader from a Color3.
  16531. * @param name Define the name of the uniform as defined in the shader
  16532. * @param value Define the value to give to the uniform
  16533. * @return the texture itself allowing "fluent" like uniform updates
  16534. */
  16535. setColor3(name: string, value: Color3): ProceduralTexture;
  16536. /**
  16537. * Set a vec4 in the shader from a Color4.
  16538. * @param name Define the name of the uniform as defined in the shader
  16539. * @param value Define the value to give to the uniform
  16540. * @return the texture itself allowing "fluent" like uniform updates
  16541. */
  16542. setColor4(name: string, value: Color4): ProceduralTexture;
  16543. /**
  16544. * Set a vec2 in the shader from a Vector2.
  16545. * @param name Define the name of the uniform as defined in the shader
  16546. * @param value Define the value to give to the uniform
  16547. * @return the texture itself allowing "fluent" like uniform updates
  16548. */
  16549. setVector2(name: string, value: Vector2): ProceduralTexture;
  16550. /**
  16551. * Set a vec3 in the shader from a Vector3.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the texture itself allowing "fluent" like uniform updates
  16555. */
  16556. setVector3(name: string, value: Vector3): ProceduralTexture;
  16557. /**
  16558. * Set a mat4 in the shader from a MAtrix.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the texture itself allowing "fluent" like uniform updates
  16562. */
  16563. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16564. /**
  16565. * Render the texture to its associated render target.
  16566. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16567. */
  16568. render(useCameraPostProcess?: boolean): void;
  16569. /**
  16570. * Clone the texture.
  16571. * @returns the cloned texture
  16572. */
  16573. clone(): ProceduralTexture;
  16574. /**
  16575. * Dispose the texture and release its asoociated resources.
  16576. */
  16577. dispose(): void;
  16578. }
  16579. }
  16580. declare module BABYLON {
  16581. /**
  16582. * This represents the base class for particle system in Babylon.
  16583. * 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.
  16584. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16585. * @example https://doc.babylonjs.com/babylon101/particles
  16586. */
  16587. export class BaseParticleSystem {
  16588. /**
  16589. * Source color is added to the destination color without alpha affecting the result
  16590. */
  16591. static BLENDMODE_ONEONE: number;
  16592. /**
  16593. * Blend current color and particle color using particle’s alpha
  16594. */
  16595. static BLENDMODE_STANDARD: number;
  16596. /**
  16597. * Add current color and particle color multiplied by particle’s alpha
  16598. */
  16599. static BLENDMODE_ADD: number;
  16600. /**
  16601. * Multiply current color with particle color
  16602. */
  16603. static BLENDMODE_MULTIPLY: number;
  16604. /**
  16605. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16606. */
  16607. static BLENDMODE_MULTIPLYADD: number;
  16608. /**
  16609. * List of animations used by the particle system.
  16610. */
  16611. animations: Animation[];
  16612. /**
  16613. * The id of the Particle system.
  16614. */
  16615. id: string;
  16616. /**
  16617. * The friendly name of the Particle system.
  16618. */
  16619. name: string;
  16620. /**
  16621. * The rendering group used by the Particle system to chose when to render.
  16622. */
  16623. renderingGroupId: number;
  16624. /**
  16625. * The emitter represents the Mesh or position we are attaching the particle system to.
  16626. */
  16627. emitter: Nullable<AbstractMesh | Vector3>;
  16628. /**
  16629. * The maximum number of particles to emit per frame
  16630. */
  16631. emitRate: number;
  16632. /**
  16633. * If you want to launch only a few particles at once, that can be done, as well.
  16634. */
  16635. manualEmitCount: number;
  16636. /**
  16637. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16638. */
  16639. updateSpeed: number;
  16640. /**
  16641. * The amount of time the particle system is running (depends of the overall update speed).
  16642. */
  16643. targetStopDuration: number;
  16644. /**
  16645. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16646. */
  16647. disposeOnStop: boolean;
  16648. /**
  16649. * Minimum power of emitting particles.
  16650. */
  16651. minEmitPower: number;
  16652. /**
  16653. * Maximum power of emitting particles.
  16654. */
  16655. maxEmitPower: number;
  16656. /**
  16657. * Minimum life time of emitting particles.
  16658. */
  16659. minLifeTime: number;
  16660. /**
  16661. * Maximum life time of emitting particles.
  16662. */
  16663. maxLifeTime: number;
  16664. /**
  16665. * Minimum Size of emitting particles.
  16666. */
  16667. minSize: number;
  16668. /**
  16669. * Maximum Size of emitting particles.
  16670. */
  16671. maxSize: number;
  16672. /**
  16673. * Minimum scale of emitting particles on X axis.
  16674. */
  16675. minScaleX: number;
  16676. /**
  16677. * Maximum scale of emitting particles on X axis.
  16678. */
  16679. maxScaleX: number;
  16680. /**
  16681. * Minimum scale of emitting particles on Y axis.
  16682. */
  16683. minScaleY: number;
  16684. /**
  16685. * Maximum scale of emitting particles on Y axis.
  16686. */
  16687. maxScaleY: number;
  16688. /**
  16689. * Gets or sets the minimal initial rotation in radians.
  16690. */
  16691. minInitialRotation: number;
  16692. /**
  16693. * Gets or sets the maximal initial rotation in radians.
  16694. */
  16695. maxInitialRotation: number;
  16696. /**
  16697. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16698. */
  16699. minAngularSpeed: number;
  16700. /**
  16701. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16702. */
  16703. maxAngularSpeed: number;
  16704. /**
  16705. * The texture used to render each particle. (this can be a spritesheet)
  16706. */
  16707. particleTexture: Nullable<Texture>;
  16708. /**
  16709. * The layer mask we are rendering the particles through.
  16710. */
  16711. layerMask: number;
  16712. /**
  16713. * This can help using your own shader to render the particle system.
  16714. * The according effect will be created
  16715. */
  16716. customShader: any;
  16717. /**
  16718. * By default particle system starts as soon as they are created. This prevents the
  16719. * automatic start to happen and let you decide when to start emitting particles.
  16720. */
  16721. preventAutoStart: boolean;
  16722. private _noiseTexture;
  16723. /**
  16724. * Gets or sets a texture used to add random noise to particle positions
  16725. */
  16726. noiseTexture: Nullable<ProceduralTexture>;
  16727. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16728. noiseStrength: Vector3;
  16729. /**
  16730. * Callback triggered when the particle animation is ending.
  16731. */
  16732. onAnimationEnd: Nullable<() => void>;
  16733. /**
  16734. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16735. */
  16736. blendMode: number;
  16737. /**
  16738. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16739. * to override the particles.
  16740. */
  16741. forceDepthWrite: boolean;
  16742. /** 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 */
  16743. preWarmCycles: number;
  16744. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16745. preWarmStepOffset: number;
  16746. /**
  16747. * 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)
  16748. */
  16749. spriteCellChangeSpeed: number;
  16750. /**
  16751. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16752. */
  16753. startSpriteCellID: number;
  16754. /**
  16755. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16756. */
  16757. endSpriteCellID: number;
  16758. /**
  16759. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16760. */
  16761. spriteCellWidth: number;
  16762. /**
  16763. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16764. */
  16765. spriteCellHeight: number;
  16766. /**
  16767. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16768. */
  16769. spriteRandomStartCell: boolean;
  16770. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16771. translationPivot: Vector2;
  16772. /** @hidden */
  16773. protected _isAnimationSheetEnabled: boolean;
  16774. /**
  16775. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16776. */
  16777. beginAnimationOnStart: boolean;
  16778. /**
  16779. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16780. */
  16781. beginAnimationFrom: number;
  16782. /**
  16783. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16784. */
  16785. beginAnimationTo: number;
  16786. /**
  16787. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16788. */
  16789. beginAnimationLoop: boolean;
  16790. /**
  16791. * Gets or sets a world offset applied to all particles
  16792. */
  16793. worldOffset: Vector3;
  16794. /**
  16795. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16796. */
  16797. isAnimationSheetEnabled: boolean;
  16798. /**
  16799. * Get hosting scene
  16800. * @returns the scene
  16801. */
  16802. getScene(): Scene;
  16803. /**
  16804. * You can use gravity if you want to give an orientation to your particles.
  16805. */
  16806. gravity: Vector3;
  16807. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16808. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16809. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16810. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16811. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16812. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16813. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16814. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16815. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16816. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16817. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16818. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16819. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16820. /**
  16821. * Defines the delay in milliseconds before starting the system (0 by default)
  16822. */
  16823. startDelay: number;
  16824. /**
  16825. * Gets the current list of drag gradients.
  16826. * You must use addDragGradient and removeDragGradient to udpate this list
  16827. * @returns the list of drag gradients
  16828. */
  16829. getDragGradients(): Nullable<Array<FactorGradient>>;
  16830. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16831. limitVelocityDamping: number;
  16832. /**
  16833. * Gets the current list of limit velocity gradients.
  16834. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16835. * @returns the list of limit velocity gradients
  16836. */
  16837. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16838. /**
  16839. * Gets the current list of color gradients.
  16840. * You must use addColorGradient and removeColorGradient to udpate this list
  16841. * @returns the list of color gradients
  16842. */
  16843. getColorGradients(): Nullable<Array<ColorGradient>>;
  16844. /**
  16845. * Gets the current list of size gradients.
  16846. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16847. * @returns the list of size gradients
  16848. */
  16849. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16850. /**
  16851. * Gets the current list of color remap gradients.
  16852. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16853. * @returns the list of color remap gradients
  16854. */
  16855. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16856. /**
  16857. * Gets the current list of alpha remap gradients.
  16858. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16859. * @returns the list of alpha remap gradients
  16860. */
  16861. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16862. /**
  16863. * Gets the current list of life time gradients.
  16864. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16865. * @returns the list of life time gradients
  16866. */
  16867. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16868. /**
  16869. * Gets the current list of angular speed gradients.
  16870. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16871. * @returns the list of angular speed gradients
  16872. */
  16873. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16874. /**
  16875. * Gets the current list of velocity gradients.
  16876. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16877. * @returns the list of velocity gradients
  16878. */
  16879. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16880. /**
  16881. * Gets the current list of start size gradients.
  16882. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16883. * @returns the list of start size gradients
  16884. */
  16885. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of emit rate gradients.
  16888. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16889. * @returns the list of emit rate gradients
  16890. */
  16891. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16894. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16895. */
  16896. direction1: Vector3;
  16897. /**
  16898. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16899. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16900. */
  16901. direction2: Vector3;
  16902. /**
  16903. * 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.
  16904. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16905. */
  16906. minEmitBox: Vector3;
  16907. /**
  16908. * 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.
  16909. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16910. */
  16911. maxEmitBox: Vector3;
  16912. /**
  16913. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16914. */
  16915. color1: Color4;
  16916. /**
  16917. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16918. */
  16919. color2: Color4;
  16920. /**
  16921. * Color the particle will have at the end of its lifetime
  16922. */
  16923. colorDead: Color4;
  16924. /**
  16925. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16926. */
  16927. textureMask: Color4;
  16928. /**
  16929. * The particle emitter type defines the emitter used by the particle system.
  16930. * It can be for example box, sphere, or cone...
  16931. */
  16932. particleEmitterType: IParticleEmitterType;
  16933. /** @hidden */
  16934. _isSubEmitter: boolean;
  16935. /**
  16936. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16937. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16938. */
  16939. billboardMode: number;
  16940. protected _isBillboardBased: boolean;
  16941. /**
  16942. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16943. */
  16944. isBillboardBased: boolean;
  16945. /**
  16946. * The scene the particle system belongs to.
  16947. */
  16948. protected _scene: Scene;
  16949. /**
  16950. * Local cache of defines for image processing.
  16951. */
  16952. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16953. /**
  16954. * Default configuration related to image processing available in the standard Material.
  16955. */
  16956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16957. /**
  16958. * Gets the image processing configuration used either in this material.
  16959. */
  16960. /**
  16961. * Sets the Default image processing configuration used either in the this material.
  16962. *
  16963. * If sets to null, the scene one is in use.
  16964. */
  16965. imageProcessingConfiguration: ImageProcessingConfiguration;
  16966. /**
  16967. * Attaches a new image processing configuration to the Standard Material.
  16968. * @param configuration
  16969. */
  16970. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16971. /** @hidden */
  16972. protected _reset(): void;
  16973. /** @hidden */
  16974. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16975. /**
  16976. * Instantiates a particle system.
  16977. * 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.
  16978. * @param name The name of the particle system
  16979. */
  16980. constructor(name: string);
  16981. /**
  16982. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16983. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16984. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16985. * @returns the emitter
  16986. */
  16987. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16988. /**
  16989. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16990. * @param radius The radius of the hemisphere to emit from
  16991. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16992. * @returns the emitter
  16993. */
  16994. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16995. /**
  16996. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16997. * @param radius The radius of the sphere to emit from
  16998. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16999. * @returns the emitter
  17000. */
  17001. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17002. /**
  17003. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17004. * @param radius The radius of the sphere to emit from
  17005. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17006. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17007. * @returns the emitter
  17008. */
  17009. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17010. /**
  17011. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17012. * @param radius The radius of the emission cylinder
  17013. * @param height The height of the emission cylinder
  17014. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17015. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17016. * @returns the emitter
  17017. */
  17018. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17019. /**
  17020. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17021. * @param radius The radius of the cylinder to emit from
  17022. * @param height The height of the emission cylinder
  17023. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17026. * @returns the emitter
  17027. */
  17028. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17029. /**
  17030. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17031. * @param radius The radius of the cone to emit from
  17032. * @param angle The base angle of the cone
  17033. * @returns the emitter
  17034. */
  17035. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17036. /**
  17037. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17038. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17039. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17040. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17041. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17042. * @returns the emitter
  17043. */
  17044. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17045. }
  17046. }
  17047. declare module BABYLON {
  17048. /**
  17049. * Type of sub emitter
  17050. */
  17051. export enum SubEmitterType {
  17052. /**
  17053. * Attached to the particle over it's lifetime
  17054. */
  17055. ATTACHED = 0,
  17056. /**
  17057. * Created when the particle dies
  17058. */
  17059. END = 1
  17060. }
  17061. /**
  17062. * Sub emitter class used to emit particles from an existing particle
  17063. */
  17064. export class SubEmitter {
  17065. /**
  17066. * the particle system to be used by the sub emitter
  17067. */
  17068. particleSystem: ParticleSystem;
  17069. /**
  17070. * Type of the submitter (Default: END)
  17071. */
  17072. type: SubEmitterType;
  17073. /**
  17074. * 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)
  17075. * Note: This only is supported when using an emitter of type Mesh
  17076. */
  17077. inheritDirection: boolean;
  17078. /**
  17079. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17080. */
  17081. inheritedVelocityAmount: number;
  17082. /**
  17083. * Creates a sub emitter
  17084. * @param particleSystem the particle system to be used by the sub emitter
  17085. */
  17086. constructor(
  17087. /**
  17088. * the particle system to be used by the sub emitter
  17089. */
  17090. particleSystem: ParticleSystem);
  17091. /**
  17092. * Clones the sub emitter
  17093. * @returns the cloned sub emitter
  17094. */
  17095. clone(): SubEmitter;
  17096. /**
  17097. * Serialize current object to a JSON object
  17098. * @returns the serialized object
  17099. */
  17100. serialize(): any;
  17101. /** @hidden */
  17102. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17103. /**
  17104. * Creates a new SubEmitter from a serialized JSON version
  17105. * @param serializationObject defines the JSON object to read from
  17106. * @param scene defines the hosting scene
  17107. * @param rootUrl defines the rootUrl for data loading
  17108. * @returns a new SubEmitter
  17109. */
  17110. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17111. /** Release associated resources */
  17112. dispose(): void;
  17113. }
  17114. }
  17115. declare module BABYLON {
  17116. /** @hidden */
  17117. export var clipPlaneFragmentDeclaration: {
  17118. name: string;
  17119. shader: string;
  17120. };
  17121. }
  17122. declare module BABYLON {
  17123. /** @hidden */
  17124. export var imageProcessingDeclaration: {
  17125. name: string;
  17126. shader: string;
  17127. };
  17128. }
  17129. declare module BABYLON {
  17130. /** @hidden */
  17131. export var imageProcessingFunctions: {
  17132. name: string;
  17133. shader: string;
  17134. };
  17135. }
  17136. declare module BABYLON {
  17137. /** @hidden */
  17138. export var clipPlaneFragment: {
  17139. name: string;
  17140. shader: string;
  17141. };
  17142. }
  17143. declare module BABYLON {
  17144. /** @hidden */
  17145. export var particlesPixelShader: {
  17146. name: string;
  17147. shader: string;
  17148. };
  17149. }
  17150. declare module BABYLON {
  17151. /** @hidden */
  17152. export var clipPlaneVertexDeclaration: {
  17153. name: string;
  17154. shader: string;
  17155. };
  17156. }
  17157. declare module BABYLON {
  17158. /** @hidden */
  17159. export var clipPlaneVertex: {
  17160. name: string;
  17161. shader: string;
  17162. };
  17163. }
  17164. declare module BABYLON {
  17165. /** @hidden */
  17166. export var particlesVertexShader: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module BABYLON {
  17172. /**
  17173. * This represents a particle system in Babylon.
  17174. * 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.
  17175. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17176. * @example https://doc.babylonjs.com/babylon101/particles
  17177. */
  17178. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17179. /**
  17180. * Billboard mode will only apply to Y axis
  17181. */
  17182. static readonly BILLBOARDMODE_Y: number;
  17183. /**
  17184. * Billboard mode will apply to all axes
  17185. */
  17186. static readonly BILLBOARDMODE_ALL: number;
  17187. /**
  17188. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17189. */
  17190. static readonly BILLBOARDMODE_STRETCHED: number;
  17191. /**
  17192. * This function can be defined to provide custom update for active particles.
  17193. * This function will be called instead of regular update (age, position, color, etc.).
  17194. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17195. */
  17196. updateFunction: (particles: Particle[]) => void;
  17197. private _emitterWorldMatrix;
  17198. /**
  17199. * This function can be defined to specify initial direction for every new particle.
  17200. * It by default use the emitterType defined function
  17201. */
  17202. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17203. /**
  17204. * This function can be defined to specify initial position for every new particle.
  17205. * It by default use the emitterType defined function
  17206. */
  17207. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17208. /**
  17209. * @hidden
  17210. */
  17211. _inheritedVelocityOffset: Vector3;
  17212. /**
  17213. * An event triggered when the system is disposed
  17214. */
  17215. onDisposeObservable: Observable<ParticleSystem>;
  17216. private _onDisposeObserver;
  17217. /**
  17218. * Sets a callback that will be triggered when the system is disposed
  17219. */
  17220. onDispose: () => void;
  17221. private _particles;
  17222. private _epsilon;
  17223. private _capacity;
  17224. private _stockParticles;
  17225. private _newPartsExcess;
  17226. private _vertexData;
  17227. private _vertexBuffer;
  17228. private _vertexBuffers;
  17229. private _spriteBuffer;
  17230. private _indexBuffer;
  17231. private _effect;
  17232. private _customEffect;
  17233. private _cachedDefines;
  17234. private _scaledColorStep;
  17235. private _colorDiff;
  17236. private _scaledDirection;
  17237. private _scaledGravity;
  17238. private _currentRenderId;
  17239. private _alive;
  17240. private _useInstancing;
  17241. private _started;
  17242. private _stopped;
  17243. private _actualFrame;
  17244. private _scaledUpdateSpeed;
  17245. private _vertexBufferSize;
  17246. /** @hidden */
  17247. _currentEmitRateGradient: Nullable<FactorGradient>;
  17248. /** @hidden */
  17249. _currentEmitRate1: number;
  17250. /** @hidden */
  17251. _currentEmitRate2: number;
  17252. /** @hidden */
  17253. _currentStartSizeGradient: Nullable<FactorGradient>;
  17254. /** @hidden */
  17255. _currentStartSize1: number;
  17256. /** @hidden */
  17257. _currentStartSize2: number;
  17258. private readonly _rawTextureWidth;
  17259. private _rampGradientsTexture;
  17260. private _useRampGradients;
  17261. /** Gets or sets a boolean indicating that ramp gradients must be used
  17262. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17263. */
  17264. useRampGradients: boolean;
  17265. /**
  17266. * 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.
  17267. * 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: [])
  17268. */
  17269. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17270. private _subEmitters;
  17271. /**
  17272. * @hidden
  17273. * If the particle systems emitter should be disposed when the particle system is disposed
  17274. */
  17275. _disposeEmitterOnDispose: boolean;
  17276. /**
  17277. * The current active Sub-systems, this property is used by the root particle system only.
  17278. */
  17279. activeSubSystems: Array<ParticleSystem>;
  17280. private _rootParticleSystem;
  17281. /**
  17282. * Gets the current list of active particles
  17283. */
  17284. readonly particles: Particle[];
  17285. /**
  17286. * Returns the string "ParticleSystem"
  17287. * @returns a string containing the class name
  17288. */
  17289. getClassName(): string;
  17290. /**
  17291. * Instantiates a particle system.
  17292. * 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.
  17293. * @param name The name of the particle system
  17294. * @param capacity The max number of particles alive at the same time
  17295. * @param scene The scene the particle system belongs to
  17296. * @param customEffect a custom effect used to change the way particles are rendered by default
  17297. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17298. * @param epsilon Offset used to render the particles
  17299. */
  17300. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17301. private _addFactorGradient;
  17302. private _removeFactorGradient;
  17303. /**
  17304. * Adds a new life time gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param factor defines the life time factor to affect to the specified gradient
  17307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17308. * @returns the current particle system
  17309. */
  17310. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific life time gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new size gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param factor defines the size factor to affect to the specified gradient
  17321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17322. * @returns the current particle system
  17323. */
  17324. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific size gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeSizeGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new color remap gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param min defines the color remap minimal range
  17335. * @param max defines the color remap maximal range
  17336. * @returns the current particle system
  17337. */
  17338. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific color remap gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeColorRemapGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new alpha remap gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param min defines the alpha remap minimal range
  17349. * @param max defines the alpha remap maximal range
  17350. * @returns the current particle system
  17351. */
  17352. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific alpha remap gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new angular speed gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the angular speed to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific angular speed gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new velocity gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the velocity to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific velocity gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeVelocityGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new limit velocity gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the limit velocity value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific limit velocity gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new drag gradient
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the drag value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific drag gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeDragGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the emit rate value to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific emit rate gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeEmitRateGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17431. * @param gradient defines the gradient to use (between 0 and 1)
  17432. * @param factor defines the start size value to affect to the specified gradient
  17433. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17434. * @returns the current particle system
  17435. */
  17436. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17437. /**
  17438. * Remove a specific start size gradient
  17439. * @param gradient defines the gradient to remove
  17440. * @returns the current particle system
  17441. */
  17442. removeStartSizeGradient(gradient: number): IParticleSystem;
  17443. private _createRampGradientTexture;
  17444. /**
  17445. * Gets the current list of ramp gradients.
  17446. * You must use addRampGradient and removeRampGradient to udpate this list
  17447. * @returns the list of ramp gradients
  17448. */
  17449. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17450. /**
  17451. * Adds a new ramp gradient used to remap particle colors
  17452. * @param gradient defines the gradient to use (between 0 and 1)
  17453. * @param color defines the color to affect to the specified gradient
  17454. * @returns the current particle system
  17455. */
  17456. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17457. /**
  17458. * Remove a specific ramp gradient
  17459. * @param gradient defines the gradient to remove
  17460. * @returns the current particle system
  17461. */
  17462. removeRampGradient(gradient: number): ParticleSystem;
  17463. /**
  17464. * Adds a new color gradient
  17465. * @param gradient defines the gradient to use (between 0 and 1)
  17466. * @param color1 defines the color to affect to the specified gradient
  17467. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17468. * @returns this particle system
  17469. */
  17470. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17471. /**
  17472. * Remove a specific color gradient
  17473. * @param gradient defines the gradient to remove
  17474. * @returns this particle system
  17475. */
  17476. removeColorGradient(gradient: number): IParticleSystem;
  17477. private _fetchR;
  17478. protected _reset(): void;
  17479. private _resetEffect;
  17480. private _createVertexBuffers;
  17481. private _createIndexBuffer;
  17482. /**
  17483. * Gets the maximum number of particles active at the same time.
  17484. * @returns The max number of active particles.
  17485. */
  17486. getCapacity(): number;
  17487. /**
  17488. * Gets whether there are still active particles in the system.
  17489. * @returns True if it is alive, otherwise false.
  17490. */
  17491. isAlive(): boolean;
  17492. /**
  17493. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17494. * @returns True if it has been started, otherwise false.
  17495. */
  17496. isStarted(): boolean;
  17497. private _prepareSubEmitterInternalArray;
  17498. /**
  17499. * Starts the particle system and begins to emit
  17500. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17501. */
  17502. start(delay?: number): void;
  17503. /**
  17504. * Stops the particle system.
  17505. * @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.
  17506. */
  17507. stop(stopSubEmitters?: boolean): void;
  17508. /**
  17509. * Remove all active particles
  17510. */
  17511. reset(): void;
  17512. /**
  17513. * @hidden (for internal use only)
  17514. */
  17515. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17516. /**
  17517. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17518. * Its lifetime will start back at 0.
  17519. */
  17520. recycleParticle: (particle: Particle) => void;
  17521. private _stopSubEmitters;
  17522. private _createParticle;
  17523. private _removeFromRoot;
  17524. private _emitFromParticle;
  17525. private _update;
  17526. /** @hidden */
  17527. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17528. /** @hidden */
  17529. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17530. /** @hidden */
  17531. private _getEffect;
  17532. /**
  17533. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17534. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17535. */
  17536. animate(preWarmOnly?: boolean): void;
  17537. private _appendParticleVertices;
  17538. /**
  17539. * Rebuilds the particle system.
  17540. */
  17541. rebuild(): void;
  17542. /**
  17543. * Is this system ready to be used/rendered
  17544. * @return true if the system is ready
  17545. */
  17546. isReady(): boolean;
  17547. private _render;
  17548. /**
  17549. * Renders the particle system in its current state.
  17550. * @returns the current number of particles
  17551. */
  17552. render(): number;
  17553. /**
  17554. * Disposes the particle system and free the associated resources
  17555. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17556. */
  17557. dispose(disposeTexture?: boolean): void;
  17558. /**
  17559. * Clones the particle system.
  17560. * @param name The name of the cloned object
  17561. * @param newEmitter The new emitter to use
  17562. * @returns the cloned particle system
  17563. */
  17564. clone(name: string, newEmitter: any): ParticleSystem;
  17565. /**
  17566. * Serializes the particle system to a JSON object.
  17567. * @returns the JSON object
  17568. */
  17569. serialize(): any;
  17570. /** @hidden */
  17571. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17572. /** @hidden */
  17573. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17574. /**
  17575. * Parses a JSON object to create a particle system.
  17576. * @param parsedParticleSystem The JSON object to parse
  17577. * @param scene The scene to create the particle system in
  17578. * @param rootUrl The root url to use to load external dependencies like texture
  17579. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17580. * @returns the Parsed particle system
  17581. */
  17582. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17583. }
  17584. }
  17585. declare module BABYLON {
  17586. /**
  17587. * A particle represents one of the element emitted by a particle system.
  17588. * This is mainly define by its coordinates, direction, velocity and age.
  17589. */
  17590. export class Particle {
  17591. /**
  17592. * The particle system the particle belongs to.
  17593. */
  17594. particleSystem: ParticleSystem;
  17595. private static _Count;
  17596. /**
  17597. * Unique ID of the particle
  17598. */
  17599. id: number;
  17600. /**
  17601. * The world position of the particle in the scene.
  17602. */
  17603. position: Vector3;
  17604. /**
  17605. * The world direction of the particle in the scene.
  17606. */
  17607. direction: Vector3;
  17608. /**
  17609. * The color of the particle.
  17610. */
  17611. color: Color4;
  17612. /**
  17613. * The color change of the particle per step.
  17614. */
  17615. colorStep: Color4;
  17616. /**
  17617. * Defines how long will the life of the particle be.
  17618. */
  17619. lifeTime: number;
  17620. /**
  17621. * The current age of the particle.
  17622. */
  17623. age: number;
  17624. /**
  17625. * The current size of the particle.
  17626. */
  17627. size: number;
  17628. /**
  17629. * The current scale of the particle.
  17630. */
  17631. scale: Vector2;
  17632. /**
  17633. * The current angle of the particle.
  17634. */
  17635. angle: number;
  17636. /**
  17637. * Defines how fast is the angle changing.
  17638. */
  17639. angularSpeed: number;
  17640. /**
  17641. * Defines the cell index used by the particle to be rendered from a sprite.
  17642. */
  17643. cellIndex: number;
  17644. /**
  17645. * The information required to support color remapping
  17646. */
  17647. remapData: Vector4;
  17648. /** @hidden */
  17649. _randomCellOffset?: number;
  17650. /** @hidden */
  17651. _initialDirection: Nullable<Vector3>;
  17652. /** @hidden */
  17653. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17654. /** @hidden */
  17655. _initialStartSpriteCellID: number;
  17656. /** @hidden */
  17657. _initialEndSpriteCellID: number;
  17658. /** @hidden */
  17659. _currentColorGradient: Nullable<ColorGradient>;
  17660. /** @hidden */
  17661. _currentColor1: Color4;
  17662. /** @hidden */
  17663. _currentColor2: Color4;
  17664. /** @hidden */
  17665. _currentSizeGradient: Nullable<FactorGradient>;
  17666. /** @hidden */
  17667. _currentSize1: number;
  17668. /** @hidden */
  17669. _currentSize2: number;
  17670. /** @hidden */
  17671. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17672. /** @hidden */
  17673. _currentAngularSpeed1: number;
  17674. /** @hidden */
  17675. _currentAngularSpeed2: number;
  17676. /** @hidden */
  17677. _currentVelocityGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentVelocity1: number;
  17680. /** @hidden */
  17681. _currentVelocity2: number;
  17682. /** @hidden */
  17683. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentLimitVelocity1: number;
  17686. /** @hidden */
  17687. _currentLimitVelocity2: number;
  17688. /** @hidden */
  17689. _currentDragGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentDrag1: number;
  17692. /** @hidden */
  17693. _currentDrag2: number;
  17694. /** @hidden */
  17695. _randomNoiseCoordinates1: Vector3;
  17696. /** @hidden */
  17697. _randomNoiseCoordinates2: Vector3;
  17698. /**
  17699. * Creates a new instance Particle
  17700. * @param particleSystem the particle system the particle belongs to
  17701. */
  17702. constructor(
  17703. /**
  17704. * The particle system the particle belongs to.
  17705. */
  17706. particleSystem: ParticleSystem);
  17707. private updateCellInfoFromSystem;
  17708. /**
  17709. * Defines how the sprite cell index is updated for the particle
  17710. */
  17711. updateCellIndex(): void;
  17712. /** @hidden */
  17713. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17714. /** @hidden */
  17715. _inheritParticleInfoToSubEmitters(): void;
  17716. /** @hidden */
  17717. _reset(): void;
  17718. /**
  17719. * Copy the properties of particle to another one.
  17720. * @param other the particle to copy the information to.
  17721. */
  17722. copyTo(other: Particle): void;
  17723. }
  17724. }
  17725. declare module BABYLON {
  17726. /**
  17727. * Particle emitter represents a volume emitting particles.
  17728. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17729. */
  17730. export interface IParticleEmitterType {
  17731. /**
  17732. * Called by the particle System when the direction is computed for the created particle.
  17733. * @param worldMatrix is the world matrix of the particle system
  17734. * @param directionToUpdate is the direction vector to update with the result
  17735. * @param particle is the particle we are computed the direction for
  17736. */
  17737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17738. /**
  17739. * Called by the particle System when the position is computed for the created particle.
  17740. * @param worldMatrix is the world matrix of the particle system
  17741. * @param positionToUpdate is the position vector to update with the result
  17742. * @param particle is the particle we are computed the position for
  17743. */
  17744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17745. /**
  17746. * Clones the current emitter and returns a copy of it
  17747. * @returns the new emitter
  17748. */
  17749. clone(): IParticleEmitterType;
  17750. /**
  17751. * Called by the GPUParticleSystem to setup the update shader
  17752. * @param effect defines the update shader
  17753. */
  17754. applyToShader(effect: Effect): void;
  17755. /**
  17756. * Returns a string to use to update the GPU particles update shader
  17757. * @returns the effect defines string
  17758. */
  17759. getEffectDefines(): string;
  17760. /**
  17761. * Returns a string representing the class name
  17762. * @returns a string containing the class name
  17763. */
  17764. getClassName(): string;
  17765. /**
  17766. * Serializes the particle system to a JSON object.
  17767. * @returns the JSON object
  17768. */
  17769. serialize(): any;
  17770. /**
  17771. * Parse properties from a JSON object
  17772. * @param serializationObject defines the JSON object
  17773. */
  17774. parse(serializationObject: any): void;
  17775. }
  17776. }
  17777. declare module BABYLON {
  17778. /**
  17779. * Particle emitter emitting particles from the inside of a box.
  17780. * It emits the particles randomly between 2 given directions.
  17781. */
  17782. export class BoxParticleEmitter implements IParticleEmitterType {
  17783. /**
  17784. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17785. */
  17786. direction1: Vector3;
  17787. /**
  17788. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17789. */
  17790. direction2: Vector3;
  17791. /**
  17792. * 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.
  17793. */
  17794. minEmitBox: Vector3;
  17795. /**
  17796. * 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.
  17797. */
  17798. maxEmitBox: Vector3;
  17799. /**
  17800. * Creates a new instance BoxParticleEmitter
  17801. */
  17802. constructor();
  17803. /**
  17804. * Called by the particle System when the direction is computed for the created particle.
  17805. * @param worldMatrix is the world matrix of the particle system
  17806. * @param directionToUpdate is the direction vector to update with the result
  17807. * @param particle is the particle we are computed the direction for
  17808. */
  17809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17810. /**
  17811. * Called by the particle System when the position is computed for the created particle.
  17812. * @param worldMatrix is the world matrix of the particle system
  17813. * @param positionToUpdate is the position vector to update with the result
  17814. * @param particle is the particle we are computed the position for
  17815. */
  17816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17817. /**
  17818. * Clones the current emitter and returns a copy of it
  17819. * @returns the new emitter
  17820. */
  17821. clone(): BoxParticleEmitter;
  17822. /**
  17823. * Called by the GPUParticleSystem to setup the update shader
  17824. * @param effect defines the update shader
  17825. */
  17826. applyToShader(effect: Effect): void;
  17827. /**
  17828. * Returns a string to use to update the GPU particles update shader
  17829. * @returns a string containng the defines string
  17830. */
  17831. getEffectDefines(): string;
  17832. /**
  17833. * Returns the string "BoxParticleEmitter"
  17834. * @returns a string containing the class name
  17835. */
  17836. getClassName(): string;
  17837. /**
  17838. * Serializes the particle system to a JSON object.
  17839. * @returns the JSON object
  17840. */
  17841. serialize(): any;
  17842. /**
  17843. * Parse properties from a JSON object
  17844. * @param serializationObject defines the JSON object
  17845. */
  17846. parse(serializationObject: any): void;
  17847. }
  17848. }
  17849. declare module BABYLON {
  17850. /**
  17851. * Particle emitter emitting particles from the inside of a cone.
  17852. * It emits the particles alongside the cone volume from the base to the particle.
  17853. * The emission direction might be randomized.
  17854. */
  17855. export class ConeParticleEmitter implements IParticleEmitterType {
  17856. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17857. directionRandomizer: number;
  17858. private _radius;
  17859. private _angle;
  17860. private _height;
  17861. /**
  17862. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17863. */
  17864. radiusRange: number;
  17865. /**
  17866. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17867. */
  17868. heightRange: number;
  17869. /**
  17870. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17871. */
  17872. emitFromSpawnPointOnly: boolean;
  17873. /**
  17874. * Gets or sets the radius of the emission cone
  17875. */
  17876. radius: number;
  17877. /**
  17878. * Gets or sets the angle of the emission cone
  17879. */
  17880. angle: number;
  17881. private _buildHeight;
  17882. /**
  17883. * Creates a new instance ConeParticleEmitter
  17884. * @param radius the radius of the emission cone (1 by default)
  17885. * @param angle the cone base angle (PI by default)
  17886. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17887. */
  17888. constructor(radius?: number, angle?: number,
  17889. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17890. directionRandomizer?: number);
  17891. /**
  17892. * Called by the particle System when the direction is computed for the created particle.
  17893. * @param worldMatrix is the world matrix of the particle system
  17894. * @param directionToUpdate is the direction vector to update with the result
  17895. * @param particle is the particle we are computed the direction for
  17896. */
  17897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17898. /**
  17899. * Called by the particle System when the position is computed for the created particle.
  17900. * @param worldMatrix is the world matrix of the particle system
  17901. * @param positionToUpdate is the position vector to update with the result
  17902. * @param particle is the particle we are computed the position for
  17903. */
  17904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17905. /**
  17906. * Clones the current emitter and returns a copy of it
  17907. * @returns the new emitter
  17908. */
  17909. clone(): ConeParticleEmitter;
  17910. /**
  17911. * Called by the GPUParticleSystem to setup the update shader
  17912. * @param effect defines the update shader
  17913. */
  17914. applyToShader(effect: Effect): void;
  17915. /**
  17916. * Returns a string to use to update the GPU particles update shader
  17917. * @returns a string containng the defines string
  17918. */
  17919. getEffectDefines(): string;
  17920. /**
  17921. * Returns the string "ConeParticleEmitter"
  17922. * @returns a string containing the class name
  17923. */
  17924. getClassName(): string;
  17925. /**
  17926. * Serializes the particle system to a JSON object.
  17927. * @returns the JSON object
  17928. */
  17929. serialize(): any;
  17930. /**
  17931. * Parse properties from a JSON object
  17932. * @param serializationObject defines the JSON object
  17933. */
  17934. parse(serializationObject: any): void;
  17935. }
  17936. }
  17937. declare module BABYLON {
  17938. /**
  17939. * Particle emitter emitting particles from the inside of a cylinder.
  17940. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17941. */
  17942. export class CylinderParticleEmitter implements IParticleEmitterType {
  17943. /**
  17944. * The radius of the emission cylinder.
  17945. */
  17946. radius: number;
  17947. /**
  17948. * The height of the emission cylinder.
  17949. */
  17950. height: number;
  17951. /**
  17952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17953. */
  17954. radiusRange: number;
  17955. /**
  17956. * How much to randomize the particle direction [0-1].
  17957. */
  17958. directionRandomizer: number;
  17959. /**
  17960. * Creates a new instance CylinderParticleEmitter
  17961. * @param radius the radius of the emission cylinder (1 by default)
  17962. * @param height the height of the emission cylinder (1 by default)
  17963. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17964. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17965. */
  17966. constructor(
  17967. /**
  17968. * The radius of the emission cylinder.
  17969. */
  17970. radius?: number,
  17971. /**
  17972. * The height of the emission cylinder.
  17973. */
  17974. height?: number,
  17975. /**
  17976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17977. */
  17978. radiusRange?: number,
  17979. /**
  17980. * How much to randomize the particle direction [0-1].
  17981. */
  17982. directionRandomizer?: number);
  17983. /**
  17984. * Called by the particle System when the direction is computed for the created particle.
  17985. * @param worldMatrix is the world matrix of the particle system
  17986. * @param directionToUpdate is the direction vector to update with the result
  17987. * @param particle is the particle we are computed the direction for
  17988. */
  17989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17990. /**
  17991. * Called by the particle System when the position is computed for the created particle.
  17992. * @param worldMatrix is the world matrix of the particle system
  17993. * @param positionToUpdate is the position vector to update with the result
  17994. * @param particle is the particle we are computed the position for
  17995. */
  17996. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17997. /**
  17998. * Clones the current emitter and returns a copy of it
  17999. * @returns the new emitter
  18000. */
  18001. clone(): CylinderParticleEmitter;
  18002. /**
  18003. * Called by the GPUParticleSystem to setup the update shader
  18004. * @param effect defines the update shader
  18005. */
  18006. applyToShader(effect: Effect): void;
  18007. /**
  18008. * Returns a string to use to update the GPU particles update shader
  18009. * @returns a string containng the defines string
  18010. */
  18011. getEffectDefines(): string;
  18012. /**
  18013. * Returns the string "CylinderParticleEmitter"
  18014. * @returns a string containing the class name
  18015. */
  18016. getClassName(): string;
  18017. /**
  18018. * Serializes the particle system to a JSON object.
  18019. * @returns the JSON object
  18020. */
  18021. serialize(): any;
  18022. /**
  18023. * Parse properties from a JSON object
  18024. * @param serializationObject defines the JSON object
  18025. */
  18026. parse(serializationObject: any): void;
  18027. }
  18028. /**
  18029. * Particle emitter emitting particles from the inside of a cylinder.
  18030. * It emits the particles randomly between two vectors.
  18031. */
  18032. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18033. /**
  18034. * The min limit of the emission direction.
  18035. */
  18036. direction1: Vector3;
  18037. /**
  18038. * The max limit of the emission direction.
  18039. */
  18040. direction2: Vector3;
  18041. /**
  18042. * Creates a new instance CylinderDirectedParticleEmitter
  18043. * @param radius the radius of the emission cylinder (1 by default)
  18044. * @param height the height of the emission cylinder (1 by default)
  18045. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18046. * @param direction1 the min limit of the emission direction (up vector by default)
  18047. * @param direction2 the max limit of the emission direction (up vector by default)
  18048. */
  18049. constructor(radius?: number, height?: number, radiusRange?: number,
  18050. /**
  18051. * The min limit of the emission direction.
  18052. */
  18053. direction1?: Vector3,
  18054. /**
  18055. * The max limit of the emission direction.
  18056. */
  18057. direction2?: Vector3);
  18058. /**
  18059. * Called by the particle System when the direction is computed for the created particle.
  18060. * @param worldMatrix is the world matrix of the particle system
  18061. * @param directionToUpdate is the direction vector to update with the result
  18062. * @param particle is the particle we are computed the direction for
  18063. */
  18064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18065. /**
  18066. * Clones the current emitter and returns a copy of it
  18067. * @returns the new emitter
  18068. */
  18069. clone(): CylinderDirectedParticleEmitter;
  18070. /**
  18071. * Called by the GPUParticleSystem to setup the update shader
  18072. * @param effect defines the update shader
  18073. */
  18074. applyToShader(effect: Effect): void;
  18075. /**
  18076. * Returns a string to use to update the GPU particles update shader
  18077. * @returns a string containng the defines string
  18078. */
  18079. getEffectDefines(): string;
  18080. /**
  18081. * Returns the string "CylinderDirectedParticleEmitter"
  18082. * @returns a string containing the class name
  18083. */
  18084. getClassName(): string;
  18085. /**
  18086. * Serializes the particle system to a JSON object.
  18087. * @returns the JSON object
  18088. */
  18089. serialize(): any;
  18090. /**
  18091. * Parse properties from a JSON object
  18092. * @param serializationObject defines the JSON object
  18093. */
  18094. parse(serializationObject: any): void;
  18095. }
  18096. }
  18097. declare module BABYLON {
  18098. /**
  18099. * Particle emitter emitting particles from the inside of a hemisphere.
  18100. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18101. */
  18102. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18103. /**
  18104. * The radius of the emission hemisphere.
  18105. */
  18106. radius: number;
  18107. /**
  18108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18109. */
  18110. radiusRange: number;
  18111. /**
  18112. * How much to randomize the particle direction [0-1].
  18113. */
  18114. directionRandomizer: number;
  18115. /**
  18116. * Creates a new instance HemisphericParticleEmitter
  18117. * @param radius the radius of the emission hemisphere (1 by default)
  18118. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18119. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18120. */
  18121. constructor(
  18122. /**
  18123. * The radius of the emission hemisphere.
  18124. */
  18125. radius?: number,
  18126. /**
  18127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18128. */
  18129. radiusRange?: number,
  18130. /**
  18131. * How much to randomize the particle direction [0-1].
  18132. */
  18133. directionRandomizer?: number);
  18134. /**
  18135. * Called by the particle System when the direction is computed for the created particle.
  18136. * @param worldMatrix is the world matrix of the particle system
  18137. * @param directionToUpdate is the direction vector to update with the result
  18138. * @param particle is the particle we are computed the direction for
  18139. */
  18140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18141. /**
  18142. * Called by the particle System when the position is computed for the created particle.
  18143. * @param worldMatrix is the world matrix of the particle system
  18144. * @param positionToUpdate is the position vector to update with the result
  18145. * @param particle is the particle we are computed the position for
  18146. */
  18147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18148. /**
  18149. * Clones the current emitter and returns a copy of it
  18150. * @returns the new emitter
  18151. */
  18152. clone(): HemisphericParticleEmitter;
  18153. /**
  18154. * Called by the GPUParticleSystem to setup the update shader
  18155. * @param effect defines the update shader
  18156. */
  18157. applyToShader(effect: Effect): void;
  18158. /**
  18159. * Returns a string to use to update the GPU particles update shader
  18160. * @returns a string containng the defines string
  18161. */
  18162. getEffectDefines(): string;
  18163. /**
  18164. * Returns the string "HemisphericParticleEmitter"
  18165. * @returns a string containing the class name
  18166. */
  18167. getClassName(): string;
  18168. /**
  18169. * Serializes the particle system to a JSON object.
  18170. * @returns the JSON object
  18171. */
  18172. serialize(): any;
  18173. /**
  18174. * Parse properties from a JSON object
  18175. * @param serializationObject defines the JSON object
  18176. */
  18177. parse(serializationObject: any): void;
  18178. }
  18179. }
  18180. declare module BABYLON {
  18181. /**
  18182. * Particle emitter emitting particles from a point.
  18183. * It emits the particles randomly between 2 given directions.
  18184. */
  18185. export class PointParticleEmitter implements IParticleEmitterType {
  18186. /**
  18187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18188. */
  18189. direction1: Vector3;
  18190. /**
  18191. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18192. */
  18193. direction2: Vector3;
  18194. /**
  18195. * Creates a new instance PointParticleEmitter
  18196. */
  18197. constructor();
  18198. /**
  18199. * Called by the particle System when the direction is computed for the created particle.
  18200. * @param worldMatrix is the world matrix of the particle system
  18201. * @param directionToUpdate is the direction vector to update with the result
  18202. * @param particle is the particle we are computed the direction for
  18203. */
  18204. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18205. /**
  18206. * Called by the particle System when the position is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param positionToUpdate is the position vector to update with the result
  18209. * @param particle is the particle we are computed the position for
  18210. */
  18211. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Clones the current emitter and returns a copy of it
  18214. * @returns the new emitter
  18215. */
  18216. clone(): PointParticleEmitter;
  18217. /**
  18218. * Called by the GPUParticleSystem to setup the update shader
  18219. * @param effect defines the update shader
  18220. */
  18221. applyToShader(effect: Effect): void;
  18222. /**
  18223. * Returns a string to use to update the GPU particles update shader
  18224. * @returns a string containng the defines string
  18225. */
  18226. getEffectDefines(): string;
  18227. /**
  18228. * Returns the string "PointParticleEmitter"
  18229. * @returns a string containing the class name
  18230. */
  18231. getClassName(): string;
  18232. /**
  18233. * Serializes the particle system to a JSON object.
  18234. * @returns the JSON object
  18235. */
  18236. serialize(): any;
  18237. /**
  18238. * Parse properties from a JSON object
  18239. * @param serializationObject defines the JSON object
  18240. */
  18241. parse(serializationObject: any): void;
  18242. }
  18243. }
  18244. declare module BABYLON {
  18245. /**
  18246. * Particle emitter emitting particles from the inside of a sphere.
  18247. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18248. */
  18249. export class SphereParticleEmitter implements IParticleEmitterType {
  18250. /**
  18251. * The radius of the emission sphere.
  18252. */
  18253. radius: number;
  18254. /**
  18255. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * How much to randomize the particle direction [0-1].
  18260. */
  18261. directionRandomizer: number;
  18262. /**
  18263. * Creates a new instance SphereParticleEmitter
  18264. * @param radius the radius of the emission sphere (1 by default)
  18265. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18266. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18267. */
  18268. constructor(
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius?: number,
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange?: number,
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer?: number);
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): SphereParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "SphereParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. /**
  18327. * Particle emitter emitting particles from the inside of a sphere.
  18328. * It emits the particles randomly between two vectors.
  18329. */
  18330. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18331. /**
  18332. * The min limit of the emission direction.
  18333. */
  18334. direction1: Vector3;
  18335. /**
  18336. * The max limit of the emission direction.
  18337. */
  18338. direction2: Vector3;
  18339. /**
  18340. * Creates a new instance SphereDirectedParticleEmitter
  18341. * @param radius the radius of the emission sphere (1 by default)
  18342. * @param direction1 the min limit of the emission direction (up vector by default)
  18343. * @param direction2 the max limit of the emission direction (up vector by default)
  18344. */
  18345. constructor(radius?: number,
  18346. /**
  18347. * The min limit of the emission direction.
  18348. */
  18349. direction1?: Vector3,
  18350. /**
  18351. * The max limit of the emission direction.
  18352. */
  18353. direction2?: Vector3);
  18354. /**
  18355. * Called by the particle System when the direction is computed for the created particle.
  18356. * @param worldMatrix is the world matrix of the particle system
  18357. * @param directionToUpdate is the direction vector to update with the result
  18358. * @param particle is the particle we are computed the direction for
  18359. */
  18360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18361. /**
  18362. * Clones the current emitter and returns a copy of it
  18363. * @returns the new emitter
  18364. */
  18365. clone(): SphereDirectedParticleEmitter;
  18366. /**
  18367. * Called by the GPUParticleSystem to setup the update shader
  18368. * @param effect defines the update shader
  18369. */
  18370. applyToShader(effect: Effect): void;
  18371. /**
  18372. * Returns a string to use to update the GPU particles update shader
  18373. * @returns a string containng the defines string
  18374. */
  18375. getEffectDefines(): string;
  18376. /**
  18377. * Returns the string "SphereDirectedParticleEmitter"
  18378. * @returns a string containing the class name
  18379. */
  18380. getClassName(): string;
  18381. /**
  18382. * Serializes the particle system to a JSON object.
  18383. * @returns the JSON object
  18384. */
  18385. serialize(): any;
  18386. /**
  18387. * Parse properties from a JSON object
  18388. * @param serializationObject defines the JSON object
  18389. */
  18390. parse(serializationObject: any): void;
  18391. }
  18392. }
  18393. declare module BABYLON {
  18394. /**
  18395. * Interface representing a particle system in Babylon.js.
  18396. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18397. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18398. */
  18399. export interface IParticleSystem {
  18400. /**
  18401. * List of animations used by the particle system.
  18402. */
  18403. animations: Animation[];
  18404. /**
  18405. * The id of the Particle system.
  18406. */
  18407. id: string;
  18408. /**
  18409. * The name of the Particle system.
  18410. */
  18411. name: string;
  18412. /**
  18413. * The emitter represents the Mesh or position we are attaching the particle system to.
  18414. */
  18415. emitter: Nullable<AbstractMesh | Vector3>;
  18416. /**
  18417. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18418. */
  18419. isBillboardBased: boolean;
  18420. /**
  18421. * The rendering group used by the Particle system to chose when to render.
  18422. */
  18423. renderingGroupId: number;
  18424. /**
  18425. * The layer mask we are rendering the particles through.
  18426. */
  18427. layerMask: number;
  18428. /**
  18429. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18430. */
  18431. updateSpeed: number;
  18432. /**
  18433. * The amount of time the particle system is running (depends of the overall update speed).
  18434. */
  18435. targetStopDuration: number;
  18436. /**
  18437. * The texture used to render each particle. (this can be a spritesheet)
  18438. */
  18439. particleTexture: Nullable<Texture>;
  18440. /**
  18441. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18442. */
  18443. blendMode: number;
  18444. /**
  18445. * Minimum life time of emitting particles.
  18446. */
  18447. minLifeTime: number;
  18448. /**
  18449. * Maximum life time of emitting particles.
  18450. */
  18451. maxLifeTime: number;
  18452. /**
  18453. * Minimum Size of emitting particles.
  18454. */
  18455. minSize: number;
  18456. /**
  18457. * Maximum Size of emitting particles.
  18458. */
  18459. maxSize: number;
  18460. /**
  18461. * Minimum scale of emitting particles on X axis.
  18462. */
  18463. minScaleX: number;
  18464. /**
  18465. * Maximum scale of emitting particles on X axis.
  18466. */
  18467. maxScaleX: number;
  18468. /**
  18469. * Minimum scale of emitting particles on Y axis.
  18470. */
  18471. minScaleY: number;
  18472. /**
  18473. * Maximum scale of emitting particles on Y axis.
  18474. */
  18475. maxScaleY: number;
  18476. /**
  18477. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18478. */
  18479. color1: Color4;
  18480. /**
  18481. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18482. */
  18483. color2: Color4;
  18484. /**
  18485. * Color the particle will have at the end of its lifetime.
  18486. */
  18487. colorDead: Color4;
  18488. /**
  18489. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18490. */
  18491. emitRate: number;
  18492. /**
  18493. * You can use gravity if you want to give an orientation to your particles.
  18494. */
  18495. gravity: Vector3;
  18496. /**
  18497. * Minimum power of emitting particles.
  18498. */
  18499. minEmitPower: number;
  18500. /**
  18501. * Maximum power of emitting particles.
  18502. */
  18503. maxEmitPower: number;
  18504. /**
  18505. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18506. */
  18507. minAngularSpeed: number;
  18508. /**
  18509. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18510. */
  18511. maxAngularSpeed: number;
  18512. /**
  18513. * Gets or sets the minimal initial rotation in radians.
  18514. */
  18515. minInitialRotation: number;
  18516. /**
  18517. * Gets or sets the maximal initial rotation in radians.
  18518. */
  18519. maxInitialRotation: number;
  18520. /**
  18521. * The particle emitter type defines the emitter used by the particle system.
  18522. * It can be for example box, sphere, or cone...
  18523. */
  18524. particleEmitterType: Nullable<IParticleEmitterType>;
  18525. /**
  18526. * Defines the delay in milliseconds before starting the system (0 by default)
  18527. */
  18528. startDelay: number;
  18529. /**
  18530. * 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
  18531. */
  18532. preWarmCycles: number;
  18533. /**
  18534. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18535. */
  18536. preWarmStepOffset: number;
  18537. /**
  18538. * 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)
  18539. */
  18540. spriteCellChangeSpeed: number;
  18541. /**
  18542. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18543. */
  18544. startSpriteCellID: number;
  18545. /**
  18546. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18547. */
  18548. endSpriteCellID: number;
  18549. /**
  18550. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18551. */
  18552. spriteCellWidth: number;
  18553. /**
  18554. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18555. */
  18556. spriteCellHeight: number;
  18557. /**
  18558. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18559. */
  18560. spriteRandomStartCell: boolean;
  18561. /**
  18562. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18563. */
  18564. isAnimationSheetEnabled: boolean;
  18565. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18566. translationPivot: Vector2;
  18567. /**
  18568. * Gets or sets a texture used to add random noise to particle positions
  18569. */
  18570. noiseTexture: Nullable<BaseTexture>;
  18571. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18572. noiseStrength: Vector3;
  18573. /**
  18574. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18575. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18576. */
  18577. billboardMode: number;
  18578. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18579. limitVelocityDamping: number;
  18580. /**
  18581. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18582. */
  18583. beginAnimationOnStart: boolean;
  18584. /**
  18585. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18586. */
  18587. beginAnimationFrom: number;
  18588. /**
  18589. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18590. */
  18591. beginAnimationTo: number;
  18592. /**
  18593. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18594. */
  18595. beginAnimationLoop: boolean;
  18596. /**
  18597. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18598. */
  18599. disposeOnStop: boolean;
  18600. /**
  18601. * Gets the maximum number of particles active at the same time.
  18602. * @returns The max number of active particles.
  18603. */
  18604. getCapacity(): number;
  18605. /**
  18606. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18607. * @returns True if it has been started, otherwise false.
  18608. */
  18609. isStarted(): boolean;
  18610. /**
  18611. * Animates the particle system for this frame.
  18612. */
  18613. animate(): void;
  18614. /**
  18615. * Renders the particle system in its current state.
  18616. * @returns the current number of particles
  18617. */
  18618. render(): number;
  18619. /**
  18620. * Dispose the particle system and frees its associated resources.
  18621. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18622. */
  18623. dispose(disposeTexture?: boolean): void;
  18624. /**
  18625. * Clones the particle system.
  18626. * @param name The name of the cloned object
  18627. * @param newEmitter The new emitter to use
  18628. * @returns the cloned particle system
  18629. */
  18630. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18631. /**
  18632. * Serializes the particle system to a JSON object.
  18633. * @returns the JSON object
  18634. */
  18635. serialize(): any;
  18636. /**
  18637. * Rebuild the particle system
  18638. */
  18639. rebuild(): void;
  18640. /**
  18641. * Starts the particle system and begins to emit
  18642. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18643. */
  18644. start(delay?: number): void;
  18645. /**
  18646. * Stops the particle system.
  18647. */
  18648. stop(): void;
  18649. /**
  18650. * Remove all active particles
  18651. */
  18652. reset(): void;
  18653. /**
  18654. * Is this system ready to be used/rendered
  18655. * @return true if the system is ready
  18656. */
  18657. isReady(): boolean;
  18658. /**
  18659. * Adds a new color gradient
  18660. * @param gradient defines the gradient to use (between 0 and 1)
  18661. * @param color1 defines the color to affect to the specified gradient
  18662. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18663. * @returns the current particle system
  18664. */
  18665. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18666. /**
  18667. * Remove a specific color gradient
  18668. * @param gradient defines the gradient to remove
  18669. * @returns the current particle system
  18670. */
  18671. removeColorGradient(gradient: number): IParticleSystem;
  18672. /**
  18673. * Adds a new size gradient
  18674. * @param gradient defines the gradient to use (between 0 and 1)
  18675. * @param factor defines the size factor to affect to the specified gradient
  18676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18677. * @returns the current particle system
  18678. */
  18679. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18680. /**
  18681. * Remove a specific size gradient
  18682. * @param gradient defines the gradient to remove
  18683. * @returns the current particle system
  18684. */
  18685. removeSizeGradient(gradient: number): IParticleSystem;
  18686. /**
  18687. * Gets the current list of color gradients.
  18688. * You must use addColorGradient and removeColorGradient to udpate this list
  18689. * @returns the list of color gradients
  18690. */
  18691. getColorGradients(): Nullable<Array<ColorGradient>>;
  18692. /**
  18693. * Gets the current list of size gradients.
  18694. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18695. * @returns the list of size gradients
  18696. */
  18697. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18698. /**
  18699. * Gets the current list of angular speed gradients.
  18700. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18701. * @returns the list of angular speed gradients
  18702. */
  18703. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18704. /**
  18705. * Adds a new angular speed gradient
  18706. * @param gradient defines the gradient to use (between 0 and 1)
  18707. * @param factor defines the angular speed to affect to the specified gradient
  18708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18709. * @returns the current particle system
  18710. */
  18711. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18712. /**
  18713. * Remove a specific angular speed gradient
  18714. * @param gradient defines the gradient to remove
  18715. * @returns the current particle system
  18716. */
  18717. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18718. /**
  18719. * Gets the current list of velocity gradients.
  18720. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18721. * @returns the list of velocity gradients
  18722. */
  18723. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18724. /**
  18725. * Adds a new velocity gradient
  18726. * @param gradient defines the gradient to use (between 0 and 1)
  18727. * @param factor defines the velocity to affect to the specified gradient
  18728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18729. * @returns the current particle system
  18730. */
  18731. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18732. /**
  18733. * Remove a specific velocity gradient
  18734. * @param gradient defines the gradient to remove
  18735. * @returns the current particle system
  18736. */
  18737. removeVelocityGradient(gradient: number): IParticleSystem;
  18738. /**
  18739. * Gets the current list of limit velocity gradients.
  18740. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18741. * @returns the list of limit velocity gradients
  18742. */
  18743. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18744. /**
  18745. * Adds a new limit velocity gradient
  18746. * @param gradient defines the gradient to use (between 0 and 1)
  18747. * @param factor defines the limit velocity to affect to the specified gradient
  18748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18749. * @returns the current particle system
  18750. */
  18751. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18752. /**
  18753. * Remove a specific limit velocity gradient
  18754. * @param gradient defines the gradient to remove
  18755. * @returns the current particle system
  18756. */
  18757. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18758. /**
  18759. * Adds a new drag gradient
  18760. * @param gradient defines the gradient to use (between 0 and 1)
  18761. * @param factor defines the drag to affect to the specified gradient
  18762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18763. * @returns the current particle system
  18764. */
  18765. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18766. /**
  18767. * Remove a specific drag gradient
  18768. * @param gradient defines the gradient to remove
  18769. * @returns the current particle system
  18770. */
  18771. removeDragGradient(gradient: number): IParticleSystem;
  18772. /**
  18773. * Gets the current list of drag gradients.
  18774. * You must use addDragGradient and removeDragGradient to udpate this list
  18775. * @returns the list of drag gradients
  18776. */
  18777. getDragGradients(): Nullable<Array<FactorGradient>>;
  18778. /**
  18779. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18780. * @param gradient defines the gradient to use (between 0 and 1)
  18781. * @param factor defines the emit rate to affect to the specified gradient
  18782. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18783. * @returns the current particle system
  18784. */
  18785. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18786. /**
  18787. * Remove a specific emit rate gradient
  18788. * @param gradient defines the gradient to remove
  18789. * @returns the current particle system
  18790. */
  18791. removeEmitRateGradient(gradient: number): IParticleSystem;
  18792. /**
  18793. * Gets the current list of emit rate gradients.
  18794. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18795. * @returns the list of emit rate gradients
  18796. */
  18797. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18798. /**
  18799. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18800. * @param gradient defines the gradient to use (between 0 and 1)
  18801. * @param factor defines the start size to affect to the specified gradient
  18802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18803. * @returns the current particle system
  18804. */
  18805. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18806. /**
  18807. * Remove a specific start size gradient
  18808. * @param gradient defines the gradient to remove
  18809. * @returns the current particle system
  18810. */
  18811. removeStartSizeGradient(gradient: number): IParticleSystem;
  18812. /**
  18813. * Gets the current list of start size gradients.
  18814. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18815. * @returns the list of start size gradients
  18816. */
  18817. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18818. /**
  18819. * Adds a new life time gradient
  18820. * @param gradient defines the gradient to use (between 0 and 1)
  18821. * @param factor defines the life time factor to affect to the specified gradient
  18822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18823. * @returns the current particle system
  18824. */
  18825. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18826. /**
  18827. * Remove a specific life time gradient
  18828. * @param gradient defines the gradient to remove
  18829. * @returns the current particle system
  18830. */
  18831. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18832. /**
  18833. * Gets the current list of life time gradients.
  18834. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18835. * @returns the list of life time gradients
  18836. */
  18837. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18838. /**
  18839. * Gets the current list of color gradients.
  18840. * You must use addColorGradient and removeColorGradient to udpate this list
  18841. * @returns the list of color gradients
  18842. */
  18843. getColorGradients(): Nullable<Array<ColorGradient>>;
  18844. /**
  18845. * Adds a new ramp gradient used to remap particle colors
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param color defines the color to affect to the specified gradient
  18848. * @returns the current particle system
  18849. */
  18850. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18851. /**
  18852. * Gets the current list of ramp gradients.
  18853. * You must use addRampGradient and removeRampGradient to udpate this list
  18854. * @returns the list of ramp gradients
  18855. */
  18856. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18857. /** Gets or sets a boolean indicating that ramp gradients must be used
  18858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18859. */
  18860. useRampGradients: boolean;
  18861. /**
  18862. * Adds a new color remap gradient
  18863. * @param gradient defines the gradient to use (between 0 and 1)
  18864. * @param min defines the color remap minimal range
  18865. * @param max defines the color remap maximal range
  18866. * @returns the current particle system
  18867. */
  18868. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18869. /**
  18870. * Gets the current list of color remap gradients.
  18871. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18872. * @returns the list of color remap gradients
  18873. */
  18874. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18875. /**
  18876. * Adds a new alpha remap gradient
  18877. * @param gradient defines the gradient to use (between 0 and 1)
  18878. * @param min defines the alpha remap minimal range
  18879. * @param max defines the alpha remap maximal range
  18880. * @returns the current particle system
  18881. */
  18882. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18883. /**
  18884. * Gets the current list of alpha remap gradients.
  18885. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18886. * @returns the list of alpha remap gradients
  18887. */
  18888. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18889. /**
  18890. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18893. * @returns the emitter
  18894. */
  18895. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18896. /**
  18897. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18898. * @param radius The radius of the hemisphere to emit from
  18899. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18900. * @returns the emitter
  18901. */
  18902. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18903. /**
  18904. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18905. * @param radius The radius of the sphere to emit from
  18906. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18907. * @returns the emitter
  18908. */
  18909. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18910. /**
  18911. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18912. * @param radius The radius of the sphere to emit from
  18913. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18914. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18915. * @returns the emitter
  18916. */
  18917. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18918. /**
  18919. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18920. * @param radius The radius of the emission cylinder
  18921. * @param height The height of the emission cylinder
  18922. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18923. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18924. * @returns the emitter
  18925. */
  18926. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18927. /**
  18928. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18929. * @param radius The radius of the cylinder to emit from
  18930. * @param height The height of the emission cylinder
  18931. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18934. * @returns the emitter
  18935. */
  18936. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18937. /**
  18938. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18939. * @param radius The radius of the cone to emit from
  18940. * @param angle The base angle of the cone
  18941. * @returns the emitter
  18942. */
  18943. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18944. /**
  18945. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18946. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18947. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18948. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18949. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18950. * @returns the emitter
  18951. */
  18952. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18953. /**
  18954. * Get hosting scene
  18955. * @returns the scene
  18956. */
  18957. getScene(): Scene;
  18958. }
  18959. }
  18960. declare module BABYLON {
  18961. /**
  18962. * Creates an instance based on a source mesh.
  18963. */
  18964. export class InstancedMesh extends AbstractMesh {
  18965. private _sourceMesh;
  18966. private _currentLOD;
  18967. /** @hidden */
  18968. _indexInSourceMeshInstanceArray: number;
  18969. constructor(name: string, source: Mesh);
  18970. /**
  18971. * Returns the string "InstancedMesh".
  18972. */
  18973. getClassName(): string;
  18974. /** Gets the list of lights affecting that mesh */
  18975. readonly lightSources: Light[];
  18976. _resyncLightSources(): void;
  18977. _resyncLighSource(light: Light): void;
  18978. _removeLightSource(light: Light, dispose: boolean): void;
  18979. /**
  18980. * If the source mesh receives shadows
  18981. */
  18982. readonly receiveShadows: boolean;
  18983. /**
  18984. * The material of the source mesh
  18985. */
  18986. readonly material: Nullable<Material>;
  18987. /**
  18988. * Visibility of the source mesh
  18989. */
  18990. readonly visibility: number;
  18991. /**
  18992. * Skeleton of the source mesh
  18993. */
  18994. readonly skeleton: Nullable<Skeleton>;
  18995. /**
  18996. * Rendering ground id of the source mesh
  18997. */
  18998. renderingGroupId: number;
  18999. /**
  19000. * Returns the total number of vertices (integer).
  19001. */
  19002. getTotalVertices(): number;
  19003. /**
  19004. * Returns a positive integer : the total number of indices in this mesh geometry.
  19005. * @returns the numner of indices or zero if the mesh has no geometry.
  19006. */
  19007. getTotalIndices(): number;
  19008. /**
  19009. * The source mesh of the instance
  19010. */
  19011. readonly sourceMesh: Mesh;
  19012. /**
  19013. * Is this node ready to be used/rendered
  19014. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19015. * @return {boolean} is it ready
  19016. */
  19017. isReady(completeCheck?: boolean): boolean;
  19018. /**
  19019. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19020. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19021. * @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.
  19022. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19023. */
  19024. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19025. /**
  19026. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19027. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19028. * The `data` are either a numeric array either a Float32Array.
  19029. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19030. * 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).
  19031. * Note that a new underlying VertexBuffer object is created each call.
  19032. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19033. *
  19034. * Possible `kind` values :
  19035. * - VertexBuffer.PositionKind
  19036. * - VertexBuffer.UVKind
  19037. * - VertexBuffer.UV2Kind
  19038. * - VertexBuffer.UV3Kind
  19039. * - VertexBuffer.UV4Kind
  19040. * - VertexBuffer.UV5Kind
  19041. * - VertexBuffer.UV6Kind
  19042. * - VertexBuffer.ColorKind
  19043. * - VertexBuffer.MatricesIndicesKind
  19044. * - VertexBuffer.MatricesIndicesExtraKind
  19045. * - VertexBuffer.MatricesWeightsKind
  19046. * - VertexBuffer.MatricesWeightsExtraKind
  19047. *
  19048. * Returns the Mesh.
  19049. */
  19050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19051. /**
  19052. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19053. * If the mesh has no geometry, it is simply returned as it is.
  19054. * The `data` are either a numeric array either a Float32Array.
  19055. * No new underlying VertexBuffer object is created.
  19056. * 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.
  19057. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19058. *
  19059. * Possible `kind` values :
  19060. * - VertexBuffer.PositionKind
  19061. * - VertexBuffer.UVKind
  19062. * - VertexBuffer.UV2Kind
  19063. * - VertexBuffer.UV3Kind
  19064. * - VertexBuffer.UV4Kind
  19065. * - VertexBuffer.UV5Kind
  19066. * - VertexBuffer.UV6Kind
  19067. * - VertexBuffer.ColorKind
  19068. * - VertexBuffer.MatricesIndicesKind
  19069. * - VertexBuffer.MatricesIndicesExtraKind
  19070. * - VertexBuffer.MatricesWeightsKind
  19071. * - VertexBuffer.MatricesWeightsExtraKind
  19072. *
  19073. * Returns the Mesh.
  19074. */
  19075. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19076. /**
  19077. * Sets the mesh indices.
  19078. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19079. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19080. * This method creates a new index buffer each call.
  19081. * Returns the Mesh.
  19082. */
  19083. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19084. /**
  19085. * Boolean : True if the mesh owns the requested kind of data.
  19086. */
  19087. isVerticesDataPresent(kind: string): boolean;
  19088. /**
  19089. * Returns an array of indices (IndicesArray).
  19090. */
  19091. getIndices(): Nullable<IndicesArray>;
  19092. readonly _positions: Nullable<Vector3[]>;
  19093. /**
  19094. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19095. * This means the mesh underlying bounding box and sphere are recomputed.
  19096. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19097. * @returns the current mesh
  19098. */
  19099. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19100. /** @hidden */
  19101. _preActivate(): InstancedMesh;
  19102. /** @hidden */
  19103. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19104. /** @hidden */
  19105. _postActivate(): void;
  19106. getWorldMatrix(): Matrix;
  19107. readonly isAnInstance: boolean;
  19108. /**
  19109. * Returns the current associated LOD AbstractMesh.
  19110. */
  19111. getLOD(camera: Camera): AbstractMesh;
  19112. /** @hidden */
  19113. _syncSubMeshes(): InstancedMesh;
  19114. /** @hidden */
  19115. _generatePointsArray(): boolean;
  19116. /**
  19117. * Creates a new InstancedMesh from the current mesh.
  19118. * - name (string) : the cloned mesh name
  19119. * - newParent (optional Node) : the optional Node to parent the clone to.
  19120. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19121. *
  19122. * Returns the clone.
  19123. */
  19124. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19125. /**
  19126. * Disposes the InstancedMesh.
  19127. * Returns nothing.
  19128. */
  19129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19130. }
  19131. interface Mesh {
  19132. /**
  19133. * Register a custom buffer that will be instanced
  19134. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19135. * @param kind defines the buffer kind
  19136. * @param stride defines the stride in floats
  19137. */
  19138. registerInstancedBuffer(kind: string, stride: number): void;
  19139. /** @hidden */
  19140. _userInstancedBuffersStorage: {
  19141. data: {
  19142. [key: string]: Float32Array;
  19143. };
  19144. sizes: {
  19145. [key: string]: number;
  19146. };
  19147. vertexBuffers: {
  19148. [key: string]: Nullable<VertexBuffer>;
  19149. };
  19150. strides: {
  19151. [key: string]: number;
  19152. };
  19153. };
  19154. }
  19155. interface AbstractMesh {
  19156. /**
  19157. * Object used to store instanced buffers defined by user
  19158. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19159. */
  19160. instancedBuffers: {
  19161. [key: string]: any;
  19162. };
  19163. }
  19164. }
  19165. declare module BABYLON {
  19166. /**
  19167. * Defines the options associated with the creation of a shader material.
  19168. */
  19169. export interface IShaderMaterialOptions {
  19170. /**
  19171. * Does the material work in alpha blend mode
  19172. */
  19173. needAlphaBlending: boolean;
  19174. /**
  19175. * Does the material work in alpha test mode
  19176. */
  19177. needAlphaTesting: boolean;
  19178. /**
  19179. * The list of attribute names used in the shader
  19180. */
  19181. attributes: string[];
  19182. /**
  19183. * The list of unifrom names used in the shader
  19184. */
  19185. uniforms: string[];
  19186. /**
  19187. * The list of UBO names used in the shader
  19188. */
  19189. uniformBuffers: string[];
  19190. /**
  19191. * The list of sampler names used in the shader
  19192. */
  19193. samplers: string[];
  19194. /**
  19195. * The list of defines used in the shader
  19196. */
  19197. defines: string[];
  19198. }
  19199. /**
  19200. * 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.
  19201. *
  19202. * This returned material effects how the mesh will look based on the code in the shaders.
  19203. *
  19204. * @see http://doc.babylonjs.com/how_to/shader_material
  19205. */
  19206. export class ShaderMaterial extends Material {
  19207. private _shaderPath;
  19208. private _options;
  19209. private _textures;
  19210. private _textureArrays;
  19211. private _floats;
  19212. private _ints;
  19213. private _floatsArrays;
  19214. private _colors3;
  19215. private _colors3Arrays;
  19216. private _colors4;
  19217. private _colors4Arrays;
  19218. private _vectors2;
  19219. private _vectors3;
  19220. private _vectors4;
  19221. private _matrices;
  19222. private _matrixArrays;
  19223. private _matrices3x3;
  19224. private _matrices2x2;
  19225. private _vectors2Arrays;
  19226. private _vectors3Arrays;
  19227. private _vectors4Arrays;
  19228. private _cachedWorldViewMatrix;
  19229. private _cachedWorldViewProjectionMatrix;
  19230. private _renderId;
  19231. private _multiview;
  19232. /**
  19233. * Instantiate a new shader material.
  19234. * 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.
  19235. * This returned material effects how the mesh will look based on the code in the shaders.
  19236. * @see http://doc.babylonjs.com/how_to/shader_material
  19237. * @param name Define the name of the material in the scene
  19238. * @param scene Define the scene the material belongs to
  19239. * @param shaderPath Defines the route to the shader code in one of three ways:
  19240. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19241. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19242. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19243. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19244. * @param options Define the options used to create the shader
  19245. */
  19246. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19247. /**
  19248. * Gets the shader path used to define the shader code
  19249. * It can be modified to trigger a new compilation
  19250. */
  19251. /**
  19252. * Sets the shader path used to define the shader code
  19253. * It can be modified to trigger a new compilation
  19254. */
  19255. shaderPath: any;
  19256. /**
  19257. * Gets the options used to compile the shader.
  19258. * They can be modified to trigger a new compilation
  19259. */
  19260. readonly options: IShaderMaterialOptions;
  19261. /**
  19262. * Gets the current class name of the material e.g. "ShaderMaterial"
  19263. * Mainly use in serialization.
  19264. * @returns the class name
  19265. */
  19266. getClassName(): string;
  19267. /**
  19268. * Specifies if the material will require alpha blending
  19269. * @returns a boolean specifying if alpha blending is needed
  19270. */
  19271. needAlphaBlending(): boolean;
  19272. /**
  19273. * Specifies if this material should be rendered in alpha test mode
  19274. * @returns a boolean specifying if an alpha test is needed.
  19275. */
  19276. needAlphaTesting(): boolean;
  19277. private _checkUniform;
  19278. /**
  19279. * Set a texture in the shader.
  19280. * @param name Define the name of the uniform samplers as defined in the shader
  19281. * @param texture Define the texture to bind to this sampler
  19282. * @return the material itself allowing "fluent" like uniform updates
  19283. */
  19284. setTexture(name: string, texture: Texture): ShaderMaterial;
  19285. /**
  19286. * Set a texture array in the shader.
  19287. * @param name Define the name of the uniform sampler array as defined in the shader
  19288. * @param textures Define the list of textures to bind to this sampler
  19289. * @return the material itself allowing "fluent" like uniform updates
  19290. */
  19291. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19292. /**
  19293. * Set a float in the shader.
  19294. * @param name Define the name of the uniform as defined in the shader
  19295. * @param value Define the value to give to the uniform
  19296. * @return the material itself allowing "fluent" like uniform updates
  19297. */
  19298. setFloat(name: string, value: number): ShaderMaterial;
  19299. /**
  19300. * Set a int in the shader.
  19301. * @param name Define the name of the uniform as defined in the shader
  19302. * @param value Define the value to give to the uniform
  19303. * @return the material itself allowing "fluent" like uniform updates
  19304. */
  19305. setInt(name: string, value: number): ShaderMaterial;
  19306. /**
  19307. * Set an array of floats in the shader.
  19308. * @param name Define the name of the uniform as defined in the shader
  19309. * @param value Define the value to give to the uniform
  19310. * @return the material itself allowing "fluent" like uniform updates
  19311. */
  19312. setFloats(name: string, value: number[]): ShaderMaterial;
  19313. /**
  19314. * Set a vec3 in the shader from a Color3.
  19315. * @param name Define the name of the uniform as defined in the shader
  19316. * @param value Define the value to give to the uniform
  19317. * @return the material itself allowing "fluent" like uniform updates
  19318. */
  19319. setColor3(name: string, value: Color3): ShaderMaterial;
  19320. /**
  19321. * Set a vec3 array in the shader from a Color3 array.
  19322. * @param name Define the name of the uniform as defined in the shader
  19323. * @param value Define the value to give to the uniform
  19324. * @return the material itself allowing "fluent" like uniform updates
  19325. */
  19326. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19327. /**
  19328. * Set a vec4 in the shader from a Color4.
  19329. * @param name Define the name of the uniform as defined in the shader
  19330. * @param value Define the value to give to the uniform
  19331. * @return the material itself allowing "fluent" like uniform updates
  19332. */
  19333. setColor4(name: string, value: Color4): ShaderMaterial;
  19334. /**
  19335. * Set a vec4 array in the shader from a Color4 array.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the material itself allowing "fluent" like uniform updates
  19339. */
  19340. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19341. /**
  19342. * Set a vec2 in the shader from a Vector2.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the material itself allowing "fluent" like uniform updates
  19346. */
  19347. setVector2(name: string, value: Vector2): ShaderMaterial;
  19348. /**
  19349. * Set a vec3 in the shader from a Vector3.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the material itself allowing "fluent" like uniform updates
  19353. */
  19354. setVector3(name: string, value: Vector3): ShaderMaterial;
  19355. /**
  19356. * Set a vec4 in the shader from a Vector4.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the material itself allowing "fluent" like uniform updates
  19360. */
  19361. setVector4(name: string, value: Vector4): ShaderMaterial;
  19362. /**
  19363. * Set a mat4 in the shader from a Matrix.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the material itself allowing "fluent" like uniform updates
  19367. */
  19368. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19369. /**
  19370. * Set a float32Array in the shader from a matrix array.
  19371. * @param name Define the name of the uniform as defined in the shader
  19372. * @param value Define the value to give to the uniform
  19373. * @return the material itself allowing "fluent" like uniform updates
  19374. */
  19375. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19376. /**
  19377. * Set a mat3 in the shader from a Float32Array.
  19378. * @param name Define the name of the uniform as defined in the shader
  19379. * @param value Define the value to give to the uniform
  19380. * @return the material itself allowing "fluent" like uniform updates
  19381. */
  19382. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19383. /**
  19384. * Set a mat2 in the shader from a Float32Array.
  19385. * @param name Define the name of the uniform as defined in the shader
  19386. * @param value Define the value to give to the uniform
  19387. * @return the material itself allowing "fluent" like uniform updates
  19388. */
  19389. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19390. /**
  19391. * Set a vec2 array in the shader from a number array.
  19392. * @param name Define the name of the uniform as defined in the shader
  19393. * @param value Define the value to give to the uniform
  19394. * @return the material itself allowing "fluent" like uniform updates
  19395. */
  19396. setArray2(name: string, value: number[]): ShaderMaterial;
  19397. /**
  19398. * Set a vec3 array in the shader from a number array.
  19399. * @param name Define the name of the uniform as defined in the shader
  19400. * @param value Define the value to give to the uniform
  19401. * @return the material itself allowing "fluent" like uniform updates
  19402. */
  19403. setArray3(name: string, value: number[]): ShaderMaterial;
  19404. /**
  19405. * Set a vec4 array in the shader from a number array.
  19406. * @param name Define the name of the uniform as defined in the shader
  19407. * @param value Define the value to give to the uniform
  19408. * @return the material itself allowing "fluent" like uniform updates
  19409. */
  19410. setArray4(name: string, value: number[]): ShaderMaterial;
  19411. private _checkCache;
  19412. /**
  19413. * Specifies that the submesh is ready to be used
  19414. * @param mesh defines the mesh to check
  19415. * @param subMesh defines which submesh to check
  19416. * @param useInstances specifies that instances should be used
  19417. * @returns a boolean indicating that the submesh is ready or not
  19418. */
  19419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19420. /**
  19421. * Checks if the material is ready to render the requested mesh
  19422. * @param mesh Define the mesh to render
  19423. * @param useInstances Define whether or not the material is used with instances
  19424. * @returns true if ready, otherwise false
  19425. */
  19426. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19427. /**
  19428. * Binds the world matrix to the material
  19429. * @param world defines the world transformation matrix
  19430. */
  19431. bindOnlyWorldMatrix(world: Matrix): void;
  19432. /**
  19433. * Binds the material to the mesh
  19434. * @param world defines the world transformation matrix
  19435. * @param mesh defines the mesh to bind the material to
  19436. */
  19437. bind(world: Matrix, mesh?: Mesh): void;
  19438. /**
  19439. * Gets the active textures from the material
  19440. * @returns an array of textures
  19441. */
  19442. getActiveTextures(): BaseTexture[];
  19443. /**
  19444. * Specifies if the material uses a texture
  19445. * @param texture defines the texture to check against the material
  19446. * @returns a boolean specifying if the material uses the texture
  19447. */
  19448. hasTexture(texture: BaseTexture): boolean;
  19449. /**
  19450. * Makes a duplicate of the material, and gives it a new name
  19451. * @param name defines the new name for the duplicated material
  19452. * @returns the cloned material
  19453. */
  19454. clone(name: string): ShaderMaterial;
  19455. /**
  19456. * Disposes the material
  19457. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19458. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19459. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19460. */
  19461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19462. /**
  19463. * Serializes this material in a JSON representation
  19464. * @returns the serialized material object
  19465. */
  19466. serialize(): any;
  19467. /**
  19468. * Creates a shader material from parsed shader material data
  19469. * @param source defines the JSON represnetation of the material
  19470. * @param scene defines the hosting scene
  19471. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19472. * @returns a new material
  19473. */
  19474. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19475. }
  19476. }
  19477. declare module BABYLON {
  19478. /** @hidden */
  19479. export var colorPixelShader: {
  19480. name: string;
  19481. shader: string;
  19482. };
  19483. }
  19484. declare module BABYLON {
  19485. /** @hidden */
  19486. export var colorVertexShader: {
  19487. name: string;
  19488. shader: string;
  19489. };
  19490. }
  19491. declare module BABYLON {
  19492. /**
  19493. * Line mesh
  19494. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19495. */
  19496. export class LinesMesh extends Mesh {
  19497. /**
  19498. * If vertex color should be applied to the mesh
  19499. */
  19500. readonly useVertexColor?: boolean | undefined;
  19501. /**
  19502. * If vertex alpha should be applied to the mesh
  19503. */
  19504. readonly useVertexAlpha?: boolean | undefined;
  19505. /**
  19506. * Color of the line (Default: White)
  19507. */
  19508. color: Color3;
  19509. /**
  19510. * Alpha of the line (Default: 1)
  19511. */
  19512. alpha: number;
  19513. /**
  19514. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19515. * This margin is expressed in world space coordinates, so its value may vary.
  19516. * Default value is 0.1
  19517. */
  19518. intersectionThreshold: number;
  19519. private _colorShader;
  19520. private color4;
  19521. /**
  19522. * Creates a new LinesMesh
  19523. * @param name defines the name
  19524. * @param scene defines the hosting scene
  19525. * @param parent defines the parent mesh if any
  19526. * @param source defines the optional source LinesMesh used to clone data from
  19527. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19528. * When false, achieved by calling a clone(), also passing False.
  19529. * This will make creation of children, recursive.
  19530. * @param useVertexColor defines if this LinesMesh supports vertex color
  19531. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19532. */
  19533. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19534. /**
  19535. * If vertex color should be applied to the mesh
  19536. */
  19537. useVertexColor?: boolean | undefined,
  19538. /**
  19539. * If vertex alpha should be applied to the mesh
  19540. */
  19541. useVertexAlpha?: boolean | undefined);
  19542. private _addClipPlaneDefine;
  19543. private _removeClipPlaneDefine;
  19544. isReady(): boolean;
  19545. /**
  19546. * Returns the string "LineMesh"
  19547. */
  19548. getClassName(): string;
  19549. /**
  19550. * @hidden
  19551. */
  19552. /**
  19553. * @hidden
  19554. */
  19555. material: Material;
  19556. /**
  19557. * @hidden
  19558. */
  19559. readonly checkCollisions: boolean;
  19560. /** @hidden */
  19561. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19562. /** @hidden */
  19563. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19564. /**
  19565. * Disposes of the line mesh
  19566. * @param doNotRecurse If children should be disposed
  19567. */
  19568. dispose(doNotRecurse?: boolean): void;
  19569. /**
  19570. * Returns a new LineMesh object cloned from the current one.
  19571. */
  19572. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19573. /**
  19574. * Creates a new InstancedLinesMesh object from the mesh model.
  19575. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19576. * @param name defines the name of the new instance
  19577. * @returns a new InstancedLinesMesh
  19578. */
  19579. createInstance(name: string): InstancedLinesMesh;
  19580. }
  19581. /**
  19582. * Creates an instance based on a source LinesMesh
  19583. */
  19584. export class InstancedLinesMesh extends InstancedMesh {
  19585. /**
  19586. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19587. * This margin is expressed in world space coordinates, so its value may vary.
  19588. * Initilized with the intersectionThreshold value of the source LinesMesh
  19589. */
  19590. intersectionThreshold: number;
  19591. constructor(name: string, source: LinesMesh);
  19592. /**
  19593. * Returns the string "InstancedLinesMesh".
  19594. */
  19595. getClassName(): string;
  19596. }
  19597. }
  19598. declare module BABYLON {
  19599. /** @hidden */
  19600. export var linePixelShader: {
  19601. name: string;
  19602. shader: string;
  19603. };
  19604. }
  19605. declare module BABYLON {
  19606. /** @hidden */
  19607. export var lineVertexShader: {
  19608. name: string;
  19609. shader: string;
  19610. };
  19611. }
  19612. declare module BABYLON {
  19613. interface AbstractMesh {
  19614. /**
  19615. * Gets the edgesRenderer associated with the mesh
  19616. */
  19617. edgesRenderer: Nullable<EdgesRenderer>;
  19618. }
  19619. interface LinesMesh {
  19620. /**
  19621. * Enables the edge rendering mode on the mesh.
  19622. * This mode makes the mesh edges visible
  19623. * @param epsilon defines the maximal distance between two angles to detect a face
  19624. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19625. * @returns the currentAbstractMesh
  19626. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19627. */
  19628. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19629. }
  19630. interface InstancedLinesMesh {
  19631. /**
  19632. * Enables the edge rendering mode on the mesh.
  19633. * This mode makes the mesh edges visible
  19634. * @param epsilon defines the maximal distance between two angles to detect a face
  19635. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19636. * @returns the current InstancedLinesMesh
  19637. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19638. */
  19639. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19640. }
  19641. /**
  19642. * Defines the minimum contract an Edges renderer should follow.
  19643. */
  19644. export interface IEdgesRenderer extends IDisposable {
  19645. /**
  19646. * Gets or sets a boolean indicating if the edgesRenderer is active
  19647. */
  19648. isEnabled: boolean;
  19649. /**
  19650. * Renders the edges of the attached mesh,
  19651. */
  19652. render(): void;
  19653. /**
  19654. * Checks wether or not the edges renderer is ready to render.
  19655. * @return true if ready, otherwise false.
  19656. */
  19657. isReady(): boolean;
  19658. }
  19659. /**
  19660. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19661. */
  19662. export class EdgesRenderer implements IEdgesRenderer {
  19663. /**
  19664. * Define the size of the edges with an orthographic camera
  19665. */
  19666. edgesWidthScalerForOrthographic: number;
  19667. /**
  19668. * Define the size of the edges with a perspective camera
  19669. */
  19670. edgesWidthScalerForPerspective: number;
  19671. protected _source: AbstractMesh;
  19672. protected _linesPositions: number[];
  19673. protected _linesNormals: number[];
  19674. protected _linesIndices: number[];
  19675. protected _epsilon: number;
  19676. protected _indicesCount: number;
  19677. protected _lineShader: ShaderMaterial;
  19678. protected _ib: DataBuffer;
  19679. protected _buffers: {
  19680. [key: string]: Nullable<VertexBuffer>;
  19681. };
  19682. protected _checkVerticesInsteadOfIndices: boolean;
  19683. private _meshRebuildObserver;
  19684. private _meshDisposeObserver;
  19685. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19686. isEnabled: boolean;
  19687. /**
  19688. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19689. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19690. * @param source Mesh used to create edges
  19691. * @param epsilon sum of angles in adjacency to check for edge
  19692. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19693. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19694. */
  19695. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19696. protected _prepareRessources(): void;
  19697. /** @hidden */
  19698. _rebuild(): void;
  19699. /**
  19700. * Releases the required resources for the edges renderer
  19701. */
  19702. dispose(): void;
  19703. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19704. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19705. /**
  19706. * Checks if the pair of p0 and p1 is en edge
  19707. * @param faceIndex
  19708. * @param edge
  19709. * @param faceNormals
  19710. * @param p0
  19711. * @param p1
  19712. * @private
  19713. */
  19714. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19715. /**
  19716. * push line into the position, normal and index buffer
  19717. * @protected
  19718. */
  19719. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19720. /**
  19721. * Generates lines edges from adjacencjes
  19722. * @private
  19723. */
  19724. _generateEdgesLines(): void;
  19725. /**
  19726. * Checks wether or not the edges renderer is ready to render.
  19727. * @return true if ready, otherwise false.
  19728. */
  19729. isReady(): boolean;
  19730. /**
  19731. * Renders the edges of the attached mesh,
  19732. */
  19733. render(): void;
  19734. }
  19735. /**
  19736. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19737. */
  19738. export class LineEdgesRenderer extends EdgesRenderer {
  19739. /**
  19740. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19741. * @param source LineMesh used to generate edges
  19742. * @param epsilon not important (specified angle for edge detection)
  19743. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19744. */
  19745. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19746. /**
  19747. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19748. */
  19749. _generateEdgesLines(): void;
  19750. }
  19751. }
  19752. declare module BABYLON {
  19753. /**
  19754. * This represents the object necessary to create a rendering group.
  19755. * This is exclusively used and created by the rendering manager.
  19756. * To modify the behavior, you use the available helpers in your scene or meshes.
  19757. * @hidden
  19758. */
  19759. export class RenderingGroup {
  19760. index: number;
  19761. private static _zeroVector;
  19762. private _scene;
  19763. private _opaqueSubMeshes;
  19764. private _transparentSubMeshes;
  19765. private _alphaTestSubMeshes;
  19766. private _depthOnlySubMeshes;
  19767. private _particleSystems;
  19768. private _spriteManagers;
  19769. private _opaqueSortCompareFn;
  19770. private _alphaTestSortCompareFn;
  19771. private _transparentSortCompareFn;
  19772. private _renderOpaque;
  19773. private _renderAlphaTest;
  19774. private _renderTransparent;
  19775. /** @hidden */
  19776. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19777. onBeforeTransparentRendering: () => void;
  19778. /**
  19779. * Set the opaque sort comparison function.
  19780. * If null the sub meshes will be render in the order they were created
  19781. */
  19782. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19783. /**
  19784. * Set the alpha test sort comparison function.
  19785. * If null the sub meshes will be render in the order they were created
  19786. */
  19787. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19788. /**
  19789. * Set the transparent sort comparison function.
  19790. * If null the sub meshes will be render in the order they were created
  19791. */
  19792. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19793. /**
  19794. * Creates a new rendering group.
  19795. * @param index The rendering group index
  19796. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19797. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19798. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19799. */
  19800. 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>);
  19801. /**
  19802. * Render all the sub meshes contained in the group.
  19803. * @param customRenderFunction Used to override the default render behaviour of the group.
  19804. * @returns true if rendered some submeshes.
  19805. */
  19806. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19807. /**
  19808. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19809. * @param subMeshes The submeshes to render
  19810. */
  19811. private renderOpaqueSorted;
  19812. /**
  19813. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19814. * @param subMeshes The submeshes to render
  19815. */
  19816. private renderAlphaTestSorted;
  19817. /**
  19818. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19819. * @param subMeshes The submeshes to render
  19820. */
  19821. private renderTransparentSorted;
  19822. /**
  19823. * Renders the submeshes in a specified order.
  19824. * @param subMeshes The submeshes to sort before render
  19825. * @param sortCompareFn The comparison function use to sort
  19826. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19827. * @param transparent Specifies to activate blending if true
  19828. */
  19829. private static renderSorted;
  19830. /**
  19831. * Renders the submeshes in the order they were dispatched (no sort applied).
  19832. * @param subMeshes The submeshes to render
  19833. */
  19834. private static renderUnsorted;
  19835. /**
  19836. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19837. * are rendered back to front if in the same alpha index.
  19838. *
  19839. * @param a The first submesh
  19840. * @param b The second submesh
  19841. * @returns The result of the comparison
  19842. */
  19843. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19844. /**
  19845. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19846. * are rendered back to front.
  19847. *
  19848. * @param a The first submesh
  19849. * @param b The second submesh
  19850. * @returns The result of the comparison
  19851. */
  19852. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19853. /**
  19854. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19855. * are rendered front to back (prevent overdraw).
  19856. *
  19857. * @param a The first submesh
  19858. * @param b The second submesh
  19859. * @returns The result of the comparison
  19860. */
  19861. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19862. /**
  19863. * Resets the different lists of submeshes to prepare a new frame.
  19864. */
  19865. prepare(): void;
  19866. dispose(): void;
  19867. /**
  19868. * Inserts the submesh in its correct queue depending on its material.
  19869. * @param subMesh The submesh to dispatch
  19870. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19871. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19872. */
  19873. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19874. dispatchSprites(spriteManager: ISpriteManager): void;
  19875. dispatchParticles(particleSystem: IParticleSystem): void;
  19876. private _renderParticles;
  19877. private _renderSprites;
  19878. }
  19879. }
  19880. declare module BABYLON {
  19881. /**
  19882. * Interface describing the different options available in the rendering manager
  19883. * regarding Auto Clear between groups.
  19884. */
  19885. export interface IRenderingManagerAutoClearSetup {
  19886. /**
  19887. * Defines whether or not autoclear is enable.
  19888. */
  19889. autoClear: boolean;
  19890. /**
  19891. * Defines whether or not to autoclear the depth buffer.
  19892. */
  19893. depth: boolean;
  19894. /**
  19895. * Defines whether or not to autoclear the stencil buffer.
  19896. */
  19897. stencil: boolean;
  19898. }
  19899. /**
  19900. * This class is used by the onRenderingGroupObservable
  19901. */
  19902. export class RenderingGroupInfo {
  19903. /**
  19904. * The Scene that being rendered
  19905. */
  19906. scene: Scene;
  19907. /**
  19908. * The camera currently used for the rendering pass
  19909. */
  19910. camera: Nullable<Camera>;
  19911. /**
  19912. * The ID of the renderingGroup being processed
  19913. */
  19914. renderingGroupId: number;
  19915. }
  19916. /**
  19917. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19918. * It is enable to manage the different groups as well as the different necessary sort functions.
  19919. * This should not be used directly aside of the few static configurations
  19920. */
  19921. export class RenderingManager {
  19922. /**
  19923. * The max id used for rendering groups (not included)
  19924. */
  19925. static MAX_RENDERINGGROUPS: number;
  19926. /**
  19927. * The min id used for rendering groups (included)
  19928. */
  19929. static MIN_RENDERINGGROUPS: number;
  19930. /**
  19931. * Used to globally prevent autoclearing scenes.
  19932. */
  19933. static AUTOCLEAR: boolean;
  19934. /**
  19935. * @hidden
  19936. */
  19937. _useSceneAutoClearSetup: boolean;
  19938. private _scene;
  19939. private _renderingGroups;
  19940. private _depthStencilBufferAlreadyCleaned;
  19941. private _autoClearDepthStencil;
  19942. private _customOpaqueSortCompareFn;
  19943. private _customAlphaTestSortCompareFn;
  19944. private _customTransparentSortCompareFn;
  19945. private _renderingGroupInfo;
  19946. /**
  19947. * Instantiates a new rendering group for a particular scene
  19948. * @param scene Defines the scene the groups belongs to
  19949. */
  19950. constructor(scene: Scene);
  19951. private _clearDepthStencilBuffer;
  19952. /**
  19953. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19954. * @hidden
  19955. */
  19956. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19957. /**
  19958. * Resets the different information of the group to prepare a new frame
  19959. * @hidden
  19960. */
  19961. reset(): void;
  19962. /**
  19963. * Dispose and release the group and its associated resources.
  19964. * @hidden
  19965. */
  19966. dispose(): void;
  19967. /**
  19968. * Clear the info related to rendering groups preventing retention points during dispose.
  19969. */
  19970. freeRenderingGroups(): void;
  19971. private _prepareRenderingGroup;
  19972. /**
  19973. * Add a sprite manager to the rendering manager in order to render it this frame.
  19974. * @param spriteManager Define the sprite manager to render
  19975. */
  19976. dispatchSprites(spriteManager: ISpriteManager): void;
  19977. /**
  19978. * Add a particle system to the rendering manager in order to render it this frame.
  19979. * @param particleSystem Define the particle system to render
  19980. */
  19981. dispatchParticles(particleSystem: IParticleSystem): void;
  19982. /**
  19983. * Add a submesh to the manager in order to render it this frame
  19984. * @param subMesh The submesh to dispatch
  19985. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19986. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19987. */
  19988. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19989. /**
  19990. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19991. * This allowed control for front to back rendering or reversly depending of the special needs.
  19992. *
  19993. * @param renderingGroupId The rendering group id corresponding to its index
  19994. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19995. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19996. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19997. */
  19998. 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;
  19999. /**
  20000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20001. *
  20002. * @param renderingGroupId The rendering group id corresponding to its index
  20003. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20004. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20005. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20006. */
  20007. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20008. /**
  20009. * Gets the current auto clear configuration for one rendering group of the rendering
  20010. * manager.
  20011. * @param index the rendering group index to get the information for
  20012. * @returns The auto clear setup for the requested rendering group
  20013. */
  20014. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20015. }
  20016. }
  20017. declare module BABYLON {
  20018. /**
  20019. * This Helps creating a texture that will be created from a camera in your scene.
  20020. * It is basically a dynamic texture that could be used to create special effects for instance.
  20021. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20022. */
  20023. export class RenderTargetTexture extends Texture {
  20024. isCube: boolean;
  20025. /**
  20026. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20027. */
  20028. static readonly REFRESHRATE_RENDER_ONCE: number;
  20029. /**
  20030. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20031. */
  20032. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20033. /**
  20034. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20035. * the central point of your effect and can save a lot of performances.
  20036. */
  20037. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20038. /**
  20039. * Use this predicate to dynamically define the list of mesh you want to render.
  20040. * If set, the renderList property will be overwritten.
  20041. */
  20042. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20043. private _renderList;
  20044. /**
  20045. * Use this list to define the list of mesh you want to render.
  20046. */
  20047. renderList: Nullable<Array<AbstractMesh>>;
  20048. private _hookArray;
  20049. /**
  20050. * Define if particles should be rendered in your texture.
  20051. */
  20052. renderParticles: boolean;
  20053. /**
  20054. * Define if sprites should be rendered in your texture.
  20055. */
  20056. renderSprites: boolean;
  20057. /**
  20058. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20059. */
  20060. coordinatesMode: number;
  20061. /**
  20062. * Define the camera used to render the texture.
  20063. */
  20064. activeCamera: Nullable<Camera>;
  20065. /**
  20066. * Override the render function of the texture with your own one.
  20067. */
  20068. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20069. /**
  20070. * Define if camera post processes should be use while rendering the texture.
  20071. */
  20072. useCameraPostProcesses: boolean;
  20073. /**
  20074. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20075. */
  20076. ignoreCameraViewport: boolean;
  20077. private _postProcessManager;
  20078. private _postProcesses;
  20079. private _resizeObserver;
  20080. /**
  20081. * An event triggered when the texture is unbind.
  20082. */
  20083. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20084. /**
  20085. * An event triggered when the texture is unbind.
  20086. */
  20087. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20088. private _onAfterUnbindObserver;
  20089. /**
  20090. * Set a after unbind callback in the texture.
  20091. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20092. */
  20093. onAfterUnbind: () => void;
  20094. /**
  20095. * An event triggered before rendering the texture
  20096. */
  20097. onBeforeRenderObservable: Observable<number>;
  20098. private _onBeforeRenderObserver;
  20099. /**
  20100. * Set a before render callback in the texture.
  20101. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20102. */
  20103. onBeforeRender: (faceIndex: number) => void;
  20104. /**
  20105. * An event triggered after rendering the texture
  20106. */
  20107. onAfterRenderObservable: Observable<number>;
  20108. private _onAfterRenderObserver;
  20109. /**
  20110. * Set a after render callback in the texture.
  20111. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20112. */
  20113. onAfterRender: (faceIndex: number) => void;
  20114. /**
  20115. * An event triggered after the texture clear
  20116. */
  20117. onClearObservable: Observable<Engine>;
  20118. private _onClearObserver;
  20119. /**
  20120. * Set a clear callback in the texture.
  20121. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20122. */
  20123. onClear: (Engine: Engine) => void;
  20124. /**
  20125. * An event triggered when the texture is resized.
  20126. */
  20127. onResizeObservable: Observable<RenderTargetTexture>;
  20128. /**
  20129. * Define the clear color of the Render Target if it should be different from the scene.
  20130. */
  20131. clearColor: Color4;
  20132. protected _size: number | {
  20133. width: number;
  20134. height: number;
  20135. };
  20136. protected _initialSizeParameter: number | {
  20137. width: number;
  20138. height: number;
  20139. } | {
  20140. ratio: number;
  20141. };
  20142. protected _sizeRatio: Nullable<number>;
  20143. /** @hidden */
  20144. _generateMipMaps: boolean;
  20145. protected _renderingManager: RenderingManager;
  20146. /** @hidden */
  20147. _waitingRenderList: string[];
  20148. protected _doNotChangeAspectRatio: boolean;
  20149. protected _currentRefreshId: number;
  20150. protected _refreshRate: number;
  20151. protected _textureMatrix: Matrix;
  20152. protected _samples: number;
  20153. protected _renderTargetOptions: RenderTargetCreationOptions;
  20154. /**
  20155. * Gets render target creation options that were used.
  20156. */
  20157. readonly renderTargetOptions: RenderTargetCreationOptions;
  20158. protected _engine: Engine;
  20159. protected _onRatioRescale(): void;
  20160. /**
  20161. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20162. * It must define where the camera used to render the texture is set
  20163. */
  20164. boundingBoxPosition: Vector3;
  20165. private _boundingBoxSize;
  20166. /**
  20167. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20168. * When defined, the cubemap will switch to local mode
  20169. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20170. * @example https://www.babylonjs-playground.com/#RNASML
  20171. */
  20172. boundingBoxSize: Vector3;
  20173. /**
  20174. * In case the RTT has been created with a depth texture, get the associated
  20175. * depth texture.
  20176. * Otherwise, return null.
  20177. */
  20178. depthStencilTexture: Nullable<InternalTexture>;
  20179. /**
  20180. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20181. * or used a shadow, depth texture...
  20182. * @param name The friendly name of the texture
  20183. * @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)
  20184. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20185. * @param generateMipMaps True if mip maps need to be generated after render.
  20186. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20187. * @param type The type of the buffer in the RTT (int, half float, float...)
  20188. * @param isCube True if a cube texture needs to be created
  20189. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20190. * @param generateDepthBuffer True to generate a depth buffer
  20191. * @param generateStencilBuffer True to generate a stencil buffer
  20192. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20193. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20194. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20195. */
  20196. constructor(name: string, size: number | {
  20197. width: number;
  20198. height: number;
  20199. } | {
  20200. ratio: number;
  20201. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20202. /**
  20203. * Creates a depth stencil texture.
  20204. * This is only available in WebGL 2 or with the depth texture extension available.
  20205. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20206. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20207. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20208. */
  20209. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20210. private _processSizeParameter;
  20211. /**
  20212. * Define the number of samples to use in case of MSAA.
  20213. * It defaults to one meaning no MSAA has been enabled.
  20214. */
  20215. samples: number;
  20216. /**
  20217. * Resets the refresh counter of the texture and start bak from scratch.
  20218. * Could be useful to regenerate the texture if it is setup to render only once.
  20219. */
  20220. resetRefreshCounter(): void;
  20221. /**
  20222. * Define the refresh rate of the texture or the rendering frequency.
  20223. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20224. */
  20225. refreshRate: number;
  20226. /**
  20227. * Adds a post process to the render target rendering passes.
  20228. * @param postProcess define the post process to add
  20229. */
  20230. addPostProcess(postProcess: PostProcess): void;
  20231. /**
  20232. * Clear all the post processes attached to the render target
  20233. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20234. */
  20235. clearPostProcesses(dispose?: boolean): void;
  20236. /**
  20237. * Remove one of the post process from the list of attached post processes to the texture
  20238. * @param postProcess define the post process to remove from the list
  20239. */
  20240. removePostProcess(postProcess: PostProcess): void;
  20241. /** @hidden */
  20242. _shouldRender(): boolean;
  20243. /**
  20244. * Gets the actual render size of the texture.
  20245. * @returns the width of the render size
  20246. */
  20247. getRenderSize(): number;
  20248. /**
  20249. * Gets the actual render width of the texture.
  20250. * @returns the width of the render size
  20251. */
  20252. getRenderWidth(): number;
  20253. /**
  20254. * Gets the actual render height of the texture.
  20255. * @returns the height of the render size
  20256. */
  20257. getRenderHeight(): number;
  20258. /**
  20259. * Get if the texture can be rescaled or not.
  20260. */
  20261. readonly canRescale: boolean;
  20262. /**
  20263. * Resize the texture using a ratio.
  20264. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20265. */
  20266. scale(ratio: number): void;
  20267. /**
  20268. * Get the texture reflection matrix used to rotate/transform the reflection.
  20269. * @returns the reflection matrix
  20270. */
  20271. getReflectionTextureMatrix(): Matrix;
  20272. /**
  20273. * Resize the texture to a new desired size.
  20274. * Be carrefull as it will recreate all the data in the new texture.
  20275. * @param size Define the new size. It can be:
  20276. * - a number for squared texture,
  20277. * - an object containing { width: number, height: number }
  20278. * - or an object containing a ratio { ratio: number }
  20279. */
  20280. resize(size: number | {
  20281. width: number;
  20282. height: number;
  20283. } | {
  20284. ratio: number;
  20285. }): void;
  20286. /**
  20287. * Renders all the objects from the render list into the texture.
  20288. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20289. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20290. */
  20291. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20292. private _bestReflectionRenderTargetDimension;
  20293. /**
  20294. * @hidden
  20295. * @param faceIndex face index to bind to if this is a cubetexture
  20296. */
  20297. _bindFrameBuffer(faceIndex?: number): void;
  20298. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20299. private renderToTarget;
  20300. /**
  20301. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20302. * This allowed control for front to back rendering or reversly depending of the special needs.
  20303. *
  20304. * @param renderingGroupId The rendering group id corresponding to its index
  20305. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20306. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20307. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20308. */
  20309. 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;
  20310. /**
  20311. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20312. *
  20313. * @param renderingGroupId The rendering group id corresponding to its index
  20314. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20315. */
  20316. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20317. /**
  20318. * Clones the texture.
  20319. * @returns the cloned texture
  20320. */
  20321. clone(): RenderTargetTexture;
  20322. /**
  20323. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20324. * @returns The JSON representation of the texture
  20325. */
  20326. serialize(): any;
  20327. /**
  20328. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20329. */
  20330. disposeFramebufferObjects(): void;
  20331. /**
  20332. * Dispose the texture and release its associated resources.
  20333. */
  20334. dispose(): void;
  20335. /** @hidden */
  20336. _rebuild(): void;
  20337. /**
  20338. * Clear the info related to rendering groups preventing retention point in material dispose.
  20339. */
  20340. freeRenderingGroups(): void;
  20341. /**
  20342. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20343. * @returns the view count
  20344. */
  20345. getViewCount(): number;
  20346. }
  20347. }
  20348. declare module BABYLON {
  20349. /**
  20350. * Options for compiling materials.
  20351. */
  20352. export interface IMaterialCompilationOptions {
  20353. /**
  20354. * Defines whether clip planes are enabled.
  20355. */
  20356. clipPlane: boolean;
  20357. /**
  20358. * Defines whether instances are enabled.
  20359. */
  20360. useInstances: boolean;
  20361. }
  20362. /**
  20363. * Base class for the main features of a material in Babylon.js
  20364. */
  20365. export class Material implements IAnimatable {
  20366. /**
  20367. * Returns the triangle fill mode
  20368. */
  20369. static readonly TriangleFillMode: number;
  20370. /**
  20371. * Returns the wireframe mode
  20372. */
  20373. static readonly WireFrameFillMode: number;
  20374. /**
  20375. * Returns the point fill mode
  20376. */
  20377. static readonly PointFillMode: number;
  20378. /**
  20379. * Returns the point list draw mode
  20380. */
  20381. static readonly PointListDrawMode: number;
  20382. /**
  20383. * Returns the line list draw mode
  20384. */
  20385. static readonly LineListDrawMode: number;
  20386. /**
  20387. * Returns the line loop draw mode
  20388. */
  20389. static readonly LineLoopDrawMode: number;
  20390. /**
  20391. * Returns the line strip draw mode
  20392. */
  20393. static readonly LineStripDrawMode: number;
  20394. /**
  20395. * Returns the triangle strip draw mode
  20396. */
  20397. static readonly TriangleStripDrawMode: number;
  20398. /**
  20399. * Returns the triangle fan draw mode
  20400. */
  20401. static readonly TriangleFanDrawMode: number;
  20402. /**
  20403. * Stores the clock-wise side orientation
  20404. */
  20405. static readonly ClockWiseSideOrientation: number;
  20406. /**
  20407. * Stores the counter clock-wise side orientation
  20408. */
  20409. static readonly CounterClockWiseSideOrientation: number;
  20410. /**
  20411. * The dirty texture flag value
  20412. */
  20413. static readonly TextureDirtyFlag: number;
  20414. /**
  20415. * The dirty light flag value
  20416. */
  20417. static readonly LightDirtyFlag: number;
  20418. /**
  20419. * The dirty fresnel flag value
  20420. */
  20421. static readonly FresnelDirtyFlag: number;
  20422. /**
  20423. * The dirty attribute flag value
  20424. */
  20425. static readonly AttributesDirtyFlag: number;
  20426. /**
  20427. * The dirty misc flag value
  20428. */
  20429. static readonly MiscDirtyFlag: number;
  20430. /**
  20431. * The all dirty flag value
  20432. */
  20433. static readonly AllDirtyFlag: number;
  20434. /**
  20435. * The ID of the material
  20436. */
  20437. id: string;
  20438. /**
  20439. * Gets or sets the unique id of the material
  20440. */
  20441. uniqueId: number;
  20442. /**
  20443. * The name of the material
  20444. */
  20445. name: string;
  20446. /**
  20447. * Gets or sets user defined metadata
  20448. */
  20449. metadata: any;
  20450. /**
  20451. * For internal use only. Please do not use.
  20452. */
  20453. reservedDataStore: any;
  20454. /**
  20455. * Specifies if the ready state should be checked on each call
  20456. */
  20457. checkReadyOnEveryCall: boolean;
  20458. /**
  20459. * Specifies if the ready state should be checked once
  20460. */
  20461. checkReadyOnlyOnce: boolean;
  20462. /**
  20463. * The state of the material
  20464. */
  20465. state: string;
  20466. /**
  20467. * The alpha value of the material
  20468. */
  20469. protected _alpha: number;
  20470. /**
  20471. * List of inspectable custom properties (used by the Inspector)
  20472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20473. */
  20474. inspectableCustomProperties: IInspectable[];
  20475. /**
  20476. * Sets the alpha value of the material
  20477. */
  20478. /**
  20479. * Gets the alpha value of the material
  20480. */
  20481. alpha: number;
  20482. /**
  20483. * Specifies if back face culling is enabled
  20484. */
  20485. protected _backFaceCulling: boolean;
  20486. /**
  20487. * Sets the back-face culling state
  20488. */
  20489. /**
  20490. * Gets the back-face culling state
  20491. */
  20492. backFaceCulling: boolean;
  20493. /**
  20494. * Stores the value for side orientation
  20495. */
  20496. sideOrientation: number;
  20497. /**
  20498. * Callback triggered when the material is compiled
  20499. */
  20500. onCompiled: Nullable<(effect: Effect) => void>;
  20501. /**
  20502. * Callback triggered when an error occurs
  20503. */
  20504. onError: Nullable<(effect: Effect, errors: string) => void>;
  20505. /**
  20506. * Callback triggered to get the render target textures
  20507. */
  20508. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20509. /**
  20510. * Gets a boolean indicating that current material needs to register RTT
  20511. */
  20512. readonly hasRenderTargetTextures: boolean;
  20513. /**
  20514. * Specifies if the material should be serialized
  20515. */
  20516. doNotSerialize: boolean;
  20517. /**
  20518. * @hidden
  20519. */
  20520. _storeEffectOnSubMeshes: boolean;
  20521. /**
  20522. * Stores the animations for the material
  20523. */
  20524. animations: Nullable<Array<Animation>>;
  20525. /**
  20526. * An event triggered when the material is disposed
  20527. */
  20528. onDisposeObservable: Observable<Material>;
  20529. /**
  20530. * An observer which watches for dispose events
  20531. */
  20532. private _onDisposeObserver;
  20533. private _onUnBindObservable;
  20534. /**
  20535. * Called during a dispose event
  20536. */
  20537. onDispose: () => void;
  20538. private _onBindObservable;
  20539. /**
  20540. * An event triggered when the material is bound
  20541. */
  20542. readonly onBindObservable: Observable<AbstractMesh>;
  20543. /**
  20544. * An observer which watches for bind events
  20545. */
  20546. private _onBindObserver;
  20547. /**
  20548. * Called during a bind event
  20549. */
  20550. onBind: (Mesh: AbstractMesh) => void;
  20551. /**
  20552. * An event triggered when the material is unbound
  20553. */
  20554. readonly onUnBindObservable: Observable<Material>;
  20555. /**
  20556. * Stores the value of the alpha mode
  20557. */
  20558. private _alphaMode;
  20559. /**
  20560. * Sets the value of the alpha mode.
  20561. *
  20562. * | Value | Type | Description |
  20563. * | --- | --- | --- |
  20564. * | 0 | ALPHA_DISABLE | |
  20565. * | 1 | ALPHA_ADD | |
  20566. * | 2 | ALPHA_COMBINE | |
  20567. * | 3 | ALPHA_SUBTRACT | |
  20568. * | 4 | ALPHA_MULTIPLY | |
  20569. * | 5 | ALPHA_MAXIMIZED | |
  20570. * | 6 | ALPHA_ONEONE | |
  20571. * | 7 | ALPHA_PREMULTIPLIED | |
  20572. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20573. * | 9 | ALPHA_INTERPOLATE | |
  20574. * | 10 | ALPHA_SCREENMODE | |
  20575. *
  20576. */
  20577. /**
  20578. * Gets the value of the alpha mode
  20579. */
  20580. alphaMode: number;
  20581. /**
  20582. * Stores the state of the need depth pre-pass value
  20583. */
  20584. private _needDepthPrePass;
  20585. /**
  20586. * Sets the need depth pre-pass value
  20587. */
  20588. /**
  20589. * Gets the depth pre-pass value
  20590. */
  20591. needDepthPrePass: boolean;
  20592. /**
  20593. * Specifies if depth writing should be disabled
  20594. */
  20595. disableDepthWrite: boolean;
  20596. /**
  20597. * Specifies if depth writing should be forced
  20598. */
  20599. forceDepthWrite: boolean;
  20600. /**
  20601. * Specifies the depth function that should be used. 0 means the default engine function
  20602. */
  20603. depthFunction: number;
  20604. /**
  20605. * Specifies if there should be a separate pass for culling
  20606. */
  20607. separateCullingPass: boolean;
  20608. /**
  20609. * Stores the state specifing if fog should be enabled
  20610. */
  20611. private _fogEnabled;
  20612. /**
  20613. * Sets the state for enabling fog
  20614. */
  20615. /**
  20616. * Gets the value of the fog enabled state
  20617. */
  20618. fogEnabled: boolean;
  20619. /**
  20620. * Stores the size of points
  20621. */
  20622. pointSize: number;
  20623. /**
  20624. * Stores the z offset value
  20625. */
  20626. zOffset: number;
  20627. /**
  20628. * Gets a value specifying if wireframe mode is enabled
  20629. */
  20630. /**
  20631. * Sets the state of wireframe mode
  20632. */
  20633. wireframe: boolean;
  20634. /**
  20635. * Gets the value specifying if point clouds are enabled
  20636. */
  20637. /**
  20638. * Sets the state of point cloud mode
  20639. */
  20640. pointsCloud: boolean;
  20641. /**
  20642. * Gets the material fill mode
  20643. */
  20644. /**
  20645. * Sets the material fill mode
  20646. */
  20647. fillMode: number;
  20648. /**
  20649. * @hidden
  20650. * Stores the effects for the material
  20651. */
  20652. _effect: Nullable<Effect>;
  20653. /**
  20654. * @hidden
  20655. * Specifies if the material was previously ready
  20656. */
  20657. _wasPreviouslyReady: boolean;
  20658. /**
  20659. * Specifies if uniform buffers should be used
  20660. */
  20661. private _useUBO;
  20662. /**
  20663. * Stores a reference to the scene
  20664. */
  20665. private _scene;
  20666. /**
  20667. * Stores the fill mode state
  20668. */
  20669. private _fillMode;
  20670. /**
  20671. * Specifies if the depth write state should be cached
  20672. */
  20673. private _cachedDepthWriteState;
  20674. /**
  20675. * Specifies if the depth function state should be cached
  20676. */
  20677. private _cachedDepthFunctionState;
  20678. /**
  20679. * Stores the uniform buffer
  20680. */
  20681. protected _uniformBuffer: UniformBuffer;
  20682. /** @hidden */
  20683. _indexInSceneMaterialArray: number;
  20684. /** @hidden */
  20685. meshMap: Nullable<{
  20686. [id: string]: AbstractMesh | undefined;
  20687. }>;
  20688. /**
  20689. * Creates a material instance
  20690. * @param name defines the name of the material
  20691. * @param scene defines the scene to reference
  20692. * @param doNotAdd specifies if the material should be added to the scene
  20693. */
  20694. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20695. /**
  20696. * Returns a string representation of the current material
  20697. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20698. * @returns a string with material information
  20699. */
  20700. toString(fullDetails?: boolean): string;
  20701. /**
  20702. * Gets the class name of the material
  20703. * @returns a string with the class name of the material
  20704. */
  20705. getClassName(): string;
  20706. /**
  20707. * Specifies if updates for the material been locked
  20708. */
  20709. readonly isFrozen: boolean;
  20710. /**
  20711. * Locks updates for the material
  20712. */
  20713. freeze(): void;
  20714. /**
  20715. * Unlocks updates for the material
  20716. */
  20717. unfreeze(): void;
  20718. /**
  20719. * Specifies if the material is ready to be used
  20720. * @param mesh defines the mesh to check
  20721. * @param useInstances specifies if instances should be used
  20722. * @returns a boolean indicating if the material is ready to be used
  20723. */
  20724. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20725. /**
  20726. * Specifies that the submesh is ready to be used
  20727. * @param mesh defines the mesh to check
  20728. * @param subMesh defines which submesh to check
  20729. * @param useInstances specifies that instances should be used
  20730. * @returns a boolean indicating that the submesh is ready or not
  20731. */
  20732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20733. /**
  20734. * Returns the material effect
  20735. * @returns the effect associated with the material
  20736. */
  20737. getEffect(): Nullable<Effect>;
  20738. /**
  20739. * Returns the current scene
  20740. * @returns a Scene
  20741. */
  20742. getScene(): Scene;
  20743. /**
  20744. * Specifies if the material will require alpha blending
  20745. * @returns a boolean specifying if alpha blending is needed
  20746. */
  20747. needAlphaBlending(): boolean;
  20748. /**
  20749. * Specifies if the mesh will require alpha blending
  20750. * @param mesh defines the mesh to check
  20751. * @returns a boolean specifying if alpha blending is needed for the mesh
  20752. */
  20753. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20754. /**
  20755. * Specifies if this material should be rendered in alpha test mode
  20756. * @returns a boolean specifying if an alpha test is needed.
  20757. */
  20758. needAlphaTesting(): boolean;
  20759. /**
  20760. * Gets the texture used for the alpha test
  20761. * @returns the texture to use for alpha testing
  20762. */
  20763. getAlphaTestTexture(): Nullable<BaseTexture>;
  20764. /**
  20765. * Marks the material to indicate that it needs to be re-calculated
  20766. */
  20767. markDirty(): void;
  20768. /** @hidden */
  20769. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20770. /**
  20771. * Binds the material to the mesh
  20772. * @param world defines the world transformation matrix
  20773. * @param mesh defines the mesh to bind the material to
  20774. */
  20775. bind(world: Matrix, mesh?: Mesh): void;
  20776. /**
  20777. * Binds the submesh to the material
  20778. * @param world defines the world transformation matrix
  20779. * @param mesh defines the mesh containing the submesh
  20780. * @param subMesh defines the submesh to bind the material to
  20781. */
  20782. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20783. /**
  20784. * Binds the world matrix to the material
  20785. * @param world defines the world transformation matrix
  20786. */
  20787. bindOnlyWorldMatrix(world: Matrix): void;
  20788. /**
  20789. * Binds the scene's uniform buffer to the effect.
  20790. * @param effect defines the effect to bind to the scene uniform buffer
  20791. * @param sceneUbo defines the uniform buffer storing scene data
  20792. */
  20793. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20794. /**
  20795. * Binds the view matrix to the effect
  20796. * @param effect defines the effect to bind the view matrix to
  20797. */
  20798. bindView(effect: Effect): void;
  20799. /**
  20800. * Binds the view projection matrix to the effect
  20801. * @param effect defines the effect to bind the view projection matrix to
  20802. */
  20803. bindViewProjection(effect: Effect): void;
  20804. /**
  20805. * Specifies if material alpha testing should be turned on for the mesh
  20806. * @param mesh defines the mesh to check
  20807. */
  20808. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20809. /**
  20810. * Processes to execute after binding the material to a mesh
  20811. * @param mesh defines the rendered mesh
  20812. */
  20813. protected _afterBind(mesh?: Mesh): void;
  20814. /**
  20815. * Unbinds the material from the mesh
  20816. */
  20817. unbind(): void;
  20818. /**
  20819. * Gets the active textures from the material
  20820. * @returns an array of textures
  20821. */
  20822. getActiveTextures(): BaseTexture[];
  20823. /**
  20824. * Specifies if the material uses a texture
  20825. * @param texture defines the texture to check against the material
  20826. * @returns a boolean specifying if the material uses the texture
  20827. */
  20828. hasTexture(texture: BaseTexture): boolean;
  20829. /**
  20830. * Makes a duplicate of the material, and gives it a new name
  20831. * @param name defines the new name for the duplicated material
  20832. * @returns the cloned material
  20833. */
  20834. clone(name: string): Nullable<Material>;
  20835. /**
  20836. * Gets the meshes bound to the material
  20837. * @returns an array of meshes bound to the material
  20838. */
  20839. getBindedMeshes(): AbstractMesh[];
  20840. /**
  20841. * Force shader compilation
  20842. * @param mesh defines the mesh associated with this material
  20843. * @param onCompiled defines a function to execute once the material is compiled
  20844. * @param options defines the options to configure the compilation
  20845. * @param onError defines a function to execute if the material fails compiling
  20846. */
  20847. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20848. /**
  20849. * Force shader compilation
  20850. * @param mesh defines the mesh that will use this material
  20851. * @param options defines additional options for compiling the shaders
  20852. * @returns a promise that resolves when the compilation completes
  20853. */
  20854. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20855. private static readonly _AllDirtyCallBack;
  20856. private static readonly _ImageProcessingDirtyCallBack;
  20857. private static readonly _TextureDirtyCallBack;
  20858. private static readonly _FresnelDirtyCallBack;
  20859. private static readonly _MiscDirtyCallBack;
  20860. private static readonly _LightsDirtyCallBack;
  20861. private static readonly _AttributeDirtyCallBack;
  20862. private static _FresnelAndMiscDirtyCallBack;
  20863. private static _TextureAndMiscDirtyCallBack;
  20864. private static readonly _DirtyCallbackArray;
  20865. private static readonly _RunDirtyCallBacks;
  20866. /**
  20867. * Marks a define in the material to indicate that it needs to be re-computed
  20868. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20869. */
  20870. markAsDirty(flag: number): void;
  20871. /**
  20872. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20873. * @param func defines a function which checks material defines against the submeshes
  20874. */
  20875. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20876. /**
  20877. * Indicates that we need to re-calculated for all submeshes
  20878. */
  20879. protected _markAllSubMeshesAsAllDirty(): void;
  20880. /**
  20881. * Indicates that image processing needs to be re-calculated for all submeshes
  20882. */
  20883. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20884. /**
  20885. * Indicates that textures need to be re-calculated for all submeshes
  20886. */
  20887. protected _markAllSubMeshesAsTexturesDirty(): void;
  20888. /**
  20889. * Indicates that fresnel needs to be re-calculated for all submeshes
  20890. */
  20891. protected _markAllSubMeshesAsFresnelDirty(): void;
  20892. /**
  20893. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20894. */
  20895. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20896. /**
  20897. * Indicates that lights need to be re-calculated for all submeshes
  20898. */
  20899. protected _markAllSubMeshesAsLightsDirty(): void;
  20900. /**
  20901. * Indicates that attributes need to be re-calculated for all submeshes
  20902. */
  20903. protected _markAllSubMeshesAsAttributesDirty(): void;
  20904. /**
  20905. * Indicates that misc needs to be re-calculated for all submeshes
  20906. */
  20907. protected _markAllSubMeshesAsMiscDirty(): void;
  20908. /**
  20909. * Indicates that textures and misc need to be re-calculated for all submeshes
  20910. */
  20911. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20912. /**
  20913. * Disposes the material
  20914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20915. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20916. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20917. */
  20918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20919. /** @hidden */
  20920. private releaseVertexArrayObject;
  20921. /**
  20922. * Serializes this material
  20923. * @returns the serialized material object
  20924. */
  20925. serialize(): any;
  20926. /**
  20927. * Creates a material from parsed material data
  20928. * @param parsedMaterial defines parsed material data
  20929. * @param scene defines the hosting scene
  20930. * @param rootUrl defines the root URL to use to load textures
  20931. * @returns a new material
  20932. */
  20933. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20934. }
  20935. }
  20936. declare module BABYLON {
  20937. /**
  20938. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20939. * separate meshes. This can be use to improve performances.
  20940. * @see http://doc.babylonjs.com/how_to/multi_materials
  20941. */
  20942. export class MultiMaterial extends Material {
  20943. private _subMaterials;
  20944. /**
  20945. * Gets or Sets the list of Materials used within the multi material.
  20946. * They need to be ordered according to the submeshes order in the associated mesh
  20947. */
  20948. subMaterials: Nullable<Material>[];
  20949. /**
  20950. * Function used to align with Node.getChildren()
  20951. * @returns the list of Materials used within the multi material
  20952. */
  20953. getChildren(): Nullable<Material>[];
  20954. /**
  20955. * Instantiates a new Multi Material
  20956. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20957. * separate meshes. This can be use to improve performances.
  20958. * @see http://doc.babylonjs.com/how_to/multi_materials
  20959. * @param name Define the name in the scene
  20960. * @param scene Define the scene the material belongs to
  20961. */
  20962. constructor(name: string, scene: Scene);
  20963. private _hookArray;
  20964. /**
  20965. * Get one of the submaterial by its index in the submaterials array
  20966. * @param index The index to look the sub material at
  20967. * @returns The Material if the index has been defined
  20968. */
  20969. getSubMaterial(index: number): Nullable<Material>;
  20970. /**
  20971. * Get the list of active textures for the whole sub materials list.
  20972. * @returns All the textures that will be used during the rendering
  20973. */
  20974. getActiveTextures(): BaseTexture[];
  20975. /**
  20976. * Gets the current class name of the material e.g. "MultiMaterial"
  20977. * Mainly use in serialization.
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Checks if the material is ready to render the requested sub mesh
  20983. * @param mesh Define the mesh the submesh belongs to
  20984. * @param subMesh Define the sub mesh to look readyness for
  20985. * @param useInstances Define whether or not the material is used with instances
  20986. * @returns true if ready, otherwise false
  20987. */
  20988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20989. /**
  20990. * Clones the current material and its related sub materials
  20991. * @param name Define the name of the newly cloned material
  20992. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20993. * @returns the cloned material
  20994. */
  20995. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20996. /**
  20997. * Serializes the materials into a JSON representation.
  20998. * @returns the JSON representation
  20999. */
  21000. serialize(): any;
  21001. /**
  21002. * Dispose the material and release its associated resources
  21003. * @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)
  21004. * @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)
  21005. * @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)
  21006. */
  21007. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21008. /**
  21009. * Creates a MultiMaterial from parsed MultiMaterial data.
  21010. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21011. * @param scene defines the hosting scene
  21012. * @returns a new MultiMaterial
  21013. */
  21014. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Base class for submeshes
  21020. */
  21021. export class BaseSubMesh {
  21022. /** @hidden */
  21023. _materialDefines: Nullable<MaterialDefines>;
  21024. /** @hidden */
  21025. _materialEffect: Nullable<Effect>;
  21026. /**
  21027. * Gets associated effect
  21028. */
  21029. readonly effect: Nullable<Effect>;
  21030. /**
  21031. * Sets associated effect (effect used to render this submesh)
  21032. * @param effect defines the effect to associate with
  21033. * @param defines defines the set of defines used to compile this effect
  21034. */
  21035. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21036. }
  21037. /**
  21038. * Defines a subdivision inside a mesh
  21039. */
  21040. export class SubMesh extends BaseSubMesh implements ICullable {
  21041. /** the material index to use */
  21042. materialIndex: number;
  21043. /** vertex index start */
  21044. verticesStart: number;
  21045. /** vertices count */
  21046. verticesCount: number;
  21047. /** index start */
  21048. indexStart: number;
  21049. /** indices count */
  21050. indexCount: number;
  21051. /** @hidden */
  21052. _linesIndexCount: number;
  21053. private _mesh;
  21054. private _renderingMesh;
  21055. private _boundingInfo;
  21056. private _linesIndexBuffer;
  21057. /** @hidden */
  21058. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21059. /** @hidden */
  21060. _trianglePlanes: Plane[];
  21061. /** @hidden */
  21062. _lastColliderTransformMatrix: Nullable<Matrix>;
  21063. /** @hidden */
  21064. _renderId: number;
  21065. /** @hidden */
  21066. _alphaIndex: number;
  21067. /** @hidden */
  21068. _distanceToCamera: number;
  21069. /** @hidden */
  21070. _id: number;
  21071. private _currentMaterial;
  21072. /**
  21073. * Add a new submesh to a mesh
  21074. * @param materialIndex defines the material index to use
  21075. * @param verticesStart defines vertex index start
  21076. * @param verticesCount defines vertices count
  21077. * @param indexStart defines index start
  21078. * @param indexCount defines indices count
  21079. * @param mesh defines the parent mesh
  21080. * @param renderingMesh defines an optional rendering mesh
  21081. * @param createBoundingBox defines if bounding box should be created for this submesh
  21082. * @returns the new submesh
  21083. */
  21084. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21085. /**
  21086. * Creates a new submesh
  21087. * @param materialIndex defines the material index to use
  21088. * @param verticesStart defines vertex index start
  21089. * @param verticesCount defines vertices count
  21090. * @param indexStart defines index start
  21091. * @param indexCount defines indices count
  21092. * @param mesh defines the parent mesh
  21093. * @param renderingMesh defines an optional rendering mesh
  21094. * @param createBoundingBox defines if bounding box should be created for this submesh
  21095. */
  21096. constructor(
  21097. /** the material index to use */
  21098. materialIndex: number,
  21099. /** vertex index start */
  21100. verticesStart: number,
  21101. /** vertices count */
  21102. verticesCount: number,
  21103. /** index start */
  21104. indexStart: number,
  21105. /** indices count */
  21106. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21107. /**
  21108. * Returns true if this submesh covers the entire parent mesh
  21109. * @ignorenaming
  21110. */
  21111. readonly IsGlobal: boolean;
  21112. /**
  21113. * Returns the submesh BoudingInfo object
  21114. * @returns current bounding info (or mesh's one if the submesh is global)
  21115. */
  21116. getBoundingInfo(): BoundingInfo;
  21117. /**
  21118. * Sets the submesh BoundingInfo
  21119. * @param boundingInfo defines the new bounding info to use
  21120. * @returns the SubMesh
  21121. */
  21122. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21123. /**
  21124. * Returns the mesh of the current submesh
  21125. * @return the parent mesh
  21126. */
  21127. getMesh(): AbstractMesh;
  21128. /**
  21129. * Returns the rendering mesh of the submesh
  21130. * @returns the rendering mesh (could be different from parent mesh)
  21131. */
  21132. getRenderingMesh(): Mesh;
  21133. /**
  21134. * Returns the submesh material
  21135. * @returns null or the current material
  21136. */
  21137. getMaterial(): Nullable<Material>;
  21138. /**
  21139. * Sets a new updated BoundingInfo object to the submesh
  21140. * @param data defines an optional position array to use to determine the bounding info
  21141. * @returns the SubMesh
  21142. */
  21143. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21144. /** @hidden */
  21145. _checkCollision(collider: Collider): boolean;
  21146. /**
  21147. * Updates the submesh BoundingInfo
  21148. * @param world defines the world matrix to use to update the bounding info
  21149. * @returns the submesh
  21150. */
  21151. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21152. /**
  21153. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21154. * @param frustumPlanes defines the frustum planes
  21155. * @returns true if the submesh is intersecting with the frustum
  21156. */
  21157. isInFrustum(frustumPlanes: Plane[]): boolean;
  21158. /**
  21159. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21160. * @param frustumPlanes defines the frustum planes
  21161. * @returns true if the submesh is inside the frustum
  21162. */
  21163. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21164. /**
  21165. * Renders the submesh
  21166. * @param enableAlphaMode defines if alpha needs to be used
  21167. * @returns the submesh
  21168. */
  21169. render(enableAlphaMode: boolean): SubMesh;
  21170. /**
  21171. * @hidden
  21172. */
  21173. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21174. /**
  21175. * Checks if the submesh intersects with a ray
  21176. * @param ray defines the ray to test
  21177. * @returns true is the passed ray intersects the submesh bounding box
  21178. */
  21179. canIntersects(ray: Ray): boolean;
  21180. /**
  21181. * Intersects current submesh with a ray
  21182. * @param ray defines the ray to test
  21183. * @param positions defines mesh's positions array
  21184. * @param indices defines mesh's indices array
  21185. * @param fastCheck defines if only bounding info should be used
  21186. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21187. * @returns intersection info or null if no intersection
  21188. */
  21189. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21190. /** @hidden */
  21191. private _intersectLines;
  21192. /** @hidden */
  21193. private _intersectUnIndexedLines;
  21194. /** @hidden */
  21195. private _intersectTriangles;
  21196. /** @hidden */
  21197. private _intersectUnIndexedTriangles;
  21198. /** @hidden */
  21199. _rebuild(): void;
  21200. /**
  21201. * Creates a new submesh from the passed mesh
  21202. * @param newMesh defines the new hosting mesh
  21203. * @param newRenderingMesh defines an optional rendering mesh
  21204. * @returns the new submesh
  21205. */
  21206. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21207. /**
  21208. * Release associated resources
  21209. */
  21210. dispose(): void;
  21211. /**
  21212. * Gets the class name
  21213. * @returns the string "SubMesh".
  21214. */
  21215. getClassName(): string;
  21216. /**
  21217. * Creates a new submesh from indices data
  21218. * @param materialIndex the index of the main mesh material
  21219. * @param startIndex the index where to start the copy in the mesh indices array
  21220. * @param indexCount the number of indices to copy then from the startIndex
  21221. * @param mesh the main mesh to create the submesh from
  21222. * @param renderingMesh the optional rendering mesh
  21223. * @returns a new submesh
  21224. */
  21225. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21226. }
  21227. }
  21228. declare module BABYLON {
  21229. /**
  21230. * Class used to represent data loading progression
  21231. */
  21232. export class SceneLoaderFlags {
  21233. private static _ForceFullSceneLoadingForIncremental;
  21234. private static _ShowLoadingScreen;
  21235. private static _CleanBoneMatrixWeights;
  21236. private static _loggingLevel;
  21237. /**
  21238. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21239. */
  21240. static ForceFullSceneLoadingForIncremental: boolean;
  21241. /**
  21242. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21243. */
  21244. static ShowLoadingScreen: boolean;
  21245. /**
  21246. * Defines the current logging level (while loading the scene)
  21247. * @ignorenaming
  21248. */
  21249. static loggingLevel: number;
  21250. /**
  21251. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21252. */
  21253. static CleanBoneMatrixWeights: boolean;
  21254. }
  21255. }
  21256. declare module BABYLON {
  21257. /**
  21258. * Class used to store geometry data (vertex buffers + index buffer)
  21259. */
  21260. export class Geometry implements IGetSetVerticesData {
  21261. /**
  21262. * Gets or sets the ID of the geometry
  21263. */
  21264. id: string;
  21265. /**
  21266. * Gets or sets the unique ID of the geometry
  21267. */
  21268. uniqueId: number;
  21269. /**
  21270. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21271. */
  21272. delayLoadState: number;
  21273. /**
  21274. * Gets the file containing the data to load when running in delay load state
  21275. */
  21276. delayLoadingFile: Nullable<string>;
  21277. /**
  21278. * Callback called when the geometry is updated
  21279. */
  21280. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21281. private _scene;
  21282. private _engine;
  21283. private _meshes;
  21284. private _totalVertices;
  21285. /** @hidden */
  21286. _indices: IndicesArray;
  21287. /** @hidden */
  21288. _vertexBuffers: {
  21289. [key: string]: VertexBuffer;
  21290. };
  21291. private _isDisposed;
  21292. private _extend;
  21293. private _boundingBias;
  21294. /** @hidden */
  21295. _delayInfo: Array<string>;
  21296. private _indexBuffer;
  21297. private _indexBufferIsUpdatable;
  21298. /** @hidden */
  21299. _boundingInfo: Nullable<BoundingInfo>;
  21300. /** @hidden */
  21301. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21302. /** @hidden */
  21303. _softwareSkinningFrameId: number;
  21304. private _vertexArrayObjects;
  21305. private _updatable;
  21306. /** @hidden */
  21307. _positions: Nullable<Vector3[]>;
  21308. /**
  21309. * 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
  21310. */
  21311. /**
  21312. * 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
  21313. */
  21314. boundingBias: Vector2;
  21315. /**
  21316. * Static function used to attach a new empty geometry to a mesh
  21317. * @param mesh defines the mesh to attach the geometry to
  21318. * @returns the new Geometry
  21319. */
  21320. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21321. /**
  21322. * Creates a new geometry
  21323. * @param id defines the unique ID
  21324. * @param scene defines the hosting scene
  21325. * @param vertexData defines the VertexData used to get geometry data
  21326. * @param updatable defines if geometry must be updatable (false by default)
  21327. * @param mesh defines the mesh that will be associated with the geometry
  21328. */
  21329. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21330. /**
  21331. * Gets the current extend of the geometry
  21332. */
  21333. readonly extend: {
  21334. minimum: Vector3;
  21335. maximum: Vector3;
  21336. };
  21337. /**
  21338. * Gets the hosting scene
  21339. * @returns the hosting Scene
  21340. */
  21341. getScene(): Scene;
  21342. /**
  21343. * Gets the hosting engine
  21344. * @returns the hosting Engine
  21345. */
  21346. getEngine(): Engine;
  21347. /**
  21348. * Defines if the geometry is ready to use
  21349. * @returns true if the geometry is ready to be used
  21350. */
  21351. isReady(): boolean;
  21352. /**
  21353. * Gets a value indicating that the geometry should not be serialized
  21354. */
  21355. readonly doNotSerialize: boolean;
  21356. /** @hidden */
  21357. _rebuild(): void;
  21358. /**
  21359. * Affects all geometry data in one call
  21360. * @param vertexData defines the geometry data
  21361. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21362. */
  21363. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21364. /**
  21365. * Set specific vertex data
  21366. * @param kind defines the data kind (Position, normal, etc...)
  21367. * @param data defines the vertex data to use
  21368. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21369. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21370. */
  21371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21372. /**
  21373. * Removes a specific vertex data
  21374. * @param kind defines the data kind (Position, normal, etc...)
  21375. */
  21376. removeVerticesData(kind: string): void;
  21377. /**
  21378. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21379. * @param buffer defines the vertex buffer to use
  21380. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21381. */
  21382. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21383. /**
  21384. * Update a specific vertex buffer
  21385. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21386. * It will do nothing if the buffer is not updatable
  21387. * @param kind defines the data kind (Position, normal, etc...)
  21388. * @param data defines the data to use
  21389. * @param offset defines the offset in the target buffer where to store the data
  21390. * @param useBytes set to true if the offset is in bytes
  21391. */
  21392. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21393. /**
  21394. * Update a specific vertex buffer
  21395. * This function will create a new buffer if the current one is not updatable
  21396. * @param kind defines the data kind (Position, normal, etc...)
  21397. * @param data defines the data to use
  21398. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21399. */
  21400. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21401. private _updateBoundingInfo;
  21402. /** @hidden */
  21403. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21404. /**
  21405. * Gets total number of vertices
  21406. * @returns the total number of vertices
  21407. */
  21408. getTotalVertices(): number;
  21409. /**
  21410. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21411. * @param kind defines the data kind (Position, normal, etc...)
  21412. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21413. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21414. * @returns a float array containing vertex data
  21415. */
  21416. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21417. /**
  21418. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21419. * @param kind defines the data kind (Position, normal, etc...)
  21420. * @returns true if the vertex buffer with the specified kind is updatable
  21421. */
  21422. isVertexBufferUpdatable(kind: string): boolean;
  21423. /**
  21424. * Gets a specific vertex buffer
  21425. * @param kind defines the data kind (Position, normal, etc...)
  21426. * @returns a VertexBuffer
  21427. */
  21428. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21429. /**
  21430. * Returns all vertex buffers
  21431. * @return an object holding all vertex buffers indexed by kind
  21432. */
  21433. getVertexBuffers(): Nullable<{
  21434. [key: string]: VertexBuffer;
  21435. }>;
  21436. /**
  21437. * Gets a boolean indicating if specific vertex buffer is present
  21438. * @param kind defines the data kind (Position, normal, etc...)
  21439. * @returns true if data is present
  21440. */
  21441. isVerticesDataPresent(kind: string): boolean;
  21442. /**
  21443. * Gets a list of all attached data kinds (Position, normal, etc...)
  21444. * @returns a list of string containing all kinds
  21445. */
  21446. getVerticesDataKinds(): string[];
  21447. /**
  21448. * Update index buffer
  21449. * @param indices defines the indices to store in the index buffer
  21450. * @param offset defines the offset in the target buffer where to store the data
  21451. * @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)
  21452. */
  21453. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21454. /**
  21455. * Creates a new index buffer
  21456. * @param indices defines the indices to store in the index buffer
  21457. * @param totalVertices defines the total number of vertices (could be null)
  21458. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21459. */
  21460. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21461. /**
  21462. * Return the total number of indices
  21463. * @returns the total number of indices
  21464. */
  21465. getTotalIndices(): number;
  21466. /**
  21467. * Gets the index buffer array
  21468. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21469. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21470. * @returns the index buffer array
  21471. */
  21472. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21473. /**
  21474. * Gets the index buffer
  21475. * @return the index buffer
  21476. */
  21477. getIndexBuffer(): Nullable<DataBuffer>;
  21478. /** @hidden */
  21479. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21480. /**
  21481. * Release the associated resources for a specific mesh
  21482. * @param mesh defines the source mesh
  21483. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21484. */
  21485. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21486. /**
  21487. * Apply current geometry to a given mesh
  21488. * @param mesh defines the mesh to apply geometry to
  21489. */
  21490. applyToMesh(mesh: Mesh): void;
  21491. private _updateExtend;
  21492. private _applyToMesh;
  21493. private notifyUpdate;
  21494. /**
  21495. * Load the geometry if it was flagged as delay loaded
  21496. * @param scene defines the hosting scene
  21497. * @param onLoaded defines a callback called when the geometry is loaded
  21498. */
  21499. load(scene: Scene, onLoaded?: () => void): void;
  21500. private _queueLoad;
  21501. /**
  21502. * Invert the geometry to move from a right handed system to a left handed one.
  21503. */
  21504. toLeftHanded(): void;
  21505. /** @hidden */
  21506. _resetPointsArrayCache(): void;
  21507. /** @hidden */
  21508. _generatePointsArray(): boolean;
  21509. /**
  21510. * Gets a value indicating if the geometry is disposed
  21511. * @returns true if the geometry was disposed
  21512. */
  21513. isDisposed(): boolean;
  21514. private _disposeVertexArrayObjects;
  21515. /**
  21516. * Free all associated resources
  21517. */
  21518. dispose(): void;
  21519. /**
  21520. * Clone the current geometry into a new geometry
  21521. * @param id defines the unique ID of the new geometry
  21522. * @returns a new geometry object
  21523. */
  21524. copy(id: string): Geometry;
  21525. /**
  21526. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21527. * @return a JSON representation of the current geometry data (without the vertices data)
  21528. */
  21529. serialize(): any;
  21530. private toNumberArray;
  21531. /**
  21532. * Serialize all vertices data into a JSON oject
  21533. * @returns a JSON representation of the current geometry data
  21534. */
  21535. serializeVerticeData(): any;
  21536. /**
  21537. * Extracts a clone of a mesh geometry
  21538. * @param mesh defines the source mesh
  21539. * @param id defines the unique ID of the new geometry object
  21540. * @returns the new geometry object
  21541. */
  21542. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21543. /**
  21544. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21545. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21546. * Be aware Math.random() could cause collisions, but:
  21547. * "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"
  21548. * @returns a string containing a new GUID
  21549. */
  21550. static RandomId(): string;
  21551. /** @hidden */
  21552. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21553. private static _CleanMatricesWeights;
  21554. /**
  21555. * Create a new geometry from persisted data (Using .babylon file format)
  21556. * @param parsedVertexData defines the persisted data
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21559. * @returns the new geometry object
  21560. */
  21561. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21562. }
  21563. }
  21564. declare module BABYLON {
  21565. /**
  21566. * Define an interface for all classes that will get and set the data on vertices
  21567. */
  21568. export interface IGetSetVerticesData {
  21569. /**
  21570. * Gets a boolean indicating if specific vertex data is present
  21571. * @param kind defines the vertex data kind to use
  21572. * @returns true is data kind is present
  21573. */
  21574. isVerticesDataPresent(kind: string): boolean;
  21575. /**
  21576. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21577. * @param kind defines the data kind (Position, normal, etc...)
  21578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21580. * @returns a float array containing vertex data
  21581. */
  21582. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21583. /**
  21584. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21585. * @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.
  21586. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21587. * @returns the indices array or an empty array if the mesh has no geometry
  21588. */
  21589. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21590. /**
  21591. * Set specific vertex data
  21592. * @param kind defines the data kind (Position, normal, etc...)
  21593. * @param data defines the vertex data to use
  21594. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21595. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21596. */
  21597. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21598. /**
  21599. * Update a specific associated vertex buffer
  21600. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21601. * - VertexBuffer.PositionKind
  21602. * - VertexBuffer.UVKind
  21603. * - VertexBuffer.UV2Kind
  21604. * - VertexBuffer.UV3Kind
  21605. * - VertexBuffer.UV4Kind
  21606. * - VertexBuffer.UV5Kind
  21607. * - VertexBuffer.UV6Kind
  21608. * - VertexBuffer.ColorKind
  21609. * - VertexBuffer.MatricesIndicesKind
  21610. * - VertexBuffer.MatricesIndicesExtraKind
  21611. * - VertexBuffer.MatricesWeightsKind
  21612. * - VertexBuffer.MatricesWeightsExtraKind
  21613. * @param data defines the data source
  21614. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21615. * @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)
  21616. */
  21617. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21618. /**
  21619. * Creates a new index buffer
  21620. * @param indices defines the indices to store in the index buffer
  21621. * @param totalVertices defines the total number of vertices (could be null)
  21622. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21623. */
  21624. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21625. }
  21626. /**
  21627. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21628. */
  21629. export class VertexData {
  21630. /**
  21631. * Mesh side orientation : usually the external or front surface
  21632. */
  21633. static readonly FRONTSIDE: number;
  21634. /**
  21635. * Mesh side orientation : usually the internal or back surface
  21636. */
  21637. static readonly BACKSIDE: number;
  21638. /**
  21639. * Mesh side orientation : both internal and external or front and back surfaces
  21640. */
  21641. static readonly DOUBLESIDE: number;
  21642. /**
  21643. * Mesh side orientation : by default, `FRONTSIDE`
  21644. */
  21645. static readonly DEFAULTSIDE: number;
  21646. /**
  21647. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21648. */
  21649. positions: Nullable<FloatArray>;
  21650. /**
  21651. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21652. */
  21653. normals: Nullable<FloatArray>;
  21654. /**
  21655. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21656. */
  21657. tangents: Nullable<FloatArray>;
  21658. /**
  21659. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21660. */
  21661. uvs: Nullable<FloatArray>;
  21662. /**
  21663. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21664. */
  21665. uvs2: Nullable<FloatArray>;
  21666. /**
  21667. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21668. */
  21669. uvs3: Nullable<FloatArray>;
  21670. /**
  21671. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21672. */
  21673. uvs4: Nullable<FloatArray>;
  21674. /**
  21675. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21676. */
  21677. uvs5: Nullable<FloatArray>;
  21678. /**
  21679. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21680. */
  21681. uvs6: Nullable<FloatArray>;
  21682. /**
  21683. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21684. */
  21685. colors: Nullable<FloatArray>;
  21686. /**
  21687. * 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).
  21688. */
  21689. matricesIndices: Nullable<FloatArray>;
  21690. /**
  21691. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21692. */
  21693. matricesWeights: Nullable<FloatArray>;
  21694. /**
  21695. * An array extending the number of possible indices
  21696. */
  21697. matricesIndicesExtra: Nullable<FloatArray>;
  21698. /**
  21699. * An array extending the number of possible weights when the number of indices is extended
  21700. */
  21701. matricesWeightsExtra: Nullable<FloatArray>;
  21702. /**
  21703. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21704. */
  21705. indices: Nullable<IndicesArray>;
  21706. /**
  21707. * Uses the passed data array to set the set the values for the specified kind of data
  21708. * @param data a linear array of floating numbers
  21709. * @param kind the type of data that is being set, eg positions, colors etc
  21710. */
  21711. set(data: FloatArray, kind: string): void;
  21712. /**
  21713. * Associates the vertexData to the passed Mesh.
  21714. * Sets it as updatable or not (default `false`)
  21715. * @param mesh the mesh the vertexData is applied to
  21716. * @param updatable when used and having the value true allows new data to update the vertexData
  21717. * @returns the VertexData
  21718. */
  21719. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21720. /**
  21721. * Associates the vertexData to the passed Geometry.
  21722. * Sets it as updatable or not (default `false`)
  21723. * @param geometry the geometry the vertexData is applied to
  21724. * @param updatable when used and having the value true allows new data to update the vertexData
  21725. * @returns VertexData
  21726. */
  21727. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21728. /**
  21729. * Updates the associated mesh
  21730. * @param mesh the mesh to be updated
  21731. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21732. * @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
  21733. * @returns VertexData
  21734. */
  21735. updateMesh(mesh: Mesh): VertexData;
  21736. /**
  21737. * Updates the associated geometry
  21738. * @param geometry the geometry to be updated
  21739. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21740. * @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
  21741. * @returns VertexData.
  21742. */
  21743. updateGeometry(geometry: Geometry): VertexData;
  21744. private _applyTo;
  21745. private _update;
  21746. /**
  21747. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21748. * @param matrix the transforming matrix
  21749. * @returns the VertexData
  21750. */
  21751. transform(matrix: Matrix): VertexData;
  21752. /**
  21753. * Merges the passed VertexData into the current one
  21754. * @param other the VertexData to be merged into the current one
  21755. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21756. * @returns the modified VertexData
  21757. */
  21758. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21759. private _mergeElement;
  21760. private _validate;
  21761. /**
  21762. * Serializes the VertexData
  21763. * @returns a serialized object
  21764. */
  21765. serialize(): any;
  21766. /**
  21767. * Extracts the vertexData from a mesh
  21768. * @param mesh the mesh from which to extract the VertexData
  21769. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21770. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21771. * @returns the object VertexData associated to the passed mesh
  21772. */
  21773. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21774. /**
  21775. * Extracts the vertexData from the geometry
  21776. * @param geometry the geometry from which to extract the VertexData
  21777. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21778. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21779. * @returns the object VertexData associated to the passed mesh
  21780. */
  21781. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21782. private static _ExtractFrom;
  21783. /**
  21784. * Creates the VertexData for a Ribbon
  21785. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21786. * * pathArray array of paths, each of which an array of successive Vector3
  21787. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21788. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21789. * * 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
  21790. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21791. * * 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)
  21792. * * 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)
  21793. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21794. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21795. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21796. * @returns the VertexData of the ribbon
  21797. */
  21798. static CreateRibbon(options: {
  21799. pathArray: Vector3[][];
  21800. closeArray?: boolean;
  21801. closePath?: boolean;
  21802. offset?: number;
  21803. sideOrientation?: number;
  21804. frontUVs?: Vector4;
  21805. backUVs?: Vector4;
  21806. invertUV?: boolean;
  21807. uvs?: Vector2[];
  21808. colors?: Color4[];
  21809. }): VertexData;
  21810. /**
  21811. * Creates the VertexData for a box
  21812. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21813. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21814. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21815. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21816. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21817. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21818. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21820. * * 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)
  21821. * * 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)
  21822. * @returns the VertexData of the box
  21823. */
  21824. static CreateBox(options: {
  21825. size?: number;
  21826. width?: number;
  21827. height?: number;
  21828. depth?: number;
  21829. faceUV?: Vector4[];
  21830. faceColors?: Color4[];
  21831. sideOrientation?: number;
  21832. frontUVs?: Vector4;
  21833. backUVs?: Vector4;
  21834. }): VertexData;
  21835. /**
  21836. * Creates the VertexData for a tiled box
  21837. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21838. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21839. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21840. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21842. * @returns the VertexData of the box
  21843. */
  21844. static CreateTiledBox(options: {
  21845. pattern?: number;
  21846. width?: number;
  21847. height?: number;
  21848. depth?: number;
  21849. tileSize?: number;
  21850. tileWidth?: number;
  21851. tileHeight?: number;
  21852. alignHorizontal?: number;
  21853. alignVertical?: number;
  21854. faceUV?: Vector4[];
  21855. faceColors?: Color4[];
  21856. sideOrientation?: number;
  21857. }): VertexData;
  21858. /**
  21859. * Creates the VertexData for a tiled plane
  21860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21861. * * pattern a limited pattern arrangement depending on the number
  21862. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21863. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21864. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21865. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21866. * * 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)
  21867. * * 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)
  21868. * @returns the VertexData of the tiled plane
  21869. */
  21870. static CreateTiledPlane(options: {
  21871. pattern?: number;
  21872. tileSize?: number;
  21873. tileWidth?: number;
  21874. tileHeight?: number;
  21875. size?: number;
  21876. width?: number;
  21877. height?: number;
  21878. alignHorizontal?: number;
  21879. alignVertical?: number;
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }): VertexData;
  21884. /**
  21885. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21887. * * segments sets the number of horizontal strips optional, default 32
  21888. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21889. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21890. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21891. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21892. * * 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
  21893. * * 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
  21894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21895. * * 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)
  21896. * * 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)
  21897. * @returns the VertexData of the ellipsoid
  21898. */
  21899. static CreateSphere(options: {
  21900. segments?: number;
  21901. diameter?: number;
  21902. diameterX?: number;
  21903. diameterY?: number;
  21904. diameterZ?: number;
  21905. arc?: number;
  21906. slice?: number;
  21907. sideOrientation?: number;
  21908. frontUVs?: Vector4;
  21909. backUVs?: Vector4;
  21910. }): VertexData;
  21911. /**
  21912. * Creates the VertexData for a cylinder, cone or prism
  21913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21914. * * height sets the height (y direction) of the cylinder, optional, default 2
  21915. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21916. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21917. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21918. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21919. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21920. * * 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
  21921. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21922. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21923. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21924. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21926. * * 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)
  21927. * * 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)
  21928. * @returns the VertexData of the cylinder, cone or prism
  21929. */
  21930. static CreateCylinder(options: {
  21931. height?: number;
  21932. diameterTop?: number;
  21933. diameterBottom?: number;
  21934. diameter?: number;
  21935. tessellation?: number;
  21936. subdivisions?: number;
  21937. arc?: number;
  21938. faceColors?: Color4[];
  21939. faceUV?: Vector4[];
  21940. hasRings?: boolean;
  21941. enclose?: boolean;
  21942. sideOrientation?: number;
  21943. frontUVs?: Vector4;
  21944. backUVs?: Vector4;
  21945. }): VertexData;
  21946. /**
  21947. * Creates the VertexData for a torus
  21948. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21949. * * diameter the diameter of the torus, optional default 1
  21950. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21951. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21953. * * 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)
  21954. * * 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)
  21955. * @returns the VertexData of the torus
  21956. */
  21957. static CreateTorus(options: {
  21958. diameter?: number;
  21959. thickness?: number;
  21960. tessellation?: number;
  21961. sideOrientation?: number;
  21962. frontUVs?: Vector4;
  21963. backUVs?: Vector4;
  21964. }): VertexData;
  21965. /**
  21966. * Creates the VertexData of the LineSystem
  21967. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21968. * - lines an array of lines, each line being an array of successive Vector3
  21969. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21970. * @returns the VertexData of the LineSystem
  21971. */
  21972. static CreateLineSystem(options: {
  21973. lines: Vector3[][];
  21974. colors?: Nullable<Color4[][]>;
  21975. }): VertexData;
  21976. /**
  21977. * Create the VertexData for a DashedLines
  21978. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21979. * - points an array successive Vector3
  21980. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21981. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21982. * - dashNb the intended total number of dashes, optional, default 200
  21983. * @returns the VertexData for the DashedLines
  21984. */
  21985. static CreateDashedLines(options: {
  21986. points: Vector3[];
  21987. dashSize?: number;
  21988. gapSize?: number;
  21989. dashNb?: number;
  21990. }): VertexData;
  21991. /**
  21992. * Creates the VertexData for a Ground
  21993. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21994. * - width the width (x direction) of the ground, optional, default 1
  21995. * - height the height (z direction) of the ground, optional, default 1
  21996. * - subdivisions the number of subdivisions per side, optional, default 1
  21997. * @returns the VertexData of the Ground
  21998. */
  21999. static CreateGround(options: {
  22000. width?: number;
  22001. height?: number;
  22002. subdivisions?: number;
  22003. subdivisionsX?: number;
  22004. subdivisionsY?: number;
  22005. }): VertexData;
  22006. /**
  22007. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22008. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22009. * * xmin the ground minimum X coordinate, optional, default -1
  22010. * * zmin the ground minimum Z coordinate, optional, default -1
  22011. * * xmax the ground maximum X coordinate, optional, default 1
  22012. * * zmax the ground maximum Z coordinate, optional, default 1
  22013. * * 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}
  22014. * * 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}
  22015. * @returns the VertexData of the TiledGround
  22016. */
  22017. static CreateTiledGround(options: {
  22018. xmin: number;
  22019. zmin: number;
  22020. xmax: number;
  22021. zmax: number;
  22022. subdivisions?: {
  22023. w: number;
  22024. h: number;
  22025. };
  22026. precision?: {
  22027. w: number;
  22028. h: number;
  22029. };
  22030. }): VertexData;
  22031. /**
  22032. * Creates the VertexData of the Ground designed from a heightmap
  22033. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22034. * * width the width (x direction) of the ground
  22035. * * height the height (z direction) of the ground
  22036. * * subdivisions the number of subdivisions per side
  22037. * * minHeight the minimum altitude on the ground, optional, default 0
  22038. * * maxHeight the maximum altitude on the ground, optional default 1
  22039. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22040. * * buffer the array holding the image color data
  22041. * * bufferWidth the width of image
  22042. * * bufferHeight the height of image
  22043. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22044. * @returns the VertexData of the Ground designed from a heightmap
  22045. */
  22046. static CreateGroundFromHeightMap(options: {
  22047. width: number;
  22048. height: number;
  22049. subdivisions: number;
  22050. minHeight: number;
  22051. maxHeight: number;
  22052. colorFilter: Color3;
  22053. buffer: Uint8Array;
  22054. bufferWidth: number;
  22055. bufferHeight: number;
  22056. alphaFilter: number;
  22057. }): VertexData;
  22058. /**
  22059. * Creates the VertexData for a Plane
  22060. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22061. * * size sets the width and height of the plane to the value of size, optional default 1
  22062. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22063. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22064. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22065. * * 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)
  22066. * * 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)
  22067. * @returns the VertexData of the box
  22068. */
  22069. static CreatePlane(options: {
  22070. size?: number;
  22071. width?: number;
  22072. height?: number;
  22073. sideOrientation?: number;
  22074. frontUVs?: Vector4;
  22075. backUVs?: Vector4;
  22076. }): VertexData;
  22077. /**
  22078. * Creates the VertexData of the Disc or regular Polygon
  22079. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22080. * * radius the radius of the disc, optional default 0.5
  22081. * * tessellation the number of polygon sides, optional, default 64
  22082. * * 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
  22083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22084. * * 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)
  22085. * * 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)
  22086. * @returns the VertexData of the box
  22087. */
  22088. static CreateDisc(options: {
  22089. radius?: number;
  22090. tessellation?: number;
  22091. arc?: number;
  22092. sideOrientation?: number;
  22093. frontUVs?: Vector4;
  22094. backUVs?: Vector4;
  22095. }): VertexData;
  22096. /**
  22097. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22098. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22099. * @param polygon a mesh built from polygonTriangulation.build()
  22100. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22102. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22103. * @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)
  22104. * @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)
  22105. * @returns the VertexData of the Polygon
  22106. */
  22107. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22108. /**
  22109. * Creates the VertexData of the IcoSphere
  22110. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22111. * * radius the radius of the IcoSphere, optional default 1
  22112. * * radiusX allows stretching in the x direction, optional, default radius
  22113. * * radiusY allows stretching in the y direction, optional, default radius
  22114. * * radiusZ allows stretching in the z direction, optional, default radius
  22115. * * flat when true creates a flat shaded mesh, optional, default true
  22116. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22118. * * 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)
  22119. * * 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)
  22120. * @returns the VertexData of the IcoSphere
  22121. */
  22122. static CreateIcoSphere(options: {
  22123. radius?: number;
  22124. radiusX?: number;
  22125. radiusY?: number;
  22126. radiusZ?: number;
  22127. flat?: boolean;
  22128. subdivisions?: number;
  22129. sideOrientation?: number;
  22130. frontUVs?: Vector4;
  22131. backUVs?: Vector4;
  22132. }): VertexData;
  22133. /**
  22134. * Creates the VertexData for a Polyhedron
  22135. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22136. * * type provided types are:
  22137. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22138. * * 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)
  22139. * * size the size of the IcoSphere, optional default 1
  22140. * * sizeX allows stretching in the x direction, optional, default size
  22141. * * sizeY allows stretching in the y direction, optional, default size
  22142. * * sizeZ allows stretching in the z direction, optional, default size
  22143. * * 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
  22144. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22145. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22146. * * flat when true creates a flat shaded mesh, optional, default true
  22147. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22148. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22149. * * 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)
  22150. * * 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)
  22151. * @returns the VertexData of the Polyhedron
  22152. */
  22153. static CreatePolyhedron(options: {
  22154. type?: number;
  22155. size?: number;
  22156. sizeX?: number;
  22157. sizeY?: number;
  22158. sizeZ?: number;
  22159. custom?: any;
  22160. faceUV?: Vector4[];
  22161. faceColors?: Color4[];
  22162. flat?: boolean;
  22163. sideOrientation?: number;
  22164. frontUVs?: Vector4;
  22165. backUVs?: Vector4;
  22166. }): VertexData;
  22167. /**
  22168. * Creates the VertexData for a TorusKnot
  22169. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22170. * * radius the radius of the torus knot, optional, default 2
  22171. * * tube the thickness of the tube, optional, default 0.5
  22172. * * radialSegments the number of sides on each tube segments, optional, default 32
  22173. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22174. * * p the number of windings around the z axis, optional, default 2
  22175. * * q the number of windings around the x axis, optional, default 3
  22176. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22177. * * 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)
  22178. * * 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)
  22179. * @returns the VertexData of the Torus Knot
  22180. */
  22181. static CreateTorusKnot(options: {
  22182. radius?: number;
  22183. tube?: number;
  22184. radialSegments?: number;
  22185. tubularSegments?: number;
  22186. p?: number;
  22187. q?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Compute normals for given positions and indices
  22194. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22195. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22196. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22197. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22198. * * facetNormals : optional array of facet normals (vector3)
  22199. * * facetPositions : optional array of facet positions (vector3)
  22200. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22201. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22202. * * bInfo : optional bounding info, required for facetPartitioning computation
  22203. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22204. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22205. * * useRightHandedSystem: optional boolean to for right handed system computation
  22206. * * depthSort : optional boolean to enable the facet depth sort computation
  22207. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22208. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22209. */
  22210. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22211. facetNormals?: any;
  22212. facetPositions?: any;
  22213. facetPartitioning?: any;
  22214. ratio?: number;
  22215. bInfo?: any;
  22216. bbSize?: Vector3;
  22217. subDiv?: any;
  22218. useRightHandedSystem?: boolean;
  22219. depthSort?: boolean;
  22220. distanceTo?: Vector3;
  22221. depthSortedFacets?: any;
  22222. }): void;
  22223. /** @hidden */
  22224. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22225. /**
  22226. * Applies VertexData created from the imported parameters to the geometry
  22227. * @param parsedVertexData the parsed data from an imported file
  22228. * @param geometry the geometry to apply the VertexData to
  22229. */
  22230. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22231. }
  22232. }
  22233. declare module BABYLON {
  22234. /**
  22235. * Defines a target to use with MorphTargetManager
  22236. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22237. */
  22238. export class MorphTarget implements IAnimatable {
  22239. /** defines the name of the target */
  22240. name: string;
  22241. /**
  22242. * Gets or sets the list of animations
  22243. */
  22244. animations: Animation[];
  22245. private _scene;
  22246. private _positions;
  22247. private _normals;
  22248. private _tangents;
  22249. private _uvs;
  22250. private _influence;
  22251. private _uniqueId;
  22252. /**
  22253. * Observable raised when the influence changes
  22254. */
  22255. onInfluenceChanged: Observable<boolean>;
  22256. /** @hidden */
  22257. _onDataLayoutChanged: Observable<void>;
  22258. /**
  22259. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22260. */
  22261. influence: number;
  22262. /**
  22263. * Gets or sets the id of the morph Target
  22264. */
  22265. id: string;
  22266. private _animationPropertiesOverride;
  22267. /**
  22268. * Gets or sets the animation properties override
  22269. */
  22270. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22271. /**
  22272. * Creates a new MorphTarget
  22273. * @param name defines the name of the target
  22274. * @param influence defines the influence to use
  22275. * @param scene defines the scene the morphtarget belongs to
  22276. */
  22277. constructor(
  22278. /** defines the name of the target */
  22279. name: string, influence?: number, scene?: Nullable<Scene>);
  22280. /**
  22281. * Gets the unique ID of this manager
  22282. */
  22283. readonly uniqueId: number;
  22284. /**
  22285. * Gets a boolean defining if the target contains position data
  22286. */
  22287. readonly hasPositions: boolean;
  22288. /**
  22289. * Gets a boolean defining if the target contains normal data
  22290. */
  22291. readonly hasNormals: boolean;
  22292. /**
  22293. * Gets a boolean defining if the target contains tangent data
  22294. */
  22295. readonly hasTangents: boolean;
  22296. /**
  22297. * Gets a boolean defining if the target contains texture coordinates data
  22298. */
  22299. readonly hasUVs: boolean;
  22300. /**
  22301. * Affects position data to this target
  22302. * @param data defines the position data to use
  22303. */
  22304. setPositions(data: Nullable<FloatArray>): void;
  22305. /**
  22306. * Gets the position data stored in this target
  22307. * @returns a FloatArray containing the position data (or null if not present)
  22308. */
  22309. getPositions(): Nullable<FloatArray>;
  22310. /**
  22311. * Affects normal data to this target
  22312. * @param data defines the normal data to use
  22313. */
  22314. setNormals(data: Nullable<FloatArray>): void;
  22315. /**
  22316. * Gets the normal data stored in this target
  22317. * @returns a FloatArray containing the normal data (or null if not present)
  22318. */
  22319. getNormals(): Nullable<FloatArray>;
  22320. /**
  22321. * Affects tangent data to this target
  22322. * @param data defines the tangent data to use
  22323. */
  22324. setTangents(data: Nullable<FloatArray>): void;
  22325. /**
  22326. * Gets the tangent data stored in this target
  22327. * @returns a FloatArray containing the tangent data (or null if not present)
  22328. */
  22329. getTangents(): Nullable<FloatArray>;
  22330. /**
  22331. * Affects texture coordinates data to this target
  22332. * @param data defines the texture coordinates data to use
  22333. */
  22334. setUVs(data: Nullable<FloatArray>): void;
  22335. /**
  22336. * Gets the texture coordinates data stored in this target
  22337. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22338. */
  22339. getUVs(): Nullable<FloatArray>;
  22340. /**
  22341. * Clone the current target
  22342. * @returns a new MorphTarget
  22343. */
  22344. clone(): MorphTarget;
  22345. /**
  22346. * Serializes the current target into a Serialization object
  22347. * @returns the serialized object
  22348. */
  22349. serialize(): any;
  22350. /**
  22351. * Returns the string "MorphTarget"
  22352. * @returns "MorphTarget"
  22353. */
  22354. getClassName(): string;
  22355. /**
  22356. * Creates a new target from serialized data
  22357. * @param serializationObject defines the serialized data to use
  22358. * @returns a new MorphTarget
  22359. */
  22360. static Parse(serializationObject: any): MorphTarget;
  22361. /**
  22362. * Creates a MorphTarget from mesh data
  22363. * @param mesh defines the source mesh
  22364. * @param name defines the name to use for the new target
  22365. * @param influence defines the influence to attach to the target
  22366. * @returns a new MorphTarget
  22367. */
  22368. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22369. }
  22370. }
  22371. declare module BABYLON {
  22372. /**
  22373. * This class is used to deform meshes using morphing between different targets
  22374. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22375. */
  22376. export class MorphTargetManager {
  22377. private _targets;
  22378. private _targetInfluenceChangedObservers;
  22379. private _targetDataLayoutChangedObservers;
  22380. private _activeTargets;
  22381. private _scene;
  22382. private _influences;
  22383. private _supportsNormals;
  22384. private _supportsTangents;
  22385. private _supportsUVs;
  22386. private _vertexCount;
  22387. private _uniqueId;
  22388. private _tempInfluences;
  22389. /**
  22390. * Gets or sets a boolean indicating if normals must be morphed
  22391. */
  22392. enableNormalMorphing: boolean;
  22393. /**
  22394. * Gets or sets a boolean indicating if tangents must be morphed
  22395. */
  22396. enableTangentMorphing: boolean;
  22397. /**
  22398. * Gets or sets a boolean indicating if UV must be morphed
  22399. */
  22400. enableUVMorphing: boolean;
  22401. /**
  22402. * Creates a new MorphTargetManager
  22403. * @param scene defines the current scene
  22404. */
  22405. constructor(scene?: Nullable<Scene>);
  22406. /**
  22407. * Gets the unique ID of this manager
  22408. */
  22409. readonly uniqueId: number;
  22410. /**
  22411. * Gets the number of vertices handled by this manager
  22412. */
  22413. readonly vertexCount: number;
  22414. /**
  22415. * Gets a boolean indicating if this manager supports morphing of normals
  22416. */
  22417. readonly supportsNormals: boolean;
  22418. /**
  22419. * Gets a boolean indicating if this manager supports morphing of tangents
  22420. */
  22421. readonly supportsTangents: boolean;
  22422. /**
  22423. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22424. */
  22425. readonly supportsUVs: boolean;
  22426. /**
  22427. * Gets the number of targets stored in this manager
  22428. */
  22429. readonly numTargets: number;
  22430. /**
  22431. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22432. */
  22433. readonly numInfluencers: number;
  22434. /**
  22435. * Gets the list of influences (one per target)
  22436. */
  22437. readonly influences: Float32Array;
  22438. /**
  22439. * Gets the active target at specified index. An active target is a target with an influence > 0
  22440. * @param index defines the index to check
  22441. * @returns the requested target
  22442. */
  22443. getActiveTarget(index: number): MorphTarget;
  22444. /**
  22445. * Gets the target at specified index
  22446. * @param index defines the index to check
  22447. * @returns the requested target
  22448. */
  22449. getTarget(index: number): MorphTarget;
  22450. /**
  22451. * Add a new target to this manager
  22452. * @param target defines the target to add
  22453. */
  22454. addTarget(target: MorphTarget): void;
  22455. /**
  22456. * Removes a target from the manager
  22457. * @param target defines the target to remove
  22458. */
  22459. removeTarget(target: MorphTarget): void;
  22460. /**
  22461. * Clone the current manager
  22462. * @returns a new MorphTargetManager
  22463. */
  22464. clone(): MorphTargetManager;
  22465. /**
  22466. * Serializes the current manager into a Serialization object
  22467. * @returns the serialized object
  22468. */
  22469. serialize(): any;
  22470. private _syncActiveTargets;
  22471. /**
  22472. * Syncrhonize the targets with all the meshes using this morph target manager
  22473. */
  22474. synchronize(): void;
  22475. /**
  22476. * Creates a new MorphTargetManager from serialized data
  22477. * @param serializationObject defines the serialized data
  22478. * @param scene defines the hosting scene
  22479. * @returns the new MorphTargetManager
  22480. */
  22481. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22482. }
  22483. }
  22484. declare module BABYLON {
  22485. /**
  22486. * Class used to represent a specific level of detail of a mesh
  22487. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22488. */
  22489. export class MeshLODLevel {
  22490. /** Defines the distance where this level should start being displayed */
  22491. distance: number;
  22492. /** Defines the mesh to use to render this level */
  22493. mesh: Nullable<Mesh>;
  22494. /**
  22495. * Creates a new LOD level
  22496. * @param distance defines the distance where this level should star being displayed
  22497. * @param mesh defines the mesh to use to render this level
  22498. */
  22499. constructor(
  22500. /** Defines the distance where this level should start being displayed */
  22501. distance: number,
  22502. /** Defines the mesh to use to render this level */
  22503. mesh: Nullable<Mesh>);
  22504. }
  22505. }
  22506. declare module BABYLON {
  22507. /**
  22508. * Mesh representing the gorund
  22509. */
  22510. export class GroundMesh extends Mesh {
  22511. /** If octree should be generated */
  22512. generateOctree: boolean;
  22513. private _heightQuads;
  22514. /** @hidden */
  22515. _subdivisionsX: number;
  22516. /** @hidden */
  22517. _subdivisionsY: number;
  22518. /** @hidden */
  22519. _width: number;
  22520. /** @hidden */
  22521. _height: number;
  22522. /** @hidden */
  22523. _minX: number;
  22524. /** @hidden */
  22525. _maxX: number;
  22526. /** @hidden */
  22527. _minZ: number;
  22528. /** @hidden */
  22529. _maxZ: number;
  22530. constructor(name: string, scene: Scene);
  22531. /**
  22532. * "GroundMesh"
  22533. * @returns "GroundMesh"
  22534. */
  22535. getClassName(): string;
  22536. /**
  22537. * The minimum of x and y subdivisions
  22538. */
  22539. readonly subdivisions: number;
  22540. /**
  22541. * X subdivisions
  22542. */
  22543. readonly subdivisionsX: number;
  22544. /**
  22545. * Y subdivisions
  22546. */
  22547. readonly subdivisionsY: number;
  22548. /**
  22549. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22550. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22551. * @param chunksCount the number of subdivisions for x and y
  22552. * @param octreeBlocksSize (Default: 32)
  22553. */
  22554. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22555. /**
  22556. * Returns a height (y) value in the Worl system :
  22557. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22558. * @param x x coordinate
  22559. * @param z z coordinate
  22560. * @returns the ground y position if (x, z) are outside the ground surface.
  22561. */
  22562. getHeightAtCoordinates(x: number, z: number): number;
  22563. /**
  22564. * Returns a normalized vector (Vector3) orthogonal to the ground
  22565. * at the ground coordinates (x, z) expressed in the World system.
  22566. * @param x x coordinate
  22567. * @param z z coordinate
  22568. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22569. */
  22570. getNormalAtCoordinates(x: number, z: number): Vector3;
  22571. /**
  22572. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22573. * at the ground coordinates (x, z) expressed in the World system.
  22574. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22575. * @param x x coordinate
  22576. * @param z z coordinate
  22577. * @param ref vector to store the result
  22578. * @returns the GroundMesh.
  22579. */
  22580. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22581. /**
  22582. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22583. * if the ground has been updated.
  22584. * This can be used in the render loop.
  22585. * @returns the GroundMesh.
  22586. */
  22587. updateCoordinateHeights(): GroundMesh;
  22588. private _getFacetAt;
  22589. private _initHeightQuads;
  22590. private _computeHeightQuads;
  22591. /**
  22592. * Serializes this ground mesh
  22593. * @param serializationObject object to write serialization to
  22594. */
  22595. serialize(serializationObject: any): void;
  22596. /**
  22597. * Parses a serialized ground mesh
  22598. * @param parsedMesh the serialized mesh
  22599. * @param scene the scene to create the ground mesh in
  22600. * @returns the created ground mesh
  22601. */
  22602. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22603. }
  22604. }
  22605. declare module BABYLON {
  22606. /**
  22607. * Interface for Physics-Joint data
  22608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22609. */
  22610. export interface PhysicsJointData {
  22611. /**
  22612. * The main pivot of the joint
  22613. */
  22614. mainPivot?: Vector3;
  22615. /**
  22616. * The connected pivot of the joint
  22617. */
  22618. connectedPivot?: Vector3;
  22619. /**
  22620. * The main axis of the joint
  22621. */
  22622. mainAxis?: Vector3;
  22623. /**
  22624. * The connected axis of the joint
  22625. */
  22626. connectedAxis?: Vector3;
  22627. /**
  22628. * The collision of the joint
  22629. */
  22630. collision?: boolean;
  22631. /**
  22632. * Native Oimo/Cannon/Energy data
  22633. */
  22634. nativeParams?: any;
  22635. }
  22636. /**
  22637. * This is a holder class for the physics joint created by the physics plugin
  22638. * It holds a set of functions to control the underlying joint
  22639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22640. */
  22641. export class PhysicsJoint {
  22642. /**
  22643. * The type of the physics joint
  22644. */
  22645. type: number;
  22646. /**
  22647. * The data for the physics joint
  22648. */
  22649. jointData: PhysicsJointData;
  22650. private _physicsJoint;
  22651. protected _physicsPlugin: IPhysicsEnginePlugin;
  22652. /**
  22653. * Initializes the physics joint
  22654. * @param type The type of the physics joint
  22655. * @param jointData The data for the physics joint
  22656. */
  22657. constructor(
  22658. /**
  22659. * The type of the physics joint
  22660. */
  22661. type: number,
  22662. /**
  22663. * The data for the physics joint
  22664. */
  22665. jointData: PhysicsJointData);
  22666. /**
  22667. * Gets the physics joint
  22668. */
  22669. /**
  22670. * Sets the physics joint
  22671. */
  22672. physicsJoint: any;
  22673. /**
  22674. * Sets the physics plugin
  22675. */
  22676. physicsPlugin: IPhysicsEnginePlugin;
  22677. /**
  22678. * Execute a function that is physics-plugin specific.
  22679. * @param {Function} func the function that will be executed.
  22680. * It accepts two parameters: the physics world and the physics joint
  22681. */
  22682. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22683. /**
  22684. * Distance-Joint type
  22685. */
  22686. static DistanceJoint: number;
  22687. /**
  22688. * Hinge-Joint type
  22689. */
  22690. static HingeJoint: number;
  22691. /**
  22692. * Ball-and-Socket joint type
  22693. */
  22694. static BallAndSocketJoint: number;
  22695. /**
  22696. * Wheel-Joint type
  22697. */
  22698. static WheelJoint: number;
  22699. /**
  22700. * Slider-Joint type
  22701. */
  22702. static SliderJoint: number;
  22703. /**
  22704. * Prismatic-Joint type
  22705. */
  22706. static PrismaticJoint: number;
  22707. /**
  22708. * Universal-Joint type
  22709. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22710. */
  22711. static UniversalJoint: number;
  22712. /**
  22713. * Hinge-Joint 2 type
  22714. */
  22715. static Hinge2Joint: number;
  22716. /**
  22717. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22718. */
  22719. static PointToPointJoint: number;
  22720. /**
  22721. * Spring-Joint type
  22722. */
  22723. static SpringJoint: number;
  22724. /**
  22725. * Lock-Joint type
  22726. */
  22727. static LockJoint: number;
  22728. }
  22729. /**
  22730. * A class representing a physics distance joint
  22731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22732. */
  22733. export class DistanceJoint extends PhysicsJoint {
  22734. /**
  22735. *
  22736. * @param jointData The data for the Distance-Joint
  22737. */
  22738. constructor(jointData: DistanceJointData);
  22739. /**
  22740. * Update the predefined distance.
  22741. * @param maxDistance The maximum preferred distance
  22742. * @param minDistance The minimum preferred distance
  22743. */
  22744. updateDistance(maxDistance: number, minDistance?: number): void;
  22745. }
  22746. /**
  22747. * Represents a Motor-Enabled Joint
  22748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22749. */
  22750. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22751. /**
  22752. * Initializes the Motor-Enabled Joint
  22753. * @param type The type of the joint
  22754. * @param jointData The physica joint data for the joint
  22755. */
  22756. constructor(type: number, jointData: PhysicsJointData);
  22757. /**
  22758. * Set the motor values.
  22759. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22760. * @param force the force to apply
  22761. * @param maxForce max force for this motor.
  22762. */
  22763. setMotor(force?: number, maxForce?: number): void;
  22764. /**
  22765. * Set the motor's limits.
  22766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22767. * @param upperLimit The upper limit of the motor
  22768. * @param lowerLimit The lower limit of the motor
  22769. */
  22770. setLimit(upperLimit: number, lowerLimit?: number): void;
  22771. }
  22772. /**
  22773. * This class represents a single physics Hinge-Joint
  22774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22775. */
  22776. export class HingeJoint extends MotorEnabledJoint {
  22777. /**
  22778. * Initializes the Hinge-Joint
  22779. * @param jointData The joint data for the Hinge-Joint
  22780. */
  22781. constructor(jointData: PhysicsJointData);
  22782. /**
  22783. * Set the motor values.
  22784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22785. * @param {number} force the force to apply
  22786. * @param {number} maxForce max force for this motor.
  22787. */
  22788. setMotor(force?: number, maxForce?: number): void;
  22789. /**
  22790. * Set the motor's limits.
  22791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22792. * @param upperLimit The upper limit of the motor
  22793. * @param lowerLimit The lower limit of the motor
  22794. */
  22795. setLimit(upperLimit: number, lowerLimit?: number): void;
  22796. }
  22797. /**
  22798. * This class represents a dual hinge physics joint (same as wheel joint)
  22799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22800. */
  22801. export class Hinge2Joint extends MotorEnabledJoint {
  22802. /**
  22803. * Initializes the Hinge2-Joint
  22804. * @param jointData The joint data for the Hinge2-Joint
  22805. */
  22806. constructor(jointData: PhysicsJointData);
  22807. /**
  22808. * Set the motor values.
  22809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22810. * @param {number} targetSpeed the speed the motor is to reach
  22811. * @param {number} maxForce max force for this motor.
  22812. * @param {motorIndex} the motor's index, 0 or 1.
  22813. */
  22814. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22815. /**
  22816. * Set the motor limits.
  22817. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22818. * @param {number} upperLimit the upper limit
  22819. * @param {number} lowerLimit lower limit
  22820. * @param {motorIndex} the motor's index, 0 or 1.
  22821. */
  22822. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22823. }
  22824. /**
  22825. * Interface for a motor enabled joint
  22826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22827. */
  22828. export interface IMotorEnabledJoint {
  22829. /**
  22830. * Physics joint
  22831. */
  22832. physicsJoint: any;
  22833. /**
  22834. * Sets the motor of the motor-enabled joint
  22835. * @param force The force of the motor
  22836. * @param maxForce The maximum force of the motor
  22837. * @param motorIndex The index of the motor
  22838. */
  22839. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22840. /**
  22841. * Sets the limit of the motor
  22842. * @param upperLimit The upper limit of the motor
  22843. * @param lowerLimit The lower limit of the motor
  22844. * @param motorIndex The index of the motor
  22845. */
  22846. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22847. }
  22848. /**
  22849. * Joint data for a Distance-Joint
  22850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22851. */
  22852. export interface DistanceJointData extends PhysicsJointData {
  22853. /**
  22854. * Max distance the 2 joint objects can be apart
  22855. */
  22856. maxDistance: number;
  22857. }
  22858. /**
  22859. * Joint data from a spring joint
  22860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22861. */
  22862. export interface SpringJointData extends PhysicsJointData {
  22863. /**
  22864. * Length of the spring
  22865. */
  22866. length: number;
  22867. /**
  22868. * Stiffness of the spring
  22869. */
  22870. stiffness: number;
  22871. /**
  22872. * Damping of the spring
  22873. */
  22874. damping: number;
  22875. /** this callback will be called when applying the force to the impostors. */
  22876. forceApplicationCallback: () => void;
  22877. }
  22878. }
  22879. declare module BABYLON {
  22880. /**
  22881. * Holds the data for the raycast result
  22882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22883. */
  22884. export class PhysicsRaycastResult {
  22885. private _hasHit;
  22886. private _hitDistance;
  22887. private _hitNormalWorld;
  22888. private _hitPointWorld;
  22889. private _rayFromWorld;
  22890. private _rayToWorld;
  22891. /**
  22892. * Gets if there was a hit
  22893. */
  22894. readonly hasHit: boolean;
  22895. /**
  22896. * Gets the distance from the hit
  22897. */
  22898. readonly hitDistance: number;
  22899. /**
  22900. * Gets the hit normal/direction in the world
  22901. */
  22902. readonly hitNormalWorld: Vector3;
  22903. /**
  22904. * Gets the hit point in the world
  22905. */
  22906. readonly hitPointWorld: Vector3;
  22907. /**
  22908. * Gets the ray "start point" of the ray in the world
  22909. */
  22910. readonly rayFromWorld: Vector3;
  22911. /**
  22912. * Gets the ray "end point" of the ray in the world
  22913. */
  22914. readonly rayToWorld: Vector3;
  22915. /**
  22916. * Sets the hit data (normal & point in world space)
  22917. * @param hitNormalWorld defines the normal in world space
  22918. * @param hitPointWorld defines the point in world space
  22919. */
  22920. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22921. /**
  22922. * Sets the distance from the start point to the hit point
  22923. * @param distance
  22924. */
  22925. setHitDistance(distance: number): void;
  22926. /**
  22927. * Calculates the distance manually
  22928. */
  22929. calculateHitDistance(): void;
  22930. /**
  22931. * Resets all the values to default
  22932. * @param from The from point on world space
  22933. * @param to The to point on world space
  22934. */
  22935. reset(from?: Vector3, to?: Vector3): void;
  22936. }
  22937. /**
  22938. * Interface for the size containing width and height
  22939. */
  22940. interface IXYZ {
  22941. /**
  22942. * X
  22943. */
  22944. x: number;
  22945. /**
  22946. * Y
  22947. */
  22948. y: number;
  22949. /**
  22950. * Z
  22951. */
  22952. z: number;
  22953. }
  22954. }
  22955. declare module BABYLON {
  22956. /**
  22957. * Interface used to describe a physics joint
  22958. */
  22959. export interface PhysicsImpostorJoint {
  22960. /** Defines the main impostor to which the joint is linked */
  22961. mainImpostor: PhysicsImpostor;
  22962. /** Defines the impostor that is connected to the main impostor using this joint */
  22963. connectedImpostor: PhysicsImpostor;
  22964. /** Defines the joint itself */
  22965. joint: PhysicsJoint;
  22966. }
  22967. /** @hidden */
  22968. export interface IPhysicsEnginePlugin {
  22969. world: any;
  22970. name: string;
  22971. setGravity(gravity: Vector3): void;
  22972. setTimeStep(timeStep: number): void;
  22973. getTimeStep(): number;
  22974. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22975. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22976. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22977. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22978. removePhysicsBody(impostor: PhysicsImpostor): void;
  22979. generateJoint(joint: PhysicsImpostorJoint): void;
  22980. removeJoint(joint: PhysicsImpostorJoint): void;
  22981. isSupported(): boolean;
  22982. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22983. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22984. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22985. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22987. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22988. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22989. getBodyMass(impostor: PhysicsImpostor): number;
  22990. getBodyFriction(impostor: PhysicsImpostor): number;
  22991. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22992. getBodyRestitution(impostor: PhysicsImpostor): number;
  22993. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22994. getBodyPressure?(impostor: PhysicsImpostor): number;
  22995. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22996. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22997. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22998. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22999. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23000. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23001. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23002. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23003. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23004. sleepBody(impostor: PhysicsImpostor): void;
  23005. wakeUpBody(impostor: PhysicsImpostor): void;
  23006. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23007. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23008. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23009. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23010. getRadius(impostor: PhysicsImpostor): number;
  23011. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23012. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23013. dispose(): void;
  23014. }
  23015. /**
  23016. * Interface used to define a physics engine
  23017. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23018. */
  23019. export interface IPhysicsEngine {
  23020. /**
  23021. * Gets the gravity vector used by the simulation
  23022. */
  23023. gravity: Vector3;
  23024. /**
  23025. * Sets the gravity vector used by the simulation
  23026. * @param gravity defines the gravity vector to use
  23027. */
  23028. setGravity(gravity: Vector3): void;
  23029. /**
  23030. * Set the time step of the physics engine.
  23031. * Default is 1/60.
  23032. * To slow it down, enter 1/600 for example.
  23033. * To speed it up, 1/30
  23034. * @param newTimeStep the new timestep to apply to this world.
  23035. */
  23036. setTimeStep(newTimeStep: number): void;
  23037. /**
  23038. * Get the time step of the physics engine.
  23039. * @returns the current time step
  23040. */
  23041. getTimeStep(): number;
  23042. /**
  23043. * Release all resources
  23044. */
  23045. dispose(): void;
  23046. /**
  23047. * Gets the name of the current physics plugin
  23048. * @returns the name of the plugin
  23049. */
  23050. getPhysicsPluginName(): string;
  23051. /**
  23052. * Adding a new impostor for the impostor tracking.
  23053. * This will be done by the impostor itself.
  23054. * @param impostor the impostor to add
  23055. */
  23056. addImpostor(impostor: PhysicsImpostor): void;
  23057. /**
  23058. * Remove an impostor from the engine.
  23059. * This impostor and its mesh will not longer be updated by the physics engine.
  23060. * @param impostor the impostor to remove
  23061. */
  23062. removeImpostor(impostor: PhysicsImpostor): void;
  23063. /**
  23064. * Add a joint to the physics engine
  23065. * @param mainImpostor defines the main impostor to which the joint is added.
  23066. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23067. * @param joint defines the joint that will connect both impostors.
  23068. */
  23069. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23070. /**
  23071. * Removes a joint from the simulation
  23072. * @param mainImpostor defines the impostor used with the joint
  23073. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23074. * @param joint defines the joint to remove
  23075. */
  23076. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23077. /**
  23078. * Gets the current plugin used to run the simulation
  23079. * @returns current plugin
  23080. */
  23081. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23082. /**
  23083. * Gets the list of physic impostors
  23084. * @returns an array of PhysicsImpostor
  23085. */
  23086. getImpostors(): Array<PhysicsImpostor>;
  23087. /**
  23088. * Gets the impostor for a physics enabled object
  23089. * @param object defines the object impersonated by the impostor
  23090. * @returns the PhysicsImpostor or null if not found
  23091. */
  23092. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23093. /**
  23094. * Gets the impostor for a physics body object
  23095. * @param body defines physics body used by the impostor
  23096. * @returns the PhysicsImpostor or null if not found
  23097. */
  23098. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23099. /**
  23100. * Does a raycast in the physics world
  23101. * @param from when should the ray start?
  23102. * @param to when should the ray end?
  23103. * @returns PhysicsRaycastResult
  23104. */
  23105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23106. /**
  23107. * Called by the scene. No need to call it.
  23108. * @param delta defines the timespam between frames
  23109. */
  23110. _step(delta: number): void;
  23111. }
  23112. }
  23113. declare module BABYLON {
  23114. /**
  23115. * The interface for the physics imposter parameters
  23116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23117. */
  23118. export interface PhysicsImpostorParameters {
  23119. /**
  23120. * The mass of the physics imposter
  23121. */
  23122. mass: number;
  23123. /**
  23124. * The friction of the physics imposter
  23125. */
  23126. friction?: number;
  23127. /**
  23128. * The coefficient of restitution of the physics imposter
  23129. */
  23130. restitution?: number;
  23131. /**
  23132. * The native options of the physics imposter
  23133. */
  23134. nativeOptions?: any;
  23135. /**
  23136. * Specifies if the parent should be ignored
  23137. */
  23138. ignoreParent?: boolean;
  23139. /**
  23140. * Specifies if bi-directional transformations should be disabled
  23141. */
  23142. disableBidirectionalTransformation?: boolean;
  23143. /**
  23144. * The pressure inside the physics imposter, soft object only
  23145. */
  23146. pressure?: number;
  23147. /**
  23148. * The stiffness the physics imposter, soft object only
  23149. */
  23150. stiffness?: number;
  23151. /**
  23152. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23153. */
  23154. velocityIterations?: number;
  23155. /**
  23156. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23157. */
  23158. positionIterations?: number;
  23159. /**
  23160. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23161. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23162. * Add to fix multiple points
  23163. */
  23164. fixedPoints?: number;
  23165. /**
  23166. * The collision margin around a soft object
  23167. */
  23168. margin?: number;
  23169. /**
  23170. * The collision margin around a soft object
  23171. */
  23172. damping?: number;
  23173. /**
  23174. * The path for a rope based on an extrusion
  23175. */
  23176. path?: any;
  23177. /**
  23178. * The shape of an extrusion used for a rope based on an extrusion
  23179. */
  23180. shape?: any;
  23181. }
  23182. /**
  23183. * Interface for a physics-enabled object
  23184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23185. */
  23186. export interface IPhysicsEnabledObject {
  23187. /**
  23188. * The position of the physics-enabled object
  23189. */
  23190. position: Vector3;
  23191. /**
  23192. * The rotation of the physics-enabled object
  23193. */
  23194. rotationQuaternion: Nullable<Quaternion>;
  23195. /**
  23196. * The scale of the physics-enabled object
  23197. */
  23198. scaling: Vector3;
  23199. /**
  23200. * The rotation of the physics-enabled object
  23201. */
  23202. rotation?: Vector3;
  23203. /**
  23204. * The parent of the physics-enabled object
  23205. */
  23206. parent?: any;
  23207. /**
  23208. * The bounding info of the physics-enabled object
  23209. * @returns The bounding info of the physics-enabled object
  23210. */
  23211. getBoundingInfo(): BoundingInfo;
  23212. /**
  23213. * Computes the world matrix
  23214. * @param force Specifies if the world matrix should be computed by force
  23215. * @returns A world matrix
  23216. */
  23217. computeWorldMatrix(force: boolean): Matrix;
  23218. /**
  23219. * Gets the world matrix
  23220. * @returns A world matrix
  23221. */
  23222. getWorldMatrix?(): Matrix;
  23223. /**
  23224. * Gets the child meshes
  23225. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23226. * @returns An array of abstract meshes
  23227. */
  23228. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23229. /**
  23230. * Gets the vertex data
  23231. * @param kind The type of vertex data
  23232. * @returns A nullable array of numbers, or a float32 array
  23233. */
  23234. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23235. /**
  23236. * Gets the indices from the mesh
  23237. * @returns A nullable array of index arrays
  23238. */
  23239. getIndices?(): Nullable<IndicesArray>;
  23240. /**
  23241. * Gets the scene from the mesh
  23242. * @returns the indices array or null
  23243. */
  23244. getScene?(): Scene;
  23245. /**
  23246. * Gets the absolute position from the mesh
  23247. * @returns the absolute position
  23248. */
  23249. getAbsolutePosition(): Vector3;
  23250. /**
  23251. * Gets the absolute pivot point from the mesh
  23252. * @returns the absolute pivot point
  23253. */
  23254. getAbsolutePivotPoint(): Vector3;
  23255. /**
  23256. * Rotates the mesh
  23257. * @param axis The axis of rotation
  23258. * @param amount The amount of rotation
  23259. * @param space The space of the rotation
  23260. * @returns The rotation transform node
  23261. */
  23262. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23263. /**
  23264. * Translates the mesh
  23265. * @param axis The axis of translation
  23266. * @param distance The distance of translation
  23267. * @param space The space of the translation
  23268. * @returns The transform node
  23269. */
  23270. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23271. /**
  23272. * Sets the absolute position of the mesh
  23273. * @param absolutePosition The absolute position of the mesh
  23274. * @returns The transform node
  23275. */
  23276. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23277. /**
  23278. * Gets the class name of the mesh
  23279. * @returns The class name
  23280. */
  23281. getClassName(): string;
  23282. }
  23283. /**
  23284. * Represents a physics imposter
  23285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23286. */
  23287. export class PhysicsImpostor {
  23288. /**
  23289. * The physics-enabled object used as the physics imposter
  23290. */
  23291. object: IPhysicsEnabledObject;
  23292. /**
  23293. * The type of the physics imposter
  23294. */
  23295. type: number;
  23296. private _options;
  23297. private _scene?;
  23298. /**
  23299. * The default object size of the imposter
  23300. */
  23301. static DEFAULT_OBJECT_SIZE: Vector3;
  23302. /**
  23303. * The identity quaternion of the imposter
  23304. */
  23305. static IDENTITY_QUATERNION: Quaternion;
  23306. /** @hidden */
  23307. _pluginData: any;
  23308. private _physicsEngine;
  23309. private _physicsBody;
  23310. private _bodyUpdateRequired;
  23311. private _onBeforePhysicsStepCallbacks;
  23312. private _onAfterPhysicsStepCallbacks;
  23313. /** @hidden */
  23314. _onPhysicsCollideCallbacks: Array<{
  23315. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23316. otherImpostors: Array<PhysicsImpostor>;
  23317. }>;
  23318. private _deltaPosition;
  23319. private _deltaRotation;
  23320. private _deltaRotationConjugated;
  23321. /** @hidden */
  23322. _isFromLine: boolean;
  23323. private _parent;
  23324. private _isDisposed;
  23325. private static _tmpVecs;
  23326. private static _tmpQuat;
  23327. /**
  23328. * Specifies if the physics imposter is disposed
  23329. */
  23330. readonly isDisposed: boolean;
  23331. /**
  23332. * Gets the mass of the physics imposter
  23333. */
  23334. mass: number;
  23335. /**
  23336. * Gets the coefficient of friction
  23337. */
  23338. /**
  23339. * Sets the coefficient of friction
  23340. */
  23341. friction: number;
  23342. /**
  23343. * Gets the coefficient of restitution
  23344. */
  23345. /**
  23346. * Sets the coefficient of restitution
  23347. */
  23348. restitution: number;
  23349. /**
  23350. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23351. */
  23352. /**
  23353. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23354. */
  23355. pressure: number;
  23356. /**
  23357. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23358. */
  23359. /**
  23360. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23361. */
  23362. stiffness: number;
  23363. /**
  23364. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23365. */
  23366. /**
  23367. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23368. */
  23369. velocityIterations: number;
  23370. /**
  23371. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23372. */
  23373. /**
  23374. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23375. */
  23376. positionIterations: number;
  23377. /**
  23378. * The unique id of the physics imposter
  23379. * set by the physics engine when adding this impostor to the array
  23380. */
  23381. uniqueId: number;
  23382. /**
  23383. * @hidden
  23384. */
  23385. soft: boolean;
  23386. /**
  23387. * @hidden
  23388. */
  23389. segments: number;
  23390. private _joints;
  23391. /**
  23392. * Initializes the physics imposter
  23393. * @param object The physics-enabled object used as the physics imposter
  23394. * @param type The type of the physics imposter
  23395. * @param _options The options for the physics imposter
  23396. * @param _scene The Babylon scene
  23397. */
  23398. constructor(
  23399. /**
  23400. * The physics-enabled object used as the physics imposter
  23401. */
  23402. object: IPhysicsEnabledObject,
  23403. /**
  23404. * The type of the physics imposter
  23405. */
  23406. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23407. /**
  23408. * This function will completly initialize this impostor.
  23409. * It will create a new body - but only if this mesh has no parent.
  23410. * If it has, this impostor will not be used other than to define the impostor
  23411. * of the child mesh.
  23412. * @hidden
  23413. */
  23414. _init(): void;
  23415. private _getPhysicsParent;
  23416. /**
  23417. * Should a new body be generated.
  23418. * @returns boolean specifying if body initialization is required
  23419. */
  23420. isBodyInitRequired(): boolean;
  23421. /**
  23422. * Sets the updated scaling
  23423. * @param updated Specifies if the scaling is updated
  23424. */
  23425. setScalingUpdated(): void;
  23426. /**
  23427. * Force a regeneration of this or the parent's impostor's body.
  23428. * Use under cautious - This will remove all joints already implemented.
  23429. */
  23430. forceUpdate(): void;
  23431. /**
  23432. * Gets the body that holds this impostor. Either its own, or its parent.
  23433. */
  23434. /**
  23435. * Set the physics body. Used mainly by the physics engine/plugin
  23436. */
  23437. physicsBody: any;
  23438. /**
  23439. * Get the parent of the physics imposter
  23440. * @returns Physics imposter or null
  23441. */
  23442. /**
  23443. * Sets the parent of the physics imposter
  23444. */
  23445. parent: Nullable<PhysicsImpostor>;
  23446. /**
  23447. * Resets the update flags
  23448. */
  23449. resetUpdateFlags(): void;
  23450. /**
  23451. * Gets the object extend size
  23452. * @returns the object extend size
  23453. */
  23454. getObjectExtendSize(): Vector3;
  23455. /**
  23456. * Gets the object center
  23457. * @returns The object center
  23458. */
  23459. getObjectCenter(): Vector3;
  23460. /**
  23461. * Get a specific parametes from the options parameter
  23462. * @param paramName The object parameter name
  23463. * @returns The object parameter
  23464. */
  23465. getParam(paramName: string): any;
  23466. /**
  23467. * Sets a specific parameter in the options given to the physics plugin
  23468. * @param paramName The parameter name
  23469. * @param value The value of the parameter
  23470. */
  23471. setParam(paramName: string, value: number): void;
  23472. /**
  23473. * Specifically change the body's mass option. Won't recreate the physics body object
  23474. * @param mass The mass of the physics imposter
  23475. */
  23476. setMass(mass: number): void;
  23477. /**
  23478. * Gets the linear velocity
  23479. * @returns linear velocity or null
  23480. */
  23481. getLinearVelocity(): Nullable<Vector3>;
  23482. /**
  23483. * Sets the linear velocity
  23484. * @param velocity linear velocity or null
  23485. */
  23486. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23487. /**
  23488. * Gets the angular velocity
  23489. * @returns angular velocity or null
  23490. */
  23491. getAngularVelocity(): Nullable<Vector3>;
  23492. /**
  23493. * Sets the angular velocity
  23494. * @param velocity The velocity or null
  23495. */
  23496. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23497. /**
  23498. * Execute a function with the physics plugin native code
  23499. * Provide a function the will have two variables - the world object and the physics body object
  23500. * @param func The function to execute with the physics plugin native code
  23501. */
  23502. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23503. /**
  23504. * Register a function that will be executed before the physics world is stepping forward
  23505. * @param func The function to execute before the physics world is stepped forward
  23506. */
  23507. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23508. /**
  23509. * Unregister a function that will be executed before the physics world is stepping forward
  23510. * @param func The function to execute before the physics world is stepped forward
  23511. */
  23512. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23513. /**
  23514. * Register a function that will be executed after the physics step
  23515. * @param func The function to execute after physics step
  23516. */
  23517. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23518. /**
  23519. * Unregisters a function that will be executed after the physics step
  23520. * @param func The function to execute after physics step
  23521. */
  23522. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23523. /**
  23524. * register a function that will be executed when this impostor collides against a different body
  23525. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23526. * @param func Callback that is executed on collision
  23527. */
  23528. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23529. /**
  23530. * Unregisters the physics imposter on contact
  23531. * @param collideAgainst The physics object to collide against
  23532. * @param func Callback to execute on collision
  23533. */
  23534. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23535. private _tmpQuat;
  23536. private _tmpQuat2;
  23537. /**
  23538. * Get the parent rotation
  23539. * @returns The parent rotation
  23540. */
  23541. getParentsRotation(): Quaternion;
  23542. /**
  23543. * this function is executed by the physics engine.
  23544. */
  23545. beforeStep: () => void;
  23546. /**
  23547. * this function is executed by the physics engine
  23548. */
  23549. afterStep: () => void;
  23550. /**
  23551. * Legacy collision detection event support
  23552. */
  23553. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23554. /**
  23555. * event and body object due to cannon's event-based architecture.
  23556. */
  23557. onCollide: (e: {
  23558. body: any;
  23559. }) => void;
  23560. /**
  23561. * Apply a force
  23562. * @param force The force to apply
  23563. * @param contactPoint The contact point for the force
  23564. * @returns The physics imposter
  23565. */
  23566. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23567. /**
  23568. * Apply an impulse
  23569. * @param force The impulse force
  23570. * @param contactPoint The contact point for the impulse force
  23571. * @returns The physics imposter
  23572. */
  23573. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23574. /**
  23575. * A help function to create a joint
  23576. * @param otherImpostor A physics imposter used to create a joint
  23577. * @param jointType The type of joint
  23578. * @param jointData The data for the joint
  23579. * @returns The physics imposter
  23580. */
  23581. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23582. /**
  23583. * Add a joint to this impostor with a different impostor
  23584. * @param otherImpostor A physics imposter used to add a joint
  23585. * @param joint The joint to add
  23586. * @returns The physics imposter
  23587. */
  23588. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23589. /**
  23590. * Add an anchor to a cloth impostor
  23591. * @param otherImpostor rigid impostor to anchor to
  23592. * @param width ratio across width from 0 to 1
  23593. * @param height ratio up height from 0 to 1
  23594. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23595. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23596. * @returns impostor the soft imposter
  23597. */
  23598. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23599. /**
  23600. * Add a hook to a rope impostor
  23601. * @param otherImpostor rigid impostor to anchor to
  23602. * @param length ratio across rope from 0 to 1
  23603. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23604. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23605. * @returns impostor the rope imposter
  23606. */
  23607. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23608. /**
  23609. * Will keep this body still, in a sleep mode.
  23610. * @returns the physics imposter
  23611. */
  23612. sleep(): PhysicsImpostor;
  23613. /**
  23614. * Wake the body up.
  23615. * @returns The physics imposter
  23616. */
  23617. wakeUp(): PhysicsImpostor;
  23618. /**
  23619. * Clones the physics imposter
  23620. * @param newObject The physics imposter clones to this physics-enabled object
  23621. * @returns A nullable physics imposter
  23622. */
  23623. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23624. /**
  23625. * Disposes the physics imposter
  23626. */
  23627. dispose(): void;
  23628. /**
  23629. * Sets the delta position
  23630. * @param position The delta position amount
  23631. */
  23632. setDeltaPosition(position: Vector3): void;
  23633. /**
  23634. * Sets the delta rotation
  23635. * @param rotation The delta rotation amount
  23636. */
  23637. setDeltaRotation(rotation: Quaternion): void;
  23638. /**
  23639. * Gets the box size of the physics imposter and stores the result in the input parameter
  23640. * @param result Stores the box size
  23641. * @returns The physics imposter
  23642. */
  23643. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23644. /**
  23645. * Gets the radius of the physics imposter
  23646. * @returns Radius of the physics imposter
  23647. */
  23648. getRadius(): number;
  23649. /**
  23650. * Sync a bone with this impostor
  23651. * @param bone The bone to sync to the impostor.
  23652. * @param boneMesh The mesh that the bone is influencing.
  23653. * @param jointPivot The pivot of the joint / bone in local space.
  23654. * @param distToJoint Optional distance from the impostor to the joint.
  23655. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23656. */
  23657. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23658. /**
  23659. * Sync impostor to a bone
  23660. * @param bone The bone that the impostor will be synced to.
  23661. * @param boneMesh The mesh that the bone is influencing.
  23662. * @param jointPivot The pivot of the joint / bone in local space.
  23663. * @param distToJoint Optional distance from the impostor to the joint.
  23664. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23665. * @param boneAxis Optional vector3 axis the bone is aligned with
  23666. */
  23667. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23668. /**
  23669. * No-Imposter type
  23670. */
  23671. static NoImpostor: number;
  23672. /**
  23673. * Sphere-Imposter type
  23674. */
  23675. static SphereImpostor: number;
  23676. /**
  23677. * Box-Imposter type
  23678. */
  23679. static BoxImpostor: number;
  23680. /**
  23681. * Plane-Imposter type
  23682. */
  23683. static PlaneImpostor: number;
  23684. /**
  23685. * Mesh-imposter type
  23686. */
  23687. static MeshImpostor: number;
  23688. /**
  23689. * Capsule-Impostor type (Ammo.js plugin only)
  23690. */
  23691. static CapsuleImpostor: number;
  23692. /**
  23693. * Cylinder-Imposter type
  23694. */
  23695. static CylinderImpostor: number;
  23696. /**
  23697. * Particle-Imposter type
  23698. */
  23699. static ParticleImpostor: number;
  23700. /**
  23701. * Heightmap-Imposter type
  23702. */
  23703. static HeightmapImpostor: number;
  23704. /**
  23705. * ConvexHull-Impostor type (Ammo.js plugin only)
  23706. */
  23707. static ConvexHullImpostor: number;
  23708. /**
  23709. * Rope-Imposter type
  23710. */
  23711. static RopeImpostor: number;
  23712. /**
  23713. * Cloth-Imposter type
  23714. */
  23715. static ClothImpostor: number;
  23716. /**
  23717. * Softbody-Imposter type
  23718. */
  23719. static SoftbodyImpostor: number;
  23720. }
  23721. }
  23722. declare module BABYLON {
  23723. /**
  23724. * @hidden
  23725. **/
  23726. export class _CreationDataStorage {
  23727. closePath?: boolean;
  23728. closeArray?: boolean;
  23729. idx: number[];
  23730. dashSize: number;
  23731. gapSize: number;
  23732. path3D: Path3D;
  23733. pathArray: Vector3[][];
  23734. arc: number;
  23735. radius: number;
  23736. cap: number;
  23737. tessellation: number;
  23738. }
  23739. /**
  23740. * @hidden
  23741. **/
  23742. class _InstanceDataStorage {
  23743. visibleInstances: any;
  23744. batchCache: _InstancesBatch;
  23745. instancesBufferSize: number;
  23746. instancesBuffer: Nullable<Buffer>;
  23747. instancesData: Float32Array;
  23748. overridenInstanceCount: number;
  23749. isFrozen: boolean;
  23750. previousBatch: Nullable<_InstancesBatch>;
  23751. hardwareInstancedRendering: boolean;
  23752. sideOrientation: number;
  23753. manualUpdate: boolean;
  23754. }
  23755. /**
  23756. * @hidden
  23757. **/
  23758. export class _InstancesBatch {
  23759. mustReturn: boolean;
  23760. visibleInstances: Nullable<InstancedMesh[]>[];
  23761. renderSelf: boolean[];
  23762. hardwareInstancedRendering: boolean[];
  23763. }
  23764. /**
  23765. * Class used to represent renderable models
  23766. */
  23767. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23768. /**
  23769. * Mesh side orientation : usually the external or front surface
  23770. */
  23771. static readonly FRONTSIDE: number;
  23772. /**
  23773. * Mesh side orientation : usually the internal or back surface
  23774. */
  23775. static readonly BACKSIDE: number;
  23776. /**
  23777. * Mesh side orientation : both internal and external or front and back surfaces
  23778. */
  23779. static readonly DOUBLESIDE: number;
  23780. /**
  23781. * Mesh side orientation : by default, `FRONTSIDE`
  23782. */
  23783. static readonly DEFAULTSIDE: number;
  23784. /**
  23785. * Mesh cap setting : no cap
  23786. */
  23787. static readonly NO_CAP: number;
  23788. /**
  23789. * Mesh cap setting : one cap at the beginning of the mesh
  23790. */
  23791. static readonly CAP_START: number;
  23792. /**
  23793. * Mesh cap setting : one cap at the end of the mesh
  23794. */
  23795. static readonly CAP_END: number;
  23796. /**
  23797. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23798. */
  23799. static readonly CAP_ALL: number;
  23800. /**
  23801. * Mesh pattern setting : no flip or rotate
  23802. */
  23803. static readonly NO_FLIP: number;
  23804. /**
  23805. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23806. */
  23807. static readonly FLIP_TILE: number;
  23808. /**
  23809. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23810. */
  23811. static readonly ROTATE_TILE: number;
  23812. /**
  23813. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23814. */
  23815. static readonly FLIP_ROW: number;
  23816. /**
  23817. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23818. */
  23819. static readonly ROTATE_ROW: number;
  23820. /**
  23821. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23822. */
  23823. static readonly FLIP_N_ROTATE_TILE: number;
  23824. /**
  23825. * Mesh pattern setting : rotate pattern and rotate
  23826. */
  23827. static readonly FLIP_N_ROTATE_ROW: number;
  23828. /**
  23829. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23830. */
  23831. static readonly CENTER: number;
  23832. /**
  23833. * Mesh tile positioning : part tiles on left
  23834. */
  23835. static readonly LEFT: number;
  23836. /**
  23837. * Mesh tile positioning : part tiles on right
  23838. */
  23839. static readonly RIGHT: number;
  23840. /**
  23841. * Mesh tile positioning : part tiles on top
  23842. */
  23843. static readonly TOP: number;
  23844. /**
  23845. * Mesh tile positioning : part tiles on bottom
  23846. */
  23847. static readonly BOTTOM: number;
  23848. /**
  23849. * Gets the default side orientation.
  23850. * @param orientation the orientation to value to attempt to get
  23851. * @returns the default orientation
  23852. * @hidden
  23853. */
  23854. static _GetDefaultSideOrientation(orientation?: number): number;
  23855. private _internalMeshDataInfo;
  23856. /**
  23857. * An event triggered before rendering the mesh
  23858. */
  23859. readonly onBeforeRenderObservable: Observable<Mesh>;
  23860. /**
  23861. * An event triggered before binding the mesh
  23862. */
  23863. readonly onBeforeBindObservable: Observable<Mesh>;
  23864. /**
  23865. * An event triggered after rendering the mesh
  23866. */
  23867. readonly onAfterRenderObservable: Observable<Mesh>;
  23868. /**
  23869. * An event triggered before drawing the mesh
  23870. */
  23871. readonly onBeforeDrawObservable: Observable<Mesh>;
  23872. private _onBeforeDrawObserver;
  23873. /**
  23874. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23875. */
  23876. onBeforeDraw: () => void;
  23877. readonly hasInstances: boolean;
  23878. /**
  23879. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23880. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23881. */
  23882. delayLoadState: number;
  23883. /**
  23884. * Gets the list of instances created from this mesh
  23885. * it is not supposed to be modified manually.
  23886. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23887. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23888. */
  23889. instances: InstancedMesh[];
  23890. /**
  23891. * Gets the file containing delay loading data for this mesh
  23892. */
  23893. delayLoadingFile: string;
  23894. /** @hidden */
  23895. _binaryInfo: any;
  23896. /**
  23897. * User defined function used to change how LOD level selection is done
  23898. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23899. */
  23900. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23901. /**
  23902. * Gets or sets the morph target manager
  23903. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23904. */
  23905. morphTargetManager: Nullable<MorphTargetManager>;
  23906. /** @hidden */
  23907. _creationDataStorage: Nullable<_CreationDataStorage>;
  23908. /** @hidden */
  23909. _geometry: Nullable<Geometry>;
  23910. /** @hidden */
  23911. _delayInfo: Array<string>;
  23912. /** @hidden */
  23913. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23914. /** @hidden */
  23915. _instanceDataStorage: _InstanceDataStorage;
  23916. private _effectiveMaterial;
  23917. /** @hidden */
  23918. _shouldGenerateFlatShading: boolean;
  23919. /** @hidden */
  23920. _originalBuilderSideOrientation: number;
  23921. /**
  23922. * Use this property to change the original side orientation defined at construction time
  23923. */
  23924. overrideMaterialSideOrientation: Nullable<number>;
  23925. /**
  23926. * Gets the source mesh (the one used to clone this one from)
  23927. */
  23928. readonly source: Nullable<Mesh>;
  23929. /**
  23930. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23931. */
  23932. isUnIndexed: boolean;
  23933. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  23934. readonly worldMatrixInstancedBuffer: Float32Array;
  23935. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  23936. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  23937. /**
  23938. * @constructor
  23939. * @param name The value used by scene.getMeshByName() to do a lookup.
  23940. * @param scene The scene to add this mesh to.
  23941. * @param parent The parent of this mesh, if it has one
  23942. * @param source An optional Mesh from which geometry is shared, cloned.
  23943. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23944. * When false, achieved by calling a clone(), also passing False.
  23945. * This will make creation of children, recursive.
  23946. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23947. */
  23948. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23949. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23950. doNotInstantiate: boolean;
  23951. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23952. /**
  23953. * Gets the class name
  23954. * @returns the string "Mesh".
  23955. */
  23956. getClassName(): string;
  23957. /** @hidden */
  23958. readonly _isMesh: boolean;
  23959. /**
  23960. * Returns a description of this mesh
  23961. * @param fullDetails define if full details about this mesh must be used
  23962. * @returns a descriptive string representing this mesh
  23963. */
  23964. toString(fullDetails?: boolean): string;
  23965. /** @hidden */
  23966. _unBindEffect(): void;
  23967. /**
  23968. * Gets a boolean indicating if this mesh has LOD
  23969. */
  23970. readonly hasLODLevels: boolean;
  23971. /**
  23972. * Gets the list of MeshLODLevel associated with the current mesh
  23973. * @returns an array of MeshLODLevel
  23974. */
  23975. getLODLevels(): MeshLODLevel[];
  23976. private _sortLODLevels;
  23977. /**
  23978. * Add a mesh as LOD level triggered at the given distance.
  23979. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23980. * @param distance The distance from the center of the object to show this level
  23981. * @param mesh The mesh to be added as LOD level (can be null)
  23982. * @return This mesh (for chaining)
  23983. */
  23984. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23985. /**
  23986. * Returns the LOD level mesh at the passed distance or null if not found.
  23987. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23988. * @param distance The distance from the center of the object to show this level
  23989. * @returns a Mesh or `null`
  23990. */
  23991. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23992. /**
  23993. * Remove a mesh from the LOD array
  23994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23995. * @param mesh defines the mesh to be removed
  23996. * @return This mesh (for chaining)
  23997. */
  23998. removeLODLevel(mesh: Mesh): Mesh;
  23999. /**
  24000. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24001. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24002. * @param camera defines the camera to use to compute distance
  24003. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24004. * @return This mesh (for chaining)
  24005. */
  24006. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24007. /**
  24008. * Gets the mesh internal Geometry object
  24009. */
  24010. readonly geometry: Nullable<Geometry>;
  24011. /**
  24012. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24013. * @returns the total number of vertices
  24014. */
  24015. getTotalVertices(): number;
  24016. /**
  24017. * Returns the content of an associated vertex buffer
  24018. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24019. * - VertexBuffer.PositionKind
  24020. * - VertexBuffer.UVKind
  24021. * - VertexBuffer.UV2Kind
  24022. * - VertexBuffer.UV3Kind
  24023. * - VertexBuffer.UV4Kind
  24024. * - VertexBuffer.UV5Kind
  24025. * - VertexBuffer.UV6Kind
  24026. * - VertexBuffer.ColorKind
  24027. * - VertexBuffer.MatricesIndicesKind
  24028. * - VertexBuffer.MatricesIndicesExtraKind
  24029. * - VertexBuffer.MatricesWeightsKind
  24030. * - VertexBuffer.MatricesWeightsExtraKind
  24031. * @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
  24032. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24033. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24034. */
  24035. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24036. /**
  24037. * Returns the mesh VertexBuffer object from the requested `kind`
  24038. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24039. * - VertexBuffer.PositionKind
  24040. * - VertexBuffer.NormalKind
  24041. * - VertexBuffer.UVKind
  24042. * - VertexBuffer.UV2Kind
  24043. * - VertexBuffer.UV3Kind
  24044. * - VertexBuffer.UV4Kind
  24045. * - VertexBuffer.UV5Kind
  24046. * - VertexBuffer.UV6Kind
  24047. * - VertexBuffer.ColorKind
  24048. * - VertexBuffer.MatricesIndicesKind
  24049. * - VertexBuffer.MatricesIndicesExtraKind
  24050. * - VertexBuffer.MatricesWeightsKind
  24051. * - VertexBuffer.MatricesWeightsExtraKind
  24052. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24053. */
  24054. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24055. /**
  24056. * Tests if a specific vertex buffer is associated with this mesh
  24057. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24058. * - VertexBuffer.PositionKind
  24059. * - VertexBuffer.NormalKind
  24060. * - VertexBuffer.UVKind
  24061. * - VertexBuffer.UV2Kind
  24062. * - VertexBuffer.UV3Kind
  24063. * - VertexBuffer.UV4Kind
  24064. * - VertexBuffer.UV5Kind
  24065. * - VertexBuffer.UV6Kind
  24066. * - VertexBuffer.ColorKind
  24067. * - VertexBuffer.MatricesIndicesKind
  24068. * - VertexBuffer.MatricesIndicesExtraKind
  24069. * - VertexBuffer.MatricesWeightsKind
  24070. * - VertexBuffer.MatricesWeightsExtraKind
  24071. * @returns a boolean
  24072. */
  24073. isVerticesDataPresent(kind: string): boolean;
  24074. /**
  24075. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24076. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24077. * - VertexBuffer.PositionKind
  24078. * - VertexBuffer.UVKind
  24079. * - VertexBuffer.UV2Kind
  24080. * - VertexBuffer.UV3Kind
  24081. * - VertexBuffer.UV4Kind
  24082. * - VertexBuffer.UV5Kind
  24083. * - VertexBuffer.UV6Kind
  24084. * - VertexBuffer.ColorKind
  24085. * - VertexBuffer.MatricesIndicesKind
  24086. * - VertexBuffer.MatricesIndicesExtraKind
  24087. * - VertexBuffer.MatricesWeightsKind
  24088. * - VertexBuffer.MatricesWeightsExtraKind
  24089. * @returns a boolean
  24090. */
  24091. isVertexBufferUpdatable(kind: string): boolean;
  24092. /**
  24093. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24094. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24095. * - VertexBuffer.PositionKind
  24096. * - VertexBuffer.NormalKind
  24097. * - VertexBuffer.UVKind
  24098. * - VertexBuffer.UV2Kind
  24099. * - VertexBuffer.UV3Kind
  24100. * - VertexBuffer.UV4Kind
  24101. * - VertexBuffer.UV5Kind
  24102. * - VertexBuffer.UV6Kind
  24103. * - VertexBuffer.ColorKind
  24104. * - VertexBuffer.MatricesIndicesKind
  24105. * - VertexBuffer.MatricesIndicesExtraKind
  24106. * - VertexBuffer.MatricesWeightsKind
  24107. * - VertexBuffer.MatricesWeightsExtraKind
  24108. * @returns an array of strings
  24109. */
  24110. getVerticesDataKinds(): string[];
  24111. /**
  24112. * Returns a positive integer : the total number of indices in this mesh geometry.
  24113. * @returns the numner of indices or zero if the mesh has no geometry.
  24114. */
  24115. getTotalIndices(): number;
  24116. /**
  24117. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24118. * @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.
  24119. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24120. * @returns the indices array or an empty array if the mesh has no geometry
  24121. */
  24122. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24123. readonly isBlocked: boolean;
  24124. /**
  24125. * Determine if the current mesh is ready to be rendered
  24126. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24127. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24128. * @returns true if all associated assets are ready (material, textures, shaders)
  24129. */
  24130. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24131. /**
  24132. * 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.
  24133. */
  24134. readonly areNormalsFrozen: boolean;
  24135. /**
  24136. * 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.
  24137. * @returns the current mesh
  24138. */
  24139. freezeNormals(): Mesh;
  24140. /**
  24141. * 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
  24142. * @returns the current mesh
  24143. */
  24144. unfreezeNormals(): Mesh;
  24145. /**
  24146. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24147. */
  24148. overridenInstanceCount: number;
  24149. /** @hidden */
  24150. _preActivate(): Mesh;
  24151. /** @hidden */
  24152. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24153. /** @hidden */
  24154. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24155. /**
  24156. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24157. * This means the mesh underlying bounding box and sphere are recomputed.
  24158. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24159. * @returns the current mesh
  24160. */
  24161. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24162. /** @hidden */
  24163. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24164. /**
  24165. * This function will subdivide the mesh into multiple submeshes
  24166. * @param count defines the expected number of submeshes
  24167. */
  24168. subdivide(count: number): void;
  24169. /**
  24170. * Copy a FloatArray into a specific associated vertex buffer
  24171. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24172. * - VertexBuffer.PositionKind
  24173. * - VertexBuffer.UVKind
  24174. * - VertexBuffer.UV2Kind
  24175. * - VertexBuffer.UV3Kind
  24176. * - VertexBuffer.UV4Kind
  24177. * - VertexBuffer.UV5Kind
  24178. * - VertexBuffer.UV6Kind
  24179. * - VertexBuffer.ColorKind
  24180. * - VertexBuffer.MatricesIndicesKind
  24181. * - VertexBuffer.MatricesIndicesExtraKind
  24182. * - VertexBuffer.MatricesWeightsKind
  24183. * - VertexBuffer.MatricesWeightsExtraKind
  24184. * @param data defines the data source
  24185. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24186. * @param stride defines the data stride size (can be null)
  24187. * @returns the current mesh
  24188. */
  24189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24190. /**
  24191. * Delete a vertex buffer associated with this mesh
  24192. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24193. * - VertexBuffer.PositionKind
  24194. * - VertexBuffer.UVKind
  24195. * - VertexBuffer.UV2Kind
  24196. * - VertexBuffer.UV3Kind
  24197. * - VertexBuffer.UV4Kind
  24198. * - VertexBuffer.UV5Kind
  24199. * - VertexBuffer.UV6Kind
  24200. * - VertexBuffer.ColorKind
  24201. * - VertexBuffer.MatricesIndicesKind
  24202. * - VertexBuffer.MatricesIndicesExtraKind
  24203. * - VertexBuffer.MatricesWeightsKind
  24204. * - VertexBuffer.MatricesWeightsExtraKind
  24205. */
  24206. removeVerticesData(kind: string): void;
  24207. /**
  24208. * Flags an associated vertex buffer as updatable
  24209. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24210. * - VertexBuffer.PositionKind
  24211. * - VertexBuffer.UVKind
  24212. * - VertexBuffer.UV2Kind
  24213. * - VertexBuffer.UV3Kind
  24214. * - VertexBuffer.UV4Kind
  24215. * - VertexBuffer.UV5Kind
  24216. * - VertexBuffer.UV6Kind
  24217. * - VertexBuffer.ColorKind
  24218. * - VertexBuffer.MatricesIndicesKind
  24219. * - VertexBuffer.MatricesIndicesExtraKind
  24220. * - VertexBuffer.MatricesWeightsKind
  24221. * - VertexBuffer.MatricesWeightsExtraKind
  24222. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24223. */
  24224. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24225. /**
  24226. * Sets the mesh global Vertex Buffer
  24227. * @param buffer defines the buffer to use
  24228. * @returns the current mesh
  24229. */
  24230. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24231. /**
  24232. * Update a specific associated vertex buffer
  24233. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24234. * - VertexBuffer.PositionKind
  24235. * - VertexBuffer.UVKind
  24236. * - VertexBuffer.UV2Kind
  24237. * - VertexBuffer.UV3Kind
  24238. * - VertexBuffer.UV4Kind
  24239. * - VertexBuffer.UV5Kind
  24240. * - VertexBuffer.UV6Kind
  24241. * - VertexBuffer.ColorKind
  24242. * - VertexBuffer.MatricesIndicesKind
  24243. * - VertexBuffer.MatricesIndicesExtraKind
  24244. * - VertexBuffer.MatricesWeightsKind
  24245. * - VertexBuffer.MatricesWeightsExtraKind
  24246. * @param data defines the data source
  24247. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24248. * @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)
  24249. * @returns the current mesh
  24250. */
  24251. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24252. /**
  24253. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24254. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24255. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24256. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24257. * @returns the current mesh
  24258. */
  24259. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24260. /**
  24261. * Creates a un-shared specific occurence of the geometry for the mesh.
  24262. * @returns the current mesh
  24263. */
  24264. makeGeometryUnique(): Mesh;
  24265. /**
  24266. * Set the index buffer of this mesh
  24267. * @param indices defines the source data
  24268. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24269. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24270. * @returns the current mesh
  24271. */
  24272. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24273. /**
  24274. * Update the current index buffer
  24275. * @param indices defines the source data
  24276. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24277. * @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)
  24278. * @returns the current mesh
  24279. */
  24280. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24281. /**
  24282. * Invert the geometry to move from a right handed system to a left handed one.
  24283. * @returns the current mesh
  24284. */
  24285. toLeftHanded(): Mesh;
  24286. /** @hidden */
  24287. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24288. /** @hidden */
  24289. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24290. /**
  24291. * Registers for this mesh a javascript function called just before the rendering process
  24292. * @param func defines the function to call before rendering this mesh
  24293. * @returns the current mesh
  24294. */
  24295. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24296. /**
  24297. * Disposes a previously registered javascript function called before the rendering
  24298. * @param func defines the function to remove
  24299. * @returns the current mesh
  24300. */
  24301. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24302. /**
  24303. * Registers for this mesh a javascript function called just after the rendering is complete
  24304. * @param func defines the function to call after rendering this mesh
  24305. * @returns the current mesh
  24306. */
  24307. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24308. /**
  24309. * Disposes a previously registered javascript function called after the rendering.
  24310. * @param func defines the function to remove
  24311. * @returns the current mesh
  24312. */
  24313. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24314. /** @hidden */
  24315. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24316. /** @hidden */
  24317. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24318. /** @hidden */
  24319. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24320. /** @hidden */
  24321. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24322. /** @hidden */
  24323. _rebuild(): void;
  24324. /** @hidden */
  24325. _freeze(): void;
  24326. /** @hidden */
  24327. _unFreeze(): void;
  24328. /**
  24329. * 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
  24330. * @param subMesh defines the subMesh to render
  24331. * @param enableAlphaMode defines if alpha mode can be changed
  24332. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24333. * @returns the current mesh
  24334. */
  24335. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24336. private _onBeforeDraw;
  24337. /**
  24338. * Renormalize the mesh and patch it up if there are no weights
  24339. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24340. * However in the case of zero weights then we set just a single influence to 1.
  24341. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24342. */
  24343. cleanMatrixWeights(): void;
  24344. private normalizeSkinFourWeights;
  24345. private normalizeSkinWeightsAndExtra;
  24346. /**
  24347. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24348. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24349. * the user know there was an issue with importing the mesh
  24350. * @returns a validation object with skinned, valid and report string
  24351. */
  24352. validateSkinning(): {
  24353. skinned: boolean;
  24354. valid: boolean;
  24355. report: string;
  24356. };
  24357. /** @hidden */
  24358. _checkDelayState(): Mesh;
  24359. private _queueLoad;
  24360. /**
  24361. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24362. * A mesh is in the frustum if its bounding box intersects the frustum
  24363. * @param frustumPlanes defines the frustum to test
  24364. * @returns true if the mesh is in the frustum planes
  24365. */
  24366. isInFrustum(frustumPlanes: Plane[]): boolean;
  24367. /**
  24368. * Sets the mesh material by the material or multiMaterial `id` property
  24369. * @param id is a string identifying the material or the multiMaterial
  24370. * @returns the current mesh
  24371. */
  24372. setMaterialByID(id: string): Mesh;
  24373. /**
  24374. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24375. * @returns an array of IAnimatable
  24376. */
  24377. getAnimatables(): IAnimatable[];
  24378. /**
  24379. * Modifies the mesh geometry according to the passed transformation matrix.
  24380. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24381. * The mesh normals are modified using the same transformation.
  24382. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24383. * @param transform defines the transform matrix to use
  24384. * @see http://doc.babylonjs.com/resources/baking_transformations
  24385. * @returns the current mesh
  24386. */
  24387. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24388. /**
  24389. * Modifies the mesh geometry according to its own current World Matrix.
  24390. * The mesh World Matrix is then reset.
  24391. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24392. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24393. * @see http://doc.babylonjs.com/resources/baking_transformations
  24394. * @returns the current mesh
  24395. */
  24396. bakeCurrentTransformIntoVertices(): Mesh;
  24397. /** @hidden */
  24398. readonly _positions: Nullable<Vector3[]>;
  24399. /** @hidden */
  24400. _resetPointsArrayCache(): Mesh;
  24401. /** @hidden */
  24402. _generatePointsArray(): boolean;
  24403. /**
  24404. * Returns a new Mesh object generated from the current mesh properties.
  24405. * This method must not get confused with createInstance()
  24406. * @param name is a string, the name given to the new mesh
  24407. * @param newParent can be any Node object (default `null`)
  24408. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24409. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24410. * @returns a new mesh
  24411. */
  24412. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24413. /**
  24414. * Releases resources associated with this mesh.
  24415. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24416. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24417. */
  24418. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24419. /** @hidden */
  24420. _disposeInstanceSpecificData(): void;
  24421. /**
  24422. * Modifies the mesh geometry according to a displacement map.
  24423. * 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.
  24424. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24425. * @param url is a string, the URL from the image file is to be downloaded.
  24426. * @param minHeight is the lower limit of the displacement.
  24427. * @param maxHeight is the upper limit of the displacement.
  24428. * @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.
  24429. * @param uvOffset is an optional vector2 used to offset UV.
  24430. * @param uvScale is an optional vector2 used to scale UV.
  24431. * @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.
  24432. * @returns the Mesh.
  24433. */
  24434. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24435. /**
  24436. * Modifies the mesh geometry according to a displacementMap buffer.
  24437. * 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.
  24438. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24439. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24440. * @param heightMapWidth is the width of the buffer image.
  24441. * @param heightMapHeight is the height of the buffer image.
  24442. * @param minHeight is the lower limit of the displacement.
  24443. * @param maxHeight is the upper limit of the displacement.
  24444. * @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.
  24445. * @param uvOffset is an optional vector2 used to offset UV.
  24446. * @param uvScale is an optional vector2 used to scale UV.
  24447. * @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.
  24448. * @returns the Mesh.
  24449. */
  24450. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24451. /**
  24452. * Modify the mesh to get a flat shading rendering.
  24453. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24454. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24455. * @returns current mesh
  24456. */
  24457. convertToFlatShadedMesh(): Mesh;
  24458. /**
  24459. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24460. * In other words, more vertices, no more indices and a single bigger VBO.
  24461. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24462. * @returns current mesh
  24463. */
  24464. convertToUnIndexedMesh(): Mesh;
  24465. /**
  24466. * Inverses facet orientations.
  24467. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24468. * @param flipNormals will also inverts the normals
  24469. * @returns current mesh
  24470. */
  24471. flipFaces(flipNormals?: boolean): Mesh;
  24472. /**
  24473. * Increase the number of facets and hence vertices in a mesh
  24474. * Vertex normals are interpolated from existing vertex normals
  24475. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24476. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24477. */
  24478. increaseVertices(numberPerEdge: number): void;
  24479. /**
  24480. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24481. * This will undo any application of covertToFlatShadedMesh
  24482. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24483. */
  24484. forceSharedVertices(): void;
  24485. /** @hidden */
  24486. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24487. /** @hidden */
  24488. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24489. /**
  24490. * Creates a new InstancedMesh object from the mesh model.
  24491. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24492. * @param name defines the name of the new instance
  24493. * @returns a new InstancedMesh
  24494. */
  24495. createInstance(name: string): InstancedMesh;
  24496. /**
  24497. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24498. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24499. * @returns the current mesh
  24500. */
  24501. synchronizeInstances(): Mesh;
  24502. /**
  24503. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24504. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24505. * This should be used together with the simplification to avoid disappearing triangles.
  24506. * @param successCallback an optional success callback to be called after the optimization finished.
  24507. * @returns the current mesh
  24508. */
  24509. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24510. /**
  24511. * Serialize current mesh
  24512. * @param serializationObject defines the object which will receive the serialization data
  24513. */
  24514. serialize(serializationObject: any): void;
  24515. /** @hidden */
  24516. _syncGeometryWithMorphTargetManager(): void;
  24517. /** @hidden */
  24518. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24519. /**
  24520. * Returns a new Mesh object parsed from the source provided.
  24521. * @param parsedMesh is the source
  24522. * @param scene defines the hosting scene
  24523. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24524. * @returns a new Mesh
  24525. */
  24526. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24527. /**
  24528. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24529. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24530. * @param name defines the name of the mesh to create
  24531. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24532. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24533. * @param closePath creates a seam between the first and the last points of each path of the path array
  24534. * @param offset is taken in account only if the `pathArray` is containing a single path
  24535. * @param scene defines the hosting scene
  24536. * @param updatable defines if the mesh must be flagged as updatable
  24537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24538. * @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)
  24539. * @returns a new Mesh
  24540. */
  24541. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24542. /**
  24543. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24544. * @param name defines the name of the mesh to create
  24545. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24546. * @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
  24547. * @param scene defines the hosting scene
  24548. * @param updatable defines if the mesh must be flagged as updatable
  24549. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24550. * @returns a new Mesh
  24551. */
  24552. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24553. /**
  24554. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24555. * @param name defines the name of the mesh to create
  24556. * @param size sets the size (float) of each box side (default 1)
  24557. * @param scene defines the hosting scene
  24558. * @param updatable defines if the mesh must be flagged as updatable
  24559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24560. * @returns a new Mesh
  24561. */
  24562. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24563. /**
  24564. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24565. * @param name defines the name of the mesh to create
  24566. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24567. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24568. * @param scene defines the hosting scene
  24569. * @param updatable defines if the mesh must be flagged as updatable
  24570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24571. * @returns a new Mesh
  24572. */
  24573. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24574. /**
  24575. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24576. * @param name defines the name of the mesh to create
  24577. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24578. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24579. * @param scene defines the hosting scene
  24580. * @returns a new Mesh
  24581. */
  24582. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24583. /**
  24584. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24585. * @param name defines the name of the mesh to create
  24586. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24587. * @param diameterTop set the top cap diameter (floats, default 1)
  24588. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24589. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24590. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24591. * @param scene defines the hosting scene
  24592. * @param updatable defines if the mesh must be flagged as updatable
  24593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24594. * @returns a new Mesh
  24595. */
  24596. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24597. /**
  24598. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24599. * @param name defines the name of the mesh to create
  24600. * @param diameter sets the diameter size (float) of the torus (default 1)
  24601. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24602. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24603. * @param scene defines the hosting scene
  24604. * @param updatable defines if the mesh must be flagged as updatable
  24605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24606. * @returns a new Mesh
  24607. */
  24608. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24609. /**
  24610. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24611. * @param name defines the name of the mesh to create
  24612. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24613. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24614. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24615. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24616. * @param p the number of windings on X axis (positive integers, default 2)
  24617. * @param q the number of windings on Y axis (positive integers, default 3)
  24618. * @param scene defines the hosting scene
  24619. * @param updatable defines if the mesh must be flagged as updatable
  24620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24621. * @returns a new Mesh
  24622. */
  24623. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24624. /**
  24625. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24626. * @param name defines the name of the mesh to create
  24627. * @param points is an array successive Vector3
  24628. * @param scene defines the hosting scene
  24629. * @param updatable defines if the mesh must be flagged as updatable
  24630. * @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).
  24631. * @returns a new Mesh
  24632. */
  24633. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24634. /**
  24635. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24636. * @param name defines the name of the mesh to create
  24637. * @param points is an array successive Vector3
  24638. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24639. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24640. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24641. * @param scene defines the hosting scene
  24642. * @param updatable defines if the mesh must be flagged as updatable
  24643. * @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)
  24644. * @returns a new Mesh
  24645. */
  24646. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24647. /**
  24648. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24649. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24650. * 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.
  24651. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24652. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24653. * Remember you can only change the shape positions, not their number when updating a polygon.
  24654. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24655. * @param name defines the name of the mesh to create
  24656. * @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
  24657. * @param scene defines the hosting scene
  24658. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24659. * @param updatable defines if the mesh must be flagged as updatable
  24660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24661. * @param earcutInjection can be used to inject your own earcut reference
  24662. * @returns a new Mesh
  24663. */
  24664. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24665. /**
  24666. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24667. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24668. * @param name defines the name of the mesh to create
  24669. * @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
  24670. * @param depth defines the height of extrusion
  24671. * @param scene defines the hosting scene
  24672. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24673. * @param updatable defines if the mesh must be flagged as updatable
  24674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24675. * @param earcutInjection can be used to inject your own earcut reference
  24676. * @returns a new Mesh
  24677. */
  24678. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24679. /**
  24680. * Creates an extruded shape mesh.
  24681. * 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
  24682. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24683. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24684. * @param name defines the name of the mesh to create
  24685. * @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
  24686. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24687. * @param scale is the value to scale the shape
  24688. * @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
  24689. * @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
  24690. * @param scene defines the hosting scene
  24691. * @param updatable defines if the mesh must be flagged as updatable
  24692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24693. * @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)
  24694. * @returns a new Mesh
  24695. */
  24696. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24697. /**
  24698. * Creates an custom extruded shape mesh.
  24699. * The custom extrusion is a parametric shape.
  24700. * It has no predefined shape. Its final shape will depend on the input parameters.
  24701. * Please consider using the same method from the MeshBuilder class instead
  24702. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24703. * @param name defines the name of the mesh to create
  24704. * @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
  24705. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24706. * @param scaleFunction is a custom Javascript function called on each path point
  24707. * @param rotationFunction is a custom Javascript function called on each path point
  24708. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24709. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24710. * @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
  24711. * @param scene defines the hosting scene
  24712. * @param updatable defines if the mesh must be flagged as updatable
  24713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24714. * @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)
  24715. * @returns a new Mesh
  24716. */
  24717. 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;
  24718. /**
  24719. * Creates lathe mesh.
  24720. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24721. * Please consider using the same method from the MeshBuilder class instead
  24722. * @param name defines the name of the mesh to create
  24723. * @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
  24724. * @param radius is the radius value of the lathe
  24725. * @param tessellation is the side number of the lathe.
  24726. * @param scene defines the hosting scene
  24727. * @param updatable defines if the mesh must be flagged as updatable
  24728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24729. * @returns a new Mesh
  24730. */
  24731. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24732. /**
  24733. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24734. * @param name defines the name of the mesh to create
  24735. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24736. * @param scene defines the hosting scene
  24737. * @param updatable defines if the mesh must be flagged as updatable
  24738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24739. * @returns a new Mesh
  24740. */
  24741. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24742. /**
  24743. * Creates a ground mesh.
  24744. * Please consider using the same method from the MeshBuilder class instead
  24745. * @param name defines the name of the mesh to create
  24746. * @param width set the width of the ground
  24747. * @param height set the height of the ground
  24748. * @param subdivisions sets the number of subdivisions per side
  24749. * @param scene defines the hosting scene
  24750. * @param updatable defines if the mesh must be flagged as updatable
  24751. * @returns a new Mesh
  24752. */
  24753. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24754. /**
  24755. * Creates a tiled ground mesh.
  24756. * Please consider using the same method from the MeshBuilder class instead
  24757. * @param name defines the name of the mesh to create
  24758. * @param xmin set the ground minimum X coordinate
  24759. * @param zmin set the ground minimum Y coordinate
  24760. * @param xmax set the ground maximum X coordinate
  24761. * @param zmax set the ground maximum Z coordinate
  24762. * @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
  24763. * @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
  24764. * @param scene defines the hosting scene
  24765. * @param updatable defines if the mesh must be flagged as updatable
  24766. * @returns a new Mesh
  24767. */
  24768. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24769. w: number;
  24770. h: number;
  24771. }, precision: {
  24772. w: number;
  24773. h: number;
  24774. }, scene: Scene, updatable?: boolean): Mesh;
  24775. /**
  24776. * Creates a ground mesh from a height map.
  24777. * Please consider using the same method from the MeshBuilder class instead
  24778. * @see http://doc.babylonjs.com/babylon101/height_map
  24779. * @param name defines the name of the mesh to create
  24780. * @param url sets the URL of the height map image resource
  24781. * @param width set the ground width size
  24782. * @param height set the ground height size
  24783. * @param subdivisions sets the number of subdivision per side
  24784. * @param minHeight is the minimum altitude on the ground
  24785. * @param maxHeight is the maximum altitude on the ground
  24786. * @param scene defines the hosting scene
  24787. * @param updatable defines if the mesh must be flagged as updatable
  24788. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24789. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24790. * @returns a new Mesh
  24791. */
  24792. 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;
  24793. /**
  24794. * Creates a tube mesh.
  24795. * The tube is a parametric shape.
  24796. * It has no predefined shape. Its final shape will depend on the input parameters.
  24797. * Please consider using the same method from the MeshBuilder class instead
  24798. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24799. * @param name defines the name of the mesh to create
  24800. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24801. * @param radius sets the tube radius size
  24802. * @param tessellation is the number of sides on the tubular surface
  24803. * @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
  24804. * @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
  24805. * @param scene defines the hosting scene
  24806. * @param updatable defines if the mesh must be flagged as updatable
  24807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24808. * @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)
  24809. * @returns a new Mesh
  24810. */
  24811. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24812. (i: number, distance: number): number;
  24813. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24814. /**
  24815. * Creates a polyhedron mesh.
  24816. * Please consider using the same method from the MeshBuilder class instead.
  24817. * * 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
  24818. * * The parameter `size` (positive float, default 1) sets the polygon size
  24819. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24820. * * 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`
  24821. * * 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
  24822. * * 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)`)
  24823. * * 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
  24824. * * 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
  24825. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24826. * * 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
  24827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24828. * @param name defines the name of the mesh to create
  24829. * @param options defines the options used to create the mesh
  24830. * @param scene defines the hosting scene
  24831. * @returns a new Mesh
  24832. */
  24833. static CreatePolyhedron(name: string, options: {
  24834. type?: number;
  24835. size?: number;
  24836. sizeX?: number;
  24837. sizeY?: number;
  24838. sizeZ?: number;
  24839. custom?: any;
  24840. faceUV?: Vector4[];
  24841. faceColors?: Color4[];
  24842. updatable?: boolean;
  24843. sideOrientation?: number;
  24844. }, scene: Scene): Mesh;
  24845. /**
  24846. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24847. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24848. * * 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`)
  24849. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24850. * * 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
  24851. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24852. * * 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
  24853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24854. * @param name defines the name of the mesh
  24855. * @param options defines the options used to create the mesh
  24856. * @param scene defines the hosting scene
  24857. * @returns a new Mesh
  24858. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24859. */
  24860. static CreateIcoSphere(name: string, options: {
  24861. radius?: number;
  24862. flat?: boolean;
  24863. subdivisions?: number;
  24864. sideOrientation?: number;
  24865. updatable?: boolean;
  24866. }, scene: Scene): Mesh;
  24867. /**
  24868. * Creates a decal mesh.
  24869. * Please consider using the same method from the MeshBuilder class instead.
  24870. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24871. * @param name defines the name of the mesh
  24872. * @param sourceMesh defines the mesh receiving the decal
  24873. * @param position sets the position of the decal in world coordinates
  24874. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24875. * @param size sets the decal scaling
  24876. * @param angle sets the angle to rotate the decal
  24877. * @returns a new Mesh
  24878. */
  24879. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24880. /**
  24881. * Prepare internal position array for software CPU skinning
  24882. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24883. */
  24884. setPositionsForCPUSkinning(): Float32Array;
  24885. /**
  24886. * Prepare internal normal array for software CPU skinning
  24887. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24888. */
  24889. setNormalsForCPUSkinning(): Float32Array;
  24890. /**
  24891. * Updates the vertex buffer by applying transformation from the bones
  24892. * @param skeleton defines the skeleton to apply to current mesh
  24893. * @returns the current mesh
  24894. */
  24895. applySkeleton(skeleton: Skeleton): Mesh;
  24896. /**
  24897. * 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
  24898. * @param meshes defines the list of meshes to scan
  24899. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24900. */
  24901. static MinMax(meshes: AbstractMesh[]): {
  24902. min: Vector3;
  24903. max: Vector3;
  24904. };
  24905. /**
  24906. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24907. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24908. * @returns a vector3
  24909. */
  24910. static Center(meshesOrMinMaxVector: {
  24911. min: Vector3;
  24912. max: Vector3;
  24913. } | AbstractMesh[]): Vector3;
  24914. /**
  24915. * Merge the array of meshes into a single mesh for performance reasons.
  24916. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24917. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24918. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24919. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24920. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24921. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24922. * @returns a new mesh
  24923. */
  24924. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24925. /** @hidden */
  24926. addInstance(instance: InstancedMesh): void;
  24927. /** @hidden */
  24928. removeInstance(instance: InstancedMesh): void;
  24929. }
  24930. }
  24931. declare module BABYLON {
  24932. /**
  24933. * This is the base class of all the camera used in the application.
  24934. * @see http://doc.babylonjs.com/features/cameras
  24935. */
  24936. export class Camera extends Node {
  24937. /** @hidden */
  24938. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24939. /**
  24940. * This is the default projection mode used by the cameras.
  24941. * It helps recreating a feeling of perspective and better appreciate depth.
  24942. * This is the best way to simulate real life cameras.
  24943. */
  24944. static readonly PERSPECTIVE_CAMERA: number;
  24945. /**
  24946. * This helps creating camera with an orthographic mode.
  24947. * 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.
  24948. */
  24949. static readonly ORTHOGRAPHIC_CAMERA: number;
  24950. /**
  24951. * This is the default FOV mode for perspective cameras.
  24952. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24953. */
  24954. static readonly FOVMODE_VERTICAL_FIXED: number;
  24955. /**
  24956. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24957. */
  24958. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24959. /**
  24960. * This specifies ther is no need for a camera rig.
  24961. * Basically only one eye is rendered corresponding to the camera.
  24962. */
  24963. static readonly RIG_MODE_NONE: number;
  24964. /**
  24965. * Simulates a camera Rig with one blue eye and one red eye.
  24966. * This can be use with 3d blue and red glasses.
  24967. */
  24968. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24969. /**
  24970. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24971. */
  24972. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24973. /**
  24974. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24975. */
  24976. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24977. /**
  24978. * Defines that both eyes of the camera will be rendered over under each other.
  24979. */
  24980. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24981. /**
  24982. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24983. */
  24984. static readonly RIG_MODE_VR: number;
  24985. /**
  24986. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24987. */
  24988. static readonly RIG_MODE_WEBVR: number;
  24989. /**
  24990. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24991. */
  24992. static readonly RIG_MODE_CUSTOM: number;
  24993. /**
  24994. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24995. */
  24996. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24997. /**
  24998. * Define the input manager associated with the camera.
  24999. */
  25000. inputs: CameraInputsManager<Camera>;
  25001. /** @hidden */
  25002. _position: Vector3;
  25003. /**
  25004. * Define the current local position of the camera in the scene
  25005. */
  25006. position: Vector3;
  25007. /**
  25008. * The vector the camera should consider as up.
  25009. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25010. */
  25011. upVector: Vector3;
  25012. /**
  25013. * Define the current limit on the left side for an orthographic camera
  25014. * In scene unit
  25015. */
  25016. orthoLeft: Nullable<number>;
  25017. /**
  25018. * Define the current limit on the right side for an orthographic camera
  25019. * In scene unit
  25020. */
  25021. orthoRight: Nullable<number>;
  25022. /**
  25023. * Define the current limit on the bottom side for an orthographic camera
  25024. * In scene unit
  25025. */
  25026. orthoBottom: Nullable<number>;
  25027. /**
  25028. * Define the current limit on the top side for an orthographic camera
  25029. * In scene unit
  25030. */
  25031. orthoTop: Nullable<number>;
  25032. /**
  25033. * Field Of View is set in Radians. (default is 0.8)
  25034. */
  25035. fov: number;
  25036. /**
  25037. * Define the minimum distance the camera can see from.
  25038. * This is important to note that the depth buffer are not infinite and the closer it starts
  25039. * the more your scene might encounter depth fighting issue.
  25040. */
  25041. minZ: number;
  25042. /**
  25043. * Define the maximum distance the camera can see to.
  25044. * This is important to note that the depth buffer are not infinite and the further it end
  25045. * the more your scene might encounter depth fighting issue.
  25046. */
  25047. maxZ: number;
  25048. /**
  25049. * Define the default inertia of the camera.
  25050. * This helps giving a smooth feeling to the camera movement.
  25051. */
  25052. inertia: number;
  25053. /**
  25054. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25055. */
  25056. mode: number;
  25057. /**
  25058. * Define wether the camera is intermediate.
  25059. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25060. */
  25061. isIntermediate: boolean;
  25062. /**
  25063. * Define the viewport of the camera.
  25064. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25065. */
  25066. viewport: Viewport;
  25067. /**
  25068. * Restricts the camera to viewing objects with the same layerMask.
  25069. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25070. */
  25071. layerMask: number;
  25072. /**
  25073. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25074. */
  25075. fovMode: number;
  25076. /**
  25077. * Rig mode of the camera.
  25078. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25079. * This is normally controlled byt the camera themselves as internal use.
  25080. */
  25081. cameraRigMode: number;
  25082. /**
  25083. * Defines the distance between both "eyes" in case of a RIG
  25084. */
  25085. interaxialDistance: number;
  25086. /**
  25087. * Defines if stereoscopic rendering is done side by side or over under.
  25088. */
  25089. isStereoscopicSideBySide: boolean;
  25090. /**
  25091. * 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
  25092. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25093. * else in the scene. (Eg. security camera)
  25094. *
  25095. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25096. */
  25097. customRenderTargets: RenderTargetTexture[];
  25098. /**
  25099. * When set, the camera will render to this render target instead of the default canvas
  25100. *
  25101. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25102. */
  25103. outputRenderTarget: Nullable<RenderTargetTexture>;
  25104. /**
  25105. * Observable triggered when the camera view matrix has changed.
  25106. */
  25107. onViewMatrixChangedObservable: Observable<Camera>;
  25108. /**
  25109. * Observable triggered when the camera Projection matrix has changed.
  25110. */
  25111. onProjectionMatrixChangedObservable: Observable<Camera>;
  25112. /**
  25113. * Observable triggered when the inputs have been processed.
  25114. */
  25115. onAfterCheckInputsObservable: Observable<Camera>;
  25116. /**
  25117. * Observable triggered when reset has been called and applied to the camera.
  25118. */
  25119. onRestoreStateObservable: Observable<Camera>;
  25120. /** @hidden */
  25121. _cameraRigParams: any;
  25122. /** @hidden */
  25123. _rigCameras: Camera[];
  25124. /** @hidden */
  25125. _rigPostProcess: Nullable<PostProcess>;
  25126. protected _webvrViewMatrix: Matrix;
  25127. /** @hidden */
  25128. _skipRendering: boolean;
  25129. /** @hidden */
  25130. _projectionMatrix: Matrix;
  25131. /** @hidden */
  25132. _postProcesses: Nullable<PostProcess>[];
  25133. /** @hidden */
  25134. _activeMeshes: SmartArray<AbstractMesh>;
  25135. protected _globalPosition: Vector3;
  25136. /** @hidden */
  25137. _computedViewMatrix: Matrix;
  25138. private _doNotComputeProjectionMatrix;
  25139. private _transformMatrix;
  25140. private _frustumPlanes;
  25141. private _refreshFrustumPlanes;
  25142. private _storedFov;
  25143. private _stateStored;
  25144. /**
  25145. * Instantiates a new camera object.
  25146. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25147. * @see http://doc.babylonjs.com/features/cameras
  25148. * @param name Defines the name of the camera in the scene
  25149. * @param position Defines the position of the camera
  25150. * @param scene Defines the scene the camera belongs too
  25151. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25152. */
  25153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25154. /**
  25155. * Store current camera state (fov, position, etc..)
  25156. * @returns the camera
  25157. */
  25158. storeState(): Camera;
  25159. /**
  25160. * Restores the camera state values if it has been stored. You must call storeState() first
  25161. */
  25162. protected _restoreStateValues(): boolean;
  25163. /**
  25164. * Restored camera state. You must call storeState() first.
  25165. * @returns true if restored and false otherwise
  25166. */
  25167. restoreState(): boolean;
  25168. /**
  25169. * Gets the class name of the camera.
  25170. * @returns the class name
  25171. */
  25172. getClassName(): string;
  25173. /** @hidden */
  25174. readonly _isCamera: boolean;
  25175. /**
  25176. * Gets a string representation of the camera useful for debug purpose.
  25177. * @param fullDetails Defines that a more verboe level of logging is required
  25178. * @returns the string representation
  25179. */
  25180. toString(fullDetails?: boolean): string;
  25181. /**
  25182. * Gets the current world space position of the camera.
  25183. */
  25184. readonly globalPosition: Vector3;
  25185. /**
  25186. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25187. * @returns the active meshe list
  25188. */
  25189. getActiveMeshes(): SmartArray<AbstractMesh>;
  25190. /**
  25191. * Check wether a mesh is part of the current active mesh list of the camera
  25192. * @param mesh Defines the mesh to check
  25193. * @returns true if active, false otherwise
  25194. */
  25195. isActiveMesh(mesh: Mesh): boolean;
  25196. /**
  25197. * Is this camera ready to be used/rendered
  25198. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25199. * @return true if the camera is ready
  25200. */
  25201. isReady(completeCheck?: boolean): boolean;
  25202. /** @hidden */
  25203. _initCache(): void;
  25204. /** @hidden */
  25205. _updateCache(ignoreParentClass?: boolean): void;
  25206. /** @hidden */
  25207. _isSynchronized(): boolean;
  25208. /** @hidden */
  25209. _isSynchronizedViewMatrix(): boolean;
  25210. /** @hidden */
  25211. _isSynchronizedProjectionMatrix(): boolean;
  25212. /**
  25213. * Attach the input controls to a specific dom element to get the input from.
  25214. * @param element Defines the element the controls should be listened from
  25215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25216. */
  25217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25218. /**
  25219. * Detach the current controls from the specified dom element.
  25220. * @param element Defines the element to stop listening the inputs from
  25221. */
  25222. detachControl(element: HTMLElement): void;
  25223. /**
  25224. * Update the camera state according to the different inputs gathered during the frame.
  25225. */
  25226. update(): void;
  25227. /** @hidden */
  25228. _checkInputs(): void;
  25229. /** @hidden */
  25230. readonly rigCameras: Camera[];
  25231. /**
  25232. * Gets the post process used by the rig cameras
  25233. */
  25234. readonly rigPostProcess: Nullable<PostProcess>;
  25235. /**
  25236. * Internal, gets the first post proces.
  25237. * @returns the first post process to be run on this camera.
  25238. */
  25239. _getFirstPostProcess(): Nullable<PostProcess>;
  25240. private _cascadePostProcessesToRigCams;
  25241. /**
  25242. * Attach a post process to the camera.
  25243. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25244. * @param postProcess The post process to attach to the camera
  25245. * @param insertAt The position of the post process in case several of them are in use in the scene
  25246. * @returns the position the post process has been inserted at
  25247. */
  25248. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25249. /**
  25250. * Detach a post process to the camera.
  25251. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25252. * @param postProcess The post process to detach from the camera
  25253. */
  25254. detachPostProcess(postProcess: PostProcess): void;
  25255. /**
  25256. * Gets the current world matrix of the camera
  25257. */
  25258. getWorldMatrix(): Matrix;
  25259. /** @hidden */
  25260. _getViewMatrix(): Matrix;
  25261. /**
  25262. * Gets the current view matrix of the camera.
  25263. * @param force forces the camera to recompute the matrix without looking at the cached state
  25264. * @returns the view matrix
  25265. */
  25266. getViewMatrix(force?: boolean): Matrix;
  25267. /**
  25268. * Freeze the projection matrix.
  25269. * It will prevent the cache check of the camera projection compute and can speed up perf
  25270. * if no parameter of the camera are meant to change
  25271. * @param projection Defines manually a projection if necessary
  25272. */
  25273. freezeProjectionMatrix(projection?: Matrix): void;
  25274. /**
  25275. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25276. */
  25277. unfreezeProjectionMatrix(): void;
  25278. /**
  25279. * Gets the current projection matrix of the camera.
  25280. * @param force forces the camera to recompute the matrix without looking at the cached state
  25281. * @returns the projection matrix
  25282. */
  25283. getProjectionMatrix(force?: boolean): Matrix;
  25284. /**
  25285. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25286. * @returns a Matrix
  25287. */
  25288. getTransformationMatrix(): Matrix;
  25289. private _updateFrustumPlanes;
  25290. /**
  25291. * Checks if a cullable object (mesh...) is in the camera frustum
  25292. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25293. * @param target The object to check
  25294. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25295. * @returns true if the object is in frustum otherwise false
  25296. */
  25297. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25298. /**
  25299. * Checks if a cullable object (mesh...) is in the camera frustum
  25300. * Unlike isInFrustum this cheks the full bounding box
  25301. * @param target The object to check
  25302. * @returns true if the object is in frustum otherwise false
  25303. */
  25304. isCompletelyInFrustum(target: ICullable): boolean;
  25305. /**
  25306. * Gets a ray in the forward direction from the camera.
  25307. * @param length Defines the length of the ray to create
  25308. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25309. * @param origin Defines the start point of the ray which defaults to the camera position
  25310. * @returns the forward ray
  25311. */
  25312. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25313. /**
  25314. * Releases resources associated with this node.
  25315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25317. */
  25318. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25319. /** @hidden */
  25320. _isLeftCamera: boolean;
  25321. /**
  25322. * Gets the left camera of a rig setup in case of Rigged Camera
  25323. */
  25324. readonly isLeftCamera: boolean;
  25325. /** @hidden */
  25326. _isRightCamera: boolean;
  25327. /**
  25328. * Gets the right camera of a rig setup in case of Rigged Camera
  25329. */
  25330. readonly isRightCamera: boolean;
  25331. /**
  25332. * Gets the left camera of a rig setup in case of Rigged Camera
  25333. */
  25334. readonly leftCamera: Nullable<FreeCamera>;
  25335. /**
  25336. * Gets the right camera of a rig setup in case of Rigged Camera
  25337. */
  25338. readonly rightCamera: Nullable<FreeCamera>;
  25339. /**
  25340. * Gets the left camera target of a rig setup in case of Rigged Camera
  25341. * @returns the target position
  25342. */
  25343. getLeftTarget(): Nullable<Vector3>;
  25344. /**
  25345. * Gets the right camera target of a rig setup in case of Rigged Camera
  25346. * @returns the target position
  25347. */
  25348. getRightTarget(): Nullable<Vector3>;
  25349. /**
  25350. * @hidden
  25351. */
  25352. setCameraRigMode(mode: number, rigParams: any): void;
  25353. /** @hidden */
  25354. static _setStereoscopicRigMode(camera: Camera): void;
  25355. /** @hidden */
  25356. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25357. /** @hidden */
  25358. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25359. /** @hidden */
  25360. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25361. /** @hidden */
  25362. _getVRProjectionMatrix(): Matrix;
  25363. protected _updateCameraRotationMatrix(): void;
  25364. protected _updateWebVRCameraRotationMatrix(): void;
  25365. /**
  25366. * This function MUST be overwritten by the different WebVR cameras available.
  25367. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25368. * @hidden
  25369. */
  25370. _getWebVRProjectionMatrix(): Matrix;
  25371. /**
  25372. * This function MUST be overwritten by the different WebVR cameras available.
  25373. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25374. * @hidden
  25375. */
  25376. _getWebVRViewMatrix(): Matrix;
  25377. /** @hidden */
  25378. setCameraRigParameter(name: string, value: any): void;
  25379. /**
  25380. * needs to be overridden by children so sub has required properties to be copied
  25381. * @hidden
  25382. */
  25383. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25384. /**
  25385. * May need to be overridden by children
  25386. * @hidden
  25387. */
  25388. _updateRigCameras(): void;
  25389. /** @hidden */
  25390. _setupInputs(): void;
  25391. /**
  25392. * Serialiaze the camera setup to a json represention
  25393. * @returns the JSON representation
  25394. */
  25395. serialize(): any;
  25396. /**
  25397. * Clones the current camera.
  25398. * @param name The cloned camera name
  25399. * @returns the cloned camera
  25400. */
  25401. clone(name: string): Camera;
  25402. /**
  25403. * Gets the direction of the camera relative to a given local axis.
  25404. * @param localAxis Defines the reference axis to provide a relative direction.
  25405. * @return the direction
  25406. */
  25407. getDirection(localAxis: Vector3): Vector3;
  25408. /**
  25409. * Returns the current camera absolute rotation
  25410. */
  25411. readonly absoluteRotation: Quaternion;
  25412. /**
  25413. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25414. * @param localAxis Defines the reference axis to provide a relative direction.
  25415. * @param result Defines the vector to store the result in
  25416. */
  25417. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25418. /**
  25419. * Gets a camera constructor for a given camera type
  25420. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25421. * @param name The name of the camera the result will be able to instantiate
  25422. * @param scene The scene the result will construct the camera in
  25423. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25424. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25425. * @returns a factory method to construc the camera
  25426. */
  25427. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25428. /**
  25429. * Compute the world matrix of the camera.
  25430. * @returns the camera world matrix
  25431. */
  25432. computeWorldMatrix(): Matrix;
  25433. /**
  25434. * Parse a JSON and creates the camera from the parsed information
  25435. * @param parsedCamera The JSON to parse
  25436. * @param scene The scene to instantiate the camera in
  25437. * @returns the newly constructed camera
  25438. */
  25439. static Parse(parsedCamera: any, scene: Scene): Camera;
  25440. }
  25441. }
  25442. declare module BABYLON {
  25443. /**
  25444. * Class containing static functions to help procedurally build meshes
  25445. */
  25446. export class DiscBuilder {
  25447. /**
  25448. * Creates a plane polygonal mesh. By default, this is a disc
  25449. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25450. * * 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
  25451. * * 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
  25452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25453. * * 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
  25454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25455. * @param name defines the name of the mesh
  25456. * @param options defines the options used to create the mesh
  25457. * @param scene defines the hosting scene
  25458. * @returns the plane polygonal mesh
  25459. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25460. */
  25461. static CreateDisc(name: string, options: {
  25462. radius?: number;
  25463. tessellation?: number;
  25464. arc?: number;
  25465. updatable?: boolean;
  25466. sideOrientation?: number;
  25467. frontUVs?: Vector4;
  25468. backUVs?: Vector4;
  25469. }, scene?: Nullable<Scene>): Mesh;
  25470. }
  25471. }
  25472. declare module BABYLON {
  25473. /**
  25474. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25475. *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.
  25476. * The SPS is also a particle system. It provides some methods to manage the particles.
  25477. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25478. *
  25479. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25480. */
  25481. export class SolidParticleSystem implements IDisposable {
  25482. /**
  25483. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25484. * Example : var p = SPS.particles[i];
  25485. */
  25486. particles: SolidParticle[];
  25487. /**
  25488. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25489. */
  25490. nbParticles: number;
  25491. /**
  25492. * If the particles must ever face the camera (default false). Useful for planar particles.
  25493. */
  25494. billboard: boolean;
  25495. /**
  25496. * Recompute normals when adding a shape
  25497. */
  25498. recomputeNormals: boolean;
  25499. /**
  25500. * This a counter ofr your own usage. It's not set by any SPS functions.
  25501. */
  25502. counter: number;
  25503. /**
  25504. * The SPS name. This name is also given to the underlying mesh.
  25505. */
  25506. name: string;
  25507. /**
  25508. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25509. */
  25510. mesh: Mesh;
  25511. /**
  25512. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25513. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25514. */
  25515. vars: any;
  25516. /**
  25517. * This array is populated when the SPS is set as 'pickable'.
  25518. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25519. * Each element of this array is an object `{idx: int, faceId: int}`.
  25520. * `idx` is the picked particle index in the `SPS.particles` array
  25521. * `faceId` is the picked face index counted within this particle.
  25522. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25523. */
  25524. pickedParticles: {
  25525. idx: number;
  25526. faceId: number;
  25527. }[];
  25528. /**
  25529. * This array is populated when `enableDepthSort` is set to true.
  25530. * Each element of this array is an instance of the class DepthSortedParticle.
  25531. */
  25532. depthSortedParticles: DepthSortedParticle[];
  25533. /**
  25534. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25535. * @hidden
  25536. */
  25537. _bSphereOnly: boolean;
  25538. /**
  25539. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25540. * @hidden
  25541. */
  25542. _bSphereRadiusFactor: number;
  25543. private _scene;
  25544. private _positions;
  25545. private _indices;
  25546. private _normals;
  25547. private _colors;
  25548. private _uvs;
  25549. private _indices32;
  25550. private _positions32;
  25551. private _normals32;
  25552. private _fixedNormal32;
  25553. private _colors32;
  25554. private _uvs32;
  25555. private _index;
  25556. private _updatable;
  25557. private _pickable;
  25558. private _isVisibilityBoxLocked;
  25559. private _alwaysVisible;
  25560. private _depthSort;
  25561. private _expandable;
  25562. private _shapeCounter;
  25563. private _copy;
  25564. private _color;
  25565. private _computeParticleColor;
  25566. private _computeParticleTexture;
  25567. private _computeParticleRotation;
  25568. private _computeParticleVertex;
  25569. private _computeBoundingBox;
  25570. private _depthSortParticles;
  25571. private _camera;
  25572. private _mustUnrotateFixedNormals;
  25573. private _particlesIntersect;
  25574. private _needs32Bits;
  25575. private _isNotBuilt;
  25576. private _lastParticleId;
  25577. private _idxOfId;
  25578. /**
  25579. * Creates a SPS (Solid Particle System) object.
  25580. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25581. * @param scene (Scene) is the scene in which the SPS is added.
  25582. * @param options defines the options of the sps e.g.
  25583. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25584. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25585. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25586. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25587. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25588. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25589. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25590. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25591. */
  25592. constructor(name: string, scene: Scene, options?: {
  25593. updatable?: boolean;
  25594. isPickable?: boolean;
  25595. enableDepthSort?: boolean;
  25596. particleIntersection?: boolean;
  25597. boundingSphereOnly?: boolean;
  25598. bSphereRadiusFactor?: number;
  25599. expandable?: boolean;
  25600. });
  25601. /**
  25602. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25603. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25604. * @returns the created mesh
  25605. */
  25606. buildMesh(): Mesh;
  25607. /**
  25608. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25609. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25610. * Thus the particles generated from `digest()` have their property `position` set yet.
  25611. * @param mesh ( Mesh ) is the mesh to be digested
  25612. * @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
  25613. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25614. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25615. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25616. * @returns the current SPS
  25617. */
  25618. digest(mesh: Mesh, options?: {
  25619. facetNb?: number;
  25620. number?: number;
  25621. delta?: number;
  25622. storage?: [];
  25623. }): SolidParticleSystem;
  25624. /**
  25625. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  25626. * @hidden
  25627. */
  25628. private _unrotateFixedNormals;
  25629. /**
  25630. * Resets the temporary working copy particle
  25631. * @hidden
  25632. */
  25633. private _resetCopy;
  25634. /**
  25635. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  25636. * @param p the current index in the positions array to be updated
  25637. * @param shape a Vector3 array, the shape geometry
  25638. * @param positions the positions array to be updated
  25639. * @param meshInd the shape indices array
  25640. * @param indices the indices array to be updated
  25641. * @param meshUV the shape uv array
  25642. * @param uvs the uv array to be updated
  25643. * @param meshCol the shape color array
  25644. * @param colors the color array to be updated
  25645. * @param meshNor the shape normals array
  25646. * @param normals the normals array to be updated
  25647. * @param idx the particle index
  25648. * @param idxInShape the particle index in its shape
  25649. * @param options the addShape() method passed options
  25650. * @hidden
  25651. */
  25652. private _meshBuilder;
  25653. /**
  25654. * Returns a shape Vector3 array from positions float array
  25655. * @param positions float array
  25656. * @returns a vector3 array
  25657. * @hidden
  25658. */
  25659. private _posToShape;
  25660. /**
  25661. * Returns a shapeUV array from a float uvs (array deep copy)
  25662. * @param uvs as a float array
  25663. * @returns a shapeUV array
  25664. * @hidden
  25665. */
  25666. private _uvsToShapeUV;
  25667. /**
  25668. * Adds a new particle object in the particles array
  25669. * @param idx particle index in particles array
  25670. * @param id particle id
  25671. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  25672. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  25673. * @param model particle ModelShape object
  25674. * @param shapeId model shape identifier
  25675. * @param idxInShape index of the particle in the current model
  25676. * @param bInfo model bounding info object
  25677. * @param storage target storage array, if any
  25678. * @hidden
  25679. */
  25680. private _addParticle;
  25681. /**
  25682. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25683. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25684. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25685. * @param nb (positive integer) the number of particles to be created from this model
  25686. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25687. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25688. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25689. * @returns the number of shapes in the system
  25690. */
  25691. addShape(mesh: Mesh, nb: number, options?: {
  25692. positionFunction?: any;
  25693. vertexFunction?: any;
  25694. storage?: [];
  25695. }): number;
  25696. /**
  25697. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  25698. * @hidden
  25699. */
  25700. private _rebuildParticle;
  25701. /**
  25702. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25703. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25704. * @returns the SPS.
  25705. */
  25706. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25707. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25708. * Returns an array with the removed particles.
  25709. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25710. * The SPS can't be empty so at least one particle needs to remain in place.
  25711. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25712. * @param start index of the first particle to remove
  25713. * @param end index of the last particle to remove (included)
  25714. * @returns an array populated with the removed particles
  25715. */
  25716. removeParticles(start: number, end: number): SolidParticle[];
  25717. /**
  25718. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  25719. * @param solidParticleArray an array populated with Solid Particles objects
  25720. * @returns the SPS
  25721. */
  25722. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  25723. /**
  25724. * Creates a new particle and modifies the SPS mesh geometry :
  25725. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  25726. * - calls _addParticle() to populate the particle array
  25727. * factorized code from addShape() and insertParticlesFromArray()
  25728. * @param idx particle index in the particles array
  25729. * @param i particle index in its shape
  25730. * @param modelShape particle ModelShape object
  25731. * @param shape shape vertex array
  25732. * @param meshInd shape indices array
  25733. * @param meshUV shape uv array
  25734. * @param meshCol shape color array
  25735. * @param meshNor shape normals array
  25736. * @param bbInfo shape bounding info
  25737. * @param storage target particle storage
  25738. * @options addShape() passed options
  25739. * @hidden
  25740. */
  25741. private _insertNewParticle;
  25742. /**
  25743. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25744. * This method calls `updateParticle()` for each particle of the SPS.
  25745. * For an animated SPS, it is usually called within the render loop.
  25746. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25747. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25748. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25749. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25750. * @returns the SPS.
  25751. */
  25752. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25753. /**
  25754. * Disposes the SPS.
  25755. */
  25756. dispose(): void;
  25757. /**
  25758. * Returns a SolidParticle object from its identifier : particle.id
  25759. * @param id (integer) the particle Id
  25760. * @returns the searched particle or null if not found in the SPS.
  25761. */
  25762. getParticleById(id: number): Nullable<SolidParticle>;
  25763. /**
  25764. * Returns a new array populated with the particles having the passed shapeId.
  25765. * @param shapeId (integer) the shape identifier
  25766. * @returns a new solid particle array
  25767. */
  25768. getParticlesByShapeId(shapeId: number): SolidParticle[];
  25769. /**
  25770. * Populates the passed array "ref" with the particles having the passed shapeId.
  25771. * @param shapeId the shape identifier
  25772. * @returns the SPS
  25773. * @param ref
  25774. */
  25775. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  25776. /**
  25777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25778. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25779. * @returns the SPS.
  25780. */
  25781. refreshVisibleSize(): SolidParticleSystem;
  25782. /**
  25783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25784. * @param size the size (float) of the visibility box
  25785. * note : this doesn't lock the SPS mesh bounding box.
  25786. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25787. */
  25788. setVisibilityBox(size: number): void;
  25789. /**
  25790. * Gets whether the SPS as always visible or not
  25791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25792. */
  25793. /**
  25794. * Sets the SPS as always visible or not
  25795. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25796. */
  25797. isAlwaysVisible: boolean;
  25798. /**
  25799. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25801. */
  25802. /**
  25803. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. */
  25806. isVisibilityBoxLocked: boolean;
  25807. /**
  25808. * Tells to `setParticles()` to compute the particle rotations or not.
  25809. * Default value : true. The SPS is faster when it's set to false.
  25810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25811. */
  25812. /**
  25813. * Gets if `setParticles()` computes the particle rotations or not.
  25814. * Default value : true. The SPS is faster when it's set to false.
  25815. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25816. */
  25817. computeParticleRotation: boolean;
  25818. /**
  25819. * Tells to `setParticles()` to compute the particle colors or not.
  25820. * Default value : true. The SPS is faster when it's set to false.
  25821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25822. */
  25823. /**
  25824. * Gets if `setParticles()` computes the particle colors or not.
  25825. * Default value : true. The SPS is faster when it's set to false.
  25826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25827. */
  25828. computeParticleColor: boolean;
  25829. /**
  25830. * Gets if `setParticles()` computes the particle textures or not.
  25831. * Default value : true. The SPS is faster when it's set to false.
  25832. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25833. */
  25834. computeParticleTexture: boolean;
  25835. /**
  25836. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25837. * Default value : false. The SPS is faster when it's set to false.
  25838. * Note : the particle custom vertex positions aren't stored values.
  25839. */
  25840. /**
  25841. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25842. * Default value : false. The SPS is faster when it's set to false.
  25843. * Note : the particle custom vertex positions aren't stored values.
  25844. */
  25845. computeParticleVertex: boolean;
  25846. /**
  25847. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25848. */
  25849. /**
  25850. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25851. */
  25852. computeBoundingBox: boolean;
  25853. /**
  25854. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25856. * Default : `true`
  25857. */
  25858. /**
  25859. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25860. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25861. * Default : `true`
  25862. */
  25863. depthSortParticles: boolean;
  25864. /**
  25865. * Gets if the SPS is created as expandable at construction time.
  25866. * Default : `false`
  25867. */
  25868. readonly expandable: boolean;
  25869. /**
  25870. * This function does nothing. It may be overwritten to set all the particle first values.
  25871. * The SPS doesn't call this function, you may have to call it by your own.
  25872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25873. */
  25874. initParticles(): void;
  25875. /**
  25876. * This function does nothing. It may be overwritten to recycle a particle.
  25877. * The SPS doesn't call this function, you may have to call it by your own.
  25878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25879. * @param particle The particle to recycle
  25880. * @returns the recycled particle
  25881. */
  25882. recycleParticle(particle: SolidParticle): SolidParticle;
  25883. /**
  25884. * Updates a particle : this function should be overwritten by the user.
  25885. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25887. * @example : just set a particle position or velocity and recycle conditions
  25888. * @param particle The particle to update
  25889. * @returns the updated particle
  25890. */
  25891. updateParticle(particle: SolidParticle): SolidParticle;
  25892. /**
  25893. * Updates a vertex of a particle : it can be overwritten by the user.
  25894. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25895. * @param particle the current particle
  25896. * @param vertex the current index of the current particle
  25897. * @param pt the index of the current vertex in the particle shape
  25898. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25899. * @example : just set a vertex particle position
  25900. * @returns the updated vertex
  25901. */
  25902. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25903. /**
  25904. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25905. * This does nothing and may be overwritten by the user.
  25906. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25907. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25908. * @param update the boolean update value actually passed to setParticles()
  25909. */
  25910. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25911. /**
  25912. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25913. * This will be passed three parameters.
  25914. * This does nothing and may be overwritten by the user.
  25915. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25917. * @param update the boolean update value actually passed to setParticles()
  25918. */
  25919. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25920. }
  25921. }
  25922. declare module BABYLON {
  25923. /**
  25924. * Represents one particle of a solid particle system.
  25925. */
  25926. export class SolidParticle {
  25927. /**
  25928. * particle global index
  25929. */
  25930. idx: number;
  25931. /**
  25932. * particle identifier
  25933. */
  25934. id: number;
  25935. /**
  25936. * The color of the particle
  25937. */
  25938. color: Nullable<Color4>;
  25939. /**
  25940. * The world space position of the particle.
  25941. */
  25942. position: Vector3;
  25943. /**
  25944. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25945. */
  25946. rotation: Vector3;
  25947. /**
  25948. * The world space rotation quaternion of the particle.
  25949. */
  25950. rotationQuaternion: Nullable<Quaternion>;
  25951. /**
  25952. * The scaling of the particle.
  25953. */
  25954. scaling: Vector3;
  25955. /**
  25956. * The uvs of the particle.
  25957. */
  25958. uvs: Vector4;
  25959. /**
  25960. * The current speed of the particle.
  25961. */
  25962. velocity: Vector3;
  25963. /**
  25964. * The pivot point in the particle local space.
  25965. */
  25966. pivot: Vector3;
  25967. /**
  25968. * Must the particle be translated from its pivot point in its local space ?
  25969. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25970. * Default : false
  25971. */
  25972. translateFromPivot: boolean;
  25973. /**
  25974. * Is the particle active or not ?
  25975. */
  25976. alive: boolean;
  25977. /**
  25978. * Is the particle visible or not ?
  25979. */
  25980. isVisible: boolean;
  25981. /**
  25982. * Index of this particle in the global "positions" array (Internal use)
  25983. * @hidden
  25984. */
  25985. _pos: number;
  25986. /**
  25987. * @hidden Index of this particle in the global "indices" array (Internal use)
  25988. */
  25989. _ind: number;
  25990. /**
  25991. * @hidden ModelShape of this particle (Internal use)
  25992. */
  25993. _model: ModelShape;
  25994. /**
  25995. * ModelShape id of this particle
  25996. */
  25997. shapeId: number;
  25998. /**
  25999. * Index of the particle in its shape id
  26000. */
  26001. idxInShape: number;
  26002. /**
  26003. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26004. */
  26005. _modelBoundingInfo: BoundingInfo;
  26006. /**
  26007. * @hidden Particle BoundingInfo object (Internal use)
  26008. */
  26009. _boundingInfo: BoundingInfo;
  26010. /**
  26011. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26012. */
  26013. _sps: SolidParticleSystem;
  26014. /**
  26015. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26016. */
  26017. _stillInvisible: boolean;
  26018. /**
  26019. * @hidden Last computed particle rotation matrix
  26020. */
  26021. _rotationMatrix: number[];
  26022. /**
  26023. * Parent particle Id, if any.
  26024. * Default null.
  26025. */
  26026. parentId: Nullable<number>;
  26027. /**
  26028. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26029. * The possible values are :
  26030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26034. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26035. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26036. * */
  26037. cullingStrategy: number;
  26038. /**
  26039. * @hidden Internal global position in the SPS.
  26040. */
  26041. _globalPosition: Vector3;
  26042. /**
  26043. * Creates a Solid Particle object.
  26044. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26045. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26046. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26047. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26048. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26049. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26050. * @param shapeId (integer) is the model shape identifier in the SPS.
  26051. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26052. * @param sps defines the sps it is associated to
  26053. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26054. */
  26055. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26056. /**
  26057. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26058. * @param target the particle target
  26059. * @returns the current particle
  26060. */
  26061. copyToRef(target: SolidParticle): SolidParticle;
  26062. /**
  26063. * Legacy support, changed scale to scaling
  26064. */
  26065. /**
  26066. * Legacy support, changed scale to scaling
  26067. */
  26068. scale: Vector3;
  26069. /**
  26070. * Legacy support, changed quaternion to rotationQuaternion
  26071. */
  26072. /**
  26073. * Legacy support, changed quaternion to rotationQuaternion
  26074. */
  26075. quaternion: Nullable<Quaternion>;
  26076. /**
  26077. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26078. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26079. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26080. * @returns true if it intersects
  26081. */
  26082. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26083. /**
  26084. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26085. * A particle is in the frustum if its bounding box intersects the frustum
  26086. * @param frustumPlanes defines the frustum to test
  26087. * @returns true if the particle is in the frustum planes
  26088. */
  26089. isInFrustum(frustumPlanes: Plane[]): boolean;
  26090. /**
  26091. * get the rotation matrix of the particle
  26092. * @hidden
  26093. */
  26094. getRotationMatrix(m: Matrix): void;
  26095. }
  26096. /**
  26097. * Represents the shape of the model used by one particle of a solid particle system.
  26098. * SPS internal tool, don't use it manually.
  26099. */
  26100. export class ModelShape {
  26101. /**
  26102. * The shape id
  26103. * @hidden
  26104. */
  26105. shapeID: number;
  26106. /**
  26107. * flat array of model positions (internal use)
  26108. * @hidden
  26109. */
  26110. _shape: Vector3[];
  26111. /**
  26112. * flat array of model UVs (internal use)
  26113. * @hidden
  26114. */
  26115. _shapeUV: number[];
  26116. /**
  26117. * color array of the model
  26118. * @hidden
  26119. */
  26120. _shapeColors: number[];
  26121. /**
  26122. * indices array of the model
  26123. * @hidden
  26124. */
  26125. _indices: number[];
  26126. /**
  26127. * normals array of the model
  26128. * @hidden
  26129. */
  26130. _normals: number[];
  26131. /**
  26132. * length of the shape in the model indices array (internal use)
  26133. * @hidden
  26134. */
  26135. _indicesLength: number;
  26136. /**
  26137. * Custom position function (internal use)
  26138. * @hidden
  26139. */
  26140. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26141. /**
  26142. * Custom vertex function (internal use)
  26143. * @hidden
  26144. */
  26145. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26146. /**
  26147. * 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.
  26148. * SPS internal tool, don't use it manually.
  26149. * @hidden
  26150. */
  26151. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26152. }
  26153. /**
  26154. * Represents a Depth Sorted Particle in the solid particle system.
  26155. */
  26156. export class DepthSortedParticle {
  26157. /**
  26158. * Index of the particle in the "indices" array
  26159. */
  26160. ind: number;
  26161. /**
  26162. * Length of the particle shape in the "indices" array
  26163. */
  26164. indicesLength: number;
  26165. /**
  26166. * Squared distance from the particle to the camera
  26167. */
  26168. sqDistance: number;
  26169. }
  26170. }
  26171. declare module BABYLON {
  26172. /**
  26173. * @hidden
  26174. */
  26175. export class _MeshCollisionData {
  26176. _checkCollisions: boolean;
  26177. _collisionMask: number;
  26178. _collisionGroup: number;
  26179. _collider: Nullable<Collider>;
  26180. _oldPositionForCollisions: Vector3;
  26181. _diffPositionForCollisions: Vector3;
  26182. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26183. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26184. }
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. class _FacetDataStorage {
  26189. facetPositions: Vector3[];
  26190. facetNormals: Vector3[];
  26191. facetPartitioning: number[][];
  26192. facetNb: number;
  26193. partitioningSubdivisions: number;
  26194. partitioningBBoxRatio: number;
  26195. facetDataEnabled: boolean;
  26196. facetParameters: any;
  26197. bbSize: Vector3;
  26198. subDiv: {
  26199. max: number;
  26200. X: number;
  26201. Y: number;
  26202. Z: number;
  26203. };
  26204. facetDepthSort: boolean;
  26205. facetDepthSortEnabled: boolean;
  26206. depthSortedIndices: IndicesArray;
  26207. depthSortedFacets: {
  26208. ind: number;
  26209. sqDistance: number;
  26210. }[];
  26211. facetDepthSortFunction: (f1: {
  26212. ind: number;
  26213. sqDistance: number;
  26214. }, f2: {
  26215. ind: number;
  26216. sqDistance: number;
  26217. }) => number;
  26218. facetDepthSortFrom: Vector3;
  26219. facetDepthSortOrigin: Vector3;
  26220. invertedMatrix: Matrix;
  26221. }
  26222. /**
  26223. * @hidden
  26224. **/
  26225. class _InternalAbstractMeshDataInfo {
  26226. _hasVertexAlpha: boolean;
  26227. _useVertexColors: boolean;
  26228. _numBoneInfluencers: number;
  26229. _applyFog: boolean;
  26230. _receiveShadows: boolean;
  26231. _facetData: _FacetDataStorage;
  26232. _visibility: number;
  26233. _skeleton: Nullable<Skeleton>;
  26234. _layerMask: number;
  26235. _computeBonesUsingShaders: boolean;
  26236. _isActive: boolean;
  26237. _onlyForInstances: boolean;
  26238. _isActiveIntermediate: boolean;
  26239. _onlyForInstancesIntermediate: boolean;
  26240. _actAsRegularMesh: boolean;
  26241. }
  26242. /**
  26243. * Class used to store all common mesh properties
  26244. */
  26245. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26246. /** No occlusion */
  26247. static OCCLUSION_TYPE_NONE: number;
  26248. /** Occlusion set to optimisitic */
  26249. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26250. /** Occlusion set to strict */
  26251. static OCCLUSION_TYPE_STRICT: number;
  26252. /** Use an accurante occlusion algorithm */
  26253. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26254. /** Use a conservative occlusion algorithm */
  26255. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26256. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26257. * Test order :
  26258. * Is the bounding sphere outside the frustum ?
  26259. * If not, are the bounding box vertices outside the frustum ?
  26260. * It not, then the cullable object is in the frustum.
  26261. */
  26262. static readonly CULLINGSTRATEGY_STANDARD: number;
  26263. /** Culling strategy : Bounding Sphere Only.
  26264. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26265. * It's also less accurate than the standard because some not visible objects can still be selected.
  26266. * Test : is the bounding sphere outside the frustum ?
  26267. * If not, then the cullable object is in the frustum.
  26268. */
  26269. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26270. /** Culling strategy : Optimistic Inclusion.
  26271. * This in an inclusion test first, then the standard exclusion test.
  26272. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26273. * 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.
  26274. * Anyway, it's as accurate as the standard strategy.
  26275. * Test :
  26276. * Is the cullable object bounding sphere center in the frustum ?
  26277. * If not, apply the default culling strategy.
  26278. */
  26279. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26280. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26281. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26282. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26283. * 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.
  26284. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26285. * Test :
  26286. * Is the cullable object bounding sphere center in the frustum ?
  26287. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26288. */
  26289. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26290. /**
  26291. * No billboard
  26292. */
  26293. static readonly BILLBOARDMODE_NONE: number;
  26294. /** Billboard on X axis */
  26295. static readonly BILLBOARDMODE_X: number;
  26296. /** Billboard on Y axis */
  26297. static readonly BILLBOARDMODE_Y: number;
  26298. /** Billboard on Z axis */
  26299. static readonly BILLBOARDMODE_Z: number;
  26300. /** Billboard on all axes */
  26301. static readonly BILLBOARDMODE_ALL: number;
  26302. /** Billboard on using position instead of orientation */
  26303. static readonly BILLBOARDMODE_USE_POSITION: number;
  26304. /** @hidden */
  26305. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26306. /**
  26307. * The culling strategy to use to check whether the mesh must be rendered or not.
  26308. * This value can be changed at any time and will be used on the next render mesh selection.
  26309. * The possible values are :
  26310. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26311. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26313. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26314. * Please read each static variable documentation to get details about the culling process.
  26315. * */
  26316. cullingStrategy: number;
  26317. /**
  26318. * Gets the number of facets in the mesh
  26319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26320. */
  26321. readonly facetNb: number;
  26322. /**
  26323. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26325. */
  26326. partitioningSubdivisions: number;
  26327. /**
  26328. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26329. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26331. */
  26332. partitioningBBoxRatio: number;
  26333. /**
  26334. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26335. * Works only for updatable meshes.
  26336. * Doesn't work with multi-materials
  26337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26338. */
  26339. mustDepthSortFacets: boolean;
  26340. /**
  26341. * The location (Vector3) where the facet depth sort must be computed from.
  26342. * By default, the active camera position.
  26343. * Used only when facet depth sort is enabled
  26344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26345. */
  26346. facetDepthSortFrom: Vector3;
  26347. /**
  26348. * gets a boolean indicating if facetData is enabled
  26349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26350. */
  26351. readonly isFacetDataEnabled: boolean;
  26352. /** @hidden */
  26353. _updateNonUniformScalingState(value: boolean): boolean;
  26354. /**
  26355. * An event triggered when this mesh collides with another one
  26356. */
  26357. onCollideObservable: Observable<AbstractMesh>;
  26358. /** Set a function to call when this mesh collides with another one */
  26359. onCollide: () => void;
  26360. /**
  26361. * An event triggered when the collision's position changes
  26362. */
  26363. onCollisionPositionChangeObservable: Observable<Vector3>;
  26364. /** Set a function to call when the collision's position changes */
  26365. onCollisionPositionChange: () => void;
  26366. /**
  26367. * An event triggered when material is changed
  26368. */
  26369. onMaterialChangedObservable: Observable<AbstractMesh>;
  26370. /**
  26371. * Gets or sets the orientation for POV movement & rotation
  26372. */
  26373. definedFacingForward: boolean;
  26374. /** @hidden */
  26375. _occlusionQuery: Nullable<WebGLQuery>;
  26376. /** @hidden */
  26377. _renderingGroup: Nullable<RenderingGroup>;
  26378. /**
  26379. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26380. */
  26381. /**
  26382. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26383. */
  26384. visibility: number;
  26385. /** Gets or sets the alpha index used to sort transparent meshes
  26386. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26387. */
  26388. alphaIndex: number;
  26389. /**
  26390. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26391. */
  26392. isVisible: boolean;
  26393. /**
  26394. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26395. */
  26396. isPickable: boolean;
  26397. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26398. showSubMeshesBoundingBox: boolean;
  26399. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26401. */
  26402. isBlocker: boolean;
  26403. /**
  26404. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26405. */
  26406. enablePointerMoveEvents: boolean;
  26407. /**
  26408. * Specifies the rendering group id for this mesh (0 by default)
  26409. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26410. */
  26411. renderingGroupId: number;
  26412. private _material;
  26413. /** Gets or sets current material */
  26414. material: Nullable<Material>;
  26415. /**
  26416. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26417. * @see http://doc.babylonjs.com/babylon101/shadows
  26418. */
  26419. receiveShadows: boolean;
  26420. /** Defines color to use when rendering outline */
  26421. outlineColor: Color3;
  26422. /** Define width to use when rendering outline */
  26423. outlineWidth: number;
  26424. /** Defines color to use when rendering overlay */
  26425. overlayColor: Color3;
  26426. /** Defines alpha to use when rendering overlay */
  26427. overlayAlpha: number;
  26428. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26429. hasVertexAlpha: boolean;
  26430. /** 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) */
  26431. useVertexColors: boolean;
  26432. /**
  26433. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26434. */
  26435. computeBonesUsingShaders: boolean;
  26436. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26437. numBoneInfluencers: number;
  26438. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26439. applyFog: boolean;
  26440. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26441. useOctreeForRenderingSelection: boolean;
  26442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26443. useOctreeForPicking: boolean;
  26444. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26445. useOctreeForCollisions: boolean;
  26446. /**
  26447. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26448. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26449. */
  26450. layerMask: number;
  26451. /**
  26452. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26453. */
  26454. alwaysSelectAsActiveMesh: boolean;
  26455. /**
  26456. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26457. */
  26458. doNotSyncBoundingInfo: boolean;
  26459. /**
  26460. * Gets or sets the current action manager
  26461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26462. */
  26463. actionManager: Nullable<AbstractActionManager>;
  26464. private _meshCollisionData;
  26465. /**
  26466. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26468. */
  26469. ellipsoid: Vector3;
  26470. /**
  26471. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26473. */
  26474. ellipsoidOffset: Vector3;
  26475. /**
  26476. * Gets or sets a collision mask used to mask collisions (default is -1).
  26477. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26478. */
  26479. collisionMask: number;
  26480. /**
  26481. * Gets or sets the current collision group mask (-1 by default).
  26482. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26483. */
  26484. collisionGroup: number;
  26485. /**
  26486. * Defines edge width used when edgesRenderer is enabled
  26487. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26488. */
  26489. edgesWidth: number;
  26490. /**
  26491. * Defines edge color used when edgesRenderer is enabled
  26492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26493. */
  26494. edgesColor: Color4;
  26495. /** @hidden */
  26496. _edgesRenderer: Nullable<IEdgesRenderer>;
  26497. /** @hidden */
  26498. _masterMesh: Nullable<AbstractMesh>;
  26499. /** @hidden */
  26500. _boundingInfo: Nullable<BoundingInfo>;
  26501. /** @hidden */
  26502. _renderId: number;
  26503. /**
  26504. * Gets or sets the list of subMeshes
  26505. * @see http://doc.babylonjs.com/how_to/multi_materials
  26506. */
  26507. subMeshes: SubMesh[];
  26508. /** @hidden */
  26509. _intersectionsInProgress: AbstractMesh[];
  26510. /** @hidden */
  26511. _unIndexed: boolean;
  26512. /** @hidden */
  26513. _lightSources: Light[];
  26514. /** Gets the list of lights affecting that mesh */
  26515. readonly lightSources: Light[];
  26516. /** @hidden */
  26517. readonly _positions: Nullable<Vector3[]>;
  26518. /** @hidden */
  26519. _waitingData: {
  26520. lods: Nullable<any>;
  26521. actions: Nullable<any>;
  26522. freezeWorldMatrix: Nullable<boolean>;
  26523. };
  26524. /** @hidden */
  26525. _bonesTransformMatrices: Nullable<Float32Array>;
  26526. /** @hidden */
  26527. _transformMatrixTexture: Nullable<RawTexture>;
  26528. /**
  26529. * Gets or sets a skeleton to apply skining transformations
  26530. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26531. */
  26532. skeleton: Nullable<Skeleton>;
  26533. /**
  26534. * An event triggered when the mesh is rebuilt.
  26535. */
  26536. onRebuildObservable: Observable<AbstractMesh>;
  26537. /**
  26538. * Creates a new AbstractMesh
  26539. * @param name defines the name of the mesh
  26540. * @param scene defines the hosting scene
  26541. */
  26542. constructor(name: string, scene?: Nullable<Scene>);
  26543. /**
  26544. * Returns the string "AbstractMesh"
  26545. * @returns "AbstractMesh"
  26546. */
  26547. getClassName(): string;
  26548. /**
  26549. * Gets a string representation of the current mesh
  26550. * @param fullDetails defines a boolean indicating if full details must be included
  26551. * @returns a string representation of the current mesh
  26552. */
  26553. toString(fullDetails?: boolean): string;
  26554. /**
  26555. * @hidden
  26556. */
  26557. protected _getEffectiveParent(): Nullable<Node>;
  26558. /** @hidden */
  26559. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26560. /** @hidden */
  26561. _rebuild(): void;
  26562. /** @hidden */
  26563. _resyncLightSources(): void;
  26564. /** @hidden */
  26565. _resyncLighSource(light: Light): void;
  26566. /** @hidden */
  26567. _unBindEffect(): void;
  26568. /** @hidden */
  26569. _removeLightSource(light: Light, dispose: boolean): void;
  26570. private _markSubMeshesAsDirty;
  26571. /** @hidden */
  26572. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26573. /** @hidden */
  26574. _markSubMeshesAsAttributesDirty(): void;
  26575. /** @hidden */
  26576. _markSubMeshesAsMiscDirty(): void;
  26577. /**
  26578. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26579. */
  26580. scaling: Vector3;
  26581. /**
  26582. * Returns true if the mesh is blocked. Implemented by child classes
  26583. */
  26584. readonly isBlocked: boolean;
  26585. /**
  26586. * Returns the mesh itself by default. Implemented by child classes
  26587. * @param camera defines the camera to use to pick the right LOD level
  26588. * @returns the currentAbstractMesh
  26589. */
  26590. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26591. /**
  26592. * Returns 0 by default. Implemented by child classes
  26593. * @returns an integer
  26594. */
  26595. getTotalVertices(): number;
  26596. /**
  26597. * Returns a positive integer : the total number of indices in this mesh geometry.
  26598. * @returns the numner of indices or zero if the mesh has no geometry.
  26599. */
  26600. getTotalIndices(): number;
  26601. /**
  26602. * Returns null by default. Implemented by child classes
  26603. * @returns null
  26604. */
  26605. getIndices(): Nullable<IndicesArray>;
  26606. /**
  26607. * Returns the array of the requested vertex data kind. Implemented by child classes
  26608. * @param kind defines the vertex data kind to use
  26609. * @returns null
  26610. */
  26611. getVerticesData(kind: string): Nullable<FloatArray>;
  26612. /**
  26613. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26614. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26615. * Note that a new underlying VertexBuffer object is created each call.
  26616. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26617. * @param kind defines vertex data kind:
  26618. * * VertexBuffer.PositionKind
  26619. * * VertexBuffer.UVKind
  26620. * * VertexBuffer.UV2Kind
  26621. * * VertexBuffer.UV3Kind
  26622. * * VertexBuffer.UV4Kind
  26623. * * VertexBuffer.UV5Kind
  26624. * * VertexBuffer.UV6Kind
  26625. * * VertexBuffer.ColorKind
  26626. * * VertexBuffer.MatricesIndicesKind
  26627. * * VertexBuffer.MatricesIndicesExtraKind
  26628. * * VertexBuffer.MatricesWeightsKind
  26629. * * VertexBuffer.MatricesWeightsExtraKind
  26630. * @param data defines the data source
  26631. * @param updatable defines if the data must be flagged as updatable (or static)
  26632. * @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
  26633. * @returns the current mesh
  26634. */
  26635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26636. /**
  26637. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26638. * If the mesh has no geometry, it is simply returned as it is.
  26639. * @param kind defines vertex data kind:
  26640. * * VertexBuffer.PositionKind
  26641. * * VertexBuffer.UVKind
  26642. * * VertexBuffer.UV2Kind
  26643. * * VertexBuffer.UV3Kind
  26644. * * VertexBuffer.UV4Kind
  26645. * * VertexBuffer.UV5Kind
  26646. * * VertexBuffer.UV6Kind
  26647. * * VertexBuffer.ColorKind
  26648. * * VertexBuffer.MatricesIndicesKind
  26649. * * VertexBuffer.MatricesIndicesExtraKind
  26650. * * VertexBuffer.MatricesWeightsKind
  26651. * * VertexBuffer.MatricesWeightsExtraKind
  26652. * @param data defines the data source
  26653. * @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
  26654. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26655. * @returns the current mesh
  26656. */
  26657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26658. /**
  26659. * Sets the mesh indices,
  26660. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26661. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26662. * @param totalVertices Defines the total number of vertices
  26663. * @returns the current mesh
  26664. */
  26665. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26666. /**
  26667. * Gets a boolean indicating if specific vertex data is present
  26668. * @param kind defines the vertex data kind to use
  26669. * @returns true is data kind is present
  26670. */
  26671. isVerticesDataPresent(kind: string): boolean;
  26672. /**
  26673. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26674. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26675. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26676. * @returns a BoundingInfo
  26677. */
  26678. getBoundingInfo(): BoundingInfo;
  26679. /**
  26680. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26681. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26682. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26683. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26684. * @returns the current mesh
  26685. */
  26686. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26687. /**
  26688. * Overwrite the current bounding info
  26689. * @param boundingInfo defines the new bounding info
  26690. * @returns the current mesh
  26691. */
  26692. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26693. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26694. readonly useBones: boolean;
  26695. /** @hidden */
  26696. _preActivate(): void;
  26697. /** @hidden */
  26698. _preActivateForIntermediateRendering(renderId: number): void;
  26699. /** @hidden */
  26700. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26701. /** @hidden */
  26702. _postActivate(): void;
  26703. /** @hidden */
  26704. _freeze(): void;
  26705. /** @hidden */
  26706. _unFreeze(): void;
  26707. /**
  26708. * Gets the current world matrix
  26709. * @returns a Matrix
  26710. */
  26711. getWorldMatrix(): Matrix;
  26712. /** @hidden */
  26713. _getWorldMatrixDeterminant(): number;
  26714. /**
  26715. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26716. */
  26717. readonly isAnInstance: boolean;
  26718. /**
  26719. * Gets a boolean indicating if this mesh has instances
  26720. */
  26721. readonly hasInstances: boolean;
  26722. /**
  26723. * Perform relative position change from the point of view of behind the front of the mesh.
  26724. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26725. * Supports definition of mesh facing forward or backward
  26726. * @param amountRight defines the distance on the right axis
  26727. * @param amountUp defines the distance on the up axis
  26728. * @param amountForward defines the distance on the forward axis
  26729. * @returns the current mesh
  26730. */
  26731. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26732. /**
  26733. * Calculate relative position change from the point of view of behind the front of the mesh.
  26734. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26735. * Supports definition of mesh facing forward or backward
  26736. * @param amountRight defines the distance on the right axis
  26737. * @param amountUp defines the distance on the up axis
  26738. * @param amountForward defines the distance on the forward axis
  26739. * @returns the new displacement vector
  26740. */
  26741. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26742. /**
  26743. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26744. * Supports definition of mesh facing forward or backward
  26745. * @param flipBack defines the flip
  26746. * @param twirlClockwise defines the twirl
  26747. * @param tiltRight defines the tilt
  26748. * @returns the current mesh
  26749. */
  26750. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26751. /**
  26752. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26753. * Supports definition of mesh facing forward or backward.
  26754. * @param flipBack defines the flip
  26755. * @param twirlClockwise defines the twirl
  26756. * @param tiltRight defines the tilt
  26757. * @returns the new rotation vector
  26758. */
  26759. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26760. /**
  26761. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26762. * This means the mesh underlying bounding box and sphere are recomputed.
  26763. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26764. * @returns the current mesh
  26765. */
  26766. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26767. /** @hidden */
  26768. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26769. /** @hidden */
  26770. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26771. /** @hidden */
  26772. _updateBoundingInfo(): AbstractMesh;
  26773. /** @hidden */
  26774. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26775. /** @hidden */
  26776. protected _afterComputeWorldMatrix(): void;
  26777. /** @hidden */
  26778. readonly _effectiveMesh: AbstractMesh;
  26779. /**
  26780. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26781. * A mesh is in the frustum if its bounding box intersects the frustum
  26782. * @param frustumPlanes defines the frustum to test
  26783. * @returns true if the mesh is in the frustum planes
  26784. */
  26785. isInFrustum(frustumPlanes: Plane[]): boolean;
  26786. /**
  26787. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26788. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26789. * @param frustumPlanes defines the frustum to test
  26790. * @returns true if the mesh is completely in the frustum planes
  26791. */
  26792. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26793. /**
  26794. * True if the mesh intersects another mesh or a SolidParticle object
  26795. * @param mesh defines a target mesh or SolidParticle to test
  26796. * @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)
  26797. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26798. * @returns true if there is an intersection
  26799. */
  26800. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26801. /**
  26802. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26803. * @param point defines the point to test
  26804. * @returns true if there is an intersection
  26805. */
  26806. intersectsPoint(point: Vector3): boolean;
  26807. /**
  26808. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26810. */
  26811. checkCollisions: boolean;
  26812. /**
  26813. * Gets Collider object used to compute collisions (not physics)
  26814. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26815. */
  26816. readonly collider: Nullable<Collider>;
  26817. /**
  26818. * Move the mesh using collision engine
  26819. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26820. * @param displacement defines the requested displacement vector
  26821. * @returns the current mesh
  26822. */
  26823. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26824. private _onCollisionPositionChange;
  26825. /** @hidden */
  26826. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26827. /** @hidden */
  26828. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26829. /** @hidden */
  26830. _checkCollision(collider: Collider): AbstractMesh;
  26831. /** @hidden */
  26832. _generatePointsArray(): boolean;
  26833. /**
  26834. * Checks if the passed Ray intersects with the mesh
  26835. * @param ray defines the ray to use
  26836. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26837. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26838. * @returns the picking info
  26839. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26840. */
  26841. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26842. /**
  26843. * Clones the current mesh
  26844. * @param name defines the mesh name
  26845. * @param newParent defines the new mesh parent
  26846. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26847. * @returns the new mesh
  26848. */
  26849. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26850. /**
  26851. * Disposes all the submeshes of the current meshnp
  26852. * @returns the current mesh
  26853. */
  26854. releaseSubMeshes(): AbstractMesh;
  26855. /**
  26856. * Releases resources associated with this abstract mesh.
  26857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26859. */
  26860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26861. /**
  26862. * Adds the passed mesh as a child to the current mesh
  26863. * @param mesh defines the child mesh
  26864. * @returns the current mesh
  26865. */
  26866. addChild(mesh: AbstractMesh): AbstractMesh;
  26867. /**
  26868. * Removes the passed mesh from the current mesh children list
  26869. * @param mesh defines the child mesh
  26870. * @returns the current mesh
  26871. */
  26872. removeChild(mesh: AbstractMesh): AbstractMesh;
  26873. /** @hidden */
  26874. private _initFacetData;
  26875. /**
  26876. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26877. * This method can be called within the render loop.
  26878. * 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
  26879. * @returns the current mesh
  26880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26881. */
  26882. updateFacetData(): AbstractMesh;
  26883. /**
  26884. * Returns the facetLocalNormals array.
  26885. * The normals are expressed in the mesh local spac
  26886. * @returns an array of Vector3
  26887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26888. */
  26889. getFacetLocalNormals(): Vector3[];
  26890. /**
  26891. * Returns the facetLocalPositions array.
  26892. * The facet positions are expressed in the mesh local space
  26893. * @returns an array of Vector3
  26894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26895. */
  26896. getFacetLocalPositions(): Vector3[];
  26897. /**
  26898. * Returns the facetLocalPartioning array
  26899. * @returns an array of array of numbers
  26900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26901. */
  26902. getFacetLocalPartitioning(): number[][];
  26903. /**
  26904. * Returns the i-th facet position in the world system.
  26905. * This method allocates a new Vector3 per call
  26906. * @param i defines the facet index
  26907. * @returns a new Vector3
  26908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26909. */
  26910. getFacetPosition(i: number): Vector3;
  26911. /**
  26912. * Sets the reference Vector3 with the i-th facet position in the world system
  26913. * @param i defines the facet index
  26914. * @param ref defines the target vector
  26915. * @returns the current mesh
  26916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26917. */
  26918. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26919. /**
  26920. * Returns the i-th facet normal in the world system.
  26921. * This method allocates a new Vector3 per call
  26922. * @param i defines the facet index
  26923. * @returns a new Vector3
  26924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26925. */
  26926. getFacetNormal(i: number): Vector3;
  26927. /**
  26928. * Sets the reference Vector3 with the i-th facet normal in the world system
  26929. * @param i defines the facet index
  26930. * @param ref defines the target vector
  26931. * @returns the current mesh
  26932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26933. */
  26934. getFacetNormalToRef(i: number, ref: Vector3): this;
  26935. /**
  26936. * 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)
  26937. * @param x defines x coordinate
  26938. * @param y defines y coordinate
  26939. * @param z defines z coordinate
  26940. * @returns the array of facet indexes
  26941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26942. */
  26943. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26944. /**
  26945. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26946. * @param projected sets as the (x,y,z) world projection on the facet
  26947. * @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
  26948. * @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
  26949. * @param x defines x coordinate
  26950. * @param y defines y coordinate
  26951. * @param z defines z coordinate
  26952. * @returns the face index if found (or null instead)
  26953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26954. */
  26955. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26956. /**
  26957. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26958. * @param projected sets as the (x,y,z) local projection on the facet
  26959. * @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
  26960. * @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
  26961. * @param x defines x coordinate
  26962. * @param y defines y coordinate
  26963. * @param z defines z coordinate
  26964. * @returns the face index if found (or null instead)
  26965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26966. */
  26967. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26968. /**
  26969. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26970. * @returns the parameters
  26971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26972. */
  26973. getFacetDataParameters(): any;
  26974. /**
  26975. * Disables the feature FacetData and frees the related memory
  26976. * @returns the current mesh
  26977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26978. */
  26979. disableFacetData(): AbstractMesh;
  26980. /**
  26981. * Updates the AbstractMesh indices array
  26982. * @param indices defines the data source
  26983. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26984. * @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)
  26985. * @returns the current mesh
  26986. */
  26987. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26988. /**
  26989. * Creates new normals data for the mesh
  26990. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26991. * @returns the current mesh
  26992. */
  26993. createNormals(updatable: boolean): AbstractMesh;
  26994. /**
  26995. * Align the mesh with a normal
  26996. * @param normal defines the normal to use
  26997. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26998. * @returns the current mesh
  26999. */
  27000. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27001. /** @hidden */
  27002. _checkOcclusionQuery(): boolean;
  27003. /**
  27004. * Disables the mesh edge rendering mode
  27005. * @returns the currentAbstractMesh
  27006. */
  27007. disableEdgesRendering(): AbstractMesh;
  27008. /**
  27009. * Enables the edge rendering mode on the mesh.
  27010. * This mode makes the mesh edges visible
  27011. * @param epsilon defines the maximal distance between two angles to detect a face
  27012. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27013. * @returns the currentAbstractMesh
  27014. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27015. */
  27016. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27017. }
  27018. }
  27019. declare module BABYLON {
  27020. /**
  27021. * Interface used to define ActionEvent
  27022. */
  27023. export interface IActionEvent {
  27024. /** The mesh or sprite that triggered the action */
  27025. source: any;
  27026. /** The X mouse cursor position at the time of the event */
  27027. pointerX: number;
  27028. /** The Y mouse cursor position at the time of the event */
  27029. pointerY: number;
  27030. /** The mesh that is currently pointed at (can be null) */
  27031. meshUnderPointer: Nullable<AbstractMesh>;
  27032. /** the original (browser) event that triggered the ActionEvent */
  27033. sourceEvent?: any;
  27034. /** additional data for the event */
  27035. additionalData?: any;
  27036. }
  27037. /**
  27038. * ActionEvent is the event being sent when an action is triggered.
  27039. */
  27040. export class ActionEvent implements IActionEvent {
  27041. /** The mesh or sprite that triggered the action */
  27042. source: any;
  27043. /** The X mouse cursor position at the time of the event */
  27044. pointerX: number;
  27045. /** The Y mouse cursor position at the time of the event */
  27046. pointerY: number;
  27047. /** The mesh that is currently pointed at (can be null) */
  27048. meshUnderPointer: Nullable<AbstractMesh>;
  27049. /** the original (browser) event that triggered the ActionEvent */
  27050. sourceEvent?: any;
  27051. /** additional data for the event */
  27052. additionalData?: any;
  27053. /**
  27054. * Creates a new ActionEvent
  27055. * @param source The mesh or sprite that triggered the action
  27056. * @param pointerX The X mouse cursor position at the time of the event
  27057. * @param pointerY The Y mouse cursor position at the time of the event
  27058. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27059. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27060. * @param additionalData additional data for the event
  27061. */
  27062. constructor(
  27063. /** The mesh or sprite that triggered the action */
  27064. source: any,
  27065. /** The X mouse cursor position at the time of the event */
  27066. pointerX: number,
  27067. /** The Y mouse cursor position at the time of the event */
  27068. pointerY: number,
  27069. /** The mesh that is currently pointed at (can be null) */
  27070. meshUnderPointer: Nullable<AbstractMesh>,
  27071. /** the original (browser) event that triggered the ActionEvent */
  27072. sourceEvent?: any,
  27073. /** additional data for the event */
  27074. additionalData?: any);
  27075. /**
  27076. * Helper function to auto-create an ActionEvent from a source mesh.
  27077. * @param source The source mesh that triggered the event
  27078. * @param evt The original (browser) event
  27079. * @param additionalData additional data for the event
  27080. * @returns the new ActionEvent
  27081. */
  27082. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27083. /**
  27084. * Helper function to auto-create an ActionEvent from a source sprite
  27085. * @param source The source sprite that triggered the event
  27086. * @param scene Scene associated with the sprite
  27087. * @param evt The original (browser) event
  27088. * @param additionalData additional data for the event
  27089. * @returns the new ActionEvent
  27090. */
  27091. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27092. /**
  27093. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27094. * @param scene the scene where the event occurred
  27095. * @param evt The original (browser) event
  27096. * @returns the new ActionEvent
  27097. */
  27098. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27099. /**
  27100. * Helper function to auto-create an ActionEvent from a primitive
  27101. * @param prim defines the target primitive
  27102. * @param pointerPos defines the pointer position
  27103. * @param evt The original (browser) event
  27104. * @param additionalData additional data for the event
  27105. * @returns the new ActionEvent
  27106. */
  27107. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27108. }
  27109. }
  27110. declare module BABYLON {
  27111. /**
  27112. * Abstract class used to decouple action Manager from scene and meshes.
  27113. * Do not instantiate.
  27114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27115. */
  27116. export abstract class AbstractActionManager implements IDisposable {
  27117. /** Gets the list of active triggers */
  27118. static Triggers: {
  27119. [key: string]: number;
  27120. };
  27121. /** Gets the cursor to use when hovering items */
  27122. hoverCursor: string;
  27123. /** Gets the list of actions */
  27124. actions: IAction[];
  27125. /**
  27126. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27127. */
  27128. isRecursive: boolean;
  27129. /**
  27130. * Releases all associated resources
  27131. */
  27132. abstract dispose(): void;
  27133. /**
  27134. * Does this action manager has pointer triggers
  27135. */
  27136. abstract readonly hasPointerTriggers: boolean;
  27137. /**
  27138. * Does this action manager has pick triggers
  27139. */
  27140. abstract readonly hasPickTriggers: boolean;
  27141. /**
  27142. * Process a specific trigger
  27143. * @param trigger defines the trigger to process
  27144. * @param evt defines the event details to be processed
  27145. */
  27146. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27147. /**
  27148. * Does this action manager handles actions of any of the given triggers
  27149. * @param triggers defines the triggers to be tested
  27150. * @return a boolean indicating whether one (or more) of the triggers is handled
  27151. */
  27152. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27153. /**
  27154. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27155. * speed.
  27156. * @param triggerA defines the trigger to be tested
  27157. * @param triggerB defines the trigger to be tested
  27158. * @return a boolean indicating whether one (or more) of the triggers is handled
  27159. */
  27160. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27161. /**
  27162. * Does this action manager handles actions of a given trigger
  27163. * @param trigger defines the trigger to be tested
  27164. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27165. * @return whether the trigger is handled
  27166. */
  27167. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27168. /**
  27169. * Serialize this manager to a JSON object
  27170. * @param name defines the property name to store this manager
  27171. * @returns a JSON representation of this manager
  27172. */
  27173. abstract serialize(name: string): any;
  27174. /**
  27175. * Registers an action to this action manager
  27176. * @param action defines the action to be registered
  27177. * @return the action amended (prepared) after registration
  27178. */
  27179. abstract registerAction(action: IAction): Nullable<IAction>;
  27180. /**
  27181. * Unregisters an action to this action manager
  27182. * @param action defines the action to be unregistered
  27183. * @return a boolean indicating whether the action has been unregistered
  27184. */
  27185. abstract unregisterAction(action: IAction): Boolean;
  27186. /**
  27187. * Does exist one action manager with at least one trigger
  27188. **/
  27189. static readonly HasTriggers: boolean;
  27190. /**
  27191. * Does exist one action manager with at least one pick trigger
  27192. **/
  27193. static readonly HasPickTriggers: boolean;
  27194. /**
  27195. * Does exist one action manager that handles actions of a given trigger
  27196. * @param trigger defines the trigger to be tested
  27197. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27198. **/
  27199. static HasSpecificTrigger(trigger: number): boolean;
  27200. }
  27201. }
  27202. declare module BABYLON {
  27203. /**
  27204. * Defines how a node can be built from a string name.
  27205. */
  27206. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27207. /**
  27208. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27209. */
  27210. export class Node implements IBehaviorAware<Node> {
  27211. /** @hidden */
  27212. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  27213. private static _NodeConstructors;
  27214. /**
  27215. * Add a new node constructor
  27216. * @param type defines the type name of the node to construct
  27217. * @param constructorFunc defines the constructor function
  27218. */
  27219. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27220. /**
  27221. * Returns a node constructor based on type name
  27222. * @param type defines the type name
  27223. * @param name defines the new node name
  27224. * @param scene defines the hosting scene
  27225. * @param options defines optional options to transmit to constructors
  27226. * @returns the new constructor or null
  27227. */
  27228. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27229. /**
  27230. * Gets or sets the name of the node
  27231. */
  27232. name: string;
  27233. /**
  27234. * Gets or sets the id of the node
  27235. */
  27236. id: string;
  27237. /**
  27238. * Gets or sets the unique id of the node
  27239. */
  27240. uniqueId: number;
  27241. /**
  27242. * Gets or sets a string used to store user defined state for the node
  27243. */
  27244. state: string;
  27245. /**
  27246. * Gets or sets an object used to store user defined information for the node
  27247. */
  27248. metadata: any;
  27249. /**
  27250. * For internal use only. Please do not use.
  27251. */
  27252. reservedDataStore: any;
  27253. /**
  27254. * List of inspectable custom properties (used by the Inspector)
  27255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27256. */
  27257. inspectableCustomProperties: IInspectable[];
  27258. private _doNotSerialize;
  27259. /**
  27260. * Gets or sets a boolean used to define if the node must be serialized
  27261. */
  27262. doNotSerialize: boolean;
  27263. /** @hidden */
  27264. _isDisposed: boolean;
  27265. /**
  27266. * Gets a list of Animations associated with the node
  27267. */
  27268. animations: Animation[];
  27269. protected _ranges: {
  27270. [name: string]: Nullable<AnimationRange>;
  27271. };
  27272. /**
  27273. * Callback raised when the node is ready to be used
  27274. */
  27275. onReady: Nullable<(node: Node) => void>;
  27276. private _isEnabled;
  27277. private _isParentEnabled;
  27278. private _isReady;
  27279. /** @hidden */
  27280. _currentRenderId: number;
  27281. private _parentUpdateId;
  27282. /** @hidden */
  27283. _childUpdateId: number;
  27284. /** @hidden */
  27285. _waitingParentId: Nullable<string>;
  27286. /** @hidden */
  27287. _scene: Scene;
  27288. /** @hidden */
  27289. _cache: any;
  27290. private _parentNode;
  27291. private _children;
  27292. /** @hidden */
  27293. _worldMatrix: Matrix;
  27294. /** @hidden */
  27295. _worldMatrixDeterminant: number;
  27296. /** @hidden */
  27297. _worldMatrixDeterminantIsDirty: boolean;
  27298. /** @hidden */
  27299. private _sceneRootNodesIndex;
  27300. /**
  27301. * Gets a boolean indicating if the node has been disposed
  27302. * @returns true if the node was disposed
  27303. */
  27304. isDisposed(): boolean;
  27305. /**
  27306. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27307. * @see https://doc.babylonjs.com/how_to/parenting
  27308. */
  27309. parent: Nullable<Node>;
  27310. /** @hidden */
  27311. _addToSceneRootNodes(): void;
  27312. /** @hidden */
  27313. _removeFromSceneRootNodes(): void;
  27314. private _animationPropertiesOverride;
  27315. /**
  27316. * Gets or sets the animation properties override
  27317. */
  27318. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27319. /**
  27320. * Gets a string idenfifying the name of the class
  27321. * @returns "Node" string
  27322. */
  27323. getClassName(): string;
  27324. /** @hidden */
  27325. readonly _isNode: boolean;
  27326. /**
  27327. * An event triggered when the mesh is disposed
  27328. */
  27329. onDisposeObservable: Observable<Node>;
  27330. private _onDisposeObserver;
  27331. /**
  27332. * Sets a callback that will be raised when the node will be disposed
  27333. */
  27334. onDispose: () => void;
  27335. /**
  27336. * Creates a new Node
  27337. * @param name the name and id to be given to this node
  27338. * @param scene the scene this node will be added to
  27339. */
  27340. constructor(name: string, scene?: Nullable<Scene>);
  27341. /**
  27342. * Gets the scene of the node
  27343. * @returns a scene
  27344. */
  27345. getScene(): Scene;
  27346. /**
  27347. * Gets the engine of the node
  27348. * @returns a Engine
  27349. */
  27350. getEngine(): Engine;
  27351. private _behaviors;
  27352. /**
  27353. * Attach a behavior to the node
  27354. * @see http://doc.babylonjs.com/features/behaviour
  27355. * @param behavior defines the behavior to attach
  27356. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27357. * @returns the current Node
  27358. */
  27359. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27360. /**
  27361. * Remove an attached behavior
  27362. * @see http://doc.babylonjs.com/features/behaviour
  27363. * @param behavior defines the behavior to attach
  27364. * @returns the current Node
  27365. */
  27366. removeBehavior(behavior: Behavior<Node>): Node;
  27367. /**
  27368. * Gets the list of attached behaviors
  27369. * @see http://doc.babylonjs.com/features/behaviour
  27370. */
  27371. readonly behaviors: Behavior<Node>[];
  27372. /**
  27373. * Gets an attached behavior by name
  27374. * @param name defines the name of the behavior to look for
  27375. * @see http://doc.babylonjs.com/features/behaviour
  27376. * @returns null if behavior was not found else the requested behavior
  27377. */
  27378. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27379. /**
  27380. * Returns the latest update of the World matrix
  27381. * @returns a Matrix
  27382. */
  27383. getWorldMatrix(): Matrix;
  27384. /** @hidden */
  27385. _getWorldMatrixDeterminant(): number;
  27386. /**
  27387. * Returns directly the latest state of the mesh World matrix.
  27388. * A Matrix is returned.
  27389. */
  27390. readonly worldMatrixFromCache: Matrix;
  27391. /** @hidden */
  27392. _initCache(): void;
  27393. /** @hidden */
  27394. updateCache(force?: boolean): void;
  27395. /** @hidden */
  27396. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27397. /** @hidden */
  27398. _updateCache(ignoreParentClass?: boolean): void;
  27399. /** @hidden */
  27400. _isSynchronized(): boolean;
  27401. /** @hidden */
  27402. _markSyncedWithParent(): void;
  27403. /** @hidden */
  27404. isSynchronizedWithParent(): boolean;
  27405. /** @hidden */
  27406. isSynchronized(): boolean;
  27407. /**
  27408. * Is this node ready to be used/rendered
  27409. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27410. * @return true if the node is ready
  27411. */
  27412. isReady(completeCheck?: boolean): boolean;
  27413. /**
  27414. * Is this node enabled?
  27415. * 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
  27416. * @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
  27417. * @return whether this node (and its parent) is enabled
  27418. */
  27419. isEnabled(checkAncestors?: boolean): boolean;
  27420. /** @hidden */
  27421. protected _syncParentEnabledState(): void;
  27422. /**
  27423. * Set the enabled state of this node
  27424. * @param value defines the new enabled state
  27425. */
  27426. setEnabled(value: boolean): void;
  27427. /**
  27428. * Is this node a descendant of the given node?
  27429. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27430. * @param ancestor defines the parent node to inspect
  27431. * @returns a boolean indicating if this node is a descendant of the given node
  27432. */
  27433. isDescendantOf(ancestor: Node): boolean;
  27434. /** @hidden */
  27435. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27436. /**
  27437. * Will return all nodes that have this node as ascendant
  27438. * @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
  27439. * @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
  27440. * @return all children nodes of all types
  27441. */
  27442. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27443. /**
  27444. * Get all child-meshes of this node
  27445. * @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)
  27446. * @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
  27447. * @returns an array of AbstractMesh
  27448. */
  27449. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27450. /**
  27451. * Get all direct children of this node
  27452. * @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
  27453. * @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)
  27454. * @returns an array of Node
  27455. */
  27456. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27457. /** @hidden */
  27458. _setReady(state: boolean): void;
  27459. /**
  27460. * Get an animation by name
  27461. * @param name defines the name of the animation to look for
  27462. * @returns null if not found else the requested animation
  27463. */
  27464. getAnimationByName(name: string): Nullable<Animation>;
  27465. /**
  27466. * Creates an animation range for this node
  27467. * @param name defines the name of the range
  27468. * @param from defines the starting key
  27469. * @param to defines the end key
  27470. */
  27471. createAnimationRange(name: string, from: number, to: number): void;
  27472. /**
  27473. * Delete a specific animation range
  27474. * @param name defines the name of the range to delete
  27475. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27476. */
  27477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27478. /**
  27479. * Get an animation range by name
  27480. * @param name defines the name of the animation range to look for
  27481. * @returns null if not found else the requested animation range
  27482. */
  27483. getAnimationRange(name: string): Nullable<AnimationRange>;
  27484. /**
  27485. * Gets the list of all animation ranges defined on this node
  27486. * @returns an array
  27487. */
  27488. getAnimationRanges(): Nullable<AnimationRange>[];
  27489. /**
  27490. * Will start the animation sequence
  27491. * @param name defines the range frames for animation sequence
  27492. * @param loop defines if the animation should loop (false by default)
  27493. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27494. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27495. * @returns the object created for this animation. If range does not exist, it will return null
  27496. */
  27497. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27498. /**
  27499. * Serialize animation ranges into a JSON compatible object
  27500. * @returns serialization object
  27501. */
  27502. serializeAnimationRanges(): any;
  27503. /**
  27504. * Computes the world matrix of the node
  27505. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27506. * @returns the world matrix
  27507. */
  27508. computeWorldMatrix(force?: boolean): Matrix;
  27509. /**
  27510. * Releases resources associated with this node.
  27511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27513. */
  27514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27515. /**
  27516. * Parse animation range data from a serialization object and store them into a given node
  27517. * @param node defines where to store the animation ranges
  27518. * @param parsedNode defines the serialization object to read data from
  27519. * @param scene defines the hosting scene
  27520. */
  27521. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27522. /**
  27523. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27524. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27525. * @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
  27526. * @returns the new bounding vectors
  27527. */
  27528. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27529. min: Vector3;
  27530. max: Vector3;
  27531. };
  27532. }
  27533. }
  27534. declare module BABYLON {
  27535. /**
  27536. * @hidden
  27537. */
  27538. export class _IAnimationState {
  27539. key: number;
  27540. repeatCount: number;
  27541. workValue?: any;
  27542. loopMode?: number;
  27543. offsetValue?: any;
  27544. highLimitValue?: any;
  27545. }
  27546. /**
  27547. * Class used to store any kind of animation
  27548. */
  27549. export class Animation {
  27550. /**Name of the animation */
  27551. name: string;
  27552. /**Property to animate */
  27553. targetProperty: string;
  27554. /**The frames per second of the animation */
  27555. framePerSecond: number;
  27556. /**The data type of the animation */
  27557. dataType: number;
  27558. /**The loop mode of the animation */
  27559. loopMode?: number | undefined;
  27560. /**Specifies if blending should be enabled */
  27561. enableBlending?: boolean | undefined;
  27562. /**
  27563. * Use matrix interpolation instead of using direct key value when animating matrices
  27564. */
  27565. static AllowMatricesInterpolation: boolean;
  27566. /**
  27567. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27568. */
  27569. static AllowMatrixDecomposeForInterpolation: boolean;
  27570. /**
  27571. * Stores the key frames of the animation
  27572. */
  27573. private _keys;
  27574. /**
  27575. * Stores the easing function of the animation
  27576. */
  27577. private _easingFunction;
  27578. /**
  27579. * @hidden Internal use only
  27580. */
  27581. _runtimeAnimations: RuntimeAnimation[];
  27582. /**
  27583. * The set of event that will be linked to this animation
  27584. */
  27585. private _events;
  27586. /**
  27587. * Stores an array of target property paths
  27588. */
  27589. targetPropertyPath: string[];
  27590. /**
  27591. * Stores the blending speed of the animation
  27592. */
  27593. blendingSpeed: number;
  27594. /**
  27595. * Stores the animation ranges for the animation
  27596. */
  27597. private _ranges;
  27598. /**
  27599. * @hidden Internal use
  27600. */
  27601. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27602. /**
  27603. * Sets up an animation
  27604. * @param property The property to animate
  27605. * @param animationType The animation type to apply
  27606. * @param framePerSecond The frames per second of the animation
  27607. * @param easingFunction The easing function used in the animation
  27608. * @returns The created animation
  27609. */
  27610. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27611. /**
  27612. * Create and start an animation on a node
  27613. * @param name defines the name of the global animation that will be run on all nodes
  27614. * @param node defines the root node where the animation will take place
  27615. * @param targetProperty defines property to animate
  27616. * @param framePerSecond defines the number of frame per second yo use
  27617. * @param totalFrame defines the number of frames in total
  27618. * @param from defines the initial value
  27619. * @param to defines the final value
  27620. * @param loopMode defines which loop mode you want to use (off by default)
  27621. * @param easingFunction defines the easing function to use (linear by default)
  27622. * @param onAnimationEnd defines the callback to call when animation end
  27623. * @returns the animatable created for this animation
  27624. */
  27625. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27626. /**
  27627. * Create and start an animation on a node and its descendants
  27628. * @param name defines the name of the global animation that will be run on all nodes
  27629. * @param node defines the root node where the animation will take place
  27630. * @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
  27631. * @param targetProperty defines property to animate
  27632. * @param framePerSecond defines the number of frame per second to use
  27633. * @param totalFrame defines the number of frames in total
  27634. * @param from defines the initial value
  27635. * @param to defines the final value
  27636. * @param loopMode defines which loop mode you want to use (off by default)
  27637. * @param easingFunction defines the easing function to use (linear by default)
  27638. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27639. * @returns the list of animatables created for all nodes
  27640. * @example https://www.babylonjs-playground.com/#MH0VLI
  27641. */
  27642. 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[]>;
  27643. /**
  27644. * Creates a new animation, merges it with the existing animations and starts it
  27645. * @param name Name of the animation
  27646. * @param node Node which contains the scene that begins the animations
  27647. * @param targetProperty Specifies which property to animate
  27648. * @param framePerSecond The frames per second of the animation
  27649. * @param totalFrame The total number of frames
  27650. * @param from The frame at the beginning of the animation
  27651. * @param to The frame at the end of the animation
  27652. * @param loopMode Specifies the loop mode of the animation
  27653. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27654. * @param onAnimationEnd Callback to run once the animation is complete
  27655. * @returns Nullable animation
  27656. */
  27657. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27658. /**
  27659. * Transition property of an host to the target Value
  27660. * @param property The property to transition
  27661. * @param targetValue The target Value of the property
  27662. * @param host The object where the property to animate belongs
  27663. * @param scene Scene used to run the animation
  27664. * @param frameRate Framerate (in frame/s) to use
  27665. * @param transition The transition type we want to use
  27666. * @param duration The duration of the animation, in milliseconds
  27667. * @param onAnimationEnd Callback trigger at the end of the animation
  27668. * @returns Nullable animation
  27669. */
  27670. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27671. /**
  27672. * Return the array of runtime animations currently using this animation
  27673. */
  27674. readonly runtimeAnimations: RuntimeAnimation[];
  27675. /**
  27676. * Specifies if any of the runtime animations are currently running
  27677. */
  27678. readonly hasRunningRuntimeAnimations: boolean;
  27679. /**
  27680. * Initializes the animation
  27681. * @param name Name of the animation
  27682. * @param targetProperty Property to animate
  27683. * @param framePerSecond The frames per second of the animation
  27684. * @param dataType The data type of the animation
  27685. * @param loopMode The loop mode of the animation
  27686. * @param enableBlending Specifies if blending should be enabled
  27687. */
  27688. constructor(
  27689. /**Name of the animation */
  27690. name: string,
  27691. /**Property to animate */
  27692. targetProperty: string,
  27693. /**The frames per second of the animation */
  27694. framePerSecond: number,
  27695. /**The data type of the animation */
  27696. dataType: number,
  27697. /**The loop mode of the animation */
  27698. loopMode?: number | undefined,
  27699. /**Specifies if blending should be enabled */
  27700. enableBlending?: boolean | undefined);
  27701. /**
  27702. * Converts the animation to a string
  27703. * @param fullDetails support for multiple levels of logging within scene loading
  27704. * @returns String form of the animation
  27705. */
  27706. toString(fullDetails?: boolean): string;
  27707. /**
  27708. * Add an event to this animation
  27709. * @param event Event to add
  27710. */
  27711. addEvent(event: AnimationEvent): void;
  27712. /**
  27713. * Remove all events found at the given frame
  27714. * @param frame The frame to remove events from
  27715. */
  27716. removeEvents(frame: number): void;
  27717. /**
  27718. * Retrieves all the events from the animation
  27719. * @returns Events from the animation
  27720. */
  27721. getEvents(): AnimationEvent[];
  27722. /**
  27723. * Creates an animation range
  27724. * @param name Name of the animation range
  27725. * @param from Starting frame of the animation range
  27726. * @param to Ending frame of the animation
  27727. */
  27728. createRange(name: string, from: number, to: number): void;
  27729. /**
  27730. * Deletes an animation range by name
  27731. * @param name Name of the animation range to delete
  27732. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27733. */
  27734. deleteRange(name: string, deleteFrames?: boolean): void;
  27735. /**
  27736. * Gets the animation range by name, or null if not defined
  27737. * @param name Name of the animation range
  27738. * @returns Nullable animation range
  27739. */
  27740. getRange(name: string): Nullable<AnimationRange>;
  27741. /**
  27742. * Gets the key frames from the animation
  27743. * @returns The key frames of the animation
  27744. */
  27745. getKeys(): Array<IAnimationKey>;
  27746. /**
  27747. * Gets the highest frame rate of the animation
  27748. * @returns Highest frame rate of the animation
  27749. */
  27750. getHighestFrame(): number;
  27751. /**
  27752. * Gets the easing function of the animation
  27753. * @returns Easing function of the animation
  27754. */
  27755. getEasingFunction(): IEasingFunction;
  27756. /**
  27757. * Sets the easing function of the animation
  27758. * @param easingFunction A custom mathematical formula for animation
  27759. */
  27760. setEasingFunction(easingFunction: EasingFunction): void;
  27761. /**
  27762. * Interpolates a scalar linearly
  27763. * @param startValue Start value of the animation curve
  27764. * @param endValue End value of the animation curve
  27765. * @param gradient Scalar amount to interpolate
  27766. * @returns Interpolated scalar value
  27767. */
  27768. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27769. /**
  27770. * Interpolates a scalar cubically
  27771. * @param startValue Start value of the animation curve
  27772. * @param outTangent End tangent of the animation
  27773. * @param endValue End value of the animation curve
  27774. * @param inTangent Start tangent of the animation curve
  27775. * @param gradient Scalar amount to interpolate
  27776. * @returns Interpolated scalar value
  27777. */
  27778. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27779. /**
  27780. * Interpolates a quaternion using a spherical linear interpolation
  27781. * @param startValue Start value of the animation curve
  27782. * @param endValue End value of the animation curve
  27783. * @param gradient Scalar amount to interpolate
  27784. * @returns Interpolated quaternion value
  27785. */
  27786. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27787. /**
  27788. * Interpolates a quaternion cubically
  27789. * @param startValue Start value of the animation curve
  27790. * @param outTangent End tangent of the animation curve
  27791. * @param endValue End value of the animation curve
  27792. * @param inTangent Start tangent of the animation curve
  27793. * @param gradient Scalar amount to interpolate
  27794. * @returns Interpolated quaternion value
  27795. */
  27796. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27797. /**
  27798. * Interpolates a Vector3 linearl
  27799. * @param startValue Start value of the animation curve
  27800. * @param endValue End value of the animation curve
  27801. * @param gradient Scalar amount to interpolate
  27802. * @returns Interpolated scalar value
  27803. */
  27804. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27805. /**
  27806. * Interpolates a Vector3 cubically
  27807. * @param startValue Start value of the animation curve
  27808. * @param outTangent End tangent of the animation
  27809. * @param endValue End value of the animation curve
  27810. * @param inTangent Start tangent of the animation curve
  27811. * @param gradient Scalar amount to interpolate
  27812. * @returns InterpolatedVector3 value
  27813. */
  27814. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27815. /**
  27816. * Interpolates a Vector2 linearly
  27817. * @param startValue Start value of the animation curve
  27818. * @param endValue End value of the animation curve
  27819. * @param gradient Scalar amount to interpolate
  27820. * @returns Interpolated Vector2 value
  27821. */
  27822. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27823. /**
  27824. * Interpolates a Vector2 cubically
  27825. * @param startValue Start value of the animation curve
  27826. * @param outTangent End tangent of the animation
  27827. * @param endValue End value of the animation curve
  27828. * @param inTangent Start tangent of the animation curve
  27829. * @param gradient Scalar amount to interpolate
  27830. * @returns Interpolated Vector2 value
  27831. */
  27832. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27833. /**
  27834. * Interpolates a size linearly
  27835. * @param startValue Start value of the animation curve
  27836. * @param endValue End value of the animation curve
  27837. * @param gradient Scalar amount to interpolate
  27838. * @returns Interpolated Size value
  27839. */
  27840. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27841. /**
  27842. * Interpolates a Color3 linearly
  27843. * @param startValue Start value of the animation curve
  27844. * @param endValue End value of the animation curve
  27845. * @param gradient Scalar amount to interpolate
  27846. * @returns Interpolated Color3 value
  27847. */
  27848. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27849. /**
  27850. * Interpolates a Color4 linearly
  27851. * @param startValue Start value of the animation curve
  27852. * @param endValue End value of the animation curve
  27853. * @param gradient Scalar amount to interpolate
  27854. * @returns Interpolated Color3 value
  27855. */
  27856. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27857. /**
  27858. * @hidden Internal use only
  27859. */
  27860. _getKeyValue(value: any): any;
  27861. /**
  27862. * @hidden Internal use only
  27863. */
  27864. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27865. /**
  27866. * Defines the function to use to interpolate matrices
  27867. * @param startValue defines the start matrix
  27868. * @param endValue defines the end matrix
  27869. * @param gradient defines the gradient between both matrices
  27870. * @param result defines an optional target matrix where to store the interpolation
  27871. * @returns the interpolated matrix
  27872. */
  27873. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27874. /**
  27875. * Makes a copy of the animation
  27876. * @returns Cloned animation
  27877. */
  27878. clone(): Animation;
  27879. /**
  27880. * Sets the key frames of the animation
  27881. * @param values The animation key frames to set
  27882. */
  27883. setKeys(values: Array<IAnimationKey>): void;
  27884. /**
  27885. * Serializes the animation to an object
  27886. * @returns Serialized object
  27887. */
  27888. serialize(): any;
  27889. /**
  27890. * Float animation type
  27891. */
  27892. static readonly ANIMATIONTYPE_FLOAT: number;
  27893. /**
  27894. * Vector3 animation type
  27895. */
  27896. static readonly ANIMATIONTYPE_VECTOR3: number;
  27897. /**
  27898. * Quaternion animation type
  27899. */
  27900. static readonly ANIMATIONTYPE_QUATERNION: number;
  27901. /**
  27902. * Matrix animation type
  27903. */
  27904. static readonly ANIMATIONTYPE_MATRIX: number;
  27905. /**
  27906. * Color3 animation type
  27907. */
  27908. static readonly ANIMATIONTYPE_COLOR3: number;
  27909. /**
  27910. * Color3 animation type
  27911. */
  27912. static readonly ANIMATIONTYPE_COLOR4: number;
  27913. /**
  27914. * Vector2 animation type
  27915. */
  27916. static readonly ANIMATIONTYPE_VECTOR2: number;
  27917. /**
  27918. * Size animation type
  27919. */
  27920. static readonly ANIMATIONTYPE_SIZE: number;
  27921. /**
  27922. * Relative Loop Mode
  27923. */
  27924. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27925. /**
  27926. * Cycle Loop Mode
  27927. */
  27928. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27929. /**
  27930. * Constant Loop Mode
  27931. */
  27932. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27933. /** @hidden */
  27934. static _UniversalLerp(left: any, right: any, amount: number): any;
  27935. /**
  27936. * Parses an animation object and creates an animation
  27937. * @param parsedAnimation Parsed animation object
  27938. * @returns Animation object
  27939. */
  27940. static Parse(parsedAnimation: any): Animation;
  27941. /**
  27942. * Appends the serialized animations from the source animations
  27943. * @param source Source containing the animations
  27944. * @param destination Target to store the animations
  27945. */
  27946. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27947. }
  27948. }
  27949. declare module BABYLON {
  27950. /**
  27951. * Interface containing an array of animations
  27952. */
  27953. export interface IAnimatable {
  27954. /**
  27955. * Array of animations
  27956. */
  27957. animations: Nullable<Array<Animation>>;
  27958. }
  27959. }
  27960. declare module BABYLON {
  27961. /**
  27962. * This represents all the required information to add a fresnel effect on a material:
  27963. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27964. */
  27965. export class FresnelParameters {
  27966. private _isEnabled;
  27967. /**
  27968. * Define if the fresnel effect is enable or not.
  27969. */
  27970. isEnabled: boolean;
  27971. /**
  27972. * Define the color used on edges (grazing angle)
  27973. */
  27974. leftColor: Color3;
  27975. /**
  27976. * Define the color used on center
  27977. */
  27978. rightColor: Color3;
  27979. /**
  27980. * Define bias applied to computed fresnel term
  27981. */
  27982. bias: number;
  27983. /**
  27984. * Defined the power exponent applied to fresnel term
  27985. */
  27986. power: number;
  27987. /**
  27988. * Clones the current fresnel and its valuues
  27989. * @returns a clone fresnel configuration
  27990. */
  27991. clone(): FresnelParameters;
  27992. /**
  27993. * Serializes the current fresnel parameters to a JSON representation.
  27994. * @return the JSON serialization
  27995. */
  27996. serialize(): any;
  27997. /**
  27998. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27999. * @param parsedFresnelParameters Define the JSON representation
  28000. * @returns the parsed parameters
  28001. */
  28002. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28003. }
  28004. }
  28005. declare module BABYLON {
  28006. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28007. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28008. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28009. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28010. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28011. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28012. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28013. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28014. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28015. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28016. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28017. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28018. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28019. /**
  28020. * Decorator used to define property that can be serialized as reference to a camera
  28021. * @param sourceName defines the name of the property to decorate
  28022. */
  28023. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28024. /**
  28025. * Class used to help serialization objects
  28026. */
  28027. export class SerializationHelper {
  28028. /** @hidden */
  28029. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  28030. /** @hidden */
  28031. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  28032. /** @hidden */
  28033. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  28034. /** @hidden */
  28035. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  28036. /**
  28037. * Appends the serialized animations from the source animations
  28038. * @param source Source containing the animations
  28039. * @param destination Target to store the animations
  28040. */
  28041. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28042. /**
  28043. * Static function used to serialized a specific entity
  28044. * @param entity defines the entity to serialize
  28045. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28046. * @returns a JSON compatible object representing the serialization of the entity
  28047. */
  28048. static Serialize<T>(entity: T, serializationObject?: any): any;
  28049. /**
  28050. * Creates a new entity from a serialization data object
  28051. * @param creationFunction defines a function used to instanciated the new entity
  28052. * @param source defines the source serialization data
  28053. * @param scene defines the hosting scene
  28054. * @param rootUrl defines the root url for resources
  28055. * @returns a new entity
  28056. */
  28057. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28058. /**
  28059. * Clones an object
  28060. * @param creationFunction defines the function used to instanciate the new object
  28061. * @param source defines the source object
  28062. * @returns the cloned object
  28063. */
  28064. static Clone<T>(creationFunction: () => T, source: T): T;
  28065. /**
  28066. * Instanciates a new object based on a source one (some data will be shared between both object)
  28067. * @param creationFunction defines the function used to instanciate the new object
  28068. * @param source defines the source object
  28069. * @returns the new object
  28070. */
  28071. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28072. }
  28073. }
  28074. declare module BABYLON {
  28075. /**
  28076. * Class used to manipulate GUIDs
  28077. */
  28078. export class GUID {
  28079. /**
  28080. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28081. * Be aware Math.random() could cause collisions, but:
  28082. * "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"
  28083. * @returns a pseudo random id
  28084. */
  28085. static RandomId(): string;
  28086. }
  28087. }
  28088. declare module BABYLON {
  28089. /**
  28090. * Base class of all the textures in babylon.
  28091. * It groups all the common properties the materials, post process, lights... might need
  28092. * in order to make a correct use of the texture.
  28093. */
  28094. export class BaseTexture implements IAnimatable {
  28095. /**
  28096. * Default anisotropic filtering level for the application.
  28097. * It is set to 4 as a good tradeoff between perf and quality.
  28098. */
  28099. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28100. /**
  28101. * Gets or sets the unique id of the texture
  28102. */
  28103. uniqueId: number;
  28104. /**
  28105. * Define the name of the texture.
  28106. */
  28107. name: string;
  28108. /**
  28109. * Gets or sets an object used to store user defined information.
  28110. */
  28111. metadata: any;
  28112. /**
  28113. * For internal use only. Please do not use.
  28114. */
  28115. reservedDataStore: any;
  28116. private _hasAlpha;
  28117. /**
  28118. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28119. */
  28120. hasAlpha: boolean;
  28121. /**
  28122. * Defines if the alpha value should be determined via the rgb values.
  28123. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28124. */
  28125. getAlphaFromRGB: boolean;
  28126. /**
  28127. * Intensity or strength of the texture.
  28128. * It is commonly used by materials to fine tune the intensity of the texture
  28129. */
  28130. level: number;
  28131. /**
  28132. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28133. * This is part of the texture as textures usually maps to one uv set.
  28134. */
  28135. coordinatesIndex: number;
  28136. private _coordinatesMode;
  28137. /**
  28138. * How a texture is mapped.
  28139. *
  28140. * | Value | Type | Description |
  28141. * | ----- | ----------------------------------- | ----------- |
  28142. * | 0 | EXPLICIT_MODE | |
  28143. * | 1 | SPHERICAL_MODE | |
  28144. * | 2 | PLANAR_MODE | |
  28145. * | 3 | CUBIC_MODE | |
  28146. * | 4 | PROJECTION_MODE | |
  28147. * | 5 | SKYBOX_MODE | |
  28148. * | 6 | INVCUBIC_MODE | |
  28149. * | 7 | EQUIRECTANGULAR_MODE | |
  28150. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28151. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28152. */
  28153. coordinatesMode: number;
  28154. /**
  28155. * | Value | Type | Description |
  28156. * | ----- | ------------------ | ----------- |
  28157. * | 0 | CLAMP_ADDRESSMODE | |
  28158. * | 1 | WRAP_ADDRESSMODE | |
  28159. * | 2 | MIRROR_ADDRESSMODE | |
  28160. */
  28161. wrapU: number;
  28162. /**
  28163. * | Value | Type | Description |
  28164. * | ----- | ------------------ | ----------- |
  28165. * | 0 | CLAMP_ADDRESSMODE | |
  28166. * | 1 | WRAP_ADDRESSMODE | |
  28167. * | 2 | MIRROR_ADDRESSMODE | |
  28168. */
  28169. wrapV: number;
  28170. /**
  28171. * | Value | Type | Description |
  28172. * | ----- | ------------------ | ----------- |
  28173. * | 0 | CLAMP_ADDRESSMODE | |
  28174. * | 1 | WRAP_ADDRESSMODE | |
  28175. * | 2 | MIRROR_ADDRESSMODE | |
  28176. */
  28177. wrapR: number;
  28178. /**
  28179. * With compliant hardware and browser (supporting anisotropic filtering)
  28180. * this defines the level of anisotropic filtering in the texture.
  28181. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28182. */
  28183. anisotropicFilteringLevel: number;
  28184. /**
  28185. * Define if the texture is a cube texture or if false a 2d texture.
  28186. */
  28187. isCube: boolean;
  28188. /**
  28189. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28190. */
  28191. is3D: boolean;
  28192. /**
  28193. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28194. */
  28195. is2DArray: boolean;
  28196. /**
  28197. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28198. * HDR texture are usually stored in linear space.
  28199. * This only impacts the PBR and Background materials
  28200. */
  28201. gammaSpace: boolean;
  28202. /**
  28203. * Gets or sets whether or not the texture contains RGBD data.
  28204. */
  28205. isRGBD: boolean;
  28206. /**
  28207. * Is Z inverted in the texture (useful in a cube texture).
  28208. */
  28209. invertZ: boolean;
  28210. /**
  28211. * Are mip maps generated for this texture or not.
  28212. */
  28213. readonly noMipmap: boolean;
  28214. /**
  28215. * @hidden
  28216. */
  28217. lodLevelInAlpha: boolean;
  28218. /**
  28219. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28220. */
  28221. lodGenerationOffset: number;
  28222. /**
  28223. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28224. */
  28225. lodGenerationScale: number;
  28226. /**
  28227. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28228. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28229. * average roughness values.
  28230. */
  28231. linearSpecularLOD: boolean;
  28232. /**
  28233. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28234. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28235. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28236. */
  28237. irradianceTexture: Nullable<BaseTexture>;
  28238. /**
  28239. * Define if the texture is a render target.
  28240. */
  28241. isRenderTarget: boolean;
  28242. /**
  28243. * Define the unique id of the texture in the scene.
  28244. */
  28245. readonly uid: string;
  28246. /**
  28247. * Return a string representation of the texture.
  28248. * @returns the texture as a string
  28249. */
  28250. toString(): string;
  28251. /**
  28252. * Get the class name of the texture.
  28253. * @returns "BaseTexture"
  28254. */
  28255. getClassName(): string;
  28256. /**
  28257. * Define the list of animation attached to the texture.
  28258. */
  28259. animations: Animation[];
  28260. /**
  28261. * An event triggered when the texture is disposed.
  28262. */
  28263. onDisposeObservable: Observable<BaseTexture>;
  28264. private _onDisposeObserver;
  28265. /**
  28266. * Callback triggered when the texture has been disposed.
  28267. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28268. */
  28269. onDispose: () => void;
  28270. /**
  28271. * Define the current state of the loading sequence when in delayed load mode.
  28272. */
  28273. delayLoadState: number;
  28274. private _scene;
  28275. /** @hidden */
  28276. _texture: Nullable<InternalTexture>;
  28277. private _uid;
  28278. /**
  28279. * Define if the texture is preventinga material to render or not.
  28280. * If not and the texture is not ready, the engine will use a default black texture instead.
  28281. */
  28282. readonly isBlocking: boolean;
  28283. /**
  28284. * Instantiates a new BaseTexture.
  28285. * Base class of all the textures in babylon.
  28286. * It groups all the common properties the materials, post process, lights... might need
  28287. * in order to make a correct use of the texture.
  28288. * @param scene Define the scene the texture blongs to
  28289. */
  28290. constructor(scene: Nullable<Scene>);
  28291. /**
  28292. * Get the scene the texture belongs to.
  28293. * @returns the scene or null if undefined
  28294. */
  28295. getScene(): Nullable<Scene>;
  28296. /**
  28297. * Get the texture transform matrix used to offset tile the texture for istance.
  28298. * @returns the transformation matrix
  28299. */
  28300. getTextureMatrix(): Matrix;
  28301. /**
  28302. * Get the texture reflection matrix used to rotate/transform the reflection.
  28303. * @returns the reflection matrix
  28304. */
  28305. getReflectionTextureMatrix(): Matrix;
  28306. /**
  28307. * Get the underlying lower level texture from Babylon.
  28308. * @returns the insternal texture
  28309. */
  28310. getInternalTexture(): Nullable<InternalTexture>;
  28311. /**
  28312. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28313. * @returns true if ready or not blocking
  28314. */
  28315. isReadyOrNotBlocking(): boolean;
  28316. /**
  28317. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28318. * @returns true if fully ready
  28319. */
  28320. isReady(): boolean;
  28321. private _cachedSize;
  28322. /**
  28323. * Get the size of the texture.
  28324. * @returns the texture size.
  28325. */
  28326. getSize(): ISize;
  28327. /**
  28328. * Get the base size of the texture.
  28329. * It can be different from the size if the texture has been resized for POT for instance
  28330. * @returns the base size
  28331. */
  28332. getBaseSize(): ISize;
  28333. /**
  28334. * Update the sampling mode of the texture.
  28335. * Default is Trilinear mode.
  28336. *
  28337. * | Value | Type | Description |
  28338. * | ----- | ------------------ | ----------- |
  28339. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28340. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28341. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28342. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28343. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28344. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28345. * | 7 | NEAREST_LINEAR | |
  28346. * | 8 | NEAREST_NEAREST | |
  28347. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28348. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28349. * | 11 | LINEAR_LINEAR | |
  28350. * | 12 | LINEAR_NEAREST | |
  28351. *
  28352. * > _mag_: magnification filter (close to the viewer)
  28353. * > _min_: minification filter (far from the viewer)
  28354. * > _mip_: filter used between mip map levels
  28355. *@param samplingMode Define the new sampling mode of the texture
  28356. */
  28357. updateSamplingMode(samplingMode: number): void;
  28358. /**
  28359. * Scales the texture if is `canRescale()`
  28360. * @param ratio the resize factor we want to use to rescale
  28361. */
  28362. scale(ratio: number): void;
  28363. /**
  28364. * Get if the texture can rescale.
  28365. */
  28366. readonly canRescale: boolean;
  28367. /** @hidden */
  28368. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28369. /** @hidden */
  28370. _rebuild(): void;
  28371. /**
  28372. * Triggers the load sequence in delayed load mode.
  28373. */
  28374. delayLoad(): void;
  28375. /**
  28376. * Clones the texture.
  28377. * @returns the cloned texture
  28378. */
  28379. clone(): Nullable<BaseTexture>;
  28380. /**
  28381. * Get the texture underlying type (INT, FLOAT...)
  28382. */
  28383. readonly textureType: number;
  28384. /**
  28385. * Get the texture underlying format (RGB, RGBA...)
  28386. */
  28387. readonly textureFormat: number;
  28388. /**
  28389. * Indicates that textures need to be re-calculated for all materials
  28390. */
  28391. protected _markAllSubMeshesAsTexturesDirty(): void;
  28392. /**
  28393. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28394. * This will returns an RGBA array buffer containing either in values (0-255) or
  28395. * float values (0-1) depending of the underlying buffer type.
  28396. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28397. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28398. * @param buffer defines a user defined buffer to fill with data (can be null)
  28399. * @returns The Array buffer containing the pixels data.
  28400. */
  28401. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28402. /**
  28403. * Release and destroy the underlying lower level texture aka internalTexture.
  28404. */
  28405. releaseInternalTexture(): void;
  28406. /** @hidden */
  28407. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28408. /** @hidden */
  28409. readonly _lodTextureMid: Nullable<BaseTexture>;
  28410. /** @hidden */
  28411. readonly _lodTextureLow: Nullable<BaseTexture>;
  28412. /**
  28413. * Dispose the texture and release its associated resources.
  28414. */
  28415. dispose(): void;
  28416. /**
  28417. * Serialize the texture into a JSON representation that can be parsed later on.
  28418. * @returns the JSON representation of the texture
  28419. */
  28420. serialize(): any;
  28421. /**
  28422. * Helper function to be called back once a list of texture contains only ready textures.
  28423. * @param textures Define the list of textures to wait for
  28424. * @param callback Define the callback triggered once the entire list will be ready
  28425. */
  28426. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28427. }
  28428. }
  28429. declare module BABYLON {
  28430. /**
  28431. * Options to be used when creating an effect.
  28432. */
  28433. export interface IEffectCreationOptions {
  28434. /**
  28435. * Atrributes that will be used in the shader.
  28436. */
  28437. attributes: string[];
  28438. /**
  28439. * Uniform varible names that will be set in the shader.
  28440. */
  28441. uniformsNames: string[];
  28442. /**
  28443. * Uniform buffer variable names that will be set in the shader.
  28444. */
  28445. uniformBuffersNames: string[];
  28446. /**
  28447. * Sampler texture variable names that will be set in the shader.
  28448. */
  28449. samplers: string[];
  28450. /**
  28451. * Define statements that will be set in the shader.
  28452. */
  28453. defines: any;
  28454. /**
  28455. * Possible fallbacks for this effect to improve performance when needed.
  28456. */
  28457. fallbacks: Nullable<IEffectFallbacks>;
  28458. /**
  28459. * Callback that will be called when the shader is compiled.
  28460. */
  28461. onCompiled: Nullable<(effect: Effect) => void>;
  28462. /**
  28463. * Callback that will be called if an error occurs during shader compilation.
  28464. */
  28465. onError: Nullable<(effect: Effect, errors: string) => void>;
  28466. /**
  28467. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28468. */
  28469. indexParameters?: any;
  28470. /**
  28471. * Max number of lights that can be used in the shader.
  28472. */
  28473. maxSimultaneousLights?: number;
  28474. /**
  28475. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28476. */
  28477. transformFeedbackVaryings?: Nullable<string[]>;
  28478. }
  28479. /**
  28480. * Effect containing vertex and fragment shader that can be executed on an object.
  28481. */
  28482. export class Effect implements IDisposable {
  28483. /**
  28484. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28485. */
  28486. static ShadersRepository: string;
  28487. /**
  28488. * Name of the effect.
  28489. */
  28490. name: any;
  28491. /**
  28492. * String container all the define statements that should be set on the shader.
  28493. */
  28494. defines: string;
  28495. /**
  28496. * Callback that will be called when the shader is compiled.
  28497. */
  28498. onCompiled: Nullable<(effect: Effect) => void>;
  28499. /**
  28500. * Callback that will be called if an error occurs during shader compilation.
  28501. */
  28502. onError: Nullable<(effect: Effect, errors: string) => void>;
  28503. /**
  28504. * Callback that will be called when effect is bound.
  28505. */
  28506. onBind: Nullable<(effect: Effect) => void>;
  28507. /**
  28508. * Unique ID of the effect.
  28509. */
  28510. uniqueId: number;
  28511. /**
  28512. * Observable that will be called when the shader is compiled.
  28513. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28514. */
  28515. onCompileObservable: Observable<Effect>;
  28516. /**
  28517. * Observable that will be called if an error occurs during shader compilation.
  28518. */
  28519. onErrorObservable: Observable<Effect>;
  28520. /** @hidden */
  28521. _onBindObservable: Nullable<Observable<Effect>>;
  28522. /**
  28523. * Observable that will be called when effect is bound.
  28524. */
  28525. readonly onBindObservable: Observable<Effect>;
  28526. /** @hidden */
  28527. _bonesComputationForcedToCPU: boolean;
  28528. private static _uniqueIdSeed;
  28529. private _engine;
  28530. private _uniformBuffersNames;
  28531. private _uniformsNames;
  28532. private _samplerList;
  28533. private _samplers;
  28534. private _isReady;
  28535. private _compilationError;
  28536. private _allFallbacksProcessed;
  28537. private _attributesNames;
  28538. private _attributes;
  28539. private _uniforms;
  28540. /**
  28541. * Key for the effect.
  28542. * @hidden
  28543. */
  28544. _key: string;
  28545. private _indexParameters;
  28546. private _fallbacks;
  28547. private _vertexSourceCode;
  28548. private _fragmentSourceCode;
  28549. private _vertexSourceCodeOverride;
  28550. private _fragmentSourceCodeOverride;
  28551. private _transformFeedbackVaryings;
  28552. /**
  28553. * Compiled shader to webGL program.
  28554. * @hidden
  28555. */
  28556. _pipelineContext: Nullable<IPipelineContext>;
  28557. private _valueCache;
  28558. private static _baseCache;
  28559. /**
  28560. * Instantiates an effect.
  28561. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28562. * @param baseName Name of the effect.
  28563. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28564. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28565. * @param samplers List of sampler variables that will be passed to the shader.
  28566. * @param engine Engine to be used to render the effect
  28567. * @param defines Define statements to be added to the shader.
  28568. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28569. * @param onCompiled Callback that will be called when the shader is compiled.
  28570. * @param onError Callback that will be called if an error occurs during shader compilation.
  28571. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28572. */
  28573. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28574. private _useFinalCode;
  28575. /**
  28576. * Unique key for this effect
  28577. */
  28578. readonly key: string;
  28579. /**
  28580. * If the effect has been compiled and prepared.
  28581. * @returns if the effect is compiled and prepared.
  28582. */
  28583. isReady(): boolean;
  28584. private _isReadyInternal;
  28585. /**
  28586. * The engine the effect was initialized with.
  28587. * @returns the engine.
  28588. */
  28589. getEngine(): Engine;
  28590. /**
  28591. * The pipeline context for this effect
  28592. * @returns the associated pipeline context
  28593. */
  28594. getPipelineContext(): Nullable<IPipelineContext>;
  28595. /**
  28596. * The set of names of attribute variables for the shader.
  28597. * @returns An array of attribute names.
  28598. */
  28599. getAttributesNames(): string[];
  28600. /**
  28601. * Returns the attribute at the given index.
  28602. * @param index The index of the attribute.
  28603. * @returns The location of the attribute.
  28604. */
  28605. getAttributeLocation(index: number): number;
  28606. /**
  28607. * Returns the attribute based on the name of the variable.
  28608. * @param name of the attribute to look up.
  28609. * @returns the attribute location.
  28610. */
  28611. getAttributeLocationByName(name: string): number;
  28612. /**
  28613. * The number of attributes.
  28614. * @returns the numnber of attributes.
  28615. */
  28616. getAttributesCount(): number;
  28617. /**
  28618. * Gets the index of a uniform variable.
  28619. * @param uniformName of the uniform to look up.
  28620. * @returns the index.
  28621. */
  28622. getUniformIndex(uniformName: string): number;
  28623. /**
  28624. * Returns the attribute based on the name of the variable.
  28625. * @param uniformName of the uniform to look up.
  28626. * @returns the location of the uniform.
  28627. */
  28628. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28629. /**
  28630. * Returns an array of sampler variable names
  28631. * @returns The array of sampler variable neames.
  28632. */
  28633. getSamplers(): string[];
  28634. /**
  28635. * The error from the last compilation.
  28636. * @returns the error string.
  28637. */
  28638. getCompilationError(): string;
  28639. /**
  28640. * Gets a boolean indicating that all fallbacks were used during compilation
  28641. * @returns true if all fallbacks were used
  28642. */
  28643. allFallbacksProcessed(): boolean;
  28644. /**
  28645. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28646. * @param func The callback to be used.
  28647. */
  28648. executeWhenCompiled(func: (effect: Effect) => void): void;
  28649. private _checkIsReady;
  28650. private _loadShader;
  28651. /**
  28652. * Recompiles the webGL program
  28653. * @param vertexSourceCode The source code for the vertex shader.
  28654. * @param fragmentSourceCode The source code for the fragment shader.
  28655. * @param onCompiled Callback called when completed.
  28656. * @param onError Callback called on error.
  28657. * @hidden
  28658. */
  28659. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28660. /**
  28661. * Prepares the effect
  28662. * @hidden
  28663. */
  28664. _prepareEffect(): void;
  28665. private _processCompilationErrors;
  28666. /**
  28667. * Checks if the effect is supported. (Must be called after compilation)
  28668. */
  28669. readonly isSupported: boolean;
  28670. /**
  28671. * Binds a texture to the engine to be used as output of the shader.
  28672. * @param channel Name of the output variable.
  28673. * @param texture Texture to bind.
  28674. * @hidden
  28675. */
  28676. _bindTexture(channel: string, texture: InternalTexture): void;
  28677. /**
  28678. * Sets a texture on the engine to be used in the shader.
  28679. * @param channel Name of the sampler variable.
  28680. * @param texture Texture to set.
  28681. */
  28682. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28683. /**
  28684. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28685. * @param channel Name of the sampler variable.
  28686. * @param texture Texture to set.
  28687. */
  28688. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28689. /**
  28690. * Sets an array of textures on the engine to be used in the shader.
  28691. * @param channel Name of the variable.
  28692. * @param textures Textures to set.
  28693. */
  28694. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28695. /**
  28696. * 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)
  28697. * @param channel Name of the sampler variable.
  28698. * @param postProcess Post process to get the input texture from.
  28699. */
  28700. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28701. /**
  28702. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28703. * 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)
  28704. * @param channel Name of the sampler variable.
  28705. * @param postProcess Post process to get the output texture from.
  28706. */
  28707. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28708. /** @hidden */
  28709. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28710. /** @hidden */
  28711. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28712. /** @hidden */
  28713. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28714. /** @hidden */
  28715. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28716. /**
  28717. * Binds a buffer to a uniform.
  28718. * @param buffer Buffer to bind.
  28719. * @param name Name of the uniform variable to bind to.
  28720. */
  28721. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28722. /**
  28723. * Binds block to a uniform.
  28724. * @param blockName Name of the block to bind.
  28725. * @param index Index to bind.
  28726. */
  28727. bindUniformBlock(blockName: string, index: number): void;
  28728. /**
  28729. * Sets an interger value on a uniform variable.
  28730. * @param uniformName Name of the variable.
  28731. * @param value Value to be set.
  28732. * @returns this effect.
  28733. */
  28734. setInt(uniformName: string, value: number): Effect;
  28735. /**
  28736. * Sets an int array on a uniform variable.
  28737. * @param uniformName Name of the variable.
  28738. * @param array array to be set.
  28739. * @returns this effect.
  28740. */
  28741. setIntArray(uniformName: string, array: Int32Array): Effect;
  28742. /**
  28743. * 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)
  28744. * @param uniformName Name of the variable.
  28745. * @param array array to be set.
  28746. * @returns this effect.
  28747. */
  28748. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28749. /**
  28750. * 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)
  28751. * @param uniformName Name of the variable.
  28752. * @param array array to be set.
  28753. * @returns this effect.
  28754. */
  28755. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28756. /**
  28757. * 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)
  28758. * @param uniformName Name of the variable.
  28759. * @param array array to be set.
  28760. * @returns this effect.
  28761. */
  28762. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28763. /**
  28764. * Sets an float array on a uniform variable.
  28765. * @param uniformName Name of the variable.
  28766. * @param array array to be set.
  28767. * @returns this effect.
  28768. */
  28769. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28770. /**
  28771. * 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)
  28772. * @param uniformName Name of the variable.
  28773. * @param array array to be set.
  28774. * @returns this effect.
  28775. */
  28776. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28777. /**
  28778. * 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)
  28779. * @param uniformName Name of the variable.
  28780. * @param array array to be set.
  28781. * @returns this effect.
  28782. */
  28783. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28784. /**
  28785. * 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)
  28786. * @param uniformName Name of the variable.
  28787. * @param array array to be set.
  28788. * @returns this effect.
  28789. */
  28790. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28791. /**
  28792. * Sets an array on a uniform variable.
  28793. * @param uniformName Name of the variable.
  28794. * @param array array to be set.
  28795. * @returns this effect.
  28796. */
  28797. setArray(uniformName: string, array: number[]): Effect;
  28798. /**
  28799. * 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)
  28800. * @param uniformName Name of the variable.
  28801. * @param array array to be set.
  28802. * @returns this effect.
  28803. */
  28804. setArray2(uniformName: string, array: number[]): Effect;
  28805. /**
  28806. * 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)
  28807. * @param uniformName Name of the variable.
  28808. * @param array array to be set.
  28809. * @returns this effect.
  28810. */
  28811. setArray3(uniformName: string, array: number[]): Effect;
  28812. /**
  28813. * 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)
  28814. * @param uniformName Name of the variable.
  28815. * @param array array to be set.
  28816. * @returns this effect.
  28817. */
  28818. setArray4(uniformName: string, array: number[]): Effect;
  28819. /**
  28820. * Sets matrices on a uniform variable.
  28821. * @param uniformName Name of the variable.
  28822. * @param matrices matrices to be set.
  28823. * @returns this effect.
  28824. */
  28825. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28826. /**
  28827. * Sets matrix on a uniform variable.
  28828. * @param uniformName Name of the variable.
  28829. * @param matrix matrix to be set.
  28830. * @returns this effect.
  28831. */
  28832. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28833. /**
  28834. * 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)
  28835. * @param uniformName Name of the variable.
  28836. * @param matrix matrix to be set.
  28837. * @returns this effect.
  28838. */
  28839. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28840. /**
  28841. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28842. * @param uniformName Name of the variable.
  28843. * @param matrix matrix to be set.
  28844. * @returns this effect.
  28845. */
  28846. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28847. /**
  28848. * Sets a float on a uniform variable.
  28849. * @param uniformName Name of the variable.
  28850. * @param value value to be set.
  28851. * @returns this effect.
  28852. */
  28853. setFloat(uniformName: string, value: number): Effect;
  28854. /**
  28855. * Sets a boolean on a uniform variable.
  28856. * @param uniformName Name of the variable.
  28857. * @param bool value to be set.
  28858. * @returns this effect.
  28859. */
  28860. setBool(uniformName: string, bool: boolean): Effect;
  28861. /**
  28862. * Sets a Vector2 on a uniform variable.
  28863. * @param uniformName Name of the variable.
  28864. * @param vector2 vector2 to be set.
  28865. * @returns this effect.
  28866. */
  28867. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28868. /**
  28869. * Sets a float2 on a uniform variable.
  28870. * @param uniformName Name of the variable.
  28871. * @param x First float in float2.
  28872. * @param y Second float in float2.
  28873. * @returns this effect.
  28874. */
  28875. setFloat2(uniformName: string, x: number, y: number): Effect;
  28876. /**
  28877. * Sets a Vector3 on a uniform variable.
  28878. * @param uniformName Name of the variable.
  28879. * @param vector3 Value to be set.
  28880. * @returns this effect.
  28881. */
  28882. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28883. /**
  28884. * Sets a float3 on a uniform variable.
  28885. * @param uniformName Name of the variable.
  28886. * @param x First float in float3.
  28887. * @param y Second float in float3.
  28888. * @param z Third float in float3.
  28889. * @returns this effect.
  28890. */
  28891. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28892. /**
  28893. * Sets a Vector4 on a uniform variable.
  28894. * @param uniformName Name of the variable.
  28895. * @param vector4 Value to be set.
  28896. * @returns this effect.
  28897. */
  28898. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28899. /**
  28900. * Sets a float4 on a uniform variable.
  28901. * @param uniformName Name of the variable.
  28902. * @param x First float in float4.
  28903. * @param y Second float in float4.
  28904. * @param z Third float in float4.
  28905. * @param w Fourth float in float4.
  28906. * @returns this effect.
  28907. */
  28908. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28909. /**
  28910. * Sets a Color3 on a uniform variable.
  28911. * @param uniformName Name of the variable.
  28912. * @param color3 Value to be set.
  28913. * @returns this effect.
  28914. */
  28915. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28916. /**
  28917. * Sets a Color4 on a uniform variable.
  28918. * @param uniformName Name of the variable.
  28919. * @param color3 Value to be set.
  28920. * @param alpha Alpha value to be set.
  28921. * @returns this effect.
  28922. */
  28923. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28924. /**
  28925. * Sets a Color4 on a uniform variable
  28926. * @param uniformName defines the name of the variable
  28927. * @param color4 defines the value to be set
  28928. * @returns this effect.
  28929. */
  28930. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28931. /** Release all associated resources */
  28932. dispose(): void;
  28933. /**
  28934. * This function will add a new shader to the shader store
  28935. * @param name the name of the shader
  28936. * @param pixelShader optional pixel shader content
  28937. * @param vertexShader optional vertex shader content
  28938. */
  28939. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28940. /**
  28941. * Store of each shader (The can be looked up using effect.key)
  28942. */
  28943. static ShadersStore: {
  28944. [key: string]: string;
  28945. };
  28946. /**
  28947. * Store of each included file for a shader (The can be looked up using effect.key)
  28948. */
  28949. static IncludesShadersStore: {
  28950. [key: string]: string;
  28951. };
  28952. /**
  28953. * Resets the cache of effects.
  28954. */
  28955. static ResetCache(): void;
  28956. }
  28957. }
  28958. declare module BABYLON {
  28959. /**
  28960. * Interface used to describe the capabilities of the engine relatively to the current browser
  28961. */
  28962. export interface EngineCapabilities {
  28963. /** Maximum textures units per fragment shader */
  28964. maxTexturesImageUnits: number;
  28965. /** Maximum texture units per vertex shader */
  28966. maxVertexTextureImageUnits: number;
  28967. /** Maximum textures units in the entire pipeline */
  28968. maxCombinedTexturesImageUnits: number;
  28969. /** Maximum texture size */
  28970. maxTextureSize: number;
  28971. /** Maximum texture samples */
  28972. maxSamples?: number;
  28973. /** Maximum cube texture size */
  28974. maxCubemapTextureSize: number;
  28975. /** Maximum render texture size */
  28976. maxRenderTextureSize: number;
  28977. /** Maximum number of vertex attributes */
  28978. maxVertexAttribs: number;
  28979. /** Maximum number of varyings */
  28980. maxVaryingVectors: number;
  28981. /** Maximum number of uniforms per vertex shader */
  28982. maxVertexUniformVectors: number;
  28983. /** Maximum number of uniforms per fragment shader */
  28984. maxFragmentUniformVectors: number;
  28985. /** Defines if standard derivates (dx/dy) are supported */
  28986. standardDerivatives: boolean;
  28987. /** Defines if s3tc texture compression is supported */
  28988. s3tc?: WEBGL_compressed_texture_s3tc;
  28989. /** Defines if pvrtc texture compression is supported */
  28990. pvrtc: any;
  28991. /** Defines if etc1 texture compression is supported */
  28992. etc1: any;
  28993. /** Defines if etc2 texture compression is supported */
  28994. etc2: any;
  28995. /** Defines if astc texture compression is supported */
  28996. astc: any;
  28997. /** Defines if float textures are supported */
  28998. textureFloat: boolean;
  28999. /** Defines if vertex array objects are supported */
  29000. vertexArrayObject: boolean;
  29001. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29002. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29003. /** Gets the maximum level of anisotropy supported */
  29004. maxAnisotropy: number;
  29005. /** Defines if instancing is supported */
  29006. instancedArrays: boolean;
  29007. /** Defines if 32 bits indices are supported */
  29008. uintIndices: boolean;
  29009. /** Defines if high precision shaders are supported */
  29010. highPrecisionShaderSupported: boolean;
  29011. /** Defines if depth reading in the fragment shader is supported */
  29012. fragmentDepthSupported: boolean;
  29013. /** Defines if float texture linear filtering is supported*/
  29014. textureFloatLinearFiltering: boolean;
  29015. /** Defines if rendering to float textures is supported */
  29016. textureFloatRender: boolean;
  29017. /** Defines if half float textures are supported*/
  29018. textureHalfFloat: boolean;
  29019. /** Defines if half float texture linear filtering is supported*/
  29020. textureHalfFloatLinearFiltering: boolean;
  29021. /** Defines if rendering to half float textures is supported */
  29022. textureHalfFloatRender: boolean;
  29023. /** Defines if textureLOD shader command is supported */
  29024. textureLOD: boolean;
  29025. /** Defines if draw buffers extension is supported */
  29026. drawBuffersExtension: boolean;
  29027. /** Defines if depth textures are supported */
  29028. depthTextureExtension: boolean;
  29029. /** Defines if float color buffer are supported */
  29030. colorBufferFloat: boolean;
  29031. /** Gets disjoint timer query extension (null if not supported) */
  29032. timerQuery?: EXT_disjoint_timer_query;
  29033. /** Defines if timestamp can be used with timer query */
  29034. canUseTimestampForTimerQuery: boolean;
  29035. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29036. multiview?: any;
  29037. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29038. oculusMultiview?: any;
  29039. /** Function used to let the system compiles shaders in background */
  29040. parallelShaderCompile?: {
  29041. COMPLETION_STATUS_KHR: number;
  29042. };
  29043. /** Max number of texture samples for MSAA */
  29044. maxMSAASamples: number;
  29045. /** Defines if the blend min max extension is supported */
  29046. blendMinMax: boolean;
  29047. }
  29048. }
  29049. declare module BABYLON {
  29050. /**
  29051. * @hidden
  29052. **/
  29053. export class DepthCullingState {
  29054. private _isDepthTestDirty;
  29055. private _isDepthMaskDirty;
  29056. private _isDepthFuncDirty;
  29057. private _isCullFaceDirty;
  29058. private _isCullDirty;
  29059. private _isZOffsetDirty;
  29060. private _isFrontFaceDirty;
  29061. private _depthTest;
  29062. private _depthMask;
  29063. private _depthFunc;
  29064. private _cull;
  29065. private _cullFace;
  29066. private _zOffset;
  29067. private _frontFace;
  29068. /**
  29069. * Initializes the state.
  29070. */
  29071. constructor();
  29072. readonly isDirty: boolean;
  29073. zOffset: number;
  29074. cullFace: Nullable<number>;
  29075. cull: Nullable<boolean>;
  29076. depthFunc: Nullable<number>;
  29077. depthMask: boolean;
  29078. depthTest: boolean;
  29079. frontFace: Nullable<number>;
  29080. reset(): void;
  29081. apply(gl: WebGLRenderingContext): void;
  29082. }
  29083. }
  29084. declare module BABYLON {
  29085. /**
  29086. * @hidden
  29087. **/
  29088. export class StencilState {
  29089. /** 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 */
  29090. static readonly ALWAYS: number;
  29091. /** Passed to stencilOperation to specify that stencil value must be kept */
  29092. static readonly KEEP: number;
  29093. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29094. static readonly REPLACE: number;
  29095. private _isStencilTestDirty;
  29096. private _isStencilMaskDirty;
  29097. private _isStencilFuncDirty;
  29098. private _isStencilOpDirty;
  29099. private _stencilTest;
  29100. private _stencilMask;
  29101. private _stencilFunc;
  29102. private _stencilFuncRef;
  29103. private _stencilFuncMask;
  29104. private _stencilOpStencilFail;
  29105. private _stencilOpDepthFail;
  29106. private _stencilOpStencilDepthPass;
  29107. readonly isDirty: boolean;
  29108. stencilFunc: number;
  29109. stencilFuncRef: number;
  29110. stencilFuncMask: number;
  29111. stencilOpStencilFail: number;
  29112. stencilOpDepthFail: number;
  29113. stencilOpStencilDepthPass: number;
  29114. stencilMask: number;
  29115. stencilTest: boolean;
  29116. constructor();
  29117. reset(): void;
  29118. apply(gl: WebGLRenderingContext): void;
  29119. }
  29120. }
  29121. declare module BABYLON {
  29122. /**
  29123. * @hidden
  29124. **/
  29125. export class AlphaState {
  29126. private _isAlphaBlendDirty;
  29127. private _isBlendFunctionParametersDirty;
  29128. private _isBlendEquationParametersDirty;
  29129. private _isBlendConstantsDirty;
  29130. private _alphaBlend;
  29131. private _blendFunctionParameters;
  29132. private _blendEquationParameters;
  29133. private _blendConstants;
  29134. /**
  29135. * Initializes the state.
  29136. */
  29137. constructor();
  29138. readonly isDirty: boolean;
  29139. alphaBlend: boolean;
  29140. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29141. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29142. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29143. reset(): void;
  29144. apply(gl: WebGLRenderingContext): void;
  29145. }
  29146. }
  29147. declare module BABYLON {
  29148. /** @hidden */
  29149. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29150. attributeProcessor(attribute: string): string;
  29151. varyingProcessor(varying: string, isFragment: boolean): string;
  29152. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29153. }
  29154. }
  29155. declare module BABYLON {
  29156. /**
  29157. * Interface for attribute information associated with buffer instanciation
  29158. */
  29159. export interface InstancingAttributeInfo {
  29160. /**
  29161. * Index/offset of the attribute in the vertex shader
  29162. */
  29163. index: number;
  29164. /**
  29165. * size of the attribute, 1, 2, 3 or 4
  29166. */
  29167. attributeSize: number;
  29168. /**
  29169. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29170. * default is FLOAT
  29171. */
  29172. attributeType: number;
  29173. /**
  29174. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29175. */
  29176. normalized: boolean;
  29177. /**
  29178. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29179. */
  29180. offset: number;
  29181. /**
  29182. * Name of the GLSL attribute, for debugging purpose only
  29183. */
  29184. attributeName: string;
  29185. }
  29186. }
  29187. declare module BABYLON {
  29188. interface ThinEngine {
  29189. /**
  29190. * Update a video texture
  29191. * @param texture defines the texture to update
  29192. * @param video defines the video element to use
  29193. * @param invertY defines if data must be stored with Y axis inverted
  29194. */
  29195. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29196. }
  29197. }
  29198. declare module BABYLON {
  29199. /**
  29200. * Settings for finer control over video usage
  29201. */
  29202. export interface VideoTextureSettings {
  29203. /**
  29204. * Applies `autoplay` to video, if specified
  29205. */
  29206. autoPlay?: boolean;
  29207. /**
  29208. * Applies `loop` to video, if specified
  29209. */
  29210. loop?: boolean;
  29211. /**
  29212. * Automatically updates internal texture from video at every frame in the render loop
  29213. */
  29214. autoUpdateTexture: boolean;
  29215. /**
  29216. * Image src displayed during the video loading or until the user interacts with the video.
  29217. */
  29218. poster?: string;
  29219. }
  29220. /**
  29221. * If you want to display a video in your scene, this is the special texture for that.
  29222. * This special texture works similar to other textures, with the exception of a few parameters.
  29223. * @see https://doc.babylonjs.com/how_to/video_texture
  29224. */
  29225. export class VideoTexture extends Texture {
  29226. /**
  29227. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29228. */
  29229. readonly autoUpdateTexture: boolean;
  29230. /**
  29231. * The video instance used by the texture internally
  29232. */
  29233. readonly video: HTMLVideoElement;
  29234. private _onUserActionRequestedObservable;
  29235. /**
  29236. * Event triggerd when a dom action is required by the user to play the video.
  29237. * This happens due to recent changes in browser policies preventing video to auto start.
  29238. */
  29239. readonly onUserActionRequestedObservable: Observable<Texture>;
  29240. private _generateMipMaps;
  29241. private _engine;
  29242. private _stillImageCaptured;
  29243. private _displayingPosterTexture;
  29244. private _settings;
  29245. private _createInternalTextureOnEvent;
  29246. private _frameId;
  29247. /**
  29248. * Creates a video texture.
  29249. * If you want to display a video in your scene, this is the special texture for that.
  29250. * This special texture works similar to other textures, with the exception of a few parameters.
  29251. * @see https://doc.babylonjs.com/how_to/video_texture
  29252. * @param name optional name, will detect from video source, if not defined
  29253. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29254. * @param scene is obviously the current scene.
  29255. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29256. * @param invertY is false by default but can be used to invert video on Y axis
  29257. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29258. * @param settings allows finer control over video usage
  29259. */
  29260. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29261. private _getName;
  29262. private _getVideo;
  29263. private _createInternalTexture;
  29264. private reset;
  29265. /**
  29266. * @hidden Internal method to initiate `update`.
  29267. */
  29268. _rebuild(): void;
  29269. /**
  29270. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29271. */
  29272. update(): void;
  29273. /**
  29274. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29275. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29276. */
  29277. updateTexture(isVisible: boolean): void;
  29278. protected _updateInternalTexture: () => void;
  29279. /**
  29280. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29281. * @param url New url.
  29282. */
  29283. updateURL(url: string): void;
  29284. /**
  29285. * Dispose the texture and release its associated resources.
  29286. */
  29287. dispose(): void;
  29288. /**
  29289. * Creates a video texture straight from a stream.
  29290. * @param scene Define the scene the texture should be created in
  29291. * @param stream Define the stream the texture should be created from
  29292. * @returns The created video texture as a promise
  29293. */
  29294. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29295. /**
  29296. * Creates a video texture straight from your WebCam video feed.
  29297. * @param scene Define the scene the texture should be created in
  29298. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29299. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29300. * @returns The created video texture as a promise
  29301. */
  29302. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29303. minWidth: number;
  29304. maxWidth: number;
  29305. minHeight: number;
  29306. maxHeight: number;
  29307. deviceId: string;
  29308. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29309. /**
  29310. * Creates a video texture straight from your WebCam video feed.
  29311. * @param scene Define the scene the texture should be created in
  29312. * @param onReady Define a callback to triggered once the texture will be ready
  29313. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29314. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29315. */
  29316. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29317. minWidth: number;
  29318. maxWidth: number;
  29319. minHeight: number;
  29320. maxHeight: number;
  29321. deviceId: string;
  29322. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29323. }
  29324. }
  29325. declare module BABYLON {
  29326. /**
  29327. * Defines the interface used by objects working like Scene
  29328. * @hidden
  29329. */
  29330. interface ISceneLike {
  29331. _addPendingData(data: any): void;
  29332. _removePendingData(data: any): void;
  29333. offlineProvider: IOfflineProvider;
  29334. }
  29335. /** Interface defining initialization parameters for Engine class */
  29336. export interface EngineOptions extends WebGLContextAttributes {
  29337. /**
  29338. * Defines if the engine should no exceed a specified device ratio
  29339. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29340. */
  29341. limitDeviceRatio?: number;
  29342. /**
  29343. * Defines if webvr should be enabled automatically
  29344. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29345. */
  29346. autoEnableWebVR?: boolean;
  29347. /**
  29348. * Defines if webgl2 should be turned off even if supported
  29349. * @see http://doc.babylonjs.com/features/webgl2
  29350. */
  29351. disableWebGL2Support?: boolean;
  29352. /**
  29353. * Defines if webaudio should be initialized as well
  29354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29355. */
  29356. audioEngine?: boolean;
  29357. /**
  29358. * Defines if animations should run using a deterministic lock step
  29359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29360. */
  29361. deterministicLockstep?: boolean;
  29362. /** Defines the maximum steps to use with deterministic lock step mode */
  29363. lockstepMaxSteps?: number;
  29364. /**
  29365. * Defines that engine should ignore context lost events
  29366. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29367. */
  29368. doNotHandleContextLost?: boolean;
  29369. /**
  29370. * Defines that engine should ignore modifying touch action attribute and style
  29371. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29372. */
  29373. doNotHandleTouchAction?: boolean;
  29374. /**
  29375. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29376. */
  29377. useHighPrecisionFloats?: boolean;
  29378. }
  29379. /**
  29380. * The base engine class (root of all engines)
  29381. */
  29382. export class ThinEngine {
  29383. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29384. static ExceptionList: ({
  29385. key: string;
  29386. capture: string;
  29387. captureConstraint: number;
  29388. targets: string[];
  29389. } | {
  29390. key: string;
  29391. capture: null;
  29392. captureConstraint: null;
  29393. targets: string[];
  29394. })[];
  29395. /** @hidden */
  29396. static _TextureLoaders: IInternalTextureLoader[];
  29397. /**
  29398. * Returns the current npm package of the sdk
  29399. */
  29400. static readonly NpmPackage: string;
  29401. /**
  29402. * Returns the current version of the framework
  29403. */
  29404. static readonly Version: string;
  29405. /**
  29406. * Returns a string describing the current engine
  29407. */
  29408. readonly description: string;
  29409. /**
  29410. * Gets or sets the epsilon value used by collision engine
  29411. */
  29412. static CollisionsEpsilon: number;
  29413. /**
  29414. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29415. */
  29416. static ShadersRepository: string;
  29417. /** @hidden */
  29418. _shaderProcessor: IShaderProcessor;
  29419. /**
  29420. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29421. */
  29422. forcePOTTextures: boolean;
  29423. /**
  29424. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29425. */
  29426. isFullscreen: boolean;
  29427. /**
  29428. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29429. */
  29430. cullBackFaces: boolean;
  29431. /**
  29432. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29433. */
  29434. renderEvenInBackground: boolean;
  29435. /**
  29436. * Gets or sets a boolean indicating that cache can be kept between frames
  29437. */
  29438. preventCacheWipeBetweenFrames: boolean;
  29439. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29440. validateShaderPrograms: boolean;
  29441. /**
  29442. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29443. */
  29444. disableUniformBuffers: boolean;
  29445. /** @hidden */
  29446. _uniformBuffers: UniformBuffer[];
  29447. /**
  29448. * Gets a boolean indicating that the engine supports uniform buffers
  29449. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29450. */
  29451. readonly supportsUniformBuffers: boolean;
  29452. /** @hidden */
  29453. _gl: WebGLRenderingContext;
  29454. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29455. protected _windowIsBackground: boolean;
  29456. protected _webGLVersion: number;
  29457. protected _creationOptions: EngineOptions;
  29458. protected _highPrecisionShadersAllowed: boolean;
  29459. /** @hidden */
  29460. readonly _shouldUseHighPrecisionShader: boolean;
  29461. /**
  29462. * Gets a boolean indicating that only power of 2 textures are supported
  29463. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29464. */
  29465. readonly needPOTTextures: boolean;
  29466. /** @hidden */
  29467. _badOS: boolean;
  29468. /** @hidden */
  29469. _badDesktopOS: boolean;
  29470. private _hardwareScalingLevel;
  29471. /** @hidden */
  29472. _caps: EngineCapabilities;
  29473. private _isStencilEnable;
  29474. protected _colorWrite: boolean;
  29475. private _glVersion;
  29476. private _glRenderer;
  29477. private _glVendor;
  29478. /** @hidden */
  29479. _videoTextureSupported: boolean;
  29480. protected _renderingQueueLaunched: boolean;
  29481. protected _activeRenderLoops: (() => void)[];
  29482. /**
  29483. * Observable signaled when a context lost event is raised
  29484. */
  29485. onContextLostObservable: Observable<ThinEngine>;
  29486. /**
  29487. * Observable signaled when a context restored event is raised
  29488. */
  29489. onContextRestoredObservable: Observable<ThinEngine>;
  29490. private _onContextLost;
  29491. private _onContextRestored;
  29492. protected _contextWasLost: boolean;
  29493. /** @hidden */
  29494. _doNotHandleContextLost: boolean;
  29495. /**
  29496. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29498. */
  29499. doNotHandleContextLost: boolean;
  29500. /**
  29501. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29502. */
  29503. disableVertexArrayObjects: boolean;
  29504. /** @hidden */
  29505. protected _depthCullingState: DepthCullingState;
  29506. /** @hidden */
  29507. protected _stencilState: StencilState;
  29508. /** @hidden */
  29509. protected _alphaState: AlphaState;
  29510. /** @hidden */
  29511. _internalTexturesCache: InternalTexture[];
  29512. /** @hidden */
  29513. protected _activeChannel: number;
  29514. private _currentTextureChannel;
  29515. /** @hidden */
  29516. protected _boundTexturesCache: {
  29517. [key: string]: Nullable<InternalTexture>;
  29518. };
  29519. /** @hidden */
  29520. protected _currentEffect: Nullable<Effect>;
  29521. /** @hidden */
  29522. protected _currentProgram: Nullable<WebGLProgram>;
  29523. private _compiledEffects;
  29524. private _vertexAttribArraysEnabled;
  29525. /** @hidden */
  29526. protected _cachedViewport: Nullable<IViewportLike>;
  29527. private _cachedVertexArrayObject;
  29528. /** @hidden */
  29529. protected _cachedVertexBuffers: any;
  29530. /** @hidden */
  29531. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29532. /** @hidden */
  29533. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29534. /** @hidden */
  29535. _currentRenderTarget: Nullable<InternalTexture>;
  29536. private _uintIndicesCurrentlySet;
  29537. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29538. /** @hidden */
  29539. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29540. private _currentBufferPointers;
  29541. private _currentInstanceLocations;
  29542. private _currentInstanceBuffers;
  29543. private _textureUnits;
  29544. /** @hidden */
  29545. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29546. /** @hidden */
  29547. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29548. /** @hidden */
  29549. _boundRenderFunction: any;
  29550. private _vaoRecordInProgress;
  29551. private _mustWipeVertexAttributes;
  29552. private _emptyTexture;
  29553. private _emptyCubeTexture;
  29554. private _emptyTexture3D;
  29555. private _emptyTexture2DArray;
  29556. /** @hidden */
  29557. _frameHandler: number;
  29558. private _nextFreeTextureSlots;
  29559. private _maxSimultaneousTextures;
  29560. private _activeRequests;
  29561. protected _texturesSupported: string[];
  29562. /** @hidden */
  29563. _textureFormatInUse: Nullable<string>;
  29564. protected readonly _supportsHardwareTextureRescaling: boolean;
  29565. /**
  29566. * Gets the list of texture formats supported
  29567. */
  29568. readonly texturesSupported: Array<string>;
  29569. /**
  29570. * Gets the list of texture formats in use
  29571. */
  29572. readonly textureFormatInUse: Nullable<string>;
  29573. /**
  29574. * Gets the current viewport
  29575. */
  29576. readonly currentViewport: Nullable<IViewportLike>;
  29577. /**
  29578. * Gets the default empty texture
  29579. */
  29580. readonly emptyTexture: InternalTexture;
  29581. /**
  29582. * Gets the default empty 3D texture
  29583. */
  29584. readonly emptyTexture3D: InternalTexture;
  29585. /**
  29586. * Gets the default empty 2D array texture
  29587. */
  29588. readonly emptyTexture2DArray: InternalTexture;
  29589. /**
  29590. * Gets the default empty cube texture
  29591. */
  29592. readonly emptyCubeTexture: InternalTexture;
  29593. /**
  29594. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29595. */
  29596. readonly premultipliedAlpha: boolean;
  29597. /**
  29598. * Observable event triggered before each texture is initialized
  29599. */
  29600. onBeforeTextureInitObservable: Observable<Texture>;
  29601. /**
  29602. * Creates a new engine
  29603. * @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
  29604. * @param antialias defines enable antialiasing (default: false)
  29605. * @param options defines further options to be sent to the getContext() function
  29606. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29607. */
  29608. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29609. private _rebuildInternalTextures;
  29610. private _rebuildEffects;
  29611. /**
  29612. * Gets a boolean indicating if all created effects are ready
  29613. * @returns true if all effects are ready
  29614. */
  29615. areAllEffectsReady(): boolean;
  29616. protected _rebuildBuffers(): void;
  29617. private _initGLContext;
  29618. /**
  29619. * Gets version of the current webGL context
  29620. */
  29621. readonly webGLVersion: number;
  29622. /**
  29623. * Gets a string idenfifying the name of the class
  29624. * @returns "Engine" string
  29625. */
  29626. getClassName(): string;
  29627. /**
  29628. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29629. */
  29630. readonly isStencilEnable: boolean;
  29631. /** @hidden */
  29632. _prepareWorkingCanvas(): void;
  29633. /**
  29634. * Reset the texture cache to empty state
  29635. */
  29636. resetTextureCache(): void;
  29637. /**
  29638. * Gets an object containing information about the current webGL context
  29639. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29640. */
  29641. getGlInfo(): {
  29642. vendor: string;
  29643. renderer: string;
  29644. version: string;
  29645. };
  29646. /**
  29647. * Defines the hardware scaling level.
  29648. * By default the hardware scaling level is computed from the window device ratio.
  29649. * 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.
  29650. * @param level defines the level to use
  29651. */
  29652. setHardwareScalingLevel(level: number): void;
  29653. /**
  29654. * Gets the current hardware scaling level.
  29655. * By default the hardware scaling level is computed from the window device ratio.
  29656. * 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.
  29657. * @returns a number indicating the current hardware scaling level
  29658. */
  29659. getHardwareScalingLevel(): number;
  29660. /**
  29661. * Gets the list of loaded textures
  29662. * @returns an array containing all loaded textures
  29663. */
  29664. getLoadedTexturesCache(): InternalTexture[];
  29665. /**
  29666. * Gets the object containing all engine capabilities
  29667. * @returns the EngineCapabilities object
  29668. */
  29669. getCaps(): EngineCapabilities;
  29670. /**
  29671. * stop executing a render loop function and remove it from the execution array
  29672. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29673. */
  29674. stopRenderLoop(renderFunction?: () => void): void;
  29675. /** @hidden */
  29676. _renderLoop(): void;
  29677. /**
  29678. * Gets the HTML canvas attached with the current webGL context
  29679. * @returns a HTML canvas
  29680. */
  29681. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29682. /**
  29683. * Gets host window
  29684. * @returns the host window object
  29685. */
  29686. getHostWindow(): Nullable<Window>;
  29687. /**
  29688. * Gets the current render width
  29689. * @param useScreen defines if screen size must be used (or the current render target if any)
  29690. * @returns a number defining the current render width
  29691. */
  29692. getRenderWidth(useScreen?: boolean): number;
  29693. /**
  29694. * Gets the current render height
  29695. * @param useScreen defines if screen size must be used (or the current render target if any)
  29696. * @returns a number defining the current render height
  29697. */
  29698. getRenderHeight(useScreen?: boolean): number;
  29699. /**
  29700. * Can be used to override the current requestAnimationFrame requester.
  29701. * @hidden
  29702. */
  29703. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29704. /**
  29705. * Register and execute a render loop. The engine can have more than one render function
  29706. * @param renderFunction defines the function to continuously execute
  29707. */
  29708. runRenderLoop(renderFunction: () => void): void;
  29709. /**
  29710. * Clear the current render buffer or the current render target (if any is set up)
  29711. * @param color defines the color to use
  29712. * @param backBuffer defines if the back buffer must be cleared
  29713. * @param depth defines if the depth buffer must be cleared
  29714. * @param stencil defines if the stencil buffer must be cleared
  29715. */
  29716. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29717. private _viewportCached;
  29718. /** @hidden */
  29719. _viewport(x: number, y: number, width: number, height: number): void;
  29720. /**
  29721. * Set the WebGL's viewport
  29722. * @param viewport defines the viewport element to be used
  29723. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29724. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29725. */
  29726. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29727. /**
  29728. * Begin a new frame
  29729. */
  29730. beginFrame(): void;
  29731. /**
  29732. * Enf the current frame
  29733. */
  29734. endFrame(): void;
  29735. /**
  29736. * Resize the view according to the canvas' size
  29737. */
  29738. resize(): void;
  29739. /**
  29740. * Force a specific size of the canvas
  29741. * @param width defines the new canvas' width
  29742. * @param height defines the new canvas' height
  29743. */
  29744. setSize(width: number, height: number): void;
  29745. /**
  29746. * Binds the frame buffer to the specified texture.
  29747. * @param texture The texture to render to or null for the default canvas
  29748. * @param faceIndex The face of the texture to render to in case of cube texture
  29749. * @param requiredWidth The width of the target to render to
  29750. * @param requiredHeight The height of the target to render to
  29751. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29752. * @param depthStencilTexture The depth stencil texture to use to render
  29753. * @param lodLevel defines le lod level to bind to the frame buffer
  29754. */
  29755. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29756. /** @hidden */
  29757. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29758. /**
  29759. * Unbind the current render target texture from the webGL context
  29760. * @param texture defines the render target texture to unbind
  29761. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29762. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29763. */
  29764. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29765. /**
  29766. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29767. */
  29768. flushFramebuffer(): void;
  29769. /**
  29770. * Unbind the current render target and bind the default framebuffer
  29771. */
  29772. restoreDefaultFramebuffer(): void;
  29773. /** @hidden */
  29774. protected _resetVertexBufferBinding(): void;
  29775. /**
  29776. * Creates a vertex buffer
  29777. * @param data the data for the vertex buffer
  29778. * @returns the new WebGL static buffer
  29779. */
  29780. createVertexBuffer(data: DataArray): DataBuffer;
  29781. private _createVertexBuffer;
  29782. /**
  29783. * Creates a dynamic vertex buffer
  29784. * @param data the data for the dynamic vertex buffer
  29785. * @returns the new WebGL dynamic buffer
  29786. */
  29787. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29788. protected _resetIndexBufferBinding(): void;
  29789. /**
  29790. * Creates a new index buffer
  29791. * @param indices defines the content of the index buffer
  29792. * @param updatable defines if the index buffer must be updatable
  29793. * @returns a new webGL buffer
  29794. */
  29795. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29796. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29797. /**
  29798. * Bind a webGL buffer to the webGL context
  29799. * @param buffer defines the buffer to bind
  29800. */
  29801. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29802. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29803. private bindBuffer;
  29804. /**
  29805. * update the bound buffer with the given data
  29806. * @param data defines the data to update
  29807. */
  29808. updateArrayBuffer(data: Float32Array): void;
  29809. private _vertexAttribPointer;
  29810. private _bindIndexBufferWithCache;
  29811. private _bindVertexBuffersAttributes;
  29812. /**
  29813. * Records a vertex array object
  29814. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29815. * @param vertexBuffers defines the list of vertex buffers to store
  29816. * @param indexBuffer defines the index buffer to store
  29817. * @param effect defines the effect to store
  29818. * @returns the new vertex array object
  29819. */
  29820. recordVertexArrayObject(vertexBuffers: {
  29821. [key: string]: VertexBuffer;
  29822. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29823. /**
  29824. * Bind a specific vertex array object
  29825. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29826. * @param vertexArrayObject defines the vertex array object to bind
  29827. * @param indexBuffer defines the index buffer to bind
  29828. */
  29829. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29830. /**
  29831. * Bind webGl buffers directly to the webGL context
  29832. * @param vertexBuffer defines the vertex buffer to bind
  29833. * @param indexBuffer defines the index buffer to bind
  29834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29836. * @param effect defines the effect associated with the vertex buffer
  29837. */
  29838. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29839. private _unbindVertexArrayObject;
  29840. /**
  29841. * Bind a list of vertex buffers to the webGL context
  29842. * @param vertexBuffers defines the list of vertex buffers to bind
  29843. * @param indexBuffer defines the index buffer to bind
  29844. * @param effect defines the effect associated with the vertex buffers
  29845. */
  29846. bindBuffers(vertexBuffers: {
  29847. [key: string]: Nullable<VertexBuffer>;
  29848. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29849. /**
  29850. * Unbind all instance attributes
  29851. */
  29852. unbindInstanceAttributes(): void;
  29853. /**
  29854. * Release and free the memory of a vertex array object
  29855. * @param vao defines the vertex array object to delete
  29856. */
  29857. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29858. /** @hidden */
  29859. _releaseBuffer(buffer: DataBuffer): boolean;
  29860. protected _deleteBuffer(buffer: DataBuffer): void;
  29861. /**
  29862. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29863. * @param instancesBuffer defines the webGL buffer to update and bind
  29864. * @param data defines the data to store in the buffer
  29865. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29866. */
  29867. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29868. /**
  29869. * Apply all cached states (depth, culling, stencil and alpha)
  29870. */
  29871. applyStates(): void;
  29872. /**
  29873. * Send a draw order
  29874. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29875. * @param indexStart defines the starting index
  29876. * @param indexCount defines the number of index to draw
  29877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29878. */
  29879. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29880. /**
  29881. * Draw a list of points
  29882. * @param verticesStart defines the index of first vertex to draw
  29883. * @param verticesCount defines the count of vertices to draw
  29884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29885. */
  29886. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29887. /**
  29888. * Draw a list of unindexed primitives
  29889. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29890. * @param verticesStart defines the index of first vertex to draw
  29891. * @param verticesCount defines the count of vertices to draw
  29892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29893. */
  29894. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29895. /**
  29896. * Draw a list of indexed primitives
  29897. * @param fillMode defines the primitive to use
  29898. * @param indexStart defines the starting index
  29899. * @param indexCount defines the number of index to draw
  29900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29901. */
  29902. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29903. /**
  29904. * Draw a list of unindexed primitives
  29905. * @param fillMode defines the primitive to use
  29906. * @param verticesStart defines the index of first vertex to draw
  29907. * @param verticesCount defines the count of vertices to draw
  29908. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29909. */
  29910. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29911. private _drawMode;
  29912. /** @hidden */
  29913. protected _reportDrawCall(): void;
  29914. /** @hidden */
  29915. _releaseEffect(effect: Effect): void;
  29916. /** @hidden */
  29917. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29918. /**
  29919. * Create a new effect (used to store vertex/fragment shaders)
  29920. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29921. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29922. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29923. * @param samplers defines an array of string used to represent textures
  29924. * @param defines defines the string containing the defines to use to compile the shaders
  29925. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29926. * @param onCompiled defines a function to call when the effect creation is successful
  29927. * @param onError defines a function to call when the effect creation has failed
  29928. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29929. * @returns the new Effect
  29930. */
  29931. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29932. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29933. private _compileShader;
  29934. private _compileRawShader;
  29935. /**
  29936. * Directly creates a webGL program
  29937. * @param pipelineContext defines the pipeline context to attach to
  29938. * @param vertexCode defines the vertex shader code to use
  29939. * @param fragmentCode defines the fragment shader code to use
  29940. * @param context defines the webGL context to use (if not set, the current one will be used)
  29941. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29942. * @returns the new webGL program
  29943. */
  29944. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29945. /**
  29946. * Creates a webGL program
  29947. * @param pipelineContext defines the pipeline context to attach to
  29948. * @param vertexCode defines the vertex shader code to use
  29949. * @param fragmentCode defines the fragment shader code to use
  29950. * @param defines defines the string containing the defines to use to compile the shaders
  29951. * @param context defines the webGL context to use (if not set, the current one will be used)
  29952. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29953. * @returns the new webGL program
  29954. */
  29955. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29956. /**
  29957. * Creates a new pipeline context
  29958. * @returns the new pipeline
  29959. */
  29960. createPipelineContext(): IPipelineContext;
  29961. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29962. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29963. /** @hidden */
  29964. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29965. /** @hidden */
  29966. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29967. /** @hidden */
  29968. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29969. /**
  29970. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29971. * @param pipelineContext defines the pipeline context to use
  29972. * @param uniformsNames defines the list of uniform names
  29973. * @returns an array of webGL uniform locations
  29974. */
  29975. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29976. /**
  29977. * Gets the lsit of active attributes for a given webGL program
  29978. * @param pipelineContext defines the pipeline context to use
  29979. * @param attributesNames defines the list of attribute names to get
  29980. * @returns an array of indices indicating the offset of each attribute
  29981. */
  29982. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29983. /**
  29984. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29985. * @param effect defines the effect to activate
  29986. */
  29987. enableEffect(effect: Nullable<Effect>): void;
  29988. /**
  29989. * Set the value of an uniform to a number (int)
  29990. * @param uniform defines the webGL uniform location where to store the value
  29991. * @param value defines the int number to store
  29992. */
  29993. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29994. /**
  29995. * Set the value of an uniform to an array of int32
  29996. * @param uniform defines the webGL uniform location where to store the value
  29997. * @param array defines the array of int32 to store
  29998. */
  29999. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30000. /**
  30001. * Set the value of an uniform to an array of int32 (stored as vec2)
  30002. * @param uniform defines the webGL uniform location where to store the value
  30003. * @param array defines the array of int32 to store
  30004. */
  30005. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30006. /**
  30007. * Set the value of an uniform to an array of int32 (stored as vec3)
  30008. * @param uniform defines the webGL uniform location where to store the value
  30009. * @param array defines the array of int32 to store
  30010. */
  30011. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30012. /**
  30013. * Set the value of an uniform to an array of int32 (stored as vec4)
  30014. * @param uniform defines the webGL uniform location where to store the value
  30015. * @param array defines the array of int32 to store
  30016. */
  30017. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30018. /**
  30019. * Set the value of an uniform to an array of number
  30020. * @param uniform defines the webGL uniform location where to store the value
  30021. * @param array defines the array of number to store
  30022. */
  30023. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30024. /**
  30025. * Set the value of an uniform to an array of number (stored as vec2)
  30026. * @param uniform defines the webGL uniform location where to store the value
  30027. * @param array defines the array of number to store
  30028. */
  30029. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30030. /**
  30031. * Set the value of an uniform to an array of number (stored as vec3)
  30032. * @param uniform defines the webGL uniform location where to store the value
  30033. * @param array defines the array of number to store
  30034. */
  30035. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30036. /**
  30037. * Set the value of an uniform to an array of number (stored as vec4)
  30038. * @param uniform defines the webGL uniform location where to store the value
  30039. * @param array defines the array of number to store
  30040. */
  30041. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30042. /**
  30043. * Set the value of an uniform to an array of float32 (stored as matrices)
  30044. * @param uniform defines the webGL uniform location where to store the value
  30045. * @param matrices defines the array of float32 to store
  30046. */
  30047. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30048. /**
  30049. * Set the value of an uniform to a matrix (3x3)
  30050. * @param uniform defines the webGL uniform location where to store the value
  30051. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30052. */
  30053. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30054. /**
  30055. * Set the value of an uniform to a matrix (2x2)
  30056. * @param uniform defines the webGL uniform location where to store the value
  30057. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30058. */
  30059. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30060. /**
  30061. * Set the value of an uniform to a number (float)
  30062. * @param uniform defines the webGL uniform location where to store the value
  30063. * @param value defines the float number to store
  30064. */
  30065. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30066. /**
  30067. * Set the value of an uniform to a vec2
  30068. * @param uniform defines the webGL uniform location where to store the value
  30069. * @param x defines the 1st component of the value
  30070. * @param y defines the 2nd component of the value
  30071. */
  30072. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30073. /**
  30074. * Set the value of an uniform to a vec3
  30075. * @param uniform defines the webGL uniform location where to store the value
  30076. * @param x defines the 1st component of the value
  30077. * @param y defines the 2nd component of the value
  30078. * @param z defines the 3rd component of the value
  30079. */
  30080. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30081. /**
  30082. * Set the value of an uniform to a vec4
  30083. * @param uniform defines the webGL uniform location where to store the value
  30084. * @param x defines the 1st component of the value
  30085. * @param y defines the 2nd component of the value
  30086. * @param z defines the 3rd component of the value
  30087. * @param w defines the 4th component of the value
  30088. */
  30089. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30090. /**
  30091. * Gets the depth culling state manager
  30092. */
  30093. readonly depthCullingState: DepthCullingState;
  30094. /**
  30095. * Gets the alpha state manager
  30096. */
  30097. readonly alphaState: AlphaState;
  30098. /**
  30099. * Gets the stencil state manager
  30100. */
  30101. readonly stencilState: StencilState;
  30102. /**
  30103. * Clears the list of texture accessible through engine.
  30104. * This can help preventing texture load conflict due to name collision.
  30105. */
  30106. clearInternalTexturesCache(): void;
  30107. /**
  30108. * Force the entire cache to be cleared
  30109. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30110. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30111. */
  30112. wipeCaches(bruteForce?: boolean): void;
  30113. /** @hidden */
  30114. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30115. min: number;
  30116. mag: number;
  30117. };
  30118. /** @hidden */
  30119. _createTexture(): WebGLTexture;
  30120. /**
  30121. * Usually called from Texture.ts.
  30122. * Passed information to create a WebGLTexture
  30123. * @param urlArg defines a value which contains one of the following:
  30124. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30125. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30126. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30127. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30128. * @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)
  30129. * @param scene needed for loading to the correct scene
  30130. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30131. * @param onLoad optional callback to be called upon successful completion
  30132. * @param onError optional callback to be called upon failure
  30133. * @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
  30134. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30135. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30136. * @param forcedExtension defines the extension to use to pick the right loader
  30137. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30138. * @param mimeType defines an optional mime type
  30139. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30140. */
  30141. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30142. /**
  30143. * @hidden
  30144. */
  30145. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30146. /**
  30147. * Creates a raw texture
  30148. * @param data defines the data to store in the texture
  30149. * @param width defines the width of the texture
  30150. * @param height defines the height of the texture
  30151. * @param format defines the format of the data
  30152. * @param generateMipMaps defines if the engine should generate the mip levels
  30153. * @param invertY defines if data must be stored with Y axis inverted
  30154. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30155. * @param compression defines the compression used (null by default)
  30156. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30157. * @returns the raw texture inside an InternalTexture
  30158. */
  30159. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30160. /**
  30161. * Creates a new raw cube texture
  30162. * @param data defines the array of data to use to create each face
  30163. * @param size defines the size of the textures
  30164. * @param format defines the format of the data
  30165. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30166. * @param generateMipMaps defines if the engine should generate the mip levels
  30167. * @param invertY defines if data must be stored with Y axis inverted
  30168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30169. * @param compression defines the compression used (null by default)
  30170. * @returns the cube texture as an InternalTexture
  30171. */
  30172. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30173. /**
  30174. * Creates a new raw 3D texture
  30175. * @param data defines the data used to create the texture
  30176. * @param width defines the width of the texture
  30177. * @param height defines the height of the texture
  30178. * @param depth defines the depth of the texture
  30179. * @param format defines the format of the texture
  30180. * @param generateMipMaps defines if the engine must generate mip levels
  30181. * @param invertY defines if data must be stored with Y axis inverted
  30182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30183. * @param compression defines the compressed used (can be null)
  30184. * @param textureType defines the compressed used (can be null)
  30185. * @returns a new raw 3D texture (stored in an InternalTexture)
  30186. */
  30187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30188. /**
  30189. * Creates a new raw 2D array texture
  30190. * @param data defines the data used to create the texture
  30191. * @param width defines the width of the texture
  30192. * @param height defines the height of the texture
  30193. * @param depth defines the number of layers of the texture
  30194. * @param format defines the format of the texture
  30195. * @param generateMipMaps defines if the engine must generate mip levels
  30196. * @param invertY defines if data must be stored with Y axis inverted
  30197. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30198. * @param compression defines the compressed used (can be null)
  30199. * @param textureType defines the compressed used (can be null)
  30200. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30201. */
  30202. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30203. private _unpackFlipYCached;
  30204. /**
  30205. * In case you are sharing the context with other applications, it might
  30206. * be interested to not cache the unpack flip y state to ensure a consistent
  30207. * value would be set.
  30208. */
  30209. enableUnpackFlipYCached: boolean;
  30210. /** @hidden */
  30211. _unpackFlipY(value: boolean): void;
  30212. /** @hidden */
  30213. _getUnpackAlignement(): number;
  30214. /**
  30215. * Update the sampling mode of a given texture
  30216. * @param samplingMode defines the required sampling mode
  30217. * @param texture defines the texture to update
  30218. */
  30219. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30220. /** @hidden */
  30221. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30222. width: number;
  30223. height: number;
  30224. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30225. /** @hidden */
  30226. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30227. /** @hidden */
  30228. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30229. /** @hidden */
  30230. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30231. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30232. private _prepareWebGLTexture;
  30233. /** @hidden */
  30234. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30235. /** @hidden */
  30236. _releaseFramebufferObjects(texture: InternalTexture): void;
  30237. /** @hidden */
  30238. _releaseTexture(texture: InternalTexture): void;
  30239. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30240. protected _setProgram(program: WebGLProgram): void;
  30241. protected _boundUniforms: {
  30242. [key: number]: WebGLUniformLocation;
  30243. };
  30244. /**
  30245. * Binds an effect to the webGL context
  30246. * @param effect defines the effect to bind
  30247. */
  30248. bindSamplers(effect: Effect): void;
  30249. private _activateCurrentTexture;
  30250. /** @hidden */
  30251. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30252. /** @hidden */
  30253. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30254. /**
  30255. * Unbind all textures from the webGL context
  30256. */
  30257. unbindAllTextures(): void;
  30258. /**
  30259. * Sets a texture to the according uniform.
  30260. * @param channel The texture channel
  30261. * @param uniform The uniform to set
  30262. * @param texture The texture to apply
  30263. */
  30264. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30265. private _bindSamplerUniformToChannel;
  30266. private _getTextureWrapMode;
  30267. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30268. /**
  30269. * Sets an array of texture to the webGL context
  30270. * @param channel defines the channel where the texture array must be set
  30271. * @param uniform defines the associated uniform location
  30272. * @param textures defines the array of textures to bind
  30273. */
  30274. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30275. /** @hidden */
  30276. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30277. private _setTextureParameterFloat;
  30278. private _setTextureParameterInteger;
  30279. /**
  30280. * Unbind all vertex attributes from the webGL context
  30281. */
  30282. unbindAllAttributes(): void;
  30283. /**
  30284. * 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
  30285. */
  30286. releaseEffects(): void;
  30287. /**
  30288. * Dispose and release all associated resources
  30289. */
  30290. dispose(): void;
  30291. /**
  30292. * Attach a new callback raised when context lost event is fired
  30293. * @param callback defines the callback to call
  30294. */
  30295. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30296. /**
  30297. * Attach a new callback raised when context restored event is fired
  30298. * @param callback defines the callback to call
  30299. */
  30300. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30301. /**
  30302. * Get the current error code of the webGL context
  30303. * @returns the error code
  30304. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30305. */
  30306. getError(): number;
  30307. private _canRenderToFloatFramebuffer;
  30308. private _canRenderToHalfFloatFramebuffer;
  30309. private _canRenderToFramebuffer;
  30310. /** @hidden */
  30311. _getWebGLTextureType(type: number): number;
  30312. /** @hidden */
  30313. _getInternalFormat(format: number): number;
  30314. /** @hidden */
  30315. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30316. /** @hidden */
  30317. _getRGBAMultiSampleBufferFormat(type: number): number;
  30318. /** @hidden */
  30319. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30320. /**
  30321. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30322. * @returns true if the engine can be created
  30323. * @ignorenaming
  30324. */
  30325. static isSupported(): boolean;
  30326. /**
  30327. * Find the next highest power of two.
  30328. * @param x Number to start search from.
  30329. * @return Next highest power of two.
  30330. */
  30331. static CeilingPOT(x: number): number;
  30332. /**
  30333. * Find the next lowest power of two.
  30334. * @param x Number to start search from.
  30335. * @return Next lowest power of two.
  30336. */
  30337. static FloorPOT(x: number): number;
  30338. /**
  30339. * Find the nearest power of two.
  30340. * @param x Number to start search from.
  30341. * @return Next nearest power of two.
  30342. */
  30343. static NearestPOT(x: number): number;
  30344. /**
  30345. * Get the closest exponent of two
  30346. * @param value defines the value to approximate
  30347. * @param max defines the maximum value to return
  30348. * @param mode defines how to define the closest value
  30349. * @returns closest exponent of two of the given value
  30350. */
  30351. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30352. /**
  30353. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30354. * @param func - the function to be called
  30355. * @param requester - the object that will request the next frame. Falls back to window.
  30356. * @returns frame number
  30357. */
  30358. static QueueNewFrame(func: () => void, requester?: any): number;
  30359. }
  30360. }
  30361. declare module BABYLON {
  30362. /**
  30363. * Class representing spherical harmonics coefficients to the 3rd degree
  30364. */
  30365. export class SphericalHarmonics {
  30366. /**
  30367. * Defines whether or not the harmonics have been prescaled for rendering.
  30368. */
  30369. preScaled: boolean;
  30370. /**
  30371. * The l0,0 coefficients of the spherical harmonics
  30372. */
  30373. l00: Vector3;
  30374. /**
  30375. * The l1,-1 coefficients of the spherical harmonics
  30376. */
  30377. l1_1: Vector3;
  30378. /**
  30379. * The l1,0 coefficients of the spherical harmonics
  30380. */
  30381. l10: Vector3;
  30382. /**
  30383. * The l1,1 coefficients of the spherical harmonics
  30384. */
  30385. l11: Vector3;
  30386. /**
  30387. * The l2,-2 coefficients of the spherical harmonics
  30388. */
  30389. l2_2: Vector3;
  30390. /**
  30391. * The l2,-1 coefficients of the spherical harmonics
  30392. */
  30393. l2_1: Vector3;
  30394. /**
  30395. * The l2,0 coefficients of the spherical harmonics
  30396. */
  30397. l20: Vector3;
  30398. /**
  30399. * The l2,1 coefficients of the spherical harmonics
  30400. */
  30401. l21: Vector3;
  30402. /**
  30403. * The l2,2 coefficients of the spherical harmonics
  30404. */
  30405. l22: Vector3;
  30406. /**
  30407. * Adds a light to the spherical harmonics
  30408. * @param direction the direction of the light
  30409. * @param color the color of the light
  30410. * @param deltaSolidAngle the delta solid angle of the light
  30411. */
  30412. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30413. /**
  30414. * Scales the spherical harmonics by the given amount
  30415. * @param scale the amount to scale
  30416. */
  30417. scaleInPlace(scale: number): void;
  30418. /**
  30419. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30420. *
  30421. * ```
  30422. * E_lm = A_l * L_lm
  30423. * ```
  30424. *
  30425. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30426. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30427. * the scaling factors are given in equation 9.
  30428. */
  30429. convertIncidentRadianceToIrradiance(): void;
  30430. /**
  30431. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30432. *
  30433. * ```
  30434. * L = (1/pi) * E * rho
  30435. * ```
  30436. *
  30437. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30438. */
  30439. convertIrradianceToLambertianRadiance(): void;
  30440. /**
  30441. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30442. * required operations at run time.
  30443. *
  30444. * This is simply done by scaling back the SH with Ylm constants parameter.
  30445. * The trigonometric part being applied by the shader at run time.
  30446. */
  30447. preScaleForRendering(): void;
  30448. /**
  30449. * Constructs a spherical harmonics from an array.
  30450. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30451. * @returns the spherical harmonics
  30452. */
  30453. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30454. /**
  30455. * Gets the spherical harmonics from polynomial
  30456. * @param polynomial the spherical polynomial
  30457. * @returns the spherical harmonics
  30458. */
  30459. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30460. }
  30461. /**
  30462. * Class representing spherical polynomial coefficients to the 3rd degree
  30463. */
  30464. export class SphericalPolynomial {
  30465. private _harmonics;
  30466. /**
  30467. * The spherical harmonics used to create the polynomials.
  30468. */
  30469. readonly preScaledHarmonics: SphericalHarmonics;
  30470. /**
  30471. * The x coefficients of the spherical polynomial
  30472. */
  30473. x: Vector3;
  30474. /**
  30475. * The y coefficients of the spherical polynomial
  30476. */
  30477. y: Vector3;
  30478. /**
  30479. * The z coefficients of the spherical polynomial
  30480. */
  30481. z: Vector3;
  30482. /**
  30483. * The xx coefficients of the spherical polynomial
  30484. */
  30485. xx: Vector3;
  30486. /**
  30487. * The yy coefficients of the spherical polynomial
  30488. */
  30489. yy: Vector3;
  30490. /**
  30491. * The zz coefficients of the spherical polynomial
  30492. */
  30493. zz: Vector3;
  30494. /**
  30495. * The xy coefficients of the spherical polynomial
  30496. */
  30497. xy: Vector3;
  30498. /**
  30499. * The yz coefficients of the spherical polynomial
  30500. */
  30501. yz: Vector3;
  30502. /**
  30503. * The zx coefficients of the spherical polynomial
  30504. */
  30505. zx: Vector3;
  30506. /**
  30507. * Adds an ambient color to the spherical polynomial
  30508. * @param color the color to add
  30509. */
  30510. addAmbient(color: Color3): void;
  30511. /**
  30512. * Scales the spherical polynomial by the given amount
  30513. * @param scale the amount to scale
  30514. */
  30515. scaleInPlace(scale: number): void;
  30516. /**
  30517. * Gets the spherical polynomial from harmonics
  30518. * @param harmonics the spherical harmonics
  30519. * @returns the spherical polynomial
  30520. */
  30521. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30522. /**
  30523. * Constructs a spherical polynomial from an array.
  30524. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30525. * @returns the spherical polynomial
  30526. */
  30527. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30528. }
  30529. }
  30530. declare module BABYLON {
  30531. /**
  30532. * Defines the source of the internal texture
  30533. */
  30534. export enum InternalTextureSource {
  30535. /**
  30536. * The source of the texture data is unknown
  30537. */
  30538. Unknown = 0,
  30539. /**
  30540. * Texture data comes from an URL
  30541. */
  30542. Url = 1,
  30543. /**
  30544. * Texture data is only used for temporary storage
  30545. */
  30546. Temp = 2,
  30547. /**
  30548. * Texture data comes from raw data (ArrayBuffer)
  30549. */
  30550. Raw = 3,
  30551. /**
  30552. * Texture content is dynamic (video or dynamic texture)
  30553. */
  30554. Dynamic = 4,
  30555. /**
  30556. * Texture content is generated by rendering to it
  30557. */
  30558. RenderTarget = 5,
  30559. /**
  30560. * Texture content is part of a multi render target process
  30561. */
  30562. MultiRenderTarget = 6,
  30563. /**
  30564. * Texture data comes from a cube data file
  30565. */
  30566. Cube = 7,
  30567. /**
  30568. * Texture data comes from a raw cube data
  30569. */
  30570. CubeRaw = 8,
  30571. /**
  30572. * Texture data come from a prefiltered cube data file
  30573. */
  30574. CubePrefiltered = 9,
  30575. /**
  30576. * Texture content is raw 3D data
  30577. */
  30578. Raw3D = 10,
  30579. /**
  30580. * Texture content is raw 2D array data
  30581. */
  30582. Raw2DArray = 11,
  30583. /**
  30584. * Texture content is a depth texture
  30585. */
  30586. Depth = 12,
  30587. /**
  30588. * Texture data comes from a raw cube data encoded with RGBD
  30589. */
  30590. CubeRawRGBD = 13
  30591. }
  30592. /**
  30593. * Class used to store data associated with WebGL texture data for the engine
  30594. * This class should not be used directly
  30595. */
  30596. export class InternalTexture {
  30597. /** @hidden */
  30598. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30599. /**
  30600. * Defines if the texture is ready
  30601. */
  30602. isReady: boolean;
  30603. /**
  30604. * Defines if the texture is a cube texture
  30605. */
  30606. isCube: boolean;
  30607. /**
  30608. * Defines if the texture contains 3D data
  30609. */
  30610. is3D: boolean;
  30611. /**
  30612. * Defines if the texture contains 2D array data
  30613. */
  30614. is2DArray: boolean;
  30615. /**
  30616. * Defines if the texture contains multiview data
  30617. */
  30618. isMultiview: boolean;
  30619. /**
  30620. * Gets the URL used to load this texture
  30621. */
  30622. url: string;
  30623. /**
  30624. * Gets the sampling mode of the texture
  30625. */
  30626. samplingMode: number;
  30627. /**
  30628. * Gets a boolean indicating if the texture needs mipmaps generation
  30629. */
  30630. generateMipMaps: boolean;
  30631. /**
  30632. * Gets the number of samples used by the texture (WebGL2+ only)
  30633. */
  30634. samples: number;
  30635. /**
  30636. * Gets the type of the texture (int, float...)
  30637. */
  30638. type: number;
  30639. /**
  30640. * Gets the format of the texture (RGB, RGBA...)
  30641. */
  30642. format: number;
  30643. /**
  30644. * Observable called when the texture is loaded
  30645. */
  30646. onLoadedObservable: Observable<InternalTexture>;
  30647. /**
  30648. * Gets the width of the texture
  30649. */
  30650. width: number;
  30651. /**
  30652. * Gets the height of the texture
  30653. */
  30654. height: number;
  30655. /**
  30656. * Gets the depth of the texture
  30657. */
  30658. depth: number;
  30659. /**
  30660. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30661. */
  30662. baseWidth: number;
  30663. /**
  30664. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30665. */
  30666. baseHeight: number;
  30667. /**
  30668. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30669. */
  30670. baseDepth: number;
  30671. /**
  30672. * Gets a boolean indicating if the texture is inverted on Y axis
  30673. */
  30674. invertY: boolean;
  30675. /** @hidden */
  30676. _invertVScale: boolean;
  30677. /** @hidden */
  30678. _associatedChannel: number;
  30679. /** @hidden */
  30680. _source: InternalTextureSource;
  30681. /** @hidden */
  30682. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30683. /** @hidden */
  30684. _bufferView: Nullable<ArrayBufferView>;
  30685. /** @hidden */
  30686. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30687. /** @hidden */
  30688. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30689. /** @hidden */
  30690. _size: number;
  30691. /** @hidden */
  30692. _extension: string;
  30693. /** @hidden */
  30694. _files: Nullable<string[]>;
  30695. /** @hidden */
  30696. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30697. /** @hidden */
  30698. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30699. /** @hidden */
  30700. _framebuffer: Nullable<WebGLFramebuffer>;
  30701. /** @hidden */
  30702. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30703. /** @hidden */
  30704. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30705. /** @hidden */
  30706. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30707. /** @hidden */
  30708. _attachments: Nullable<number[]>;
  30709. /** @hidden */
  30710. _cachedCoordinatesMode: Nullable<number>;
  30711. /** @hidden */
  30712. _cachedWrapU: Nullable<number>;
  30713. /** @hidden */
  30714. _cachedWrapV: Nullable<number>;
  30715. /** @hidden */
  30716. _cachedWrapR: Nullable<number>;
  30717. /** @hidden */
  30718. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30719. /** @hidden */
  30720. _isDisabled: boolean;
  30721. /** @hidden */
  30722. _compression: Nullable<string>;
  30723. /** @hidden */
  30724. _generateStencilBuffer: boolean;
  30725. /** @hidden */
  30726. _generateDepthBuffer: boolean;
  30727. /** @hidden */
  30728. _comparisonFunction: number;
  30729. /** @hidden */
  30730. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30731. /** @hidden */
  30732. _lodGenerationScale: number;
  30733. /** @hidden */
  30734. _lodGenerationOffset: number;
  30735. /** @hidden */
  30736. _colorTextureArray: Nullable<WebGLTexture>;
  30737. /** @hidden */
  30738. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30739. /** @hidden */
  30740. _lodTextureHigh: Nullable<BaseTexture>;
  30741. /** @hidden */
  30742. _lodTextureMid: Nullable<BaseTexture>;
  30743. /** @hidden */
  30744. _lodTextureLow: Nullable<BaseTexture>;
  30745. /** @hidden */
  30746. _isRGBD: boolean;
  30747. /** @hidden */
  30748. _linearSpecularLOD: boolean;
  30749. /** @hidden */
  30750. _irradianceTexture: Nullable<BaseTexture>;
  30751. /** @hidden */
  30752. _webGLTexture: Nullable<WebGLTexture>;
  30753. /** @hidden */
  30754. _references: number;
  30755. private _engine;
  30756. /**
  30757. * Gets the Engine the texture belongs to.
  30758. * @returns The babylon engine
  30759. */
  30760. getEngine(): ThinEngine;
  30761. /**
  30762. * Gets the data source type of the texture
  30763. */
  30764. readonly source: InternalTextureSource;
  30765. /**
  30766. * Creates a new InternalTexture
  30767. * @param engine defines the engine to use
  30768. * @param source defines the type of data that will be used
  30769. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30770. */
  30771. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30772. /**
  30773. * Increments the number of references (ie. the number of Texture that point to it)
  30774. */
  30775. incrementReferences(): void;
  30776. /**
  30777. * Change the size of the texture (not the size of the content)
  30778. * @param width defines the new width
  30779. * @param height defines the new height
  30780. * @param depth defines the new depth (1 by default)
  30781. */
  30782. updateSize(width: int, height: int, depth?: int): void;
  30783. /** @hidden */
  30784. _rebuild(): void;
  30785. /** @hidden */
  30786. _swapAndDie(target: InternalTexture): void;
  30787. /**
  30788. * Dispose the current allocated resources
  30789. */
  30790. dispose(): void;
  30791. }
  30792. }
  30793. declare module BABYLON {
  30794. /**
  30795. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30797. */
  30798. export class Analyser {
  30799. /**
  30800. * Gets or sets the smoothing
  30801. * @ignorenaming
  30802. */
  30803. SMOOTHING: number;
  30804. /**
  30805. * Gets or sets the FFT table size
  30806. * @ignorenaming
  30807. */
  30808. FFT_SIZE: number;
  30809. /**
  30810. * Gets or sets the bar graph amplitude
  30811. * @ignorenaming
  30812. */
  30813. BARGRAPHAMPLITUDE: number;
  30814. /**
  30815. * Gets or sets the position of the debug canvas
  30816. * @ignorenaming
  30817. */
  30818. DEBUGCANVASPOS: {
  30819. x: number;
  30820. y: number;
  30821. };
  30822. /**
  30823. * Gets or sets the debug canvas size
  30824. * @ignorenaming
  30825. */
  30826. DEBUGCANVASSIZE: {
  30827. width: number;
  30828. height: number;
  30829. };
  30830. private _byteFreqs;
  30831. private _byteTime;
  30832. private _floatFreqs;
  30833. private _webAudioAnalyser;
  30834. private _debugCanvas;
  30835. private _debugCanvasContext;
  30836. private _scene;
  30837. private _registerFunc;
  30838. private _audioEngine;
  30839. /**
  30840. * Creates a new analyser
  30841. * @param scene defines hosting scene
  30842. */
  30843. constructor(scene: Scene);
  30844. /**
  30845. * Get the number of data values you will have to play with for the visualization
  30846. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30847. * @returns a number
  30848. */
  30849. getFrequencyBinCount(): number;
  30850. /**
  30851. * Gets the current frequency data as a byte array
  30852. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30853. * @returns a Uint8Array
  30854. */
  30855. getByteFrequencyData(): Uint8Array;
  30856. /**
  30857. * Gets the current waveform as a byte array
  30858. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30859. * @returns a Uint8Array
  30860. */
  30861. getByteTimeDomainData(): Uint8Array;
  30862. /**
  30863. * Gets the current frequency data as a float array
  30864. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30865. * @returns a Float32Array
  30866. */
  30867. getFloatFrequencyData(): Float32Array;
  30868. /**
  30869. * Renders the debug canvas
  30870. */
  30871. drawDebugCanvas(): void;
  30872. /**
  30873. * Stops rendering the debug canvas and removes it
  30874. */
  30875. stopDebugCanvas(): void;
  30876. /**
  30877. * Connects two audio nodes
  30878. * @param inputAudioNode defines first node to connect
  30879. * @param outputAudioNode defines second node to connect
  30880. */
  30881. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30882. /**
  30883. * Releases all associated resources
  30884. */
  30885. dispose(): void;
  30886. }
  30887. }
  30888. declare module BABYLON {
  30889. /**
  30890. * This represents an audio engine and it is responsible
  30891. * to play, synchronize and analyse sounds throughout the application.
  30892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30893. */
  30894. export interface IAudioEngine extends IDisposable {
  30895. /**
  30896. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30897. */
  30898. readonly canUseWebAudio: boolean;
  30899. /**
  30900. * Gets the current AudioContext if available.
  30901. */
  30902. readonly audioContext: Nullable<AudioContext>;
  30903. /**
  30904. * The master gain node defines the global audio volume of your audio engine.
  30905. */
  30906. readonly masterGain: GainNode;
  30907. /**
  30908. * Gets whether or not mp3 are supported by your browser.
  30909. */
  30910. readonly isMP3supported: boolean;
  30911. /**
  30912. * Gets whether or not ogg are supported by your browser.
  30913. */
  30914. readonly isOGGsupported: boolean;
  30915. /**
  30916. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30917. * @ignoreNaming
  30918. */
  30919. WarnedWebAudioUnsupported: boolean;
  30920. /**
  30921. * Defines if the audio engine relies on a custom unlocked button.
  30922. * In this case, the embedded button will not be displayed.
  30923. */
  30924. useCustomUnlockedButton: boolean;
  30925. /**
  30926. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30927. */
  30928. readonly unlocked: boolean;
  30929. /**
  30930. * Event raised when audio has been unlocked on the browser.
  30931. */
  30932. onAudioUnlockedObservable: Observable<AudioEngine>;
  30933. /**
  30934. * Event raised when audio has been locked on the browser.
  30935. */
  30936. onAudioLockedObservable: Observable<AudioEngine>;
  30937. /**
  30938. * Flags the audio engine in Locked state.
  30939. * This happens due to new browser policies preventing audio to autoplay.
  30940. */
  30941. lock(): void;
  30942. /**
  30943. * Unlocks the audio engine once a user action has been done on the dom.
  30944. * This is helpful to resume play once browser policies have been satisfied.
  30945. */
  30946. unlock(): void;
  30947. }
  30948. /**
  30949. * This represents the default audio engine used in babylon.
  30950. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30952. */
  30953. export class AudioEngine implements IAudioEngine {
  30954. private _audioContext;
  30955. private _audioContextInitialized;
  30956. private _muteButton;
  30957. private _hostElement;
  30958. /**
  30959. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30960. */
  30961. canUseWebAudio: boolean;
  30962. /**
  30963. * The master gain node defines the global audio volume of your audio engine.
  30964. */
  30965. masterGain: GainNode;
  30966. /**
  30967. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30968. * @ignoreNaming
  30969. */
  30970. WarnedWebAudioUnsupported: boolean;
  30971. /**
  30972. * Gets whether or not mp3 are supported by your browser.
  30973. */
  30974. isMP3supported: boolean;
  30975. /**
  30976. * Gets whether or not ogg are supported by your browser.
  30977. */
  30978. isOGGsupported: boolean;
  30979. /**
  30980. * Gets whether audio has been unlocked on the device.
  30981. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30982. * a user interaction has happened.
  30983. */
  30984. unlocked: boolean;
  30985. /**
  30986. * Defines if the audio engine relies on a custom unlocked button.
  30987. * In this case, the embedded button will not be displayed.
  30988. */
  30989. useCustomUnlockedButton: boolean;
  30990. /**
  30991. * Event raised when audio has been unlocked on the browser.
  30992. */
  30993. onAudioUnlockedObservable: Observable<AudioEngine>;
  30994. /**
  30995. * Event raised when audio has been locked on the browser.
  30996. */
  30997. onAudioLockedObservable: Observable<AudioEngine>;
  30998. /**
  30999. * Gets the current AudioContext if available.
  31000. */
  31001. readonly audioContext: Nullable<AudioContext>;
  31002. private _connectedAnalyser;
  31003. /**
  31004. * Instantiates a new audio engine.
  31005. *
  31006. * There should be only one per page as some browsers restrict the number
  31007. * of audio contexts you can create.
  31008. * @param hostElement defines the host element where to display the mute icon if necessary
  31009. */
  31010. constructor(hostElement?: Nullable<HTMLElement>);
  31011. /**
  31012. * Flags the audio engine in Locked state.
  31013. * This happens due to new browser policies preventing audio to autoplay.
  31014. */
  31015. lock(): void;
  31016. /**
  31017. * Unlocks the audio engine once a user action has been done on the dom.
  31018. * This is helpful to resume play once browser policies have been satisfied.
  31019. */
  31020. unlock(): void;
  31021. private _resumeAudioContext;
  31022. private _initializeAudioContext;
  31023. private _tryToRun;
  31024. private _triggerRunningState;
  31025. private _triggerSuspendedState;
  31026. private _displayMuteButton;
  31027. private _moveButtonToTopLeft;
  31028. private _onResize;
  31029. private _hideMuteButton;
  31030. /**
  31031. * Destroy and release the resources associated with the audio ccontext.
  31032. */
  31033. dispose(): void;
  31034. /**
  31035. * Gets the global volume sets on the master gain.
  31036. * @returns the global volume if set or -1 otherwise
  31037. */
  31038. getGlobalVolume(): number;
  31039. /**
  31040. * Sets the global volume of your experience (sets on the master gain).
  31041. * @param newVolume Defines the new global volume of the application
  31042. */
  31043. setGlobalVolume(newVolume: number): void;
  31044. /**
  31045. * Connect the audio engine to an audio analyser allowing some amazing
  31046. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31048. * @param analyser The analyser to connect to the engine
  31049. */
  31050. connectToAnalyser(analyser: Analyser): void;
  31051. }
  31052. }
  31053. declare module BABYLON {
  31054. /**
  31055. * Interface used to present a loading screen while loading a scene
  31056. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31057. */
  31058. export interface ILoadingScreen {
  31059. /**
  31060. * Function called to display the loading screen
  31061. */
  31062. displayLoadingUI: () => void;
  31063. /**
  31064. * Function called to hide the loading screen
  31065. */
  31066. hideLoadingUI: () => void;
  31067. /**
  31068. * Gets or sets the color to use for the background
  31069. */
  31070. loadingUIBackgroundColor: string;
  31071. /**
  31072. * Gets or sets the text to display while loading
  31073. */
  31074. loadingUIText: string;
  31075. }
  31076. /**
  31077. * Class used for the default loading screen
  31078. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31079. */
  31080. export class DefaultLoadingScreen implements ILoadingScreen {
  31081. private _renderingCanvas;
  31082. private _loadingText;
  31083. private _loadingDivBackgroundColor;
  31084. private _loadingDiv;
  31085. private _loadingTextDiv;
  31086. /** Gets or sets the logo url to use for the default loading screen */
  31087. static DefaultLogoUrl: string;
  31088. /** Gets or sets the spinner url to use for the default loading screen */
  31089. static DefaultSpinnerUrl: string;
  31090. /**
  31091. * Creates a new default loading screen
  31092. * @param _renderingCanvas defines the canvas used to render the scene
  31093. * @param _loadingText defines the default text to display
  31094. * @param _loadingDivBackgroundColor defines the default background color
  31095. */
  31096. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31097. /**
  31098. * Function called to display the loading screen
  31099. */
  31100. displayLoadingUI(): void;
  31101. /**
  31102. * Function called to hide the loading screen
  31103. */
  31104. hideLoadingUI(): void;
  31105. /**
  31106. * Gets or sets the text to display while loading
  31107. */
  31108. loadingUIText: string;
  31109. /**
  31110. * Gets or sets the color to use for the background
  31111. */
  31112. loadingUIBackgroundColor: string;
  31113. private _resizeLoadingUI;
  31114. }
  31115. }
  31116. declare module BABYLON {
  31117. /**
  31118. * Interface for any object that can request an animation frame
  31119. */
  31120. export interface ICustomAnimationFrameRequester {
  31121. /**
  31122. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31123. */
  31124. renderFunction?: Function;
  31125. /**
  31126. * Called to request the next frame to render to
  31127. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31128. */
  31129. requestAnimationFrame: Function;
  31130. /**
  31131. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31132. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31133. */
  31134. requestID?: number;
  31135. }
  31136. }
  31137. declare module BABYLON {
  31138. /**
  31139. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31140. */
  31141. export class PerformanceMonitor {
  31142. private _enabled;
  31143. private _rollingFrameTime;
  31144. private _lastFrameTimeMs;
  31145. /**
  31146. * constructor
  31147. * @param frameSampleSize The number of samples required to saturate the sliding window
  31148. */
  31149. constructor(frameSampleSize?: number);
  31150. /**
  31151. * Samples current frame
  31152. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31153. */
  31154. sampleFrame(timeMs?: number): void;
  31155. /**
  31156. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31157. */
  31158. readonly averageFrameTime: number;
  31159. /**
  31160. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31161. */
  31162. readonly averageFrameTimeVariance: number;
  31163. /**
  31164. * Returns the frame time of the most recent frame
  31165. */
  31166. readonly instantaneousFrameTime: number;
  31167. /**
  31168. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31169. */
  31170. readonly averageFPS: number;
  31171. /**
  31172. * Returns the average framerate in frames per second using the most recent frame time
  31173. */
  31174. readonly instantaneousFPS: number;
  31175. /**
  31176. * Returns true if enough samples have been taken to completely fill the sliding window
  31177. */
  31178. readonly isSaturated: boolean;
  31179. /**
  31180. * Enables contributions to the sliding window sample set
  31181. */
  31182. enable(): void;
  31183. /**
  31184. * Disables contributions to the sliding window sample set
  31185. * Samples will not be interpolated over the disabled period
  31186. */
  31187. disable(): void;
  31188. /**
  31189. * Returns true if sampling is enabled
  31190. */
  31191. readonly isEnabled: boolean;
  31192. /**
  31193. * Resets performance monitor
  31194. */
  31195. reset(): void;
  31196. }
  31197. /**
  31198. * RollingAverage
  31199. *
  31200. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31201. */
  31202. export class RollingAverage {
  31203. /**
  31204. * Current average
  31205. */
  31206. average: number;
  31207. /**
  31208. * Current variance
  31209. */
  31210. variance: number;
  31211. protected _samples: Array<number>;
  31212. protected _sampleCount: number;
  31213. protected _pos: number;
  31214. protected _m2: number;
  31215. /**
  31216. * constructor
  31217. * @param length The number of samples required to saturate the sliding window
  31218. */
  31219. constructor(length: number);
  31220. /**
  31221. * Adds a sample to the sample set
  31222. * @param v The sample value
  31223. */
  31224. add(v: number): void;
  31225. /**
  31226. * Returns previously added values or null if outside of history or outside the sliding window domain
  31227. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31228. * @return Value previously recorded with add() or null if outside of range
  31229. */
  31230. history(i: number): number;
  31231. /**
  31232. * Returns true if enough samples have been taken to completely fill the sliding window
  31233. * @return true if sample-set saturated
  31234. */
  31235. isSaturated(): boolean;
  31236. /**
  31237. * Resets the rolling average (equivalent to 0 samples taken so far)
  31238. */
  31239. reset(): void;
  31240. /**
  31241. * Wraps a value around the sample range boundaries
  31242. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31243. * @return Wrapped position in sample range
  31244. */
  31245. protected _wrapPosition(i: number): number;
  31246. }
  31247. }
  31248. declare module BABYLON {
  31249. /**
  31250. * This class is used to track a performance counter which is number based.
  31251. * The user has access to many properties which give statistics of different nature.
  31252. *
  31253. * The implementer can track two kinds of Performance Counter: time and count.
  31254. * 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.
  31255. * 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.
  31256. */
  31257. export class PerfCounter {
  31258. /**
  31259. * Gets or sets a global boolean to turn on and off all the counters
  31260. */
  31261. static Enabled: boolean;
  31262. /**
  31263. * Returns the smallest value ever
  31264. */
  31265. readonly min: number;
  31266. /**
  31267. * Returns the biggest value ever
  31268. */
  31269. readonly max: number;
  31270. /**
  31271. * Returns the average value since the performance counter is running
  31272. */
  31273. readonly average: number;
  31274. /**
  31275. * Returns the average value of the last second the counter was monitored
  31276. */
  31277. readonly lastSecAverage: number;
  31278. /**
  31279. * Returns the current value
  31280. */
  31281. readonly current: number;
  31282. /**
  31283. * Gets the accumulated total
  31284. */
  31285. readonly total: number;
  31286. /**
  31287. * Gets the total value count
  31288. */
  31289. readonly count: number;
  31290. /**
  31291. * Creates a new counter
  31292. */
  31293. constructor();
  31294. /**
  31295. * Call this method to start monitoring a new frame.
  31296. * 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.
  31297. */
  31298. fetchNewFrame(): void;
  31299. /**
  31300. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31301. * @param newCount the count value to add to the monitored count
  31302. * @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.
  31303. */
  31304. addCount(newCount: number, fetchResult: boolean): void;
  31305. /**
  31306. * Start monitoring this performance counter
  31307. */
  31308. beginMonitoring(): void;
  31309. /**
  31310. * Compute the time lapsed since the previous beginMonitoring() call.
  31311. * @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
  31312. */
  31313. endMonitoring(newFrame?: boolean): void;
  31314. private _fetchResult;
  31315. private _startMonitoringTime;
  31316. private _min;
  31317. private _max;
  31318. private _average;
  31319. private _current;
  31320. private _totalValueCount;
  31321. private _totalAccumulated;
  31322. private _lastSecAverage;
  31323. private _lastSecAccumulated;
  31324. private _lastSecTime;
  31325. private _lastSecValueCount;
  31326. }
  31327. }
  31328. declare module BABYLON {
  31329. /**
  31330. * Defines the interface used by display changed events
  31331. */
  31332. export interface IDisplayChangedEventArgs {
  31333. /** Gets the vrDisplay object (if any) */
  31334. vrDisplay: Nullable<any>;
  31335. /** Gets a boolean indicating if webVR is supported */
  31336. vrSupported: boolean;
  31337. }
  31338. /**
  31339. * Defines the interface used by objects containing a viewport (like a camera)
  31340. */
  31341. interface IViewportOwnerLike {
  31342. /**
  31343. * Gets or sets the viewport
  31344. */
  31345. viewport: IViewportLike;
  31346. }
  31347. /**
  31348. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31349. */
  31350. export class Engine extends ThinEngine {
  31351. /** Defines that alpha blending is disabled */
  31352. static readonly ALPHA_DISABLE: number;
  31353. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31354. static readonly ALPHA_ADD: number;
  31355. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31356. static readonly ALPHA_COMBINE: number;
  31357. /** Defines that alpha blending to DEST - SRC * DEST */
  31358. static readonly ALPHA_SUBTRACT: number;
  31359. /** Defines that alpha blending to SRC * DEST */
  31360. static readonly ALPHA_MULTIPLY: number;
  31361. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31362. static readonly ALPHA_MAXIMIZED: number;
  31363. /** Defines that alpha blending to SRC + DEST */
  31364. static readonly ALPHA_ONEONE: number;
  31365. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31366. static readonly ALPHA_PREMULTIPLIED: number;
  31367. /**
  31368. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31369. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31370. */
  31371. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31372. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31373. static readonly ALPHA_INTERPOLATE: number;
  31374. /**
  31375. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31376. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31377. */
  31378. static readonly ALPHA_SCREENMODE: number;
  31379. /** Defines that the ressource is not delayed*/
  31380. static readonly DELAYLOADSTATE_NONE: number;
  31381. /** Defines that the ressource was successfully delay loaded */
  31382. static readonly DELAYLOADSTATE_LOADED: number;
  31383. /** Defines that the ressource is currently delay loading */
  31384. static readonly DELAYLOADSTATE_LOADING: number;
  31385. /** Defines that the ressource is delayed and has not started loading */
  31386. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31388. static readonly NEVER: number;
  31389. /** 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 */
  31390. static readonly ALWAYS: number;
  31391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31392. static readonly LESS: number;
  31393. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31394. static readonly EQUAL: number;
  31395. /** 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 */
  31396. static readonly LEQUAL: number;
  31397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31398. static readonly GREATER: number;
  31399. /** 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 */
  31400. static readonly GEQUAL: number;
  31401. /** 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 */
  31402. static readonly NOTEQUAL: number;
  31403. /** Passed to stencilOperation to specify that stencil value must be kept */
  31404. static readonly KEEP: number;
  31405. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31406. static readonly REPLACE: number;
  31407. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31408. static readonly INCR: number;
  31409. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31410. static readonly DECR: number;
  31411. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31412. static readonly INVERT: number;
  31413. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31414. static readonly INCR_WRAP: number;
  31415. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31416. static readonly DECR_WRAP: number;
  31417. /** Texture is not repeating outside of 0..1 UVs */
  31418. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31419. /** Texture is repeating outside of 0..1 UVs */
  31420. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31421. /** Texture is repeating and mirrored */
  31422. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31423. /** ALPHA */
  31424. static readonly TEXTUREFORMAT_ALPHA: number;
  31425. /** LUMINANCE */
  31426. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31427. /** LUMINANCE_ALPHA */
  31428. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31429. /** RGB */
  31430. static readonly TEXTUREFORMAT_RGB: number;
  31431. /** RGBA */
  31432. static readonly TEXTUREFORMAT_RGBA: number;
  31433. /** RED */
  31434. static readonly TEXTUREFORMAT_RED: number;
  31435. /** RED (2nd reference) */
  31436. static readonly TEXTUREFORMAT_R: number;
  31437. /** RG */
  31438. static readonly TEXTUREFORMAT_RG: number;
  31439. /** RED_INTEGER */
  31440. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31441. /** RED_INTEGER (2nd reference) */
  31442. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31443. /** RG_INTEGER */
  31444. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31445. /** RGB_INTEGER */
  31446. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31447. /** RGBA_INTEGER */
  31448. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31449. /** UNSIGNED_BYTE */
  31450. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31451. /** UNSIGNED_BYTE (2nd reference) */
  31452. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31453. /** FLOAT */
  31454. static readonly TEXTURETYPE_FLOAT: number;
  31455. /** HALF_FLOAT */
  31456. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31457. /** BYTE */
  31458. static readonly TEXTURETYPE_BYTE: number;
  31459. /** SHORT */
  31460. static readonly TEXTURETYPE_SHORT: number;
  31461. /** UNSIGNED_SHORT */
  31462. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31463. /** INT */
  31464. static readonly TEXTURETYPE_INT: number;
  31465. /** UNSIGNED_INT */
  31466. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31467. /** UNSIGNED_SHORT_4_4_4_4 */
  31468. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31469. /** UNSIGNED_SHORT_5_5_5_1 */
  31470. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31471. /** UNSIGNED_SHORT_5_6_5 */
  31472. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31473. /** UNSIGNED_INT_2_10_10_10_REV */
  31474. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31475. /** UNSIGNED_INT_24_8 */
  31476. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31477. /** UNSIGNED_INT_10F_11F_11F_REV */
  31478. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31479. /** UNSIGNED_INT_5_9_9_9_REV */
  31480. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31481. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31482. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31483. /** nearest is mag = nearest and min = nearest and mip = linear */
  31484. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31486. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31487. /** Trilinear is mag = linear and min = linear and mip = linear */
  31488. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31489. /** nearest is mag = nearest and min = nearest and mip = linear */
  31490. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31492. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31493. /** Trilinear is mag = linear and min = linear and mip = linear */
  31494. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31495. /** mag = nearest and min = nearest and mip = nearest */
  31496. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31497. /** mag = nearest and min = linear and mip = nearest */
  31498. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31499. /** mag = nearest and min = linear and mip = linear */
  31500. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31501. /** mag = nearest and min = linear and mip = none */
  31502. static readonly TEXTURE_NEAREST_LINEAR: number;
  31503. /** mag = nearest and min = nearest and mip = none */
  31504. static readonly TEXTURE_NEAREST_NEAREST: number;
  31505. /** mag = linear and min = nearest and mip = nearest */
  31506. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31507. /** mag = linear and min = nearest and mip = linear */
  31508. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31509. /** mag = linear and min = linear and mip = none */
  31510. static readonly TEXTURE_LINEAR_LINEAR: number;
  31511. /** mag = linear and min = nearest and mip = none */
  31512. static readonly TEXTURE_LINEAR_NEAREST: number;
  31513. /** Explicit coordinates mode */
  31514. static readonly TEXTURE_EXPLICIT_MODE: number;
  31515. /** Spherical coordinates mode */
  31516. static readonly TEXTURE_SPHERICAL_MODE: number;
  31517. /** Planar coordinates mode */
  31518. static readonly TEXTURE_PLANAR_MODE: number;
  31519. /** Cubic coordinates mode */
  31520. static readonly TEXTURE_CUBIC_MODE: number;
  31521. /** Projection coordinates mode */
  31522. static readonly TEXTURE_PROJECTION_MODE: number;
  31523. /** Skybox coordinates mode */
  31524. static readonly TEXTURE_SKYBOX_MODE: number;
  31525. /** Inverse Cubic coordinates mode */
  31526. static readonly TEXTURE_INVCUBIC_MODE: number;
  31527. /** Equirectangular coordinates mode */
  31528. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31529. /** Equirectangular Fixed coordinates mode */
  31530. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31531. /** Equirectangular Fixed Mirrored coordinates mode */
  31532. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31533. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31534. static readonly SCALEMODE_FLOOR: number;
  31535. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31536. static readonly SCALEMODE_NEAREST: number;
  31537. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31538. static readonly SCALEMODE_CEILING: number;
  31539. /**
  31540. * Returns the current npm package of the sdk
  31541. */
  31542. static readonly NpmPackage: string;
  31543. /**
  31544. * Returns the current version of the framework
  31545. */
  31546. static readonly Version: string;
  31547. /** Gets the list of created engines */
  31548. static readonly Instances: Engine[];
  31549. /**
  31550. * Gets the latest created engine
  31551. */
  31552. static readonly LastCreatedEngine: Nullable<Engine>;
  31553. /**
  31554. * Gets the latest created scene
  31555. */
  31556. static readonly LastCreatedScene: Nullable<Scene>;
  31557. /**
  31558. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31559. * @param flag defines which part of the materials must be marked as dirty
  31560. * @param predicate defines a predicate used to filter which materials should be affected
  31561. */
  31562. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31563. /**
  31564. * Method called to create the default loading screen.
  31565. * This can be overriden in your own app.
  31566. * @param canvas The rendering canvas element
  31567. * @returns The loading screen
  31568. */
  31569. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31570. /**
  31571. * Method called to create the default rescale post process on each engine.
  31572. */
  31573. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31574. /**
  31575. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31576. **/
  31577. enableOfflineSupport: boolean;
  31578. /**
  31579. * 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)
  31580. **/
  31581. disableManifestCheck: boolean;
  31582. /**
  31583. * Gets the list of created scenes
  31584. */
  31585. scenes: Scene[];
  31586. /**
  31587. * Event raised when a new scene is created
  31588. */
  31589. onNewSceneAddedObservable: Observable<Scene>;
  31590. /**
  31591. * Gets the list of created postprocesses
  31592. */
  31593. postProcesses: PostProcess[];
  31594. /**
  31595. * Gets a boolean indicating if the pointer is currently locked
  31596. */
  31597. isPointerLock: boolean;
  31598. /**
  31599. * Observable event triggered each time the rendering canvas is resized
  31600. */
  31601. onResizeObservable: Observable<Engine>;
  31602. /**
  31603. * Observable event triggered each time the canvas loses focus
  31604. */
  31605. onCanvasBlurObservable: Observable<Engine>;
  31606. /**
  31607. * Observable event triggered each time the canvas gains focus
  31608. */
  31609. onCanvasFocusObservable: Observable<Engine>;
  31610. /**
  31611. * Observable event triggered each time the canvas receives pointerout event
  31612. */
  31613. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31614. /**
  31615. * Observable raised when the engine begins a new frame
  31616. */
  31617. onBeginFrameObservable: Observable<Engine>;
  31618. /**
  31619. * If set, will be used to request the next animation frame for the render loop
  31620. */
  31621. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31622. /**
  31623. * Observable raised when the engine ends the current frame
  31624. */
  31625. onEndFrameObservable: Observable<Engine>;
  31626. /**
  31627. * Observable raised when the engine is about to compile a shader
  31628. */
  31629. onBeforeShaderCompilationObservable: Observable<Engine>;
  31630. /**
  31631. * Observable raised when the engine has jsut compiled a shader
  31632. */
  31633. onAfterShaderCompilationObservable: Observable<Engine>;
  31634. /**
  31635. * Gets the audio engine
  31636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31637. * @ignorenaming
  31638. */
  31639. static audioEngine: IAudioEngine;
  31640. /**
  31641. * Default AudioEngine factory responsible of creating the Audio Engine.
  31642. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31643. */
  31644. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31645. /**
  31646. * Default offline support factory responsible of creating a tool used to store data locally.
  31647. * By default, this will create a Database object if the workload has been embedded.
  31648. */
  31649. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31650. private _loadingScreen;
  31651. private _pointerLockRequested;
  31652. private _dummyFramebuffer;
  31653. private _rescalePostProcess;
  31654. /** @hidden */
  31655. protected _alphaMode: number;
  31656. /** @hidden */
  31657. protected _alphaEquation: number;
  31658. private _deterministicLockstep;
  31659. private _lockstepMaxSteps;
  31660. protected readonly _supportsHardwareTextureRescaling: boolean;
  31661. private _fps;
  31662. private _deltaTime;
  31663. /** @hidden */
  31664. _drawCalls: PerfCounter;
  31665. /**
  31666. * Turn this value on if you want to pause FPS computation when in background
  31667. */
  31668. disablePerformanceMonitorInBackground: boolean;
  31669. private _performanceMonitor;
  31670. /**
  31671. * Gets the performance monitor attached to this engine
  31672. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31673. */
  31674. readonly performanceMonitor: PerformanceMonitor;
  31675. private _onFocus;
  31676. private _onBlur;
  31677. private _onCanvasPointerOut;
  31678. private _onCanvasBlur;
  31679. private _onCanvasFocus;
  31680. private _onFullscreenChange;
  31681. private _onPointerLockChange;
  31682. /**
  31683. * Gets the HTML element used to attach event listeners
  31684. * @returns a HTML element
  31685. */
  31686. getInputElement(): Nullable<HTMLElement>;
  31687. /**
  31688. * Creates a new engine
  31689. * @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
  31690. * @param antialias defines enable antialiasing (default: false)
  31691. * @param options defines further options to be sent to the getContext() function
  31692. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31693. */
  31694. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31695. /**
  31696. * Gets current aspect ratio
  31697. * @param viewportOwner defines the camera to use to get the aspect ratio
  31698. * @param useScreen defines if screen size must be used (or the current render target if any)
  31699. * @returns a number defining the aspect ratio
  31700. */
  31701. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31702. /**
  31703. * Gets current screen aspect ratio
  31704. * @returns a number defining the aspect ratio
  31705. */
  31706. getScreenAspectRatio(): number;
  31707. /**
  31708. * Gets host document
  31709. * @returns the host document object
  31710. */
  31711. getHostDocument(): Document;
  31712. /**
  31713. * Gets the client rect of the HTML canvas attached with the current webGL context
  31714. * @returns a client rectanglee
  31715. */
  31716. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31717. /**
  31718. * Gets the client rect of the HTML element used for events
  31719. * @returns a client rectanglee
  31720. */
  31721. getInputElementClientRect(): Nullable<ClientRect>;
  31722. /**
  31723. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31725. * @returns true if engine is in deterministic lock step mode
  31726. */
  31727. isDeterministicLockStep(): boolean;
  31728. /**
  31729. * Gets the max steps when engine is running in deterministic lock step
  31730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31731. * @returns the max steps
  31732. */
  31733. getLockstepMaxSteps(): number;
  31734. /**
  31735. * Force the mipmap generation for the given render target texture
  31736. * @param texture defines the render target texture to use
  31737. */
  31738. generateMipMapsForCubemap(texture: InternalTexture): void;
  31739. /** States */
  31740. /**
  31741. * Set various states to the webGL context
  31742. * @param culling defines backface culling state
  31743. * @param zOffset defines the value to apply to zOffset (0 by default)
  31744. * @param force defines if states must be applied even if cache is up to date
  31745. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31746. */
  31747. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31748. /**
  31749. * Set the z offset to apply to current rendering
  31750. * @param value defines the offset to apply
  31751. */
  31752. setZOffset(value: number): void;
  31753. /**
  31754. * Gets the current value of the zOffset
  31755. * @returns the current zOffset state
  31756. */
  31757. getZOffset(): number;
  31758. /**
  31759. * Enable or disable depth buffering
  31760. * @param enable defines the state to set
  31761. */
  31762. setDepthBuffer(enable: boolean): void;
  31763. /**
  31764. * Gets a boolean indicating if depth writing is enabled
  31765. * @returns the current depth writing state
  31766. */
  31767. getDepthWrite(): boolean;
  31768. /**
  31769. * Enable or disable depth writing
  31770. * @param enable defines the state to set
  31771. */
  31772. setDepthWrite(enable: boolean): void;
  31773. /**
  31774. * Enable or disable color writing
  31775. * @param enable defines the state to set
  31776. */
  31777. setColorWrite(enable: boolean): void;
  31778. /**
  31779. * Gets a boolean indicating if color writing is enabled
  31780. * @returns the current color writing state
  31781. */
  31782. getColorWrite(): boolean;
  31783. /**
  31784. * Sets alpha constants used by some alpha blending modes
  31785. * @param r defines the red component
  31786. * @param g defines the green component
  31787. * @param b defines the blue component
  31788. * @param a defines the alpha component
  31789. */
  31790. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31791. /**
  31792. * Sets the current alpha mode
  31793. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31794. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31796. */
  31797. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31798. /**
  31799. * Gets the current alpha mode
  31800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31801. * @returns the current alpha mode
  31802. */
  31803. getAlphaMode(): number;
  31804. /**
  31805. * Sets the current alpha equation
  31806. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31807. */
  31808. setAlphaEquation(equation: number): void;
  31809. /**
  31810. * Gets the current alpha equation.
  31811. * @returns the current alpha equation
  31812. */
  31813. getAlphaEquation(): number;
  31814. /**
  31815. * Gets a boolean indicating if stencil buffer is enabled
  31816. * @returns the current stencil buffer state
  31817. */
  31818. getStencilBuffer(): boolean;
  31819. /**
  31820. * Enable or disable the stencil buffer
  31821. * @param enable defines if the stencil buffer must be enabled or disabled
  31822. */
  31823. setStencilBuffer(enable: boolean): void;
  31824. /**
  31825. * Gets the current stencil mask
  31826. * @returns a number defining the new stencil mask to use
  31827. */
  31828. getStencilMask(): number;
  31829. /**
  31830. * Sets the current stencil mask
  31831. * @param mask defines the new stencil mask to use
  31832. */
  31833. setStencilMask(mask: number): void;
  31834. /**
  31835. * Gets the current stencil function
  31836. * @returns a number defining the stencil function to use
  31837. */
  31838. getStencilFunction(): number;
  31839. /**
  31840. * Gets the current stencil reference value
  31841. * @returns a number defining the stencil reference value to use
  31842. */
  31843. getStencilFunctionReference(): number;
  31844. /**
  31845. * Gets the current stencil mask
  31846. * @returns a number defining the stencil mask to use
  31847. */
  31848. getStencilFunctionMask(): number;
  31849. /**
  31850. * Sets the current stencil function
  31851. * @param stencilFunc defines the new stencil function to use
  31852. */
  31853. setStencilFunction(stencilFunc: number): void;
  31854. /**
  31855. * Sets the current stencil reference
  31856. * @param reference defines the new stencil reference to use
  31857. */
  31858. setStencilFunctionReference(reference: number): void;
  31859. /**
  31860. * Sets the current stencil mask
  31861. * @param mask defines the new stencil mask to use
  31862. */
  31863. setStencilFunctionMask(mask: number): void;
  31864. /**
  31865. * Gets the current stencil operation when stencil fails
  31866. * @returns a number defining stencil operation to use when stencil fails
  31867. */
  31868. getStencilOperationFail(): number;
  31869. /**
  31870. * Gets the current stencil operation when depth fails
  31871. * @returns a number defining stencil operation to use when depth fails
  31872. */
  31873. getStencilOperationDepthFail(): number;
  31874. /**
  31875. * Gets the current stencil operation when stencil passes
  31876. * @returns a number defining stencil operation to use when stencil passes
  31877. */
  31878. getStencilOperationPass(): number;
  31879. /**
  31880. * Sets the stencil operation to use when stencil fails
  31881. * @param operation defines the stencil operation to use when stencil fails
  31882. */
  31883. setStencilOperationFail(operation: number): void;
  31884. /**
  31885. * Sets the stencil operation to use when depth fails
  31886. * @param operation defines the stencil operation to use when depth fails
  31887. */
  31888. setStencilOperationDepthFail(operation: number): void;
  31889. /**
  31890. * Sets the stencil operation to use when stencil passes
  31891. * @param operation defines the stencil operation to use when stencil passes
  31892. */
  31893. setStencilOperationPass(operation: number): void;
  31894. /**
  31895. * Sets a boolean indicating if the dithering state is enabled or disabled
  31896. * @param value defines the dithering state
  31897. */
  31898. setDitheringState(value: boolean): void;
  31899. /**
  31900. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31901. * @param value defines the rasterizer state
  31902. */
  31903. setRasterizerState(value: boolean): void;
  31904. /**
  31905. * Gets the current depth function
  31906. * @returns a number defining the depth function
  31907. */
  31908. getDepthFunction(): Nullable<number>;
  31909. /**
  31910. * Sets the current depth function
  31911. * @param depthFunc defines the function to use
  31912. */
  31913. setDepthFunction(depthFunc: number): void;
  31914. /**
  31915. * Sets the current depth function to GREATER
  31916. */
  31917. setDepthFunctionToGreater(): void;
  31918. /**
  31919. * Sets the current depth function to GEQUAL
  31920. */
  31921. setDepthFunctionToGreaterOrEqual(): void;
  31922. /**
  31923. * Sets the current depth function to LESS
  31924. */
  31925. setDepthFunctionToLess(): void;
  31926. /**
  31927. * Sets the current depth function to LEQUAL
  31928. */
  31929. setDepthFunctionToLessOrEqual(): void;
  31930. private _cachedStencilBuffer;
  31931. private _cachedStencilFunction;
  31932. private _cachedStencilMask;
  31933. private _cachedStencilOperationPass;
  31934. private _cachedStencilOperationFail;
  31935. private _cachedStencilOperationDepthFail;
  31936. private _cachedStencilReference;
  31937. /**
  31938. * Caches the the state of the stencil buffer
  31939. */
  31940. cacheStencilState(): void;
  31941. /**
  31942. * Restores the state of the stencil buffer
  31943. */
  31944. restoreStencilState(): void;
  31945. /**
  31946. * Directly set the WebGL Viewport
  31947. * @param x defines the x coordinate of the viewport (in screen space)
  31948. * @param y defines the y coordinate of the viewport (in screen space)
  31949. * @param width defines the width of the viewport (in screen space)
  31950. * @param height defines the height of the viewport (in screen space)
  31951. * @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
  31952. */
  31953. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31954. /**
  31955. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31956. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31957. * @param y defines the y-coordinate of the corner of the clear rectangle
  31958. * @param width defines the width of the clear rectangle
  31959. * @param height defines the height of the clear rectangle
  31960. * @param clearColor defines the clear color
  31961. */
  31962. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31963. /**
  31964. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31965. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31966. * @param y defines the y-coordinate of the corner of the clear rectangle
  31967. * @param width defines the width of the clear rectangle
  31968. * @param height defines the height of the clear rectangle
  31969. */
  31970. enableScissor(x: number, y: number, width: number, height: number): void;
  31971. /**
  31972. * Disable previously set scissor test rectangle
  31973. */
  31974. disableScissor(): void;
  31975. protected _reportDrawCall(): void;
  31976. /**
  31977. * Initializes a webVR display and starts listening to display change events
  31978. * The onVRDisplayChangedObservable will be notified upon these changes
  31979. * @returns The onVRDisplayChangedObservable
  31980. */
  31981. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31982. /** @hidden */
  31983. _prepareVRComponent(): void;
  31984. /** @hidden */
  31985. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31986. /** @hidden */
  31987. _submitVRFrame(): void;
  31988. /**
  31989. * Call this function to leave webVR mode
  31990. * Will do nothing if webVR is not supported or if there is no webVR device
  31991. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31992. */
  31993. disableVR(): void;
  31994. /**
  31995. * Gets a boolean indicating that the system is in VR mode and is presenting
  31996. * @returns true if VR mode is engaged
  31997. */
  31998. isVRPresenting(): boolean;
  31999. /** @hidden */
  32000. _requestVRFrame(): void;
  32001. /** @hidden */
  32002. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32003. /**
  32004. * Gets the source code of the vertex shader associated with a specific webGL program
  32005. * @param program defines the program to use
  32006. * @returns a string containing the source code of the vertex shader associated with the program
  32007. */
  32008. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32009. /**
  32010. * Gets the source code of the fragment shader associated with a specific webGL program
  32011. * @param program defines the program to use
  32012. * @returns a string containing the source code of the fragment shader associated with the program
  32013. */
  32014. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32015. /**
  32016. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32017. * @param x defines the x coordinate of the rectangle where pixels must be read
  32018. * @param y defines the y coordinate of the rectangle where pixels must be read
  32019. * @param width defines the width of the rectangle where pixels must be read
  32020. * @param height defines the height of the rectangle where pixels must be read
  32021. * @returns a Uint8Array containing RGBA colors
  32022. */
  32023. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32024. /**
  32025. * Sets a depth stencil texture from a render target to the according uniform.
  32026. * @param channel The texture channel
  32027. * @param uniform The uniform to set
  32028. * @param texture The render target texture containing the depth stencil texture to apply
  32029. */
  32030. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32031. /**
  32032. * Sets a texture to the webGL context from a postprocess
  32033. * @param channel defines the channel to use
  32034. * @param postProcess defines the source postprocess
  32035. */
  32036. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32037. /**
  32038. * Binds the output of the passed in post process to the texture channel specified
  32039. * @param channel The channel the texture should be bound to
  32040. * @param postProcess The post process which's output should be bound
  32041. */
  32042. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32043. /** @hidden */
  32044. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32045. protected _rebuildBuffers(): void;
  32046. /** @hidden */
  32047. _renderFrame(): void;
  32048. _renderLoop(): void;
  32049. /** @hidden */
  32050. _renderViews(): boolean;
  32051. /**
  32052. * Toggle full screen mode
  32053. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32054. */
  32055. switchFullscreen(requestPointerLock: boolean): void;
  32056. /**
  32057. * Enters full screen mode
  32058. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32059. */
  32060. enterFullscreen(requestPointerLock: boolean): void;
  32061. /**
  32062. * Exits full screen mode
  32063. */
  32064. exitFullscreen(): void;
  32065. /**
  32066. * Enters Pointerlock mode
  32067. */
  32068. enterPointerlock(): void;
  32069. /**
  32070. * Exits Pointerlock mode
  32071. */
  32072. exitPointerlock(): void;
  32073. /**
  32074. * Begin a new frame
  32075. */
  32076. beginFrame(): void;
  32077. /**
  32078. * Enf the current frame
  32079. */
  32080. endFrame(): void;
  32081. resize(): void;
  32082. /**
  32083. * Set the compressed texture format to use, based on the formats you have, and the formats
  32084. * supported by the hardware / browser.
  32085. *
  32086. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32087. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32088. * to API arguments needed to compressed textures. This puts the burden on the container
  32089. * generator to house the arcane code for determining these for current & future formats.
  32090. *
  32091. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32092. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32093. *
  32094. * Note: The result of this call is not taken into account when a texture is base64.
  32095. *
  32096. * @param formatsAvailable defines the list of those format families you have created
  32097. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32098. *
  32099. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32100. * @returns The extension selected.
  32101. */
  32102. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32103. /**
  32104. * Force a specific size of the canvas
  32105. * @param width defines the new canvas' width
  32106. * @param height defines the new canvas' height
  32107. */
  32108. setSize(width: number, height: number): void;
  32109. /**
  32110. * Updates a dynamic vertex buffer.
  32111. * @param vertexBuffer the vertex buffer to update
  32112. * @param data the data used to update the vertex buffer
  32113. * @param byteOffset the byte offset of the data
  32114. * @param byteLength the byte length of the data
  32115. */
  32116. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32117. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32118. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32119. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32120. _releaseTexture(texture: InternalTexture): void;
  32121. /**
  32122. * @hidden
  32123. * Rescales a texture
  32124. * @param source input texutre
  32125. * @param destination destination texture
  32126. * @param scene scene to use to render the resize
  32127. * @param internalFormat format to use when resizing
  32128. * @param onComplete callback to be called when resize has completed
  32129. */
  32130. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32131. /**
  32132. * Gets the current framerate
  32133. * @returns a number representing the framerate
  32134. */
  32135. getFps(): number;
  32136. /**
  32137. * Gets the time spent between current and previous frame
  32138. * @returns a number representing the delta time in ms
  32139. */
  32140. getDeltaTime(): number;
  32141. private _measureFps;
  32142. /** @hidden */
  32143. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32144. /**
  32145. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32146. * @param renderTarget The render target to set the frame buffer for
  32147. */
  32148. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32149. /**
  32150. * Update a dynamic index buffer
  32151. * @param indexBuffer defines the target index buffer
  32152. * @param indices defines the data to update
  32153. * @param offset defines the offset in the target index buffer where update should start
  32154. */
  32155. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32156. /**
  32157. * Updates the sample count of a render target texture
  32158. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32159. * @param texture defines the texture to update
  32160. * @param samples defines the sample count to set
  32161. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32162. */
  32163. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32164. /**
  32165. * Updates a depth texture Comparison Mode and Function.
  32166. * If the comparison Function is equal to 0, the mode will be set to none.
  32167. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32168. * @param texture The texture to set the comparison function for
  32169. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32170. */
  32171. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32172. /**
  32173. * Creates a webGL buffer to use with instanciation
  32174. * @param capacity defines the size of the buffer
  32175. * @returns the webGL buffer
  32176. */
  32177. createInstancesBuffer(capacity: number): DataBuffer;
  32178. /**
  32179. * Delete a webGL buffer used with instanciation
  32180. * @param buffer defines the webGL buffer to delete
  32181. */
  32182. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32183. /** @hidden */
  32184. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32185. dispose(): void;
  32186. private _disableTouchAction;
  32187. /**
  32188. * Display the loading screen
  32189. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32190. */
  32191. displayLoadingUI(): void;
  32192. /**
  32193. * Hide the loading screen
  32194. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32195. */
  32196. hideLoadingUI(): void;
  32197. /**
  32198. * Gets the current loading screen object
  32199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32200. */
  32201. /**
  32202. * Sets the current loading screen object
  32203. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32204. */
  32205. loadingScreen: ILoadingScreen;
  32206. /**
  32207. * Sets the current loading screen text
  32208. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32209. */
  32210. loadingUIText: string;
  32211. /**
  32212. * Sets the current loading screen background color
  32213. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32214. */
  32215. loadingUIBackgroundColor: string;
  32216. /** Pointerlock and fullscreen */
  32217. /**
  32218. * Ask the browser to promote the current element to pointerlock mode
  32219. * @param element defines the DOM element to promote
  32220. */
  32221. static _RequestPointerlock(element: HTMLElement): void;
  32222. /**
  32223. * Asks the browser to exit pointerlock mode
  32224. */
  32225. static _ExitPointerlock(): void;
  32226. /**
  32227. * Ask the browser to promote the current element to fullscreen rendering mode
  32228. * @param element defines the DOM element to promote
  32229. */
  32230. static _RequestFullscreen(element: HTMLElement): void;
  32231. /**
  32232. * Asks the browser to exit fullscreen mode
  32233. */
  32234. static _ExitFullscreen(): void;
  32235. }
  32236. }
  32237. declare module BABYLON {
  32238. /**
  32239. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32240. * during the life time of the application.
  32241. */
  32242. export class EngineStore {
  32243. /** Gets the list of created engines */
  32244. static Instances: Engine[];
  32245. /** @hidden */
  32246. static _LastCreatedScene: Nullable<Scene>;
  32247. /**
  32248. * Gets the latest created engine
  32249. */
  32250. static readonly LastCreatedEngine: Nullable<Engine>;
  32251. /**
  32252. * Gets the latest created scene
  32253. */
  32254. static readonly LastCreatedScene: Nullable<Scene>;
  32255. /**
  32256. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32257. * @ignorenaming
  32258. */
  32259. static UseFallbackTexture: boolean;
  32260. /**
  32261. * Texture content used if a texture cannot loaded
  32262. * @ignorenaming
  32263. */
  32264. static FallbackTexture: string;
  32265. }
  32266. }
  32267. declare module BABYLON {
  32268. /**
  32269. * Helper class that provides a small promise polyfill
  32270. */
  32271. export class PromisePolyfill {
  32272. /**
  32273. * Static function used to check if the polyfill is required
  32274. * If this is the case then the function will inject the polyfill to window.Promise
  32275. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32276. */
  32277. static Apply(force?: boolean): void;
  32278. }
  32279. }
  32280. declare module BABYLON {
  32281. /**
  32282. * Interface for screenshot methods with describe argument called `size` as object with options
  32283. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32284. */
  32285. export interface IScreenshotSize {
  32286. /**
  32287. * number in pixels for canvas height
  32288. */
  32289. height?: number;
  32290. /**
  32291. * multiplier allowing render at a higher or lower resolution
  32292. * If value is defined then height and width will be ignored and taken from camera
  32293. */
  32294. precision?: number;
  32295. /**
  32296. * number in pixels for canvas width
  32297. */
  32298. width?: number;
  32299. }
  32300. }
  32301. declare module BABYLON {
  32302. interface IColor4Like {
  32303. r: float;
  32304. g: float;
  32305. b: float;
  32306. a: float;
  32307. }
  32308. /**
  32309. * Class containing a set of static utilities functions
  32310. */
  32311. export class Tools {
  32312. /**
  32313. * Gets or sets the base URL to use to load assets
  32314. */
  32315. static BaseUrl: string;
  32316. /**
  32317. * Enable/Disable Custom HTTP Request Headers globally.
  32318. * default = false
  32319. * @see CustomRequestHeaders
  32320. */
  32321. static UseCustomRequestHeaders: boolean;
  32322. /**
  32323. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32324. * i.e. when loading files, where the server/service expects an Authorization header
  32325. */
  32326. static CustomRequestHeaders: {
  32327. [key: string]: string;
  32328. };
  32329. /**
  32330. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32331. */
  32332. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32333. /**
  32334. * Default behaviour for cors in the application.
  32335. * It can be a string if the expected behavior is identical in the entire app.
  32336. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32337. */
  32338. static CorsBehavior: string | ((url: string | string[]) => string);
  32339. /**
  32340. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32341. * @ignorenaming
  32342. */
  32343. static UseFallbackTexture: boolean;
  32344. /**
  32345. * Use this object to register external classes like custom textures or material
  32346. * to allow the laoders to instantiate them
  32347. */
  32348. static RegisteredExternalClasses: {
  32349. [key: string]: Object;
  32350. };
  32351. /**
  32352. * Texture content used if a texture cannot loaded
  32353. * @ignorenaming
  32354. */
  32355. static fallbackTexture: string;
  32356. /**
  32357. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32358. * @param u defines the coordinate on X axis
  32359. * @param v defines the coordinate on Y axis
  32360. * @param width defines the width of the source data
  32361. * @param height defines the height of the source data
  32362. * @param pixels defines the source byte array
  32363. * @param color defines the output color
  32364. */
  32365. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32366. /**
  32367. * Interpolates between a and b via alpha
  32368. * @param a The lower value (returned when alpha = 0)
  32369. * @param b The upper value (returned when alpha = 1)
  32370. * @param alpha The interpolation-factor
  32371. * @return The mixed value
  32372. */
  32373. static Mix(a: number, b: number, alpha: number): number;
  32374. /**
  32375. * Tries to instantiate a new object from a given class name
  32376. * @param className defines the class name to instantiate
  32377. * @returns the new object or null if the system was not able to do the instantiation
  32378. */
  32379. static Instantiate(className: string): any;
  32380. /**
  32381. * Provides a slice function that will work even on IE
  32382. * @param data defines the array to slice
  32383. * @param start defines the start of the data (optional)
  32384. * @param end defines the end of the data (optional)
  32385. * @returns the new sliced array
  32386. */
  32387. static Slice<T>(data: T, start?: number, end?: number): T;
  32388. /**
  32389. * Polyfill for setImmediate
  32390. * @param action defines the action to execute after the current execution block
  32391. */
  32392. static SetImmediate(action: () => void): void;
  32393. /**
  32394. * Function indicating if a number is an exponent of 2
  32395. * @param value defines the value to test
  32396. * @returns true if the value is an exponent of 2
  32397. */
  32398. static IsExponentOfTwo(value: number): boolean;
  32399. private static _tmpFloatArray;
  32400. /**
  32401. * Returns the nearest 32-bit single precision float representation of a Number
  32402. * @param value A Number. If the parameter is of a different type, it will get converted
  32403. * to a number or to NaN if it cannot be converted
  32404. * @returns number
  32405. */
  32406. static FloatRound(value: number): number;
  32407. /**
  32408. * Extracts the filename from a path
  32409. * @param path defines the path to use
  32410. * @returns the filename
  32411. */
  32412. static GetFilename(path: string): string;
  32413. /**
  32414. * Extracts the "folder" part of a path (everything before the filename).
  32415. * @param uri The URI to extract the info from
  32416. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32417. * @returns The "folder" part of the path
  32418. */
  32419. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32420. /**
  32421. * Extracts text content from a DOM element hierarchy
  32422. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32423. */
  32424. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32425. /**
  32426. * Convert an angle in radians to degrees
  32427. * @param angle defines the angle to convert
  32428. * @returns the angle in degrees
  32429. */
  32430. static ToDegrees(angle: number): number;
  32431. /**
  32432. * Convert an angle in degrees to radians
  32433. * @param angle defines the angle to convert
  32434. * @returns the angle in radians
  32435. */
  32436. static ToRadians(angle: number): number;
  32437. /**
  32438. * Returns an array if obj is not an array
  32439. * @param obj defines the object to evaluate as an array
  32440. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32441. * @returns either obj directly if obj is an array or a new array containing obj
  32442. */
  32443. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32444. /**
  32445. * Gets the pointer prefix to use
  32446. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32447. */
  32448. static GetPointerPrefix(): string;
  32449. /**
  32450. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32451. * @param url define the url we are trying
  32452. * @param element define the dom element where to configure the cors policy
  32453. */
  32454. static SetCorsBehavior(url: string | string[], element: {
  32455. crossOrigin: string | null;
  32456. }): void;
  32457. /**
  32458. * Removes unwanted characters from an url
  32459. * @param url defines the url to clean
  32460. * @returns the cleaned url
  32461. */
  32462. static CleanUrl(url: string): string;
  32463. /**
  32464. * Gets or sets a function used to pre-process url before using them to load assets
  32465. */
  32466. static PreprocessUrl: (url: string) => string;
  32467. /**
  32468. * Loads an image as an HTMLImageElement.
  32469. * @param input url string, ArrayBuffer, or Blob to load
  32470. * @param onLoad callback called when the image successfully loads
  32471. * @param onError callback called when the image fails to load
  32472. * @param offlineProvider offline provider for caching
  32473. * @param mimeType optional mime type
  32474. * @returns the HTMLImageElement of the loaded image
  32475. */
  32476. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32477. /**
  32478. * Loads a file from a url
  32479. * @param url url string, ArrayBuffer, or Blob to load
  32480. * @param onSuccess callback called when the file successfully loads
  32481. * @param onProgress callback called while file is loading (if the server supports this mode)
  32482. * @param offlineProvider defines the offline provider for caching
  32483. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32484. * @param onError callback called when the file fails to load
  32485. * @returns a file request object
  32486. */
  32487. 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;
  32488. /**
  32489. * Loads a file from a url
  32490. * @param url the file url to load
  32491. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32492. */
  32493. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32494. /**
  32495. * Load a script (identified by an url). When the url returns, the
  32496. * content of this file is added into a new script element, attached to the DOM (body element)
  32497. * @param scriptUrl defines the url of the script to laod
  32498. * @param onSuccess defines the callback called when the script is loaded
  32499. * @param onError defines the callback to call if an error occurs
  32500. * @param scriptId defines the id of the script element
  32501. */
  32502. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32503. /**
  32504. * Load an asynchronous script (identified by an url). When the url returns, the
  32505. * content of this file is added into a new script element, attached to the DOM (body element)
  32506. * @param scriptUrl defines the url of the script to laod
  32507. * @param scriptId defines the id of the script element
  32508. * @returns a promise request object
  32509. */
  32510. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32511. /**
  32512. * Loads a file from a blob
  32513. * @param fileToLoad defines the blob to use
  32514. * @param callback defines the callback to call when data is loaded
  32515. * @param progressCallback defines the callback to call during loading process
  32516. * @returns a file request object
  32517. */
  32518. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32519. /**
  32520. * Reads a file from a File object
  32521. * @param file defines the file to load
  32522. * @param onSuccess defines the callback to call when data is loaded
  32523. * @param onProgress defines the callback to call during loading process
  32524. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32525. * @param onError defines the callback to call when an error occurs
  32526. * @returns a file request object
  32527. */
  32528. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32529. /**
  32530. * Creates a data url from a given string content
  32531. * @param content defines the content to convert
  32532. * @returns the new data url link
  32533. */
  32534. static FileAsURL(content: string): string;
  32535. /**
  32536. * Format the given number to a specific decimal format
  32537. * @param value defines the number to format
  32538. * @param decimals defines the number of decimals to use
  32539. * @returns the formatted string
  32540. */
  32541. static Format(value: number, decimals?: number): string;
  32542. /**
  32543. * Tries to copy an object by duplicating every property
  32544. * @param source defines the source object
  32545. * @param destination defines the target object
  32546. * @param doNotCopyList defines a list of properties to avoid
  32547. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32548. */
  32549. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32550. /**
  32551. * Gets a boolean indicating if the given object has no own property
  32552. * @param obj defines the object to test
  32553. * @returns true if object has no own property
  32554. */
  32555. static IsEmpty(obj: any): boolean;
  32556. /**
  32557. * Function used to register events at window level
  32558. * @param windowElement defines the Window object to use
  32559. * @param events defines the events to register
  32560. */
  32561. static RegisterTopRootEvents(windowElement: Window, events: {
  32562. name: string;
  32563. handler: Nullable<(e: FocusEvent) => any>;
  32564. }[]): void;
  32565. /**
  32566. * Function used to unregister events from window level
  32567. * @param windowElement defines the Window object to use
  32568. * @param events defines the events to unregister
  32569. */
  32570. static UnregisterTopRootEvents(windowElement: Window, events: {
  32571. name: string;
  32572. handler: Nullable<(e: FocusEvent) => any>;
  32573. }[]): void;
  32574. /**
  32575. * @ignore
  32576. */
  32577. static _ScreenshotCanvas: HTMLCanvasElement;
  32578. /**
  32579. * Dumps the current bound framebuffer
  32580. * @param width defines the rendering width
  32581. * @param height defines the rendering height
  32582. * @param engine defines the hosting engine
  32583. * @param successCallback defines the callback triggered once the data are available
  32584. * @param mimeType defines the mime type of the result
  32585. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32586. */
  32587. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32588. /**
  32589. * Converts the canvas data to blob.
  32590. * This acts as a polyfill for browsers not supporting the to blob function.
  32591. * @param canvas Defines the canvas to extract the data from
  32592. * @param successCallback Defines the callback triggered once the data are available
  32593. * @param mimeType Defines the mime type of the result
  32594. */
  32595. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32596. /**
  32597. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32598. * @param successCallback defines the callback triggered once the data are available
  32599. * @param mimeType defines the mime type of the result
  32600. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32601. */
  32602. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32603. /**
  32604. * Downloads a blob in the browser
  32605. * @param blob defines the blob to download
  32606. * @param fileName defines the name of the downloaded file
  32607. */
  32608. static Download(blob: Blob, fileName: string): void;
  32609. /**
  32610. * Captures a screenshot of the current rendering
  32611. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32612. * @param engine defines the rendering engine
  32613. * @param camera defines the source camera
  32614. * @param size This parameter can be set to a single number or to an object with the
  32615. * following (optional) properties: precision, width, height. If a single number is passed,
  32616. * it will be used for both width and height. If an object is passed, the screenshot size
  32617. * will be derived from the parameters. The precision property is a multiplier allowing
  32618. * rendering at a higher or lower resolution
  32619. * @param successCallback defines the callback receives a single parameter which contains the
  32620. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32621. * src parameter of an <img> to display it
  32622. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32623. * Check your browser for supported MIME types
  32624. */
  32625. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32626. /**
  32627. * Captures a screenshot of the current rendering
  32628. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32629. * @param engine defines the rendering engine
  32630. * @param camera defines the source camera
  32631. * @param size This parameter can be set to a single number or to an object with the
  32632. * following (optional) properties: precision, width, height. If a single number is passed,
  32633. * it will be used for both width and height. If an object is passed, the screenshot size
  32634. * will be derived from the parameters. The precision property is a multiplier allowing
  32635. * rendering at a higher or lower resolution
  32636. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32637. * Check your browser for supported MIME types
  32638. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32639. * to the src parameter of an <img> to display it
  32640. */
  32641. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32642. /**
  32643. * Generates an image screenshot from the specified camera.
  32644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32645. * @param engine The engine to use for rendering
  32646. * @param camera The camera to use for rendering
  32647. * @param size This parameter can be set to a single number or to an object with the
  32648. * following (optional) properties: precision, width, height. If a single number is passed,
  32649. * it will be used for both width and height. If an object is passed, the screenshot size
  32650. * will be derived from the parameters. The precision property is a multiplier allowing
  32651. * rendering at a higher or lower resolution
  32652. * @param successCallback The callback receives a single parameter which contains the
  32653. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32654. * src parameter of an <img> to display it
  32655. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32656. * Check your browser for supported MIME types
  32657. * @param samples Texture samples (default: 1)
  32658. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32659. * @param fileName A name for for the downloaded file.
  32660. */
  32661. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32662. /**
  32663. * Generates an image screenshot from the specified camera.
  32664. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32665. * @param engine The engine to use for rendering
  32666. * @param camera The camera to use for rendering
  32667. * @param size This parameter can be set to a single number or to an object with the
  32668. * following (optional) properties: precision, width, height. If a single number is passed,
  32669. * it will be used for both width and height. If an object is passed, the screenshot size
  32670. * will be derived from the parameters. The precision property is a multiplier allowing
  32671. * rendering at a higher or lower resolution
  32672. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32673. * Check your browser for supported MIME types
  32674. * @param samples Texture samples (default: 1)
  32675. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32676. * @param fileName A name for for the downloaded file.
  32677. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32678. * to the src parameter of an <img> to display it
  32679. */
  32680. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32681. /**
  32682. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32683. * Be aware Math.random() could cause collisions, but:
  32684. * "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"
  32685. * @returns a pseudo random id
  32686. */
  32687. static RandomId(): string;
  32688. /**
  32689. * Test if the given uri is a base64 string
  32690. * @param uri The uri to test
  32691. * @return True if the uri is a base64 string or false otherwise
  32692. */
  32693. static IsBase64(uri: string): boolean;
  32694. /**
  32695. * Decode the given base64 uri.
  32696. * @param uri The uri to decode
  32697. * @return The decoded base64 data.
  32698. */
  32699. static DecodeBase64(uri: string): ArrayBuffer;
  32700. /**
  32701. * Gets the absolute url.
  32702. * @param url the input url
  32703. * @return the absolute url
  32704. */
  32705. static GetAbsoluteUrl(url: string): string;
  32706. /**
  32707. * No log
  32708. */
  32709. static readonly NoneLogLevel: number;
  32710. /**
  32711. * Only message logs
  32712. */
  32713. static readonly MessageLogLevel: number;
  32714. /**
  32715. * Only warning logs
  32716. */
  32717. static readonly WarningLogLevel: number;
  32718. /**
  32719. * Only error logs
  32720. */
  32721. static readonly ErrorLogLevel: number;
  32722. /**
  32723. * All logs
  32724. */
  32725. static readonly AllLogLevel: number;
  32726. /**
  32727. * Gets a value indicating the number of loading errors
  32728. * @ignorenaming
  32729. */
  32730. static readonly errorsCount: number;
  32731. /**
  32732. * Callback called when a new log is added
  32733. */
  32734. static OnNewCacheEntry: (entry: string) => void;
  32735. /**
  32736. * Log a message to the console
  32737. * @param message defines the message to log
  32738. */
  32739. static Log(message: string): void;
  32740. /**
  32741. * Write a warning message to the console
  32742. * @param message defines the message to log
  32743. */
  32744. static Warn(message: string): void;
  32745. /**
  32746. * Write an error message to the console
  32747. * @param message defines the message to log
  32748. */
  32749. static Error(message: string): void;
  32750. /**
  32751. * Gets current log cache (list of logs)
  32752. */
  32753. static readonly LogCache: string;
  32754. /**
  32755. * Clears the log cache
  32756. */
  32757. static ClearLogCache(): void;
  32758. /**
  32759. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32760. */
  32761. static LogLevels: number;
  32762. /**
  32763. * Checks if the window object exists
  32764. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32765. */
  32766. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32767. /**
  32768. * No performance log
  32769. */
  32770. static readonly PerformanceNoneLogLevel: number;
  32771. /**
  32772. * Use user marks to log performance
  32773. */
  32774. static readonly PerformanceUserMarkLogLevel: number;
  32775. /**
  32776. * Log performance to the console
  32777. */
  32778. static readonly PerformanceConsoleLogLevel: number;
  32779. private static _performance;
  32780. /**
  32781. * Sets the current performance log level
  32782. */
  32783. static PerformanceLogLevel: number;
  32784. private static _StartPerformanceCounterDisabled;
  32785. private static _EndPerformanceCounterDisabled;
  32786. private static _StartUserMark;
  32787. private static _EndUserMark;
  32788. private static _StartPerformanceConsole;
  32789. private static _EndPerformanceConsole;
  32790. /**
  32791. * Starts a performance counter
  32792. */
  32793. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32794. /**
  32795. * Ends a specific performance coutner
  32796. */
  32797. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32798. /**
  32799. * Gets either window.performance.now() if supported or Date.now() else
  32800. */
  32801. static readonly Now: number;
  32802. /**
  32803. * This method will return the name of the class used to create the instance of the given object.
  32804. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32805. * @param object the object to get the class name from
  32806. * @param isType defines if the object is actually a type
  32807. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32808. */
  32809. static GetClassName(object: any, isType?: boolean): string;
  32810. /**
  32811. * Gets the first element of an array satisfying a given predicate
  32812. * @param array defines the array to browse
  32813. * @param predicate defines the predicate to use
  32814. * @returns null if not found or the element
  32815. */
  32816. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32817. /**
  32818. * This method will return the name of the full name of the class, including its owning module (if any).
  32819. * 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).
  32820. * @param object the object to get the class name from
  32821. * @param isType defines if the object is actually a type
  32822. * @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.
  32823. * @ignorenaming
  32824. */
  32825. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32826. /**
  32827. * Returns a promise that resolves after the given amount of time.
  32828. * @param delay Number of milliseconds to delay
  32829. * @returns Promise that resolves after the given amount of time
  32830. */
  32831. static DelayAsync(delay: number): Promise<void>;
  32832. }
  32833. /**
  32834. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32835. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32836. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32837. * @param name The name of the class, case should be preserved
  32838. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32839. */
  32840. export function className(name: string, module?: string): (target: Object) => void;
  32841. /**
  32842. * An implementation of a loop for asynchronous functions.
  32843. */
  32844. export class AsyncLoop {
  32845. /**
  32846. * Defines the number of iterations for the loop
  32847. */
  32848. iterations: number;
  32849. /**
  32850. * Defines the current index of the loop.
  32851. */
  32852. index: number;
  32853. private _done;
  32854. private _fn;
  32855. private _successCallback;
  32856. /**
  32857. * Constructor.
  32858. * @param iterations the number of iterations.
  32859. * @param func the function to run each iteration
  32860. * @param successCallback the callback that will be called upon succesful execution
  32861. * @param offset starting offset.
  32862. */
  32863. constructor(
  32864. /**
  32865. * Defines the number of iterations for the loop
  32866. */
  32867. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32868. /**
  32869. * Execute the next iteration. Must be called after the last iteration was finished.
  32870. */
  32871. executeNext(): void;
  32872. /**
  32873. * Break the loop and run the success callback.
  32874. */
  32875. breakLoop(): void;
  32876. /**
  32877. * Create and run an async loop.
  32878. * @param iterations the number of iterations.
  32879. * @param fn the function to run each iteration
  32880. * @param successCallback the callback that will be called upon succesful execution
  32881. * @param offset starting offset.
  32882. * @returns the created async loop object
  32883. */
  32884. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32885. /**
  32886. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32887. * @param iterations total number of iterations
  32888. * @param syncedIterations number of synchronous iterations in each async iteration.
  32889. * @param fn the function to call each iteration.
  32890. * @param callback a success call back that will be called when iterating stops.
  32891. * @param breakFunction a break condition (optional)
  32892. * @param timeout timeout settings for the setTimeout function. default - 0.
  32893. * @returns the created async loop object
  32894. */
  32895. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32896. }
  32897. }
  32898. declare module BABYLON {
  32899. /**
  32900. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32901. * The underlying implementation relies on an associative array to ensure the best performances.
  32902. * The value can be anything including 'null' but except 'undefined'
  32903. */
  32904. export class StringDictionary<T> {
  32905. /**
  32906. * This will clear this dictionary and copy the content from the 'source' one.
  32907. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32908. * @param source the dictionary to take the content from and copy to this dictionary
  32909. */
  32910. copyFrom(source: StringDictionary<T>): void;
  32911. /**
  32912. * Get a value based from its key
  32913. * @param key the given key to get the matching value from
  32914. * @return the value if found, otherwise undefined is returned
  32915. */
  32916. get(key: string): T | undefined;
  32917. /**
  32918. * Get a value from its key or add it if it doesn't exist.
  32919. * This method will ensure you that a given key/data will be present in the dictionary.
  32920. * @param key the given key to get the matching value from
  32921. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32922. * The factory will only be invoked if there's no data for the given key.
  32923. * @return the value corresponding to the key.
  32924. */
  32925. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32926. /**
  32927. * Get a value from its key if present in the dictionary otherwise add it
  32928. * @param key the key to get the value from
  32929. * @param val if there's no such key/value pair in the dictionary add it with this value
  32930. * @return the value corresponding to the key
  32931. */
  32932. getOrAdd(key: string, val: T): T;
  32933. /**
  32934. * Check if there's a given key in the dictionary
  32935. * @param key the key to check for
  32936. * @return true if the key is present, false otherwise
  32937. */
  32938. contains(key: string): boolean;
  32939. /**
  32940. * Add a new key and its corresponding value
  32941. * @param key the key to add
  32942. * @param value the value corresponding to the key
  32943. * @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
  32944. */
  32945. add(key: string, value: T): boolean;
  32946. /**
  32947. * Update a specific value associated to a key
  32948. * @param key defines the key to use
  32949. * @param value defines the value to store
  32950. * @returns true if the value was updated (or false if the key was not found)
  32951. */
  32952. set(key: string, value: T): boolean;
  32953. /**
  32954. * Get the element of the given key and remove it from the dictionary
  32955. * @param key defines the key to search
  32956. * @returns the value associated with the key or null if not found
  32957. */
  32958. getAndRemove(key: string): Nullable<T>;
  32959. /**
  32960. * Remove a key/value from the dictionary.
  32961. * @param key the key to remove
  32962. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32963. */
  32964. remove(key: string): boolean;
  32965. /**
  32966. * Clear the whole content of the dictionary
  32967. */
  32968. clear(): void;
  32969. /**
  32970. * Gets the current count
  32971. */
  32972. readonly count: number;
  32973. /**
  32974. * Execute a callback on each key/val of the dictionary.
  32975. * Note that you can remove any element in this dictionary in the callback implementation
  32976. * @param callback the callback to execute on a given key/value pair
  32977. */
  32978. forEach(callback: (key: string, val: T) => void): void;
  32979. /**
  32980. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32981. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32982. * Note that you can remove any element in this dictionary in the callback implementation
  32983. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32984. * @returns the first item
  32985. */
  32986. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32987. private _count;
  32988. private _data;
  32989. }
  32990. }
  32991. declare module BABYLON {
  32992. /** @hidden */
  32993. export interface ICollisionCoordinator {
  32994. createCollider(): Collider;
  32995. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32996. init(scene: Scene): void;
  32997. }
  32998. /** @hidden */
  32999. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33000. private _scene;
  33001. private _scaledPosition;
  33002. private _scaledVelocity;
  33003. private _finalPosition;
  33004. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33005. createCollider(): Collider;
  33006. init(scene: Scene): void;
  33007. private _collideWithWorld;
  33008. }
  33009. }
  33010. declare module BABYLON {
  33011. /**
  33012. * Class used to manage all inputs for the scene.
  33013. */
  33014. export class InputManager {
  33015. /** The distance in pixel that you have to move to prevent some events */
  33016. static DragMovementThreshold: number;
  33017. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33018. static LongPressDelay: number;
  33019. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33020. static DoubleClickDelay: number;
  33021. /** If you need to check double click without raising a single click at first click, enable this flag */
  33022. static ExclusiveDoubleClickMode: boolean;
  33023. private _wheelEventName;
  33024. private _onPointerMove;
  33025. private _onPointerDown;
  33026. private _onPointerUp;
  33027. private _initClickEvent;
  33028. private _initActionManager;
  33029. private _delayedSimpleClick;
  33030. private _delayedSimpleClickTimeout;
  33031. private _previousDelayedSimpleClickTimeout;
  33032. private _meshPickProceed;
  33033. private _previousButtonPressed;
  33034. private _currentPickResult;
  33035. private _previousPickResult;
  33036. private _totalPointersPressed;
  33037. private _doubleClickOccured;
  33038. private _pointerOverMesh;
  33039. private _pickedDownMesh;
  33040. private _pickedUpMesh;
  33041. private _pointerX;
  33042. private _pointerY;
  33043. private _unTranslatedPointerX;
  33044. private _unTranslatedPointerY;
  33045. private _startingPointerPosition;
  33046. private _previousStartingPointerPosition;
  33047. private _startingPointerTime;
  33048. private _previousStartingPointerTime;
  33049. private _pointerCaptures;
  33050. private _onKeyDown;
  33051. private _onKeyUp;
  33052. private _onCanvasFocusObserver;
  33053. private _onCanvasBlurObserver;
  33054. private _scene;
  33055. /**
  33056. * Creates a new InputManager
  33057. * @param scene defines the hosting scene
  33058. */
  33059. constructor(scene: Scene);
  33060. /**
  33061. * Gets the mesh that is currently under the pointer
  33062. */
  33063. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33064. /**
  33065. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33066. */
  33067. readonly unTranslatedPointer: Vector2;
  33068. /**
  33069. * Gets or sets the current on-screen X position of the pointer
  33070. */
  33071. pointerX: number;
  33072. /**
  33073. * Gets or sets the current on-screen Y position of the pointer
  33074. */
  33075. pointerY: number;
  33076. private _updatePointerPosition;
  33077. private _processPointerMove;
  33078. private _setRayOnPointerInfo;
  33079. private _checkPrePointerObservable;
  33080. /**
  33081. * Use this method to simulate a pointer move on a mesh
  33082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33085. */
  33086. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33087. /**
  33088. * Use this method to simulate a pointer down on a mesh
  33089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33092. */
  33093. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33094. private _processPointerDown;
  33095. /** @hidden */
  33096. _isPointerSwiping(): boolean;
  33097. /**
  33098. * Use this method to simulate a pointer up on a mesh
  33099. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33100. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33101. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33102. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33103. */
  33104. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33105. private _processPointerUp;
  33106. /**
  33107. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33108. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33109. * @returns true if the pointer was captured
  33110. */
  33111. isPointerCaptured(pointerId?: number): boolean;
  33112. /**
  33113. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33114. * @param attachUp defines if you want to attach events to pointerup
  33115. * @param attachDown defines if you want to attach events to pointerdown
  33116. * @param attachMove defines if you want to attach events to pointermove
  33117. */
  33118. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33119. /**
  33120. * Detaches all event handlers
  33121. */
  33122. detachControl(): void;
  33123. /**
  33124. * Force the value of meshUnderPointer
  33125. * @param mesh defines the mesh to use
  33126. */
  33127. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33128. /**
  33129. * Gets the mesh under the pointer
  33130. * @returns a Mesh or null if no mesh is under the pointer
  33131. */
  33132. getPointerOverMesh(): Nullable<AbstractMesh>;
  33133. }
  33134. }
  33135. declare module BABYLON {
  33136. /**
  33137. * Helper class used to generate session unique ID
  33138. */
  33139. export class UniqueIdGenerator {
  33140. private static _UniqueIdCounter;
  33141. /**
  33142. * Gets an unique (relatively to the current scene) Id
  33143. */
  33144. static readonly UniqueId: number;
  33145. }
  33146. }
  33147. declare module BABYLON {
  33148. /**
  33149. * This class defines the direct association between an animation and a target
  33150. */
  33151. export class TargetedAnimation {
  33152. /**
  33153. * Animation to perform
  33154. */
  33155. animation: Animation;
  33156. /**
  33157. * Target to animate
  33158. */
  33159. target: any;
  33160. /**
  33161. * Serialize the object
  33162. * @returns the JSON object representing the current entity
  33163. */
  33164. serialize(): any;
  33165. }
  33166. /**
  33167. * Use this class to create coordinated animations on multiple targets
  33168. */
  33169. export class AnimationGroup implements IDisposable {
  33170. /** The name of the animation group */
  33171. name: string;
  33172. private _scene;
  33173. private _targetedAnimations;
  33174. private _animatables;
  33175. private _from;
  33176. private _to;
  33177. private _isStarted;
  33178. private _isPaused;
  33179. private _speedRatio;
  33180. private _loopAnimation;
  33181. /**
  33182. * Gets or sets the unique id of the node
  33183. */
  33184. uniqueId: number;
  33185. /**
  33186. * This observable will notify when one animation have ended
  33187. */
  33188. onAnimationEndObservable: Observable<TargetedAnimation>;
  33189. /**
  33190. * Observer raised when one animation loops
  33191. */
  33192. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33193. /**
  33194. * Observer raised when all animations have looped
  33195. */
  33196. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33197. /**
  33198. * This observable will notify when all animations have ended.
  33199. */
  33200. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33201. /**
  33202. * This observable will notify when all animations have paused.
  33203. */
  33204. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33205. /**
  33206. * This observable will notify when all animations are playing.
  33207. */
  33208. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33209. /**
  33210. * Gets the first frame
  33211. */
  33212. readonly from: number;
  33213. /**
  33214. * Gets the last frame
  33215. */
  33216. readonly to: number;
  33217. /**
  33218. * Define if the animations are started
  33219. */
  33220. readonly isStarted: boolean;
  33221. /**
  33222. * Gets a value indicating that the current group is playing
  33223. */
  33224. readonly isPlaying: boolean;
  33225. /**
  33226. * Gets or sets the speed ratio to use for all animations
  33227. */
  33228. /**
  33229. * Gets or sets the speed ratio to use for all animations
  33230. */
  33231. speedRatio: number;
  33232. /**
  33233. * Gets or sets if all animations should loop or not
  33234. */
  33235. loopAnimation: boolean;
  33236. /**
  33237. * Gets the targeted animations for this animation group
  33238. */
  33239. readonly targetedAnimations: Array<TargetedAnimation>;
  33240. /**
  33241. * returning the list of animatables controlled by this animation group.
  33242. */
  33243. readonly animatables: Array<Animatable>;
  33244. /**
  33245. * Instantiates a new Animation Group.
  33246. * This helps managing several animations at once.
  33247. * @see http://doc.babylonjs.com/how_to/group
  33248. * @param name Defines the name of the group
  33249. * @param scene Defines the scene the group belongs to
  33250. */
  33251. constructor(
  33252. /** The name of the animation group */
  33253. name: string, scene?: Nullable<Scene>);
  33254. /**
  33255. * Add an animation (with its target) in the group
  33256. * @param animation defines the animation we want to add
  33257. * @param target defines the target of the animation
  33258. * @returns the TargetedAnimation object
  33259. */
  33260. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33261. /**
  33262. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33263. * It can add constant keys at begin or end
  33264. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33265. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33266. * @returns the animation group
  33267. */
  33268. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33269. private _animationLoopCount;
  33270. private _animationLoopFlags;
  33271. private _processLoop;
  33272. /**
  33273. * Start all animations on given targets
  33274. * @param loop defines if animations must loop
  33275. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33276. * @param from defines the from key (optional)
  33277. * @param to defines the to key (optional)
  33278. * @returns the current animation group
  33279. */
  33280. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33281. /**
  33282. * Pause all animations
  33283. * @returns the animation group
  33284. */
  33285. pause(): AnimationGroup;
  33286. /**
  33287. * Play all animations to initial state
  33288. * This function will start() the animations if they were not started or will restart() them if they were paused
  33289. * @param loop defines if animations must loop
  33290. * @returns the animation group
  33291. */
  33292. play(loop?: boolean): AnimationGroup;
  33293. /**
  33294. * Reset all animations to initial state
  33295. * @returns the animation group
  33296. */
  33297. reset(): AnimationGroup;
  33298. /**
  33299. * Restart animations from key 0
  33300. * @returns the animation group
  33301. */
  33302. restart(): AnimationGroup;
  33303. /**
  33304. * Stop all animations
  33305. * @returns the animation group
  33306. */
  33307. stop(): AnimationGroup;
  33308. /**
  33309. * Set animation weight for all animatables
  33310. * @param weight defines the weight to use
  33311. * @return the animationGroup
  33312. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33313. */
  33314. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33315. /**
  33316. * Synchronize and normalize all animatables with a source animatable
  33317. * @param root defines the root animatable to synchronize with
  33318. * @return the animationGroup
  33319. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33320. */
  33321. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33322. /**
  33323. * Goes to a specific frame in this animation group
  33324. * @param frame the frame number to go to
  33325. * @return the animationGroup
  33326. */
  33327. goToFrame(frame: number): AnimationGroup;
  33328. /**
  33329. * Dispose all associated resources
  33330. */
  33331. dispose(): void;
  33332. private _checkAnimationGroupEnded;
  33333. /**
  33334. * Clone the current animation group and returns a copy
  33335. * @param newName defines the name of the new group
  33336. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33337. * @returns the new aniamtion group
  33338. */
  33339. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33340. /**
  33341. * Serializes the animationGroup to an object
  33342. * @returns Serialized object
  33343. */
  33344. serialize(): any;
  33345. /**
  33346. * Returns a new AnimationGroup object parsed from the source provided.
  33347. * @param parsedAnimationGroup defines the source
  33348. * @param scene defines the scene that will receive the animationGroup
  33349. * @returns a new AnimationGroup
  33350. */
  33351. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33352. /**
  33353. * Returns the string "AnimationGroup"
  33354. * @returns "AnimationGroup"
  33355. */
  33356. getClassName(): string;
  33357. /**
  33358. * Creates a detailled string about the object
  33359. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33360. * @returns a string representing the object
  33361. */
  33362. toString(fullDetails?: boolean): string;
  33363. }
  33364. }
  33365. declare module BABYLON {
  33366. /**
  33367. * Define an interface for all classes that will hold resources
  33368. */
  33369. export interface IDisposable {
  33370. /**
  33371. * Releases all held resources
  33372. */
  33373. dispose(): void;
  33374. }
  33375. /** Interface defining initialization parameters for Scene class */
  33376. export interface SceneOptions {
  33377. /**
  33378. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33379. * It will improve performance when the number of geometries becomes important.
  33380. */
  33381. useGeometryUniqueIdsMap?: boolean;
  33382. /**
  33383. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33384. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33385. */
  33386. useMaterialMeshMap?: boolean;
  33387. /**
  33388. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33389. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33390. */
  33391. useClonedMeshhMap?: boolean;
  33392. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33393. virtual?: boolean;
  33394. }
  33395. /**
  33396. * Represents a scene to be rendered by the engine.
  33397. * @see http://doc.babylonjs.com/features/scene
  33398. */
  33399. export class Scene extends AbstractScene implements IAnimatable {
  33400. /** The fog is deactivated */
  33401. static readonly FOGMODE_NONE: number;
  33402. /** The fog density is following an exponential function */
  33403. static readonly FOGMODE_EXP: number;
  33404. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33405. static readonly FOGMODE_EXP2: number;
  33406. /** The fog density is following a linear function. */
  33407. static readonly FOGMODE_LINEAR: number;
  33408. /**
  33409. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33410. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33411. */
  33412. static MinDeltaTime: number;
  33413. /**
  33414. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33416. */
  33417. static MaxDeltaTime: number;
  33418. /**
  33419. * Factory used to create the default material.
  33420. * @param name The name of the material to create
  33421. * @param scene The scene to create the material for
  33422. * @returns The default material
  33423. */
  33424. static DefaultMaterialFactory(scene: Scene): Material;
  33425. /**
  33426. * Factory used to create the a collision coordinator.
  33427. * @returns The collision coordinator
  33428. */
  33429. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33430. /** @hidden */
  33431. _inputManager: InputManager;
  33432. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33433. cameraToUseForPointers: Nullable<Camera>;
  33434. /** @hidden */
  33435. readonly _isScene: boolean;
  33436. /**
  33437. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33438. */
  33439. autoClear: boolean;
  33440. /**
  33441. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33442. */
  33443. autoClearDepthAndStencil: boolean;
  33444. /**
  33445. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33446. */
  33447. clearColor: Color4;
  33448. /**
  33449. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33450. */
  33451. ambientColor: Color3;
  33452. /**
  33453. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33454. * It should only be one of the following (if not the default embedded one):
  33455. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33456. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33457. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33458. * The material properties need to be setup according to the type of texture in use.
  33459. */
  33460. environmentBRDFTexture: BaseTexture;
  33461. /** @hidden */
  33462. protected _environmentTexture: Nullable<BaseTexture>;
  33463. /**
  33464. * Texture used in all pbr material as the reflection texture.
  33465. * As in the majority of the scene they are the same (exception for multi room and so on),
  33466. * this is easier to reference from here than from all the materials.
  33467. */
  33468. /**
  33469. * Texture used in all pbr material as the reflection texture.
  33470. * As in the majority of the scene they are the same (exception for multi room and so on),
  33471. * this is easier to set here than in all the materials.
  33472. */
  33473. environmentTexture: Nullable<BaseTexture>;
  33474. /** @hidden */
  33475. protected _environmentIntensity: number;
  33476. /**
  33477. * Intensity of the environment in all pbr material.
  33478. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33479. * As in the majority of the scene they are the same (exception for multi room and so on),
  33480. * this is easier to reference from here than from all the materials.
  33481. */
  33482. /**
  33483. * Intensity of the environment in all pbr material.
  33484. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33485. * As in the majority of the scene they are the same (exception for multi room and so on),
  33486. * this is easier to set here than in all the materials.
  33487. */
  33488. environmentIntensity: number;
  33489. /** @hidden */
  33490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33491. /**
  33492. * Default image processing configuration used either in the rendering
  33493. * Forward main pass or through the imageProcessingPostProcess if present.
  33494. * As in the majority of the scene they are the same (exception for multi camera),
  33495. * this is easier to reference from here than from all the materials and post process.
  33496. *
  33497. * No setter as we it is a shared configuration, you can set the values instead.
  33498. */
  33499. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33500. private _forceWireframe;
  33501. /**
  33502. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33503. */
  33504. forceWireframe: boolean;
  33505. private _forcePointsCloud;
  33506. /**
  33507. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33508. */
  33509. forcePointsCloud: boolean;
  33510. /**
  33511. * Gets or sets the active clipplane 1
  33512. */
  33513. clipPlane: Nullable<Plane>;
  33514. /**
  33515. * Gets or sets the active clipplane 2
  33516. */
  33517. clipPlane2: Nullable<Plane>;
  33518. /**
  33519. * Gets or sets the active clipplane 3
  33520. */
  33521. clipPlane3: Nullable<Plane>;
  33522. /**
  33523. * Gets or sets the active clipplane 4
  33524. */
  33525. clipPlane4: Nullable<Plane>;
  33526. /**
  33527. * Gets or sets a boolean indicating if animations are enabled
  33528. */
  33529. animationsEnabled: boolean;
  33530. private _animationPropertiesOverride;
  33531. /**
  33532. * Gets or sets the animation properties override
  33533. */
  33534. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33535. /**
  33536. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33537. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33538. */
  33539. useConstantAnimationDeltaTime: boolean;
  33540. /**
  33541. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33542. * Please note that it requires to run a ray cast through the scene on every frame
  33543. */
  33544. constantlyUpdateMeshUnderPointer: boolean;
  33545. /**
  33546. * Defines the HTML cursor to use when hovering over interactive elements
  33547. */
  33548. hoverCursor: string;
  33549. /**
  33550. * Defines the HTML default cursor to use (empty by default)
  33551. */
  33552. defaultCursor: string;
  33553. /**
  33554. * Defines wether cursors are handled by the scene.
  33555. */
  33556. doNotHandleCursors: boolean;
  33557. /**
  33558. * This is used to call preventDefault() on pointer down
  33559. * in order to block unwanted artifacts like system double clicks
  33560. */
  33561. preventDefaultOnPointerDown: boolean;
  33562. /**
  33563. * This is used to call preventDefault() on pointer up
  33564. * in order to block unwanted artifacts like system double clicks
  33565. */
  33566. preventDefaultOnPointerUp: boolean;
  33567. /**
  33568. * Gets or sets user defined metadata
  33569. */
  33570. metadata: any;
  33571. /**
  33572. * For internal use only. Please do not use.
  33573. */
  33574. reservedDataStore: any;
  33575. /**
  33576. * Gets the name of the plugin used to load this scene (null by default)
  33577. */
  33578. loadingPluginName: string;
  33579. /**
  33580. * Use this array to add regular expressions used to disable offline support for specific urls
  33581. */
  33582. disableOfflineSupportExceptionRules: RegExp[];
  33583. /**
  33584. * An event triggered when the scene is disposed.
  33585. */
  33586. onDisposeObservable: Observable<Scene>;
  33587. private _onDisposeObserver;
  33588. /** Sets a function to be executed when this scene is disposed. */
  33589. onDispose: () => void;
  33590. /**
  33591. * An event triggered before rendering the scene (right after animations and physics)
  33592. */
  33593. onBeforeRenderObservable: Observable<Scene>;
  33594. private _onBeforeRenderObserver;
  33595. /** Sets a function to be executed before rendering this scene */
  33596. beforeRender: Nullable<() => void>;
  33597. /**
  33598. * An event triggered after rendering the scene
  33599. */
  33600. onAfterRenderObservable: Observable<Scene>;
  33601. /**
  33602. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33603. */
  33604. onAfterRenderCameraObservable: Observable<Camera>;
  33605. private _onAfterRenderObserver;
  33606. /** Sets a function to be executed after rendering this scene */
  33607. afterRender: Nullable<() => void>;
  33608. /**
  33609. * An event triggered before animating the scene
  33610. */
  33611. onBeforeAnimationsObservable: Observable<Scene>;
  33612. /**
  33613. * An event triggered after animations processing
  33614. */
  33615. onAfterAnimationsObservable: Observable<Scene>;
  33616. /**
  33617. * An event triggered before draw calls are ready to be sent
  33618. */
  33619. onBeforeDrawPhaseObservable: Observable<Scene>;
  33620. /**
  33621. * An event triggered after draw calls have been sent
  33622. */
  33623. onAfterDrawPhaseObservable: Observable<Scene>;
  33624. /**
  33625. * An event triggered when the scene is ready
  33626. */
  33627. onReadyObservable: Observable<Scene>;
  33628. /**
  33629. * An event triggered before rendering a camera
  33630. */
  33631. onBeforeCameraRenderObservable: Observable<Camera>;
  33632. private _onBeforeCameraRenderObserver;
  33633. /** Sets a function to be executed before rendering a camera*/
  33634. beforeCameraRender: () => void;
  33635. /**
  33636. * An event triggered after rendering a camera
  33637. */
  33638. onAfterCameraRenderObservable: Observable<Camera>;
  33639. private _onAfterCameraRenderObserver;
  33640. /** Sets a function to be executed after rendering a camera*/
  33641. afterCameraRender: () => void;
  33642. /**
  33643. * An event triggered when active meshes evaluation is about to start
  33644. */
  33645. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33646. /**
  33647. * An event triggered when active meshes evaluation is done
  33648. */
  33649. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33650. /**
  33651. * An event triggered when particles rendering is about to start
  33652. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33653. */
  33654. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33655. /**
  33656. * An event triggered when particles rendering is done
  33657. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33658. */
  33659. onAfterParticlesRenderingObservable: Observable<Scene>;
  33660. /**
  33661. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33662. */
  33663. onDataLoadedObservable: Observable<Scene>;
  33664. /**
  33665. * An event triggered when a camera is created
  33666. */
  33667. onNewCameraAddedObservable: Observable<Camera>;
  33668. /**
  33669. * An event triggered when a camera is removed
  33670. */
  33671. onCameraRemovedObservable: Observable<Camera>;
  33672. /**
  33673. * An event triggered when a light is created
  33674. */
  33675. onNewLightAddedObservable: Observable<Light>;
  33676. /**
  33677. * An event triggered when a light is removed
  33678. */
  33679. onLightRemovedObservable: Observable<Light>;
  33680. /**
  33681. * An event triggered when a geometry is created
  33682. */
  33683. onNewGeometryAddedObservable: Observable<Geometry>;
  33684. /**
  33685. * An event triggered when a geometry is removed
  33686. */
  33687. onGeometryRemovedObservable: Observable<Geometry>;
  33688. /**
  33689. * An event triggered when a transform node is created
  33690. */
  33691. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33692. /**
  33693. * An event triggered when a transform node is removed
  33694. */
  33695. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33696. /**
  33697. * An event triggered when a mesh is created
  33698. */
  33699. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33700. /**
  33701. * An event triggered when a mesh is removed
  33702. */
  33703. onMeshRemovedObservable: Observable<AbstractMesh>;
  33704. /**
  33705. * An event triggered when a skeleton is created
  33706. */
  33707. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33708. /**
  33709. * An event triggered when a skeleton is removed
  33710. */
  33711. onSkeletonRemovedObservable: Observable<Skeleton>;
  33712. /**
  33713. * An event triggered when a material is created
  33714. */
  33715. onNewMaterialAddedObservable: Observable<Material>;
  33716. /**
  33717. * An event triggered when a material is removed
  33718. */
  33719. onMaterialRemovedObservable: Observable<Material>;
  33720. /**
  33721. * An event triggered when a texture is created
  33722. */
  33723. onNewTextureAddedObservable: Observable<BaseTexture>;
  33724. /**
  33725. * An event triggered when a texture is removed
  33726. */
  33727. onTextureRemovedObservable: Observable<BaseTexture>;
  33728. /**
  33729. * An event triggered when render targets are about to be rendered
  33730. * Can happen multiple times per frame.
  33731. */
  33732. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33733. /**
  33734. * An event triggered when render targets were rendered.
  33735. * Can happen multiple times per frame.
  33736. */
  33737. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33738. /**
  33739. * An event triggered before calculating deterministic simulation step
  33740. */
  33741. onBeforeStepObservable: Observable<Scene>;
  33742. /**
  33743. * An event triggered after calculating deterministic simulation step
  33744. */
  33745. onAfterStepObservable: Observable<Scene>;
  33746. /**
  33747. * An event triggered when the activeCamera property is updated
  33748. */
  33749. onActiveCameraChanged: Observable<Scene>;
  33750. /**
  33751. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33752. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33753. * 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)
  33754. */
  33755. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33756. /**
  33757. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33758. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33759. * 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)
  33760. */
  33761. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33762. /**
  33763. * This Observable will when a mesh has been imported into the scene.
  33764. */
  33765. onMeshImportedObservable: Observable<AbstractMesh>;
  33766. /**
  33767. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33768. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33769. */
  33770. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33771. /** @hidden */
  33772. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33773. /**
  33774. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33775. */
  33776. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33777. /**
  33778. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33779. */
  33780. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33781. /**
  33782. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33783. */
  33784. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33785. /** Callback called when a pointer move is detected */
  33786. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33787. /** Callback called when a pointer down is detected */
  33788. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33789. /** Callback called when a pointer up is detected */
  33790. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33791. /** Callback called when a pointer pick is detected */
  33792. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33793. /**
  33794. * 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).
  33795. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33796. */
  33797. onPrePointerObservable: Observable<PointerInfoPre>;
  33798. /**
  33799. * Observable event triggered each time an input event is received from the rendering canvas
  33800. */
  33801. onPointerObservable: Observable<PointerInfo>;
  33802. /**
  33803. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33804. */
  33805. readonly unTranslatedPointer: Vector2;
  33806. /**
  33807. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33808. */
  33809. static DragMovementThreshold: number;
  33810. /**
  33811. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33812. */
  33813. static LongPressDelay: number;
  33814. /**
  33815. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33816. */
  33817. static DoubleClickDelay: number;
  33818. /** If you need to check double click without raising a single click at first click, enable this flag */
  33819. static ExclusiveDoubleClickMode: boolean;
  33820. /** @hidden */
  33821. _mirroredCameraPosition: Nullable<Vector3>;
  33822. /**
  33823. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33824. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33825. */
  33826. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33827. /**
  33828. * Observable event triggered each time an keyboard event is received from the hosting window
  33829. */
  33830. onKeyboardObservable: Observable<KeyboardInfo>;
  33831. private _useRightHandedSystem;
  33832. /**
  33833. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33834. */
  33835. useRightHandedSystem: boolean;
  33836. private _timeAccumulator;
  33837. private _currentStepId;
  33838. private _currentInternalStep;
  33839. /**
  33840. * Sets the step Id used by deterministic lock step
  33841. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33842. * @param newStepId defines the step Id
  33843. */
  33844. setStepId(newStepId: number): void;
  33845. /**
  33846. * Gets the step Id used by deterministic lock step
  33847. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33848. * @returns the step Id
  33849. */
  33850. getStepId(): number;
  33851. /**
  33852. * Gets the internal step used by deterministic lock step
  33853. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33854. * @returns the internal step
  33855. */
  33856. getInternalStep(): number;
  33857. private _fogEnabled;
  33858. /**
  33859. * Gets or sets a boolean indicating if fog is enabled on this scene
  33860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33861. * (Default is true)
  33862. */
  33863. fogEnabled: boolean;
  33864. private _fogMode;
  33865. /**
  33866. * Gets or sets the fog mode to use
  33867. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33868. * | mode | value |
  33869. * | --- | --- |
  33870. * | FOGMODE_NONE | 0 |
  33871. * | FOGMODE_EXP | 1 |
  33872. * | FOGMODE_EXP2 | 2 |
  33873. * | FOGMODE_LINEAR | 3 |
  33874. */
  33875. fogMode: number;
  33876. /**
  33877. * Gets or sets the fog color to use
  33878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33879. * (Default is Color3(0.2, 0.2, 0.3))
  33880. */
  33881. fogColor: Color3;
  33882. /**
  33883. * Gets or sets the fog density to use
  33884. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33885. * (Default is 0.1)
  33886. */
  33887. fogDensity: number;
  33888. /**
  33889. * Gets or sets the fog start distance to use
  33890. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33891. * (Default is 0)
  33892. */
  33893. fogStart: number;
  33894. /**
  33895. * Gets or sets the fog end distance to use
  33896. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33897. * (Default is 1000)
  33898. */
  33899. fogEnd: number;
  33900. private _shadowsEnabled;
  33901. /**
  33902. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33903. */
  33904. shadowsEnabled: boolean;
  33905. private _lightsEnabled;
  33906. /**
  33907. * Gets or sets a boolean indicating if lights are enabled on this scene
  33908. */
  33909. lightsEnabled: boolean;
  33910. /** All of the active cameras added to this scene. */
  33911. activeCameras: Camera[];
  33912. /** @hidden */
  33913. _activeCamera: Nullable<Camera>;
  33914. /** Gets or sets the current active camera */
  33915. activeCamera: Nullable<Camera>;
  33916. private _defaultMaterial;
  33917. /** The default material used on meshes when no material is affected */
  33918. /** The default material used on meshes when no material is affected */
  33919. defaultMaterial: Material;
  33920. private _texturesEnabled;
  33921. /**
  33922. * Gets or sets a boolean indicating if textures are enabled on this scene
  33923. */
  33924. texturesEnabled: boolean;
  33925. /**
  33926. * Gets or sets a boolean indicating if particles are enabled on this scene
  33927. */
  33928. particlesEnabled: boolean;
  33929. /**
  33930. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33931. */
  33932. spritesEnabled: boolean;
  33933. private _skeletonsEnabled;
  33934. /**
  33935. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33936. */
  33937. skeletonsEnabled: boolean;
  33938. /**
  33939. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33940. */
  33941. lensFlaresEnabled: boolean;
  33942. /**
  33943. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33945. */
  33946. collisionsEnabled: boolean;
  33947. private _collisionCoordinator;
  33948. /** @hidden */
  33949. readonly collisionCoordinator: ICollisionCoordinator;
  33950. /**
  33951. * Defines the gravity applied to this scene (used only for collisions)
  33952. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33953. */
  33954. gravity: Vector3;
  33955. /**
  33956. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33957. */
  33958. postProcessesEnabled: boolean;
  33959. /**
  33960. * The list of postprocesses added to the scene
  33961. */
  33962. postProcesses: PostProcess[];
  33963. /**
  33964. * Gets the current postprocess manager
  33965. */
  33966. postProcessManager: PostProcessManager;
  33967. /**
  33968. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33969. */
  33970. renderTargetsEnabled: boolean;
  33971. /**
  33972. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33973. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33974. */
  33975. dumpNextRenderTargets: boolean;
  33976. /**
  33977. * The list of user defined render targets added to the scene
  33978. */
  33979. customRenderTargets: RenderTargetTexture[];
  33980. /**
  33981. * Defines if texture loading must be delayed
  33982. * If true, textures will only be loaded when they need to be rendered
  33983. */
  33984. useDelayedTextureLoading: boolean;
  33985. /**
  33986. * Gets the list of meshes imported to the scene through SceneLoader
  33987. */
  33988. importedMeshesFiles: String[];
  33989. /**
  33990. * Gets or sets a boolean indicating if probes are enabled on this scene
  33991. */
  33992. probesEnabled: boolean;
  33993. /**
  33994. * Gets or sets the current offline provider to use to store scene data
  33995. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33996. */
  33997. offlineProvider: IOfflineProvider;
  33998. /**
  33999. * Gets or sets the action manager associated with the scene
  34000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34001. */
  34002. actionManager: AbstractActionManager;
  34003. private _meshesForIntersections;
  34004. /**
  34005. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34006. */
  34007. proceduralTexturesEnabled: boolean;
  34008. private _engine;
  34009. private _totalVertices;
  34010. /** @hidden */
  34011. _activeIndices: PerfCounter;
  34012. /** @hidden */
  34013. _activeParticles: PerfCounter;
  34014. /** @hidden */
  34015. _activeBones: PerfCounter;
  34016. private _animationRatio;
  34017. /** @hidden */
  34018. _animationTimeLast: number;
  34019. /** @hidden */
  34020. _animationTime: number;
  34021. /**
  34022. * Gets or sets a general scale for animation speed
  34023. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34024. */
  34025. animationTimeScale: number;
  34026. /** @hidden */
  34027. _cachedMaterial: Nullable<Material>;
  34028. /** @hidden */
  34029. _cachedEffect: Nullable<Effect>;
  34030. /** @hidden */
  34031. _cachedVisibility: Nullable<number>;
  34032. private _renderId;
  34033. private _frameId;
  34034. private _executeWhenReadyTimeoutId;
  34035. private _intermediateRendering;
  34036. private _viewUpdateFlag;
  34037. private _projectionUpdateFlag;
  34038. /** @hidden */
  34039. _toBeDisposed: Nullable<IDisposable>[];
  34040. private _activeRequests;
  34041. /** @hidden */
  34042. _pendingData: any[];
  34043. private _isDisposed;
  34044. /**
  34045. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34046. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34047. */
  34048. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34049. private _activeMeshes;
  34050. private _processedMaterials;
  34051. private _renderTargets;
  34052. /** @hidden */
  34053. _activeParticleSystems: SmartArray<IParticleSystem>;
  34054. private _activeSkeletons;
  34055. private _softwareSkinnedMeshes;
  34056. private _renderingManager;
  34057. /** @hidden */
  34058. _activeAnimatables: Animatable[];
  34059. private _transformMatrix;
  34060. private _sceneUbo;
  34061. /** @hidden */
  34062. _viewMatrix: Matrix;
  34063. private _projectionMatrix;
  34064. /** @hidden */
  34065. _forcedViewPosition: Nullable<Vector3>;
  34066. /** @hidden */
  34067. _frustumPlanes: Plane[];
  34068. /**
  34069. * Gets the list of frustum planes (built from the active camera)
  34070. */
  34071. readonly frustumPlanes: Plane[];
  34072. /**
  34073. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34074. * This is useful if there are more lights that the maximum simulteanous authorized
  34075. */
  34076. requireLightSorting: boolean;
  34077. /** @hidden */
  34078. readonly useMaterialMeshMap: boolean;
  34079. /** @hidden */
  34080. readonly useClonedMeshhMap: boolean;
  34081. private _externalData;
  34082. private _uid;
  34083. /**
  34084. * @hidden
  34085. * Backing store of defined scene components.
  34086. */
  34087. _components: ISceneComponent[];
  34088. /**
  34089. * @hidden
  34090. * Backing store of defined scene components.
  34091. */
  34092. _serializableComponents: ISceneSerializableComponent[];
  34093. /**
  34094. * List of components to register on the next registration step.
  34095. */
  34096. private _transientComponents;
  34097. /**
  34098. * Registers the transient components if needed.
  34099. */
  34100. private _registerTransientComponents;
  34101. /**
  34102. * @hidden
  34103. * Add a component to the scene.
  34104. * Note that the ccomponent could be registered on th next frame if this is called after
  34105. * the register component stage.
  34106. * @param component Defines the component to add to the scene
  34107. */
  34108. _addComponent(component: ISceneComponent): void;
  34109. /**
  34110. * @hidden
  34111. * Gets a component from the scene.
  34112. * @param name defines the name of the component to retrieve
  34113. * @returns the component or null if not present
  34114. */
  34115. _getComponent(name: string): Nullable<ISceneComponent>;
  34116. /**
  34117. * @hidden
  34118. * Defines the actions happening before camera updates.
  34119. */
  34120. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34121. /**
  34122. * @hidden
  34123. * Defines the actions happening before clear the canvas.
  34124. */
  34125. _beforeClearStage: Stage<SimpleStageAction>;
  34126. /**
  34127. * @hidden
  34128. * Defines the actions when collecting render targets for the frame.
  34129. */
  34130. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34131. /**
  34132. * @hidden
  34133. * Defines the actions happening for one camera in the frame.
  34134. */
  34135. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34136. /**
  34137. * @hidden
  34138. * Defines the actions happening during the per mesh ready checks.
  34139. */
  34140. _isReadyForMeshStage: Stage<MeshStageAction>;
  34141. /**
  34142. * @hidden
  34143. * Defines the actions happening before evaluate active mesh checks.
  34144. */
  34145. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34146. /**
  34147. * @hidden
  34148. * Defines the actions happening during the evaluate sub mesh checks.
  34149. */
  34150. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34151. /**
  34152. * @hidden
  34153. * Defines the actions happening during the active mesh stage.
  34154. */
  34155. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34156. /**
  34157. * @hidden
  34158. * Defines the actions happening during the per camera render target step.
  34159. */
  34160. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34161. /**
  34162. * @hidden
  34163. * Defines the actions happening just before the active camera is drawing.
  34164. */
  34165. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34166. /**
  34167. * @hidden
  34168. * Defines the actions happening just before a render target is drawing.
  34169. */
  34170. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34171. /**
  34172. * @hidden
  34173. * Defines the actions happening just before a rendering group is drawing.
  34174. */
  34175. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34176. /**
  34177. * @hidden
  34178. * Defines the actions happening just before a mesh is drawing.
  34179. */
  34180. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34181. /**
  34182. * @hidden
  34183. * Defines the actions happening just after a mesh has been drawn.
  34184. */
  34185. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34186. /**
  34187. * @hidden
  34188. * Defines the actions happening just after a rendering group has been drawn.
  34189. */
  34190. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34191. /**
  34192. * @hidden
  34193. * Defines the actions happening just after the active camera has been drawn.
  34194. */
  34195. _afterCameraDrawStage: Stage<CameraStageAction>;
  34196. /**
  34197. * @hidden
  34198. * Defines the actions happening just after a render target has been drawn.
  34199. */
  34200. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34201. /**
  34202. * @hidden
  34203. * Defines the actions happening just after rendering all cameras and computing intersections.
  34204. */
  34205. _afterRenderStage: Stage<SimpleStageAction>;
  34206. /**
  34207. * @hidden
  34208. * Defines the actions happening when a pointer move event happens.
  34209. */
  34210. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34211. /**
  34212. * @hidden
  34213. * Defines the actions happening when a pointer down event happens.
  34214. */
  34215. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34216. /**
  34217. * @hidden
  34218. * Defines the actions happening when a pointer up event happens.
  34219. */
  34220. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34221. /**
  34222. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34223. */
  34224. private geometriesByUniqueId;
  34225. /**
  34226. * Creates a new Scene
  34227. * @param engine defines the engine to use to render this scene
  34228. * @param options defines the scene options
  34229. */
  34230. constructor(engine: Engine, options?: SceneOptions);
  34231. /**
  34232. * Gets a string idenfifying the name of the class
  34233. * @returns "Scene" string
  34234. */
  34235. getClassName(): string;
  34236. private _defaultMeshCandidates;
  34237. /**
  34238. * @hidden
  34239. */
  34240. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34241. private _defaultSubMeshCandidates;
  34242. /**
  34243. * @hidden
  34244. */
  34245. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34246. /**
  34247. * Sets the default candidate providers for the scene.
  34248. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34249. * and getCollidingSubMeshCandidates to their default function
  34250. */
  34251. setDefaultCandidateProviders(): void;
  34252. /**
  34253. * Gets the mesh that is currently under the pointer
  34254. */
  34255. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34256. /**
  34257. * Gets or sets the current on-screen X position of the pointer
  34258. */
  34259. pointerX: number;
  34260. /**
  34261. * Gets or sets the current on-screen Y position of the pointer
  34262. */
  34263. pointerY: number;
  34264. /**
  34265. * Gets the cached material (ie. the latest rendered one)
  34266. * @returns the cached material
  34267. */
  34268. getCachedMaterial(): Nullable<Material>;
  34269. /**
  34270. * Gets the cached effect (ie. the latest rendered one)
  34271. * @returns the cached effect
  34272. */
  34273. getCachedEffect(): Nullable<Effect>;
  34274. /**
  34275. * Gets the cached visibility state (ie. the latest rendered one)
  34276. * @returns the cached visibility state
  34277. */
  34278. getCachedVisibility(): Nullable<number>;
  34279. /**
  34280. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34281. * @param material defines the current material
  34282. * @param effect defines the current effect
  34283. * @param visibility defines the current visibility state
  34284. * @returns true if one parameter is not cached
  34285. */
  34286. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34287. /**
  34288. * Gets the engine associated with the scene
  34289. * @returns an Engine
  34290. */
  34291. getEngine(): Engine;
  34292. /**
  34293. * Gets the total number of vertices rendered per frame
  34294. * @returns the total number of vertices rendered per frame
  34295. */
  34296. getTotalVertices(): number;
  34297. /**
  34298. * Gets the performance counter for total vertices
  34299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34300. */
  34301. readonly totalVerticesPerfCounter: PerfCounter;
  34302. /**
  34303. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34304. * @returns the total number of active indices rendered per frame
  34305. */
  34306. getActiveIndices(): number;
  34307. /**
  34308. * Gets the performance counter for active indices
  34309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34310. */
  34311. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34312. /**
  34313. * Gets the total number of active particles rendered per frame
  34314. * @returns the total number of active particles rendered per frame
  34315. */
  34316. getActiveParticles(): number;
  34317. /**
  34318. * Gets the performance counter for active particles
  34319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34320. */
  34321. readonly activeParticlesPerfCounter: PerfCounter;
  34322. /**
  34323. * Gets the total number of active bones rendered per frame
  34324. * @returns the total number of active bones rendered per frame
  34325. */
  34326. getActiveBones(): number;
  34327. /**
  34328. * Gets the performance counter for active bones
  34329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34330. */
  34331. readonly activeBonesPerfCounter: PerfCounter;
  34332. /**
  34333. * Gets the array of active meshes
  34334. * @returns an array of AbstractMesh
  34335. */
  34336. getActiveMeshes(): SmartArray<AbstractMesh>;
  34337. /**
  34338. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34339. * @returns a number
  34340. */
  34341. getAnimationRatio(): number;
  34342. /**
  34343. * Gets an unique Id for the current render phase
  34344. * @returns a number
  34345. */
  34346. getRenderId(): number;
  34347. /**
  34348. * Gets an unique Id for the current frame
  34349. * @returns a number
  34350. */
  34351. getFrameId(): number;
  34352. /** Call this function if you want to manually increment the render Id*/
  34353. incrementRenderId(): void;
  34354. private _createUbo;
  34355. /**
  34356. * Use this method to simulate a pointer move on a mesh
  34357. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34358. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34359. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34360. * @returns the current scene
  34361. */
  34362. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34363. /**
  34364. * Use this method to simulate a pointer down on a mesh
  34365. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34366. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34367. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34368. * @returns the current scene
  34369. */
  34370. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34371. /**
  34372. * Use this method to simulate a pointer up on a mesh
  34373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34376. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34377. * @returns the current scene
  34378. */
  34379. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34380. /**
  34381. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34382. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34383. * @returns true if the pointer was captured
  34384. */
  34385. isPointerCaptured(pointerId?: number): boolean;
  34386. /**
  34387. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34388. * @param attachUp defines if you want to attach events to pointerup
  34389. * @param attachDown defines if you want to attach events to pointerdown
  34390. * @param attachMove defines if you want to attach events to pointermove
  34391. */
  34392. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34393. /** Detaches all event handlers*/
  34394. detachControl(): void;
  34395. /**
  34396. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34397. * Delay loaded resources are not taking in account
  34398. * @return true if all required resources are ready
  34399. */
  34400. isReady(): boolean;
  34401. /** Resets all cached information relative to material (including effect and visibility) */
  34402. resetCachedMaterial(): void;
  34403. /**
  34404. * Registers a function to be called before every frame render
  34405. * @param func defines the function to register
  34406. */
  34407. registerBeforeRender(func: () => void): void;
  34408. /**
  34409. * Unregisters a function called before every frame render
  34410. * @param func defines the function to unregister
  34411. */
  34412. unregisterBeforeRender(func: () => void): void;
  34413. /**
  34414. * Registers a function to be called after every frame render
  34415. * @param func defines the function to register
  34416. */
  34417. registerAfterRender(func: () => void): void;
  34418. /**
  34419. * Unregisters a function called after every frame render
  34420. * @param func defines the function to unregister
  34421. */
  34422. unregisterAfterRender(func: () => void): void;
  34423. private _executeOnceBeforeRender;
  34424. /**
  34425. * The provided function will run before render once and will be disposed afterwards.
  34426. * A timeout delay can be provided so that the function will be executed in N ms.
  34427. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34428. * @param func The function to be executed.
  34429. * @param timeout optional delay in ms
  34430. */
  34431. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34432. /** @hidden */
  34433. _addPendingData(data: any): void;
  34434. /** @hidden */
  34435. _removePendingData(data: any): void;
  34436. /**
  34437. * Returns the number of items waiting to be loaded
  34438. * @returns the number of items waiting to be loaded
  34439. */
  34440. getWaitingItemsCount(): number;
  34441. /**
  34442. * Returns a boolean indicating if the scene is still loading data
  34443. */
  34444. readonly isLoading: boolean;
  34445. /**
  34446. * Registers a function to be executed when the scene is ready
  34447. * @param {Function} func - the function to be executed
  34448. */
  34449. executeWhenReady(func: () => void): void;
  34450. /**
  34451. * Returns a promise that resolves when the scene is ready
  34452. * @returns A promise that resolves when the scene is ready
  34453. */
  34454. whenReadyAsync(): Promise<void>;
  34455. /** @hidden */
  34456. _checkIsReady(): void;
  34457. /**
  34458. * Gets all animatable attached to the scene
  34459. */
  34460. readonly animatables: Animatable[];
  34461. /**
  34462. * Resets the last animation time frame.
  34463. * Useful to override when animations start running when loading a scene for the first time.
  34464. */
  34465. resetLastAnimationTimeFrame(): void;
  34466. /**
  34467. * Gets the current view matrix
  34468. * @returns a Matrix
  34469. */
  34470. getViewMatrix(): Matrix;
  34471. /**
  34472. * Gets the current projection matrix
  34473. * @returns a Matrix
  34474. */
  34475. getProjectionMatrix(): Matrix;
  34476. /**
  34477. * Gets the current transform matrix
  34478. * @returns a Matrix made of View * Projection
  34479. */
  34480. getTransformMatrix(): Matrix;
  34481. /**
  34482. * Sets the current transform matrix
  34483. * @param viewL defines the View matrix to use
  34484. * @param projectionL defines the Projection matrix to use
  34485. * @param viewR defines the right View matrix to use (if provided)
  34486. * @param projectionR defines the right Projection matrix to use (if provided)
  34487. */
  34488. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34489. /**
  34490. * Gets the uniform buffer used to store scene data
  34491. * @returns a UniformBuffer
  34492. */
  34493. getSceneUniformBuffer(): UniformBuffer;
  34494. /**
  34495. * Gets an unique (relatively to the current scene) Id
  34496. * @returns an unique number for the scene
  34497. */
  34498. getUniqueId(): number;
  34499. /**
  34500. * Add a mesh to the list of scene's meshes
  34501. * @param newMesh defines the mesh to add
  34502. * @param recursive if all child meshes should also be added to the scene
  34503. */
  34504. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34505. /**
  34506. * Remove a mesh for the list of scene's meshes
  34507. * @param toRemove defines the mesh to remove
  34508. * @param recursive if all child meshes should also be removed from the scene
  34509. * @returns the index where the mesh was in the mesh list
  34510. */
  34511. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34512. /**
  34513. * Add a transform node to the list of scene's transform nodes
  34514. * @param newTransformNode defines the transform node to add
  34515. */
  34516. addTransformNode(newTransformNode: TransformNode): void;
  34517. /**
  34518. * Remove a transform node for the list of scene's transform nodes
  34519. * @param toRemove defines the transform node to remove
  34520. * @returns the index where the transform node was in the transform node list
  34521. */
  34522. removeTransformNode(toRemove: TransformNode): number;
  34523. /**
  34524. * Remove a skeleton for the list of scene's skeletons
  34525. * @param toRemove defines the skeleton to remove
  34526. * @returns the index where the skeleton was in the skeleton list
  34527. */
  34528. removeSkeleton(toRemove: Skeleton): number;
  34529. /**
  34530. * Remove a morph target for the list of scene's morph targets
  34531. * @param toRemove defines the morph target to remove
  34532. * @returns the index where the morph target was in the morph target list
  34533. */
  34534. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34535. /**
  34536. * Remove a light for the list of scene's lights
  34537. * @param toRemove defines the light to remove
  34538. * @returns the index where the light was in the light list
  34539. */
  34540. removeLight(toRemove: Light): number;
  34541. /**
  34542. * Remove a camera for the list of scene's cameras
  34543. * @param toRemove defines the camera to remove
  34544. * @returns the index where the camera was in the camera list
  34545. */
  34546. removeCamera(toRemove: Camera): number;
  34547. /**
  34548. * Remove a particle system for the list of scene's particle systems
  34549. * @param toRemove defines the particle system to remove
  34550. * @returns the index where the particle system was in the particle system list
  34551. */
  34552. removeParticleSystem(toRemove: IParticleSystem): number;
  34553. /**
  34554. * Remove a animation for the list of scene's animations
  34555. * @param toRemove defines the animation to remove
  34556. * @returns the index where the animation was in the animation list
  34557. */
  34558. removeAnimation(toRemove: Animation): number;
  34559. /**
  34560. * Will stop the animation of the given target
  34561. * @param target - the target
  34562. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34563. * @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)
  34564. */
  34565. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34566. /**
  34567. * Removes the given animation group from this scene.
  34568. * @param toRemove The animation group to remove
  34569. * @returns The index of the removed animation group
  34570. */
  34571. removeAnimationGroup(toRemove: AnimationGroup): number;
  34572. /**
  34573. * Removes the given multi-material from this scene.
  34574. * @param toRemove The multi-material to remove
  34575. * @returns The index of the removed multi-material
  34576. */
  34577. removeMultiMaterial(toRemove: MultiMaterial): number;
  34578. /**
  34579. * Removes the given material from this scene.
  34580. * @param toRemove The material to remove
  34581. * @returns The index of the removed material
  34582. */
  34583. removeMaterial(toRemove: Material): number;
  34584. /**
  34585. * Removes the given action manager from this scene.
  34586. * @param toRemove The action manager to remove
  34587. * @returns The index of the removed action manager
  34588. */
  34589. removeActionManager(toRemove: AbstractActionManager): number;
  34590. /**
  34591. * Removes the given texture from this scene.
  34592. * @param toRemove The texture to remove
  34593. * @returns The index of the removed texture
  34594. */
  34595. removeTexture(toRemove: BaseTexture): number;
  34596. /**
  34597. * Adds the given light to this scene
  34598. * @param newLight The light to add
  34599. */
  34600. addLight(newLight: Light): void;
  34601. /**
  34602. * Sorts the list list based on light priorities
  34603. */
  34604. sortLightsByPriority(): void;
  34605. /**
  34606. * Adds the given camera to this scene
  34607. * @param newCamera The camera to add
  34608. */
  34609. addCamera(newCamera: Camera): void;
  34610. /**
  34611. * Adds the given skeleton to this scene
  34612. * @param newSkeleton The skeleton to add
  34613. */
  34614. addSkeleton(newSkeleton: Skeleton): void;
  34615. /**
  34616. * Adds the given particle system to this scene
  34617. * @param newParticleSystem The particle system to add
  34618. */
  34619. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34620. /**
  34621. * Adds the given animation to this scene
  34622. * @param newAnimation The animation to add
  34623. */
  34624. addAnimation(newAnimation: Animation): void;
  34625. /**
  34626. * Adds the given animation group to this scene.
  34627. * @param newAnimationGroup The animation group to add
  34628. */
  34629. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34630. /**
  34631. * Adds the given multi-material to this scene
  34632. * @param newMultiMaterial The multi-material to add
  34633. */
  34634. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34635. /**
  34636. * Adds the given material to this scene
  34637. * @param newMaterial The material to add
  34638. */
  34639. addMaterial(newMaterial: Material): void;
  34640. /**
  34641. * Adds the given morph target to this scene
  34642. * @param newMorphTargetManager The morph target to add
  34643. */
  34644. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34645. /**
  34646. * Adds the given geometry to this scene
  34647. * @param newGeometry The geometry to add
  34648. */
  34649. addGeometry(newGeometry: Geometry): void;
  34650. /**
  34651. * Adds the given action manager to this scene
  34652. * @param newActionManager The action manager to add
  34653. */
  34654. addActionManager(newActionManager: AbstractActionManager): void;
  34655. /**
  34656. * Adds the given texture to this scene.
  34657. * @param newTexture The texture to add
  34658. */
  34659. addTexture(newTexture: BaseTexture): void;
  34660. /**
  34661. * Switch active camera
  34662. * @param newCamera defines the new active camera
  34663. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34664. */
  34665. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34666. /**
  34667. * sets the active camera of the scene using its ID
  34668. * @param id defines the camera's ID
  34669. * @return the new active camera or null if none found.
  34670. */
  34671. setActiveCameraByID(id: string): Nullable<Camera>;
  34672. /**
  34673. * sets the active camera of the scene using its name
  34674. * @param name defines the camera's name
  34675. * @returns the new active camera or null if none found.
  34676. */
  34677. setActiveCameraByName(name: string): Nullable<Camera>;
  34678. /**
  34679. * get an animation group using its name
  34680. * @param name defines the material's name
  34681. * @return the animation group or null if none found.
  34682. */
  34683. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34684. /**
  34685. * Get a material using its unique id
  34686. * @param uniqueId defines the material's unique id
  34687. * @return the material or null if none found.
  34688. */
  34689. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34690. /**
  34691. * get a material using its id
  34692. * @param id defines the material's ID
  34693. * @return the material or null if none found.
  34694. */
  34695. getMaterialByID(id: string): Nullable<Material>;
  34696. /**
  34697. * Gets a the last added material using a given id
  34698. * @param id defines the material's ID
  34699. * @return the last material with the given id or null if none found.
  34700. */
  34701. getLastMaterialByID(id: string): Nullable<Material>;
  34702. /**
  34703. * Gets a material using its name
  34704. * @param name defines the material's name
  34705. * @return the material or null if none found.
  34706. */
  34707. getMaterialByName(name: string): Nullable<Material>;
  34708. /**
  34709. * Get a texture using its unique id
  34710. * @param uniqueId defines the texture's unique id
  34711. * @return the texture or null if none found.
  34712. */
  34713. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34714. /**
  34715. * Gets a camera using its id
  34716. * @param id defines the id to look for
  34717. * @returns the camera or null if not found
  34718. */
  34719. getCameraByID(id: string): Nullable<Camera>;
  34720. /**
  34721. * Gets a camera using its unique id
  34722. * @param uniqueId defines the unique id to look for
  34723. * @returns the camera or null if not found
  34724. */
  34725. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34726. /**
  34727. * Gets a camera using its name
  34728. * @param name defines the camera's name
  34729. * @return the camera or null if none found.
  34730. */
  34731. getCameraByName(name: string): Nullable<Camera>;
  34732. /**
  34733. * Gets a bone using its id
  34734. * @param id defines the bone's id
  34735. * @return the bone or null if not found
  34736. */
  34737. getBoneByID(id: string): Nullable<Bone>;
  34738. /**
  34739. * Gets a bone using its id
  34740. * @param name defines the bone's name
  34741. * @return the bone or null if not found
  34742. */
  34743. getBoneByName(name: string): Nullable<Bone>;
  34744. /**
  34745. * Gets a light node using its name
  34746. * @param name defines the the light's name
  34747. * @return the light or null if none found.
  34748. */
  34749. getLightByName(name: string): Nullable<Light>;
  34750. /**
  34751. * Gets a light node using its id
  34752. * @param id defines the light's id
  34753. * @return the light or null if none found.
  34754. */
  34755. getLightByID(id: string): Nullable<Light>;
  34756. /**
  34757. * Gets a light node using its scene-generated unique ID
  34758. * @param uniqueId defines the light's unique id
  34759. * @return the light or null if none found.
  34760. */
  34761. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34762. /**
  34763. * Gets a particle system by id
  34764. * @param id defines the particle system id
  34765. * @return the corresponding system or null if none found
  34766. */
  34767. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34768. /**
  34769. * Gets a geometry using its ID
  34770. * @param id defines the geometry's id
  34771. * @return the geometry or null if none found.
  34772. */
  34773. getGeometryByID(id: string): Nullable<Geometry>;
  34774. private _getGeometryByUniqueID;
  34775. /**
  34776. * Add a new geometry to this scene
  34777. * @param geometry defines the geometry to be added to the scene.
  34778. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34779. * @return a boolean defining if the geometry was added or not
  34780. */
  34781. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34782. /**
  34783. * Removes an existing geometry
  34784. * @param geometry defines the geometry to be removed from the scene
  34785. * @return a boolean defining if the geometry was removed or not
  34786. */
  34787. removeGeometry(geometry: Geometry): boolean;
  34788. /**
  34789. * Gets the list of geometries attached to the scene
  34790. * @returns an array of Geometry
  34791. */
  34792. getGeometries(): Geometry[];
  34793. /**
  34794. * Gets the first added mesh found of a given ID
  34795. * @param id defines the id to search for
  34796. * @return the mesh found or null if not found at all
  34797. */
  34798. getMeshByID(id: string): Nullable<AbstractMesh>;
  34799. /**
  34800. * Gets a list of meshes using their id
  34801. * @param id defines the id to search for
  34802. * @returns a list of meshes
  34803. */
  34804. getMeshesByID(id: string): Array<AbstractMesh>;
  34805. /**
  34806. * Gets the first added transform node found of a given ID
  34807. * @param id defines the id to search for
  34808. * @return the found transform node or null if not found at all.
  34809. */
  34810. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34811. /**
  34812. * Gets a transform node with its auto-generated unique id
  34813. * @param uniqueId efines the unique id to search for
  34814. * @return the found transform node or null if not found at all.
  34815. */
  34816. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34817. /**
  34818. * Gets a list of transform nodes using their id
  34819. * @param id defines the id to search for
  34820. * @returns a list of transform nodes
  34821. */
  34822. getTransformNodesByID(id: string): Array<TransformNode>;
  34823. /**
  34824. * Gets a mesh with its auto-generated unique id
  34825. * @param uniqueId defines the unique id to search for
  34826. * @return the found mesh or null if not found at all.
  34827. */
  34828. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34829. /**
  34830. * Gets a the last added mesh using a given id
  34831. * @param id defines the id to search for
  34832. * @return the found mesh or null if not found at all.
  34833. */
  34834. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34835. /**
  34836. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34837. * @param id defines the id to search for
  34838. * @return the found node or null if not found at all
  34839. */
  34840. getLastEntryByID(id: string): Nullable<Node>;
  34841. /**
  34842. * Gets a node (Mesh, Camera, Light) using a given id
  34843. * @param id defines the id to search for
  34844. * @return the found node or null if not found at all
  34845. */
  34846. getNodeByID(id: string): Nullable<Node>;
  34847. /**
  34848. * Gets a node (Mesh, Camera, Light) using a given name
  34849. * @param name defines the name to search for
  34850. * @return the found node or null if not found at all.
  34851. */
  34852. getNodeByName(name: string): Nullable<Node>;
  34853. /**
  34854. * Gets a mesh using a given name
  34855. * @param name defines the name to search for
  34856. * @return the found mesh or null if not found at all.
  34857. */
  34858. getMeshByName(name: string): Nullable<AbstractMesh>;
  34859. /**
  34860. * Gets a transform node using a given name
  34861. * @param name defines the name to search for
  34862. * @return the found transform node or null if not found at all.
  34863. */
  34864. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34865. /**
  34866. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34867. * @param id defines the id to search for
  34868. * @return the found skeleton or null if not found at all.
  34869. */
  34870. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34871. /**
  34872. * Gets a skeleton using a given auto generated unique id
  34873. * @param uniqueId defines the unique id to search for
  34874. * @return the found skeleton or null if not found at all.
  34875. */
  34876. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34877. /**
  34878. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34879. * @param id defines the id to search for
  34880. * @return the found skeleton or null if not found at all.
  34881. */
  34882. getSkeletonById(id: string): Nullable<Skeleton>;
  34883. /**
  34884. * Gets a skeleton using a given name
  34885. * @param name defines the name to search for
  34886. * @return the found skeleton or null if not found at all.
  34887. */
  34888. getSkeletonByName(name: string): Nullable<Skeleton>;
  34889. /**
  34890. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34891. * @param id defines the id to search for
  34892. * @return the found morph target manager or null if not found at all.
  34893. */
  34894. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34895. /**
  34896. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34897. * @param id defines the id to search for
  34898. * @return the found morph target or null if not found at all.
  34899. */
  34900. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34901. /**
  34902. * Gets a boolean indicating if the given mesh is active
  34903. * @param mesh defines the mesh to look for
  34904. * @returns true if the mesh is in the active list
  34905. */
  34906. isActiveMesh(mesh: AbstractMesh): boolean;
  34907. /**
  34908. * Return a unique id as a string which can serve as an identifier for the scene
  34909. */
  34910. readonly uid: string;
  34911. /**
  34912. * Add an externaly attached data from its key.
  34913. * This method call will fail and return false, if such key already exists.
  34914. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34915. * @param key the unique key that identifies the data
  34916. * @param data the data object to associate to the key for this Engine instance
  34917. * @return true if no such key were already present and the data was added successfully, false otherwise
  34918. */
  34919. addExternalData<T>(key: string, data: T): boolean;
  34920. /**
  34921. * Get an externaly attached data from its key
  34922. * @param key the unique key that identifies the data
  34923. * @return the associated data, if present (can be null), or undefined if not present
  34924. */
  34925. getExternalData<T>(key: string): Nullable<T>;
  34926. /**
  34927. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34928. * @param key the unique key that identifies the data
  34929. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34930. * @return the associated data, can be null if the factory returned null.
  34931. */
  34932. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34933. /**
  34934. * Remove an externaly attached data from the Engine instance
  34935. * @param key the unique key that identifies the data
  34936. * @return true if the data was successfully removed, false if it doesn't exist
  34937. */
  34938. removeExternalData(key: string): boolean;
  34939. private _evaluateSubMesh;
  34940. /**
  34941. * Clear the processed materials smart array preventing retention point in material dispose.
  34942. */
  34943. freeProcessedMaterials(): void;
  34944. private _preventFreeActiveMeshesAndRenderingGroups;
  34945. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34946. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34947. * when disposing several meshes in a row or a hierarchy of meshes.
  34948. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34949. */
  34950. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34951. /**
  34952. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34953. */
  34954. freeActiveMeshes(): void;
  34955. /**
  34956. * Clear the info related to rendering groups preventing retention points during dispose.
  34957. */
  34958. freeRenderingGroups(): void;
  34959. /** @hidden */
  34960. _isInIntermediateRendering(): boolean;
  34961. /**
  34962. * Lambda returning the list of potentially active meshes.
  34963. */
  34964. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34965. /**
  34966. * Lambda returning the list of potentially active sub meshes.
  34967. */
  34968. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34969. /**
  34970. * Lambda returning the list of potentially intersecting sub meshes.
  34971. */
  34972. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34973. /**
  34974. * Lambda returning the list of potentially colliding sub meshes.
  34975. */
  34976. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34977. private _activeMeshesFrozen;
  34978. private _skipEvaluateActiveMeshesCompletely;
  34979. /**
  34980. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34981. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  34982. * @returns the current scene
  34983. */
  34984. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  34985. /**
  34986. * Use this function to restart evaluating active meshes on every frame
  34987. * @returns the current scene
  34988. */
  34989. unfreezeActiveMeshes(): Scene;
  34990. private _evaluateActiveMeshes;
  34991. private _activeMesh;
  34992. /**
  34993. * Update the transform matrix to update from the current active camera
  34994. * @param force defines a boolean used to force the update even if cache is up to date
  34995. */
  34996. updateTransformMatrix(force?: boolean): void;
  34997. private _bindFrameBuffer;
  34998. /** @hidden */
  34999. _allowPostProcessClearColor: boolean;
  35000. /** @hidden */
  35001. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35002. private _processSubCameras;
  35003. private _checkIntersections;
  35004. /** @hidden */
  35005. _advancePhysicsEngineStep(step: number): void;
  35006. /**
  35007. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35008. */
  35009. getDeterministicFrameTime: () => number;
  35010. /** @hidden */
  35011. _animate(): void;
  35012. /** Execute all animations (for a frame) */
  35013. animate(): void;
  35014. /**
  35015. * Render the scene
  35016. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35017. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35018. */
  35019. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35020. /**
  35021. * Freeze all materials
  35022. * A frozen material will not be updatable but should be faster to render
  35023. */
  35024. freezeMaterials(): void;
  35025. /**
  35026. * Unfreeze all materials
  35027. * A frozen material will not be updatable but should be faster to render
  35028. */
  35029. unfreezeMaterials(): void;
  35030. /**
  35031. * Releases all held ressources
  35032. */
  35033. dispose(): void;
  35034. /**
  35035. * Gets if the scene is already disposed
  35036. */
  35037. readonly isDisposed: boolean;
  35038. /**
  35039. * Call this function to reduce memory footprint of the scene.
  35040. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35041. */
  35042. clearCachedVertexData(): void;
  35043. /**
  35044. * This function will remove the local cached buffer data from texture.
  35045. * It will save memory but will prevent the texture from being rebuilt
  35046. */
  35047. cleanCachedTextureBuffer(): void;
  35048. /**
  35049. * Get the world extend vectors with an optional filter
  35050. *
  35051. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35052. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35053. */
  35054. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35055. min: Vector3;
  35056. max: Vector3;
  35057. };
  35058. /**
  35059. * Creates a ray that can be used to pick in the scene
  35060. * @param x defines the x coordinate of the origin (on-screen)
  35061. * @param y defines the y coordinate of the origin (on-screen)
  35062. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35063. * @param camera defines the camera to use for the picking
  35064. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35065. * @returns a Ray
  35066. */
  35067. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35068. /**
  35069. * Creates a ray that can be used to pick in the scene
  35070. * @param x defines the x coordinate of the origin (on-screen)
  35071. * @param y defines the y coordinate of the origin (on-screen)
  35072. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35073. * @param result defines the ray where to store the picking ray
  35074. * @param camera defines the camera to use for the picking
  35075. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35076. * @returns the current scene
  35077. */
  35078. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35079. /**
  35080. * Creates a ray that can be used to pick in the scene
  35081. * @param x defines the x coordinate of the origin (on-screen)
  35082. * @param y defines the y coordinate of the origin (on-screen)
  35083. * @param camera defines the camera to use for the picking
  35084. * @returns a Ray
  35085. */
  35086. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35087. /**
  35088. * Creates a ray that can be used to pick in the scene
  35089. * @param x defines the x coordinate of the origin (on-screen)
  35090. * @param y defines the y coordinate of the origin (on-screen)
  35091. * @param result defines the ray where to store the picking ray
  35092. * @param camera defines the camera to use for the picking
  35093. * @returns the current scene
  35094. */
  35095. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35096. /** Launch a ray to try to pick a mesh in the scene
  35097. * @param x position on screen
  35098. * @param y position on screen
  35099. * @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
  35100. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35101. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35103. * @returns a PickingInfo
  35104. */
  35105. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35106. /** Use the given ray to pick a mesh in the scene
  35107. * @param ray The ray to use to pick meshes
  35108. * @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
  35109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35111. * @returns a PickingInfo
  35112. */
  35113. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35114. /**
  35115. * Launch a ray to try to pick a mesh in the scene
  35116. * @param x X position on screen
  35117. * @param y Y position on screen
  35118. * @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
  35119. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35120. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35121. * @returns an array of PickingInfo
  35122. */
  35123. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35124. /**
  35125. * Launch a ray to try to pick a mesh in the scene
  35126. * @param ray Ray to use
  35127. * @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
  35128. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35129. * @returns an array of PickingInfo
  35130. */
  35131. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35132. /**
  35133. * Force the value of meshUnderPointer
  35134. * @param mesh defines the mesh to use
  35135. */
  35136. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35137. /**
  35138. * Gets the mesh under the pointer
  35139. * @returns a Mesh or null if no mesh is under the pointer
  35140. */
  35141. getPointerOverMesh(): Nullable<AbstractMesh>;
  35142. /** @hidden */
  35143. _rebuildGeometries(): void;
  35144. /** @hidden */
  35145. _rebuildTextures(): void;
  35146. private _getByTags;
  35147. /**
  35148. * Get a list of meshes by tags
  35149. * @param tagsQuery defines the tags query to use
  35150. * @param forEach defines a predicate used to filter results
  35151. * @returns an array of Mesh
  35152. */
  35153. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35154. /**
  35155. * Get a list of cameras by tags
  35156. * @param tagsQuery defines the tags query to use
  35157. * @param forEach defines a predicate used to filter results
  35158. * @returns an array of Camera
  35159. */
  35160. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35161. /**
  35162. * Get a list of lights by tags
  35163. * @param tagsQuery defines the tags query to use
  35164. * @param forEach defines a predicate used to filter results
  35165. * @returns an array of Light
  35166. */
  35167. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35168. /**
  35169. * Get a list of materials by tags
  35170. * @param tagsQuery defines the tags query to use
  35171. * @param forEach defines a predicate used to filter results
  35172. * @returns an array of Material
  35173. */
  35174. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35175. /**
  35176. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35177. * This allowed control for front to back rendering or reversly depending of the special needs.
  35178. *
  35179. * @param renderingGroupId The rendering group id corresponding to its index
  35180. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35181. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35182. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35183. */
  35184. 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;
  35185. /**
  35186. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35187. *
  35188. * @param renderingGroupId The rendering group id corresponding to its index
  35189. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35190. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35191. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35192. */
  35193. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35194. /**
  35195. * Gets the current auto clear configuration for one rendering group of the rendering
  35196. * manager.
  35197. * @param index the rendering group index to get the information for
  35198. * @returns The auto clear setup for the requested rendering group
  35199. */
  35200. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35201. private _blockMaterialDirtyMechanism;
  35202. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35203. blockMaterialDirtyMechanism: boolean;
  35204. /**
  35205. * Will flag all materials as dirty to trigger new shader compilation
  35206. * @param flag defines the flag used to specify which material part must be marked as dirty
  35207. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35208. */
  35209. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35210. /** @hidden */
  35211. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35212. /** @hidden */
  35213. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35214. /** @hidden */
  35215. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35216. /** @hidden */
  35217. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35218. /** @hidden */
  35219. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35220. /** @hidden */
  35221. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35222. }
  35223. }
  35224. declare module BABYLON {
  35225. /**
  35226. * Set of assets to keep when moving a scene into an asset container.
  35227. */
  35228. export class KeepAssets extends AbstractScene {
  35229. }
  35230. /**
  35231. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35232. */
  35233. export class InstantiatedEntries {
  35234. /**
  35235. * List of new root nodes (eg. nodes with no parent)
  35236. */
  35237. rootNodes: TransformNode[];
  35238. /**
  35239. * List of new skeletons
  35240. */
  35241. skeletons: Skeleton[];
  35242. /**
  35243. * List of new animation groups
  35244. */
  35245. animationGroups: AnimationGroup[];
  35246. }
  35247. /**
  35248. * Container with a set of assets that can be added or removed from a scene.
  35249. */
  35250. export class AssetContainer extends AbstractScene {
  35251. /**
  35252. * The scene the AssetContainer belongs to.
  35253. */
  35254. scene: Scene;
  35255. /**
  35256. * Instantiates an AssetContainer.
  35257. * @param scene The scene the AssetContainer belongs to.
  35258. */
  35259. constructor(scene: Scene);
  35260. /**
  35261. * Instantiate or clone all meshes and add the new ones to the scene.
  35262. * Skeletons and animation groups will all be cloned
  35263. * @param nameFunction defines an optional function used to get new names for clones
  35264. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35265. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35266. */
  35267. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35268. /**
  35269. * Adds all the assets from the container to the scene.
  35270. */
  35271. addAllToScene(): void;
  35272. /**
  35273. * Removes all the assets in the container from the scene
  35274. */
  35275. removeAllFromScene(): void;
  35276. /**
  35277. * Disposes all the assets in the container
  35278. */
  35279. dispose(): void;
  35280. private _moveAssets;
  35281. /**
  35282. * Removes all the assets contained in the scene and adds them to the container.
  35283. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35284. */
  35285. moveAllFromScene(keepAssets?: KeepAssets): void;
  35286. /**
  35287. * 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.
  35288. * @returns the root mesh
  35289. */
  35290. createRootMesh(): Mesh;
  35291. }
  35292. }
  35293. declare module BABYLON {
  35294. /**
  35295. * Defines how the parser contract is defined.
  35296. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35297. */
  35298. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35299. /**
  35300. * Defines how the individual parser contract is defined.
  35301. * These parser can parse an individual asset
  35302. */
  35303. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35304. /**
  35305. * Base class of the scene acting as a container for the different elements composing a scene.
  35306. * This class is dynamically extended by the different components of the scene increasing
  35307. * flexibility and reducing coupling
  35308. */
  35309. export abstract class AbstractScene {
  35310. /**
  35311. * Stores the list of available parsers in the application.
  35312. */
  35313. private static _BabylonFileParsers;
  35314. /**
  35315. * Stores the list of available individual parsers in the application.
  35316. */
  35317. private static _IndividualBabylonFileParsers;
  35318. /**
  35319. * Adds a parser in the list of available ones
  35320. * @param name Defines the name of the parser
  35321. * @param parser Defines the parser to add
  35322. */
  35323. static AddParser(name: string, parser: BabylonFileParser): void;
  35324. /**
  35325. * Gets a general parser from the list of avaialble ones
  35326. * @param name Defines the name of the parser
  35327. * @returns the requested parser or null
  35328. */
  35329. static GetParser(name: string): Nullable<BabylonFileParser>;
  35330. /**
  35331. * Adds n individual parser in the list of available ones
  35332. * @param name Defines the name of the parser
  35333. * @param parser Defines the parser to add
  35334. */
  35335. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35336. /**
  35337. * Gets an individual parser from the list of avaialble ones
  35338. * @param name Defines the name of the parser
  35339. * @returns the requested parser or null
  35340. */
  35341. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35342. /**
  35343. * Parser json data and populate both a scene and its associated container object
  35344. * @param jsonData Defines the data to parse
  35345. * @param scene Defines the scene to parse the data for
  35346. * @param container Defines the container attached to the parsing sequence
  35347. * @param rootUrl Defines the root url of the data
  35348. */
  35349. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35350. /**
  35351. * Gets the list of root nodes (ie. nodes with no parent)
  35352. */
  35353. rootNodes: Node[];
  35354. /** All of the cameras added to this scene
  35355. * @see http://doc.babylonjs.com/babylon101/cameras
  35356. */
  35357. cameras: Camera[];
  35358. /**
  35359. * All of the lights added to this scene
  35360. * @see http://doc.babylonjs.com/babylon101/lights
  35361. */
  35362. lights: Light[];
  35363. /**
  35364. * All of the (abstract) meshes added to this scene
  35365. */
  35366. meshes: AbstractMesh[];
  35367. /**
  35368. * The list of skeletons added to the scene
  35369. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35370. */
  35371. skeletons: Skeleton[];
  35372. /**
  35373. * All of the particle systems added to this scene
  35374. * @see http://doc.babylonjs.com/babylon101/particles
  35375. */
  35376. particleSystems: IParticleSystem[];
  35377. /**
  35378. * Gets a list of Animations associated with the scene
  35379. */
  35380. animations: Animation[];
  35381. /**
  35382. * All of the animation groups added to this scene
  35383. * @see http://doc.babylonjs.com/how_to/group
  35384. */
  35385. animationGroups: AnimationGroup[];
  35386. /**
  35387. * All of the multi-materials added to this scene
  35388. * @see http://doc.babylonjs.com/how_to/multi_materials
  35389. */
  35390. multiMaterials: MultiMaterial[];
  35391. /**
  35392. * All of the materials added to this scene
  35393. * In the context of a Scene, it is not supposed to be modified manually.
  35394. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35395. * Note also that the order of the Material within the array is not significant and might change.
  35396. * @see http://doc.babylonjs.com/babylon101/materials
  35397. */
  35398. materials: Material[];
  35399. /**
  35400. * The list of morph target managers added to the scene
  35401. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35402. */
  35403. morphTargetManagers: MorphTargetManager[];
  35404. /**
  35405. * The list of geometries used in the scene.
  35406. */
  35407. geometries: Geometry[];
  35408. /**
  35409. * All of the tranform nodes added to this scene
  35410. * In the context of a Scene, it is not supposed to be modified manually.
  35411. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35412. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35413. * @see http://doc.babylonjs.com/how_to/transformnode
  35414. */
  35415. transformNodes: TransformNode[];
  35416. /**
  35417. * ActionManagers available on the scene.
  35418. */
  35419. actionManagers: AbstractActionManager[];
  35420. /**
  35421. * Textures to keep.
  35422. */
  35423. textures: BaseTexture[];
  35424. /**
  35425. * Environment texture for the scene
  35426. */
  35427. environmentTexture: Nullable<BaseTexture>;
  35428. }
  35429. }
  35430. declare module BABYLON {
  35431. /**
  35432. * Interface used to define options for Sound class
  35433. */
  35434. export interface ISoundOptions {
  35435. /**
  35436. * Does the sound autoplay once loaded.
  35437. */
  35438. autoplay?: boolean;
  35439. /**
  35440. * Does the sound loop after it finishes playing once.
  35441. */
  35442. loop?: boolean;
  35443. /**
  35444. * Sound's volume
  35445. */
  35446. volume?: number;
  35447. /**
  35448. * Is it a spatial sound?
  35449. */
  35450. spatialSound?: boolean;
  35451. /**
  35452. * Maximum distance to hear that sound
  35453. */
  35454. maxDistance?: number;
  35455. /**
  35456. * Uses user defined attenuation function
  35457. */
  35458. useCustomAttenuation?: boolean;
  35459. /**
  35460. * Define the roll off factor of spatial sounds.
  35461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35462. */
  35463. rolloffFactor?: number;
  35464. /**
  35465. * Define the reference distance the sound should be heard perfectly.
  35466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35467. */
  35468. refDistance?: number;
  35469. /**
  35470. * Define the distance attenuation model the sound will follow.
  35471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35472. */
  35473. distanceModel?: string;
  35474. /**
  35475. * Defines the playback speed (1 by default)
  35476. */
  35477. playbackRate?: number;
  35478. /**
  35479. * Defines if the sound is from a streaming source
  35480. */
  35481. streaming?: boolean;
  35482. /**
  35483. * Defines an optional length (in seconds) inside the sound file
  35484. */
  35485. length?: number;
  35486. /**
  35487. * Defines an optional offset (in seconds) inside the sound file
  35488. */
  35489. offset?: number;
  35490. /**
  35491. * If true, URLs will not be required to state the audio file codec to use.
  35492. */
  35493. skipCodecCheck?: boolean;
  35494. }
  35495. /**
  35496. * Defines a sound that can be played in the application.
  35497. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35499. */
  35500. export class Sound {
  35501. /**
  35502. * The name of the sound in the scene.
  35503. */
  35504. name: string;
  35505. /**
  35506. * Does the sound autoplay once loaded.
  35507. */
  35508. autoplay: boolean;
  35509. /**
  35510. * Does the sound loop after it finishes playing once.
  35511. */
  35512. loop: boolean;
  35513. /**
  35514. * Does the sound use a custom attenuation curve to simulate the falloff
  35515. * happening when the source gets further away from the camera.
  35516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35517. */
  35518. useCustomAttenuation: boolean;
  35519. /**
  35520. * The sound track id this sound belongs to.
  35521. */
  35522. soundTrackId: number;
  35523. /**
  35524. * Is this sound currently played.
  35525. */
  35526. isPlaying: boolean;
  35527. /**
  35528. * Is this sound currently paused.
  35529. */
  35530. isPaused: boolean;
  35531. /**
  35532. * Does this sound enables spatial sound.
  35533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35534. */
  35535. spatialSound: boolean;
  35536. /**
  35537. * Define the reference distance the sound should be heard perfectly.
  35538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35539. */
  35540. refDistance: number;
  35541. /**
  35542. * Define the roll off factor of spatial sounds.
  35543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35544. */
  35545. rolloffFactor: number;
  35546. /**
  35547. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35549. */
  35550. maxDistance: number;
  35551. /**
  35552. * Define the distance attenuation model the sound will follow.
  35553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35554. */
  35555. distanceModel: string;
  35556. /**
  35557. * @hidden
  35558. * Back Compat
  35559. **/
  35560. onended: () => any;
  35561. /**
  35562. * Observable event when the current playing sound finishes.
  35563. */
  35564. onEndedObservable: Observable<Sound>;
  35565. private _panningModel;
  35566. private _playbackRate;
  35567. private _streaming;
  35568. private _startTime;
  35569. private _startOffset;
  35570. private _position;
  35571. /** @hidden */
  35572. _positionInEmitterSpace: boolean;
  35573. private _localDirection;
  35574. private _volume;
  35575. private _isReadyToPlay;
  35576. private _isDirectional;
  35577. private _readyToPlayCallback;
  35578. private _audioBuffer;
  35579. private _soundSource;
  35580. private _streamingSource;
  35581. private _soundPanner;
  35582. private _soundGain;
  35583. private _inputAudioNode;
  35584. private _outputAudioNode;
  35585. private _coneInnerAngle;
  35586. private _coneOuterAngle;
  35587. private _coneOuterGain;
  35588. private _scene;
  35589. private _connectedTransformNode;
  35590. private _customAttenuationFunction;
  35591. private _registerFunc;
  35592. private _isOutputConnected;
  35593. private _htmlAudioElement;
  35594. private _urlType;
  35595. private _length?;
  35596. private _offset?;
  35597. /** @hidden */
  35598. static _SceneComponentInitialization: (scene: Scene) => void;
  35599. /**
  35600. * Create a sound and attach it to a scene
  35601. * @param name Name of your sound
  35602. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35603. * @param scene defines the scene the sound belongs to
  35604. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35605. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35606. */
  35607. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35608. /**
  35609. * Release the sound and its associated resources
  35610. */
  35611. dispose(): void;
  35612. /**
  35613. * Gets if the sounds is ready to be played or not.
  35614. * @returns true if ready, otherwise false
  35615. */
  35616. isReady(): boolean;
  35617. private _soundLoaded;
  35618. /**
  35619. * Sets the data of the sound from an audiobuffer
  35620. * @param audioBuffer The audioBuffer containing the data
  35621. */
  35622. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35623. /**
  35624. * Updates the current sounds options such as maxdistance, loop...
  35625. * @param options A JSON object containing values named as the object properties
  35626. */
  35627. updateOptions(options: ISoundOptions): void;
  35628. private _createSpatialParameters;
  35629. private _updateSpatialParameters;
  35630. /**
  35631. * Switch the panning model to HRTF:
  35632. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35634. */
  35635. switchPanningModelToHRTF(): void;
  35636. /**
  35637. * Switch the panning model to Equal Power:
  35638. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35640. */
  35641. switchPanningModelToEqualPower(): void;
  35642. private _switchPanningModel;
  35643. /**
  35644. * Connect this sound to a sound track audio node like gain...
  35645. * @param soundTrackAudioNode the sound track audio node to connect to
  35646. */
  35647. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35648. /**
  35649. * Transform this sound into a directional source
  35650. * @param coneInnerAngle Size of the inner cone in degree
  35651. * @param coneOuterAngle Size of the outer cone in degree
  35652. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35653. */
  35654. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35655. /**
  35656. * Gets or sets the inner angle for the directional cone.
  35657. */
  35658. /**
  35659. * Gets or sets the inner angle for the directional cone.
  35660. */
  35661. directionalConeInnerAngle: number;
  35662. /**
  35663. * Gets or sets the outer angle for the directional cone.
  35664. */
  35665. /**
  35666. * Gets or sets the outer angle for the directional cone.
  35667. */
  35668. directionalConeOuterAngle: number;
  35669. /**
  35670. * Sets the position of the emitter if spatial sound is enabled
  35671. * @param newPosition Defines the new posisiton
  35672. */
  35673. setPosition(newPosition: Vector3): void;
  35674. /**
  35675. * Sets the local direction of the emitter if spatial sound is enabled
  35676. * @param newLocalDirection Defines the new local direction
  35677. */
  35678. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35679. private _updateDirection;
  35680. /** @hidden */
  35681. updateDistanceFromListener(): void;
  35682. /**
  35683. * Sets a new custom attenuation function for the sound.
  35684. * @param callback Defines the function used for the attenuation
  35685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35686. */
  35687. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35688. /**
  35689. * Play the sound
  35690. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35691. * @param offset (optional) Start the sound at a specific time in seconds
  35692. * @param length (optional) Sound duration (in seconds)
  35693. */
  35694. play(time?: number, offset?: number, length?: number): void;
  35695. private _onended;
  35696. /**
  35697. * Stop the sound
  35698. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35699. */
  35700. stop(time?: number): void;
  35701. /**
  35702. * Put the sound in pause
  35703. */
  35704. pause(): void;
  35705. /**
  35706. * Sets a dedicated volume for this sounds
  35707. * @param newVolume Define the new volume of the sound
  35708. * @param time Define time for gradual change to new volume
  35709. */
  35710. setVolume(newVolume: number, time?: number): void;
  35711. /**
  35712. * Set the sound play back rate
  35713. * @param newPlaybackRate Define the playback rate the sound should be played at
  35714. */
  35715. setPlaybackRate(newPlaybackRate: number): void;
  35716. /**
  35717. * Gets the volume of the sound.
  35718. * @returns the volume of the sound
  35719. */
  35720. getVolume(): number;
  35721. /**
  35722. * Attach the sound to a dedicated mesh
  35723. * @param transformNode The transform node to connect the sound with
  35724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35725. */
  35726. attachToMesh(transformNode: TransformNode): void;
  35727. /**
  35728. * Detach the sound from the previously attached mesh
  35729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35730. */
  35731. detachFromMesh(): void;
  35732. private _onRegisterAfterWorldMatrixUpdate;
  35733. /**
  35734. * Clone the current sound in the scene.
  35735. * @returns the new sound clone
  35736. */
  35737. clone(): Nullable<Sound>;
  35738. /**
  35739. * Gets the current underlying audio buffer containing the data
  35740. * @returns the audio buffer
  35741. */
  35742. getAudioBuffer(): Nullable<AudioBuffer>;
  35743. /**
  35744. * Serializes the Sound in a JSON representation
  35745. * @returns the JSON representation of the sound
  35746. */
  35747. serialize(): any;
  35748. /**
  35749. * Parse a JSON representation of a sound to innstantiate in a given scene
  35750. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35751. * @param scene Define the scene the new parsed sound should be created in
  35752. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35753. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35754. * @returns the newly parsed sound
  35755. */
  35756. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35757. }
  35758. }
  35759. declare module BABYLON {
  35760. /**
  35761. * This defines an action helpful to play a defined sound on a triggered action.
  35762. */
  35763. export class PlaySoundAction extends Action {
  35764. private _sound;
  35765. /**
  35766. * Instantiate the action
  35767. * @param triggerOptions defines the trigger options
  35768. * @param sound defines the sound to play
  35769. * @param condition defines the trigger related conditions
  35770. */
  35771. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35772. /** @hidden */
  35773. _prepare(): void;
  35774. /**
  35775. * Execute the action and play the sound.
  35776. */
  35777. execute(): void;
  35778. /**
  35779. * Serializes the actions and its related information.
  35780. * @param parent defines the object to serialize in
  35781. * @returns the serialized object
  35782. */
  35783. serialize(parent: any): any;
  35784. }
  35785. /**
  35786. * This defines an action helpful to stop a defined sound on a triggered action.
  35787. */
  35788. export class StopSoundAction extends Action {
  35789. private _sound;
  35790. /**
  35791. * Instantiate the action
  35792. * @param triggerOptions defines the trigger options
  35793. * @param sound defines the sound to stop
  35794. * @param condition defines the trigger related conditions
  35795. */
  35796. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35797. /** @hidden */
  35798. _prepare(): void;
  35799. /**
  35800. * Execute the action and stop the sound.
  35801. */
  35802. execute(): void;
  35803. /**
  35804. * Serializes the actions and its related information.
  35805. * @param parent defines the object to serialize in
  35806. * @returns the serialized object
  35807. */
  35808. serialize(parent: any): any;
  35809. }
  35810. }
  35811. declare module BABYLON {
  35812. /**
  35813. * This defines an action responsible to change the value of a property
  35814. * by interpolating between its current value and the newly set one once triggered.
  35815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35816. */
  35817. export class InterpolateValueAction extends Action {
  35818. /**
  35819. * Defines the path of the property where the value should be interpolated
  35820. */
  35821. propertyPath: string;
  35822. /**
  35823. * Defines the target value at the end of the interpolation.
  35824. */
  35825. value: any;
  35826. /**
  35827. * Defines the time it will take for the property to interpolate to the value.
  35828. */
  35829. duration: number;
  35830. /**
  35831. * Defines if the other scene animations should be stopped when the action has been triggered
  35832. */
  35833. stopOtherAnimations?: boolean;
  35834. /**
  35835. * Defines a callback raised once the interpolation animation has been done.
  35836. */
  35837. onInterpolationDone?: () => void;
  35838. /**
  35839. * Observable triggered once the interpolation animation has been done.
  35840. */
  35841. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35842. private _target;
  35843. private _effectiveTarget;
  35844. private _property;
  35845. /**
  35846. * Instantiate the action
  35847. * @param triggerOptions defines the trigger options
  35848. * @param target defines the object containing the value to interpolate
  35849. * @param propertyPath defines the path to the property in the target object
  35850. * @param value defines the target value at the end of the interpolation
  35851. * @param duration deines the time it will take for the property to interpolate to the value.
  35852. * @param condition defines the trigger related conditions
  35853. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35854. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35855. */
  35856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35857. /** @hidden */
  35858. _prepare(): void;
  35859. /**
  35860. * Execute the action starts the value interpolation.
  35861. */
  35862. execute(): void;
  35863. /**
  35864. * Serializes the actions and its related information.
  35865. * @param parent defines the object to serialize in
  35866. * @returns the serialized object
  35867. */
  35868. serialize(parent: any): any;
  35869. }
  35870. }
  35871. declare module BABYLON {
  35872. /**
  35873. * Options allowed during the creation of a sound track.
  35874. */
  35875. export interface ISoundTrackOptions {
  35876. /**
  35877. * The volume the sound track should take during creation
  35878. */
  35879. volume?: number;
  35880. /**
  35881. * Define if the sound track is the main sound track of the scene
  35882. */
  35883. mainTrack?: boolean;
  35884. }
  35885. /**
  35886. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35887. * It will be also used in a future release to apply effects on a specific track.
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35889. */
  35890. export class SoundTrack {
  35891. /**
  35892. * The unique identifier of the sound track in the scene.
  35893. */
  35894. id: number;
  35895. /**
  35896. * The list of sounds included in the sound track.
  35897. */
  35898. soundCollection: Array<Sound>;
  35899. private _outputAudioNode;
  35900. private _scene;
  35901. private _connectedAnalyser;
  35902. private _options;
  35903. private _isInitialized;
  35904. /**
  35905. * Creates a new sound track.
  35906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35907. * @param scene Define the scene the sound track belongs to
  35908. * @param options
  35909. */
  35910. constructor(scene: Scene, options?: ISoundTrackOptions);
  35911. private _initializeSoundTrackAudioGraph;
  35912. /**
  35913. * Release the sound track and its associated resources
  35914. */
  35915. dispose(): void;
  35916. /**
  35917. * Adds a sound to this sound track
  35918. * @param sound define the cound to add
  35919. * @ignoreNaming
  35920. */
  35921. AddSound(sound: Sound): void;
  35922. /**
  35923. * Removes a sound to this sound track
  35924. * @param sound define the cound to remove
  35925. * @ignoreNaming
  35926. */
  35927. RemoveSound(sound: Sound): void;
  35928. /**
  35929. * Set a global volume for the full sound track.
  35930. * @param newVolume Define the new volume of the sound track
  35931. */
  35932. setVolume(newVolume: number): void;
  35933. /**
  35934. * Switch the panning model to HRTF:
  35935. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35937. */
  35938. switchPanningModelToHRTF(): void;
  35939. /**
  35940. * Switch the panning model to Equal Power:
  35941. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35943. */
  35944. switchPanningModelToEqualPower(): void;
  35945. /**
  35946. * Connect the sound track to an audio analyser allowing some amazing
  35947. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35949. * @param analyser The analyser to connect to the engine
  35950. */
  35951. connectToAnalyser(analyser: Analyser): void;
  35952. }
  35953. }
  35954. declare module BABYLON {
  35955. interface AbstractScene {
  35956. /**
  35957. * The list of sounds used in the scene.
  35958. */
  35959. sounds: Nullable<Array<Sound>>;
  35960. }
  35961. interface Scene {
  35962. /**
  35963. * @hidden
  35964. * Backing field
  35965. */
  35966. _mainSoundTrack: SoundTrack;
  35967. /**
  35968. * The main sound track played by the scene.
  35969. * It cotains your primary collection of sounds.
  35970. */
  35971. mainSoundTrack: SoundTrack;
  35972. /**
  35973. * The list of sound tracks added to the scene
  35974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35975. */
  35976. soundTracks: Nullable<Array<SoundTrack>>;
  35977. /**
  35978. * Gets a sound using a given name
  35979. * @param name defines the name to search for
  35980. * @return the found sound or null if not found at all.
  35981. */
  35982. getSoundByName(name: string): Nullable<Sound>;
  35983. /**
  35984. * Gets or sets if audio support is enabled
  35985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35986. */
  35987. audioEnabled: boolean;
  35988. /**
  35989. * Gets or sets if audio will be output to headphones
  35990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35991. */
  35992. headphone: boolean;
  35993. /**
  35994. * Gets or sets custom audio listener position provider
  35995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35996. */
  35997. audioListenerPositionProvider: Nullable<() => Vector3>;
  35998. /**
  35999. * Gets or sets a refresh rate when using 3D audio positioning
  36000. */
  36001. audioPositioningRefreshRate: number;
  36002. }
  36003. /**
  36004. * Defines the sound scene component responsible to manage any sounds
  36005. * in a given scene.
  36006. */
  36007. export class AudioSceneComponent implements ISceneSerializableComponent {
  36008. /**
  36009. * The component name helpfull to identify the component in the list of scene components.
  36010. */
  36011. readonly name: string;
  36012. /**
  36013. * The scene the component belongs to.
  36014. */
  36015. scene: Scene;
  36016. private _audioEnabled;
  36017. /**
  36018. * Gets whether audio is enabled or not.
  36019. * Please use related enable/disable method to switch state.
  36020. */
  36021. readonly audioEnabled: boolean;
  36022. private _headphone;
  36023. /**
  36024. * Gets whether audio is outputing to headphone or not.
  36025. * Please use the according Switch methods to change output.
  36026. */
  36027. readonly headphone: boolean;
  36028. /**
  36029. * Gets or sets a refresh rate when using 3D audio positioning
  36030. */
  36031. audioPositioningRefreshRate: number;
  36032. private _audioListenerPositionProvider;
  36033. /**
  36034. * Gets the current audio listener position provider
  36035. */
  36036. /**
  36037. * Sets a custom listener position for all sounds in the scene
  36038. * By default, this is the position of the first active camera
  36039. */
  36040. audioListenerPositionProvider: Nullable<() => Vector3>;
  36041. /**
  36042. * Creates a new instance of the component for the given scene
  36043. * @param scene Defines the scene to register the component in
  36044. */
  36045. constructor(scene: Scene);
  36046. /**
  36047. * Registers the component in a given scene
  36048. */
  36049. register(): void;
  36050. /**
  36051. * Rebuilds the elements related to this component in case of
  36052. * context lost for instance.
  36053. */
  36054. rebuild(): void;
  36055. /**
  36056. * Serializes the component data to the specified json object
  36057. * @param serializationObject The object to serialize to
  36058. */
  36059. serialize(serializationObject: any): void;
  36060. /**
  36061. * Adds all the elements from the container to the scene
  36062. * @param container the container holding the elements
  36063. */
  36064. addFromContainer(container: AbstractScene): void;
  36065. /**
  36066. * Removes all the elements in the container from the scene
  36067. * @param container contains the elements to remove
  36068. * @param dispose if the removed element should be disposed (default: false)
  36069. */
  36070. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36071. /**
  36072. * Disposes the component and the associated ressources.
  36073. */
  36074. dispose(): void;
  36075. /**
  36076. * Disables audio in the associated scene.
  36077. */
  36078. disableAudio(): void;
  36079. /**
  36080. * Enables audio in the associated scene.
  36081. */
  36082. enableAudio(): void;
  36083. /**
  36084. * Switch audio to headphone output.
  36085. */
  36086. switchAudioModeForHeadphones(): void;
  36087. /**
  36088. * Switch audio to normal speakers.
  36089. */
  36090. switchAudioModeForNormalSpeakers(): void;
  36091. private _cachedCameraDirection;
  36092. private _cachedCameraPosition;
  36093. private _lastCheck;
  36094. private _afterRender;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Wraps one or more Sound objects and selects one with random weight for playback.
  36100. */
  36101. export class WeightedSound {
  36102. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36103. loop: boolean;
  36104. private _coneInnerAngle;
  36105. private _coneOuterAngle;
  36106. private _volume;
  36107. /** A Sound is currently playing. */
  36108. isPlaying: boolean;
  36109. /** A Sound is currently paused. */
  36110. isPaused: boolean;
  36111. private _sounds;
  36112. private _weights;
  36113. private _currentIndex?;
  36114. /**
  36115. * Creates a new WeightedSound from the list of sounds given.
  36116. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36117. * @param sounds Array of Sounds that will be selected from.
  36118. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36119. */
  36120. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36121. /**
  36122. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36123. */
  36124. /**
  36125. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36126. */
  36127. directionalConeInnerAngle: number;
  36128. /**
  36129. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36130. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36131. */
  36132. /**
  36133. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36134. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36135. */
  36136. directionalConeOuterAngle: number;
  36137. /**
  36138. * Playback volume.
  36139. */
  36140. /**
  36141. * Playback volume.
  36142. */
  36143. volume: number;
  36144. private _onended;
  36145. /**
  36146. * Suspend playback
  36147. */
  36148. pause(): void;
  36149. /**
  36150. * Stop playback
  36151. */
  36152. stop(): void;
  36153. /**
  36154. * Start playback.
  36155. * @param startOffset Position the clip head at a specific time in seconds.
  36156. */
  36157. play(startOffset?: number): void;
  36158. }
  36159. }
  36160. declare module BABYLON {
  36161. /**
  36162. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36164. */
  36165. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36166. /**
  36167. * Gets the name of the behavior.
  36168. */
  36169. readonly name: string;
  36170. /**
  36171. * The easing function used by animations
  36172. */
  36173. static EasingFunction: BackEase;
  36174. /**
  36175. * The easing mode used by animations
  36176. */
  36177. static EasingMode: number;
  36178. /**
  36179. * The duration of the animation, in milliseconds
  36180. */
  36181. transitionDuration: number;
  36182. /**
  36183. * Length of the distance animated by the transition when lower radius is reached
  36184. */
  36185. lowerRadiusTransitionRange: number;
  36186. /**
  36187. * Length of the distance animated by the transition when upper radius is reached
  36188. */
  36189. upperRadiusTransitionRange: number;
  36190. private _autoTransitionRange;
  36191. /**
  36192. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36193. */
  36194. /**
  36195. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36196. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36197. */
  36198. autoTransitionRange: boolean;
  36199. private _attachedCamera;
  36200. private _onAfterCheckInputsObserver;
  36201. private _onMeshTargetChangedObserver;
  36202. /**
  36203. * Initializes the behavior.
  36204. */
  36205. init(): void;
  36206. /**
  36207. * Attaches the behavior to its arc rotate camera.
  36208. * @param camera Defines the camera to attach the behavior to
  36209. */
  36210. attach(camera: ArcRotateCamera): void;
  36211. /**
  36212. * Detaches the behavior from its current arc rotate camera.
  36213. */
  36214. detach(): void;
  36215. private _radiusIsAnimating;
  36216. private _radiusBounceTransition;
  36217. private _animatables;
  36218. private _cachedWheelPrecision;
  36219. /**
  36220. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36221. * @param radiusLimit The limit to check against.
  36222. * @return Bool to indicate if at limit.
  36223. */
  36224. private _isRadiusAtLimit;
  36225. /**
  36226. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36227. * @param radiusDelta The delta by which to animate to. Can be negative.
  36228. */
  36229. private _applyBoundRadiusAnimation;
  36230. /**
  36231. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36232. */
  36233. protected _clearAnimationLocks(): void;
  36234. /**
  36235. * Stops and removes all animations that have been applied to the camera
  36236. */
  36237. stopAllAnimations(): void;
  36238. }
  36239. }
  36240. declare module BABYLON {
  36241. /**
  36242. * 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.
  36243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36244. */
  36245. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36246. /**
  36247. * Gets the name of the behavior.
  36248. */
  36249. readonly name: string;
  36250. private _mode;
  36251. private _radiusScale;
  36252. private _positionScale;
  36253. private _defaultElevation;
  36254. private _elevationReturnTime;
  36255. private _elevationReturnWaitTime;
  36256. private _zoomStopsAnimation;
  36257. private _framingTime;
  36258. /**
  36259. * The easing function used by animations
  36260. */
  36261. static EasingFunction: ExponentialEase;
  36262. /**
  36263. * The easing mode used by animations
  36264. */
  36265. static EasingMode: number;
  36266. /**
  36267. * Sets the current mode used by the behavior
  36268. */
  36269. /**
  36270. * Gets current mode used by the behavior.
  36271. */
  36272. mode: number;
  36273. /**
  36274. * Sets the scale applied to the radius (1 by default)
  36275. */
  36276. /**
  36277. * Gets the scale applied to the radius
  36278. */
  36279. radiusScale: number;
  36280. /**
  36281. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36282. */
  36283. /**
  36284. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36285. */
  36286. positionScale: number;
  36287. /**
  36288. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36289. * behaviour is triggered, in radians.
  36290. */
  36291. /**
  36292. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36293. * behaviour is triggered, in radians.
  36294. */
  36295. defaultElevation: number;
  36296. /**
  36297. * Sets the time (in milliseconds) taken to return to the default beta position.
  36298. * Negative value indicates camera should not return to default.
  36299. */
  36300. /**
  36301. * Gets the time (in milliseconds) taken to return to the default beta position.
  36302. * Negative value indicates camera should not return to default.
  36303. */
  36304. elevationReturnTime: number;
  36305. /**
  36306. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36307. */
  36308. /**
  36309. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36310. */
  36311. elevationReturnWaitTime: number;
  36312. /**
  36313. * Sets the flag that indicates if user zooming should stop animation.
  36314. */
  36315. /**
  36316. * Gets the flag that indicates if user zooming should stop animation.
  36317. */
  36318. zoomStopsAnimation: boolean;
  36319. /**
  36320. * Sets the transition time when framing the mesh, in milliseconds
  36321. */
  36322. /**
  36323. * Gets the transition time when framing the mesh, in milliseconds
  36324. */
  36325. framingTime: number;
  36326. /**
  36327. * Define if the behavior should automatically change the configured
  36328. * camera limits and sensibilities.
  36329. */
  36330. autoCorrectCameraLimitsAndSensibility: boolean;
  36331. private _onPrePointerObservableObserver;
  36332. private _onAfterCheckInputsObserver;
  36333. private _onMeshTargetChangedObserver;
  36334. private _attachedCamera;
  36335. private _isPointerDown;
  36336. private _lastInteractionTime;
  36337. /**
  36338. * Initializes the behavior.
  36339. */
  36340. init(): void;
  36341. /**
  36342. * Attaches the behavior to its arc rotate camera.
  36343. * @param camera Defines the camera to attach the behavior to
  36344. */
  36345. attach(camera: ArcRotateCamera): void;
  36346. /**
  36347. * Detaches the behavior from its current arc rotate camera.
  36348. */
  36349. detach(): void;
  36350. private _animatables;
  36351. private _betaIsAnimating;
  36352. private _betaTransition;
  36353. private _radiusTransition;
  36354. private _vectorTransition;
  36355. /**
  36356. * Targets the given mesh and updates zoom level accordingly.
  36357. * @param mesh The mesh to target.
  36358. * @param radius Optional. If a cached radius position already exists, overrides default.
  36359. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36362. */
  36363. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36364. /**
  36365. * Targets the given mesh with its children and updates zoom level accordingly.
  36366. * @param mesh The mesh to target.
  36367. * @param radius Optional. If a cached radius position already exists, overrides default.
  36368. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36369. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36370. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36371. */
  36372. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36373. /**
  36374. * Targets the given meshes with their children and updates zoom level accordingly.
  36375. * @param meshes The mesh to target.
  36376. * @param radius Optional. If a cached radius position already exists, overrides default.
  36377. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36378. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36379. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36380. */
  36381. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36382. /**
  36383. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36384. * @param minimumWorld Determines the smaller position of the bounding box extend
  36385. * @param maximumWorld Determines the bigger position of the bounding box extend
  36386. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36387. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36388. */
  36389. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36390. /**
  36391. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36392. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36393. * frustum width.
  36394. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36395. * to fully enclose the mesh in the viewing frustum.
  36396. */
  36397. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36398. /**
  36399. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36400. * is automatically returned to its default position (expected to be above ground plane).
  36401. */
  36402. private _maintainCameraAboveGround;
  36403. /**
  36404. * Returns the frustum slope based on the canvas ratio and camera FOV
  36405. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36406. */
  36407. private _getFrustumSlope;
  36408. /**
  36409. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36410. */
  36411. private _clearAnimationLocks;
  36412. /**
  36413. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36414. */
  36415. private _applyUserInteraction;
  36416. /**
  36417. * Stops and removes all animations that have been applied to the camera
  36418. */
  36419. stopAllAnimations(): void;
  36420. /**
  36421. * Gets a value indicating if the user is moving the camera
  36422. */
  36423. readonly isUserIsMoving: boolean;
  36424. /**
  36425. * The camera can move all the way towards the mesh.
  36426. */
  36427. static IgnoreBoundsSizeMode: number;
  36428. /**
  36429. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36430. */
  36431. static FitFrustumSidesMode: number;
  36432. }
  36433. }
  36434. declare module BABYLON {
  36435. /**
  36436. * Base class for Camera Pointer Inputs.
  36437. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36438. * for example usage.
  36439. */
  36440. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36441. /**
  36442. * Defines the camera the input is attached to.
  36443. */
  36444. abstract camera: Camera;
  36445. /**
  36446. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36447. */
  36448. protected _altKey: boolean;
  36449. protected _ctrlKey: boolean;
  36450. protected _metaKey: boolean;
  36451. protected _shiftKey: boolean;
  36452. /**
  36453. * Which mouse buttons were pressed at time of last mouse event.
  36454. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36455. */
  36456. protected _buttonsPressed: number;
  36457. /**
  36458. * Defines the buttons associated with the input to handle camera move.
  36459. */
  36460. buttons: number[];
  36461. /**
  36462. * Attach the input controls to a specific dom element to get the input from.
  36463. * @param element Defines the element the controls should be listened from
  36464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36465. */
  36466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36467. /**
  36468. * Detach the current controls from the specified dom element.
  36469. * @param element Defines the element to stop listening the inputs from
  36470. */
  36471. detachControl(element: Nullable<HTMLElement>): void;
  36472. /**
  36473. * Gets the class name of the current input.
  36474. * @returns the class name
  36475. */
  36476. getClassName(): string;
  36477. /**
  36478. * Get the friendly name associated with the input class.
  36479. * @returns the input friendly name
  36480. */
  36481. getSimpleName(): string;
  36482. /**
  36483. * Called on pointer POINTERDOUBLETAP event.
  36484. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36485. */
  36486. protected onDoubleTap(type: string): void;
  36487. /**
  36488. * Called on pointer POINTERMOVE event if only a single touch is active.
  36489. * Override this method to provide functionality.
  36490. */
  36491. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36492. /**
  36493. * Called on pointer POINTERMOVE event if multiple touches are active.
  36494. * Override this method to provide functionality.
  36495. */
  36496. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36497. /**
  36498. * Called on JS contextmenu event.
  36499. * Override this method to provide functionality.
  36500. */
  36501. protected onContextMenu(evt: PointerEvent): void;
  36502. /**
  36503. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36504. * press.
  36505. * Override this method to provide functionality.
  36506. */
  36507. protected onButtonDown(evt: PointerEvent): void;
  36508. /**
  36509. * Called each time a new POINTERUP event occurs. Ie, for each button
  36510. * release.
  36511. * Override this method to provide functionality.
  36512. */
  36513. protected onButtonUp(evt: PointerEvent): void;
  36514. /**
  36515. * Called when window becomes inactive.
  36516. * Override this method to provide functionality.
  36517. */
  36518. protected onLostFocus(): void;
  36519. private _pointerInput;
  36520. private _observer;
  36521. private _onLostFocus;
  36522. private pointA;
  36523. private pointB;
  36524. }
  36525. }
  36526. declare module BABYLON {
  36527. /**
  36528. * Manage the pointers inputs to control an arc rotate camera.
  36529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36530. */
  36531. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36532. /**
  36533. * Defines the camera the input is attached to.
  36534. */
  36535. camera: ArcRotateCamera;
  36536. /**
  36537. * Gets the class name of the current input.
  36538. * @returns the class name
  36539. */
  36540. getClassName(): string;
  36541. /**
  36542. * Defines the buttons associated with the input to handle camera move.
  36543. */
  36544. buttons: number[];
  36545. /**
  36546. * Defines the pointer angular sensibility along the X axis or how fast is
  36547. * the camera rotating.
  36548. */
  36549. angularSensibilityX: number;
  36550. /**
  36551. * Defines the pointer angular sensibility along the Y axis or how fast is
  36552. * the camera rotating.
  36553. */
  36554. angularSensibilityY: number;
  36555. /**
  36556. * Defines the pointer pinch precision or how fast is the camera zooming.
  36557. */
  36558. pinchPrecision: number;
  36559. /**
  36560. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36561. * from 0.
  36562. * It defines the percentage of current camera.radius to use as delta when
  36563. * pinch zoom is used.
  36564. */
  36565. pinchDeltaPercentage: number;
  36566. /**
  36567. * Defines the pointer panning sensibility or how fast is the camera moving.
  36568. */
  36569. panningSensibility: number;
  36570. /**
  36571. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36572. */
  36573. multiTouchPanning: boolean;
  36574. /**
  36575. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36576. * zoom (pinch) through multitouch.
  36577. */
  36578. multiTouchPanAndZoom: boolean;
  36579. /**
  36580. * Revers pinch action direction.
  36581. */
  36582. pinchInwards: boolean;
  36583. private _isPanClick;
  36584. private _twoFingerActivityCount;
  36585. private _isPinching;
  36586. /**
  36587. * Called on pointer POINTERMOVE event if only a single touch is active.
  36588. */
  36589. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36590. /**
  36591. * Called on pointer POINTERDOUBLETAP event.
  36592. */
  36593. protected onDoubleTap(type: string): void;
  36594. /**
  36595. * Called on pointer POINTERMOVE event if multiple touches are active.
  36596. */
  36597. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36598. /**
  36599. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36600. * press.
  36601. */
  36602. protected onButtonDown(evt: PointerEvent): void;
  36603. /**
  36604. * Called each time a new POINTERUP event occurs. Ie, for each button
  36605. * release.
  36606. */
  36607. protected onButtonUp(evt: PointerEvent): void;
  36608. /**
  36609. * Called when window becomes inactive.
  36610. */
  36611. protected onLostFocus(): void;
  36612. }
  36613. }
  36614. declare module BABYLON {
  36615. /**
  36616. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36618. */
  36619. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36620. /**
  36621. * Defines the camera the input is attached to.
  36622. */
  36623. camera: ArcRotateCamera;
  36624. /**
  36625. * Defines the list of key codes associated with the up action (increase alpha)
  36626. */
  36627. keysUp: number[];
  36628. /**
  36629. * Defines the list of key codes associated with the down action (decrease alpha)
  36630. */
  36631. keysDown: number[];
  36632. /**
  36633. * Defines the list of key codes associated with the left action (increase beta)
  36634. */
  36635. keysLeft: number[];
  36636. /**
  36637. * Defines the list of key codes associated with the right action (decrease beta)
  36638. */
  36639. keysRight: number[];
  36640. /**
  36641. * Defines the list of key codes associated with the reset action.
  36642. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36643. */
  36644. keysReset: number[];
  36645. /**
  36646. * Defines the panning sensibility of the inputs.
  36647. * (How fast is the camera paning)
  36648. */
  36649. panningSensibility: number;
  36650. /**
  36651. * Defines the zooming sensibility of the inputs.
  36652. * (How fast is the camera zooming)
  36653. */
  36654. zoomingSensibility: number;
  36655. /**
  36656. * Defines wether maintaining the alt key down switch the movement mode from
  36657. * orientation to zoom.
  36658. */
  36659. useAltToZoom: boolean;
  36660. /**
  36661. * Rotation speed of the camera
  36662. */
  36663. angularSpeed: number;
  36664. private _keys;
  36665. private _ctrlPressed;
  36666. private _altPressed;
  36667. private _onCanvasBlurObserver;
  36668. private _onKeyboardObserver;
  36669. private _engine;
  36670. private _scene;
  36671. /**
  36672. * Attach the input controls to a specific dom element to get the input from.
  36673. * @param element Defines the element the controls should be listened from
  36674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36675. */
  36676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36677. /**
  36678. * Detach the current controls from the specified dom element.
  36679. * @param element Defines the element to stop listening the inputs from
  36680. */
  36681. detachControl(element: Nullable<HTMLElement>): void;
  36682. /**
  36683. * Update the current camera state depending on the inputs that have been used this frame.
  36684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36685. */
  36686. checkInputs(): void;
  36687. /**
  36688. * Gets the class name of the current intput.
  36689. * @returns the class name
  36690. */
  36691. getClassName(): string;
  36692. /**
  36693. * Get the friendly name associated with the input class.
  36694. * @returns the input friendly name
  36695. */
  36696. getSimpleName(): string;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * Manage the mouse wheel inputs to control an arc rotate camera.
  36702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36703. */
  36704. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36705. /**
  36706. * Defines the camera the input is attached to.
  36707. */
  36708. camera: ArcRotateCamera;
  36709. /**
  36710. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36711. */
  36712. wheelPrecision: number;
  36713. /**
  36714. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36715. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36716. */
  36717. wheelDeltaPercentage: number;
  36718. private _wheel;
  36719. private _observer;
  36720. private computeDeltaFromMouseWheelLegacyEvent;
  36721. /**
  36722. * Attach the input controls to a specific dom element to get the input from.
  36723. * @param element Defines the element the controls should be listened from
  36724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36725. */
  36726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36727. /**
  36728. * Detach the current controls from the specified dom element.
  36729. * @param element Defines the element to stop listening the inputs from
  36730. */
  36731. detachControl(element: Nullable<HTMLElement>): void;
  36732. /**
  36733. * Gets the class name of the current intput.
  36734. * @returns the class name
  36735. */
  36736. getClassName(): string;
  36737. /**
  36738. * Get the friendly name associated with the input class.
  36739. * @returns the input friendly name
  36740. */
  36741. getSimpleName(): string;
  36742. }
  36743. }
  36744. declare module BABYLON {
  36745. /**
  36746. * Default Inputs manager for the ArcRotateCamera.
  36747. * It groups all the default supported inputs for ease of use.
  36748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36749. */
  36750. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36751. /**
  36752. * Instantiates a new ArcRotateCameraInputsManager.
  36753. * @param camera Defines the camera the inputs belong to
  36754. */
  36755. constructor(camera: ArcRotateCamera);
  36756. /**
  36757. * Add mouse wheel input support to the input manager.
  36758. * @returns the current input manager
  36759. */
  36760. addMouseWheel(): ArcRotateCameraInputsManager;
  36761. /**
  36762. * Add pointers input support to the input manager.
  36763. * @returns the current input manager
  36764. */
  36765. addPointers(): ArcRotateCameraInputsManager;
  36766. /**
  36767. * Add keyboard input support to the input manager.
  36768. * @returns the current input manager
  36769. */
  36770. addKeyboard(): ArcRotateCameraInputsManager;
  36771. }
  36772. }
  36773. declare module BABYLON {
  36774. /**
  36775. * This represents an orbital type of camera.
  36776. *
  36777. * 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.
  36778. * 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.
  36779. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36780. */
  36781. export class ArcRotateCamera extends TargetCamera {
  36782. /**
  36783. * Defines the rotation angle of the camera along the longitudinal axis.
  36784. */
  36785. alpha: number;
  36786. /**
  36787. * Defines the rotation angle of the camera along the latitudinal axis.
  36788. */
  36789. beta: number;
  36790. /**
  36791. * Defines the radius of the camera from it s target point.
  36792. */
  36793. radius: number;
  36794. protected _target: Vector3;
  36795. protected _targetHost: Nullable<AbstractMesh>;
  36796. /**
  36797. * Defines the target point of the camera.
  36798. * The camera looks towards it form the radius distance.
  36799. */
  36800. target: Vector3;
  36801. /**
  36802. * Define the current local position of the camera in the scene
  36803. */
  36804. position: Vector3;
  36805. protected _upVector: Vector3;
  36806. protected _upToYMatrix: Matrix;
  36807. protected _YToUpMatrix: Matrix;
  36808. /**
  36809. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36810. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36811. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36812. */
  36813. upVector: Vector3;
  36814. /**
  36815. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36816. */
  36817. setMatUp(): void;
  36818. /**
  36819. * Current inertia value on the longitudinal axis.
  36820. * The bigger this number the longer it will take for the camera to stop.
  36821. */
  36822. inertialAlphaOffset: number;
  36823. /**
  36824. * Current inertia value on the latitudinal axis.
  36825. * The bigger this number the longer it will take for the camera to stop.
  36826. */
  36827. inertialBetaOffset: number;
  36828. /**
  36829. * Current inertia value on the radius axis.
  36830. * The bigger this number the longer it will take for the camera to stop.
  36831. */
  36832. inertialRadiusOffset: number;
  36833. /**
  36834. * Minimum allowed angle on the longitudinal axis.
  36835. * This can help limiting how the Camera is able to move in the scene.
  36836. */
  36837. lowerAlphaLimit: Nullable<number>;
  36838. /**
  36839. * Maximum allowed angle on the longitudinal axis.
  36840. * This can help limiting how the Camera is able to move in the scene.
  36841. */
  36842. upperAlphaLimit: Nullable<number>;
  36843. /**
  36844. * Minimum allowed angle on the latitudinal axis.
  36845. * This can help limiting how the Camera is able to move in the scene.
  36846. */
  36847. lowerBetaLimit: number;
  36848. /**
  36849. * Maximum allowed angle on the latitudinal axis.
  36850. * This can help limiting how the Camera is able to move in the scene.
  36851. */
  36852. upperBetaLimit: number;
  36853. /**
  36854. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36855. * This can help limiting how the Camera is able to move in the scene.
  36856. */
  36857. lowerRadiusLimit: Nullable<number>;
  36858. /**
  36859. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36860. * This can help limiting how the Camera is able to move in the scene.
  36861. */
  36862. upperRadiusLimit: Nullable<number>;
  36863. /**
  36864. * Defines the current inertia value used during panning of the camera along the X axis.
  36865. */
  36866. inertialPanningX: number;
  36867. /**
  36868. * Defines the current inertia value used during panning of the camera along the Y axis.
  36869. */
  36870. inertialPanningY: number;
  36871. /**
  36872. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36873. * Basically if your fingers moves away from more than this distance you will be considered
  36874. * in pinch mode.
  36875. */
  36876. pinchToPanMaxDistance: number;
  36877. /**
  36878. * Defines the maximum distance the camera can pan.
  36879. * This could help keeping the cammera always in your scene.
  36880. */
  36881. panningDistanceLimit: Nullable<number>;
  36882. /**
  36883. * Defines the target of the camera before paning.
  36884. */
  36885. panningOriginTarget: Vector3;
  36886. /**
  36887. * Defines the value of the inertia used during panning.
  36888. * 0 would mean stop inertia and one would mean no decelleration at all.
  36889. */
  36890. panningInertia: number;
  36891. /**
  36892. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36893. */
  36894. angularSensibilityX: number;
  36895. /**
  36896. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36897. */
  36898. angularSensibilityY: number;
  36899. /**
  36900. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36901. */
  36902. pinchPrecision: number;
  36903. /**
  36904. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36905. * It will be used instead of pinchDeltaPrecision if different from 0.
  36906. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36907. */
  36908. pinchDeltaPercentage: number;
  36909. /**
  36910. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36911. */
  36912. panningSensibility: number;
  36913. /**
  36914. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36915. */
  36916. keysUp: number[];
  36917. /**
  36918. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36919. */
  36920. keysDown: number[];
  36921. /**
  36922. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36923. */
  36924. keysLeft: number[];
  36925. /**
  36926. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36927. */
  36928. keysRight: number[];
  36929. /**
  36930. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36931. */
  36932. wheelPrecision: number;
  36933. /**
  36934. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36935. * It will be used instead of pinchDeltaPrecision if different from 0.
  36936. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36937. */
  36938. wheelDeltaPercentage: number;
  36939. /**
  36940. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36941. */
  36942. zoomOnFactor: number;
  36943. /**
  36944. * Defines a screen offset for the camera position.
  36945. */
  36946. targetScreenOffset: Vector2;
  36947. /**
  36948. * Allows the camera to be completely reversed.
  36949. * If false the camera can not arrive upside down.
  36950. */
  36951. allowUpsideDown: boolean;
  36952. /**
  36953. * Define if double tap/click is used to restore the previously saved state of the camera.
  36954. */
  36955. useInputToRestoreState: boolean;
  36956. /** @hidden */
  36957. _viewMatrix: Matrix;
  36958. /** @hidden */
  36959. _useCtrlForPanning: boolean;
  36960. /** @hidden */
  36961. _panningMouseButton: number;
  36962. /**
  36963. * Defines the input associated to the camera.
  36964. */
  36965. inputs: ArcRotateCameraInputsManager;
  36966. /** @hidden */
  36967. _reset: () => void;
  36968. /**
  36969. * Defines the allowed panning axis.
  36970. */
  36971. panningAxis: Vector3;
  36972. protected _localDirection: Vector3;
  36973. protected _transformedDirection: Vector3;
  36974. private _bouncingBehavior;
  36975. /**
  36976. * Gets the bouncing behavior of the camera if it has been enabled.
  36977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36978. */
  36979. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36980. /**
  36981. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36983. */
  36984. useBouncingBehavior: boolean;
  36985. private _framingBehavior;
  36986. /**
  36987. * Gets the framing behavior of the camera if it has been enabled.
  36988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36989. */
  36990. readonly framingBehavior: Nullable<FramingBehavior>;
  36991. /**
  36992. * Defines if the framing behavior of the camera is enabled on the camera.
  36993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36994. */
  36995. useFramingBehavior: boolean;
  36996. private _autoRotationBehavior;
  36997. /**
  36998. * Gets the auto rotation behavior of the camera if it has been enabled.
  36999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37000. */
  37001. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37002. /**
  37003. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37004. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37005. */
  37006. useAutoRotationBehavior: boolean;
  37007. /**
  37008. * Observable triggered when the mesh target has been changed on the camera.
  37009. */
  37010. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37011. /**
  37012. * Event raised when the camera is colliding with a mesh.
  37013. */
  37014. onCollide: (collidedMesh: AbstractMesh) => void;
  37015. /**
  37016. * Defines whether the camera should check collision with the objects oh the scene.
  37017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37018. */
  37019. checkCollisions: boolean;
  37020. /**
  37021. * Defines the collision radius of the camera.
  37022. * This simulates a sphere around the camera.
  37023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37024. */
  37025. collisionRadius: Vector3;
  37026. protected _collider: Collider;
  37027. protected _previousPosition: Vector3;
  37028. protected _collisionVelocity: Vector3;
  37029. protected _newPosition: Vector3;
  37030. protected _previousAlpha: number;
  37031. protected _previousBeta: number;
  37032. protected _previousRadius: number;
  37033. protected _collisionTriggered: boolean;
  37034. protected _targetBoundingCenter: Nullable<Vector3>;
  37035. private _computationVector;
  37036. /**
  37037. * Instantiates a new ArcRotateCamera in a given scene
  37038. * @param name Defines the name of the camera
  37039. * @param alpha Defines the camera rotation along the logitudinal axis
  37040. * @param beta Defines the camera rotation along the latitudinal axis
  37041. * @param radius Defines the camera distance from its target
  37042. * @param target Defines the camera target
  37043. * @param scene Defines the scene the camera belongs to
  37044. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37045. */
  37046. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37047. /** @hidden */
  37048. _initCache(): void;
  37049. /** @hidden */
  37050. _updateCache(ignoreParentClass?: boolean): void;
  37051. protected _getTargetPosition(): Vector3;
  37052. private _storedAlpha;
  37053. private _storedBeta;
  37054. private _storedRadius;
  37055. private _storedTarget;
  37056. private _storedTargetScreenOffset;
  37057. /**
  37058. * Stores the current state of the camera (alpha, beta, radius and target)
  37059. * @returns the camera itself
  37060. */
  37061. storeState(): Camera;
  37062. /**
  37063. * @hidden
  37064. * Restored camera state. You must call storeState() first
  37065. */
  37066. _restoreStateValues(): boolean;
  37067. /** @hidden */
  37068. _isSynchronizedViewMatrix(): boolean;
  37069. /**
  37070. * Attached controls to the current camera.
  37071. * @param element Defines the element the controls should be listened from
  37072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37073. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37074. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37075. */
  37076. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37077. /**
  37078. * Detach the current controls from the camera.
  37079. * The camera will stop reacting to inputs.
  37080. * @param element Defines the element to stop listening the inputs from
  37081. */
  37082. detachControl(element: HTMLElement): void;
  37083. /** @hidden */
  37084. _checkInputs(): void;
  37085. protected _checkLimits(): void;
  37086. /**
  37087. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37088. */
  37089. rebuildAnglesAndRadius(): void;
  37090. /**
  37091. * Use a position to define the current camera related information like alpha, beta and radius
  37092. * @param position Defines the position to set the camera at
  37093. */
  37094. setPosition(position: Vector3): void;
  37095. /**
  37096. * Defines the target the camera should look at.
  37097. * This will automatically adapt alpha beta and radius to fit within the new target.
  37098. * @param target Defines the new target as a Vector or a mesh
  37099. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37100. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37101. */
  37102. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37103. /** @hidden */
  37104. _getViewMatrix(): Matrix;
  37105. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37106. /**
  37107. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37108. * @param meshes Defines the mesh to zoom on
  37109. * @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)
  37110. */
  37111. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37112. /**
  37113. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37114. * The target will be changed but the radius
  37115. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37116. * @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)
  37117. */
  37118. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37119. min: Vector3;
  37120. max: Vector3;
  37121. distance: number;
  37122. }, doNotUpdateMaxZ?: boolean): void;
  37123. /**
  37124. * @override
  37125. * Override Camera.createRigCamera
  37126. */
  37127. createRigCamera(name: string, cameraIndex: number): Camera;
  37128. /**
  37129. * @hidden
  37130. * @override
  37131. * Override Camera._updateRigCameras
  37132. */
  37133. _updateRigCameras(): void;
  37134. /**
  37135. * Destroy the camera and release the current resources hold by it.
  37136. */
  37137. dispose(): void;
  37138. /**
  37139. * Gets the current object class name.
  37140. * @return the class name
  37141. */
  37142. getClassName(): string;
  37143. }
  37144. }
  37145. declare module BABYLON {
  37146. /**
  37147. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37148. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37149. */
  37150. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37151. /**
  37152. * Gets the name of the behavior.
  37153. */
  37154. readonly name: string;
  37155. private _zoomStopsAnimation;
  37156. private _idleRotationSpeed;
  37157. private _idleRotationWaitTime;
  37158. private _idleRotationSpinupTime;
  37159. /**
  37160. * Sets the flag that indicates if user zooming should stop animation.
  37161. */
  37162. /**
  37163. * Gets the flag that indicates if user zooming should stop animation.
  37164. */
  37165. zoomStopsAnimation: boolean;
  37166. /**
  37167. * Sets the default speed at which the camera rotates around the model.
  37168. */
  37169. /**
  37170. * Gets the default speed at which the camera rotates around the model.
  37171. */
  37172. idleRotationSpeed: number;
  37173. /**
  37174. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37175. */
  37176. /**
  37177. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37178. */
  37179. idleRotationWaitTime: number;
  37180. /**
  37181. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37182. */
  37183. /**
  37184. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37185. */
  37186. idleRotationSpinupTime: number;
  37187. /**
  37188. * Gets a value indicating if the camera is currently rotating because of this behavior
  37189. */
  37190. readonly rotationInProgress: boolean;
  37191. private _onPrePointerObservableObserver;
  37192. private _onAfterCheckInputsObserver;
  37193. private _attachedCamera;
  37194. private _isPointerDown;
  37195. private _lastFrameTime;
  37196. private _lastInteractionTime;
  37197. private _cameraRotationSpeed;
  37198. /**
  37199. * Initializes the behavior.
  37200. */
  37201. init(): void;
  37202. /**
  37203. * Attaches the behavior to its arc rotate camera.
  37204. * @param camera Defines the camera to attach the behavior to
  37205. */
  37206. attach(camera: ArcRotateCamera): void;
  37207. /**
  37208. * Detaches the behavior from its current arc rotate camera.
  37209. */
  37210. detach(): void;
  37211. /**
  37212. * Returns true if user is scrolling.
  37213. * @return true if user is scrolling.
  37214. */
  37215. private _userIsZooming;
  37216. private _lastFrameRadius;
  37217. private _shouldAnimationStopForInteraction;
  37218. /**
  37219. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37220. */
  37221. private _applyUserInteraction;
  37222. private _userIsMoving;
  37223. }
  37224. }
  37225. declare module BABYLON {
  37226. /**
  37227. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37228. */
  37229. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37230. private ui;
  37231. /**
  37232. * The name of the behavior
  37233. */
  37234. name: string;
  37235. /**
  37236. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37237. */
  37238. distanceAwayFromFace: number;
  37239. /**
  37240. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37241. */
  37242. distanceAwayFromBottomOfFace: number;
  37243. private _faceVectors;
  37244. private _target;
  37245. private _scene;
  37246. private _onRenderObserver;
  37247. private _tmpMatrix;
  37248. private _tmpVector;
  37249. /**
  37250. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37251. * @param ui The transform node that should be attched to the mesh
  37252. */
  37253. constructor(ui: TransformNode);
  37254. /**
  37255. * Initializes the behavior
  37256. */
  37257. init(): void;
  37258. private _closestFace;
  37259. private _zeroVector;
  37260. private _lookAtTmpMatrix;
  37261. private _lookAtToRef;
  37262. /**
  37263. * Attaches the AttachToBoxBehavior to the passed in mesh
  37264. * @param target The mesh that the specified node will be attached to
  37265. */
  37266. attach(target: Mesh): void;
  37267. /**
  37268. * Detaches the behavior from the mesh
  37269. */
  37270. detach(): void;
  37271. }
  37272. }
  37273. declare module BABYLON {
  37274. /**
  37275. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37276. */
  37277. export class FadeInOutBehavior implements Behavior<Mesh> {
  37278. /**
  37279. * Time in milliseconds to delay before fading in (Default: 0)
  37280. */
  37281. delay: number;
  37282. /**
  37283. * Time in milliseconds for the mesh to fade in (Default: 300)
  37284. */
  37285. fadeInTime: number;
  37286. private _millisecondsPerFrame;
  37287. private _hovered;
  37288. private _hoverValue;
  37289. private _ownerNode;
  37290. /**
  37291. * Instatiates the FadeInOutBehavior
  37292. */
  37293. constructor();
  37294. /**
  37295. * The name of the behavior
  37296. */
  37297. readonly name: string;
  37298. /**
  37299. * Initializes the behavior
  37300. */
  37301. init(): void;
  37302. /**
  37303. * Attaches the fade behavior on the passed in mesh
  37304. * @param ownerNode The mesh that will be faded in/out once attached
  37305. */
  37306. attach(ownerNode: Mesh): void;
  37307. /**
  37308. * Detaches the behavior from the mesh
  37309. */
  37310. detach(): void;
  37311. /**
  37312. * Triggers the mesh to begin fading in or out
  37313. * @param value if the object should fade in or out (true to fade in)
  37314. */
  37315. fadeIn(value: boolean): void;
  37316. private _update;
  37317. private _setAllVisibility;
  37318. }
  37319. }
  37320. declare module BABYLON {
  37321. /**
  37322. * Class containing a set of static utilities functions for managing Pivots
  37323. * @hidden
  37324. */
  37325. export class PivotTools {
  37326. private static _PivotCached;
  37327. private static _OldPivotPoint;
  37328. private static _PivotTranslation;
  37329. private static _PivotTmpVector;
  37330. /** @hidden */
  37331. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37332. /** @hidden */
  37333. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37334. }
  37335. }
  37336. declare module BABYLON {
  37337. /**
  37338. * Class containing static functions to help procedurally build meshes
  37339. */
  37340. export class PlaneBuilder {
  37341. /**
  37342. * Creates a plane mesh
  37343. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37344. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37345. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37347. * * 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
  37348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37349. * @param name defines the name of the mesh
  37350. * @param options defines the options used to create the mesh
  37351. * @param scene defines the hosting scene
  37352. * @returns the plane mesh
  37353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37354. */
  37355. static CreatePlane(name: string, options: {
  37356. size?: number;
  37357. width?: number;
  37358. height?: number;
  37359. sideOrientation?: number;
  37360. frontUVs?: Vector4;
  37361. backUVs?: Vector4;
  37362. updatable?: boolean;
  37363. sourcePlane?: Plane;
  37364. }, scene?: Nullable<Scene>): Mesh;
  37365. }
  37366. }
  37367. declare module BABYLON {
  37368. /**
  37369. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37370. */
  37371. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37372. private static _AnyMouseID;
  37373. /**
  37374. * Abstract mesh the behavior is set on
  37375. */
  37376. attachedNode: AbstractMesh;
  37377. private _dragPlane;
  37378. private _scene;
  37379. private _pointerObserver;
  37380. private _beforeRenderObserver;
  37381. private static _planeScene;
  37382. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37383. /**
  37384. * 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)
  37385. */
  37386. maxDragAngle: number;
  37387. /**
  37388. * @hidden
  37389. */
  37390. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37391. /**
  37392. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37393. */
  37394. currentDraggingPointerID: number;
  37395. /**
  37396. * The last position where the pointer hit the drag plane in world space
  37397. */
  37398. lastDragPosition: Vector3;
  37399. /**
  37400. * If the behavior is currently in a dragging state
  37401. */
  37402. dragging: boolean;
  37403. /**
  37404. * 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)
  37405. */
  37406. dragDeltaRatio: number;
  37407. /**
  37408. * If the drag plane orientation should be updated during the dragging (Default: true)
  37409. */
  37410. updateDragPlane: boolean;
  37411. private _debugMode;
  37412. private _moving;
  37413. /**
  37414. * Fires each time the attached mesh is dragged with the pointer
  37415. * * delta between last drag position and current drag position in world space
  37416. * * dragDistance along the drag axis
  37417. * * dragPlaneNormal normal of the current drag plane used during the drag
  37418. * * dragPlanePoint in world space where the drag intersects the drag plane
  37419. */
  37420. onDragObservable: Observable<{
  37421. delta: Vector3;
  37422. dragPlanePoint: Vector3;
  37423. dragPlaneNormal: Vector3;
  37424. dragDistance: number;
  37425. pointerId: number;
  37426. }>;
  37427. /**
  37428. * Fires each time a drag begins (eg. mouse down on mesh)
  37429. */
  37430. onDragStartObservable: Observable<{
  37431. dragPlanePoint: Vector3;
  37432. pointerId: number;
  37433. }>;
  37434. /**
  37435. * Fires each time a drag ends (eg. mouse release after drag)
  37436. */
  37437. onDragEndObservable: Observable<{
  37438. dragPlanePoint: Vector3;
  37439. pointerId: number;
  37440. }>;
  37441. /**
  37442. * If the attached mesh should be moved when dragged
  37443. */
  37444. moveAttached: boolean;
  37445. /**
  37446. * If the drag behavior will react to drag events (Default: true)
  37447. */
  37448. enabled: boolean;
  37449. /**
  37450. * If pointer events should start and release the drag (Default: true)
  37451. */
  37452. startAndReleaseDragOnPointerEvents: boolean;
  37453. /**
  37454. * If camera controls should be detached during the drag
  37455. */
  37456. detachCameraControls: boolean;
  37457. /**
  37458. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37459. */
  37460. useObjectOrienationForDragging: boolean;
  37461. private _options;
  37462. /**
  37463. * Creates a pointer drag behavior that can be attached to a mesh
  37464. * @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)
  37465. */
  37466. constructor(options?: {
  37467. dragAxis?: Vector3;
  37468. dragPlaneNormal?: Vector3;
  37469. });
  37470. /**
  37471. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37472. */
  37473. validateDrag: (targetPosition: Vector3) => boolean;
  37474. /**
  37475. * The name of the behavior
  37476. */
  37477. readonly name: string;
  37478. /**
  37479. * Initializes the behavior
  37480. */
  37481. init(): void;
  37482. private _tmpVector;
  37483. private _alternatePickedPoint;
  37484. private _worldDragAxis;
  37485. private _targetPosition;
  37486. private _attachedElement;
  37487. /**
  37488. * Attaches the drag behavior the passed in mesh
  37489. * @param ownerNode The mesh that will be dragged around once attached
  37490. * @param predicate Predicate to use for pick filtering
  37491. */
  37492. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37493. /**
  37494. * Force relase the drag action by code.
  37495. */
  37496. releaseDrag(): void;
  37497. private _startDragRay;
  37498. private _lastPointerRay;
  37499. /**
  37500. * Simulates the start of a pointer drag event on the behavior
  37501. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37502. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37503. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37504. */
  37505. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37506. private _startDrag;
  37507. private _dragDelta;
  37508. private _moveDrag;
  37509. private _pickWithRayOnDragPlane;
  37510. private _pointA;
  37511. private _pointB;
  37512. private _pointC;
  37513. private _lineA;
  37514. private _lineB;
  37515. private _localAxis;
  37516. private _lookAt;
  37517. private _updateDragPlanePosition;
  37518. /**
  37519. * Detaches the behavior from the mesh
  37520. */
  37521. detach(): void;
  37522. }
  37523. }
  37524. declare module BABYLON {
  37525. /**
  37526. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37527. */
  37528. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37529. private _dragBehaviorA;
  37530. private _dragBehaviorB;
  37531. private _startDistance;
  37532. private _initialScale;
  37533. private _targetScale;
  37534. private _ownerNode;
  37535. private _sceneRenderObserver;
  37536. /**
  37537. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37538. */
  37539. constructor();
  37540. /**
  37541. * The name of the behavior
  37542. */
  37543. readonly name: string;
  37544. /**
  37545. * Initializes the behavior
  37546. */
  37547. init(): void;
  37548. private _getCurrentDistance;
  37549. /**
  37550. * Attaches the scale behavior the passed in mesh
  37551. * @param ownerNode The mesh that will be scaled around once attached
  37552. */
  37553. attach(ownerNode: Mesh): void;
  37554. /**
  37555. * Detaches the behavior from the mesh
  37556. */
  37557. detach(): void;
  37558. }
  37559. }
  37560. declare module BABYLON {
  37561. /**
  37562. * 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
  37563. */
  37564. export class SixDofDragBehavior implements Behavior<Mesh> {
  37565. private static _virtualScene;
  37566. private _ownerNode;
  37567. private _sceneRenderObserver;
  37568. private _scene;
  37569. private _targetPosition;
  37570. private _virtualOriginMesh;
  37571. private _virtualDragMesh;
  37572. private _pointerObserver;
  37573. private _moving;
  37574. private _startingOrientation;
  37575. /**
  37576. * 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)
  37577. */
  37578. private zDragFactor;
  37579. /**
  37580. * If the object should rotate to face the drag origin
  37581. */
  37582. rotateDraggedObject: boolean;
  37583. /**
  37584. * If the behavior is currently in a dragging state
  37585. */
  37586. dragging: boolean;
  37587. /**
  37588. * 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)
  37589. */
  37590. dragDeltaRatio: number;
  37591. /**
  37592. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37593. */
  37594. currentDraggingPointerID: number;
  37595. /**
  37596. * If camera controls should be detached during the drag
  37597. */
  37598. detachCameraControls: boolean;
  37599. /**
  37600. * Fires each time a drag starts
  37601. */
  37602. onDragStartObservable: Observable<{}>;
  37603. /**
  37604. * Fires each time a drag ends (eg. mouse release after drag)
  37605. */
  37606. onDragEndObservable: Observable<{}>;
  37607. /**
  37608. * 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
  37609. */
  37610. constructor();
  37611. /**
  37612. * The name of the behavior
  37613. */
  37614. readonly name: string;
  37615. /**
  37616. * Initializes the behavior
  37617. */
  37618. init(): void;
  37619. /**
  37620. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37621. */
  37622. private readonly _pointerCamera;
  37623. /**
  37624. * Attaches the scale behavior the passed in mesh
  37625. * @param ownerNode The mesh that will be scaled around once attached
  37626. */
  37627. attach(ownerNode: Mesh): void;
  37628. /**
  37629. * Detaches the behavior from the mesh
  37630. */
  37631. detach(): void;
  37632. }
  37633. }
  37634. declare module BABYLON {
  37635. /**
  37636. * Class used to apply inverse kinematics to bones
  37637. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37638. */
  37639. export class BoneIKController {
  37640. private static _tmpVecs;
  37641. private static _tmpQuat;
  37642. private static _tmpMats;
  37643. /**
  37644. * Gets or sets the target mesh
  37645. */
  37646. targetMesh: AbstractMesh;
  37647. /** Gets or sets the mesh used as pole */
  37648. poleTargetMesh: AbstractMesh;
  37649. /**
  37650. * Gets or sets the bone used as pole
  37651. */
  37652. poleTargetBone: Nullable<Bone>;
  37653. /**
  37654. * Gets or sets the target position
  37655. */
  37656. targetPosition: Vector3;
  37657. /**
  37658. * Gets or sets the pole target position
  37659. */
  37660. poleTargetPosition: Vector3;
  37661. /**
  37662. * Gets or sets the pole target local offset
  37663. */
  37664. poleTargetLocalOffset: Vector3;
  37665. /**
  37666. * Gets or sets the pole angle
  37667. */
  37668. poleAngle: number;
  37669. /**
  37670. * Gets or sets the mesh associated with the controller
  37671. */
  37672. mesh: AbstractMesh;
  37673. /**
  37674. * 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)
  37675. */
  37676. slerpAmount: number;
  37677. private _bone1Quat;
  37678. private _bone1Mat;
  37679. private _bone2Ang;
  37680. private _bone1;
  37681. private _bone2;
  37682. private _bone1Length;
  37683. private _bone2Length;
  37684. private _maxAngle;
  37685. private _maxReach;
  37686. private _rightHandedSystem;
  37687. private _bendAxis;
  37688. private _slerping;
  37689. private _adjustRoll;
  37690. /**
  37691. * Gets or sets maximum allowed angle
  37692. */
  37693. maxAngle: number;
  37694. /**
  37695. * Creates a new BoneIKController
  37696. * @param mesh defines the mesh to control
  37697. * @param bone defines the bone to control
  37698. * @param options defines options to set up the controller
  37699. */
  37700. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37701. targetMesh?: AbstractMesh;
  37702. poleTargetMesh?: AbstractMesh;
  37703. poleTargetBone?: Bone;
  37704. poleTargetLocalOffset?: Vector3;
  37705. poleAngle?: number;
  37706. bendAxis?: Vector3;
  37707. maxAngle?: number;
  37708. slerpAmount?: number;
  37709. });
  37710. private _setMaxAngle;
  37711. /**
  37712. * Force the controller to update the bones
  37713. */
  37714. update(): void;
  37715. }
  37716. }
  37717. declare module BABYLON {
  37718. /**
  37719. * Class used to make a bone look toward a point in space
  37720. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37721. */
  37722. export class BoneLookController {
  37723. private static _tmpVecs;
  37724. private static _tmpQuat;
  37725. private static _tmpMats;
  37726. /**
  37727. * The target Vector3 that the bone will look at
  37728. */
  37729. target: Vector3;
  37730. /**
  37731. * The mesh that the bone is attached to
  37732. */
  37733. mesh: AbstractMesh;
  37734. /**
  37735. * The bone that will be looking to the target
  37736. */
  37737. bone: Bone;
  37738. /**
  37739. * The up axis of the coordinate system that is used when the bone is rotated
  37740. */
  37741. upAxis: Vector3;
  37742. /**
  37743. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37744. */
  37745. upAxisSpace: Space;
  37746. /**
  37747. * Used to make an adjustment to the yaw of the bone
  37748. */
  37749. adjustYaw: number;
  37750. /**
  37751. * Used to make an adjustment to the pitch of the bone
  37752. */
  37753. adjustPitch: number;
  37754. /**
  37755. * Used to make an adjustment to the roll of the bone
  37756. */
  37757. adjustRoll: number;
  37758. /**
  37759. * 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)
  37760. */
  37761. slerpAmount: number;
  37762. private _minYaw;
  37763. private _maxYaw;
  37764. private _minPitch;
  37765. private _maxPitch;
  37766. private _minYawSin;
  37767. private _minYawCos;
  37768. private _maxYawSin;
  37769. private _maxYawCos;
  37770. private _midYawConstraint;
  37771. private _minPitchTan;
  37772. private _maxPitchTan;
  37773. private _boneQuat;
  37774. private _slerping;
  37775. private _transformYawPitch;
  37776. private _transformYawPitchInv;
  37777. private _firstFrameSkipped;
  37778. private _yawRange;
  37779. private _fowardAxis;
  37780. /**
  37781. * Gets or sets the minimum yaw angle that the bone can look to
  37782. */
  37783. minYaw: number;
  37784. /**
  37785. * Gets or sets the maximum yaw angle that the bone can look to
  37786. */
  37787. maxYaw: number;
  37788. /**
  37789. * Gets or sets the minimum pitch angle that the bone can look to
  37790. */
  37791. minPitch: number;
  37792. /**
  37793. * Gets or sets the maximum pitch angle that the bone can look to
  37794. */
  37795. maxPitch: number;
  37796. /**
  37797. * Create a BoneLookController
  37798. * @param mesh the mesh that the bone belongs to
  37799. * @param bone the bone that will be looking to the target
  37800. * @param target the target Vector3 to look at
  37801. * @param options optional settings:
  37802. * * maxYaw: the maximum angle the bone will yaw to
  37803. * * minYaw: the minimum angle the bone will yaw to
  37804. * * maxPitch: the maximum angle the bone will pitch to
  37805. * * minPitch: the minimum angle the bone will yaw to
  37806. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37807. * * upAxis: the up axis of the coordinate system
  37808. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37809. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37810. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37811. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37812. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37813. * * adjustRoll: used to make an adjustment to the roll of the bone
  37814. **/
  37815. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37816. maxYaw?: number;
  37817. minYaw?: number;
  37818. maxPitch?: number;
  37819. minPitch?: number;
  37820. slerpAmount?: number;
  37821. upAxis?: Vector3;
  37822. upAxisSpace?: Space;
  37823. yawAxis?: Vector3;
  37824. pitchAxis?: Vector3;
  37825. adjustYaw?: number;
  37826. adjustPitch?: number;
  37827. adjustRoll?: number;
  37828. });
  37829. /**
  37830. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37831. */
  37832. update(): void;
  37833. private _getAngleDiff;
  37834. private _getAngleBetween;
  37835. private _isAngleBetween;
  37836. }
  37837. }
  37838. declare module BABYLON {
  37839. /**
  37840. * Manage the gamepad inputs to control an arc rotate camera.
  37841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37842. */
  37843. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37844. /**
  37845. * Defines the camera the input is attached to.
  37846. */
  37847. camera: ArcRotateCamera;
  37848. /**
  37849. * Defines the gamepad the input is gathering event from.
  37850. */
  37851. gamepad: Nullable<Gamepad>;
  37852. /**
  37853. * Defines the gamepad rotation sensiblity.
  37854. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37855. */
  37856. gamepadRotationSensibility: number;
  37857. /**
  37858. * Defines the gamepad move sensiblity.
  37859. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37860. */
  37861. gamepadMoveSensibility: number;
  37862. private _yAxisScale;
  37863. /**
  37864. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37865. */
  37866. invertYAxis: boolean;
  37867. private _onGamepadConnectedObserver;
  37868. private _onGamepadDisconnectedObserver;
  37869. /**
  37870. * Attach the input controls to a specific dom element to get the input from.
  37871. * @param element Defines the element the controls should be listened from
  37872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37873. */
  37874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37875. /**
  37876. * Detach the current controls from the specified dom element.
  37877. * @param element Defines the element to stop listening the inputs from
  37878. */
  37879. detachControl(element: Nullable<HTMLElement>): void;
  37880. /**
  37881. * Update the current camera state depending on the inputs that have been used this frame.
  37882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37883. */
  37884. checkInputs(): void;
  37885. /**
  37886. * Gets the class name of the current intput.
  37887. * @returns the class name
  37888. */
  37889. getClassName(): string;
  37890. /**
  37891. * Get the friendly name associated with the input class.
  37892. * @returns the input friendly name
  37893. */
  37894. getSimpleName(): string;
  37895. }
  37896. }
  37897. declare module BABYLON {
  37898. interface ArcRotateCameraInputsManager {
  37899. /**
  37900. * Add orientation input support to the input manager.
  37901. * @returns the current input manager
  37902. */
  37903. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37904. }
  37905. /**
  37906. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37908. */
  37909. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37910. /**
  37911. * Defines the camera the input is attached to.
  37912. */
  37913. camera: ArcRotateCamera;
  37914. /**
  37915. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37916. */
  37917. alphaCorrection: number;
  37918. /**
  37919. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37920. */
  37921. gammaCorrection: number;
  37922. private _alpha;
  37923. private _gamma;
  37924. private _dirty;
  37925. private _deviceOrientationHandler;
  37926. /**
  37927. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37928. */
  37929. constructor();
  37930. /**
  37931. * Attach the input controls to a specific dom element to get the input from.
  37932. * @param element Defines the element the controls should be listened from
  37933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37934. */
  37935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37936. /** @hidden */
  37937. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37938. /**
  37939. * Update the current camera state depending on the inputs that have been used this frame.
  37940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37941. */
  37942. checkInputs(): void;
  37943. /**
  37944. * Detach the current controls from the specified dom element.
  37945. * @param element Defines the element to stop listening the inputs from
  37946. */
  37947. detachControl(element: Nullable<HTMLElement>): void;
  37948. /**
  37949. * Gets the class name of the current intput.
  37950. * @returns the class name
  37951. */
  37952. getClassName(): string;
  37953. /**
  37954. * Get the friendly name associated with the input class.
  37955. * @returns the input friendly name
  37956. */
  37957. getSimpleName(): string;
  37958. }
  37959. }
  37960. declare module BABYLON {
  37961. /**
  37962. * Listen to mouse events to control the camera.
  37963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37964. */
  37965. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37966. /**
  37967. * Defines the camera the input is attached to.
  37968. */
  37969. camera: FlyCamera;
  37970. /**
  37971. * Defines if touch is enabled. (Default is true.)
  37972. */
  37973. touchEnabled: boolean;
  37974. /**
  37975. * Defines the buttons associated with the input to handle camera rotation.
  37976. */
  37977. buttons: number[];
  37978. /**
  37979. * Assign buttons for Yaw control.
  37980. */
  37981. buttonsYaw: number[];
  37982. /**
  37983. * Assign buttons for Pitch control.
  37984. */
  37985. buttonsPitch: number[];
  37986. /**
  37987. * Assign buttons for Roll control.
  37988. */
  37989. buttonsRoll: number[];
  37990. /**
  37991. * Detect if any button is being pressed while mouse is moved.
  37992. * -1 = Mouse locked.
  37993. * 0 = Left button.
  37994. * 1 = Middle Button.
  37995. * 2 = Right Button.
  37996. */
  37997. activeButton: number;
  37998. /**
  37999. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38000. * Higher values reduce its sensitivity.
  38001. */
  38002. angularSensibility: number;
  38003. private _mousemoveCallback;
  38004. private _observer;
  38005. private _rollObserver;
  38006. private previousPosition;
  38007. private noPreventDefault;
  38008. private element;
  38009. /**
  38010. * Listen to mouse events to control the camera.
  38011. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38013. */
  38014. constructor(touchEnabled?: boolean);
  38015. /**
  38016. * Attach the mouse control to the HTML DOM element.
  38017. * @param element Defines the element that listens to the input events.
  38018. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38019. */
  38020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38021. /**
  38022. * Detach the current controls from the specified dom element.
  38023. * @param element Defines the element to stop listening the inputs from
  38024. */
  38025. detachControl(element: Nullable<HTMLElement>): void;
  38026. /**
  38027. * Gets the class name of the current input.
  38028. * @returns the class name.
  38029. */
  38030. getClassName(): string;
  38031. /**
  38032. * Get the friendly name associated with the input class.
  38033. * @returns the input's friendly name.
  38034. */
  38035. getSimpleName(): string;
  38036. private _pointerInput;
  38037. private _onMouseMove;
  38038. /**
  38039. * Rotate camera by mouse offset.
  38040. */
  38041. private rotateCamera;
  38042. }
  38043. }
  38044. declare module BABYLON {
  38045. /**
  38046. * Default Inputs manager for the FlyCamera.
  38047. * It groups all the default supported inputs for ease of use.
  38048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38049. */
  38050. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38051. /**
  38052. * Instantiates a new FlyCameraInputsManager.
  38053. * @param camera Defines the camera the inputs belong to.
  38054. */
  38055. constructor(camera: FlyCamera);
  38056. /**
  38057. * Add keyboard input support to the input manager.
  38058. * @returns the new FlyCameraKeyboardMoveInput().
  38059. */
  38060. addKeyboard(): FlyCameraInputsManager;
  38061. /**
  38062. * Add mouse input support to the input manager.
  38063. * @param touchEnabled Enable touch screen support.
  38064. * @returns the new FlyCameraMouseInput().
  38065. */
  38066. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38067. }
  38068. }
  38069. declare module BABYLON {
  38070. /**
  38071. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38072. * such as in a 3D Space Shooter or a Flight Simulator.
  38073. */
  38074. export class FlyCamera extends TargetCamera {
  38075. /**
  38076. * Define the collision ellipsoid of the camera.
  38077. * This is helpful for simulating a camera body, like a player's body.
  38078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38079. */
  38080. ellipsoid: Vector3;
  38081. /**
  38082. * Define an offset for the position of the ellipsoid around the camera.
  38083. * This can be helpful if the camera is attached away from the player's body center,
  38084. * such as at its head.
  38085. */
  38086. ellipsoidOffset: Vector3;
  38087. /**
  38088. * Enable or disable collisions of the camera with the rest of the scene objects.
  38089. */
  38090. checkCollisions: boolean;
  38091. /**
  38092. * Enable or disable gravity on the camera.
  38093. */
  38094. applyGravity: boolean;
  38095. /**
  38096. * Define the current direction the camera is moving to.
  38097. */
  38098. cameraDirection: Vector3;
  38099. /**
  38100. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38101. * This overrides and empties cameraRotation.
  38102. */
  38103. rotationQuaternion: Quaternion;
  38104. /**
  38105. * Track Roll to maintain the wanted Rolling when looking around.
  38106. */
  38107. _trackRoll: number;
  38108. /**
  38109. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38110. */
  38111. rollCorrect: number;
  38112. /**
  38113. * Mimic a banked turn, Rolling the camera when Yawing.
  38114. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38115. */
  38116. bankedTurn: boolean;
  38117. /**
  38118. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38119. */
  38120. bankedTurnLimit: number;
  38121. /**
  38122. * Value of 0 disables the banked Roll.
  38123. * Value of 1 is equal to the Yaw angle in radians.
  38124. */
  38125. bankedTurnMultiplier: number;
  38126. /**
  38127. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38128. */
  38129. inputs: FlyCameraInputsManager;
  38130. /**
  38131. * Gets the input sensibility for mouse input.
  38132. * Higher values reduce sensitivity.
  38133. */
  38134. /**
  38135. * Sets the input sensibility for a mouse input.
  38136. * Higher values reduce sensitivity.
  38137. */
  38138. angularSensibility: number;
  38139. /**
  38140. * Get the keys for camera movement forward.
  38141. */
  38142. /**
  38143. * Set the keys for camera movement forward.
  38144. */
  38145. keysForward: number[];
  38146. /**
  38147. * Get the keys for camera movement backward.
  38148. */
  38149. keysBackward: number[];
  38150. /**
  38151. * Get the keys for camera movement up.
  38152. */
  38153. /**
  38154. * Set the keys for camera movement up.
  38155. */
  38156. keysUp: number[];
  38157. /**
  38158. * Get the keys for camera movement down.
  38159. */
  38160. /**
  38161. * Set the keys for camera movement down.
  38162. */
  38163. keysDown: number[];
  38164. /**
  38165. * Get the keys for camera movement left.
  38166. */
  38167. /**
  38168. * Set the keys for camera movement left.
  38169. */
  38170. keysLeft: number[];
  38171. /**
  38172. * Set the keys for camera movement right.
  38173. */
  38174. /**
  38175. * Set the keys for camera movement right.
  38176. */
  38177. keysRight: number[];
  38178. /**
  38179. * Event raised when the camera collides with a mesh in the scene.
  38180. */
  38181. onCollide: (collidedMesh: AbstractMesh) => void;
  38182. private _collider;
  38183. private _needMoveForGravity;
  38184. private _oldPosition;
  38185. private _diffPosition;
  38186. private _newPosition;
  38187. /** @hidden */
  38188. _localDirection: Vector3;
  38189. /** @hidden */
  38190. _transformedDirection: Vector3;
  38191. /**
  38192. * Instantiates a FlyCamera.
  38193. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38194. * such as in a 3D Space Shooter or a Flight Simulator.
  38195. * @param name Define the name of the camera in the scene.
  38196. * @param position Define the starting position of the camera in the scene.
  38197. * @param scene Define the scene the camera belongs to.
  38198. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38199. */
  38200. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38201. /**
  38202. * Attach a control to the HTML DOM element.
  38203. * @param element Defines the element that listens to the input events.
  38204. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38205. */
  38206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38207. /**
  38208. * Detach a control from the HTML DOM element.
  38209. * The camera will stop reacting to that input.
  38210. * @param element Defines the element that listens to the input events.
  38211. */
  38212. detachControl(element: HTMLElement): void;
  38213. private _collisionMask;
  38214. /**
  38215. * Get the mask that the camera ignores in collision events.
  38216. */
  38217. /**
  38218. * Set the mask that the camera ignores in collision events.
  38219. */
  38220. collisionMask: number;
  38221. /** @hidden */
  38222. _collideWithWorld(displacement: Vector3): void;
  38223. /** @hidden */
  38224. private _onCollisionPositionChange;
  38225. /** @hidden */
  38226. _checkInputs(): void;
  38227. /** @hidden */
  38228. _decideIfNeedsToMove(): boolean;
  38229. /** @hidden */
  38230. _updatePosition(): void;
  38231. /**
  38232. * Restore the Roll to its target value at the rate specified.
  38233. * @param rate - Higher means slower restoring.
  38234. * @hidden
  38235. */
  38236. restoreRoll(rate: number): void;
  38237. /**
  38238. * Destroy the camera and release the current resources held by it.
  38239. */
  38240. dispose(): void;
  38241. /**
  38242. * Get the current object class name.
  38243. * @returns the class name.
  38244. */
  38245. getClassName(): string;
  38246. }
  38247. }
  38248. declare module BABYLON {
  38249. /**
  38250. * Listen to keyboard events to control the camera.
  38251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38252. */
  38253. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38254. /**
  38255. * Defines the camera the input is attached to.
  38256. */
  38257. camera: FlyCamera;
  38258. /**
  38259. * The list of keyboard keys used to control the forward move of the camera.
  38260. */
  38261. keysForward: number[];
  38262. /**
  38263. * The list of keyboard keys used to control the backward move of the camera.
  38264. */
  38265. keysBackward: number[];
  38266. /**
  38267. * The list of keyboard keys used to control the forward move of the camera.
  38268. */
  38269. keysUp: number[];
  38270. /**
  38271. * The list of keyboard keys used to control the backward move of the camera.
  38272. */
  38273. keysDown: number[];
  38274. /**
  38275. * The list of keyboard keys used to control the right strafe move of the camera.
  38276. */
  38277. keysRight: number[];
  38278. /**
  38279. * The list of keyboard keys used to control the left strafe move of the camera.
  38280. */
  38281. keysLeft: number[];
  38282. private _keys;
  38283. private _onCanvasBlurObserver;
  38284. private _onKeyboardObserver;
  38285. private _engine;
  38286. private _scene;
  38287. /**
  38288. * Attach the input controls to a specific dom element to get the input from.
  38289. * @param element Defines the element the controls should be listened from
  38290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38291. */
  38292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38293. /**
  38294. * Detach the current controls from the specified dom element.
  38295. * @param element Defines the element to stop listening the inputs from
  38296. */
  38297. detachControl(element: Nullable<HTMLElement>): void;
  38298. /**
  38299. * Gets the class name of the current intput.
  38300. * @returns the class name
  38301. */
  38302. getClassName(): string;
  38303. /** @hidden */
  38304. _onLostFocus(e: FocusEvent): void;
  38305. /**
  38306. * Get the friendly name associated with the input class.
  38307. * @returns the input friendly name
  38308. */
  38309. getSimpleName(): string;
  38310. /**
  38311. * Update the current camera state depending on the inputs that have been used this frame.
  38312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38313. */
  38314. checkInputs(): void;
  38315. }
  38316. }
  38317. declare module BABYLON {
  38318. /**
  38319. * Manage the mouse wheel inputs to control a follow camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: FollowCamera;
  38327. /**
  38328. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38329. */
  38330. axisControlRadius: boolean;
  38331. /**
  38332. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38333. */
  38334. axisControlHeight: boolean;
  38335. /**
  38336. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38337. */
  38338. axisControlRotation: boolean;
  38339. /**
  38340. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38341. * relation to mouseWheel events.
  38342. */
  38343. wheelPrecision: number;
  38344. /**
  38345. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38346. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38347. */
  38348. wheelDeltaPercentage: number;
  38349. private _wheel;
  38350. private _observer;
  38351. /**
  38352. * Attach the input controls to a specific dom element to get the input from.
  38353. * @param element Defines the element the controls should be listened from
  38354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38355. */
  38356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38357. /**
  38358. * Detach the current controls from the specified dom element.
  38359. * @param element Defines the element to stop listening the inputs from
  38360. */
  38361. detachControl(element: Nullable<HTMLElement>): void;
  38362. /**
  38363. * Gets the class name of the current intput.
  38364. * @returns the class name
  38365. */
  38366. getClassName(): string;
  38367. /**
  38368. * Get the friendly name associated with the input class.
  38369. * @returns the input friendly name
  38370. */
  38371. getSimpleName(): string;
  38372. }
  38373. }
  38374. declare module BABYLON {
  38375. /**
  38376. * Manage the pointers inputs to control an follow camera.
  38377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38378. */
  38379. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38380. /**
  38381. * Defines the camera the input is attached to.
  38382. */
  38383. camera: FollowCamera;
  38384. /**
  38385. * Gets the class name of the current input.
  38386. * @returns the class name
  38387. */
  38388. getClassName(): string;
  38389. /**
  38390. * Defines the pointer angular sensibility along the X axis or how fast is
  38391. * the camera rotating.
  38392. * A negative number will reverse the axis direction.
  38393. */
  38394. angularSensibilityX: number;
  38395. /**
  38396. * Defines the pointer angular sensibility along the Y axis or how fast is
  38397. * the camera rotating.
  38398. * A negative number will reverse the axis direction.
  38399. */
  38400. angularSensibilityY: number;
  38401. /**
  38402. * Defines the pointer pinch precision or how fast is the camera zooming.
  38403. * A negative number will reverse the axis direction.
  38404. */
  38405. pinchPrecision: number;
  38406. /**
  38407. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38408. * from 0.
  38409. * It defines the percentage of current camera.radius to use as delta when
  38410. * pinch zoom is used.
  38411. */
  38412. pinchDeltaPercentage: number;
  38413. /**
  38414. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38415. */
  38416. axisXControlRadius: boolean;
  38417. /**
  38418. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38419. */
  38420. axisXControlHeight: boolean;
  38421. /**
  38422. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38423. */
  38424. axisXControlRotation: boolean;
  38425. /**
  38426. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38427. */
  38428. axisYControlRadius: boolean;
  38429. /**
  38430. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38431. */
  38432. axisYControlHeight: boolean;
  38433. /**
  38434. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38435. */
  38436. axisYControlRotation: boolean;
  38437. /**
  38438. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38439. */
  38440. axisPinchControlRadius: boolean;
  38441. /**
  38442. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38443. */
  38444. axisPinchControlHeight: boolean;
  38445. /**
  38446. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38447. */
  38448. axisPinchControlRotation: boolean;
  38449. /**
  38450. * Log error messages if basic misconfiguration has occurred.
  38451. */
  38452. warningEnable: boolean;
  38453. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38454. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38455. private _warningCounter;
  38456. private _warning;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /**
  38461. * Default Inputs manager for the FollowCamera.
  38462. * It groups all the default supported inputs for ease of use.
  38463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38464. */
  38465. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38466. /**
  38467. * Instantiates a new FollowCameraInputsManager.
  38468. * @param camera Defines the camera the inputs belong to
  38469. */
  38470. constructor(camera: FollowCamera);
  38471. /**
  38472. * Add keyboard input support to the input manager.
  38473. * @returns the current input manager
  38474. */
  38475. addKeyboard(): FollowCameraInputsManager;
  38476. /**
  38477. * Add mouse wheel input support to the input manager.
  38478. * @returns the current input manager
  38479. */
  38480. addMouseWheel(): FollowCameraInputsManager;
  38481. /**
  38482. * Add pointers input support to the input manager.
  38483. * @returns the current input manager
  38484. */
  38485. addPointers(): FollowCameraInputsManager;
  38486. /**
  38487. * Add orientation input support to the input manager.
  38488. * @returns the current input manager
  38489. */
  38490. addVRDeviceOrientation(): FollowCameraInputsManager;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /**
  38495. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38496. * an arc rotate version arcFollowCamera are available.
  38497. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38498. */
  38499. export class FollowCamera extends TargetCamera {
  38500. /**
  38501. * Distance the follow camera should follow an object at
  38502. */
  38503. radius: number;
  38504. /**
  38505. * Minimum allowed distance of the camera to the axis of rotation
  38506. * (The camera can not get closer).
  38507. * This can help limiting how the Camera is able to move in the scene.
  38508. */
  38509. lowerRadiusLimit: Nullable<number>;
  38510. /**
  38511. * Maximum allowed distance of the camera to the axis of rotation
  38512. * (The camera can not get further).
  38513. * This can help limiting how the Camera is able to move in the scene.
  38514. */
  38515. upperRadiusLimit: Nullable<number>;
  38516. /**
  38517. * Define a rotation offset between the camera and the object it follows
  38518. */
  38519. rotationOffset: number;
  38520. /**
  38521. * Minimum allowed angle to camera position relative to target object.
  38522. * This can help limiting how the Camera is able to move in the scene.
  38523. */
  38524. lowerRotationOffsetLimit: Nullable<number>;
  38525. /**
  38526. * Maximum allowed angle to camera position relative to target object.
  38527. * This can help limiting how the Camera is able to move in the scene.
  38528. */
  38529. upperRotationOffsetLimit: Nullable<number>;
  38530. /**
  38531. * Define a height offset between the camera and the object it follows.
  38532. * It can help following an object from the top (like a car chaing a plane)
  38533. */
  38534. heightOffset: number;
  38535. /**
  38536. * Minimum allowed height of camera position relative to target object.
  38537. * This can help limiting how the Camera is able to move in the scene.
  38538. */
  38539. lowerHeightOffsetLimit: Nullable<number>;
  38540. /**
  38541. * Maximum allowed height of camera position relative to target object.
  38542. * This can help limiting how the Camera is able to move in the scene.
  38543. */
  38544. upperHeightOffsetLimit: Nullable<number>;
  38545. /**
  38546. * Define how fast the camera can accelerate to follow it s target.
  38547. */
  38548. cameraAcceleration: number;
  38549. /**
  38550. * Define the speed limit of the camera following an object.
  38551. */
  38552. maxCameraSpeed: number;
  38553. /**
  38554. * Define the target of the camera.
  38555. */
  38556. lockedTarget: Nullable<AbstractMesh>;
  38557. /**
  38558. * Defines the input associated with the camera.
  38559. */
  38560. inputs: FollowCameraInputsManager;
  38561. /**
  38562. * Instantiates the follow camera.
  38563. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38564. * @param name Define the name of the camera in the scene
  38565. * @param position Define the position of the camera
  38566. * @param scene Define the scene the camera belong to
  38567. * @param lockedTarget Define the target of the camera
  38568. */
  38569. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38570. private _follow;
  38571. /**
  38572. * Attached controls to the current camera.
  38573. * @param element Defines the element the controls should be listened from
  38574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38577. /**
  38578. * Detach the current controls from the camera.
  38579. * The camera will stop reacting to inputs.
  38580. * @param element Defines the element to stop listening the inputs from
  38581. */
  38582. detachControl(element: HTMLElement): void;
  38583. /** @hidden */
  38584. _checkInputs(): void;
  38585. private _checkLimits;
  38586. /**
  38587. * Gets the camera class name.
  38588. * @returns the class name
  38589. */
  38590. getClassName(): string;
  38591. }
  38592. /**
  38593. * Arc Rotate version of the follow camera.
  38594. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38595. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38596. */
  38597. export class ArcFollowCamera extends TargetCamera {
  38598. /** The longitudinal angle of the camera */
  38599. alpha: number;
  38600. /** The latitudinal angle of the camera */
  38601. beta: number;
  38602. /** The radius of the camera from its target */
  38603. radius: number;
  38604. /** Define the camera target (the messh it should follow) */
  38605. target: Nullable<AbstractMesh>;
  38606. private _cartesianCoordinates;
  38607. /**
  38608. * Instantiates a new ArcFollowCamera
  38609. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38610. * @param name Define the name of the camera
  38611. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38612. * @param beta Define the rotation angle of the camera around the elevation axis
  38613. * @param radius Define the radius of the camera from its target point
  38614. * @param target Define the target of the camera
  38615. * @param scene Define the scene the camera belongs to
  38616. */
  38617. constructor(name: string,
  38618. /** The longitudinal angle of the camera */
  38619. alpha: number,
  38620. /** The latitudinal angle of the camera */
  38621. beta: number,
  38622. /** The radius of the camera from its target */
  38623. radius: number,
  38624. /** Define the camera target (the messh it should follow) */
  38625. target: Nullable<AbstractMesh>, scene: Scene);
  38626. private _follow;
  38627. /** @hidden */
  38628. _checkInputs(): void;
  38629. /**
  38630. * Returns the class name of the object.
  38631. * It is mostly used internally for serialization purposes.
  38632. */
  38633. getClassName(): string;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * Manage the keyboard inputs to control the movement of a follow camera.
  38639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38640. */
  38641. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38642. /**
  38643. * Defines the camera the input is attached to.
  38644. */
  38645. camera: FollowCamera;
  38646. /**
  38647. * Defines the list of key codes associated with the up action (increase heightOffset)
  38648. */
  38649. keysHeightOffsetIncr: number[];
  38650. /**
  38651. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38652. */
  38653. keysHeightOffsetDecr: number[];
  38654. /**
  38655. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38656. */
  38657. keysHeightOffsetModifierAlt: boolean;
  38658. /**
  38659. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38660. */
  38661. keysHeightOffsetModifierCtrl: boolean;
  38662. /**
  38663. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38664. */
  38665. keysHeightOffsetModifierShift: boolean;
  38666. /**
  38667. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38668. */
  38669. keysRotationOffsetIncr: number[];
  38670. /**
  38671. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38672. */
  38673. keysRotationOffsetDecr: number[];
  38674. /**
  38675. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38676. */
  38677. keysRotationOffsetModifierAlt: boolean;
  38678. /**
  38679. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38680. */
  38681. keysRotationOffsetModifierCtrl: boolean;
  38682. /**
  38683. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38684. */
  38685. keysRotationOffsetModifierShift: boolean;
  38686. /**
  38687. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38688. */
  38689. keysRadiusIncr: number[];
  38690. /**
  38691. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38692. */
  38693. keysRadiusDecr: number[];
  38694. /**
  38695. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38696. */
  38697. keysRadiusModifierAlt: boolean;
  38698. /**
  38699. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38700. */
  38701. keysRadiusModifierCtrl: boolean;
  38702. /**
  38703. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38704. */
  38705. keysRadiusModifierShift: boolean;
  38706. /**
  38707. * Defines the rate of change of heightOffset.
  38708. */
  38709. heightSensibility: number;
  38710. /**
  38711. * Defines the rate of change of rotationOffset.
  38712. */
  38713. rotationSensibility: number;
  38714. /**
  38715. * Defines the rate of change of radius.
  38716. */
  38717. radiusSensibility: number;
  38718. private _keys;
  38719. private _ctrlPressed;
  38720. private _altPressed;
  38721. private _shiftPressed;
  38722. private _onCanvasBlurObserver;
  38723. private _onKeyboardObserver;
  38724. private _engine;
  38725. private _scene;
  38726. /**
  38727. * Attach the input controls to a specific dom element to get the input from.
  38728. * @param element Defines the element the controls should be listened from
  38729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /**
  38733. * Detach the current controls from the specified dom element.
  38734. * @param element Defines the element to stop listening the inputs from
  38735. */
  38736. detachControl(element: Nullable<HTMLElement>): void;
  38737. /**
  38738. * Update the current camera state depending on the inputs that have been used this frame.
  38739. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38740. */
  38741. checkInputs(): void;
  38742. /**
  38743. * Gets the class name of the current input.
  38744. * @returns the class name
  38745. */
  38746. getClassName(): string;
  38747. /**
  38748. * Get the friendly name associated with the input class.
  38749. * @returns the input friendly name
  38750. */
  38751. getSimpleName(): string;
  38752. /**
  38753. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38754. * allow modification of the heightOffset value.
  38755. */
  38756. private _modifierHeightOffset;
  38757. /**
  38758. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38759. * allow modification of the rotationOffset value.
  38760. */
  38761. private _modifierRotationOffset;
  38762. /**
  38763. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38764. * allow modification of the radius value.
  38765. */
  38766. private _modifierRadius;
  38767. }
  38768. }
  38769. declare module BABYLON {
  38770. interface FreeCameraInputsManager {
  38771. /**
  38772. * @hidden
  38773. */
  38774. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38775. /**
  38776. * Add orientation input support to the input manager.
  38777. * @returns the current input manager
  38778. */
  38779. addDeviceOrientation(): FreeCameraInputsManager;
  38780. }
  38781. /**
  38782. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38783. * Screen rotation is taken into account.
  38784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38785. */
  38786. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38787. private _camera;
  38788. private _screenOrientationAngle;
  38789. private _constantTranform;
  38790. private _screenQuaternion;
  38791. private _alpha;
  38792. private _beta;
  38793. private _gamma;
  38794. /**
  38795. * Can be used to detect if a device orientation sensor is availible on a device
  38796. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38797. * @returns a promise that will resolve on orientation change
  38798. */
  38799. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38800. /**
  38801. * @hidden
  38802. */
  38803. _onDeviceOrientationChangedObservable: Observable<void>;
  38804. /**
  38805. * Instantiates a new input
  38806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38807. */
  38808. constructor();
  38809. /**
  38810. * Define the camera controlled by the input.
  38811. */
  38812. camera: FreeCamera;
  38813. /**
  38814. * Attach the input controls to a specific dom element to get the input from.
  38815. * @param element Defines the element the controls should be listened from
  38816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38817. */
  38818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38819. private _orientationChanged;
  38820. private _deviceOrientation;
  38821. /**
  38822. * Detach the current controls from the specified dom element.
  38823. * @param element Defines the element to stop listening the inputs from
  38824. */
  38825. detachControl(element: Nullable<HTMLElement>): void;
  38826. /**
  38827. * Update the current camera state depending on the inputs that have been used this frame.
  38828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38829. */
  38830. checkInputs(): void;
  38831. /**
  38832. * Gets the class name of the current intput.
  38833. * @returns the class name
  38834. */
  38835. getClassName(): string;
  38836. /**
  38837. * Get the friendly name associated with the input class.
  38838. * @returns the input friendly name
  38839. */
  38840. getSimpleName(): string;
  38841. }
  38842. }
  38843. declare module BABYLON {
  38844. /**
  38845. * Manage the gamepad inputs to control a free camera.
  38846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38847. */
  38848. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38849. /**
  38850. * Define the camera the input is attached to.
  38851. */
  38852. camera: FreeCamera;
  38853. /**
  38854. * Define the Gamepad controlling the input
  38855. */
  38856. gamepad: Nullable<Gamepad>;
  38857. /**
  38858. * Defines the gamepad rotation sensiblity.
  38859. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38860. */
  38861. gamepadAngularSensibility: number;
  38862. /**
  38863. * Defines the gamepad move sensiblity.
  38864. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38865. */
  38866. gamepadMoveSensibility: number;
  38867. private _yAxisScale;
  38868. /**
  38869. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38870. */
  38871. invertYAxis: boolean;
  38872. private _onGamepadConnectedObserver;
  38873. private _onGamepadDisconnectedObserver;
  38874. private _cameraTransform;
  38875. private _deltaTransform;
  38876. private _vector3;
  38877. private _vector2;
  38878. /**
  38879. * Attach the input controls to a specific dom element to get the input from.
  38880. * @param element Defines the element the controls should be listened from
  38881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38882. */
  38883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38884. /**
  38885. * Detach the current controls from the specified dom element.
  38886. * @param element Defines the element to stop listening the inputs from
  38887. */
  38888. detachControl(element: Nullable<HTMLElement>): void;
  38889. /**
  38890. * Update the current camera state depending on the inputs that have been used this frame.
  38891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38892. */
  38893. checkInputs(): void;
  38894. /**
  38895. * Gets the class name of the current intput.
  38896. * @returns the class name
  38897. */
  38898. getClassName(): string;
  38899. /**
  38900. * Get the friendly name associated with the input class.
  38901. * @returns the input friendly name
  38902. */
  38903. getSimpleName(): string;
  38904. }
  38905. }
  38906. declare module BABYLON {
  38907. /**
  38908. * Defines the potential axis of a Joystick
  38909. */
  38910. export enum JoystickAxis {
  38911. /** X axis */
  38912. X = 0,
  38913. /** Y axis */
  38914. Y = 1,
  38915. /** Z axis */
  38916. Z = 2
  38917. }
  38918. /**
  38919. * Class used to define virtual joystick (used in touch mode)
  38920. */
  38921. export class VirtualJoystick {
  38922. /**
  38923. * Gets or sets a boolean indicating that left and right values must be inverted
  38924. */
  38925. reverseLeftRight: boolean;
  38926. /**
  38927. * Gets or sets a boolean indicating that up and down values must be inverted
  38928. */
  38929. reverseUpDown: boolean;
  38930. /**
  38931. * Gets the offset value for the position (ie. the change of the position value)
  38932. */
  38933. deltaPosition: Vector3;
  38934. /**
  38935. * Gets a boolean indicating if the virtual joystick was pressed
  38936. */
  38937. pressed: boolean;
  38938. /**
  38939. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38940. */
  38941. static Canvas: Nullable<HTMLCanvasElement>;
  38942. private static _globalJoystickIndex;
  38943. private static vjCanvasContext;
  38944. private static vjCanvasWidth;
  38945. private static vjCanvasHeight;
  38946. private static halfWidth;
  38947. private _action;
  38948. private _axisTargetedByLeftAndRight;
  38949. private _axisTargetedByUpAndDown;
  38950. private _joystickSensibility;
  38951. private _inversedSensibility;
  38952. private _joystickPointerID;
  38953. private _joystickColor;
  38954. private _joystickPointerPos;
  38955. private _joystickPreviousPointerPos;
  38956. private _joystickPointerStartPos;
  38957. private _deltaJoystickVector;
  38958. private _leftJoystick;
  38959. private _touches;
  38960. private _onPointerDownHandlerRef;
  38961. private _onPointerMoveHandlerRef;
  38962. private _onPointerUpHandlerRef;
  38963. private _onResize;
  38964. /**
  38965. * Creates a new virtual joystick
  38966. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38967. */
  38968. constructor(leftJoystick?: boolean);
  38969. /**
  38970. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38971. * @param newJoystickSensibility defines the new sensibility
  38972. */
  38973. setJoystickSensibility(newJoystickSensibility: number): void;
  38974. private _onPointerDown;
  38975. private _onPointerMove;
  38976. private _onPointerUp;
  38977. /**
  38978. * Change the color of the virtual joystick
  38979. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38980. */
  38981. setJoystickColor(newColor: string): void;
  38982. /**
  38983. * Defines a callback to call when the joystick is touched
  38984. * @param action defines the callback
  38985. */
  38986. setActionOnTouch(action: () => any): void;
  38987. /**
  38988. * Defines which axis you'd like to control for left & right
  38989. * @param axis defines the axis to use
  38990. */
  38991. setAxisForLeftRight(axis: JoystickAxis): void;
  38992. /**
  38993. * Defines which axis you'd like to control for up & down
  38994. * @param axis defines the axis to use
  38995. */
  38996. setAxisForUpDown(axis: JoystickAxis): void;
  38997. private _drawVirtualJoystick;
  38998. /**
  38999. * Release internal HTML canvas
  39000. */
  39001. releaseCanvas(): void;
  39002. }
  39003. }
  39004. declare module BABYLON {
  39005. interface FreeCameraInputsManager {
  39006. /**
  39007. * Add virtual joystick input support to the input manager.
  39008. * @returns the current input manager
  39009. */
  39010. addVirtualJoystick(): FreeCameraInputsManager;
  39011. }
  39012. /**
  39013. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39015. */
  39016. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39017. /**
  39018. * Defines the camera the input is attached to.
  39019. */
  39020. camera: FreeCamera;
  39021. private _leftjoystick;
  39022. private _rightjoystick;
  39023. /**
  39024. * Gets the left stick of the virtual joystick.
  39025. * @returns The virtual Joystick
  39026. */
  39027. getLeftJoystick(): VirtualJoystick;
  39028. /**
  39029. * Gets the right stick of the virtual joystick.
  39030. * @returns The virtual Joystick
  39031. */
  39032. getRightJoystick(): VirtualJoystick;
  39033. /**
  39034. * Update the current camera state depending on the inputs that have been used this frame.
  39035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39036. */
  39037. checkInputs(): void;
  39038. /**
  39039. * Attach the input controls to a specific dom element to get the input from.
  39040. * @param element Defines the element the controls should be listened from
  39041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39042. */
  39043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39044. /**
  39045. * Detach the current controls from the specified dom element.
  39046. * @param element Defines the element to stop listening the inputs from
  39047. */
  39048. detachControl(element: Nullable<HTMLElement>): void;
  39049. /**
  39050. * Gets the class name of the current intput.
  39051. * @returns the class name
  39052. */
  39053. getClassName(): string;
  39054. /**
  39055. * Get the friendly name associated with the input class.
  39056. * @returns the input friendly name
  39057. */
  39058. getSimpleName(): string;
  39059. }
  39060. }
  39061. declare module BABYLON {
  39062. /**
  39063. * This represents a FPS type of camera controlled by touch.
  39064. * This is like a universal camera minus the Gamepad controls.
  39065. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39066. */
  39067. export class TouchCamera extends FreeCamera {
  39068. /**
  39069. * Defines the touch sensibility for rotation.
  39070. * The higher the faster.
  39071. */
  39072. touchAngularSensibility: number;
  39073. /**
  39074. * Defines the touch sensibility for move.
  39075. * The higher the faster.
  39076. */
  39077. touchMoveSensibility: number;
  39078. /**
  39079. * Instantiates a new touch camera.
  39080. * This represents a FPS type of camera controlled by touch.
  39081. * This is like a universal camera minus the Gamepad controls.
  39082. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39083. * @param name Define the name of the camera in the scene
  39084. * @param position Define the start position of the camera in the scene
  39085. * @param scene Define the scene the camera belongs to
  39086. */
  39087. constructor(name: string, position: Vector3, scene: Scene);
  39088. /**
  39089. * Gets the current object class name.
  39090. * @return the class name
  39091. */
  39092. getClassName(): string;
  39093. /** @hidden */
  39094. _setupInputs(): void;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39100. * being tilted forward or back and left or right.
  39101. */
  39102. export class DeviceOrientationCamera extends FreeCamera {
  39103. private _initialQuaternion;
  39104. private _quaternionCache;
  39105. private _tmpDragQuaternion;
  39106. private _disablePointerInputWhenUsingDeviceOrientation;
  39107. /**
  39108. * Creates a new device orientation camera
  39109. * @param name The name of the camera
  39110. * @param position The start position camera
  39111. * @param scene The scene the camera belongs to
  39112. */
  39113. constructor(name: string, position: Vector3, scene: Scene);
  39114. /**
  39115. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39116. */
  39117. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39118. private _dragFactor;
  39119. /**
  39120. * Enabled turning on the y axis when the orientation sensor is active
  39121. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39122. */
  39123. enableHorizontalDragging(dragFactor?: number): void;
  39124. /**
  39125. * Gets the current instance class name ("DeviceOrientationCamera").
  39126. * This helps avoiding instanceof at run time.
  39127. * @returns the class name
  39128. */
  39129. getClassName(): string;
  39130. /**
  39131. * @hidden
  39132. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39133. */
  39134. _checkInputs(): void;
  39135. /**
  39136. * Reset the camera to its default orientation on the specified axis only.
  39137. * @param axis The axis to reset
  39138. */
  39139. resetToCurrentRotation(axis?: Axis): void;
  39140. }
  39141. }
  39142. declare module BABYLON {
  39143. /**
  39144. * Defines supported buttons for XBox360 compatible gamepads
  39145. */
  39146. export enum Xbox360Button {
  39147. /** A */
  39148. A = 0,
  39149. /** B */
  39150. B = 1,
  39151. /** X */
  39152. X = 2,
  39153. /** Y */
  39154. Y = 3,
  39155. /** Start */
  39156. Start = 4,
  39157. /** Back */
  39158. Back = 5,
  39159. /** Left button */
  39160. LB = 6,
  39161. /** Right button */
  39162. RB = 7,
  39163. /** Left stick */
  39164. LeftStick = 8,
  39165. /** Right stick */
  39166. RightStick = 9
  39167. }
  39168. /** Defines values for XBox360 DPad */
  39169. export enum Xbox360Dpad {
  39170. /** Up */
  39171. Up = 0,
  39172. /** Down */
  39173. Down = 1,
  39174. /** Left */
  39175. Left = 2,
  39176. /** Right */
  39177. Right = 3
  39178. }
  39179. /**
  39180. * Defines a XBox360 gamepad
  39181. */
  39182. export class Xbox360Pad extends Gamepad {
  39183. private _leftTrigger;
  39184. private _rightTrigger;
  39185. private _onlefttriggerchanged;
  39186. private _onrighttriggerchanged;
  39187. private _onbuttondown;
  39188. private _onbuttonup;
  39189. private _ondpaddown;
  39190. private _ondpadup;
  39191. /** Observable raised when a button is pressed */
  39192. onButtonDownObservable: Observable<Xbox360Button>;
  39193. /** Observable raised when a button is released */
  39194. onButtonUpObservable: Observable<Xbox360Button>;
  39195. /** Observable raised when a pad is pressed */
  39196. onPadDownObservable: Observable<Xbox360Dpad>;
  39197. /** Observable raised when a pad is released */
  39198. onPadUpObservable: Observable<Xbox360Dpad>;
  39199. private _buttonA;
  39200. private _buttonB;
  39201. private _buttonX;
  39202. private _buttonY;
  39203. private _buttonBack;
  39204. private _buttonStart;
  39205. private _buttonLB;
  39206. private _buttonRB;
  39207. private _buttonLeftStick;
  39208. private _buttonRightStick;
  39209. private _dPadUp;
  39210. private _dPadDown;
  39211. private _dPadLeft;
  39212. private _dPadRight;
  39213. private _isXboxOnePad;
  39214. /**
  39215. * Creates a new XBox360 gamepad object
  39216. * @param id defines the id of this gamepad
  39217. * @param index defines its index
  39218. * @param gamepad defines the internal HTML gamepad object
  39219. * @param xboxOne defines if it is a XBox One gamepad
  39220. */
  39221. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39222. /**
  39223. * Defines the callback to call when left trigger is pressed
  39224. * @param callback defines the callback to use
  39225. */
  39226. onlefttriggerchanged(callback: (value: number) => void): void;
  39227. /**
  39228. * Defines the callback to call when right trigger is pressed
  39229. * @param callback defines the callback to use
  39230. */
  39231. onrighttriggerchanged(callback: (value: number) => void): void;
  39232. /**
  39233. * Gets the left trigger value
  39234. */
  39235. /**
  39236. * Sets the left trigger value
  39237. */
  39238. leftTrigger: number;
  39239. /**
  39240. * Gets the right trigger value
  39241. */
  39242. /**
  39243. * Sets the right trigger value
  39244. */
  39245. rightTrigger: number;
  39246. /**
  39247. * Defines the callback to call when a button is pressed
  39248. * @param callback defines the callback to use
  39249. */
  39250. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39251. /**
  39252. * Defines the callback to call when a button is released
  39253. * @param callback defines the callback to use
  39254. */
  39255. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39256. /**
  39257. * Defines the callback to call when a pad is pressed
  39258. * @param callback defines the callback to use
  39259. */
  39260. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39261. /**
  39262. * Defines the callback to call when a pad is released
  39263. * @param callback defines the callback to use
  39264. */
  39265. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39266. private _setButtonValue;
  39267. private _setDPadValue;
  39268. /**
  39269. * Gets the value of the `A` button
  39270. */
  39271. /**
  39272. * Sets the value of the `A` button
  39273. */
  39274. buttonA: number;
  39275. /**
  39276. * Gets the value of the `B` button
  39277. */
  39278. /**
  39279. * Sets the value of the `B` button
  39280. */
  39281. buttonB: number;
  39282. /**
  39283. * Gets the value of the `X` button
  39284. */
  39285. /**
  39286. * Sets the value of the `X` button
  39287. */
  39288. buttonX: number;
  39289. /**
  39290. * Gets the value of the `Y` button
  39291. */
  39292. /**
  39293. * Sets the value of the `Y` button
  39294. */
  39295. buttonY: number;
  39296. /**
  39297. * Gets the value of the `Start` button
  39298. */
  39299. /**
  39300. * Sets the value of the `Start` button
  39301. */
  39302. buttonStart: number;
  39303. /**
  39304. * Gets the value of the `Back` button
  39305. */
  39306. /**
  39307. * Sets the value of the `Back` button
  39308. */
  39309. buttonBack: number;
  39310. /**
  39311. * Gets the value of the `Left` button
  39312. */
  39313. /**
  39314. * Sets the value of the `Left` button
  39315. */
  39316. buttonLB: number;
  39317. /**
  39318. * Gets the value of the `Right` button
  39319. */
  39320. /**
  39321. * Sets the value of the `Right` button
  39322. */
  39323. buttonRB: number;
  39324. /**
  39325. * Gets the value of the Left joystick
  39326. */
  39327. /**
  39328. * Sets the value of the Left joystick
  39329. */
  39330. buttonLeftStick: number;
  39331. /**
  39332. * Gets the value of the Right joystick
  39333. */
  39334. /**
  39335. * Sets the value of the Right joystick
  39336. */
  39337. buttonRightStick: number;
  39338. /**
  39339. * Gets the value of D-pad up
  39340. */
  39341. /**
  39342. * Sets the value of D-pad up
  39343. */
  39344. dPadUp: number;
  39345. /**
  39346. * Gets the value of D-pad down
  39347. */
  39348. /**
  39349. * Sets the value of D-pad down
  39350. */
  39351. dPadDown: number;
  39352. /**
  39353. * Gets the value of D-pad left
  39354. */
  39355. /**
  39356. * Sets the value of D-pad left
  39357. */
  39358. dPadLeft: number;
  39359. /**
  39360. * Gets the value of D-pad right
  39361. */
  39362. /**
  39363. * Sets the value of D-pad right
  39364. */
  39365. dPadRight: number;
  39366. /**
  39367. * Force the gamepad to synchronize with device values
  39368. */
  39369. update(): void;
  39370. /**
  39371. * Disposes the gamepad
  39372. */
  39373. dispose(): void;
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. /**
  39378. * Defines supported buttons for DualShock compatible gamepads
  39379. */
  39380. export enum DualShockButton {
  39381. /** Cross */
  39382. Cross = 0,
  39383. /** Circle */
  39384. Circle = 1,
  39385. /** Square */
  39386. Square = 2,
  39387. /** Triangle */
  39388. Triangle = 3,
  39389. /** Options */
  39390. Options = 4,
  39391. /** Share */
  39392. Share = 5,
  39393. /** L1 */
  39394. L1 = 6,
  39395. /** R1 */
  39396. R1 = 7,
  39397. /** Left stick */
  39398. LeftStick = 8,
  39399. /** Right stick */
  39400. RightStick = 9
  39401. }
  39402. /** Defines values for DualShock DPad */
  39403. export enum DualShockDpad {
  39404. /** Up */
  39405. Up = 0,
  39406. /** Down */
  39407. Down = 1,
  39408. /** Left */
  39409. Left = 2,
  39410. /** Right */
  39411. Right = 3
  39412. }
  39413. /**
  39414. * Defines a DualShock gamepad
  39415. */
  39416. export class DualShockPad extends Gamepad {
  39417. private _leftTrigger;
  39418. private _rightTrigger;
  39419. private _onlefttriggerchanged;
  39420. private _onrighttriggerchanged;
  39421. private _onbuttondown;
  39422. private _onbuttonup;
  39423. private _ondpaddown;
  39424. private _ondpadup;
  39425. /** Observable raised when a button is pressed */
  39426. onButtonDownObservable: Observable<DualShockButton>;
  39427. /** Observable raised when a button is released */
  39428. onButtonUpObservable: Observable<DualShockButton>;
  39429. /** Observable raised when a pad is pressed */
  39430. onPadDownObservable: Observable<DualShockDpad>;
  39431. /** Observable raised when a pad is released */
  39432. onPadUpObservable: Observable<DualShockDpad>;
  39433. private _buttonCross;
  39434. private _buttonCircle;
  39435. private _buttonSquare;
  39436. private _buttonTriangle;
  39437. private _buttonShare;
  39438. private _buttonOptions;
  39439. private _buttonL1;
  39440. private _buttonR1;
  39441. private _buttonLeftStick;
  39442. private _buttonRightStick;
  39443. private _dPadUp;
  39444. private _dPadDown;
  39445. private _dPadLeft;
  39446. private _dPadRight;
  39447. /**
  39448. * Creates a new DualShock gamepad object
  39449. * @param id defines the id of this gamepad
  39450. * @param index defines its index
  39451. * @param gamepad defines the internal HTML gamepad object
  39452. */
  39453. constructor(id: string, index: number, gamepad: any);
  39454. /**
  39455. * Defines the callback to call when left trigger is pressed
  39456. * @param callback defines the callback to use
  39457. */
  39458. onlefttriggerchanged(callback: (value: number) => void): void;
  39459. /**
  39460. * Defines the callback to call when right trigger is pressed
  39461. * @param callback defines the callback to use
  39462. */
  39463. onrighttriggerchanged(callback: (value: number) => void): void;
  39464. /**
  39465. * Gets the left trigger value
  39466. */
  39467. /**
  39468. * Sets the left trigger value
  39469. */
  39470. leftTrigger: number;
  39471. /**
  39472. * Gets the right trigger value
  39473. */
  39474. /**
  39475. * Sets the right trigger value
  39476. */
  39477. rightTrigger: number;
  39478. /**
  39479. * Defines the callback to call when a button is pressed
  39480. * @param callback defines the callback to use
  39481. */
  39482. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39483. /**
  39484. * Defines the callback to call when a button is released
  39485. * @param callback defines the callback to use
  39486. */
  39487. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39488. /**
  39489. * Defines the callback to call when a pad is pressed
  39490. * @param callback defines the callback to use
  39491. */
  39492. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39493. /**
  39494. * Defines the callback to call when a pad is released
  39495. * @param callback defines the callback to use
  39496. */
  39497. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39498. private _setButtonValue;
  39499. private _setDPadValue;
  39500. /**
  39501. * Gets the value of the `Cross` button
  39502. */
  39503. /**
  39504. * Sets the value of the `Cross` button
  39505. */
  39506. buttonCross: number;
  39507. /**
  39508. * Gets the value of the `Circle` button
  39509. */
  39510. /**
  39511. * Sets the value of the `Circle` button
  39512. */
  39513. buttonCircle: number;
  39514. /**
  39515. * Gets the value of the `Square` button
  39516. */
  39517. /**
  39518. * Sets the value of the `Square` button
  39519. */
  39520. buttonSquare: number;
  39521. /**
  39522. * Gets the value of the `Triangle` button
  39523. */
  39524. /**
  39525. * Sets the value of the `Triangle` button
  39526. */
  39527. buttonTriangle: number;
  39528. /**
  39529. * Gets the value of the `Options` button
  39530. */
  39531. /**
  39532. * Sets the value of the `Options` button
  39533. */
  39534. buttonOptions: number;
  39535. /**
  39536. * Gets the value of the `Share` button
  39537. */
  39538. /**
  39539. * Sets the value of the `Share` button
  39540. */
  39541. buttonShare: number;
  39542. /**
  39543. * Gets the value of the `L1` button
  39544. */
  39545. /**
  39546. * Sets the value of the `L1` button
  39547. */
  39548. buttonL1: number;
  39549. /**
  39550. * Gets the value of the `R1` button
  39551. */
  39552. /**
  39553. * Sets the value of the `R1` button
  39554. */
  39555. buttonR1: number;
  39556. /**
  39557. * Gets the value of the Left joystick
  39558. */
  39559. /**
  39560. * Sets the value of the Left joystick
  39561. */
  39562. buttonLeftStick: number;
  39563. /**
  39564. * Gets the value of the Right joystick
  39565. */
  39566. /**
  39567. * Sets the value of the Right joystick
  39568. */
  39569. buttonRightStick: number;
  39570. /**
  39571. * Gets the value of D-pad up
  39572. */
  39573. /**
  39574. * Sets the value of D-pad up
  39575. */
  39576. dPadUp: number;
  39577. /**
  39578. * Gets the value of D-pad down
  39579. */
  39580. /**
  39581. * Sets the value of D-pad down
  39582. */
  39583. dPadDown: number;
  39584. /**
  39585. * Gets the value of D-pad left
  39586. */
  39587. /**
  39588. * Sets the value of D-pad left
  39589. */
  39590. dPadLeft: number;
  39591. /**
  39592. * Gets the value of D-pad right
  39593. */
  39594. /**
  39595. * Sets the value of D-pad right
  39596. */
  39597. dPadRight: number;
  39598. /**
  39599. * Force the gamepad to synchronize with device values
  39600. */
  39601. update(): void;
  39602. /**
  39603. * Disposes the gamepad
  39604. */
  39605. dispose(): void;
  39606. }
  39607. }
  39608. declare module BABYLON {
  39609. /**
  39610. * Manager for handling gamepads
  39611. */
  39612. export class GamepadManager {
  39613. private _scene?;
  39614. private _babylonGamepads;
  39615. private _oneGamepadConnected;
  39616. /** @hidden */
  39617. _isMonitoring: boolean;
  39618. private _gamepadEventSupported;
  39619. private _gamepadSupport;
  39620. /**
  39621. * observable to be triggered when the gamepad controller has been connected
  39622. */
  39623. onGamepadConnectedObservable: Observable<Gamepad>;
  39624. /**
  39625. * observable to be triggered when the gamepad controller has been disconnected
  39626. */
  39627. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39628. private _onGamepadConnectedEvent;
  39629. private _onGamepadDisconnectedEvent;
  39630. /**
  39631. * Initializes the gamepad manager
  39632. * @param _scene BabylonJS scene
  39633. */
  39634. constructor(_scene?: Scene | undefined);
  39635. /**
  39636. * The gamepads in the game pad manager
  39637. */
  39638. readonly gamepads: Gamepad[];
  39639. /**
  39640. * Get the gamepad controllers based on type
  39641. * @param type The type of gamepad controller
  39642. * @returns Nullable gamepad
  39643. */
  39644. getGamepadByType(type?: number): Nullable<Gamepad>;
  39645. /**
  39646. * Disposes the gamepad manager
  39647. */
  39648. dispose(): void;
  39649. private _addNewGamepad;
  39650. private _startMonitoringGamepads;
  39651. private _stopMonitoringGamepads;
  39652. /** @hidden */
  39653. _checkGamepadsStatus(): void;
  39654. private _updateGamepadObjects;
  39655. }
  39656. }
  39657. declare module BABYLON {
  39658. interface Scene {
  39659. /** @hidden */
  39660. _gamepadManager: Nullable<GamepadManager>;
  39661. /**
  39662. * Gets the gamepad manager associated with the scene
  39663. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39664. */
  39665. gamepadManager: GamepadManager;
  39666. }
  39667. /**
  39668. * Interface representing a free camera inputs manager
  39669. */
  39670. interface FreeCameraInputsManager {
  39671. /**
  39672. * Adds gamepad input support to the FreeCameraInputsManager.
  39673. * @returns the FreeCameraInputsManager
  39674. */
  39675. addGamepad(): FreeCameraInputsManager;
  39676. }
  39677. /**
  39678. * Interface representing an arc rotate camera inputs manager
  39679. */
  39680. interface ArcRotateCameraInputsManager {
  39681. /**
  39682. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39683. * @returns the camera inputs manager
  39684. */
  39685. addGamepad(): ArcRotateCameraInputsManager;
  39686. }
  39687. /**
  39688. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39689. */
  39690. export class GamepadSystemSceneComponent implements ISceneComponent {
  39691. /**
  39692. * The component name helpfull to identify the component in the list of scene components.
  39693. */
  39694. readonly name: string;
  39695. /**
  39696. * The scene the component belongs to.
  39697. */
  39698. scene: Scene;
  39699. /**
  39700. * Creates a new instance of the component for the given scene
  39701. * @param scene Defines the scene to register the component in
  39702. */
  39703. constructor(scene: Scene);
  39704. /**
  39705. * Registers the component in a given scene
  39706. */
  39707. register(): void;
  39708. /**
  39709. * Rebuilds the elements related to this component in case of
  39710. * context lost for instance.
  39711. */
  39712. rebuild(): void;
  39713. /**
  39714. * Disposes the component and the associated ressources
  39715. */
  39716. dispose(): void;
  39717. private _beforeCameraUpdate;
  39718. }
  39719. }
  39720. declare module BABYLON {
  39721. /**
  39722. * 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,
  39723. * which still works and will still be found in many Playgrounds.
  39724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39725. */
  39726. export class UniversalCamera extends TouchCamera {
  39727. /**
  39728. * Defines the gamepad rotation sensiblity.
  39729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39730. */
  39731. gamepadAngularSensibility: number;
  39732. /**
  39733. * Defines the gamepad move sensiblity.
  39734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39735. */
  39736. gamepadMoveSensibility: number;
  39737. /**
  39738. * 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,
  39739. * which still works and will still be found in many Playgrounds.
  39740. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39741. * @param name Define the name of the camera in the scene
  39742. * @param position Define the start position of the camera in the scene
  39743. * @param scene Define the scene the camera belongs to
  39744. */
  39745. constructor(name: string, position: Vector3, scene: Scene);
  39746. /**
  39747. * Gets the current object class name.
  39748. * @return the class name
  39749. */
  39750. getClassName(): string;
  39751. }
  39752. }
  39753. declare module BABYLON {
  39754. /**
  39755. * This represents a FPS type of camera. This is only here for back compat purpose.
  39756. * Please use the UniversalCamera instead as both are identical.
  39757. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39758. */
  39759. export class GamepadCamera extends UniversalCamera {
  39760. /**
  39761. * Instantiates a new Gamepad Camera
  39762. * This represents a FPS type of camera. This is only here for back compat purpose.
  39763. * Please use the UniversalCamera instead as both are identical.
  39764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39765. * @param name Define the name of the camera in the scene
  39766. * @param position Define the start position of the camera in the scene
  39767. * @param scene Define the scene the camera belongs to
  39768. */
  39769. constructor(name: string, position: Vector3, scene: Scene);
  39770. /**
  39771. * Gets the current object class name.
  39772. * @return the class name
  39773. */
  39774. getClassName(): string;
  39775. }
  39776. }
  39777. declare module BABYLON {
  39778. /** @hidden */
  39779. export var passPixelShader: {
  39780. name: string;
  39781. shader: string;
  39782. };
  39783. }
  39784. declare module BABYLON {
  39785. /** @hidden */
  39786. export var passCubePixelShader: {
  39787. name: string;
  39788. shader: string;
  39789. };
  39790. }
  39791. declare module BABYLON {
  39792. /**
  39793. * PassPostProcess which produces an output the same as it's input
  39794. */
  39795. export class PassPostProcess extends PostProcess {
  39796. /**
  39797. * Creates the PassPostProcess
  39798. * @param name The name of the effect.
  39799. * @param options The required width/height ratio to downsize to before computing the render pass.
  39800. * @param camera The camera to apply the render pass to.
  39801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39802. * @param engine The engine which the post process will be applied. (default: current engine)
  39803. * @param reusable If the post process can be reused on the same frame. (default: false)
  39804. * @param textureType The type of texture to be used when performing the post processing.
  39805. * @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)
  39806. */
  39807. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39808. }
  39809. /**
  39810. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39811. */
  39812. export class PassCubePostProcess extends PostProcess {
  39813. private _face;
  39814. /**
  39815. * Gets or sets the cube face to display.
  39816. * * 0 is +X
  39817. * * 1 is -X
  39818. * * 2 is +Y
  39819. * * 3 is -Y
  39820. * * 4 is +Z
  39821. * * 5 is -Z
  39822. */
  39823. face: number;
  39824. /**
  39825. * Creates the PassCubePostProcess
  39826. * @param name The name of the effect.
  39827. * @param options The required width/height ratio to downsize to before computing the render pass.
  39828. * @param camera The camera to apply the render pass to.
  39829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39830. * @param engine The engine which the post process will be applied. (default: current engine)
  39831. * @param reusable If the post process can be reused on the same frame. (default: false)
  39832. * @param textureType The type of texture to be used when performing the post processing.
  39833. * @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)
  39834. */
  39835. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39836. }
  39837. }
  39838. declare module BABYLON {
  39839. /** @hidden */
  39840. export var anaglyphPixelShader: {
  39841. name: string;
  39842. shader: string;
  39843. };
  39844. }
  39845. declare module BABYLON {
  39846. /**
  39847. * Postprocess used to generate anaglyphic rendering
  39848. */
  39849. export class AnaglyphPostProcess extends PostProcess {
  39850. private _passedProcess;
  39851. /**
  39852. * Creates a new AnaglyphPostProcess
  39853. * @param name defines postprocess name
  39854. * @param options defines creation options or target ratio scale
  39855. * @param rigCameras defines cameras using this postprocess
  39856. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39857. * @param engine defines hosting engine
  39858. * @param reusable defines if the postprocess will be reused multiple times per frame
  39859. */
  39860. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39861. }
  39862. }
  39863. declare module BABYLON {
  39864. /**
  39865. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39866. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39867. */
  39868. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39869. /**
  39870. * Creates a new AnaglyphArcRotateCamera
  39871. * @param name defines camera name
  39872. * @param alpha defines alpha angle (in radians)
  39873. * @param beta defines beta angle (in radians)
  39874. * @param radius defines radius
  39875. * @param target defines camera target
  39876. * @param interaxialDistance defines distance between each color axis
  39877. * @param scene defines the hosting scene
  39878. */
  39879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39880. /**
  39881. * Gets camera class name
  39882. * @returns AnaglyphArcRotateCamera
  39883. */
  39884. getClassName(): string;
  39885. }
  39886. }
  39887. declare module BABYLON {
  39888. /**
  39889. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39890. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39891. */
  39892. export class AnaglyphFreeCamera extends FreeCamera {
  39893. /**
  39894. * Creates a new AnaglyphFreeCamera
  39895. * @param name defines camera name
  39896. * @param position defines initial position
  39897. * @param interaxialDistance defines distance between each color axis
  39898. * @param scene defines the hosting scene
  39899. */
  39900. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39901. /**
  39902. * Gets camera class name
  39903. * @returns AnaglyphFreeCamera
  39904. */
  39905. getClassName(): string;
  39906. }
  39907. }
  39908. declare module BABYLON {
  39909. /**
  39910. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39911. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39912. */
  39913. export class AnaglyphGamepadCamera extends GamepadCamera {
  39914. /**
  39915. * Creates a new AnaglyphGamepadCamera
  39916. * @param name defines camera name
  39917. * @param position defines initial position
  39918. * @param interaxialDistance defines distance between each color axis
  39919. * @param scene defines the hosting scene
  39920. */
  39921. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39922. /**
  39923. * Gets camera class name
  39924. * @returns AnaglyphGamepadCamera
  39925. */
  39926. getClassName(): string;
  39927. }
  39928. }
  39929. declare module BABYLON {
  39930. /**
  39931. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39932. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39933. */
  39934. export class AnaglyphUniversalCamera extends UniversalCamera {
  39935. /**
  39936. * Creates a new AnaglyphUniversalCamera
  39937. * @param name defines camera name
  39938. * @param position defines initial position
  39939. * @param interaxialDistance defines distance between each color axis
  39940. * @param scene defines the hosting scene
  39941. */
  39942. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39943. /**
  39944. * Gets camera class name
  39945. * @returns AnaglyphUniversalCamera
  39946. */
  39947. getClassName(): string;
  39948. }
  39949. }
  39950. declare module BABYLON {
  39951. /** @hidden */
  39952. export var stereoscopicInterlacePixelShader: {
  39953. name: string;
  39954. shader: string;
  39955. };
  39956. }
  39957. declare module BABYLON {
  39958. /**
  39959. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39960. */
  39961. export class StereoscopicInterlacePostProcess extends PostProcess {
  39962. private _stepSize;
  39963. private _passedProcess;
  39964. /**
  39965. * Initializes a StereoscopicInterlacePostProcess
  39966. * @param name The name of the effect.
  39967. * @param rigCameras The rig cameras to be appled to the post process
  39968. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39970. * @param engine The engine which the post process will be applied. (default: current engine)
  39971. * @param reusable If the post process can be reused on the same frame. (default: false)
  39972. */
  39973. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39974. }
  39975. }
  39976. declare module BABYLON {
  39977. /**
  39978. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39979. * @see http://doc.babylonjs.com/features/cameras
  39980. */
  39981. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39982. /**
  39983. * Creates a new StereoscopicArcRotateCamera
  39984. * @param name defines camera name
  39985. * @param alpha defines alpha angle (in radians)
  39986. * @param beta defines beta angle (in radians)
  39987. * @param radius defines radius
  39988. * @param target defines camera target
  39989. * @param interaxialDistance defines distance between each color axis
  39990. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39991. * @param scene defines the hosting scene
  39992. */
  39993. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39994. /**
  39995. * Gets camera class name
  39996. * @returns StereoscopicArcRotateCamera
  39997. */
  39998. getClassName(): string;
  39999. }
  40000. }
  40001. declare module BABYLON {
  40002. /**
  40003. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40004. * @see http://doc.babylonjs.com/features/cameras
  40005. */
  40006. export class StereoscopicFreeCamera extends FreeCamera {
  40007. /**
  40008. * Creates a new StereoscopicFreeCamera
  40009. * @param name defines camera name
  40010. * @param position defines initial position
  40011. * @param interaxialDistance defines distance between each color axis
  40012. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40013. * @param scene defines the hosting scene
  40014. */
  40015. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40016. /**
  40017. * Gets camera class name
  40018. * @returns StereoscopicFreeCamera
  40019. */
  40020. getClassName(): string;
  40021. }
  40022. }
  40023. declare module BABYLON {
  40024. /**
  40025. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40026. * @see http://doc.babylonjs.com/features/cameras
  40027. */
  40028. export class StereoscopicGamepadCamera extends GamepadCamera {
  40029. /**
  40030. * Creates a new StereoscopicGamepadCamera
  40031. * @param name defines camera name
  40032. * @param position defines initial position
  40033. * @param interaxialDistance defines distance between each color axis
  40034. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40035. * @param scene defines the hosting scene
  40036. */
  40037. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40038. /**
  40039. * Gets camera class name
  40040. * @returns StereoscopicGamepadCamera
  40041. */
  40042. getClassName(): string;
  40043. }
  40044. }
  40045. declare module BABYLON {
  40046. /**
  40047. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40048. * @see http://doc.babylonjs.com/features/cameras
  40049. */
  40050. export class StereoscopicUniversalCamera extends UniversalCamera {
  40051. /**
  40052. * Creates a new StereoscopicUniversalCamera
  40053. * @param name defines camera name
  40054. * @param position defines initial position
  40055. * @param interaxialDistance defines distance between each color axis
  40056. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40057. * @param scene defines the hosting scene
  40058. */
  40059. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40060. /**
  40061. * Gets camera class name
  40062. * @returns StereoscopicUniversalCamera
  40063. */
  40064. getClassName(): string;
  40065. }
  40066. }
  40067. declare module BABYLON {
  40068. /**
  40069. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40070. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40071. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40072. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40073. */
  40074. export class VirtualJoysticksCamera extends FreeCamera {
  40075. /**
  40076. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40077. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40078. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40079. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40080. * @param name Define the name of the camera in the scene
  40081. * @param position Define the start position of the camera in the scene
  40082. * @param scene Define the scene the camera belongs to
  40083. */
  40084. constructor(name: string, position: Vector3, scene: Scene);
  40085. /**
  40086. * Gets the current object class name.
  40087. * @return the class name
  40088. */
  40089. getClassName(): string;
  40090. }
  40091. }
  40092. declare module BABYLON {
  40093. /**
  40094. * This represents all the required metrics to create a VR camera.
  40095. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40096. */
  40097. export class VRCameraMetrics {
  40098. /**
  40099. * Define the horizontal resolution off the screen.
  40100. */
  40101. hResolution: number;
  40102. /**
  40103. * Define the vertical resolution off the screen.
  40104. */
  40105. vResolution: number;
  40106. /**
  40107. * Define the horizontal screen size.
  40108. */
  40109. hScreenSize: number;
  40110. /**
  40111. * Define the vertical screen size.
  40112. */
  40113. vScreenSize: number;
  40114. /**
  40115. * Define the vertical screen center position.
  40116. */
  40117. vScreenCenter: number;
  40118. /**
  40119. * Define the distance of the eyes to the screen.
  40120. */
  40121. eyeToScreenDistance: number;
  40122. /**
  40123. * Define the distance between both lenses
  40124. */
  40125. lensSeparationDistance: number;
  40126. /**
  40127. * Define the distance between both viewer's eyes.
  40128. */
  40129. interpupillaryDistance: number;
  40130. /**
  40131. * Define the distortion factor of the VR postprocess.
  40132. * Please, touch with care.
  40133. */
  40134. distortionK: number[];
  40135. /**
  40136. * Define the chromatic aberration correction factors for the VR post process.
  40137. */
  40138. chromaAbCorrection: number[];
  40139. /**
  40140. * Define the scale factor of the post process.
  40141. * The smaller the better but the slower.
  40142. */
  40143. postProcessScaleFactor: number;
  40144. /**
  40145. * Define an offset for the lens center.
  40146. */
  40147. lensCenterOffset: number;
  40148. /**
  40149. * Define if the current vr camera should compensate the distortion of the lense or not.
  40150. */
  40151. compensateDistortion: boolean;
  40152. /**
  40153. * Defines if multiview should be enabled when rendering (Default: false)
  40154. */
  40155. multiviewEnabled: boolean;
  40156. /**
  40157. * Gets the rendering aspect ratio based on the provided resolutions.
  40158. */
  40159. readonly aspectRatio: number;
  40160. /**
  40161. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40162. */
  40163. readonly aspectRatioFov: number;
  40164. /**
  40165. * @hidden
  40166. */
  40167. readonly leftHMatrix: Matrix;
  40168. /**
  40169. * @hidden
  40170. */
  40171. readonly rightHMatrix: Matrix;
  40172. /**
  40173. * @hidden
  40174. */
  40175. readonly leftPreViewMatrix: Matrix;
  40176. /**
  40177. * @hidden
  40178. */
  40179. readonly rightPreViewMatrix: Matrix;
  40180. /**
  40181. * Get the default VRMetrics based on the most generic setup.
  40182. * @returns the default vr metrics
  40183. */
  40184. static GetDefault(): VRCameraMetrics;
  40185. }
  40186. }
  40187. declare module BABYLON {
  40188. /** @hidden */
  40189. export var vrDistortionCorrectionPixelShader: {
  40190. name: string;
  40191. shader: string;
  40192. };
  40193. }
  40194. declare module BABYLON {
  40195. /**
  40196. * VRDistortionCorrectionPostProcess used for mobile VR
  40197. */
  40198. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40199. private _isRightEye;
  40200. private _distortionFactors;
  40201. private _postProcessScaleFactor;
  40202. private _lensCenterOffset;
  40203. private _scaleIn;
  40204. private _scaleFactor;
  40205. private _lensCenter;
  40206. /**
  40207. * Initializes the VRDistortionCorrectionPostProcess
  40208. * @param name The name of the effect.
  40209. * @param camera The camera to apply the render pass to.
  40210. * @param isRightEye If this is for the right eye distortion
  40211. * @param vrMetrics All the required metrics for the VR camera
  40212. */
  40213. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40214. }
  40215. }
  40216. declare module BABYLON {
  40217. /**
  40218. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40219. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40220. */
  40221. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40222. /**
  40223. * Creates a new VRDeviceOrientationArcRotateCamera
  40224. * @param name defines camera name
  40225. * @param alpha defines the camera rotation along the logitudinal axis
  40226. * @param beta defines the camera rotation along the latitudinal axis
  40227. * @param radius defines the camera distance from its target
  40228. * @param target defines the camera target
  40229. * @param scene defines the scene the camera belongs to
  40230. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40231. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40232. */
  40233. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40234. /**
  40235. * Gets camera class name
  40236. * @returns VRDeviceOrientationArcRotateCamera
  40237. */
  40238. getClassName(): string;
  40239. }
  40240. }
  40241. declare module BABYLON {
  40242. /**
  40243. * Camera used to simulate VR rendering (based on FreeCamera)
  40244. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40245. */
  40246. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40247. /**
  40248. * Creates a new VRDeviceOrientationFreeCamera
  40249. * @param name defines camera name
  40250. * @param position defines the start position of the camera
  40251. * @param scene defines the scene the camera belongs to
  40252. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40253. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40254. */
  40255. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40256. /**
  40257. * Gets camera class name
  40258. * @returns VRDeviceOrientationFreeCamera
  40259. */
  40260. getClassName(): string;
  40261. }
  40262. }
  40263. declare module BABYLON {
  40264. /**
  40265. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40266. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40267. */
  40268. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40269. /**
  40270. * Creates a new VRDeviceOrientationGamepadCamera
  40271. * @param name defines camera name
  40272. * @param position defines the start position of the camera
  40273. * @param scene defines the scene the camera belongs to
  40274. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40275. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40276. */
  40277. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40278. /**
  40279. * Gets camera class name
  40280. * @returns VRDeviceOrientationGamepadCamera
  40281. */
  40282. getClassName(): string;
  40283. }
  40284. }
  40285. declare module BABYLON {
  40286. /**
  40287. * Base class of materials working in push mode in babylon JS
  40288. * @hidden
  40289. */
  40290. export class PushMaterial extends Material {
  40291. protected _activeEffect: Effect;
  40292. protected _normalMatrix: Matrix;
  40293. /**
  40294. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40295. * This means that the material can keep using a previous shader while a new one is being compiled.
  40296. * This is mostly used when shader parallel compilation is supported (true by default)
  40297. */
  40298. allowShaderHotSwapping: boolean;
  40299. constructor(name: string, scene: Scene);
  40300. getEffect(): Effect;
  40301. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40302. /**
  40303. * Binds the given world matrix to the active effect
  40304. *
  40305. * @param world the matrix to bind
  40306. */
  40307. bindOnlyWorldMatrix(world: Matrix): void;
  40308. /**
  40309. * Binds the given normal matrix to the active effect
  40310. *
  40311. * @param normalMatrix the matrix to bind
  40312. */
  40313. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40314. bind(world: Matrix, mesh?: Mesh): void;
  40315. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40316. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40317. }
  40318. }
  40319. declare module BABYLON {
  40320. /**
  40321. * This groups all the flags used to control the materials channel.
  40322. */
  40323. export class MaterialFlags {
  40324. private static _DiffuseTextureEnabled;
  40325. /**
  40326. * Are diffuse textures enabled in the application.
  40327. */
  40328. static DiffuseTextureEnabled: boolean;
  40329. private static _AmbientTextureEnabled;
  40330. /**
  40331. * Are ambient textures enabled in the application.
  40332. */
  40333. static AmbientTextureEnabled: boolean;
  40334. private static _OpacityTextureEnabled;
  40335. /**
  40336. * Are opacity textures enabled in the application.
  40337. */
  40338. static OpacityTextureEnabled: boolean;
  40339. private static _ReflectionTextureEnabled;
  40340. /**
  40341. * Are reflection textures enabled in the application.
  40342. */
  40343. static ReflectionTextureEnabled: boolean;
  40344. private static _EmissiveTextureEnabled;
  40345. /**
  40346. * Are emissive textures enabled in the application.
  40347. */
  40348. static EmissiveTextureEnabled: boolean;
  40349. private static _SpecularTextureEnabled;
  40350. /**
  40351. * Are specular textures enabled in the application.
  40352. */
  40353. static SpecularTextureEnabled: boolean;
  40354. private static _BumpTextureEnabled;
  40355. /**
  40356. * Are bump textures enabled in the application.
  40357. */
  40358. static BumpTextureEnabled: boolean;
  40359. private static _LightmapTextureEnabled;
  40360. /**
  40361. * Are lightmap textures enabled in the application.
  40362. */
  40363. static LightmapTextureEnabled: boolean;
  40364. private static _RefractionTextureEnabled;
  40365. /**
  40366. * Are refraction textures enabled in the application.
  40367. */
  40368. static RefractionTextureEnabled: boolean;
  40369. private static _ColorGradingTextureEnabled;
  40370. /**
  40371. * Are color grading textures enabled in the application.
  40372. */
  40373. static ColorGradingTextureEnabled: boolean;
  40374. private static _FresnelEnabled;
  40375. /**
  40376. * Are fresnels enabled in the application.
  40377. */
  40378. static FresnelEnabled: boolean;
  40379. private static _ClearCoatTextureEnabled;
  40380. /**
  40381. * Are clear coat textures enabled in the application.
  40382. */
  40383. static ClearCoatTextureEnabled: boolean;
  40384. private static _ClearCoatBumpTextureEnabled;
  40385. /**
  40386. * Are clear coat bump textures enabled in the application.
  40387. */
  40388. static ClearCoatBumpTextureEnabled: boolean;
  40389. private static _ClearCoatTintTextureEnabled;
  40390. /**
  40391. * Are clear coat tint textures enabled in the application.
  40392. */
  40393. static ClearCoatTintTextureEnabled: boolean;
  40394. private static _SheenTextureEnabled;
  40395. /**
  40396. * Are sheen textures enabled in the application.
  40397. */
  40398. static SheenTextureEnabled: boolean;
  40399. private static _AnisotropicTextureEnabled;
  40400. /**
  40401. * Are anisotropic textures enabled in the application.
  40402. */
  40403. static AnisotropicTextureEnabled: boolean;
  40404. private static _ThicknessTextureEnabled;
  40405. /**
  40406. * Are thickness textures enabled in the application.
  40407. */
  40408. static ThicknessTextureEnabled: boolean;
  40409. }
  40410. }
  40411. declare module BABYLON {
  40412. /** @hidden */
  40413. export var defaultFragmentDeclaration: {
  40414. name: string;
  40415. shader: string;
  40416. };
  40417. }
  40418. declare module BABYLON {
  40419. /** @hidden */
  40420. export var defaultUboDeclaration: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module BABYLON {
  40426. /** @hidden */
  40427. export var lightFragmentDeclaration: {
  40428. name: string;
  40429. shader: string;
  40430. };
  40431. }
  40432. declare module BABYLON {
  40433. /** @hidden */
  40434. export var lightUboDeclaration: {
  40435. name: string;
  40436. shader: string;
  40437. };
  40438. }
  40439. declare module BABYLON {
  40440. /** @hidden */
  40441. export var lightsFragmentFunctions: {
  40442. name: string;
  40443. shader: string;
  40444. };
  40445. }
  40446. declare module BABYLON {
  40447. /** @hidden */
  40448. export var shadowsFragmentFunctions: {
  40449. name: string;
  40450. shader: string;
  40451. };
  40452. }
  40453. declare module BABYLON {
  40454. /** @hidden */
  40455. export var fresnelFunction: {
  40456. name: string;
  40457. shader: string;
  40458. };
  40459. }
  40460. declare module BABYLON {
  40461. /** @hidden */
  40462. export var reflectionFunction: {
  40463. name: string;
  40464. shader: string;
  40465. };
  40466. }
  40467. declare module BABYLON {
  40468. /** @hidden */
  40469. export var bumpFragmentFunctions: {
  40470. name: string;
  40471. shader: string;
  40472. };
  40473. }
  40474. declare module BABYLON {
  40475. /** @hidden */
  40476. export var logDepthDeclaration: {
  40477. name: string;
  40478. shader: string;
  40479. };
  40480. }
  40481. declare module BABYLON {
  40482. /** @hidden */
  40483. export var bumpFragment: {
  40484. name: string;
  40485. shader: string;
  40486. };
  40487. }
  40488. declare module BABYLON {
  40489. /** @hidden */
  40490. export var depthPrePass: {
  40491. name: string;
  40492. shader: string;
  40493. };
  40494. }
  40495. declare module BABYLON {
  40496. /** @hidden */
  40497. export var lightFragment: {
  40498. name: string;
  40499. shader: string;
  40500. };
  40501. }
  40502. declare module BABYLON {
  40503. /** @hidden */
  40504. export var logDepthFragment: {
  40505. name: string;
  40506. shader: string;
  40507. };
  40508. }
  40509. declare module BABYLON {
  40510. /** @hidden */
  40511. export var defaultPixelShader: {
  40512. name: string;
  40513. shader: string;
  40514. };
  40515. }
  40516. declare module BABYLON {
  40517. /** @hidden */
  40518. export var defaultVertexDeclaration: {
  40519. name: string;
  40520. shader: string;
  40521. };
  40522. }
  40523. declare module BABYLON {
  40524. /** @hidden */
  40525. export var bumpVertexDeclaration: {
  40526. name: string;
  40527. shader: string;
  40528. };
  40529. }
  40530. declare module BABYLON {
  40531. /** @hidden */
  40532. export var bumpVertex: {
  40533. name: string;
  40534. shader: string;
  40535. };
  40536. }
  40537. declare module BABYLON {
  40538. /** @hidden */
  40539. export var fogVertex: {
  40540. name: string;
  40541. shader: string;
  40542. };
  40543. }
  40544. declare module BABYLON {
  40545. /** @hidden */
  40546. export var shadowsVertex: {
  40547. name: string;
  40548. shader: string;
  40549. };
  40550. }
  40551. declare module BABYLON {
  40552. /** @hidden */
  40553. export var pointCloudVertex: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module BABYLON {
  40559. /** @hidden */
  40560. export var logDepthVertex: {
  40561. name: string;
  40562. shader: string;
  40563. };
  40564. }
  40565. declare module BABYLON {
  40566. /** @hidden */
  40567. export var defaultVertexShader: {
  40568. name: string;
  40569. shader: string;
  40570. };
  40571. }
  40572. declare module BABYLON {
  40573. /** @hidden */
  40574. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40575. MAINUV1: boolean;
  40576. MAINUV2: boolean;
  40577. DIFFUSE: boolean;
  40578. DIFFUSEDIRECTUV: number;
  40579. AMBIENT: boolean;
  40580. AMBIENTDIRECTUV: number;
  40581. OPACITY: boolean;
  40582. OPACITYDIRECTUV: number;
  40583. OPACITYRGB: boolean;
  40584. REFLECTION: boolean;
  40585. EMISSIVE: boolean;
  40586. EMISSIVEDIRECTUV: number;
  40587. SPECULAR: boolean;
  40588. SPECULARDIRECTUV: number;
  40589. BUMP: boolean;
  40590. BUMPDIRECTUV: number;
  40591. PARALLAX: boolean;
  40592. PARALLAXOCCLUSION: boolean;
  40593. SPECULAROVERALPHA: boolean;
  40594. CLIPPLANE: boolean;
  40595. CLIPPLANE2: boolean;
  40596. CLIPPLANE3: boolean;
  40597. CLIPPLANE4: boolean;
  40598. ALPHATEST: boolean;
  40599. DEPTHPREPASS: boolean;
  40600. ALPHAFROMDIFFUSE: boolean;
  40601. POINTSIZE: boolean;
  40602. FOG: boolean;
  40603. SPECULARTERM: boolean;
  40604. DIFFUSEFRESNEL: boolean;
  40605. OPACITYFRESNEL: boolean;
  40606. REFLECTIONFRESNEL: boolean;
  40607. REFRACTIONFRESNEL: boolean;
  40608. EMISSIVEFRESNEL: boolean;
  40609. FRESNEL: boolean;
  40610. NORMAL: boolean;
  40611. UV1: boolean;
  40612. UV2: boolean;
  40613. VERTEXCOLOR: boolean;
  40614. VERTEXALPHA: boolean;
  40615. NUM_BONE_INFLUENCERS: number;
  40616. BonesPerMesh: number;
  40617. BONETEXTURE: boolean;
  40618. INSTANCES: boolean;
  40619. GLOSSINESS: boolean;
  40620. ROUGHNESS: boolean;
  40621. EMISSIVEASILLUMINATION: boolean;
  40622. LINKEMISSIVEWITHDIFFUSE: boolean;
  40623. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40624. LIGHTMAP: boolean;
  40625. LIGHTMAPDIRECTUV: number;
  40626. OBJECTSPACE_NORMALMAP: boolean;
  40627. USELIGHTMAPASSHADOWMAP: boolean;
  40628. REFLECTIONMAP_3D: boolean;
  40629. REFLECTIONMAP_SPHERICAL: boolean;
  40630. REFLECTIONMAP_PLANAR: boolean;
  40631. REFLECTIONMAP_CUBIC: boolean;
  40632. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40633. REFLECTIONMAP_PROJECTION: boolean;
  40634. REFLECTIONMAP_SKYBOX: boolean;
  40635. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40636. REFLECTIONMAP_EXPLICIT: boolean;
  40637. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40638. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40639. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40640. INVERTCUBICMAP: boolean;
  40641. LOGARITHMICDEPTH: boolean;
  40642. REFRACTION: boolean;
  40643. REFRACTIONMAP_3D: boolean;
  40644. REFLECTIONOVERALPHA: boolean;
  40645. TWOSIDEDLIGHTING: boolean;
  40646. SHADOWFLOAT: boolean;
  40647. MORPHTARGETS: boolean;
  40648. MORPHTARGETS_NORMAL: boolean;
  40649. MORPHTARGETS_TANGENT: boolean;
  40650. MORPHTARGETS_UV: boolean;
  40651. NUM_MORPH_INFLUENCERS: number;
  40652. NONUNIFORMSCALING: boolean;
  40653. PREMULTIPLYALPHA: boolean;
  40654. IMAGEPROCESSING: boolean;
  40655. VIGNETTE: boolean;
  40656. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40657. VIGNETTEBLENDMODEOPAQUE: boolean;
  40658. TONEMAPPING: boolean;
  40659. TONEMAPPING_ACES: boolean;
  40660. CONTRAST: boolean;
  40661. COLORCURVES: boolean;
  40662. COLORGRADING: boolean;
  40663. COLORGRADING3D: boolean;
  40664. SAMPLER3DGREENDEPTH: boolean;
  40665. SAMPLER3DBGRMAP: boolean;
  40666. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40667. MULTIVIEW: boolean;
  40668. /**
  40669. * If the reflection texture on this material is in linear color space
  40670. * @hidden
  40671. */
  40672. IS_REFLECTION_LINEAR: boolean;
  40673. /**
  40674. * If the refraction texture on this material is in linear color space
  40675. * @hidden
  40676. */
  40677. IS_REFRACTION_LINEAR: boolean;
  40678. EXPOSURE: boolean;
  40679. constructor();
  40680. setReflectionMode(modeToEnable: string): void;
  40681. }
  40682. /**
  40683. * This is the default material used in Babylon. It is the best trade off between quality
  40684. * and performances.
  40685. * @see http://doc.babylonjs.com/babylon101/materials
  40686. */
  40687. export class StandardMaterial extends PushMaterial {
  40688. private _diffuseTexture;
  40689. /**
  40690. * The basic texture of the material as viewed under a light.
  40691. */
  40692. diffuseTexture: Nullable<BaseTexture>;
  40693. private _ambientTexture;
  40694. /**
  40695. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40696. */
  40697. ambientTexture: Nullable<BaseTexture>;
  40698. private _opacityTexture;
  40699. /**
  40700. * Define the transparency of the material from a texture.
  40701. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40702. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40703. */
  40704. opacityTexture: Nullable<BaseTexture>;
  40705. private _reflectionTexture;
  40706. /**
  40707. * Define the texture used to display the reflection.
  40708. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40709. */
  40710. reflectionTexture: Nullable<BaseTexture>;
  40711. private _emissiveTexture;
  40712. /**
  40713. * Define texture of the material as if self lit.
  40714. * This will be mixed in the final result even in the absence of light.
  40715. */
  40716. emissiveTexture: Nullable<BaseTexture>;
  40717. private _specularTexture;
  40718. /**
  40719. * Define how the color and intensity of the highlight given by the light in the material.
  40720. */
  40721. specularTexture: Nullable<BaseTexture>;
  40722. private _bumpTexture;
  40723. /**
  40724. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40725. * 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.
  40726. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40727. */
  40728. bumpTexture: Nullable<BaseTexture>;
  40729. private _lightmapTexture;
  40730. /**
  40731. * Complex lighting can be computationally expensive to compute at runtime.
  40732. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40733. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40734. */
  40735. lightmapTexture: Nullable<BaseTexture>;
  40736. private _refractionTexture;
  40737. /**
  40738. * Define the texture used to display the refraction.
  40739. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40740. */
  40741. refractionTexture: Nullable<BaseTexture>;
  40742. /**
  40743. * The color of the material lit by the environmental background lighting.
  40744. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40745. */
  40746. ambientColor: Color3;
  40747. /**
  40748. * The basic color of the material as viewed under a light.
  40749. */
  40750. diffuseColor: Color3;
  40751. /**
  40752. * Define how the color and intensity of the highlight given by the light in the material.
  40753. */
  40754. specularColor: Color3;
  40755. /**
  40756. * Define the color of the material as if self lit.
  40757. * This will be mixed in the final result even in the absence of light.
  40758. */
  40759. emissiveColor: Color3;
  40760. /**
  40761. * Defines how sharp are the highlights in the material.
  40762. * The bigger the value the sharper giving a more glossy feeling to the result.
  40763. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40764. */
  40765. specularPower: number;
  40766. private _useAlphaFromDiffuseTexture;
  40767. /**
  40768. * Does the transparency come from the diffuse texture alpha channel.
  40769. */
  40770. useAlphaFromDiffuseTexture: boolean;
  40771. private _useEmissiveAsIllumination;
  40772. /**
  40773. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40774. */
  40775. useEmissiveAsIllumination: boolean;
  40776. private _linkEmissiveWithDiffuse;
  40777. /**
  40778. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40779. * the emissive level when the final color is close to one.
  40780. */
  40781. linkEmissiveWithDiffuse: boolean;
  40782. private _useSpecularOverAlpha;
  40783. /**
  40784. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40785. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40786. */
  40787. useSpecularOverAlpha: boolean;
  40788. private _useReflectionOverAlpha;
  40789. /**
  40790. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40791. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40792. */
  40793. useReflectionOverAlpha: boolean;
  40794. private _disableLighting;
  40795. /**
  40796. * Does lights from the scene impacts this material.
  40797. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40798. */
  40799. disableLighting: boolean;
  40800. private _useObjectSpaceNormalMap;
  40801. /**
  40802. * Allows using an object space normal map (instead of tangent space).
  40803. */
  40804. useObjectSpaceNormalMap: boolean;
  40805. private _useParallax;
  40806. /**
  40807. * Is parallax enabled or not.
  40808. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40809. */
  40810. useParallax: boolean;
  40811. private _useParallaxOcclusion;
  40812. /**
  40813. * Is parallax occlusion enabled or not.
  40814. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40815. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40816. */
  40817. useParallaxOcclusion: boolean;
  40818. /**
  40819. * 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.
  40820. */
  40821. parallaxScaleBias: number;
  40822. private _roughness;
  40823. /**
  40824. * Helps to define how blurry the reflections should appears in the material.
  40825. */
  40826. roughness: number;
  40827. /**
  40828. * In case of refraction, define the value of the index of refraction.
  40829. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40830. */
  40831. indexOfRefraction: number;
  40832. /**
  40833. * Invert the refraction texture alongside the y axis.
  40834. * It can be useful with procedural textures or probe for instance.
  40835. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40836. */
  40837. invertRefractionY: boolean;
  40838. /**
  40839. * Defines the alpha limits in alpha test mode.
  40840. */
  40841. alphaCutOff: number;
  40842. private _useLightmapAsShadowmap;
  40843. /**
  40844. * In case of light mapping, define whether the map contains light or shadow informations.
  40845. */
  40846. useLightmapAsShadowmap: boolean;
  40847. private _diffuseFresnelParameters;
  40848. /**
  40849. * Define the diffuse fresnel parameters of the material.
  40850. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40851. */
  40852. diffuseFresnelParameters: FresnelParameters;
  40853. private _opacityFresnelParameters;
  40854. /**
  40855. * Define the opacity fresnel parameters of the material.
  40856. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40857. */
  40858. opacityFresnelParameters: FresnelParameters;
  40859. private _reflectionFresnelParameters;
  40860. /**
  40861. * Define the reflection fresnel parameters of the material.
  40862. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40863. */
  40864. reflectionFresnelParameters: FresnelParameters;
  40865. private _refractionFresnelParameters;
  40866. /**
  40867. * Define the refraction fresnel parameters of the material.
  40868. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40869. */
  40870. refractionFresnelParameters: FresnelParameters;
  40871. private _emissiveFresnelParameters;
  40872. /**
  40873. * Define the emissive fresnel parameters of the material.
  40874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40875. */
  40876. emissiveFresnelParameters: FresnelParameters;
  40877. private _useReflectionFresnelFromSpecular;
  40878. /**
  40879. * If true automatically deducts the fresnels values from the material specularity.
  40880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40881. */
  40882. useReflectionFresnelFromSpecular: boolean;
  40883. private _useGlossinessFromSpecularMapAlpha;
  40884. /**
  40885. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40886. */
  40887. useGlossinessFromSpecularMapAlpha: boolean;
  40888. private _maxSimultaneousLights;
  40889. /**
  40890. * Defines the maximum number of lights that can be used in the material
  40891. */
  40892. maxSimultaneousLights: number;
  40893. private _invertNormalMapX;
  40894. /**
  40895. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40896. */
  40897. invertNormalMapX: boolean;
  40898. private _invertNormalMapY;
  40899. /**
  40900. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40901. */
  40902. invertNormalMapY: boolean;
  40903. private _twoSidedLighting;
  40904. /**
  40905. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40906. */
  40907. twoSidedLighting: boolean;
  40908. /**
  40909. * Default configuration related to image processing available in the standard Material.
  40910. */
  40911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40912. /**
  40913. * Gets the image processing configuration used either in this material.
  40914. */
  40915. /**
  40916. * Sets the Default image processing configuration used either in the this material.
  40917. *
  40918. * If sets to null, the scene one is in use.
  40919. */
  40920. imageProcessingConfiguration: ImageProcessingConfiguration;
  40921. /**
  40922. * Keep track of the image processing observer to allow dispose and replace.
  40923. */
  40924. private _imageProcessingObserver;
  40925. /**
  40926. * Attaches a new image processing configuration to the Standard Material.
  40927. * @param configuration
  40928. */
  40929. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40930. /**
  40931. * Gets wether the color curves effect is enabled.
  40932. */
  40933. /**
  40934. * Sets wether the color curves effect is enabled.
  40935. */
  40936. cameraColorCurvesEnabled: boolean;
  40937. /**
  40938. * Gets wether the color grading effect is enabled.
  40939. */
  40940. /**
  40941. * Gets wether the color grading effect is enabled.
  40942. */
  40943. cameraColorGradingEnabled: boolean;
  40944. /**
  40945. * Gets wether tonemapping is enabled or not.
  40946. */
  40947. /**
  40948. * Sets wether tonemapping is enabled or not
  40949. */
  40950. cameraToneMappingEnabled: boolean;
  40951. /**
  40952. * The camera exposure used on this material.
  40953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40954. * This corresponds to a photographic exposure.
  40955. */
  40956. /**
  40957. * The camera exposure used on this material.
  40958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40959. * This corresponds to a photographic exposure.
  40960. */
  40961. cameraExposure: number;
  40962. /**
  40963. * Gets The camera contrast used on this material.
  40964. */
  40965. /**
  40966. * Sets The camera contrast used on this material.
  40967. */
  40968. cameraContrast: number;
  40969. /**
  40970. * Gets the Color Grading 2D Lookup Texture.
  40971. */
  40972. /**
  40973. * Sets the Color Grading 2D Lookup Texture.
  40974. */
  40975. cameraColorGradingTexture: Nullable<BaseTexture>;
  40976. /**
  40977. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40978. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40979. * 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;
  40980. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40981. */
  40982. /**
  40983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40985. * 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;
  40986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40987. */
  40988. cameraColorCurves: Nullable<ColorCurves>;
  40989. /**
  40990. * Custom callback helping to override the default shader used in the material.
  40991. */
  40992. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40993. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40994. protected _worldViewProjectionMatrix: Matrix;
  40995. protected _globalAmbientColor: Color3;
  40996. protected _useLogarithmicDepth: boolean;
  40997. protected _rebuildInParallel: boolean;
  40998. /**
  40999. * Instantiates a new standard material.
  41000. * This is the default material used in Babylon. It is the best trade off between quality
  41001. * and performances.
  41002. * @see http://doc.babylonjs.com/babylon101/materials
  41003. * @param name Define the name of the material in the scene
  41004. * @param scene Define the scene the material belong to
  41005. */
  41006. constructor(name: string, scene: Scene);
  41007. /**
  41008. * Gets a boolean indicating that current material needs to register RTT
  41009. */
  41010. readonly hasRenderTargetTextures: boolean;
  41011. /**
  41012. * Gets the current class name of the material e.g. "StandardMaterial"
  41013. * Mainly use in serialization.
  41014. * @returns the class name
  41015. */
  41016. getClassName(): string;
  41017. /**
  41018. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41019. * You can try switching to logarithmic depth.
  41020. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41021. */
  41022. useLogarithmicDepth: boolean;
  41023. /**
  41024. * Specifies if the material will require alpha blending
  41025. * @returns a boolean specifying if alpha blending is needed
  41026. */
  41027. needAlphaBlending(): boolean;
  41028. /**
  41029. * Specifies if this material should be rendered in alpha test mode
  41030. * @returns a boolean specifying if an alpha test is needed.
  41031. */
  41032. needAlphaTesting(): boolean;
  41033. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41034. /**
  41035. * Get the texture used for alpha test purpose.
  41036. * @returns the diffuse texture in case of the standard material.
  41037. */
  41038. getAlphaTestTexture(): Nullable<BaseTexture>;
  41039. /**
  41040. * Get if the submesh is ready to be used and all its information available.
  41041. * Child classes can use it to update shaders
  41042. * @param mesh defines the mesh to check
  41043. * @param subMesh defines which submesh to check
  41044. * @param useInstances specifies that instances should be used
  41045. * @returns a boolean indicating that the submesh is ready or not
  41046. */
  41047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41048. /**
  41049. * Builds the material UBO layouts.
  41050. * Used internally during the effect preparation.
  41051. */
  41052. buildUniformLayout(): void;
  41053. /**
  41054. * Unbinds the material from the mesh
  41055. */
  41056. unbind(): void;
  41057. /**
  41058. * Binds the submesh to this material by preparing the effect and shader to draw
  41059. * @param world defines the world transformation matrix
  41060. * @param mesh defines the mesh containing the submesh
  41061. * @param subMesh defines the submesh to bind the material to
  41062. */
  41063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41064. /**
  41065. * Get the list of animatables in the material.
  41066. * @returns the list of animatables object used in the material
  41067. */
  41068. getAnimatables(): IAnimatable[];
  41069. /**
  41070. * Gets the active textures from the material
  41071. * @returns an array of textures
  41072. */
  41073. getActiveTextures(): BaseTexture[];
  41074. /**
  41075. * Specifies if the material uses a texture
  41076. * @param texture defines the texture to check against the material
  41077. * @returns a boolean specifying if the material uses the texture
  41078. */
  41079. hasTexture(texture: BaseTexture): boolean;
  41080. /**
  41081. * Disposes the material
  41082. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41083. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41084. */
  41085. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41086. /**
  41087. * Makes a duplicate of the material, and gives it a new name
  41088. * @param name defines the new name for the duplicated material
  41089. * @returns the cloned material
  41090. */
  41091. clone(name: string): StandardMaterial;
  41092. /**
  41093. * Serializes this material in a JSON representation
  41094. * @returns the serialized material object
  41095. */
  41096. serialize(): any;
  41097. /**
  41098. * Creates a standard material from parsed material data
  41099. * @param source defines the JSON representation of the material
  41100. * @param scene defines the hosting scene
  41101. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41102. * @returns a new standard material
  41103. */
  41104. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41105. /**
  41106. * Are diffuse textures enabled in the application.
  41107. */
  41108. static DiffuseTextureEnabled: boolean;
  41109. /**
  41110. * Are ambient textures enabled in the application.
  41111. */
  41112. static AmbientTextureEnabled: boolean;
  41113. /**
  41114. * Are opacity textures enabled in the application.
  41115. */
  41116. static OpacityTextureEnabled: boolean;
  41117. /**
  41118. * Are reflection textures enabled in the application.
  41119. */
  41120. static ReflectionTextureEnabled: boolean;
  41121. /**
  41122. * Are emissive textures enabled in the application.
  41123. */
  41124. static EmissiveTextureEnabled: boolean;
  41125. /**
  41126. * Are specular textures enabled in the application.
  41127. */
  41128. static SpecularTextureEnabled: boolean;
  41129. /**
  41130. * Are bump textures enabled in the application.
  41131. */
  41132. static BumpTextureEnabled: boolean;
  41133. /**
  41134. * Are lightmap textures enabled in the application.
  41135. */
  41136. static LightmapTextureEnabled: boolean;
  41137. /**
  41138. * Are refraction textures enabled in the application.
  41139. */
  41140. static RefractionTextureEnabled: boolean;
  41141. /**
  41142. * Are color grading textures enabled in the application.
  41143. */
  41144. static ColorGradingTextureEnabled: boolean;
  41145. /**
  41146. * Are fresnels enabled in the application.
  41147. */
  41148. static FresnelEnabled: boolean;
  41149. }
  41150. }
  41151. declare module BABYLON {
  41152. /** @hidden */
  41153. export var imageProcessingPixelShader: {
  41154. name: string;
  41155. shader: string;
  41156. };
  41157. }
  41158. declare module BABYLON {
  41159. /**
  41160. * ImageProcessingPostProcess
  41161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41162. */
  41163. export class ImageProcessingPostProcess extends PostProcess {
  41164. /**
  41165. * Default configuration related to image processing available in the PBR Material.
  41166. */
  41167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41168. /**
  41169. * Gets the image processing configuration used either in this material.
  41170. */
  41171. /**
  41172. * Sets the Default image processing configuration used either in the this material.
  41173. *
  41174. * If sets to null, the scene one is in use.
  41175. */
  41176. imageProcessingConfiguration: ImageProcessingConfiguration;
  41177. /**
  41178. * Keep track of the image processing observer to allow dispose and replace.
  41179. */
  41180. private _imageProcessingObserver;
  41181. /**
  41182. * Attaches a new image processing configuration to the PBR Material.
  41183. * @param configuration
  41184. */
  41185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41186. /**
  41187. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41188. */
  41189. /**
  41190. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41191. */
  41192. colorCurves: Nullable<ColorCurves>;
  41193. /**
  41194. * Gets wether the color curves effect is enabled.
  41195. */
  41196. /**
  41197. * Sets wether the color curves effect is enabled.
  41198. */
  41199. colorCurvesEnabled: boolean;
  41200. /**
  41201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41202. */
  41203. /**
  41204. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41205. */
  41206. colorGradingTexture: Nullable<BaseTexture>;
  41207. /**
  41208. * Gets wether the color grading effect is enabled.
  41209. */
  41210. /**
  41211. * Gets wether the color grading effect is enabled.
  41212. */
  41213. colorGradingEnabled: boolean;
  41214. /**
  41215. * Gets exposure used in the effect.
  41216. */
  41217. /**
  41218. * Sets exposure used in the effect.
  41219. */
  41220. exposure: number;
  41221. /**
  41222. * Gets wether tonemapping is enabled or not.
  41223. */
  41224. /**
  41225. * Sets wether tonemapping is enabled or not
  41226. */
  41227. toneMappingEnabled: boolean;
  41228. /**
  41229. * Gets the type of tone mapping effect.
  41230. */
  41231. /**
  41232. * Sets the type of tone mapping effect.
  41233. */
  41234. toneMappingType: number;
  41235. /**
  41236. * Gets contrast used in the effect.
  41237. */
  41238. /**
  41239. * Sets contrast used in the effect.
  41240. */
  41241. contrast: number;
  41242. /**
  41243. * Gets Vignette stretch size.
  41244. */
  41245. /**
  41246. * Sets Vignette stretch size.
  41247. */
  41248. vignetteStretch: number;
  41249. /**
  41250. * Gets Vignette centre X Offset.
  41251. */
  41252. /**
  41253. * Sets Vignette centre X Offset.
  41254. */
  41255. vignetteCentreX: number;
  41256. /**
  41257. * Gets Vignette centre Y Offset.
  41258. */
  41259. /**
  41260. * Sets Vignette centre Y Offset.
  41261. */
  41262. vignetteCentreY: number;
  41263. /**
  41264. * Gets Vignette weight or intensity of the vignette effect.
  41265. */
  41266. /**
  41267. * Sets Vignette weight or intensity of the vignette effect.
  41268. */
  41269. vignetteWeight: number;
  41270. /**
  41271. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41272. * if vignetteEnabled is set to true.
  41273. */
  41274. /**
  41275. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41276. * if vignetteEnabled is set to true.
  41277. */
  41278. vignetteColor: Color4;
  41279. /**
  41280. * Gets Camera field of view used by the Vignette effect.
  41281. */
  41282. /**
  41283. * Sets Camera field of view used by the Vignette effect.
  41284. */
  41285. vignetteCameraFov: number;
  41286. /**
  41287. * Gets the vignette blend mode allowing different kind of effect.
  41288. */
  41289. /**
  41290. * Sets the vignette blend mode allowing different kind of effect.
  41291. */
  41292. vignetteBlendMode: number;
  41293. /**
  41294. * Gets wether the vignette effect is enabled.
  41295. */
  41296. /**
  41297. * Sets wether the vignette effect is enabled.
  41298. */
  41299. vignetteEnabled: boolean;
  41300. private _fromLinearSpace;
  41301. /**
  41302. * Gets wether the input of the processing is in Gamma or Linear Space.
  41303. */
  41304. /**
  41305. * Sets wether the input of the processing is in Gamma or Linear Space.
  41306. */
  41307. fromLinearSpace: boolean;
  41308. /**
  41309. * Defines cache preventing GC.
  41310. */
  41311. private _defines;
  41312. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41313. /**
  41314. * "ImageProcessingPostProcess"
  41315. * @returns "ImageProcessingPostProcess"
  41316. */
  41317. getClassName(): string;
  41318. protected _updateParameters(): void;
  41319. dispose(camera?: Camera): void;
  41320. }
  41321. }
  41322. declare module BABYLON {
  41323. /**
  41324. * Class containing static functions to help procedurally build meshes
  41325. */
  41326. export class GroundBuilder {
  41327. /**
  41328. * Creates a ground mesh
  41329. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41330. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41332. * @param name defines the name of the mesh
  41333. * @param options defines the options used to create the mesh
  41334. * @param scene defines the hosting scene
  41335. * @returns the ground mesh
  41336. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41337. */
  41338. static CreateGround(name: string, options: {
  41339. width?: number;
  41340. height?: number;
  41341. subdivisions?: number;
  41342. subdivisionsX?: number;
  41343. subdivisionsY?: number;
  41344. updatable?: boolean;
  41345. }, scene: any): Mesh;
  41346. /**
  41347. * Creates a tiled ground mesh
  41348. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41349. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41350. * * 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
  41351. * * 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
  41352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41353. * @param name defines the name of the mesh
  41354. * @param options defines the options used to create the mesh
  41355. * @param scene defines the hosting scene
  41356. * @returns the tiled ground mesh
  41357. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41358. */
  41359. static CreateTiledGround(name: string, options: {
  41360. xmin: number;
  41361. zmin: number;
  41362. xmax: number;
  41363. zmax: number;
  41364. subdivisions?: {
  41365. w: number;
  41366. h: number;
  41367. };
  41368. precision?: {
  41369. w: number;
  41370. h: number;
  41371. };
  41372. updatable?: boolean;
  41373. }, scene?: Nullable<Scene>): Mesh;
  41374. /**
  41375. * Creates a ground mesh from a height map
  41376. * * The parameter `url` sets the URL of the height map image resource.
  41377. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41378. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41379. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41380. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41381. * * 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.
  41382. * * 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).
  41383. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41385. * @param name defines the name of the mesh
  41386. * @param url defines the url to the height map
  41387. * @param options defines the options used to create the mesh
  41388. * @param scene defines the hosting scene
  41389. * @returns the ground mesh
  41390. * @see https://doc.babylonjs.com/babylon101/height_map
  41391. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41392. */
  41393. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41394. width?: number;
  41395. height?: number;
  41396. subdivisions?: number;
  41397. minHeight?: number;
  41398. maxHeight?: number;
  41399. colorFilter?: Color3;
  41400. alphaFilter?: number;
  41401. updatable?: boolean;
  41402. onReady?: (mesh: GroundMesh) => void;
  41403. }, scene?: Nullable<Scene>): GroundMesh;
  41404. }
  41405. }
  41406. declare module BABYLON {
  41407. /**
  41408. * Class containing static functions to help procedurally build meshes
  41409. */
  41410. export class TorusBuilder {
  41411. /**
  41412. * Creates a torus mesh
  41413. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41414. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41415. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41417. * * 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
  41418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41419. * @param name defines the name of the mesh
  41420. * @param options defines the options used to create the mesh
  41421. * @param scene defines the hosting scene
  41422. * @returns the torus mesh
  41423. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41424. */
  41425. static CreateTorus(name: string, options: {
  41426. diameter?: number;
  41427. thickness?: number;
  41428. tessellation?: number;
  41429. updatable?: boolean;
  41430. sideOrientation?: number;
  41431. frontUVs?: Vector4;
  41432. backUVs?: Vector4;
  41433. }, scene: any): Mesh;
  41434. }
  41435. }
  41436. declare module BABYLON {
  41437. /**
  41438. * Class containing static functions to help procedurally build meshes
  41439. */
  41440. export class CylinderBuilder {
  41441. /**
  41442. * Creates a cylinder or a cone mesh
  41443. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41444. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41445. * * 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.
  41446. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41447. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41448. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41449. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41450. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  41451. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41452. * * 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).
  41453. * * 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
  41454. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41455. * * 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
  41456. * * 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.
  41457. * * If `enclose` is false, a ring surface is one element.
  41458. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41459. * * 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
  41460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41461. * * 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
  41462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41463. * @param name defines the name of the mesh
  41464. * @param options defines the options used to create the mesh
  41465. * @param scene defines the hosting scene
  41466. * @returns the cylinder mesh
  41467. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41468. */
  41469. static CreateCylinder(name: string, options: {
  41470. height?: number;
  41471. diameterTop?: number;
  41472. diameterBottom?: number;
  41473. diameter?: number;
  41474. tessellation?: number;
  41475. subdivisions?: number;
  41476. arc?: number;
  41477. faceColors?: Color4[];
  41478. faceUV?: Vector4[];
  41479. updatable?: boolean;
  41480. hasRings?: boolean;
  41481. enclose?: boolean;
  41482. cap?: number;
  41483. sideOrientation?: number;
  41484. frontUVs?: Vector4;
  41485. backUVs?: Vector4;
  41486. }, scene: any): Mesh;
  41487. }
  41488. }
  41489. declare module BABYLON {
  41490. /**
  41491. * Options to modify the vr teleportation behavior.
  41492. */
  41493. export interface VRTeleportationOptions {
  41494. /**
  41495. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41496. */
  41497. floorMeshName?: string;
  41498. /**
  41499. * A list of meshes to be used as the teleportation floor. (default: empty)
  41500. */
  41501. floorMeshes?: Mesh[];
  41502. }
  41503. /**
  41504. * Options to modify the vr experience helper's behavior.
  41505. */
  41506. export interface VRExperienceHelperOptions extends WebVROptions {
  41507. /**
  41508. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41509. */
  41510. createDeviceOrientationCamera?: boolean;
  41511. /**
  41512. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41513. */
  41514. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41515. /**
  41516. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41517. */
  41518. laserToggle?: boolean;
  41519. /**
  41520. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41521. */
  41522. floorMeshes?: Mesh[];
  41523. /**
  41524. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41525. */
  41526. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41527. }
  41528. /**
  41529. * Event containing information after VR has been entered
  41530. */
  41531. export class OnAfterEnteringVRObservableEvent {
  41532. /**
  41533. * If entering vr was successful
  41534. */
  41535. success: boolean;
  41536. }
  41537. /**
  41538. * Helps to quickly add VR support to an existing scene.
  41539. * See http://doc.babylonjs.com/how_to/webvr_helper
  41540. */
  41541. export class VRExperienceHelper {
  41542. /** Options to modify the vr experience helper's behavior. */
  41543. webVROptions: VRExperienceHelperOptions;
  41544. private _scene;
  41545. private _position;
  41546. private _btnVR;
  41547. private _btnVRDisplayed;
  41548. private _webVRsupported;
  41549. private _webVRready;
  41550. private _webVRrequesting;
  41551. private _webVRpresenting;
  41552. private _hasEnteredVR;
  41553. private _fullscreenVRpresenting;
  41554. private _inputElement;
  41555. private _webVRCamera;
  41556. private _vrDeviceOrientationCamera;
  41557. private _deviceOrientationCamera;
  41558. private _existingCamera;
  41559. private _onKeyDown;
  41560. private _onVrDisplayPresentChange;
  41561. private _onVRDisplayChanged;
  41562. private _onVRRequestPresentStart;
  41563. private _onVRRequestPresentComplete;
  41564. /**
  41565. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41566. */
  41567. enableGazeEvenWhenNoPointerLock: boolean;
  41568. /**
  41569. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41570. */
  41571. exitVROnDoubleTap: boolean;
  41572. /**
  41573. * Observable raised right before entering VR.
  41574. */
  41575. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41576. /**
  41577. * Observable raised when entering VR has completed.
  41578. */
  41579. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41580. /**
  41581. * Observable raised when exiting VR.
  41582. */
  41583. onExitingVRObservable: Observable<VRExperienceHelper>;
  41584. /**
  41585. * Observable raised when controller mesh is loaded.
  41586. */
  41587. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41588. /** Return this.onEnteringVRObservable
  41589. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41590. */
  41591. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41592. /** Return this.onExitingVRObservable
  41593. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41594. */
  41595. readonly onExitingVR: Observable<VRExperienceHelper>;
  41596. /** Return this.onControllerMeshLoadedObservable
  41597. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41598. */
  41599. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41600. private _rayLength;
  41601. private _useCustomVRButton;
  41602. private _teleportationRequested;
  41603. private _teleportActive;
  41604. private _floorMeshName;
  41605. private _floorMeshesCollection;
  41606. private _rotationAllowed;
  41607. private _teleportBackwardsVector;
  41608. private _teleportationTarget;
  41609. private _isDefaultTeleportationTarget;
  41610. private _postProcessMove;
  41611. private _teleportationFillColor;
  41612. private _teleportationBorderColor;
  41613. private _rotationAngle;
  41614. private _haloCenter;
  41615. private _cameraGazer;
  41616. private _padSensibilityUp;
  41617. private _padSensibilityDown;
  41618. private _leftController;
  41619. private _rightController;
  41620. /**
  41621. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41622. */
  41623. onNewMeshSelected: Observable<AbstractMesh>;
  41624. /**
  41625. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41626. * This observable will provide the mesh and the controller used to select the mesh
  41627. */
  41628. onMeshSelectedWithController: Observable<{
  41629. mesh: AbstractMesh;
  41630. controller: WebVRController;
  41631. }>;
  41632. /**
  41633. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41634. */
  41635. onNewMeshPicked: Observable<PickingInfo>;
  41636. private _circleEase;
  41637. /**
  41638. * Observable raised before camera teleportation
  41639. */
  41640. onBeforeCameraTeleport: Observable<Vector3>;
  41641. /**
  41642. * Observable raised after camera teleportation
  41643. */
  41644. onAfterCameraTeleport: Observable<Vector3>;
  41645. /**
  41646. * Observable raised when current selected mesh gets unselected
  41647. */
  41648. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41649. private _raySelectionPredicate;
  41650. /**
  41651. * To be optionaly changed by user to define custom ray selection
  41652. */
  41653. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41654. /**
  41655. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41656. */
  41657. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41658. /**
  41659. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41660. */
  41661. teleportationEnabled: boolean;
  41662. private _defaultHeight;
  41663. private _teleportationInitialized;
  41664. private _interactionsEnabled;
  41665. private _interactionsRequested;
  41666. private _displayGaze;
  41667. private _displayLaserPointer;
  41668. /**
  41669. * The mesh used to display where the user is going to teleport.
  41670. */
  41671. /**
  41672. * Sets the mesh to be used to display where the user is going to teleport.
  41673. */
  41674. teleportationTarget: Mesh;
  41675. /**
  41676. * 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
  41677. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41678. * See http://doc.babylonjs.com/resources/baking_transformations
  41679. */
  41680. gazeTrackerMesh: Mesh;
  41681. /**
  41682. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41683. */
  41684. updateGazeTrackerScale: boolean;
  41685. /**
  41686. * If the gaze trackers color should be updated when selecting meshes
  41687. */
  41688. updateGazeTrackerColor: boolean;
  41689. /**
  41690. * If the controller laser color should be updated when selecting meshes
  41691. */
  41692. updateControllerLaserColor: boolean;
  41693. /**
  41694. * The gaze tracking mesh corresponding to the left controller
  41695. */
  41696. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41697. /**
  41698. * The gaze tracking mesh corresponding to the right controller
  41699. */
  41700. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41701. /**
  41702. * If the ray of the gaze should be displayed.
  41703. */
  41704. /**
  41705. * Sets if the ray of the gaze should be displayed.
  41706. */
  41707. displayGaze: boolean;
  41708. /**
  41709. * If the ray of the LaserPointer should be displayed.
  41710. */
  41711. /**
  41712. * Sets if the ray of the LaserPointer should be displayed.
  41713. */
  41714. displayLaserPointer: boolean;
  41715. /**
  41716. * The deviceOrientationCamera used as the camera when not in VR.
  41717. */
  41718. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41719. /**
  41720. * Based on the current WebVR support, returns the current VR camera used.
  41721. */
  41722. readonly currentVRCamera: Nullable<Camera>;
  41723. /**
  41724. * The webVRCamera which is used when in VR.
  41725. */
  41726. readonly webVRCamera: WebVRFreeCamera;
  41727. /**
  41728. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41729. */
  41730. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41731. /**
  41732. * The html button that is used to trigger entering into VR.
  41733. */
  41734. readonly vrButton: Nullable<HTMLButtonElement>;
  41735. private readonly _teleportationRequestInitiated;
  41736. /**
  41737. * Defines wether or not Pointer lock should be requested when switching to
  41738. * full screen.
  41739. */
  41740. requestPointerLockOnFullScreen: boolean;
  41741. /**
  41742. * Instantiates a VRExperienceHelper.
  41743. * Helps to quickly add VR support to an existing scene.
  41744. * @param scene The scene the VRExperienceHelper belongs to.
  41745. * @param webVROptions Options to modify the vr experience helper's behavior.
  41746. */
  41747. constructor(scene: Scene,
  41748. /** Options to modify the vr experience helper's behavior. */
  41749. webVROptions?: VRExperienceHelperOptions);
  41750. private _onDefaultMeshLoaded;
  41751. private _onResize;
  41752. private _onFullscreenChange;
  41753. /**
  41754. * Gets a value indicating if we are currently in VR mode.
  41755. */
  41756. readonly isInVRMode: boolean;
  41757. private onVrDisplayPresentChange;
  41758. private onVRDisplayChanged;
  41759. private moveButtonToBottomRight;
  41760. private displayVRButton;
  41761. private updateButtonVisibility;
  41762. private _cachedAngularSensibility;
  41763. /**
  41764. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41765. * Otherwise, will use the fullscreen API.
  41766. */
  41767. enterVR(): void;
  41768. /**
  41769. * Attempt to exit VR, or fullscreen.
  41770. */
  41771. exitVR(): void;
  41772. /**
  41773. * The position of the vr experience helper.
  41774. */
  41775. /**
  41776. * Sets the position of the vr experience helper.
  41777. */
  41778. position: Vector3;
  41779. /**
  41780. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41781. */
  41782. enableInteractions(): void;
  41783. private readonly _noControllerIsActive;
  41784. private beforeRender;
  41785. private _isTeleportationFloor;
  41786. /**
  41787. * Adds a floor mesh to be used for teleportation.
  41788. * @param floorMesh the mesh to be used for teleportation.
  41789. */
  41790. addFloorMesh(floorMesh: Mesh): void;
  41791. /**
  41792. * Removes a floor mesh from being used for teleportation.
  41793. * @param floorMesh the mesh to be removed.
  41794. */
  41795. removeFloorMesh(floorMesh: Mesh): void;
  41796. /**
  41797. * Enables interactions and teleportation using the VR controllers and gaze.
  41798. * @param vrTeleportationOptions options to modify teleportation behavior.
  41799. */
  41800. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41801. private _onNewGamepadConnected;
  41802. private _tryEnableInteractionOnController;
  41803. private _onNewGamepadDisconnected;
  41804. private _enableInteractionOnController;
  41805. private _checkTeleportWithRay;
  41806. private _checkRotate;
  41807. private _checkTeleportBackwards;
  41808. private _enableTeleportationOnController;
  41809. private _createTeleportationCircles;
  41810. private _displayTeleportationTarget;
  41811. private _hideTeleportationTarget;
  41812. private _rotateCamera;
  41813. private _moveTeleportationSelectorTo;
  41814. private _workingVector;
  41815. private _workingQuaternion;
  41816. private _workingMatrix;
  41817. /**
  41818. * Teleports the users feet to the desired location
  41819. * @param location The location where the user's feet should be placed
  41820. */
  41821. teleportCamera(location: Vector3): void;
  41822. private _convertNormalToDirectionOfRay;
  41823. private _castRayAndSelectObject;
  41824. private _notifySelectedMeshUnselected;
  41825. /**
  41826. * Sets the color of the laser ray from the vr controllers.
  41827. * @param color new color for the ray.
  41828. */
  41829. changeLaserColor(color: Color3): void;
  41830. /**
  41831. * Sets the color of the ray from the vr headsets gaze.
  41832. * @param color new color for the ray.
  41833. */
  41834. changeGazeColor(color: Color3): void;
  41835. /**
  41836. * Exits VR and disposes of the vr experience helper
  41837. */
  41838. dispose(): void;
  41839. /**
  41840. * Gets the name of the VRExperienceHelper class
  41841. * @returns "VRExperienceHelper"
  41842. */
  41843. getClassName(): string;
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * States of the webXR experience
  41849. */
  41850. export enum WebXRState {
  41851. /**
  41852. * Transitioning to being in XR mode
  41853. */
  41854. ENTERING_XR = 0,
  41855. /**
  41856. * Transitioning to non XR mode
  41857. */
  41858. EXITING_XR = 1,
  41859. /**
  41860. * In XR mode and presenting
  41861. */
  41862. IN_XR = 2,
  41863. /**
  41864. * Not entered XR mode
  41865. */
  41866. NOT_IN_XR = 3
  41867. }
  41868. /**
  41869. * Abstraction of the XR render target
  41870. */
  41871. export interface WebXRRenderTarget extends IDisposable {
  41872. /**
  41873. * xrpresent context of the canvas which can be used to display/mirror xr content
  41874. */
  41875. canvasContext: WebGLRenderingContext;
  41876. /**
  41877. * xr layer for the canvas
  41878. */
  41879. xrLayer: Nullable<XRWebGLLayer>;
  41880. /**
  41881. * Initializes the xr layer for the session
  41882. * @param xrSession xr session
  41883. * @returns a promise that will resolve once the XR Layer has been created
  41884. */
  41885. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41886. }
  41887. }
  41888. declare module BABYLON {
  41889. /**
  41890. * COnfiguration object for WebXR output canvas
  41891. */
  41892. export class WebXRManagedOutputCanvasOptions {
  41893. /**
  41894. * Options for this XR Layer output
  41895. */
  41896. canvasOptions: XRWebGLLayerOptions;
  41897. /**
  41898. * CSS styling for a newly created canvas (if not provided)
  41899. */
  41900. newCanvasCssStyle?: string;
  41901. /**
  41902. * Get the default values of the configuration object
  41903. * @returns default values of this configuration object
  41904. */
  41905. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  41906. }
  41907. /**
  41908. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41909. */
  41910. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41911. private configuration;
  41912. private _engine;
  41913. private _canvas;
  41914. /**
  41915. * xrpresent context of the canvas which can be used to display/mirror xr content
  41916. */
  41917. canvasContext: WebGLRenderingContext;
  41918. /**
  41919. * xr layer for the canvas
  41920. */
  41921. xrLayer: Nullable<XRWebGLLayer>;
  41922. /**
  41923. * Initializes the xr layer for the session
  41924. * @param xrSession xr session
  41925. * @returns a promise that will resolve once the XR Layer has been created
  41926. */
  41927. initializeXRLayerAsync(xrSession: any): any;
  41928. /**
  41929. * Initializes the canvas to be added/removed upon entering/exiting xr
  41930. * @param engine the Babylon engine
  41931. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41932. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41933. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  41934. */
  41935. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  41936. /**
  41937. * Disposes of the object
  41938. */
  41939. dispose(): void;
  41940. private _setManagedOutputCanvas;
  41941. private _addCanvas;
  41942. private _removeCanvas;
  41943. }
  41944. }
  41945. declare module BABYLON {
  41946. /**
  41947. * Manages an XRSession to work with Babylon's engine
  41948. * @see https://doc.babylonjs.com/how_to/webxr
  41949. */
  41950. export class WebXRSessionManager implements IDisposable {
  41951. private scene;
  41952. /**
  41953. * Fires every time a new xrFrame arrives which can be used to update the camera
  41954. */
  41955. onXRFrameObservable: Observable<any>;
  41956. /**
  41957. * Fires when the xr session is ended either by the device or manually done
  41958. */
  41959. onXRSessionEnded: Observable<any>;
  41960. /**
  41961. * Underlying xr session
  41962. */
  41963. session: XRSession;
  41964. /**
  41965. * Type of reference space used when creating the session
  41966. */
  41967. referenceSpace: XRReferenceSpace;
  41968. /**
  41969. * Current XR frame
  41970. */
  41971. currentFrame: Nullable<XRFrame>;
  41972. private _xrNavigator;
  41973. private baseLayer;
  41974. private _rttProvider;
  41975. private _sessionEnded;
  41976. /**
  41977. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41978. * @param scene The scene which the session should be created for
  41979. */
  41980. constructor(scene: Scene);
  41981. /**
  41982. * Initializes the manager
  41983. * After initialization enterXR can be called to start an XR session
  41984. * @returns Promise which resolves after it is initialized
  41985. */
  41986. initializeAsync(): Promise<void>;
  41987. /**
  41988. * Initializes an xr session
  41989. * @param xrSessionMode mode to initialize
  41990. * @param optionalFeatures defines optional values to pass to the session builder
  41991. * @returns a promise which will resolve once the session has been initialized
  41992. */
  41993. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41994. /**
  41995. * Sets the reference space on the xr session
  41996. * @param referenceSpace space to set
  41997. * @returns a promise that will resolve once the reference space has been set
  41998. */
  41999. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42000. /**
  42001. * Updates the render state of the session
  42002. * @param state state to set
  42003. * @returns a promise that resolves once the render state has been updated
  42004. */
  42005. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42006. /**
  42007. * Starts rendering to the xr layer
  42008. * @returns a promise that will resolve once rendering has started
  42009. */
  42010. startRenderingToXRAsync(): Promise<void>;
  42011. /**
  42012. * Gets the correct render target texture to be rendered this frame for this eye
  42013. * @param eye the eye for which to get the render target
  42014. * @returns the render target for the specified eye
  42015. */
  42016. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42017. /**
  42018. * Stops the xrSession and restores the renderloop
  42019. * @returns Promise which resolves after it exits XR
  42020. */
  42021. exitXRAsync(): Promise<void>;
  42022. /**
  42023. * Checks if a session would be supported for the creation options specified
  42024. * @param sessionMode session mode to check if supported eg. immersive-vr
  42025. * @returns true if supported
  42026. */
  42027. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42028. /**
  42029. * Creates a WebXRRenderTarget object for the XR session
  42030. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42031. * @param options optional options to provide when creating a new render target
  42032. * @returns a WebXR render target to which the session can render
  42033. */
  42034. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42035. /**
  42036. * @hidden
  42037. * Converts the render layer of xrSession to a render target
  42038. * @param session session to create render target for
  42039. * @param scene scene the new render target should be created for
  42040. */
  42041. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42042. /**
  42043. * Disposes of the session manager
  42044. */
  42045. dispose(): void;
  42046. }
  42047. }
  42048. declare module BABYLON {
  42049. /**
  42050. * WebXR Camera which holds the views for the xrSession
  42051. * @see https://doc.babylonjs.com/how_to/webxr
  42052. */
  42053. export class WebXRCamera extends FreeCamera {
  42054. /**
  42055. * Is the camera in debug mode. Used when using an emulator
  42056. */
  42057. debugMode: boolean;
  42058. /**
  42059. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42060. * @param name the name of the camera
  42061. * @param scene the scene to add the camera to
  42062. */
  42063. constructor(name: string, scene: Scene);
  42064. private _updateNumberOfRigCameras;
  42065. /** @hidden */
  42066. _updateForDualEyeDebugging(): void;
  42067. /**
  42068. * Updates the cameras position from the current pose information of the XR session
  42069. * @param xrSessionManager the session containing pose information
  42070. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42071. */
  42072. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42078. * @see https://doc.babylonjs.com/how_to/webxr
  42079. */
  42080. export class WebXRExperienceHelper implements IDisposable {
  42081. private scene;
  42082. /**
  42083. * 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
  42084. */
  42085. container: AbstractMesh;
  42086. /**
  42087. * Camera used to render xr content
  42088. */
  42089. camera: WebXRCamera;
  42090. /**
  42091. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42092. */
  42093. state: WebXRState;
  42094. private _setState;
  42095. private static _TmpVector;
  42096. /**
  42097. * Fires when the state of the experience helper has changed
  42098. */
  42099. onStateChangedObservable: Observable<WebXRState>;
  42100. /** Session manager used to keep track of xr session */
  42101. sessionManager: WebXRSessionManager;
  42102. private _nonVRCamera;
  42103. private _originalSceneAutoClear;
  42104. private _supported;
  42105. /**
  42106. * Creates the experience helper
  42107. * @param scene the scene to attach the experience helper to
  42108. * @returns a promise for the experience helper
  42109. */
  42110. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42111. /**
  42112. * Creates a WebXRExperienceHelper
  42113. * @param scene The scene the helper should be created in
  42114. */
  42115. private constructor();
  42116. /**
  42117. * Exits XR mode and returns the scene to its original state
  42118. * @returns promise that resolves after xr mode has exited
  42119. */
  42120. exitXRAsync(): Promise<void>;
  42121. /**
  42122. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42123. * @param sessionMode options for the XR session
  42124. * @param referenceSpaceType frame of reference of the XR session
  42125. * @param renderTarget the output canvas that will be used to enter XR mode
  42126. * @returns promise that resolves after xr mode has entered
  42127. */
  42128. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  42129. /**
  42130. * Updates the global position of the camera by moving the camera's container
  42131. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42132. * @param position The desired global position of the camera
  42133. */
  42134. setPositionOfCameraUsingContainer(position: Vector3): void;
  42135. /**
  42136. * Rotates the xr camera by rotating the camera's container around the camera's position
  42137. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42138. * @param rotation the desired quaternion rotation to apply to the camera
  42139. */
  42140. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42141. /**
  42142. * Disposes of the experience helper
  42143. */
  42144. dispose(): void;
  42145. }
  42146. }
  42147. declare module BABYLON {
  42148. /**
  42149. * Button which can be used to enter a different mode of XR
  42150. */
  42151. export class WebXREnterExitUIButton {
  42152. /** button element */
  42153. element: HTMLElement;
  42154. /** XR initialization options for the button */
  42155. sessionMode: XRSessionMode;
  42156. /** Reference space type */
  42157. referenceSpaceType: XRReferenceSpaceType;
  42158. /**
  42159. * Creates a WebXREnterExitUIButton
  42160. * @param element button element
  42161. * @param sessionMode XR initialization session mode
  42162. * @param referenceSpaceType the type of reference space to be used
  42163. */
  42164. constructor(
  42165. /** button element */
  42166. element: HTMLElement,
  42167. /** XR initialization options for the button */
  42168. sessionMode: XRSessionMode,
  42169. /** Reference space type */
  42170. referenceSpaceType: XRReferenceSpaceType);
  42171. /**
  42172. * Overwritable function which can be used to update the button's visuals when the state changes
  42173. * @param activeButton the current active button in the UI
  42174. */
  42175. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42176. }
  42177. /**
  42178. * Options to create the webXR UI
  42179. */
  42180. export class WebXREnterExitUIOptions {
  42181. /**
  42182. * Context to enter xr with
  42183. */
  42184. renderTarget?: Nullable<WebXRRenderTarget>;
  42185. /**
  42186. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42187. */
  42188. customButtons?: Array<WebXREnterExitUIButton>;
  42189. }
  42190. /**
  42191. * UI to allow the user to enter/exit XR mode
  42192. */
  42193. export class WebXREnterExitUI implements IDisposable {
  42194. private scene;
  42195. private _overlay;
  42196. private _buttons;
  42197. private _activeButton;
  42198. /**
  42199. * Fired every time the active button is changed.
  42200. *
  42201. * When xr is entered via a button that launches xr that button will be the callback parameter
  42202. *
  42203. * When exiting xr the callback parameter will be null)
  42204. */
  42205. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42206. /**
  42207. * Creates UI to allow the user to enter/exit XR mode
  42208. * @param scene the scene to add the ui to
  42209. * @param helper the xr experience helper to enter/exit xr with
  42210. * @param options options to configure the UI
  42211. * @returns the created ui
  42212. */
  42213. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42214. private constructor();
  42215. private _updateButtons;
  42216. /**
  42217. * Disposes of the object
  42218. */
  42219. dispose(): void;
  42220. }
  42221. }
  42222. declare module BABYLON {
  42223. /**
  42224. * Represents an XR input
  42225. */
  42226. export class WebXRController {
  42227. private scene;
  42228. /** The underlying input source for the controller */
  42229. inputSource: XRInputSource;
  42230. private parentContainer;
  42231. /**
  42232. * 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
  42233. */
  42234. grip?: AbstractMesh;
  42235. /**
  42236. * Pointer which can be used to select objects or attach a visible laser to
  42237. */
  42238. pointer: AbstractMesh;
  42239. private _gamepadMode;
  42240. /**
  42241. * If available, this is the gamepad object related to this controller.
  42242. * Using this object it is possible to get click events and trackpad changes of the
  42243. * webxr controller that is currently being used.
  42244. */
  42245. gamepadController?: WebVRController;
  42246. /**
  42247. * Event that fires when the controller is removed/disposed
  42248. */
  42249. onDisposeObservable: Observable<{}>;
  42250. private _tmpMatrix;
  42251. private _tmpQuaternion;
  42252. private _tmpVector;
  42253. /**
  42254. * Creates the controller
  42255. * @see https://doc.babylonjs.com/how_to/webxr
  42256. * @param scene the scene which the controller should be associated to
  42257. * @param inputSource the underlying input source for the controller
  42258. * @param parentContainer parent that the controller meshes should be children of
  42259. */
  42260. constructor(scene: Scene,
  42261. /** The underlying input source for the controller */
  42262. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42263. /**
  42264. * Updates the controller pose based on the given XRFrame
  42265. * @param xrFrame xr frame to update the pose with
  42266. * @param referenceSpace reference space to use
  42267. */
  42268. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42269. /**
  42270. * Gets a world space ray coming from the controller
  42271. * @param result the resulting ray
  42272. */
  42273. getWorldPointerRayToRef(result: Ray): void;
  42274. /**
  42275. * Get the scene associated with this controller
  42276. * @returns the scene object
  42277. */
  42278. getScene(): Scene;
  42279. /**
  42280. * Disposes of the object
  42281. */
  42282. dispose(): void;
  42283. }
  42284. }
  42285. declare module BABYLON {
  42286. /**
  42287. * XR input used to track XR inputs such as controllers/rays
  42288. */
  42289. export class WebXRInput implements IDisposable {
  42290. /**
  42291. * Base experience the input listens to
  42292. */
  42293. baseExperience: WebXRExperienceHelper;
  42294. /**
  42295. * XR controllers being tracked
  42296. */
  42297. controllers: Array<WebXRController>;
  42298. private _frameObserver;
  42299. private _stateObserver;
  42300. /**
  42301. * Event when a controller has been connected/added
  42302. */
  42303. onControllerAddedObservable: Observable<WebXRController>;
  42304. /**
  42305. * Event when a controller has been removed/disconnected
  42306. */
  42307. onControllerRemovedObservable: Observable<WebXRController>;
  42308. /**
  42309. * Initializes the WebXRInput
  42310. * @param baseExperience experience helper which the input should be created for
  42311. */
  42312. constructor(
  42313. /**
  42314. * Base experience the input listens to
  42315. */
  42316. baseExperience: WebXRExperienceHelper);
  42317. private _onInputSourcesChange;
  42318. private _addAndRemoveControllers;
  42319. /**
  42320. * Disposes of the object
  42321. */
  42322. dispose(): void;
  42323. }
  42324. }
  42325. declare module BABYLON {
  42326. /**
  42327. * Enables teleportation
  42328. */
  42329. export class WebXRControllerTeleportation {
  42330. private _teleportationFillColor;
  42331. private _teleportationBorderColor;
  42332. private _tmpRay;
  42333. private _tmpVector;
  42334. /**
  42335. * Creates a WebXRControllerTeleportation
  42336. * @param input input manager to add teleportation to
  42337. * @param floorMeshes floormeshes which can be teleported to
  42338. */
  42339. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42340. }
  42341. }
  42342. declare module BABYLON {
  42343. /**
  42344. * Handles pointer input automatically for the pointer of XR controllers
  42345. */
  42346. export class WebXRControllerPointerSelection {
  42347. private static _idCounter;
  42348. private _tmpRay;
  42349. /**
  42350. * Creates a WebXRControllerPointerSelection
  42351. * @param input input manager to setup pointer selection
  42352. */
  42353. constructor(input: WebXRInput);
  42354. private _convertNormalToDirectionOfRay;
  42355. private _updatePointerDistance;
  42356. }
  42357. }
  42358. declare module BABYLON {
  42359. /**
  42360. * Class used to represent data loading progression
  42361. */
  42362. export class SceneLoaderProgressEvent {
  42363. /** defines if data length to load can be evaluated */
  42364. readonly lengthComputable: boolean;
  42365. /** defines the loaded data length */
  42366. readonly loaded: number;
  42367. /** defines the data length to load */
  42368. readonly total: number;
  42369. /**
  42370. * Create a new progress event
  42371. * @param lengthComputable defines if data length to load can be evaluated
  42372. * @param loaded defines the loaded data length
  42373. * @param total defines the data length to load
  42374. */
  42375. constructor(
  42376. /** defines if data length to load can be evaluated */
  42377. lengthComputable: boolean,
  42378. /** defines the loaded data length */
  42379. loaded: number,
  42380. /** defines the data length to load */
  42381. total: number);
  42382. /**
  42383. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42384. * @param event defines the source event
  42385. * @returns a new SceneLoaderProgressEvent
  42386. */
  42387. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42388. }
  42389. /**
  42390. * Interface used by SceneLoader plugins to define supported file extensions
  42391. */
  42392. export interface ISceneLoaderPluginExtensions {
  42393. /**
  42394. * Defines the list of supported extensions
  42395. */
  42396. [extension: string]: {
  42397. isBinary: boolean;
  42398. };
  42399. }
  42400. /**
  42401. * Interface used by SceneLoader plugin factory
  42402. */
  42403. export interface ISceneLoaderPluginFactory {
  42404. /**
  42405. * Defines the name of the factory
  42406. */
  42407. name: string;
  42408. /**
  42409. * Function called to create a new plugin
  42410. * @return the new plugin
  42411. */
  42412. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42413. /**
  42414. * The callback that returns true if the data can be directly loaded.
  42415. * @param data string containing the file data
  42416. * @returns if the data can be loaded directly
  42417. */
  42418. canDirectLoad?(data: string): boolean;
  42419. }
  42420. /**
  42421. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42422. */
  42423. export interface ISceneLoaderPluginBase {
  42424. /**
  42425. * The friendly name of this plugin.
  42426. */
  42427. name: string;
  42428. /**
  42429. * The file extensions supported by this plugin.
  42430. */
  42431. extensions: string | ISceneLoaderPluginExtensions;
  42432. /**
  42433. * The callback called when loading from a url.
  42434. * @param scene scene loading this url
  42435. * @param url url to load
  42436. * @param onSuccess callback called when the file successfully loads
  42437. * @param onProgress callback called while file is loading (if the server supports this mode)
  42438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42439. * @param onError callback called when the file fails to load
  42440. * @returns a file request object
  42441. */
  42442. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42443. /**
  42444. * The callback called when loading from a file object.
  42445. * @param scene scene loading this file
  42446. * @param file defines the file to load
  42447. * @param onSuccess defines the callback to call when data is loaded
  42448. * @param onProgress defines the callback to call during loading process
  42449. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42450. * @param onError defines the callback to call when an error occurs
  42451. * @returns a file request object
  42452. */
  42453. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42454. /**
  42455. * The callback that returns true if the data can be directly loaded.
  42456. * @param data string containing the file data
  42457. * @returns if the data can be loaded directly
  42458. */
  42459. canDirectLoad?(data: string): boolean;
  42460. /**
  42461. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42462. * @param scene scene loading this data
  42463. * @param data string containing the data
  42464. * @returns data to pass to the plugin
  42465. */
  42466. directLoad?(scene: Scene, data: string): any;
  42467. /**
  42468. * The callback that allows custom handling of the root url based on the response url.
  42469. * @param rootUrl the original root url
  42470. * @param responseURL the response url if available
  42471. * @returns the new root url
  42472. */
  42473. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42474. }
  42475. /**
  42476. * Interface used to define a SceneLoader plugin
  42477. */
  42478. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42479. /**
  42480. * Import meshes into a scene.
  42481. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42482. * @param scene The scene to import into
  42483. * @param data The data to import
  42484. * @param rootUrl The root url for scene and resources
  42485. * @param meshes The meshes array to import into
  42486. * @param particleSystems The particle systems array to import into
  42487. * @param skeletons The skeletons array to import into
  42488. * @param onError The callback when import fails
  42489. * @returns True if successful or false otherwise
  42490. */
  42491. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42492. /**
  42493. * Load into a scene.
  42494. * @param scene The scene to load into
  42495. * @param data The data to import
  42496. * @param rootUrl The root url for scene and resources
  42497. * @param onError The callback when import fails
  42498. * @returns True if successful or false otherwise
  42499. */
  42500. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42501. /**
  42502. * Load into an asset container.
  42503. * @param scene The scene to load into
  42504. * @param data The data to import
  42505. * @param rootUrl The root url for scene and resources
  42506. * @param onError The callback when import fails
  42507. * @returns The loaded asset container
  42508. */
  42509. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42510. }
  42511. /**
  42512. * Interface used to define an async SceneLoader plugin
  42513. */
  42514. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42515. /**
  42516. * Import meshes into a scene.
  42517. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42518. * @param scene The scene to import into
  42519. * @param data The data to import
  42520. * @param rootUrl The root url for scene and resources
  42521. * @param onProgress The callback when the load progresses
  42522. * @param fileName Defines the name of the file to load
  42523. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42524. */
  42525. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42526. meshes: AbstractMesh[];
  42527. particleSystems: IParticleSystem[];
  42528. skeletons: Skeleton[];
  42529. animationGroups: AnimationGroup[];
  42530. }>;
  42531. /**
  42532. * Load into a scene.
  42533. * @param scene The scene to load into
  42534. * @param data The data to import
  42535. * @param rootUrl The root url for scene and resources
  42536. * @param onProgress The callback when the load progresses
  42537. * @param fileName Defines the name of the file to load
  42538. * @returns Nothing
  42539. */
  42540. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42541. /**
  42542. * Load into an asset container.
  42543. * @param scene The scene to load into
  42544. * @param data The data to import
  42545. * @param rootUrl The root url for scene and resources
  42546. * @param onProgress The callback when the load progresses
  42547. * @param fileName Defines the name of the file to load
  42548. * @returns The loaded asset container
  42549. */
  42550. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42551. }
  42552. /**
  42553. * Class used to load scene from various file formats using registered plugins
  42554. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42555. */
  42556. export class SceneLoader {
  42557. /**
  42558. * No logging while loading
  42559. */
  42560. static readonly NO_LOGGING: number;
  42561. /**
  42562. * Minimal logging while loading
  42563. */
  42564. static readonly MINIMAL_LOGGING: number;
  42565. /**
  42566. * Summary logging while loading
  42567. */
  42568. static readonly SUMMARY_LOGGING: number;
  42569. /**
  42570. * Detailled logging while loading
  42571. */
  42572. static readonly DETAILED_LOGGING: number;
  42573. /**
  42574. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42575. */
  42576. static ForceFullSceneLoadingForIncremental: boolean;
  42577. /**
  42578. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42579. */
  42580. static ShowLoadingScreen: boolean;
  42581. /**
  42582. * Defines the current logging level (while loading the scene)
  42583. * @ignorenaming
  42584. */
  42585. static loggingLevel: number;
  42586. /**
  42587. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42588. */
  42589. static CleanBoneMatrixWeights: boolean;
  42590. /**
  42591. * Event raised when a plugin is used to load a scene
  42592. */
  42593. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42594. private static _registeredPlugins;
  42595. private static _getDefaultPlugin;
  42596. private static _getPluginForExtension;
  42597. private static _getPluginForDirectLoad;
  42598. private static _getPluginForFilename;
  42599. private static _getDirectLoad;
  42600. private static _loadData;
  42601. private static _getFileInfo;
  42602. /**
  42603. * Gets a plugin that can load the given extension
  42604. * @param extension defines the extension to load
  42605. * @returns a plugin or null if none works
  42606. */
  42607. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42608. /**
  42609. * Gets a boolean indicating that the given extension can be loaded
  42610. * @param extension defines the extension to load
  42611. * @returns true if the extension is supported
  42612. */
  42613. static IsPluginForExtensionAvailable(extension: string): boolean;
  42614. /**
  42615. * Adds a new plugin to the list of registered plugins
  42616. * @param plugin defines the plugin to add
  42617. */
  42618. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42619. /**
  42620. * Import meshes into a scene
  42621. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42622. * @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)
  42623. * @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)
  42624. * @param scene the instance of BABYLON.Scene to append to
  42625. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42626. * @param onProgress a callback with a progress event for each file being loaded
  42627. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42628. * @param pluginExtension the extension used to determine the plugin
  42629. * @returns The loaded plugin
  42630. */
  42631. 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>;
  42632. /**
  42633. * Import meshes into a scene
  42634. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42635. * @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)
  42636. * @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)
  42637. * @param scene the instance of BABYLON.Scene to append to
  42638. * @param onProgress a callback with a progress event for each file being loaded
  42639. * @param pluginExtension the extension used to determine the plugin
  42640. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42641. */
  42642. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42643. meshes: AbstractMesh[];
  42644. particleSystems: IParticleSystem[];
  42645. skeletons: Skeleton[];
  42646. animationGroups: AnimationGroup[];
  42647. }>;
  42648. /**
  42649. * Load a scene
  42650. * @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)
  42651. * @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)
  42652. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42653. * @param onSuccess a callback with the scene when import succeeds
  42654. * @param onProgress a callback with a progress event for each file being loaded
  42655. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42656. * @param pluginExtension the extension used to determine the plugin
  42657. * @returns The loaded plugin
  42658. */
  42659. 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>;
  42660. /**
  42661. * Load a scene
  42662. * @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)
  42663. * @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)
  42664. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42665. * @param onProgress a callback with a progress event for each file being loaded
  42666. * @param pluginExtension the extension used to determine the plugin
  42667. * @returns The loaded scene
  42668. */
  42669. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42670. /**
  42671. * Append a scene
  42672. * @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)
  42673. * @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)
  42674. * @param scene is the instance of BABYLON.Scene to append to
  42675. * @param onSuccess a callback with the scene when import succeeds
  42676. * @param onProgress a callback with a progress event for each file being loaded
  42677. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42678. * @param pluginExtension the extension used to determine the plugin
  42679. * @returns The loaded plugin
  42680. */
  42681. 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>;
  42682. /**
  42683. * Append a scene
  42684. * @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)
  42685. * @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)
  42686. * @param scene is the instance of BABYLON.Scene to append to
  42687. * @param onProgress a callback with a progress event for each file being loaded
  42688. * @param pluginExtension the extension used to determine the plugin
  42689. * @returns The given scene
  42690. */
  42691. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42692. /**
  42693. * Load a scene into an asset container
  42694. * @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)
  42695. * @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)
  42696. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42697. * @param onSuccess a callback with the scene when import succeeds
  42698. * @param onProgress a callback with a progress event for each file being loaded
  42699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42700. * @param pluginExtension the extension used to determine the plugin
  42701. * @returns The loaded plugin
  42702. */
  42703. 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>;
  42704. /**
  42705. * Load a scene into an asset container
  42706. * @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)
  42707. * @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)
  42708. * @param scene is the instance of Scene to append to
  42709. * @param onProgress a callback with a progress event for each file being loaded
  42710. * @param pluginExtension the extension used to determine the plugin
  42711. * @returns The loaded asset container
  42712. */
  42713. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42714. }
  42715. }
  42716. declare module BABYLON {
  42717. /**
  42718. * Generic Controller
  42719. */
  42720. export class GenericController extends WebVRController {
  42721. /**
  42722. * Base Url for the controller model.
  42723. */
  42724. static readonly MODEL_BASE_URL: string;
  42725. /**
  42726. * File name for the controller model.
  42727. */
  42728. static readonly MODEL_FILENAME: string;
  42729. /**
  42730. * Creates a new GenericController from a gamepad
  42731. * @param vrGamepad the gamepad that the controller should be created from
  42732. */
  42733. constructor(vrGamepad: any);
  42734. /**
  42735. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42736. * @param scene scene in which to add meshes
  42737. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42738. */
  42739. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42740. /**
  42741. * Called once for each button that changed state since the last frame
  42742. * @param buttonIdx Which button index changed
  42743. * @param state New state of the button
  42744. * @param changes Which properties on the state changed since last frame
  42745. */
  42746. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42747. }
  42748. }
  42749. declare module BABYLON {
  42750. /**
  42751. * Defines the WindowsMotionController object that the state of the windows motion controller
  42752. */
  42753. export class WindowsMotionController extends WebVRController {
  42754. /**
  42755. * The base url used to load the left and right controller models
  42756. */
  42757. static MODEL_BASE_URL: string;
  42758. /**
  42759. * The name of the left controller model file
  42760. */
  42761. static MODEL_LEFT_FILENAME: string;
  42762. /**
  42763. * The name of the right controller model file
  42764. */
  42765. static MODEL_RIGHT_FILENAME: string;
  42766. /**
  42767. * The controller name prefix for this controller type
  42768. */
  42769. static readonly GAMEPAD_ID_PREFIX: string;
  42770. /**
  42771. * The controller id pattern for this controller type
  42772. */
  42773. private static readonly GAMEPAD_ID_PATTERN;
  42774. private _loadedMeshInfo;
  42775. private readonly _mapping;
  42776. /**
  42777. * Fired when the trackpad on this controller is clicked
  42778. */
  42779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42780. /**
  42781. * Fired when the trackpad on this controller is modified
  42782. */
  42783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42784. /**
  42785. * The current x and y values of this controller's trackpad
  42786. */
  42787. trackpad: StickValues;
  42788. /**
  42789. * Creates a new WindowsMotionController from a gamepad
  42790. * @param vrGamepad the gamepad that the controller should be created from
  42791. */
  42792. constructor(vrGamepad: any);
  42793. /**
  42794. * Fired when the trigger on this controller is modified
  42795. */
  42796. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42797. /**
  42798. * Fired when the menu button on this controller is modified
  42799. */
  42800. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42801. /**
  42802. * Fired when the grip button on this controller is modified
  42803. */
  42804. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42805. /**
  42806. * Fired when the thumbstick button on this controller is modified
  42807. */
  42808. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42809. /**
  42810. * Fired when the touchpad button on this controller is modified
  42811. */
  42812. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42813. /**
  42814. * Fired when the touchpad values on this controller are modified
  42815. */
  42816. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42817. private _updateTrackpad;
  42818. /**
  42819. * Called once per frame by the engine.
  42820. */
  42821. update(): void;
  42822. /**
  42823. * Called once for each button that changed state since the last frame
  42824. * @param buttonIdx Which button index changed
  42825. * @param state New state of the button
  42826. * @param changes Which properties on the state changed since last frame
  42827. */
  42828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42829. /**
  42830. * Moves the buttons on the controller mesh based on their current state
  42831. * @param buttonName the name of the button to move
  42832. * @param buttonValue the value of the button which determines the buttons new position
  42833. */
  42834. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42835. /**
  42836. * Moves the axis on the controller mesh based on its current state
  42837. * @param axis the index of the axis
  42838. * @param axisValue the value of the axis which determines the meshes new position
  42839. * @hidden
  42840. */
  42841. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42842. /**
  42843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42844. * @param scene scene in which to add meshes
  42845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42846. */
  42847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42848. /**
  42849. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42850. * can be transformed by button presses and axes values, based on this._mapping.
  42851. *
  42852. * @param scene scene in which the meshes exist
  42853. * @param meshes list of meshes that make up the controller model to process
  42854. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42855. */
  42856. private processModel;
  42857. private createMeshInfo;
  42858. /**
  42859. * Gets the ray of the controller in the direction the controller is pointing
  42860. * @param length the length the resulting ray should be
  42861. * @returns a ray in the direction the controller is pointing
  42862. */
  42863. getForwardRay(length?: number): Ray;
  42864. /**
  42865. * Disposes of the controller
  42866. */
  42867. dispose(): void;
  42868. }
  42869. }
  42870. declare module BABYLON {
  42871. /**
  42872. * Oculus Touch Controller
  42873. */
  42874. export class OculusTouchController extends WebVRController {
  42875. /**
  42876. * Base Url for the controller model.
  42877. */
  42878. static MODEL_BASE_URL: string;
  42879. /**
  42880. * File name for the left controller model.
  42881. */
  42882. static MODEL_LEFT_FILENAME: string;
  42883. /**
  42884. * File name for the right controller model.
  42885. */
  42886. static MODEL_RIGHT_FILENAME: string;
  42887. /**
  42888. * Base Url for the Quest controller model.
  42889. */
  42890. static QUEST_MODEL_BASE_URL: string;
  42891. /**
  42892. * @hidden
  42893. * If the controllers are running on a device that needs the updated Quest controller models
  42894. */
  42895. static _IsQuest: boolean;
  42896. /**
  42897. * Fired when the secondary trigger on this controller is modified
  42898. */
  42899. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42900. /**
  42901. * Fired when the thumb rest on this controller is modified
  42902. */
  42903. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42904. /**
  42905. * Creates a new OculusTouchController from a gamepad
  42906. * @param vrGamepad the gamepad that the controller should be created from
  42907. */
  42908. constructor(vrGamepad: any);
  42909. /**
  42910. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42911. * @param scene scene in which to add meshes
  42912. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42913. */
  42914. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42915. /**
  42916. * Fired when the A button on this controller is modified
  42917. */
  42918. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42919. /**
  42920. * Fired when the B button on this controller is modified
  42921. */
  42922. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42923. /**
  42924. * Fired when the X button on this controller is modified
  42925. */
  42926. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42927. /**
  42928. * Fired when the Y button on this controller is modified
  42929. */
  42930. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42931. /**
  42932. * Called once for each button that changed state since the last frame
  42933. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42934. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42935. * 2) secondary trigger (same)
  42936. * 3) A (right) X (left), touch, pressed = value
  42937. * 4) B / Y
  42938. * 5) thumb rest
  42939. * @param buttonIdx Which button index changed
  42940. * @param state New state of the button
  42941. * @param changes Which properties on the state changed since last frame
  42942. */
  42943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42944. }
  42945. }
  42946. declare module BABYLON {
  42947. /**
  42948. * Vive Controller
  42949. */
  42950. export class ViveController extends WebVRController {
  42951. /**
  42952. * Base Url for the controller model.
  42953. */
  42954. static MODEL_BASE_URL: string;
  42955. /**
  42956. * File name for the controller model.
  42957. */
  42958. static MODEL_FILENAME: string;
  42959. /**
  42960. * Creates a new ViveController from a gamepad
  42961. * @param vrGamepad the gamepad that the controller should be created from
  42962. */
  42963. constructor(vrGamepad: any);
  42964. /**
  42965. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42966. * @param scene scene in which to add meshes
  42967. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42968. */
  42969. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42970. /**
  42971. * Fired when the left button on this controller is modified
  42972. */
  42973. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42974. /**
  42975. * Fired when the right button on this controller is modified
  42976. */
  42977. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42978. /**
  42979. * Fired when the menu button on this controller is modified
  42980. */
  42981. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42982. /**
  42983. * Called once for each button that changed state since the last frame
  42984. * Vive mapping:
  42985. * 0: touchpad
  42986. * 1: trigger
  42987. * 2: left AND right buttons
  42988. * 3: menu button
  42989. * @param buttonIdx Which button index changed
  42990. * @param state New state of the button
  42991. * @param changes Which properties on the state changed since last frame
  42992. */
  42993. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42999. */
  43000. export class WebXRControllerModelLoader {
  43001. /**
  43002. * Creates the WebXRControllerModelLoader
  43003. * @param input xr input that creates the controllers
  43004. */
  43005. constructor(input: WebXRInput);
  43006. }
  43007. }
  43008. declare module BABYLON {
  43009. /**
  43010. * Options for the default xr helper
  43011. */
  43012. export class WebXRDefaultExperienceOptions {
  43013. /**
  43014. * Floor meshes that should be used for teleporting
  43015. */
  43016. floorMeshes: Array<AbstractMesh>;
  43017. /**
  43018. * Enable or disable default UI to enter XR
  43019. */
  43020. disableDefaultUI: boolean;
  43021. /**
  43022. * optional configuration for the output canvas
  43023. */
  43024. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  43025. }
  43026. /**
  43027. * Default experience which provides a similar setup to the previous webVRExperience
  43028. */
  43029. export class WebXRDefaultExperience {
  43030. /**
  43031. * Base experience
  43032. */
  43033. baseExperience: WebXRExperienceHelper;
  43034. /**
  43035. * Input experience extension
  43036. */
  43037. input: WebXRInput;
  43038. /**
  43039. * Loads the controller models
  43040. */
  43041. controllerModelLoader: WebXRControllerModelLoader;
  43042. /**
  43043. * Enables laser pointer and selection
  43044. */
  43045. pointerSelection: WebXRControllerPointerSelection;
  43046. /**
  43047. * Enables teleportation
  43048. */
  43049. teleportation: WebXRControllerTeleportation;
  43050. /**
  43051. * Enables ui for enetering/exiting xr
  43052. */
  43053. enterExitUI: WebXREnterExitUI;
  43054. /**
  43055. * Default target xr should render to
  43056. */
  43057. renderTarget: WebXRRenderTarget;
  43058. /**
  43059. * Creates the default xr experience
  43060. * @param scene scene
  43061. * @param options options for basic configuration
  43062. * @returns resulting WebXRDefaultExperience
  43063. */
  43064. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  43065. private constructor();
  43066. /**
  43067. * DIsposes of the experience helper
  43068. */
  43069. dispose(): void;
  43070. }
  43071. }
  43072. declare module BABYLON {
  43073. /**
  43074. * Contains an array of blocks representing the octree
  43075. */
  43076. export interface IOctreeContainer<T> {
  43077. /**
  43078. * Blocks within the octree
  43079. */
  43080. blocks: Array<OctreeBlock<T>>;
  43081. }
  43082. /**
  43083. * Class used to store a cell in an octree
  43084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43085. */
  43086. export class OctreeBlock<T> {
  43087. /**
  43088. * Gets the content of the current block
  43089. */
  43090. entries: T[];
  43091. /**
  43092. * Gets the list of block children
  43093. */
  43094. blocks: Array<OctreeBlock<T>>;
  43095. private _depth;
  43096. private _maxDepth;
  43097. private _capacity;
  43098. private _minPoint;
  43099. private _maxPoint;
  43100. private _boundingVectors;
  43101. private _creationFunc;
  43102. /**
  43103. * Creates a new block
  43104. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43105. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43106. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43107. * @param depth defines the current depth of this block in the octree
  43108. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43109. * @param creationFunc defines a callback to call when an element is added to the block
  43110. */
  43111. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43112. /**
  43113. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43114. */
  43115. readonly capacity: number;
  43116. /**
  43117. * Gets the minimum vector (in world space) of the block's bounding box
  43118. */
  43119. readonly minPoint: Vector3;
  43120. /**
  43121. * Gets the maximum vector (in world space) of the block's bounding box
  43122. */
  43123. readonly maxPoint: Vector3;
  43124. /**
  43125. * Add a new element to this block
  43126. * @param entry defines the element to add
  43127. */
  43128. addEntry(entry: T): void;
  43129. /**
  43130. * Remove an element from this block
  43131. * @param entry defines the element to remove
  43132. */
  43133. removeEntry(entry: T): void;
  43134. /**
  43135. * Add an array of elements to this block
  43136. * @param entries defines the array of elements to add
  43137. */
  43138. addEntries(entries: T[]): void;
  43139. /**
  43140. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43141. * @param frustumPlanes defines the frustum planes to test
  43142. * @param selection defines the array to store current content if selection is positive
  43143. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43144. */
  43145. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43146. /**
  43147. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43148. * @param sphereCenter defines the bounding sphere center
  43149. * @param sphereRadius defines the bounding sphere radius
  43150. * @param selection defines the array to store current content if selection is positive
  43151. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43152. */
  43153. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43154. /**
  43155. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43156. * @param ray defines the ray to test with
  43157. * @param selection defines the array to store current content if selection is positive
  43158. */
  43159. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43160. /**
  43161. * Subdivide the content into child blocks (this block will then be empty)
  43162. */
  43163. createInnerBlocks(): void;
  43164. /**
  43165. * @hidden
  43166. */
  43167. 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;
  43168. }
  43169. }
  43170. declare module BABYLON {
  43171. /**
  43172. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43173. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43174. */
  43175. export class Octree<T> {
  43176. /** 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.) */
  43177. maxDepth: number;
  43178. /**
  43179. * Blocks within the octree containing objects
  43180. */
  43181. blocks: Array<OctreeBlock<T>>;
  43182. /**
  43183. * Content stored in the octree
  43184. */
  43185. dynamicContent: T[];
  43186. private _maxBlockCapacity;
  43187. private _selectionContent;
  43188. private _creationFunc;
  43189. /**
  43190. * Creates a octree
  43191. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43192. * @param creationFunc function to be used to instatiate the octree
  43193. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43194. * @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.)
  43195. */
  43196. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43197. /** 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.) */
  43198. maxDepth?: number);
  43199. /**
  43200. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43201. * @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);
  43202. * @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);
  43203. * @param entries meshes to be added to the octree blocks
  43204. */
  43205. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43206. /**
  43207. * Adds a mesh to the octree
  43208. * @param entry Mesh to add to the octree
  43209. */
  43210. addMesh(entry: T): void;
  43211. /**
  43212. * Remove an element from the octree
  43213. * @param entry defines the element to remove
  43214. */
  43215. removeMesh(entry: T): void;
  43216. /**
  43217. * Selects an array of meshes within the frustum
  43218. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43219. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43220. * @returns array of meshes within the frustum
  43221. */
  43222. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43223. /**
  43224. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43225. * @param sphereCenter defines the bounding sphere center
  43226. * @param sphereRadius defines the bounding sphere radius
  43227. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43228. * @returns an array of objects that intersect the sphere
  43229. */
  43230. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43231. /**
  43232. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43233. * @param ray defines the ray to test with
  43234. * @returns array of intersected objects
  43235. */
  43236. intersectsRay(ray: Ray): SmartArray<T>;
  43237. /**
  43238. * Adds a mesh into the octree block if it intersects the block
  43239. */
  43240. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43241. /**
  43242. * Adds a submesh into the octree block if it intersects the block
  43243. */
  43244. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43245. }
  43246. }
  43247. declare module BABYLON {
  43248. interface Scene {
  43249. /**
  43250. * @hidden
  43251. * Backing Filed
  43252. */
  43253. _selectionOctree: Octree<AbstractMesh>;
  43254. /**
  43255. * Gets the octree used to boost mesh selection (picking)
  43256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43257. */
  43258. selectionOctree: Octree<AbstractMesh>;
  43259. /**
  43260. * Creates or updates the octree used to boost selection (picking)
  43261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43262. * @param maxCapacity defines the maximum capacity per leaf
  43263. * @param maxDepth defines the maximum depth of the octree
  43264. * @returns an octree of AbstractMesh
  43265. */
  43266. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43267. }
  43268. interface AbstractMesh {
  43269. /**
  43270. * @hidden
  43271. * Backing Field
  43272. */
  43273. _submeshesOctree: Octree<SubMesh>;
  43274. /**
  43275. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43276. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43277. * @param maxCapacity defines the maximum size of each block (64 by default)
  43278. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43279. * @returns the new octree
  43280. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43282. */
  43283. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43284. }
  43285. /**
  43286. * Defines the octree scene component responsible to manage any octrees
  43287. * in a given scene.
  43288. */
  43289. export class OctreeSceneComponent {
  43290. /**
  43291. * The component name help to identify the component in the list of scene components.
  43292. */
  43293. readonly name: string;
  43294. /**
  43295. * The scene the component belongs to.
  43296. */
  43297. scene: Scene;
  43298. /**
  43299. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43300. */
  43301. readonly checksIsEnabled: boolean;
  43302. /**
  43303. * Creates a new instance of the component for the given scene
  43304. * @param scene Defines the scene to register the component in
  43305. */
  43306. constructor(scene: Scene);
  43307. /**
  43308. * Registers the component in a given scene
  43309. */
  43310. register(): void;
  43311. /**
  43312. * Return the list of active meshes
  43313. * @returns the list of active meshes
  43314. */
  43315. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43316. /**
  43317. * Return the list of active sub meshes
  43318. * @param mesh The mesh to get the candidates sub meshes from
  43319. * @returns the list of active sub meshes
  43320. */
  43321. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43322. private _tempRay;
  43323. /**
  43324. * Return the list of sub meshes intersecting with a given local ray
  43325. * @param mesh defines the mesh to find the submesh for
  43326. * @param localRay defines the ray in local space
  43327. * @returns the list of intersecting sub meshes
  43328. */
  43329. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43330. /**
  43331. * Return the list of sub meshes colliding with a collider
  43332. * @param mesh defines the mesh to find the submesh for
  43333. * @param collider defines the collider to evaluate the collision against
  43334. * @returns the list of colliding sub meshes
  43335. */
  43336. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43337. /**
  43338. * Rebuilds the elements related to this component in case of
  43339. * context lost for instance.
  43340. */
  43341. rebuild(): void;
  43342. /**
  43343. * Disposes the component and the associated ressources.
  43344. */
  43345. dispose(): void;
  43346. }
  43347. }
  43348. declare module BABYLON {
  43349. /**
  43350. * Renders a layer on top of an existing scene
  43351. */
  43352. export class UtilityLayerRenderer implements IDisposable {
  43353. /** the original scene that will be rendered on top of */
  43354. originalScene: Scene;
  43355. private _pointerCaptures;
  43356. private _lastPointerEvents;
  43357. private static _DefaultUtilityLayer;
  43358. private static _DefaultKeepDepthUtilityLayer;
  43359. private _sharedGizmoLight;
  43360. private _renderCamera;
  43361. /**
  43362. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43363. * @returns the camera that is used when rendering the utility layer
  43364. */
  43365. getRenderCamera(): Nullable<Camera>;
  43366. /**
  43367. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43368. * @param cam the camera that should be used when rendering the utility layer
  43369. */
  43370. setRenderCamera(cam: Nullable<Camera>): void;
  43371. /**
  43372. * @hidden
  43373. * Light which used by gizmos to get light shading
  43374. */
  43375. _getSharedGizmoLight(): HemisphericLight;
  43376. /**
  43377. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43378. */
  43379. pickUtilitySceneFirst: boolean;
  43380. /**
  43381. * 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)
  43382. */
  43383. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43384. /**
  43385. * 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)
  43386. */
  43387. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43388. /**
  43389. * The scene that is rendered on top of the original scene
  43390. */
  43391. utilityLayerScene: Scene;
  43392. /**
  43393. * If the utility layer should automatically be rendered on top of existing scene
  43394. */
  43395. shouldRender: boolean;
  43396. /**
  43397. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43398. */
  43399. onlyCheckPointerDownEvents: boolean;
  43400. /**
  43401. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43402. */
  43403. processAllEvents: boolean;
  43404. /**
  43405. * Observable raised when the pointer move from the utility layer scene to the main scene
  43406. */
  43407. onPointerOutObservable: Observable<number>;
  43408. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43409. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43410. private _afterRenderObserver;
  43411. private _sceneDisposeObserver;
  43412. private _originalPointerObserver;
  43413. /**
  43414. * Instantiates a UtilityLayerRenderer
  43415. * @param originalScene the original scene that will be rendered on top of
  43416. * @param handleEvents boolean indicating if the utility layer should handle events
  43417. */
  43418. constructor(
  43419. /** the original scene that will be rendered on top of */
  43420. originalScene: Scene, handleEvents?: boolean);
  43421. private _notifyObservers;
  43422. /**
  43423. * Renders the utility layers scene on top of the original scene
  43424. */
  43425. render(): void;
  43426. /**
  43427. * Disposes of the renderer
  43428. */
  43429. dispose(): void;
  43430. private _updateCamera;
  43431. }
  43432. }
  43433. declare module BABYLON {
  43434. /**
  43435. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43436. */
  43437. export class Gizmo implements IDisposable {
  43438. /** The utility layer the gizmo will be added to */
  43439. gizmoLayer: UtilityLayerRenderer;
  43440. /**
  43441. * The root mesh of the gizmo
  43442. */
  43443. _rootMesh: Mesh;
  43444. private _attachedMesh;
  43445. /**
  43446. * Ratio for the scale of the gizmo (Default: 1)
  43447. */
  43448. scaleRatio: number;
  43449. /**
  43450. * If a custom mesh has been set (Default: false)
  43451. */
  43452. protected _customMeshSet: boolean;
  43453. /**
  43454. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43455. * * When set, interactions will be enabled
  43456. */
  43457. attachedMesh: Nullable<AbstractMesh>;
  43458. /**
  43459. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43460. * @param mesh The mesh to replace the default mesh of the gizmo
  43461. */
  43462. setCustomMesh(mesh: Mesh): void;
  43463. /**
  43464. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43465. */
  43466. updateGizmoRotationToMatchAttachedMesh: boolean;
  43467. /**
  43468. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43469. */
  43470. updateGizmoPositionToMatchAttachedMesh: boolean;
  43471. /**
  43472. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43473. */
  43474. updateScale: boolean;
  43475. protected _interactionsEnabled: boolean;
  43476. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43477. private _beforeRenderObserver;
  43478. private _tempVector;
  43479. /**
  43480. * Creates a gizmo
  43481. * @param gizmoLayer The utility layer the gizmo will be added to
  43482. */
  43483. constructor(
  43484. /** The utility layer the gizmo will be added to */
  43485. gizmoLayer?: UtilityLayerRenderer);
  43486. /**
  43487. * Updates the gizmo to match the attached mesh's position/rotation
  43488. */
  43489. protected _update(): void;
  43490. /**
  43491. * Disposes of the gizmo
  43492. */
  43493. dispose(): void;
  43494. }
  43495. }
  43496. declare module BABYLON {
  43497. /**
  43498. * Single plane drag gizmo
  43499. */
  43500. export class PlaneDragGizmo extends Gizmo {
  43501. /**
  43502. * Drag behavior responsible for the gizmos dragging interactions
  43503. */
  43504. dragBehavior: PointerDragBehavior;
  43505. private _pointerObserver;
  43506. /**
  43507. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43508. */
  43509. snapDistance: number;
  43510. /**
  43511. * Event that fires each time the gizmo snaps to a new location.
  43512. * * snapDistance is the the change in distance
  43513. */
  43514. onSnapObservable: Observable<{
  43515. snapDistance: number;
  43516. }>;
  43517. private _plane;
  43518. private _coloredMaterial;
  43519. private _hoverMaterial;
  43520. private _isEnabled;
  43521. private _parent;
  43522. /** @hidden */
  43523. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43524. /** @hidden */
  43525. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43526. /**
  43527. * Creates a PlaneDragGizmo
  43528. * @param gizmoLayer The utility layer the gizmo will be added to
  43529. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43530. * @param color The color of the gizmo
  43531. */
  43532. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43533. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43534. /**
  43535. * If the gizmo is enabled
  43536. */
  43537. isEnabled: boolean;
  43538. /**
  43539. * Disposes of the gizmo
  43540. */
  43541. dispose(): void;
  43542. }
  43543. }
  43544. declare module BABYLON {
  43545. /**
  43546. * Gizmo that enables dragging a mesh along 3 axis
  43547. */
  43548. export class PositionGizmo extends Gizmo {
  43549. /**
  43550. * Internal gizmo used for interactions on the x axis
  43551. */
  43552. xGizmo: AxisDragGizmo;
  43553. /**
  43554. * Internal gizmo used for interactions on the y axis
  43555. */
  43556. yGizmo: AxisDragGizmo;
  43557. /**
  43558. * Internal gizmo used for interactions on the z axis
  43559. */
  43560. zGizmo: AxisDragGizmo;
  43561. /**
  43562. * Internal gizmo used for interactions on the yz plane
  43563. */
  43564. xPlaneGizmo: PlaneDragGizmo;
  43565. /**
  43566. * Internal gizmo used for interactions on the xz plane
  43567. */
  43568. yPlaneGizmo: PlaneDragGizmo;
  43569. /**
  43570. * Internal gizmo used for interactions on the xy plane
  43571. */
  43572. zPlaneGizmo: PlaneDragGizmo;
  43573. /**
  43574. * private variables
  43575. */
  43576. private _meshAttached;
  43577. private _updateGizmoRotationToMatchAttachedMesh;
  43578. private _snapDistance;
  43579. private _scaleRatio;
  43580. /** Fires an event when any of it's sub gizmos are dragged */
  43581. onDragStartObservable: Observable<unknown>;
  43582. /** Fires an event when any of it's sub gizmos are released from dragging */
  43583. onDragEndObservable: Observable<unknown>;
  43584. /**
  43585. * If set to true, planar drag is enabled
  43586. */
  43587. private _planarGizmoEnabled;
  43588. attachedMesh: Nullable<AbstractMesh>;
  43589. /**
  43590. * Creates a PositionGizmo
  43591. * @param gizmoLayer The utility layer the gizmo will be added to
  43592. */
  43593. constructor(gizmoLayer?: UtilityLayerRenderer);
  43594. /**
  43595. * If the planar drag gizmo is enabled
  43596. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43597. */
  43598. planarGizmoEnabled: boolean;
  43599. updateGizmoRotationToMatchAttachedMesh: boolean;
  43600. /**
  43601. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43602. */
  43603. snapDistance: number;
  43604. /**
  43605. * Ratio for the scale of the gizmo (Default: 1)
  43606. */
  43607. scaleRatio: number;
  43608. /**
  43609. * Disposes of the gizmo
  43610. */
  43611. dispose(): void;
  43612. /**
  43613. * CustomMeshes are not supported by this gizmo
  43614. * @param mesh The mesh to replace the default mesh of the gizmo
  43615. */
  43616. setCustomMesh(mesh: Mesh): void;
  43617. }
  43618. }
  43619. declare module BABYLON {
  43620. /**
  43621. * Single axis drag gizmo
  43622. */
  43623. export class AxisDragGizmo extends Gizmo {
  43624. /**
  43625. * Drag behavior responsible for the gizmos dragging interactions
  43626. */
  43627. dragBehavior: PointerDragBehavior;
  43628. private _pointerObserver;
  43629. /**
  43630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43631. */
  43632. snapDistance: number;
  43633. /**
  43634. * Event that fires each time the gizmo snaps to a new location.
  43635. * * snapDistance is the the change in distance
  43636. */
  43637. onSnapObservable: Observable<{
  43638. snapDistance: number;
  43639. }>;
  43640. private _isEnabled;
  43641. private _parent;
  43642. private _arrow;
  43643. private _coloredMaterial;
  43644. private _hoverMaterial;
  43645. /** @hidden */
  43646. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43647. /** @hidden */
  43648. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43649. /**
  43650. * Creates an AxisDragGizmo
  43651. * @param gizmoLayer The utility layer the gizmo will be added to
  43652. * @param dragAxis The axis which the gizmo will be able to drag on
  43653. * @param color The color of the gizmo
  43654. */
  43655. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43656. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43657. /**
  43658. * If the gizmo is enabled
  43659. */
  43660. isEnabled: boolean;
  43661. /**
  43662. * Disposes of the gizmo
  43663. */
  43664. dispose(): void;
  43665. }
  43666. }
  43667. declare module BABYLON.Debug {
  43668. /**
  43669. * The Axes viewer will show 3 axes in a specific point in space
  43670. */
  43671. export class AxesViewer {
  43672. private _xAxis;
  43673. private _yAxis;
  43674. private _zAxis;
  43675. private _scaleLinesFactor;
  43676. private _instanced;
  43677. /**
  43678. * Gets the hosting scene
  43679. */
  43680. scene: Scene;
  43681. /**
  43682. * Gets or sets a number used to scale line length
  43683. */
  43684. scaleLines: number;
  43685. /** Gets the node hierarchy used to render x-axis */
  43686. readonly xAxis: TransformNode;
  43687. /** Gets the node hierarchy used to render y-axis */
  43688. readonly yAxis: TransformNode;
  43689. /** Gets the node hierarchy used to render z-axis */
  43690. readonly zAxis: TransformNode;
  43691. /**
  43692. * Creates a new AxesViewer
  43693. * @param scene defines the hosting scene
  43694. * @param scaleLines defines a number used to scale line length (1 by default)
  43695. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43696. * @param xAxis defines the node hierarchy used to render the x-axis
  43697. * @param yAxis defines the node hierarchy used to render the y-axis
  43698. * @param zAxis defines the node hierarchy used to render the z-axis
  43699. */
  43700. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43701. /**
  43702. * Force the viewer to update
  43703. * @param position defines the position of the viewer
  43704. * @param xaxis defines the x axis of the viewer
  43705. * @param yaxis defines the y axis of the viewer
  43706. * @param zaxis defines the z axis of the viewer
  43707. */
  43708. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43709. /**
  43710. * Creates an instance of this axes viewer.
  43711. * @returns a new axes viewer with instanced meshes
  43712. */
  43713. createInstance(): AxesViewer;
  43714. /** Releases resources */
  43715. dispose(): void;
  43716. private static _SetRenderingGroupId;
  43717. }
  43718. }
  43719. declare module BABYLON.Debug {
  43720. /**
  43721. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43722. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43723. */
  43724. export class BoneAxesViewer extends AxesViewer {
  43725. /**
  43726. * Gets or sets the target mesh where to display the axes viewer
  43727. */
  43728. mesh: Nullable<Mesh>;
  43729. /**
  43730. * Gets or sets the target bone where to display the axes viewer
  43731. */
  43732. bone: Nullable<Bone>;
  43733. /** Gets current position */
  43734. pos: Vector3;
  43735. /** Gets direction of X axis */
  43736. xaxis: Vector3;
  43737. /** Gets direction of Y axis */
  43738. yaxis: Vector3;
  43739. /** Gets direction of Z axis */
  43740. zaxis: Vector3;
  43741. /**
  43742. * Creates a new BoneAxesViewer
  43743. * @param scene defines the hosting scene
  43744. * @param bone defines the target bone
  43745. * @param mesh defines the target mesh
  43746. * @param scaleLines defines a scaling factor for line length (1 by default)
  43747. */
  43748. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43749. /**
  43750. * Force the viewer to update
  43751. */
  43752. update(): void;
  43753. /** Releases resources */
  43754. dispose(): void;
  43755. }
  43756. }
  43757. declare module BABYLON {
  43758. /**
  43759. * Interface used to define scene explorer extensibility option
  43760. */
  43761. export interface IExplorerExtensibilityOption {
  43762. /**
  43763. * Define the option label
  43764. */
  43765. label: string;
  43766. /**
  43767. * Defines the action to execute on click
  43768. */
  43769. action: (entity: any) => void;
  43770. }
  43771. /**
  43772. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43773. */
  43774. export interface IExplorerExtensibilityGroup {
  43775. /**
  43776. * Defines a predicate to test if a given type mut be extended
  43777. */
  43778. predicate: (entity: any) => boolean;
  43779. /**
  43780. * Gets the list of options added to a type
  43781. */
  43782. entries: IExplorerExtensibilityOption[];
  43783. }
  43784. /**
  43785. * Interface used to define the options to use to create the Inspector
  43786. */
  43787. export interface IInspectorOptions {
  43788. /**
  43789. * Display in overlay mode (default: false)
  43790. */
  43791. overlay?: boolean;
  43792. /**
  43793. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43794. */
  43795. globalRoot?: HTMLElement;
  43796. /**
  43797. * Display the Scene explorer
  43798. */
  43799. showExplorer?: boolean;
  43800. /**
  43801. * Display the property inspector
  43802. */
  43803. showInspector?: boolean;
  43804. /**
  43805. * Display in embed mode (both panes on the right)
  43806. */
  43807. embedMode?: boolean;
  43808. /**
  43809. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43810. */
  43811. handleResize?: boolean;
  43812. /**
  43813. * Allow the panes to popup (default: true)
  43814. */
  43815. enablePopup?: boolean;
  43816. /**
  43817. * Allow the panes to be closed by users (default: true)
  43818. */
  43819. enableClose?: boolean;
  43820. /**
  43821. * Optional list of extensibility entries
  43822. */
  43823. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43824. /**
  43825. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43826. */
  43827. inspectorURL?: string;
  43828. }
  43829. interface Scene {
  43830. /**
  43831. * @hidden
  43832. * Backing field
  43833. */
  43834. _debugLayer: DebugLayer;
  43835. /**
  43836. * Gets the debug layer (aka Inspector) associated with the scene
  43837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43838. */
  43839. debugLayer: DebugLayer;
  43840. }
  43841. /**
  43842. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43843. * what is happening in your scene
  43844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43845. */
  43846. export class DebugLayer {
  43847. /**
  43848. * Define the url to get the inspector script from.
  43849. * By default it uses the babylonjs CDN.
  43850. * @ignoreNaming
  43851. */
  43852. static InspectorURL: string;
  43853. private _scene;
  43854. private BJSINSPECTOR;
  43855. private _onPropertyChangedObservable?;
  43856. /**
  43857. * Observable triggered when a property is changed through the inspector.
  43858. */
  43859. readonly onPropertyChangedObservable: any;
  43860. /**
  43861. * Instantiates a new debug layer.
  43862. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43863. * what is happening in your scene
  43864. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43865. * @param scene Defines the scene to inspect
  43866. */
  43867. constructor(scene: Scene);
  43868. /** Creates the inspector window. */
  43869. private _createInspector;
  43870. /**
  43871. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43872. * @param entity defines the entity to select
  43873. * @param lineContainerTitle defines the specific block to highlight
  43874. */
  43875. select(entity: any, lineContainerTitle?: string): void;
  43876. /** Get the inspector from bundle or global */
  43877. private _getGlobalInspector;
  43878. /**
  43879. * Get if the inspector is visible or not.
  43880. * @returns true if visible otherwise, false
  43881. */
  43882. isVisible(): boolean;
  43883. /**
  43884. * Hide the inspector and close its window.
  43885. */
  43886. hide(): void;
  43887. /**
  43888. * Launch the debugLayer.
  43889. * @param config Define the configuration of the inspector
  43890. * @return a promise fulfilled when the debug layer is visible
  43891. */
  43892. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43893. }
  43894. }
  43895. declare module BABYLON {
  43896. /**
  43897. * Class containing static functions to help procedurally build meshes
  43898. */
  43899. export class BoxBuilder {
  43900. /**
  43901. * Creates a box mesh
  43902. * * The parameter `size` sets the size (float) of each box side (default 1)
  43903. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43904. * * 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)
  43905. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43907. * * 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
  43908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43909. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43910. * @param name defines the name of the mesh
  43911. * @param options defines the options used to create the mesh
  43912. * @param scene defines the hosting scene
  43913. * @returns the box mesh
  43914. */
  43915. static CreateBox(name: string, options: {
  43916. size?: number;
  43917. width?: number;
  43918. height?: number;
  43919. depth?: number;
  43920. faceUV?: Vector4[];
  43921. faceColors?: Color4[];
  43922. sideOrientation?: number;
  43923. frontUVs?: Vector4;
  43924. backUVs?: Vector4;
  43925. wrap?: boolean;
  43926. topBaseAt?: number;
  43927. bottomBaseAt?: number;
  43928. updatable?: boolean;
  43929. }, scene?: Nullable<Scene>): Mesh;
  43930. }
  43931. }
  43932. declare module BABYLON {
  43933. /**
  43934. * Class containing static functions to help procedurally build meshes
  43935. */
  43936. export class SphereBuilder {
  43937. /**
  43938. * Creates a sphere mesh
  43939. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43940. * * 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`)
  43941. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43942. * * 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
  43943. * * 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)
  43944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43945. * * 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
  43946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43947. * @param name defines the name of the mesh
  43948. * @param options defines the options used to create the mesh
  43949. * @param scene defines the hosting scene
  43950. * @returns the sphere mesh
  43951. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43952. */
  43953. static CreateSphere(name: string, options: {
  43954. segments?: number;
  43955. diameter?: number;
  43956. diameterX?: number;
  43957. diameterY?: number;
  43958. diameterZ?: number;
  43959. arc?: number;
  43960. slice?: number;
  43961. sideOrientation?: number;
  43962. frontUVs?: Vector4;
  43963. backUVs?: Vector4;
  43964. updatable?: boolean;
  43965. }, scene?: Nullable<Scene>): Mesh;
  43966. }
  43967. }
  43968. declare module BABYLON.Debug {
  43969. /**
  43970. * Used to show the physics impostor around the specific mesh
  43971. */
  43972. export class PhysicsViewer {
  43973. /** @hidden */
  43974. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43975. /** @hidden */
  43976. protected _meshes: Array<Nullable<AbstractMesh>>;
  43977. /** @hidden */
  43978. protected _scene: Nullable<Scene>;
  43979. /** @hidden */
  43980. protected _numMeshes: number;
  43981. /** @hidden */
  43982. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43983. private _renderFunction;
  43984. private _utilityLayer;
  43985. private _debugBoxMesh;
  43986. private _debugSphereMesh;
  43987. private _debugCylinderMesh;
  43988. private _debugMaterial;
  43989. private _debugMeshMeshes;
  43990. /**
  43991. * Creates a new PhysicsViewer
  43992. * @param scene defines the hosting scene
  43993. */
  43994. constructor(scene: Scene);
  43995. /** @hidden */
  43996. protected _updateDebugMeshes(): void;
  43997. /**
  43998. * Renders a specified physic impostor
  43999. * @param impostor defines the impostor to render
  44000. * @param targetMesh defines the mesh represented by the impostor
  44001. * @returns the new debug mesh used to render the impostor
  44002. */
  44003. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44004. /**
  44005. * Hides a specified physic impostor
  44006. * @param impostor defines the impostor to hide
  44007. */
  44008. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44009. private _getDebugMaterial;
  44010. private _getDebugBoxMesh;
  44011. private _getDebugSphereMesh;
  44012. private _getDebugCylinderMesh;
  44013. private _getDebugMeshMesh;
  44014. private _getDebugMesh;
  44015. /** Releases all resources */
  44016. dispose(): void;
  44017. }
  44018. }
  44019. declare module BABYLON {
  44020. /**
  44021. * Class containing static functions to help procedurally build meshes
  44022. */
  44023. export class LinesBuilder {
  44024. /**
  44025. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44026. * * 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
  44027. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44028. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44029. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44030. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44031. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44032. * * 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
  44033. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44035. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44036. * @param name defines the name of the new line system
  44037. * @param options defines the options used to create the line system
  44038. * @param scene defines the hosting scene
  44039. * @returns a new line system mesh
  44040. */
  44041. static CreateLineSystem(name: string, options: {
  44042. lines: Vector3[][];
  44043. updatable?: boolean;
  44044. instance?: Nullable<LinesMesh>;
  44045. colors?: Nullable<Color4[][]>;
  44046. useVertexAlpha?: boolean;
  44047. }, scene: Nullable<Scene>): LinesMesh;
  44048. /**
  44049. * Creates a line mesh
  44050. * 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
  44051. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44052. * * The parameter `points` is an array successive Vector3
  44053. * * 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
  44054. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44055. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44056. * * When updating an instance, remember that only point positions can change, not the number of points
  44057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44059. * @param name defines the name of the new line system
  44060. * @param options defines the options used to create the line system
  44061. * @param scene defines the hosting scene
  44062. * @returns a new line mesh
  44063. */
  44064. static CreateLines(name: string, options: {
  44065. points: Vector3[];
  44066. updatable?: boolean;
  44067. instance?: Nullable<LinesMesh>;
  44068. colors?: Color4[];
  44069. useVertexAlpha?: boolean;
  44070. }, scene?: Nullable<Scene>): LinesMesh;
  44071. /**
  44072. * Creates a dashed line mesh
  44073. * * 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
  44074. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44075. * * The parameter `points` is an array successive Vector3
  44076. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44077. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44078. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44079. * * 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
  44080. * * When updating an instance, remember that only point positions can change, not the number of points
  44081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44082. * @param name defines the name of the mesh
  44083. * @param options defines the options used to create the mesh
  44084. * @param scene defines the hosting scene
  44085. * @returns the dashed line mesh
  44086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44087. */
  44088. static CreateDashedLines(name: string, options: {
  44089. points: Vector3[];
  44090. dashSize?: number;
  44091. gapSize?: number;
  44092. dashNb?: number;
  44093. updatable?: boolean;
  44094. instance?: LinesMesh;
  44095. }, scene?: Nullable<Scene>): LinesMesh;
  44096. }
  44097. }
  44098. declare module BABYLON {
  44099. /**
  44100. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44101. * in order to better appreciate the issue one might have.
  44102. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44103. */
  44104. export class RayHelper {
  44105. /**
  44106. * Defines the ray we are currently tryin to visualize.
  44107. */
  44108. ray: Nullable<Ray>;
  44109. private _renderPoints;
  44110. private _renderLine;
  44111. private _renderFunction;
  44112. private _scene;
  44113. private _updateToMeshFunction;
  44114. private _attachedToMesh;
  44115. private _meshSpaceDirection;
  44116. private _meshSpaceOrigin;
  44117. /**
  44118. * Helper function to create a colored helper in a scene in one line.
  44119. * @param ray Defines the ray we are currently tryin to visualize
  44120. * @param scene Defines the scene the ray is used in
  44121. * @param color Defines the color we want to see the ray in
  44122. * @returns The newly created ray helper.
  44123. */
  44124. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44125. /**
  44126. * Instantiate a new ray helper.
  44127. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44128. * in order to better appreciate the issue one might have.
  44129. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44130. * @param ray Defines the ray we are currently tryin to visualize
  44131. */
  44132. constructor(ray: Ray);
  44133. /**
  44134. * Shows the ray we are willing to debug.
  44135. * @param scene Defines the scene the ray needs to be rendered in
  44136. * @param color Defines the color the ray needs to be rendered in
  44137. */
  44138. show(scene: Scene, color?: Color3): void;
  44139. /**
  44140. * Hides the ray we are debugging.
  44141. */
  44142. hide(): void;
  44143. private _render;
  44144. /**
  44145. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44146. * @param mesh Defines the mesh we want the helper attached to
  44147. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44148. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44149. * @param length Defines the length of the ray
  44150. */
  44151. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44152. /**
  44153. * Detach the ray helper from the mesh it has previously been attached to.
  44154. */
  44155. detachFromMesh(): void;
  44156. private _updateToMesh;
  44157. /**
  44158. * Dispose the helper and release its associated resources.
  44159. */
  44160. dispose(): void;
  44161. }
  44162. }
  44163. declare module BABYLON.Debug {
  44164. /**
  44165. * Class used to render a debug view of a given skeleton
  44166. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44167. */
  44168. export class SkeletonViewer {
  44169. /** defines the skeleton to render */
  44170. skeleton: Skeleton;
  44171. /** defines the mesh attached to the skeleton */
  44172. mesh: AbstractMesh;
  44173. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44174. autoUpdateBonesMatrices: boolean;
  44175. /** defines the rendering group id to use with the viewer */
  44176. renderingGroupId: number;
  44177. /** Gets or sets the color used to render the skeleton */
  44178. color: Color3;
  44179. private _scene;
  44180. private _debugLines;
  44181. private _debugMesh;
  44182. private _isEnabled;
  44183. private _renderFunction;
  44184. private _utilityLayer;
  44185. /**
  44186. * Returns the mesh used to render the bones
  44187. */
  44188. readonly debugMesh: Nullable<LinesMesh>;
  44189. /**
  44190. * Creates a new SkeletonViewer
  44191. * @param skeleton defines the skeleton to render
  44192. * @param mesh defines the mesh attached to the skeleton
  44193. * @param scene defines the hosting scene
  44194. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44195. * @param renderingGroupId defines the rendering group id to use with the viewer
  44196. */
  44197. constructor(
  44198. /** defines the skeleton to render */
  44199. skeleton: Skeleton,
  44200. /** defines the mesh attached to the skeleton */
  44201. mesh: AbstractMesh, scene: Scene,
  44202. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44203. autoUpdateBonesMatrices?: boolean,
  44204. /** defines the rendering group id to use with the viewer */
  44205. renderingGroupId?: number);
  44206. /** Gets or sets a boolean indicating if the viewer is enabled */
  44207. isEnabled: boolean;
  44208. private _getBonePosition;
  44209. private _getLinesForBonesWithLength;
  44210. private _getLinesForBonesNoLength;
  44211. /** Update the viewer to sync with current skeleton state */
  44212. update(): void;
  44213. /** Release associated resources */
  44214. dispose(): void;
  44215. }
  44216. }
  44217. declare module BABYLON {
  44218. /**
  44219. * Options to create the null engine
  44220. */
  44221. export class NullEngineOptions {
  44222. /**
  44223. * Render width (Default: 512)
  44224. */
  44225. renderWidth: number;
  44226. /**
  44227. * Render height (Default: 256)
  44228. */
  44229. renderHeight: number;
  44230. /**
  44231. * Texture size (Default: 512)
  44232. */
  44233. textureSize: number;
  44234. /**
  44235. * If delta time between frames should be constant
  44236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44237. */
  44238. deterministicLockstep: boolean;
  44239. /**
  44240. * Maximum about of steps between frames (Default: 4)
  44241. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44242. */
  44243. lockstepMaxSteps: number;
  44244. }
  44245. /**
  44246. * The null engine class provides support for headless version of babylon.js.
  44247. * This can be used in server side scenario or for testing purposes
  44248. */
  44249. export class NullEngine extends Engine {
  44250. private _options;
  44251. /**
  44252. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44253. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44254. * @returns true if engine is in deterministic lock step mode
  44255. */
  44256. isDeterministicLockStep(): boolean;
  44257. /**
  44258. * Gets the max steps when engine is running in deterministic lock step
  44259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44260. * @returns the max steps
  44261. */
  44262. getLockstepMaxSteps(): number;
  44263. /**
  44264. * Gets the current hardware scaling level.
  44265. * By default the hardware scaling level is computed from the window device ratio.
  44266. * 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.
  44267. * @returns a number indicating the current hardware scaling level
  44268. */
  44269. getHardwareScalingLevel(): number;
  44270. constructor(options?: NullEngineOptions);
  44271. /**
  44272. * Creates a vertex buffer
  44273. * @param vertices the data for the vertex buffer
  44274. * @returns the new WebGL static buffer
  44275. */
  44276. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44277. /**
  44278. * Creates a new index buffer
  44279. * @param indices defines the content of the index buffer
  44280. * @param updatable defines if the index buffer must be updatable
  44281. * @returns a new webGL buffer
  44282. */
  44283. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44284. /**
  44285. * Clear the current render buffer or the current render target (if any is set up)
  44286. * @param color defines the color to use
  44287. * @param backBuffer defines if the back buffer must be cleared
  44288. * @param depth defines if the depth buffer must be cleared
  44289. * @param stencil defines if the stencil buffer must be cleared
  44290. */
  44291. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44292. /**
  44293. * Gets the current render width
  44294. * @param useScreen defines if screen size must be used (or the current render target if any)
  44295. * @returns a number defining the current render width
  44296. */
  44297. getRenderWidth(useScreen?: boolean): number;
  44298. /**
  44299. * Gets the current render height
  44300. * @param useScreen defines if screen size must be used (or the current render target if any)
  44301. * @returns a number defining the current render height
  44302. */
  44303. getRenderHeight(useScreen?: boolean): number;
  44304. /**
  44305. * Set the WebGL's viewport
  44306. * @param viewport defines the viewport element to be used
  44307. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44308. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44309. */
  44310. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44311. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44312. /**
  44313. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44314. * @param pipelineContext defines the pipeline context to use
  44315. * @param uniformsNames defines the list of uniform names
  44316. * @returns an array of webGL uniform locations
  44317. */
  44318. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44319. /**
  44320. * Gets the lsit of active attributes for a given webGL program
  44321. * @param pipelineContext defines the pipeline context to use
  44322. * @param attributesNames defines the list of attribute names to get
  44323. * @returns an array of indices indicating the offset of each attribute
  44324. */
  44325. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44326. /**
  44327. * Binds an effect to the webGL context
  44328. * @param effect defines the effect to bind
  44329. */
  44330. bindSamplers(effect: Effect): void;
  44331. /**
  44332. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44333. * @param effect defines the effect to activate
  44334. */
  44335. enableEffect(effect: Effect): void;
  44336. /**
  44337. * Set various states to the webGL context
  44338. * @param culling defines backface culling state
  44339. * @param zOffset defines the value to apply to zOffset (0 by default)
  44340. * @param force defines if states must be applied even if cache is up to date
  44341. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44342. */
  44343. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44344. /**
  44345. * Set the value of an uniform to an array of int32
  44346. * @param uniform defines the webGL uniform location where to store the value
  44347. * @param array defines the array of int32 to store
  44348. */
  44349. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44350. /**
  44351. * Set the value of an uniform to an array of int32 (stored as vec2)
  44352. * @param uniform defines the webGL uniform location where to store the value
  44353. * @param array defines the array of int32 to store
  44354. */
  44355. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44356. /**
  44357. * Set the value of an uniform to an array of int32 (stored as vec3)
  44358. * @param uniform defines the webGL uniform location where to store the value
  44359. * @param array defines the array of int32 to store
  44360. */
  44361. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44362. /**
  44363. * Set the value of an uniform to an array of int32 (stored as vec4)
  44364. * @param uniform defines the webGL uniform location where to store the value
  44365. * @param array defines the array of int32 to store
  44366. */
  44367. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44368. /**
  44369. * Set the value of an uniform to an array of float32
  44370. * @param uniform defines the webGL uniform location where to store the value
  44371. * @param array defines the array of float32 to store
  44372. */
  44373. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44374. /**
  44375. * Set the value of an uniform to an array of float32 (stored as vec2)
  44376. * @param uniform defines the webGL uniform location where to store the value
  44377. * @param array defines the array of float32 to store
  44378. */
  44379. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44380. /**
  44381. * Set the value of an uniform to an array of float32 (stored as vec3)
  44382. * @param uniform defines the webGL uniform location where to store the value
  44383. * @param array defines the array of float32 to store
  44384. */
  44385. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44386. /**
  44387. * Set the value of an uniform to an array of float32 (stored as vec4)
  44388. * @param uniform defines the webGL uniform location where to store the value
  44389. * @param array defines the array of float32 to store
  44390. */
  44391. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44392. /**
  44393. * Set the value of an uniform to an array of number
  44394. * @param uniform defines the webGL uniform location where to store the value
  44395. * @param array defines the array of number to store
  44396. */
  44397. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44398. /**
  44399. * Set the value of an uniform to an array of number (stored as vec2)
  44400. * @param uniform defines the webGL uniform location where to store the value
  44401. * @param array defines the array of number to store
  44402. */
  44403. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44404. /**
  44405. * Set the value of an uniform to an array of number (stored as vec3)
  44406. * @param uniform defines the webGL uniform location where to store the value
  44407. * @param array defines the array of number to store
  44408. */
  44409. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44410. /**
  44411. * Set the value of an uniform to an array of number (stored as vec4)
  44412. * @param uniform defines the webGL uniform location where to store the value
  44413. * @param array defines the array of number to store
  44414. */
  44415. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44416. /**
  44417. * Set the value of an uniform to an array of float32 (stored as matrices)
  44418. * @param uniform defines the webGL uniform location where to store the value
  44419. * @param matrices defines the array of float32 to store
  44420. */
  44421. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44422. /**
  44423. * Set the value of an uniform to a matrix (3x3)
  44424. * @param uniform defines the webGL uniform location where to store the value
  44425. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44426. */
  44427. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44428. /**
  44429. * Set the value of an uniform to a matrix (2x2)
  44430. * @param uniform defines the webGL uniform location where to store the value
  44431. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44432. */
  44433. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44434. /**
  44435. * Set the value of an uniform to a number (float)
  44436. * @param uniform defines the webGL uniform location where to store the value
  44437. * @param value defines the float number to store
  44438. */
  44439. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44440. /**
  44441. * Set the value of an uniform to a vec2
  44442. * @param uniform defines the webGL uniform location where to store the value
  44443. * @param x defines the 1st component of the value
  44444. * @param y defines the 2nd component of the value
  44445. */
  44446. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44447. /**
  44448. * Set the value of an uniform to a vec3
  44449. * @param uniform defines the webGL uniform location where to store the value
  44450. * @param x defines the 1st component of the value
  44451. * @param y defines the 2nd component of the value
  44452. * @param z defines the 3rd component of the value
  44453. */
  44454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44455. /**
  44456. * Set the value of an uniform to a boolean
  44457. * @param uniform defines the webGL uniform location where to store the value
  44458. * @param bool defines the boolean to store
  44459. */
  44460. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44461. /**
  44462. * Set the value of an uniform to a vec4
  44463. * @param uniform defines the webGL uniform location where to store the value
  44464. * @param x defines the 1st component of the value
  44465. * @param y defines the 2nd component of the value
  44466. * @param z defines the 3rd component of the value
  44467. * @param w defines the 4th component of the value
  44468. */
  44469. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44470. /**
  44471. * Sets the current alpha mode
  44472. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44473. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44475. */
  44476. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44477. /**
  44478. * Bind webGl buffers directly to the webGL context
  44479. * @param vertexBuffers defines the vertex buffer to bind
  44480. * @param indexBuffer defines the index buffer to bind
  44481. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44482. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44483. * @param effect defines the effect associated with the vertex buffer
  44484. */
  44485. bindBuffers(vertexBuffers: {
  44486. [key: string]: VertexBuffer;
  44487. }, indexBuffer: DataBuffer, effect: Effect): void;
  44488. /**
  44489. * Force the entire cache to be cleared
  44490. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44491. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44492. */
  44493. wipeCaches(bruteForce?: boolean): void;
  44494. /**
  44495. * Send a draw order
  44496. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44497. * @param indexStart defines the starting index
  44498. * @param indexCount defines the number of index to draw
  44499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44500. */
  44501. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44502. /**
  44503. * Draw a list of indexed primitives
  44504. * @param fillMode defines the primitive to use
  44505. * @param indexStart defines the starting index
  44506. * @param indexCount defines the number of index to draw
  44507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44508. */
  44509. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44510. /**
  44511. * Draw a list of unindexed primitives
  44512. * @param fillMode defines the primitive to use
  44513. * @param verticesStart defines the index of first vertex to draw
  44514. * @param verticesCount defines the count of vertices to draw
  44515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44516. */
  44517. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44518. /** @hidden */
  44519. _createTexture(): WebGLTexture;
  44520. /** @hidden */
  44521. _releaseTexture(texture: InternalTexture): void;
  44522. /**
  44523. * Usually called from Texture.ts.
  44524. * Passed information to create a WebGLTexture
  44525. * @param urlArg defines a value which contains one of the following:
  44526. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44527. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44528. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44529. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44530. * @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)
  44531. * @param scene needed for loading to the correct scene
  44532. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44533. * @param onLoad optional callback to be called upon successful completion
  44534. * @param onError optional callback to be called upon failure
  44535. * @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
  44536. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44537. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44538. * @param forcedExtension defines the extension to use to pick the right loader
  44539. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44540. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44541. */
  44542. 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;
  44543. /**
  44544. * Creates a new render target texture
  44545. * @param size defines the size of the texture
  44546. * @param options defines the options used to create the texture
  44547. * @returns a new render target texture stored in an InternalTexture
  44548. */
  44549. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44550. /**
  44551. * Update the sampling mode of a given texture
  44552. * @param samplingMode defines the required sampling mode
  44553. * @param texture defines the texture to update
  44554. */
  44555. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44556. /**
  44557. * Binds the frame buffer to the specified texture.
  44558. * @param texture The texture to render to or null for the default canvas
  44559. * @param faceIndex The face of the texture to render to in case of cube texture
  44560. * @param requiredWidth The width of the target to render to
  44561. * @param requiredHeight The height of the target to render to
  44562. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44563. * @param depthStencilTexture The depth stencil texture to use to render
  44564. * @param lodLevel defines le lod level to bind to the frame buffer
  44565. */
  44566. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44567. /**
  44568. * Unbind the current render target texture from the webGL context
  44569. * @param texture defines the render target texture to unbind
  44570. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44571. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44572. */
  44573. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44574. /**
  44575. * Creates a dynamic vertex buffer
  44576. * @param vertices the data for the dynamic vertex buffer
  44577. * @returns the new WebGL dynamic buffer
  44578. */
  44579. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44580. /**
  44581. * Update the content of a dynamic texture
  44582. * @param texture defines the texture to update
  44583. * @param canvas defines the canvas containing the source
  44584. * @param invertY defines if data must be stored with Y axis inverted
  44585. * @param premulAlpha defines if alpha is stored as premultiplied
  44586. * @param format defines the format of the data
  44587. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44588. */
  44589. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44590. /**
  44591. * Gets a boolean indicating if all created effects are ready
  44592. * @returns true if all effects are ready
  44593. */
  44594. areAllEffectsReady(): boolean;
  44595. /**
  44596. * @hidden
  44597. * Get the current error code of the webGL context
  44598. * @returns the error code
  44599. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44600. */
  44601. getError(): number;
  44602. /** @hidden */
  44603. _getUnpackAlignement(): number;
  44604. /** @hidden */
  44605. _unpackFlipY(value: boolean): void;
  44606. /**
  44607. * Update a dynamic index buffer
  44608. * @param indexBuffer defines the target index buffer
  44609. * @param indices defines the data to update
  44610. * @param offset defines the offset in the target index buffer where update should start
  44611. */
  44612. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44613. /**
  44614. * Updates a dynamic vertex buffer.
  44615. * @param vertexBuffer the vertex buffer to update
  44616. * @param vertices the data used to update the vertex buffer
  44617. * @param byteOffset the byte offset of the data (optional)
  44618. * @param byteLength the byte length of the data (optional)
  44619. */
  44620. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44621. /** @hidden */
  44622. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44623. /** @hidden */
  44624. _bindTexture(channel: number, texture: InternalTexture): void;
  44625. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44626. /**
  44627. * 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
  44628. */
  44629. releaseEffects(): void;
  44630. displayLoadingUI(): void;
  44631. hideLoadingUI(): void;
  44632. /** @hidden */
  44633. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44634. /** @hidden */
  44635. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44636. /** @hidden */
  44637. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44638. /** @hidden */
  44639. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44640. }
  44641. }
  44642. declare module BABYLON {
  44643. /** @hidden */
  44644. export class _OcclusionDataStorage {
  44645. /** @hidden */
  44646. occlusionInternalRetryCounter: number;
  44647. /** @hidden */
  44648. isOcclusionQueryInProgress: boolean;
  44649. /** @hidden */
  44650. isOccluded: boolean;
  44651. /** @hidden */
  44652. occlusionRetryCount: number;
  44653. /** @hidden */
  44654. occlusionType: number;
  44655. /** @hidden */
  44656. occlusionQueryAlgorithmType: number;
  44657. }
  44658. interface Engine {
  44659. /**
  44660. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44661. * @return the new query
  44662. */
  44663. createQuery(): WebGLQuery;
  44664. /**
  44665. * Delete and release a webGL query
  44666. * @param query defines the query to delete
  44667. * @return the current engine
  44668. */
  44669. deleteQuery(query: WebGLQuery): Engine;
  44670. /**
  44671. * Check if a given query has resolved and got its value
  44672. * @param query defines the query to check
  44673. * @returns true if the query got its value
  44674. */
  44675. isQueryResultAvailable(query: WebGLQuery): boolean;
  44676. /**
  44677. * Gets the value of a given query
  44678. * @param query defines the query to check
  44679. * @returns the value of the query
  44680. */
  44681. getQueryResult(query: WebGLQuery): number;
  44682. /**
  44683. * Initiates an occlusion query
  44684. * @param algorithmType defines the algorithm to use
  44685. * @param query defines the query to use
  44686. * @returns the current engine
  44687. * @see http://doc.babylonjs.com/features/occlusionquery
  44688. */
  44689. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44690. /**
  44691. * Ends an occlusion query
  44692. * @see http://doc.babylonjs.com/features/occlusionquery
  44693. * @param algorithmType defines the algorithm to use
  44694. * @returns the current engine
  44695. */
  44696. endOcclusionQuery(algorithmType: number): Engine;
  44697. /**
  44698. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44699. * Please note that only one query can be issued at a time
  44700. * @returns a time token used to track the time span
  44701. */
  44702. startTimeQuery(): Nullable<_TimeToken>;
  44703. /**
  44704. * Ends a time query
  44705. * @param token defines the token used to measure the time span
  44706. * @returns the time spent (in ns)
  44707. */
  44708. endTimeQuery(token: _TimeToken): int;
  44709. /** @hidden */
  44710. _currentNonTimestampToken: Nullable<_TimeToken>;
  44711. /** @hidden */
  44712. _createTimeQuery(): WebGLQuery;
  44713. /** @hidden */
  44714. _deleteTimeQuery(query: WebGLQuery): void;
  44715. /** @hidden */
  44716. _getGlAlgorithmType(algorithmType: number): number;
  44717. /** @hidden */
  44718. _getTimeQueryResult(query: WebGLQuery): any;
  44719. /** @hidden */
  44720. _getTimeQueryAvailability(query: WebGLQuery): any;
  44721. }
  44722. interface AbstractMesh {
  44723. /**
  44724. * Backing filed
  44725. * @hidden
  44726. */
  44727. __occlusionDataStorage: _OcclusionDataStorage;
  44728. /**
  44729. * Access property
  44730. * @hidden
  44731. */
  44732. _occlusionDataStorage: _OcclusionDataStorage;
  44733. /**
  44734. * 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.
  44735. * The default value is -1 which means don't break the query and wait till the result
  44736. * @see http://doc.babylonjs.com/features/occlusionquery
  44737. */
  44738. occlusionRetryCount: number;
  44739. /**
  44740. * 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:
  44741. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44742. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44743. * * 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.
  44744. * @see http://doc.babylonjs.com/features/occlusionquery
  44745. */
  44746. occlusionType: number;
  44747. /**
  44748. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44749. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44750. * * 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.
  44751. * @see http://doc.babylonjs.com/features/occlusionquery
  44752. */
  44753. occlusionQueryAlgorithmType: number;
  44754. /**
  44755. * 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
  44756. * @see http://doc.babylonjs.com/features/occlusionquery
  44757. */
  44758. isOccluded: boolean;
  44759. /**
  44760. * Flag to check the progress status of the query
  44761. * @see http://doc.babylonjs.com/features/occlusionquery
  44762. */
  44763. isOcclusionQueryInProgress: boolean;
  44764. }
  44765. }
  44766. declare module BABYLON {
  44767. /** @hidden */
  44768. export var _forceTransformFeedbackToBundle: boolean;
  44769. interface Engine {
  44770. /**
  44771. * Creates a webGL transform feedback object
  44772. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44773. * @returns the webGL transform feedback object
  44774. */
  44775. createTransformFeedback(): WebGLTransformFeedback;
  44776. /**
  44777. * Delete a webGL transform feedback object
  44778. * @param value defines the webGL transform feedback object to delete
  44779. */
  44780. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44781. /**
  44782. * Bind a webGL transform feedback object to the webgl context
  44783. * @param value defines the webGL transform feedback object to bind
  44784. */
  44785. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44786. /**
  44787. * Begins a transform feedback operation
  44788. * @param usePoints defines if points or triangles must be used
  44789. */
  44790. beginTransformFeedback(usePoints: boolean): void;
  44791. /**
  44792. * Ends a transform feedback operation
  44793. */
  44794. endTransformFeedback(): void;
  44795. /**
  44796. * Specify the varyings to use with transform feedback
  44797. * @param program defines the associated webGL program
  44798. * @param value defines the list of strings representing the varying names
  44799. */
  44800. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44801. /**
  44802. * Bind a webGL buffer for a transform feedback operation
  44803. * @param value defines the webGL buffer to bind
  44804. */
  44805. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /**
  44810. * Creation options of the multi render target texture.
  44811. */
  44812. export interface IMultiRenderTargetOptions {
  44813. /**
  44814. * Define if the texture needs to create mip maps after render.
  44815. */
  44816. generateMipMaps?: boolean;
  44817. /**
  44818. * Define the types of all the draw buffers we want to create
  44819. */
  44820. types?: number[];
  44821. /**
  44822. * Define the sampling modes of all the draw buffers we want to create
  44823. */
  44824. samplingModes?: number[];
  44825. /**
  44826. * Define if a depth buffer is required
  44827. */
  44828. generateDepthBuffer?: boolean;
  44829. /**
  44830. * Define if a stencil buffer is required
  44831. */
  44832. generateStencilBuffer?: boolean;
  44833. /**
  44834. * Define if a depth texture is required instead of a depth buffer
  44835. */
  44836. generateDepthTexture?: boolean;
  44837. /**
  44838. * Define the number of desired draw buffers
  44839. */
  44840. textureCount?: number;
  44841. /**
  44842. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44843. */
  44844. doNotChangeAspectRatio?: boolean;
  44845. /**
  44846. * Define the default type of the buffers we are creating
  44847. */
  44848. defaultType?: number;
  44849. }
  44850. /**
  44851. * A multi render target, like a render target provides the ability to render to a texture.
  44852. * Unlike the render target, it can render to several draw buffers in one draw.
  44853. * This is specially interesting in deferred rendering or for any effects requiring more than
  44854. * just one color from a single pass.
  44855. */
  44856. export class MultiRenderTarget extends RenderTargetTexture {
  44857. private _internalTextures;
  44858. private _textures;
  44859. private _multiRenderTargetOptions;
  44860. /**
  44861. * Get if draw buffers are currently supported by the used hardware and browser.
  44862. */
  44863. readonly isSupported: boolean;
  44864. /**
  44865. * Get the list of textures generated by the multi render target.
  44866. */
  44867. readonly textures: Texture[];
  44868. /**
  44869. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44870. */
  44871. readonly depthTexture: Texture;
  44872. /**
  44873. * Set the wrapping mode on U of all the textures we are rendering to.
  44874. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44875. */
  44876. wrapU: number;
  44877. /**
  44878. * Set the wrapping mode on V of all the textures we are rendering to.
  44879. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44880. */
  44881. wrapV: number;
  44882. /**
  44883. * Instantiate a new multi render target texture.
  44884. * A multi render target, like a render target provides the ability to render to a texture.
  44885. * Unlike the render target, it can render to several draw buffers in one draw.
  44886. * This is specially interesting in deferred rendering or for any effects requiring more than
  44887. * just one color from a single pass.
  44888. * @param name Define the name of the texture
  44889. * @param size Define the size of the buffers to render to
  44890. * @param count Define the number of target we are rendering into
  44891. * @param scene Define the scene the texture belongs to
  44892. * @param options Define the options used to create the multi render target
  44893. */
  44894. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44895. /** @hidden */
  44896. _rebuild(): void;
  44897. private _createInternalTextures;
  44898. private _createTextures;
  44899. /**
  44900. * Define the number of samples used if MSAA is enabled.
  44901. */
  44902. samples: number;
  44903. /**
  44904. * Resize all the textures in the multi render target.
  44905. * Be carrefull as it will recreate all the data in the new texture.
  44906. * @param size Define the new size
  44907. */
  44908. resize(size: any): void;
  44909. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44910. /**
  44911. * Dispose the render targets and their associated resources
  44912. */
  44913. dispose(): void;
  44914. /**
  44915. * Release all the underlying texture used as draw buffers.
  44916. */
  44917. releaseInternalTextures(): void;
  44918. }
  44919. }
  44920. declare module BABYLON {
  44921. interface ThinEngine {
  44922. /**
  44923. * Unbind a list of render target textures from the webGL context
  44924. * This is used only when drawBuffer extension or webGL2 are active
  44925. * @param textures defines the render target textures to unbind
  44926. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44927. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44928. */
  44929. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44930. /**
  44931. * Create a multi render target texture
  44932. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44933. * @param size defines the size of the texture
  44934. * @param options defines the creation options
  44935. * @returns the cube texture as an InternalTexture
  44936. */
  44937. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44938. /**
  44939. * Update the sample count for a given multiple render target texture
  44940. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44941. * @param textures defines the textures to update
  44942. * @param samples defines the sample count to set
  44943. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44944. */
  44945. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44946. }
  44947. }
  44948. declare module BABYLON {
  44949. /**
  44950. * Class used to define an additional view for the engine
  44951. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44952. */
  44953. export class EngineView {
  44954. /** Defines the canvas where to render the view */
  44955. target: HTMLCanvasElement;
  44956. /** Defines an optional camera used to render the view (will use active camera else) */
  44957. camera?: Camera;
  44958. }
  44959. interface Engine {
  44960. /**
  44961. * Gets or sets the HTML element to use for attaching events
  44962. */
  44963. inputElement: Nullable<HTMLElement>;
  44964. /**
  44965. * Gets the current engine view
  44966. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44967. */
  44968. activeView: Nullable<EngineView>;
  44969. /** Gets or sets the list of views */
  44970. views: EngineView[];
  44971. /**
  44972. * Register a new child canvas
  44973. * @param canvas defines the canvas to register
  44974. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44975. * @returns the associated view
  44976. */
  44977. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44978. /**
  44979. * Remove a registered child canvas
  44980. * @param canvas defines the canvas to remove
  44981. * @returns the current engine
  44982. */
  44983. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44984. }
  44985. }
  44986. declare module BABYLON {
  44987. /**
  44988. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44989. */
  44990. export interface CubeMapInfo {
  44991. /**
  44992. * The pixel array for the front face.
  44993. * This is stored in format, left to right, up to down format.
  44994. */
  44995. front: Nullable<ArrayBufferView>;
  44996. /**
  44997. * The pixel array for the back face.
  44998. * This is stored in format, left to right, up to down format.
  44999. */
  45000. back: Nullable<ArrayBufferView>;
  45001. /**
  45002. * The pixel array for the left face.
  45003. * This is stored in format, left to right, up to down format.
  45004. */
  45005. left: Nullable<ArrayBufferView>;
  45006. /**
  45007. * The pixel array for the right face.
  45008. * This is stored in format, left to right, up to down format.
  45009. */
  45010. right: Nullable<ArrayBufferView>;
  45011. /**
  45012. * The pixel array for the up face.
  45013. * This is stored in format, left to right, up to down format.
  45014. */
  45015. up: Nullable<ArrayBufferView>;
  45016. /**
  45017. * The pixel array for the down face.
  45018. * This is stored in format, left to right, up to down format.
  45019. */
  45020. down: Nullable<ArrayBufferView>;
  45021. /**
  45022. * The size of the cubemap stored.
  45023. *
  45024. * Each faces will be size * size pixels.
  45025. */
  45026. size: number;
  45027. /**
  45028. * The format of the texture.
  45029. *
  45030. * RGBA, RGB.
  45031. */
  45032. format: number;
  45033. /**
  45034. * The type of the texture data.
  45035. *
  45036. * UNSIGNED_INT, FLOAT.
  45037. */
  45038. type: number;
  45039. /**
  45040. * Specifies whether the texture is in gamma space.
  45041. */
  45042. gammaSpace: boolean;
  45043. }
  45044. /**
  45045. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  45046. */
  45047. export class PanoramaToCubeMapTools {
  45048. private static FACE_FRONT;
  45049. private static FACE_BACK;
  45050. private static FACE_RIGHT;
  45051. private static FACE_LEFT;
  45052. private static FACE_DOWN;
  45053. private static FACE_UP;
  45054. /**
  45055. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  45056. *
  45057. * @param float32Array The source data.
  45058. * @param inputWidth The width of the input panorama.
  45059. * @param inputHeight The height of the input panorama.
  45060. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  45061. * @return The cubemap data
  45062. */
  45063. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  45064. private static CreateCubemapTexture;
  45065. private static CalcProjectionSpherical;
  45066. }
  45067. }
  45068. declare module BABYLON {
  45069. /**
  45070. * Helper class dealing with the extraction of spherical polynomial dataArray
  45071. * from a cube map.
  45072. */
  45073. export class CubeMapToSphericalPolynomialTools {
  45074. private static FileFaces;
  45075. /**
  45076. * Converts a texture to the according Spherical Polynomial data.
  45077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45078. *
  45079. * @param texture The texture to extract the information from.
  45080. * @return The Spherical Polynomial data.
  45081. */
  45082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  45083. /**
  45084. * Converts a cubemap to the according Spherical Polynomial data.
  45085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  45086. *
  45087. * @param cubeInfo The Cube map to extract the information from.
  45088. * @return The Spherical Polynomial data.
  45089. */
  45090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  45091. }
  45092. }
  45093. declare module BABYLON {
  45094. interface BaseTexture {
  45095. /**
  45096. * Get the polynomial representation of the texture data.
  45097. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45098. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45099. */
  45100. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45101. }
  45102. }
  45103. declare module BABYLON {
  45104. /** @hidden */
  45105. export var rgbdEncodePixelShader: {
  45106. name: string;
  45107. shader: string;
  45108. };
  45109. }
  45110. declare module BABYLON {
  45111. /** @hidden */
  45112. export var rgbdDecodePixelShader: {
  45113. name: string;
  45114. shader: string;
  45115. };
  45116. }
  45117. declare module BABYLON {
  45118. /**
  45119. * Raw texture data and descriptor sufficient for WebGL texture upload
  45120. */
  45121. export interface EnvironmentTextureInfo {
  45122. /**
  45123. * Version of the environment map
  45124. */
  45125. version: number;
  45126. /**
  45127. * Width of image
  45128. */
  45129. width: number;
  45130. /**
  45131. * Irradiance information stored in the file.
  45132. */
  45133. irradiance: any;
  45134. /**
  45135. * Specular information stored in the file.
  45136. */
  45137. specular: any;
  45138. }
  45139. /**
  45140. * Defines One Image in the file. It requires only the position in the file
  45141. * as well as the length.
  45142. */
  45143. interface BufferImageData {
  45144. /**
  45145. * Length of the image data.
  45146. */
  45147. length: number;
  45148. /**
  45149. * Position of the data from the null terminator delimiting the end of the JSON.
  45150. */
  45151. position: number;
  45152. }
  45153. /**
  45154. * Defines the specular data enclosed in the file.
  45155. * This corresponds to the version 1 of the data.
  45156. */
  45157. export interface EnvironmentTextureSpecularInfoV1 {
  45158. /**
  45159. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45160. */
  45161. specularDataPosition?: number;
  45162. /**
  45163. * This contains all the images data needed to reconstruct the cubemap.
  45164. */
  45165. mipmaps: Array<BufferImageData>;
  45166. /**
  45167. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45168. */
  45169. lodGenerationScale: number;
  45170. }
  45171. /**
  45172. * Sets of helpers addressing the serialization and deserialization of environment texture
  45173. * stored in a BabylonJS env file.
  45174. * Those files are usually stored as .env files.
  45175. */
  45176. export class EnvironmentTextureTools {
  45177. /**
  45178. * Magic number identifying the env file.
  45179. */
  45180. private static _MagicBytes;
  45181. /**
  45182. * Gets the environment info from an env file.
  45183. * @param data The array buffer containing the .env bytes.
  45184. * @returns the environment file info (the json header) if successfully parsed.
  45185. */
  45186. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45187. /**
  45188. * Creates an environment texture from a loaded cube texture.
  45189. * @param texture defines the cube texture to convert in env file
  45190. * @return a promise containing the environment data if succesfull.
  45191. */
  45192. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45193. /**
  45194. * Creates a JSON representation of the spherical data.
  45195. * @param texture defines the texture containing the polynomials
  45196. * @return the JSON representation of the spherical info
  45197. */
  45198. private static _CreateEnvTextureIrradiance;
  45199. /**
  45200. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45201. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45202. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45203. * @return the views described by info providing access to the underlying buffer
  45204. */
  45205. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45206. /**
  45207. * Uploads the texture info contained in the env file to the GPU.
  45208. * @param texture defines the internal texture to upload to
  45209. * @param arrayBuffer defines the buffer cotaining the data to load
  45210. * @param info defines the texture info retrieved through the GetEnvInfo method
  45211. * @returns a promise
  45212. */
  45213. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45214. private static _OnImageReadyAsync;
  45215. /**
  45216. * Uploads the levels of image data to the GPU.
  45217. * @param texture defines the internal texture to upload to
  45218. * @param imageData defines the array buffer views of image data [mipmap][face]
  45219. * @returns a promise
  45220. */
  45221. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45222. /**
  45223. * Uploads spherical polynomials information to the texture.
  45224. * @param texture defines the texture we are trying to upload the information to
  45225. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45226. */
  45227. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45228. /** @hidden */
  45229. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45230. }
  45231. }
  45232. declare module BABYLON {
  45233. /**
  45234. * Contains position and normal vectors for a vertex
  45235. */
  45236. export class PositionNormalVertex {
  45237. /** the position of the vertex (defaut: 0,0,0) */
  45238. position: Vector3;
  45239. /** the normal of the vertex (defaut: 0,1,0) */
  45240. normal: Vector3;
  45241. /**
  45242. * Creates a PositionNormalVertex
  45243. * @param position the position of the vertex (defaut: 0,0,0)
  45244. * @param normal the normal of the vertex (defaut: 0,1,0)
  45245. */
  45246. constructor(
  45247. /** the position of the vertex (defaut: 0,0,0) */
  45248. position?: Vector3,
  45249. /** the normal of the vertex (defaut: 0,1,0) */
  45250. normal?: Vector3);
  45251. /**
  45252. * Clones the PositionNormalVertex
  45253. * @returns the cloned PositionNormalVertex
  45254. */
  45255. clone(): PositionNormalVertex;
  45256. }
  45257. /**
  45258. * Contains position, normal and uv vectors for a vertex
  45259. */
  45260. export class PositionNormalTextureVertex {
  45261. /** the position of the vertex (defaut: 0,0,0) */
  45262. position: Vector3;
  45263. /** the normal of the vertex (defaut: 0,1,0) */
  45264. normal: Vector3;
  45265. /** the uv of the vertex (default: 0,0) */
  45266. uv: Vector2;
  45267. /**
  45268. * Creates a PositionNormalTextureVertex
  45269. * @param position the position of the vertex (defaut: 0,0,0)
  45270. * @param normal the normal of the vertex (defaut: 0,1,0)
  45271. * @param uv the uv of the vertex (default: 0,0)
  45272. */
  45273. constructor(
  45274. /** the position of the vertex (defaut: 0,0,0) */
  45275. position?: Vector3,
  45276. /** the normal of the vertex (defaut: 0,1,0) */
  45277. normal?: Vector3,
  45278. /** the uv of the vertex (default: 0,0) */
  45279. uv?: Vector2);
  45280. /**
  45281. * Clones the PositionNormalTextureVertex
  45282. * @returns the cloned PositionNormalTextureVertex
  45283. */
  45284. clone(): PositionNormalTextureVertex;
  45285. }
  45286. }
  45287. declare module BABYLON {
  45288. /** @hidden */
  45289. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45290. private _genericAttributeLocation;
  45291. private _varyingLocationCount;
  45292. private _varyingLocationMap;
  45293. private _replacements;
  45294. private _textureCount;
  45295. private _uniforms;
  45296. lineProcessor(line: string): string;
  45297. attributeProcessor(attribute: string): string;
  45298. varyingProcessor(varying: string, isFragment: boolean): string;
  45299. uniformProcessor(uniform: string): string;
  45300. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45301. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45302. }
  45303. }
  45304. declare module BABYLON {
  45305. /**
  45306. * Container for accessors for natively-stored mesh data buffers.
  45307. */
  45308. class NativeDataBuffer extends DataBuffer {
  45309. /**
  45310. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45311. */
  45312. nativeIndexBuffer?: any;
  45313. /**
  45314. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45315. */
  45316. nativeVertexBuffer?: any;
  45317. }
  45318. /** @hidden */
  45319. class NativeTexture extends InternalTexture {
  45320. getInternalTexture(): InternalTexture;
  45321. getViewCount(): number;
  45322. }
  45323. /** @hidden */
  45324. export class NativeEngine extends Engine {
  45325. private readonly _native;
  45326. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  45327. private readonly INVALID_HANDLE;
  45328. getHardwareScalingLevel(): number;
  45329. constructor();
  45330. /**
  45331. * Can be used to override the current requestAnimationFrame requester.
  45332. * @hidden
  45333. */
  45334. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45335. /**
  45336. * Override default engine behavior.
  45337. * @param color
  45338. * @param backBuffer
  45339. * @param depth
  45340. * @param stencil
  45341. */
  45342. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45343. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45344. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45345. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45346. recordVertexArrayObject(vertexBuffers: {
  45347. [key: string]: VertexBuffer;
  45348. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45349. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45350. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45351. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45352. /**
  45353. * Draw a list of indexed primitives
  45354. * @param fillMode defines the primitive to use
  45355. * @param indexStart defines the starting index
  45356. * @param indexCount defines the number of index to draw
  45357. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45358. */
  45359. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45360. /**
  45361. * Draw a list of unindexed primitives
  45362. * @param fillMode defines the primitive to use
  45363. * @param verticesStart defines the index of first vertex to draw
  45364. * @param verticesCount defines the count of vertices to draw
  45365. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45366. */
  45367. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45368. createPipelineContext(): IPipelineContext;
  45369. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45370. /** @hidden */
  45371. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45372. /** @hidden */
  45373. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45374. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45375. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45376. protected _setProgram(program: WebGLProgram): void;
  45377. _releaseEffect(effect: Effect): void;
  45378. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45379. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45380. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45381. bindSamplers(effect: Effect): void;
  45382. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45383. getRenderWidth(useScreen?: boolean): number;
  45384. getRenderHeight(useScreen?: boolean): number;
  45385. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45386. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45387. /**
  45388. * Set the z offset to apply to current rendering
  45389. * @param value defines the offset to apply
  45390. */
  45391. setZOffset(value: number): void;
  45392. /**
  45393. * Gets the current value of the zOffset
  45394. * @returns the current zOffset state
  45395. */
  45396. getZOffset(): number;
  45397. /**
  45398. * Enable or disable depth buffering
  45399. * @param enable defines the state to set
  45400. */
  45401. setDepthBuffer(enable: boolean): void;
  45402. /**
  45403. * Gets a boolean indicating if depth writing is enabled
  45404. * @returns the current depth writing state
  45405. */
  45406. getDepthWrite(): boolean;
  45407. /**
  45408. * Enable or disable depth writing
  45409. * @param enable defines the state to set
  45410. */
  45411. setDepthWrite(enable: boolean): void;
  45412. /**
  45413. * Enable or disable color writing
  45414. * @param enable defines the state to set
  45415. */
  45416. setColorWrite(enable: boolean): void;
  45417. /**
  45418. * Gets a boolean indicating if color writing is enabled
  45419. * @returns the current color writing state
  45420. */
  45421. getColorWrite(): boolean;
  45422. /**
  45423. * Sets alpha constants used by some alpha blending modes
  45424. * @param r defines the red component
  45425. * @param g defines the green component
  45426. * @param b defines the blue component
  45427. * @param a defines the alpha component
  45428. */
  45429. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45430. /**
  45431. * Sets the current alpha mode
  45432. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45433. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45435. */
  45436. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45437. /**
  45438. * Gets the current alpha mode
  45439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45440. * @returns the current alpha mode
  45441. */
  45442. getAlphaMode(): number;
  45443. setInt(uniform: WebGLUniformLocation, int: number): void;
  45444. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45445. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45446. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45447. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45448. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45449. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45450. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45451. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45452. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45453. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45454. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45455. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45456. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45457. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45458. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45459. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45460. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45461. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45462. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45463. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45464. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45465. wipeCaches(bruteForce?: boolean): void;
  45466. _createTexture(): WebGLTexture;
  45467. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45468. /**
  45469. * Usually called from BABYLON.Texture.ts.
  45470. * Passed information to create a WebGLTexture
  45471. * @param urlArg defines a value which contains one of the following:
  45472. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45473. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45474. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45475. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45476. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45477. * @param scene needed for loading to the correct scene
  45478. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45479. * @param onLoad optional callback to be called upon successful completion
  45480. * @param onError optional callback to be called upon failure
  45481. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45482. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45483. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45484. * @param forcedExtension defines the extension to use to pick the right loader
  45485. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45486. */
  45487. 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 | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45488. /**
  45489. * Creates a cube texture
  45490. * @param rootUrl defines the url where the files to load is located
  45491. * @param scene defines the current scene
  45492. * @param files defines the list of files to load (1 per face)
  45493. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45494. * @param onLoad defines an optional callback raised when the texture is loaded
  45495. * @param onError defines an optional callback raised if there is an issue to load the texture
  45496. * @param format defines the format of the data
  45497. * @param forcedExtension defines the extension to use to pick the right loader
  45498. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45499. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45500. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45501. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45502. * @returns the cube texture as an InternalTexture
  45503. */
  45504. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45505. private _getSamplingFilter;
  45506. private static _GetNativeTextureFormat;
  45507. createRenderTargetTexture(size: number | {
  45508. width: number;
  45509. height: number;
  45510. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45511. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45512. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45513. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45514. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45515. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45516. /**
  45517. * Updates a dynamic vertex buffer.
  45518. * @param vertexBuffer the vertex buffer to update
  45519. * @param data the data used to update the vertex buffer
  45520. * @param byteOffset the byte offset of the data (optional)
  45521. * @param byteLength the byte length of the data (optional)
  45522. */
  45523. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45524. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45525. private _updateAnisotropicLevel;
  45526. private _getAddressMode;
  45527. /** @hidden */
  45528. _bindTexture(channel: number, texture: InternalTexture): void;
  45529. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45530. releaseEffects(): void;
  45531. /** @hidden */
  45532. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45533. /** @hidden */
  45534. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45535. /** @hidden */
  45536. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45537. /** @hidden */
  45538. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45539. }
  45540. }
  45541. declare module BABYLON {
  45542. /**
  45543. * Gather the list of clipboard event types as constants.
  45544. */
  45545. export class ClipboardEventTypes {
  45546. /**
  45547. * The clipboard event is fired when a copy command is active (pressed).
  45548. */
  45549. static readonly COPY: number;
  45550. /**
  45551. * The clipboard event is fired when a cut command is active (pressed).
  45552. */
  45553. static readonly CUT: number;
  45554. /**
  45555. * The clipboard event is fired when a paste command is active (pressed).
  45556. */
  45557. static readonly PASTE: number;
  45558. }
  45559. /**
  45560. * This class is used to store clipboard related info for the onClipboardObservable event.
  45561. */
  45562. export class ClipboardInfo {
  45563. /**
  45564. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45565. */
  45566. type: number;
  45567. /**
  45568. * Defines the related dom event
  45569. */
  45570. event: ClipboardEvent;
  45571. /**
  45572. *Creates an instance of ClipboardInfo.
  45573. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45574. * @param event Defines the related dom event
  45575. */
  45576. constructor(
  45577. /**
  45578. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45579. */
  45580. type: number,
  45581. /**
  45582. * Defines the related dom event
  45583. */
  45584. event: ClipboardEvent);
  45585. /**
  45586. * Get the clipboard event's type from the keycode.
  45587. * @param keyCode Defines the keyCode for the current keyboard event.
  45588. * @return {number}
  45589. */
  45590. static GetTypeFromCharacter(keyCode: number): number;
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. /**
  45595. * Google Daydream controller
  45596. */
  45597. export class DaydreamController extends WebVRController {
  45598. /**
  45599. * Base Url for the controller model.
  45600. */
  45601. static MODEL_BASE_URL: string;
  45602. /**
  45603. * File name for the controller model.
  45604. */
  45605. static MODEL_FILENAME: string;
  45606. /**
  45607. * Gamepad Id prefix used to identify Daydream Controller.
  45608. */
  45609. static readonly GAMEPAD_ID_PREFIX: string;
  45610. /**
  45611. * Creates a new DaydreamController from a gamepad
  45612. * @param vrGamepad the gamepad that the controller should be created from
  45613. */
  45614. constructor(vrGamepad: any);
  45615. /**
  45616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45617. * @param scene scene in which to add meshes
  45618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45619. */
  45620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45621. /**
  45622. * Called once for each button that changed state since the last frame
  45623. * @param buttonIdx Which button index changed
  45624. * @param state New state of the button
  45625. * @param changes Which properties on the state changed since last frame
  45626. */
  45627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. /**
  45632. * Gear VR Controller
  45633. */
  45634. export class GearVRController extends WebVRController {
  45635. /**
  45636. * Base Url for the controller model.
  45637. */
  45638. static MODEL_BASE_URL: string;
  45639. /**
  45640. * File name for the controller model.
  45641. */
  45642. static MODEL_FILENAME: string;
  45643. /**
  45644. * Gamepad Id prefix used to identify this controller.
  45645. */
  45646. static readonly GAMEPAD_ID_PREFIX: string;
  45647. private readonly _buttonIndexToObservableNameMap;
  45648. /**
  45649. * Creates a new GearVRController from a gamepad
  45650. * @param vrGamepad the gamepad that the controller should be created from
  45651. */
  45652. constructor(vrGamepad: any);
  45653. /**
  45654. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45655. * @param scene scene in which to add meshes
  45656. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45657. */
  45658. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45659. /**
  45660. * Called once for each button that changed state since the last frame
  45661. * @param buttonIdx Which button index changed
  45662. * @param state New state of the button
  45663. * @param changes Which properties on the state changed since last frame
  45664. */
  45665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45666. }
  45667. }
  45668. declare module BABYLON {
  45669. /**
  45670. * Class containing static functions to help procedurally build meshes
  45671. */
  45672. export class PolyhedronBuilder {
  45673. /**
  45674. * Creates a polyhedron mesh
  45675. * * 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
  45676. * * The parameter `size` (positive float, default 1) sets the polygon size
  45677. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45678. * * 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`
  45679. * * 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
  45680. * * 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)`)
  45681. * * 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
  45682. * * 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
  45683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45684. * * 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
  45685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45686. * @param name defines the name of the mesh
  45687. * @param options defines the options used to create the mesh
  45688. * @param scene defines the hosting scene
  45689. * @returns the polyhedron mesh
  45690. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45691. */
  45692. static CreatePolyhedron(name: string, options: {
  45693. type?: number;
  45694. size?: number;
  45695. sizeX?: number;
  45696. sizeY?: number;
  45697. sizeZ?: number;
  45698. custom?: any;
  45699. faceUV?: Vector4[];
  45700. faceColors?: Color4[];
  45701. flat?: boolean;
  45702. updatable?: boolean;
  45703. sideOrientation?: number;
  45704. frontUVs?: Vector4;
  45705. backUVs?: Vector4;
  45706. }, scene?: Nullable<Scene>): Mesh;
  45707. }
  45708. }
  45709. declare module BABYLON {
  45710. /**
  45711. * Gizmo that enables scaling a mesh along 3 axis
  45712. */
  45713. export class ScaleGizmo extends Gizmo {
  45714. /**
  45715. * Internal gizmo used for interactions on the x axis
  45716. */
  45717. xGizmo: AxisScaleGizmo;
  45718. /**
  45719. * Internal gizmo used for interactions on the y axis
  45720. */
  45721. yGizmo: AxisScaleGizmo;
  45722. /**
  45723. * Internal gizmo used for interactions on the z axis
  45724. */
  45725. zGizmo: AxisScaleGizmo;
  45726. /**
  45727. * Internal gizmo used to scale all axis equally
  45728. */
  45729. uniformScaleGizmo: AxisScaleGizmo;
  45730. private _meshAttached;
  45731. private _updateGizmoRotationToMatchAttachedMesh;
  45732. private _snapDistance;
  45733. private _scaleRatio;
  45734. private _uniformScalingMesh;
  45735. private _octahedron;
  45736. /** Fires an event when any of it's sub gizmos are dragged */
  45737. onDragStartObservable: Observable<unknown>;
  45738. /** Fires an event when any of it's sub gizmos are released from dragging */
  45739. onDragEndObservable: Observable<unknown>;
  45740. attachedMesh: Nullable<AbstractMesh>;
  45741. /**
  45742. * Creates a ScaleGizmo
  45743. * @param gizmoLayer The utility layer the gizmo will be added to
  45744. */
  45745. constructor(gizmoLayer?: UtilityLayerRenderer);
  45746. updateGizmoRotationToMatchAttachedMesh: boolean;
  45747. /**
  45748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45749. */
  45750. snapDistance: number;
  45751. /**
  45752. * Ratio for the scale of the gizmo (Default: 1)
  45753. */
  45754. scaleRatio: number;
  45755. /**
  45756. * Disposes of the gizmo
  45757. */
  45758. dispose(): void;
  45759. }
  45760. }
  45761. declare module BABYLON {
  45762. /**
  45763. * Single axis scale gizmo
  45764. */
  45765. export class AxisScaleGizmo extends Gizmo {
  45766. /**
  45767. * Drag behavior responsible for the gizmos dragging interactions
  45768. */
  45769. dragBehavior: PointerDragBehavior;
  45770. private _pointerObserver;
  45771. /**
  45772. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45773. */
  45774. snapDistance: number;
  45775. /**
  45776. * Event that fires each time the gizmo snaps to a new location.
  45777. * * snapDistance is the the change in distance
  45778. */
  45779. onSnapObservable: Observable<{
  45780. snapDistance: number;
  45781. }>;
  45782. /**
  45783. * If the scaling operation should be done on all axis (default: false)
  45784. */
  45785. uniformScaling: boolean;
  45786. private _isEnabled;
  45787. private _parent;
  45788. private _arrow;
  45789. private _coloredMaterial;
  45790. private _hoverMaterial;
  45791. /**
  45792. * Creates an AxisScaleGizmo
  45793. * @param gizmoLayer The utility layer the gizmo will be added to
  45794. * @param dragAxis The axis which the gizmo will be able to scale on
  45795. * @param color The color of the gizmo
  45796. */
  45797. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45798. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45799. /**
  45800. * If the gizmo is enabled
  45801. */
  45802. isEnabled: boolean;
  45803. /**
  45804. * Disposes of the gizmo
  45805. */
  45806. dispose(): void;
  45807. /**
  45808. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45809. * @param mesh The mesh to replace the default mesh of the gizmo
  45810. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45811. */
  45812. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45813. }
  45814. }
  45815. declare module BABYLON {
  45816. /**
  45817. * Bounding box gizmo
  45818. */
  45819. export class BoundingBoxGizmo extends Gizmo {
  45820. private _lineBoundingBox;
  45821. private _rotateSpheresParent;
  45822. private _scaleBoxesParent;
  45823. private _boundingDimensions;
  45824. private _renderObserver;
  45825. private _pointerObserver;
  45826. private _scaleDragSpeed;
  45827. private _tmpQuaternion;
  45828. private _tmpVector;
  45829. private _tmpRotationMatrix;
  45830. /**
  45831. * 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)
  45832. */
  45833. ignoreChildren: boolean;
  45834. /**
  45835. * 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)
  45836. */
  45837. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45838. /**
  45839. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45840. */
  45841. rotationSphereSize: number;
  45842. /**
  45843. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45844. */
  45845. scaleBoxSize: number;
  45846. /**
  45847. * 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)
  45848. */
  45849. fixedDragMeshScreenSize: boolean;
  45850. /**
  45851. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45852. */
  45853. fixedDragMeshScreenSizeDistanceFactor: number;
  45854. /**
  45855. * Fired when a rotation sphere or scale box is dragged
  45856. */
  45857. onDragStartObservable: Observable<{}>;
  45858. /**
  45859. * Fired when a scale box is dragged
  45860. */
  45861. onScaleBoxDragObservable: Observable<{}>;
  45862. /**
  45863. * Fired when a scale box drag is ended
  45864. */
  45865. onScaleBoxDragEndObservable: Observable<{}>;
  45866. /**
  45867. * Fired when a rotation sphere is dragged
  45868. */
  45869. onRotationSphereDragObservable: Observable<{}>;
  45870. /**
  45871. * Fired when a rotation sphere drag is ended
  45872. */
  45873. onRotationSphereDragEndObservable: Observable<{}>;
  45874. /**
  45875. * 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)
  45876. */
  45877. scalePivot: Nullable<Vector3>;
  45878. /**
  45879. * Mesh used as a pivot to rotate the attached mesh
  45880. */
  45881. private _anchorMesh;
  45882. private _existingMeshScale;
  45883. private _dragMesh;
  45884. private pointerDragBehavior;
  45885. private coloredMaterial;
  45886. private hoverColoredMaterial;
  45887. /**
  45888. * Sets the color of the bounding box gizmo
  45889. * @param color the color to set
  45890. */
  45891. setColor(color: Color3): void;
  45892. /**
  45893. * Creates an BoundingBoxGizmo
  45894. * @param gizmoLayer The utility layer the gizmo will be added to
  45895. * @param color The color of the gizmo
  45896. */
  45897. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45898. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45899. private _selectNode;
  45900. /**
  45901. * Updates the bounding box information for the Gizmo
  45902. */
  45903. updateBoundingBox(): void;
  45904. private _updateRotationSpheres;
  45905. private _updateScaleBoxes;
  45906. /**
  45907. * Enables rotation on the specified axis and disables rotation on the others
  45908. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45909. */
  45910. setEnabledRotationAxis(axis: string): void;
  45911. /**
  45912. * Enables/disables scaling
  45913. * @param enable if scaling should be enabled
  45914. */
  45915. setEnabledScaling(enable: boolean): void;
  45916. private _updateDummy;
  45917. /**
  45918. * Enables a pointer drag behavior on the bounding box of the gizmo
  45919. */
  45920. enableDragBehavior(): void;
  45921. /**
  45922. * Disposes of the gizmo
  45923. */
  45924. dispose(): void;
  45925. /**
  45926. * 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)
  45927. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45928. * @returns the bounding box mesh with the passed in mesh as a child
  45929. */
  45930. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45931. /**
  45932. * CustomMeshes are not supported by this gizmo
  45933. * @param mesh The mesh to replace the default mesh of the gizmo
  45934. */
  45935. setCustomMesh(mesh: Mesh): void;
  45936. }
  45937. }
  45938. declare module BABYLON {
  45939. /**
  45940. * Single plane rotation gizmo
  45941. */
  45942. export class PlaneRotationGizmo extends Gizmo {
  45943. /**
  45944. * Drag behavior responsible for the gizmos dragging interactions
  45945. */
  45946. dragBehavior: PointerDragBehavior;
  45947. private _pointerObserver;
  45948. /**
  45949. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45950. */
  45951. snapDistance: number;
  45952. /**
  45953. * Event that fires each time the gizmo snaps to a new location.
  45954. * * snapDistance is the the change in distance
  45955. */
  45956. onSnapObservable: Observable<{
  45957. snapDistance: number;
  45958. }>;
  45959. private _isEnabled;
  45960. private _parent;
  45961. /**
  45962. * Creates a PlaneRotationGizmo
  45963. * @param gizmoLayer The utility layer the gizmo will be added to
  45964. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45965. * @param color The color of the gizmo
  45966. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45967. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45968. */
  45969. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45970. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45971. /**
  45972. * If the gizmo is enabled
  45973. */
  45974. isEnabled: boolean;
  45975. /**
  45976. * Disposes of the gizmo
  45977. */
  45978. dispose(): void;
  45979. }
  45980. }
  45981. declare module BABYLON {
  45982. /**
  45983. * Gizmo that enables rotating a mesh along 3 axis
  45984. */
  45985. export class RotationGizmo extends Gizmo {
  45986. /**
  45987. * Internal gizmo used for interactions on the x axis
  45988. */
  45989. xGizmo: PlaneRotationGizmo;
  45990. /**
  45991. * Internal gizmo used for interactions on the y axis
  45992. */
  45993. yGizmo: PlaneRotationGizmo;
  45994. /**
  45995. * Internal gizmo used for interactions on the z axis
  45996. */
  45997. zGizmo: PlaneRotationGizmo;
  45998. /** Fires an event when any of it's sub gizmos are dragged */
  45999. onDragStartObservable: Observable<unknown>;
  46000. /** Fires an event when any of it's sub gizmos are released from dragging */
  46001. onDragEndObservable: Observable<unknown>;
  46002. private _meshAttached;
  46003. attachedMesh: Nullable<AbstractMesh>;
  46004. /**
  46005. * Creates a RotationGizmo
  46006. * @param gizmoLayer The utility layer the gizmo will be added to
  46007. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46008. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46009. */
  46010. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46011. updateGizmoRotationToMatchAttachedMesh: boolean;
  46012. /**
  46013. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46014. */
  46015. snapDistance: number;
  46016. /**
  46017. * Ratio for the scale of the gizmo (Default: 1)
  46018. */
  46019. scaleRatio: number;
  46020. /**
  46021. * Disposes of the gizmo
  46022. */
  46023. dispose(): void;
  46024. /**
  46025. * CustomMeshes are not supported by this gizmo
  46026. * @param mesh The mesh to replace the default mesh of the gizmo
  46027. */
  46028. setCustomMesh(mesh: Mesh): void;
  46029. }
  46030. }
  46031. declare module BABYLON {
  46032. /**
  46033. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46034. */
  46035. export class GizmoManager implements IDisposable {
  46036. private scene;
  46037. /**
  46038. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46039. */
  46040. gizmos: {
  46041. positionGizmo: Nullable<PositionGizmo>;
  46042. rotationGizmo: Nullable<RotationGizmo>;
  46043. scaleGizmo: Nullable<ScaleGizmo>;
  46044. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46045. };
  46046. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46047. clearGizmoOnEmptyPointerEvent: boolean;
  46048. /** Fires an event when the manager is attached to a mesh */
  46049. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46050. private _gizmosEnabled;
  46051. private _pointerObserver;
  46052. private _attachedMesh;
  46053. private _boundingBoxColor;
  46054. private _defaultUtilityLayer;
  46055. private _defaultKeepDepthUtilityLayer;
  46056. /**
  46057. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46058. */
  46059. boundingBoxDragBehavior: SixDofDragBehavior;
  46060. /**
  46061. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46062. */
  46063. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46064. /**
  46065. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46066. */
  46067. usePointerToAttachGizmos: boolean;
  46068. /**
  46069. * Utility layer that the bounding box gizmo belongs to
  46070. */
  46071. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46072. /**
  46073. * Utility layer that all gizmos besides bounding box belong to
  46074. */
  46075. readonly utilityLayer: UtilityLayerRenderer;
  46076. /**
  46077. * Instatiates a gizmo manager
  46078. * @param scene the scene to overlay the gizmos on top of
  46079. */
  46080. constructor(scene: Scene);
  46081. /**
  46082. * Attaches a set of gizmos to the specified mesh
  46083. * @param mesh The mesh the gizmo's should be attached to
  46084. */
  46085. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46086. /**
  46087. * If the position gizmo is enabled
  46088. */
  46089. positionGizmoEnabled: boolean;
  46090. /**
  46091. * If the rotation gizmo is enabled
  46092. */
  46093. rotationGizmoEnabled: boolean;
  46094. /**
  46095. * If the scale gizmo is enabled
  46096. */
  46097. scaleGizmoEnabled: boolean;
  46098. /**
  46099. * If the boundingBox gizmo is enabled
  46100. */
  46101. boundingBoxGizmoEnabled: boolean;
  46102. /**
  46103. * Disposes of the gizmo manager
  46104. */
  46105. dispose(): void;
  46106. }
  46107. }
  46108. declare module BABYLON {
  46109. /**
  46110. * A directional light is defined by a direction (what a surprise!).
  46111. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46112. * 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.
  46113. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46114. */
  46115. export class DirectionalLight extends ShadowLight {
  46116. private _shadowFrustumSize;
  46117. /**
  46118. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46119. */
  46120. /**
  46121. * Specifies a fix frustum size for the shadow generation.
  46122. */
  46123. shadowFrustumSize: number;
  46124. private _shadowOrthoScale;
  46125. /**
  46126. * Gets the shadow projection scale against the optimal computed one.
  46127. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46128. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46129. */
  46130. /**
  46131. * Sets the shadow projection scale against the optimal computed one.
  46132. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46133. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46134. */
  46135. shadowOrthoScale: number;
  46136. /**
  46137. * Automatically compute the projection matrix to best fit (including all the casters)
  46138. * on each frame.
  46139. */
  46140. autoUpdateExtends: boolean;
  46141. private _orthoLeft;
  46142. private _orthoRight;
  46143. private _orthoTop;
  46144. private _orthoBottom;
  46145. /**
  46146. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46147. * The directional light is emitted from everywhere in the given direction.
  46148. * It can cast shadows.
  46149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46150. * @param name The friendly name of the light
  46151. * @param direction The direction of the light
  46152. * @param scene The scene the light belongs to
  46153. */
  46154. constructor(name: string, direction: Vector3, scene: Scene);
  46155. /**
  46156. * Returns the string "DirectionalLight".
  46157. * @return The class name
  46158. */
  46159. getClassName(): string;
  46160. /**
  46161. * Returns the integer 1.
  46162. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46163. */
  46164. getTypeID(): number;
  46165. /**
  46166. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46167. * Returns the DirectionalLight Shadow projection matrix.
  46168. */
  46169. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46170. /**
  46171. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46172. * Returns the DirectionalLight Shadow projection matrix.
  46173. */
  46174. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46175. /**
  46176. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46177. * Returns the DirectionalLight Shadow projection matrix.
  46178. */
  46179. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46180. protected _buildUniformLayout(): void;
  46181. /**
  46182. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46183. * @param effect The effect to update
  46184. * @param lightIndex The index of the light in the effect to update
  46185. * @returns The directional light
  46186. */
  46187. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46188. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46189. /**
  46190. * Gets the minZ used for shadow according to both the scene and the light.
  46191. *
  46192. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46193. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46194. * @param activeCamera The camera we are returning the min for
  46195. * @returns the depth min z
  46196. */
  46197. getDepthMinZ(activeCamera: Camera): number;
  46198. /**
  46199. * Gets the maxZ used for shadow according to both the scene and the light.
  46200. *
  46201. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46202. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46203. * @param activeCamera The camera we are returning the max for
  46204. * @returns the depth max z
  46205. */
  46206. getDepthMaxZ(activeCamera: Camera): number;
  46207. /**
  46208. * Prepares the list of defines specific to the light type.
  46209. * @param defines the list of defines
  46210. * @param lightIndex defines the index of the light for the effect
  46211. */
  46212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46213. }
  46214. }
  46215. declare module BABYLON {
  46216. /**
  46217. * Class containing static functions to help procedurally build meshes
  46218. */
  46219. export class HemisphereBuilder {
  46220. /**
  46221. * Creates a hemisphere mesh
  46222. * @param name defines the name of the mesh
  46223. * @param options defines the options used to create the mesh
  46224. * @param scene defines the hosting scene
  46225. * @returns the hemisphere mesh
  46226. */
  46227. static CreateHemisphere(name: string, options: {
  46228. segments?: number;
  46229. diameter?: number;
  46230. sideOrientation?: number;
  46231. }, scene: any): Mesh;
  46232. }
  46233. }
  46234. declare module BABYLON {
  46235. /**
  46236. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46237. * These values define a cone of light starting from the position, emitting toward the direction.
  46238. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46239. * and the exponent defines the speed of the decay of the light with distance (reach).
  46240. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46241. */
  46242. export class SpotLight extends ShadowLight {
  46243. private _angle;
  46244. private _innerAngle;
  46245. private _cosHalfAngle;
  46246. private _lightAngleScale;
  46247. private _lightAngleOffset;
  46248. /**
  46249. * Gets the cone angle of the spot light in Radians.
  46250. */
  46251. /**
  46252. * Sets the cone angle of the spot light in Radians.
  46253. */
  46254. angle: number;
  46255. /**
  46256. * Only used in gltf falloff mode, this defines the angle where
  46257. * the directional falloff will start before cutting at angle which could be seen
  46258. * as outer angle.
  46259. */
  46260. /**
  46261. * Only used in gltf falloff mode, this defines the angle where
  46262. * the directional falloff will start before cutting at angle which could be seen
  46263. * as outer angle.
  46264. */
  46265. innerAngle: number;
  46266. private _shadowAngleScale;
  46267. /**
  46268. * Allows scaling the angle of the light for shadow generation only.
  46269. */
  46270. /**
  46271. * Allows scaling the angle of the light for shadow generation only.
  46272. */
  46273. shadowAngleScale: number;
  46274. /**
  46275. * The light decay speed with the distance from the emission spot.
  46276. */
  46277. exponent: number;
  46278. private _projectionTextureMatrix;
  46279. /**
  46280. * Allows reading the projecton texture
  46281. */
  46282. readonly projectionTextureMatrix: Matrix;
  46283. protected _projectionTextureLightNear: number;
  46284. /**
  46285. * Gets the near clip of the Spotlight for texture projection.
  46286. */
  46287. /**
  46288. * Sets the near clip of the Spotlight for texture projection.
  46289. */
  46290. projectionTextureLightNear: number;
  46291. protected _projectionTextureLightFar: number;
  46292. /**
  46293. * Gets the far clip of the Spotlight for texture projection.
  46294. */
  46295. /**
  46296. * Sets the far clip of the Spotlight for texture projection.
  46297. */
  46298. projectionTextureLightFar: number;
  46299. protected _projectionTextureUpDirection: Vector3;
  46300. /**
  46301. * Gets the Up vector of the Spotlight for texture projection.
  46302. */
  46303. /**
  46304. * Sets the Up vector of the Spotlight for texture projection.
  46305. */
  46306. projectionTextureUpDirection: Vector3;
  46307. private _projectionTexture;
  46308. /**
  46309. * Gets the projection texture of the light.
  46310. */
  46311. /**
  46312. * Sets the projection texture of the light.
  46313. */
  46314. projectionTexture: Nullable<BaseTexture>;
  46315. private _projectionTextureViewLightDirty;
  46316. private _projectionTextureProjectionLightDirty;
  46317. private _projectionTextureDirty;
  46318. private _projectionTextureViewTargetVector;
  46319. private _projectionTextureViewLightMatrix;
  46320. private _projectionTextureProjectionLightMatrix;
  46321. private _projectionTextureScalingMatrix;
  46322. /**
  46323. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46324. * It can cast shadows.
  46325. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46326. * @param name The light friendly name
  46327. * @param position The position of the spot light in the scene
  46328. * @param direction The direction of the light in the scene
  46329. * @param angle The cone angle of the light in Radians
  46330. * @param exponent The light decay speed with the distance from the emission spot
  46331. * @param scene The scene the lights belongs to
  46332. */
  46333. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46334. /**
  46335. * Returns the string "SpotLight".
  46336. * @returns the class name
  46337. */
  46338. getClassName(): string;
  46339. /**
  46340. * Returns the integer 2.
  46341. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46342. */
  46343. getTypeID(): number;
  46344. /**
  46345. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46346. */
  46347. protected _setDirection(value: Vector3): void;
  46348. /**
  46349. * Overrides the position setter to recompute the projection texture view light Matrix.
  46350. */
  46351. protected _setPosition(value: Vector3): void;
  46352. /**
  46353. * 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.
  46354. * Returns the SpotLight.
  46355. */
  46356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46357. protected _computeProjectionTextureViewLightMatrix(): void;
  46358. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46359. /**
  46360. * Main function for light texture projection matrix computing.
  46361. */
  46362. protected _computeProjectionTextureMatrix(): void;
  46363. protected _buildUniformLayout(): void;
  46364. private _computeAngleValues;
  46365. /**
  46366. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46367. * @param effect The effect to update
  46368. * @param lightIndex The index of the light in the effect to update
  46369. * @returns The spot light
  46370. */
  46371. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46373. /**
  46374. * Disposes the light and the associated resources.
  46375. */
  46376. dispose(): void;
  46377. /**
  46378. * Prepares the list of defines specific to the light type.
  46379. * @param defines the list of defines
  46380. * @param lightIndex defines the index of the light for the effect
  46381. */
  46382. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46383. }
  46384. }
  46385. declare module BABYLON {
  46386. /**
  46387. * Gizmo that enables viewing a light
  46388. */
  46389. export class LightGizmo extends Gizmo {
  46390. private _lightMesh;
  46391. private _material;
  46392. private cachedPosition;
  46393. private cachedForward;
  46394. /**
  46395. * Creates a LightGizmo
  46396. * @param gizmoLayer The utility layer the gizmo will be added to
  46397. */
  46398. constructor(gizmoLayer?: UtilityLayerRenderer);
  46399. private _light;
  46400. /**
  46401. * The light that the gizmo is attached to
  46402. */
  46403. light: Nullable<Light>;
  46404. /**
  46405. * Gets the material used to render the light gizmo
  46406. */
  46407. readonly material: StandardMaterial;
  46408. /**
  46409. * @hidden
  46410. * Updates the gizmo to match the attached mesh's position/rotation
  46411. */
  46412. protected _update(): void;
  46413. private static _Scale;
  46414. /**
  46415. * Creates the lines for a light mesh
  46416. */
  46417. private static _createLightLines;
  46418. /**
  46419. * Disposes of the light gizmo
  46420. */
  46421. dispose(): void;
  46422. private static _CreateHemisphericLightMesh;
  46423. private static _CreatePointLightMesh;
  46424. private static _CreateSpotLightMesh;
  46425. private static _CreateDirectionalLightMesh;
  46426. }
  46427. }
  46428. declare module BABYLON {
  46429. /** @hidden */
  46430. export var backgroundFragmentDeclaration: {
  46431. name: string;
  46432. shader: string;
  46433. };
  46434. }
  46435. declare module BABYLON {
  46436. /** @hidden */
  46437. export var backgroundUboDeclaration: {
  46438. name: string;
  46439. shader: string;
  46440. };
  46441. }
  46442. declare module BABYLON {
  46443. /** @hidden */
  46444. export var backgroundPixelShader: {
  46445. name: string;
  46446. shader: string;
  46447. };
  46448. }
  46449. declare module BABYLON {
  46450. /** @hidden */
  46451. export var backgroundVertexDeclaration: {
  46452. name: string;
  46453. shader: string;
  46454. };
  46455. }
  46456. declare module BABYLON {
  46457. /** @hidden */
  46458. export var backgroundVertexShader: {
  46459. name: string;
  46460. shader: string;
  46461. };
  46462. }
  46463. declare module BABYLON {
  46464. /**
  46465. * Background material used to create an efficient environement around your scene.
  46466. */
  46467. export class BackgroundMaterial extends PushMaterial {
  46468. /**
  46469. * Standard reflectance value at parallel view angle.
  46470. */
  46471. static StandardReflectance0: number;
  46472. /**
  46473. * Standard reflectance value at grazing angle.
  46474. */
  46475. static StandardReflectance90: number;
  46476. protected _primaryColor: Color3;
  46477. /**
  46478. * Key light Color (multiply against the environement texture)
  46479. */
  46480. primaryColor: Color3;
  46481. protected __perceptualColor: Nullable<Color3>;
  46482. /**
  46483. * Experimental Internal Use Only.
  46484. *
  46485. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46486. * This acts as a helper to set the primary color to a more "human friendly" value.
  46487. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46488. * output color as close as possible from the chosen value.
  46489. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46490. * part of lighting setup.)
  46491. */
  46492. _perceptualColor: Nullable<Color3>;
  46493. protected _primaryColorShadowLevel: float;
  46494. /**
  46495. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46496. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46497. */
  46498. primaryColorShadowLevel: float;
  46499. protected _primaryColorHighlightLevel: float;
  46500. /**
  46501. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46502. * The primary color is used at the level chosen to define what the white area would look.
  46503. */
  46504. primaryColorHighlightLevel: float;
  46505. protected _reflectionTexture: Nullable<BaseTexture>;
  46506. /**
  46507. * Reflection Texture used in the material.
  46508. * Should be author in a specific way for the best result (refer to the documentation).
  46509. */
  46510. reflectionTexture: Nullable<BaseTexture>;
  46511. protected _reflectionBlur: float;
  46512. /**
  46513. * Reflection Texture level of blur.
  46514. *
  46515. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46516. * texture twice.
  46517. */
  46518. reflectionBlur: float;
  46519. protected _diffuseTexture: Nullable<BaseTexture>;
  46520. /**
  46521. * Diffuse Texture used in the material.
  46522. * Should be author in a specific way for the best result (refer to the documentation).
  46523. */
  46524. diffuseTexture: Nullable<BaseTexture>;
  46525. protected _shadowLights: Nullable<IShadowLight[]>;
  46526. /**
  46527. * Specify the list of lights casting shadow on the material.
  46528. * All scene shadow lights will be included if null.
  46529. */
  46530. shadowLights: Nullable<IShadowLight[]>;
  46531. protected _shadowLevel: float;
  46532. /**
  46533. * Helps adjusting the shadow to a softer level if required.
  46534. * 0 means black shadows and 1 means no shadows.
  46535. */
  46536. shadowLevel: float;
  46537. protected _sceneCenter: Vector3;
  46538. /**
  46539. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46540. * It is usually zero but might be interesting to modify according to your setup.
  46541. */
  46542. sceneCenter: Vector3;
  46543. protected _opacityFresnel: boolean;
  46544. /**
  46545. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46546. * This helps ensuring a nice transition when the camera goes under the ground.
  46547. */
  46548. opacityFresnel: boolean;
  46549. protected _reflectionFresnel: boolean;
  46550. /**
  46551. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46552. * This helps adding a mirror texture on the ground.
  46553. */
  46554. reflectionFresnel: boolean;
  46555. protected _reflectionFalloffDistance: number;
  46556. /**
  46557. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46558. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46559. */
  46560. reflectionFalloffDistance: number;
  46561. protected _reflectionAmount: number;
  46562. /**
  46563. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46564. */
  46565. reflectionAmount: number;
  46566. protected _reflectionReflectance0: number;
  46567. /**
  46568. * This specifies the weight of the reflection at grazing angle.
  46569. */
  46570. reflectionReflectance0: number;
  46571. protected _reflectionReflectance90: number;
  46572. /**
  46573. * This specifies the weight of the reflection at a perpendicular point of view.
  46574. */
  46575. reflectionReflectance90: number;
  46576. /**
  46577. * Sets the reflection reflectance fresnel values according to the default standard
  46578. * empirically know to work well :-)
  46579. */
  46580. reflectionStandardFresnelWeight: number;
  46581. protected _useRGBColor: boolean;
  46582. /**
  46583. * Helps to directly use the maps channels instead of their level.
  46584. */
  46585. useRGBColor: boolean;
  46586. protected _enableNoise: boolean;
  46587. /**
  46588. * This helps reducing the banding effect that could occur on the background.
  46589. */
  46590. enableNoise: boolean;
  46591. /**
  46592. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46593. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46594. * Recommended to be keep at 1.0 except for special cases.
  46595. */
  46596. fovMultiplier: number;
  46597. private _fovMultiplier;
  46598. /**
  46599. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46600. */
  46601. useEquirectangularFOV: boolean;
  46602. private _maxSimultaneousLights;
  46603. /**
  46604. * Number of Simultaneous lights allowed on the material.
  46605. */
  46606. maxSimultaneousLights: int;
  46607. /**
  46608. * Default configuration related to image processing available in the Background Material.
  46609. */
  46610. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46611. /**
  46612. * Keep track of the image processing observer to allow dispose and replace.
  46613. */
  46614. private _imageProcessingObserver;
  46615. /**
  46616. * Attaches a new image processing configuration to the PBR Material.
  46617. * @param configuration (if null the scene configuration will be use)
  46618. */
  46619. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46620. /**
  46621. * Gets the image processing configuration used either in this material.
  46622. */
  46623. /**
  46624. * Sets the Default image processing configuration used either in the this material.
  46625. *
  46626. * If sets to null, the scene one is in use.
  46627. */
  46628. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46629. /**
  46630. * Gets wether the color curves effect is enabled.
  46631. */
  46632. /**
  46633. * Sets wether the color curves effect is enabled.
  46634. */
  46635. cameraColorCurvesEnabled: boolean;
  46636. /**
  46637. * Gets wether the color grading effect is enabled.
  46638. */
  46639. /**
  46640. * Gets wether the color grading effect is enabled.
  46641. */
  46642. cameraColorGradingEnabled: boolean;
  46643. /**
  46644. * Gets wether tonemapping is enabled or not.
  46645. */
  46646. /**
  46647. * Sets wether tonemapping is enabled or not
  46648. */
  46649. cameraToneMappingEnabled: boolean;
  46650. /**
  46651. * The camera exposure used on this material.
  46652. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46653. * This corresponds to a photographic exposure.
  46654. */
  46655. /**
  46656. * The camera exposure used on this material.
  46657. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46658. * This corresponds to a photographic exposure.
  46659. */
  46660. cameraExposure: float;
  46661. /**
  46662. * Gets The camera contrast used on this material.
  46663. */
  46664. /**
  46665. * Sets The camera contrast used on this material.
  46666. */
  46667. cameraContrast: float;
  46668. /**
  46669. * Gets the Color Grading 2D Lookup Texture.
  46670. */
  46671. /**
  46672. * Sets the Color Grading 2D Lookup Texture.
  46673. */
  46674. cameraColorGradingTexture: Nullable<BaseTexture>;
  46675. /**
  46676. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46677. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46678. * 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;
  46679. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46680. */
  46681. /**
  46682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46684. * 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;
  46685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46686. */
  46687. cameraColorCurves: Nullable<ColorCurves>;
  46688. /**
  46689. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46690. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46691. */
  46692. switchToBGR: boolean;
  46693. private _renderTargets;
  46694. private _reflectionControls;
  46695. private _white;
  46696. private _primaryShadowColor;
  46697. private _primaryHighlightColor;
  46698. /**
  46699. * Instantiates a Background Material in the given scene
  46700. * @param name The friendly name of the material
  46701. * @param scene The scene to add the material to
  46702. */
  46703. constructor(name: string, scene: Scene);
  46704. /**
  46705. * Gets a boolean indicating that current material needs to register RTT
  46706. */
  46707. readonly hasRenderTargetTextures: boolean;
  46708. /**
  46709. * The entire material has been created in order to prevent overdraw.
  46710. * @returns false
  46711. */
  46712. needAlphaTesting(): boolean;
  46713. /**
  46714. * The entire material has been created in order to prevent overdraw.
  46715. * @returns true if blending is enable
  46716. */
  46717. needAlphaBlending(): boolean;
  46718. /**
  46719. * Checks wether the material is ready to be rendered for a given mesh.
  46720. * @param mesh The mesh to render
  46721. * @param subMesh The submesh to check against
  46722. * @param useInstances Specify wether or not the material is used with instances
  46723. * @returns true if all the dependencies are ready (Textures, Effects...)
  46724. */
  46725. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46726. /**
  46727. * Compute the primary color according to the chosen perceptual color.
  46728. */
  46729. private _computePrimaryColorFromPerceptualColor;
  46730. /**
  46731. * Compute the highlights and shadow colors according to their chosen levels.
  46732. */
  46733. private _computePrimaryColors;
  46734. /**
  46735. * Build the uniform buffer used in the material.
  46736. */
  46737. buildUniformLayout(): void;
  46738. /**
  46739. * Unbind the material.
  46740. */
  46741. unbind(): void;
  46742. /**
  46743. * Bind only the world matrix to the material.
  46744. * @param world The world matrix to bind.
  46745. */
  46746. bindOnlyWorldMatrix(world: Matrix): void;
  46747. /**
  46748. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46749. * @param world The world matrix to bind.
  46750. * @param subMesh The submesh to bind for.
  46751. */
  46752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46753. /**
  46754. * Checks to see if a texture is used in the material.
  46755. * @param texture - Base texture to use.
  46756. * @returns - Boolean specifying if a texture is used in the material.
  46757. */
  46758. hasTexture(texture: BaseTexture): boolean;
  46759. /**
  46760. * Dispose the material.
  46761. * @param forceDisposeEffect Force disposal of the associated effect.
  46762. * @param forceDisposeTextures Force disposal of the associated textures.
  46763. */
  46764. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46765. /**
  46766. * Clones the material.
  46767. * @param name The cloned name.
  46768. * @returns The cloned material.
  46769. */
  46770. clone(name: string): BackgroundMaterial;
  46771. /**
  46772. * Serializes the current material to its JSON representation.
  46773. * @returns The JSON representation.
  46774. */
  46775. serialize(): any;
  46776. /**
  46777. * Gets the class name of the material
  46778. * @returns "BackgroundMaterial"
  46779. */
  46780. getClassName(): string;
  46781. /**
  46782. * Parse a JSON input to create back a background material.
  46783. * @param source The JSON data to parse
  46784. * @param scene The scene to create the parsed material in
  46785. * @param rootUrl The root url of the assets the material depends upon
  46786. * @returns the instantiated BackgroundMaterial.
  46787. */
  46788. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46789. }
  46790. }
  46791. declare module BABYLON {
  46792. /**
  46793. * Represents the different options available during the creation of
  46794. * a Environment helper.
  46795. *
  46796. * This can control the default ground, skybox and image processing setup of your scene.
  46797. */
  46798. export interface IEnvironmentHelperOptions {
  46799. /**
  46800. * Specifies wether or not to create a ground.
  46801. * True by default.
  46802. */
  46803. createGround: boolean;
  46804. /**
  46805. * Specifies the ground size.
  46806. * 15 by default.
  46807. */
  46808. groundSize: number;
  46809. /**
  46810. * The texture used on the ground for the main color.
  46811. * Comes from the BabylonJS CDN by default.
  46812. *
  46813. * Remarks: Can be either a texture or a url.
  46814. */
  46815. groundTexture: string | BaseTexture;
  46816. /**
  46817. * The color mixed in the ground texture by default.
  46818. * BabylonJS clearColor by default.
  46819. */
  46820. groundColor: Color3;
  46821. /**
  46822. * Specifies the ground opacity.
  46823. * 1 by default.
  46824. */
  46825. groundOpacity: number;
  46826. /**
  46827. * Enables the ground to receive shadows.
  46828. * True by default.
  46829. */
  46830. enableGroundShadow: boolean;
  46831. /**
  46832. * Helps preventing the shadow to be fully black on the ground.
  46833. * 0.5 by default.
  46834. */
  46835. groundShadowLevel: number;
  46836. /**
  46837. * Creates a mirror texture attach to the ground.
  46838. * false by default.
  46839. */
  46840. enableGroundMirror: boolean;
  46841. /**
  46842. * Specifies the ground mirror size ratio.
  46843. * 0.3 by default as the default kernel is 64.
  46844. */
  46845. groundMirrorSizeRatio: number;
  46846. /**
  46847. * Specifies the ground mirror blur kernel size.
  46848. * 64 by default.
  46849. */
  46850. groundMirrorBlurKernel: number;
  46851. /**
  46852. * Specifies the ground mirror visibility amount.
  46853. * 1 by default
  46854. */
  46855. groundMirrorAmount: number;
  46856. /**
  46857. * Specifies the ground mirror reflectance weight.
  46858. * This uses the standard weight of the background material to setup the fresnel effect
  46859. * of the mirror.
  46860. * 1 by default.
  46861. */
  46862. groundMirrorFresnelWeight: number;
  46863. /**
  46864. * Specifies the ground mirror Falloff distance.
  46865. * This can helps reducing the size of the reflection.
  46866. * 0 by Default.
  46867. */
  46868. groundMirrorFallOffDistance: number;
  46869. /**
  46870. * Specifies the ground mirror texture type.
  46871. * Unsigned Int by Default.
  46872. */
  46873. groundMirrorTextureType: number;
  46874. /**
  46875. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46876. * the shown objects.
  46877. */
  46878. groundYBias: number;
  46879. /**
  46880. * Specifies wether or not to create a skybox.
  46881. * True by default.
  46882. */
  46883. createSkybox: boolean;
  46884. /**
  46885. * Specifies the skybox size.
  46886. * 20 by default.
  46887. */
  46888. skyboxSize: number;
  46889. /**
  46890. * The texture used on the skybox for the main color.
  46891. * Comes from the BabylonJS CDN by default.
  46892. *
  46893. * Remarks: Can be either a texture or a url.
  46894. */
  46895. skyboxTexture: string | BaseTexture;
  46896. /**
  46897. * The color mixed in the skybox texture by default.
  46898. * BabylonJS clearColor by default.
  46899. */
  46900. skyboxColor: Color3;
  46901. /**
  46902. * The background rotation around the Y axis of the scene.
  46903. * This helps aligning the key lights of your scene with the background.
  46904. * 0 by default.
  46905. */
  46906. backgroundYRotation: number;
  46907. /**
  46908. * Compute automatically the size of the elements to best fit with the scene.
  46909. */
  46910. sizeAuto: boolean;
  46911. /**
  46912. * Default position of the rootMesh if autoSize is not true.
  46913. */
  46914. rootPosition: Vector3;
  46915. /**
  46916. * Sets up the image processing in the scene.
  46917. * true by default.
  46918. */
  46919. setupImageProcessing: boolean;
  46920. /**
  46921. * The texture used as your environment texture in the scene.
  46922. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46923. *
  46924. * Remarks: Can be either a texture or a url.
  46925. */
  46926. environmentTexture: string | BaseTexture;
  46927. /**
  46928. * The value of the exposure to apply to the scene.
  46929. * 0.6 by default if setupImageProcessing is true.
  46930. */
  46931. cameraExposure: number;
  46932. /**
  46933. * The value of the contrast to apply to the scene.
  46934. * 1.6 by default if setupImageProcessing is true.
  46935. */
  46936. cameraContrast: number;
  46937. /**
  46938. * Specifies wether or not tonemapping should be enabled in the scene.
  46939. * true by default if setupImageProcessing is true.
  46940. */
  46941. toneMappingEnabled: boolean;
  46942. }
  46943. /**
  46944. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46945. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46946. * It also helps with the default setup of your imageProcessing configuration.
  46947. */
  46948. export class EnvironmentHelper {
  46949. /**
  46950. * Default ground texture URL.
  46951. */
  46952. private static _groundTextureCDNUrl;
  46953. /**
  46954. * Default skybox texture URL.
  46955. */
  46956. private static _skyboxTextureCDNUrl;
  46957. /**
  46958. * Default environment texture URL.
  46959. */
  46960. private static _environmentTextureCDNUrl;
  46961. /**
  46962. * Creates the default options for the helper.
  46963. */
  46964. private static _getDefaultOptions;
  46965. private _rootMesh;
  46966. /**
  46967. * Gets the root mesh created by the helper.
  46968. */
  46969. readonly rootMesh: Mesh;
  46970. private _skybox;
  46971. /**
  46972. * Gets the skybox created by the helper.
  46973. */
  46974. readonly skybox: Nullable<Mesh>;
  46975. private _skyboxTexture;
  46976. /**
  46977. * Gets the skybox texture created by the helper.
  46978. */
  46979. readonly skyboxTexture: Nullable<BaseTexture>;
  46980. private _skyboxMaterial;
  46981. /**
  46982. * Gets the skybox material created by the helper.
  46983. */
  46984. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46985. private _ground;
  46986. /**
  46987. * Gets the ground mesh created by the helper.
  46988. */
  46989. readonly ground: Nullable<Mesh>;
  46990. private _groundTexture;
  46991. /**
  46992. * Gets the ground texture created by the helper.
  46993. */
  46994. readonly groundTexture: Nullable<BaseTexture>;
  46995. private _groundMirror;
  46996. /**
  46997. * Gets the ground mirror created by the helper.
  46998. */
  46999. readonly groundMirror: Nullable<MirrorTexture>;
  47000. /**
  47001. * Gets the ground mirror render list to helps pushing the meshes
  47002. * you wish in the ground reflection.
  47003. */
  47004. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47005. private _groundMaterial;
  47006. /**
  47007. * Gets the ground material created by the helper.
  47008. */
  47009. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47010. /**
  47011. * Stores the creation options.
  47012. */
  47013. private readonly _scene;
  47014. private _options;
  47015. /**
  47016. * This observable will be notified with any error during the creation of the environment,
  47017. * mainly texture creation errors.
  47018. */
  47019. onErrorObservable: Observable<{
  47020. message?: string;
  47021. exception?: any;
  47022. }>;
  47023. /**
  47024. * constructor
  47025. * @param options Defines the options we want to customize the helper
  47026. * @param scene The scene to add the material to
  47027. */
  47028. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47029. /**
  47030. * Updates the background according to the new options
  47031. * @param options
  47032. */
  47033. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47034. /**
  47035. * Sets the primary color of all the available elements.
  47036. * @param color the main color to affect to the ground and the background
  47037. */
  47038. setMainColor(color: Color3): void;
  47039. /**
  47040. * Setup the image processing according to the specified options.
  47041. */
  47042. private _setupImageProcessing;
  47043. /**
  47044. * Setup the environment texture according to the specified options.
  47045. */
  47046. private _setupEnvironmentTexture;
  47047. /**
  47048. * Setup the background according to the specified options.
  47049. */
  47050. private _setupBackground;
  47051. /**
  47052. * Get the scene sizes according to the setup.
  47053. */
  47054. private _getSceneSize;
  47055. /**
  47056. * Setup the ground according to the specified options.
  47057. */
  47058. private _setupGround;
  47059. /**
  47060. * Setup the ground material according to the specified options.
  47061. */
  47062. private _setupGroundMaterial;
  47063. /**
  47064. * Setup the ground diffuse texture according to the specified options.
  47065. */
  47066. private _setupGroundDiffuseTexture;
  47067. /**
  47068. * Setup the ground mirror texture according to the specified options.
  47069. */
  47070. private _setupGroundMirrorTexture;
  47071. /**
  47072. * Setup the ground to receive the mirror texture.
  47073. */
  47074. private _setupMirrorInGroundMaterial;
  47075. /**
  47076. * Setup the skybox according to the specified options.
  47077. */
  47078. private _setupSkybox;
  47079. /**
  47080. * Setup the skybox material according to the specified options.
  47081. */
  47082. private _setupSkyboxMaterial;
  47083. /**
  47084. * Setup the skybox reflection texture according to the specified options.
  47085. */
  47086. private _setupSkyboxReflectionTexture;
  47087. private _errorHandler;
  47088. /**
  47089. * Dispose all the elements created by the Helper.
  47090. */
  47091. dispose(): void;
  47092. }
  47093. }
  47094. declare module BABYLON {
  47095. /**
  47096. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47097. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47098. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47099. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47100. */
  47101. export class PhotoDome extends TransformNode {
  47102. /**
  47103. * Define the image as a Monoscopic panoramic 360 image.
  47104. */
  47105. static readonly MODE_MONOSCOPIC: number;
  47106. /**
  47107. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47108. */
  47109. static readonly MODE_TOPBOTTOM: number;
  47110. /**
  47111. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47112. */
  47113. static readonly MODE_SIDEBYSIDE: number;
  47114. private _useDirectMapping;
  47115. /**
  47116. * The texture being displayed on the sphere
  47117. */
  47118. protected _photoTexture: Texture;
  47119. /**
  47120. * Gets or sets the texture being displayed on the sphere
  47121. */
  47122. photoTexture: Texture;
  47123. /**
  47124. * Observable raised when an error occured while loading the 360 image
  47125. */
  47126. onLoadErrorObservable: Observable<string>;
  47127. /**
  47128. * The skybox material
  47129. */
  47130. protected _material: BackgroundMaterial;
  47131. /**
  47132. * The surface used for the skybox
  47133. */
  47134. protected _mesh: Mesh;
  47135. /**
  47136. * Gets the mesh used for the skybox.
  47137. */
  47138. readonly mesh: Mesh;
  47139. /**
  47140. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47141. * Also see the options.resolution property.
  47142. */
  47143. fovMultiplier: number;
  47144. private _imageMode;
  47145. /**
  47146. * Gets or set the current video mode for the video. It can be:
  47147. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47148. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47149. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47150. */
  47151. imageMode: number;
  47152. /**
  47153. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47154. * @param name Element's name, child elements will append suffixes for their own names.
  47155. * @param urlsOfPhoto defines the url of the photo to display
  47156. * @param options defines an object containing optional or exposed sub element properties
  47157. * @param onError defines a callback called when an error occured while loading the texture
  47158. */
  47159. constructor(name: string, urlOfPhoto: string, options: {
  47160. resolution?: number;
  47161. size?: number;
  47162. useDirectMapping?: boolean;
  47163. faceForward?: boolean;
  47164. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47165. private _onBeforeCameraRenderObserver;
  47166. private _changeImageMode;
  47167. /**
  47168. * Releases resources associated with this node.
  47169. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47170. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47171. */
  47172. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47173. }
  47174. }
  47175. declare module BABYLON {
  47176. /**
  47177. * Class used to host RGBD texture specific utilities
  47178. */
  47179. export class RGBDTextureTools {
  47180. /**
  47181. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47182. * @param texture the texture to expand.
  47183. */
  47184. static ExpandRGBDTexture(texture: Texture): void;
  47185. }
  47186. }
  47187. declare module BABYLON {
  47188. /**
  47189. * Class used to host texture specific utilities
  47190. */
  47191. export class BRDFTextureTools {
  47192. /**
  47193. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47194. * @param scene defines the hosting scene
  47195. * @returns the environment BRDF texture
  47196. */
  47197. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47198. private static _environmentBRDFBase64Texture;
  47199. }
  47200. }
  47201. declare module BABYLON {
  47202. /**
  47203. * @hidden
  47204. */
  47205. export interface IMaterialClearCoatDefines {
  47206. CLEARCOAT: boolean;
  47207. CLEARCOAT_DEFAULTIOR: boolean;
  47208. CLEARCOAT_TEXTURE: boolean;
  47209. CLEARCOAT_TEXTUREDIRECTUV: number;
  47210. CLEARCOAT_BUMP: boolean;
  47211. CLEARCOAT_BUMPDIRECTUV: number;
  47212. CLEARCOAT_TINT: boolean;
  47213. CLEARCOAT_TINT_TEXTURE: boolean;
  47214. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47215. /** @hidden */
  47216. _areTexturesDirty: boolean;
  47217. }
  47218. /**
  47219. * Define the code related to the clear coat parameters of the pbr material.
  47220. */
  47221. export class PBRClearCoatConfiguration {
  47222. /**
  47223. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47224. * The default fits with a polyurethane material.
  47225. */
  47226. private static readonly _DefaultIndexOfRefraction;
  47227. private _isEnabled;
  47228. /**
  47229. * Defines if the clear coat is enabled in the material.
  47230. */
  47231. isEnabled: boolean;
  47232. /**
  47233. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47234. */
  47235. intensity: number;
  47236. /**
  47237. * Defines the clear coat layer roughness.
  47238. */
  47239. roughness: number;
  47240. private _indexOfRefraction;
  47241. /**
  47242. * Defines the index of refraction of the clear coat.
  47243. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47244. * The default fits with a polyurethane material.
  47245. * Changing the default value is more performance intensive.
  47246. */
  47247. indexOfRefraction: number;
  47248. private _texture;
  47249. /**
  47250. * Stores the clear coat values in a texture.
  47251. */
  47252. texture: Nullable<BaseTexture>;
  47253. private _bumpTexture;
  47254. /**
  47255. * Define the clear coat specific bump texture.
  47256. */
  47257. bumpTexture: Nullable<BaseTexture>;
  47258. private _isTintEnabled;
  47259. /**
  47260. * Defines if the clear coat tint is enabled in the material.
  47261. */
  47262. isTintEnabled: boolean;
  47263. /**
  47264. * Defines the clear coat tint of the material.
  47265. * This is only use if tint is enabled
  47266. */
  47267. tintColor: Color3;
  47268. /**
  47269. * Defines the distance at which the tint color should be found in the
  47270. * clear coat media.
  47271. * This is only use if tint is enabled
  47272. */
  47273. tintColorAtDistance: number;
  47274. /**
  47275. * Defines the clear coat layer thickness.
  47276. * This is only use if tint is enabled
  47277. */
  47278. tintThickness: number;
  47279. private _tintTexture;
  47280. /**
  47281. * Stores the clear tint values in a texture.
  47282. * rgb is tint
  47283. * a is a thickness factor
  47284. */
  47285. tintTexture: Nullable<BaseTexture>;
  47286. /** @hidden */
  47287. private _internalMarkAllSubMeshesAsTexturesDirty;
  47288. /** @hidden */
  47289. _markAllSubMeshesAsTexturesDirty(): void;
  47290. /**
  47291. * Instantiate a new istance of clear coat configuration.
  47292. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47293. */
  47294. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47295. /**
  47296. * Gets wehter the submesh is ready to be used or not.
  47297. * @param defines the list of "defines" to update.
  47298. * @param scene defines the scene the material belongs to.
  47299. * @param engine defines the engine the material belongs to.
  47300. * @param disableBumpMap defines wether the material disables bump or not.
  47301. * @returns - boolean indicating that the submesh is ready or not.
  47302. */
  47303. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47304. /**
  47305. * Checks to see if a texture is used in the material.
  47306. * @param defines the list of "defines" to update.
  47307. * @param scene defines the scene to the material belongs to.
  47308. */
  47309. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47310. /**
  47311. * Binds the material data.
  47312. * @param uniformBuffer defines the Uniform buffer to fill in.
  47313. * @param scene defines the scene the material belongs to.
  47314. * @param engine defines the engine the material belongs to.
  47315. * @param disableBumpMap defines wether the material disables bump or not.
  47316. * @param isFrozen defines wether the material is frozen or not.
  47317. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47318. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47319. */
  47320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47321. /**
  47322. * Checks to see if a texture is used in the material.
  47323. * @param texture - Base texture to use.
  47324. * @returns - Boolean specifying if a texture is used in the material.
  47325. */
  47326. hasTexture(texture: BaseTexture): boolean;
  47327. /**
  47328. * Returns an array of the actively used textures.
  47329. * @param activeTextures Array of BaseTextures
  47330. */
  47331. getActiveTextures(activeTextures: BaseTexture[]): void;
  47332. /**
  47333. * Returns the animatable textures.
  47334. * @param animatables Array of animatable textures.
  47335. */
  47336. getAnimatables(animatables: IAnimatable[]): void;
  47337. /**
  47338. * Disposes the resources of the material.
  47339. * @param forceDisposeTextures - Forces the disposal of all textures.
  47340. */
  47341. dispose(forceDisposeTextures?: boolean): void;
  47342. /**
  47343. * Get the current class name of the texture useful for serialization or dynamic coding.
  47344. * @returns "PBRClearCoatConfiguration"
  47345. */
  47346. getClassName(): string;
  47347. /**
  47348. * Add fallbacks to the effect fallbacks list.
  47349. * @param defines defines the Base texture to use.
  47350. * @param fallbacks defines the current fallback list.
  47351. * @param currentRank defines the current fallback rank.
  47352. * @returns the new fallback rank.
  47353. */
  47354. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47355. /**
  47356. * Add the required uniforms to the current list.
  47357. * @param uniforms defines the current uniform list.
  47358. */
  47359. static AddUniforms(uniforms: string[]): void;
  47360. /**
  47361. * Add the required samplers to the current list.
  47362. * @param samplers defines the current sampler list.
  47363. */
  47364. static AddSamplers(samplers: string[]): void;
  47365. /**
  47366. * Add the required uniforms to the current buffer.
  47367. * @param uniformBuffer defines the current uniform buffer.
  47368. */
  47369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47370. /**
  47371. * Makes a duplicate of the current configuration into another one.
  47372. * @param clearCoatConfiguration define the config where to copy the info
  47373. */
  47374. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47375. /**
  47376. * Serializes this clear coat configuration.
  47377. * @returns - An object with the serialized config.
  47378. */
  47379. serialize(): any;
  47380. /**
  47381. * Parses a anisotropy Configuration from a serialized object.
  47382. * @param source - Serialized object.
  47383. * @param scene Defines the scene we are parsing for
  47384. * @param rootUrl Defines the rootUrl to load from
  47385. */
  47386. parse(source: any, scene: Scene, rootUrl: string): void;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /**
  47391. * @hidden
  47392. */
  47393. export interface IMaterialAnisotropicDefines {
  47394. ANISOTROPIC: boolean;
  47395. ANISOTROPIC_TEXTURE: boolean;
  47396. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47397. MAINUV1: boolean;
  47398. _areTexturesDirty: boolean;
  47399. _needUVs: boolean;
  47400. }
  47401. /**
  47402. * Define the code related to the anisotropic parameters of the pbr material.
  47403. */
  47404. export class PBRAnisotropicConfiguration {
  47405. private _isEnabled;
  47406. /**
  47407. * Defines if the anisotropy is enabled in the material.
  47408. */
  47409. isEnabled: boolean;
  47410. /**
  47411. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47412. */
  47413. intensity: number;
  47414. /**
  47415. * Defines if the effect is along the tangents, bitangents or in between.
  47416. * By default, the effect is "strectching" the highlights along the tangents.
  47417. */
  47418. direction: Vector2;
  47419. private _texture;
  47420. /**
  47421. * Stores the anisotropy values in a texture.
  47422. * rg is direction (like normal from -1 to 1)
  47423. * b is a intensity
  47424. */
  47425. texture: Nullable<BaseTexture>;
  47426. /** @hidden */
  47427. private _internalMarkAllSubMeshesAsTexturesDirty;
  47428. /** @hidden */
  47429. _markAllSubMeshesAsTexturesDirty(): void;
  47430. /**
  47431. * Instantiate a new istance of anisotropy configuration.
  47432. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47433. */
  47434. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47435. /**
  47436. * Specifies that the submesh is ready to be used.
  47437. * @param defines the list of "defines" to update.
  47438. * @param scene defines the scene the material belongs to.
  47439. * @returns - boolean indicating that the submesh is ready or not.
  47440. */
  47441. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47442. /**
  47443. * Checks to see if a texture is used in the material.
  47444. * @param defines the list of "defines" to update.
  47445. * @param mesh the mesh we are preparing the defines for.
  47446. * @param scene defines the scene the material belongs to.
  47447. */
  47448. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47449. /**
  47450. * Binds the material data.
  47451. * @param uniformBuffer defines the Uniform buffer to fill in.
  47452. * @param scene defines the scene the material belongs to.
  47453. * @param isFrozen defines wether the material is frozen or not.
  47454. */
  47455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47456. /**
  47457. * Checks to see if a texture is used in the material.
  47458. * @param texture - Base texture to use.
  47459. * @returns - Boolean specifying if a texture is used in the material.
  47460. */
  47461. hasTexture(texture: BaseTexture): boolean;
  47462. /**
  47463. * Returns an array of the actively used textures.
  47464. * @param activeTextures Array of BaseTextures
  47465. */
  47466. getActiveTextures(activeTextures: BaseTexture[]): void;
  47467. /**
  47468. * Returns the animatable textures.
  47469. * @param animatables Array of animatable textures.
  47470. */
  47471. getAnimatables(animatables: IAnimatable[]): void;
  47472. /**
  47473. * Disposes the resources of the material.
  47474. * @param forceDisposeTextures - Forces the disposal of all textures.
  47475. */
  47476. dispose(forceDisposeTextures?: boolean): void;
  47477. /**
  47478. * Get the current class name of the texture useful for serialization or dynamic coding.
  47479. * @returns "PBRAnisotropicConfiguration"
  47480. */
  47481. getClassName(): string;
  47482. /**
  47483. * Add fallbacks to the effect fallbacks list.
  47484. * @param defines defines the Base texture to use.
  47485. * @param fallbacks defines the current fallback list.
  47486. * @param currentRank defines the current fallback rank.
  47487. * @returns the new fallback rank.
  47488. */
  47489. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47490. /**
  47491. * Add the required uniforms to the current list.
  47492. * @param uniforms defines the current uniform list.
  47493. */
  47494. static AddUniforms(uniforms: string[]): void;
  47495. /**
  47496. * Add the required uniforms to the current buffer.
  47497. * @param uniformBuffer defines the current uniform buffer.
  47498. */
  47499. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47500. /**
  47501. * Add the required samplers to the current list.
  47502. * @param samplers defines the current sampler list.
  47503. */
  47504. static AddSamplers(samplers: string[]): void;
  47505. /**
  47506. * Makes a duplicate of the current configuration into another one.
  47507. * @param anisotropicConfiguration define the config where to copy the info
  47508. */
  47509. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47510. /**
  47511. * Serializes this anisotropy configuration.
  47512. * @returns - An object with the serialized config.
  47513. */
  47514. serialize(): any;
  47515. /**
  47516. * Parses a anisotropy Configuration from a serialized object.
  47517. * @param source - Serialized object.
  47518. * @param scene Defines the scene we are parsing for
  47519. * @param rootUrl Defines the rootUrl to load from
  47520. */
  47521. parse(source: any, scene: Scene, rootUrl: string): void;
  47522. }
  47523. }
  47524. declare module BABYLON {
  47525. /**
  47526. * @hidden
  47527. */
  47528. export interface IMaterialBRDFDefines {
  47529. BRDF_V_HEIGHT_CORRELATED: boolean;
  47530. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47531. SPHERICAL_HARMONICS: boolean;
  47532. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47533. /** @hidden */
  47534. _areMiscDirty: boolean;
  47535. }
  47536. /**
  47537. * Define the code related to the BRDF parameters of the pbr material.
  47538. */
  47539. export class PBRBRDFConfiguration {
  47540. /**
  47541. * Default value used for the energy conservation.
  47542. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47543. */
  47544. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47545. /**
  47546. * Default value used for the Smith Visibility Height Correlated mode.
  47547. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47548. */
  47549. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47550. /**
  47551. * Default value used for the IBL diffuse part.
  47552. * This can help switching back to the polynomials mode globally which is a tiny bit
  47553. * less GPU intensive at the drawback of a lower quality.
  47554. */
  47555. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47556. /**
  47557. * Default value used for activating energy conservation for the specular workflow.
  47558. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47559. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47560. */
  47561. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47562. private _useEnergyConservation;
  47563. /**
  47564. * Defines if the material uses energy conservation.
  47565. */
  47566. useEnergyConservation: boolean;
  47567. private _useSmithVisibilityHeightCorrelated;
  47568. /**
  47569. * LEGACY Mode set to false
  47570. * Defines if the material uses height smith correlated visibility term.
  47571. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47572. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47573. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47574. * Not relying on height correlated will also disable energy conservation.
  47575. */
  47576. useSmithVisibilityHeightCorrelated: boolean;
  47577. private _useSphericalHarmonics;
  47578. /**
  47579. * LEGACY Mode set to false
  47580. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47581. * diffuse part of the IBL.
  47582. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47583. * to the ground truth.
  47584. */
  47585. useSphericalHarmonics: boolean;
  47586. private _useSpecularGlossinessInputEnergyConservation;
  47587. /**
  47588. * Defines if the material uses energy conservation, when the specular workflow is active.
  47589. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47590. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47591. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47592. */
  47593. useSpecularGlossinessInputEnergyConservation: boolean;
  47594. /** @hidden */
  47595. private _internalMarkAllSubMeshesAsMiscDirty;
  47596. /** @hidden */
  47597. _markAllSubMeshesAsMiscDirty(): void;
  47598. /**
  47599. * Instantiate a new istance of clear coat configuration.
  47600. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47601. */
  47602. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47603. /**
  47604. * Checks to see if a texture is used in the material.
  47605. * @param defines the list of "defines" to update.
  47606. */
  47607. prepareDefines(defines: IMaterialBRDFDefines): void;
  47608. /**
  47609. * Get the current class name of the texture useful for serialization or dynamic coding.
  47610. * @returns "PBRClearCoatConfiguration"
  47611. */
  47612. getClassName(): string;
  47613. /**
  47614. * Makes a duplicate of the current configuration into another one.
  47615. * @param brdfConfiguration define the config where to copy the info
  47616. */
  47617. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47618. /**
  47619. * Serializes this BRDF configuration.
  47620. * @returns - An object with the serialized config.
  47621. */
  47622. serialize(): any;
  47623. /**
  47624. * Parses a anisotropy Configuration from a serialized object.
  47625. * @param source - Serialized object.
  47626. * @param scene Defines the scene we are parsing for
  47627. * @param rootUrl Defines the rootUrl to load from
  47628. */
  47629. parse(source: any, scene: Scene, rootUrl: string): void;
  47630. }
  47631. }
  47632. declare module BABYLON {
  47633. /**
  47634. * @hidden
  47635. */
  47636. export interface IMaterialSheenDefines {
  47637. SHEEN: boolean;
  47638. SHEEN_TEXTURE: boolean;
  47639. SHEEN_TEXTUREDIRECTUV: number;
  47640. SHEEN_LINKWITHALBEDO: boolean;
  47641. /** @hidden */
  47642. _areTexturesDirty: boolean;
  47643. }
  47644. /**
  47645. * Define the code related to the Sheen parameters of the pbr material.
  47646. */
  47647. export class PBRSheenConfiguration {
  47648. private _isEnabled;
  47649. /**
  47650. * Defines if the material uses sheen.
  47651. */
  47652. isEnabled: boolean;
  47653. private _linkSheenWithAlbedo;
  47654. /**
  47655. * Defines if the sheen is linked to the sheen color.
  47656. */
  47657. linkSheenWithAlbedo: boolean;
  47658. /**
  47659. * Defines the sheen intensity.
  47660. */
  47661. intensity: number;
  47662. /**
  47663. * Defines the sheen color.
  47664. */
  47665. color: Color3;
  47666. private _texture;
  47667. /**
  47668. * Stores the sheen tint values in a texture.
  47669. * rgb is tint
  47670. * a is a intensity
  47671. */
  47672. texture: Nullable<BaseTexture>;
  47673. /** @hidden */
  47674. private _internalMarkAllSubMeshesAsTexturesDirty;
  47675. /** @hidden */
  47676. _markAllSubMeshesAsTexturesDirty(): void;
  47677. /**
  47678. * Instantiate a new istance of clear coat configuration.
  47679. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47680. */
  47681. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47682. /**
  47683. * Specifies that the submesh is ready to be used.
  47684. * @param defines the list of "defines" to update.
  47685. * @param scene defines the scene the material belongs to.
  47686. * @returns - boolean indicating that the submesh is ready or not.
  47687. */
  47688. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47689. /**
  47690. * Checks to see if a texture is used in the material.
  47691. * @param defines the list of "defines" to update.
  47692. * @param scene defines the scene the material belongs to.
  47693. */
  47694. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47695. /**
  47696. * Binds the material data.
  47697. * @param uniformBuffer defines the Uniform buffer to fill in.
  47698. * @param scene defines the scene the material belongs to.
  47699. * @param isFrozen defines wether the material is frozen or not.
  47700. */
  47701. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47702. /**
  47703. * Checks to see if a texture is used in the material.
  47704. * @param texture - Base texture to use.
  47705. * @returns - Boolean specifying if a texture is used in the material.
  47706. */
  47707. hasTexture(texture: BaseTexture): boolean;
  47708. /**
  47709. * Returns an array of the actively used textures.
  47710. * @param activeTextures Array of BaseTextures
  47711. */
  47712. getActiveTextures(activeTextures: BaseTexture[]): void;
  47713. /**
  47714. * Returns the animatable textures.
  47715. * @param animatables Array of animatable textures.
  47716. */
  47717. getAnimatables(animatables: IAnimatable[]): void;
  47718. /**
  47719. * Disposes the resources of the material.
  47720. * @param forceDisposeTextures - Forces the disposal of all textures.
  47721. */
  47722. dispose(forceDisposeTextures?: boolean): void;
  47723. /**
  47724. * Get the current class name of the texture useful for serialization or dynamic coding.
  47725. * @returns "PBRSheenConfiguration"
  47726. */
  47727. getClassName(): string;
  47728. /**
  47729. * Add fallbacks to the effect fallbacks list.
  47730. * @param defines defines the Base texture to use.
  47731. * @param fallbacks defines the current fallback list.
  47732. * @param currentRank defines the current fallback rank.
  47733. * @returns the new fallback rank.
  47734. */
  47735. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47736. /**
  47737. * Add the required uniforms to the current list.
  47738. * @param uniforms defines the current uniform list.
  47739. */
  47740. static AddUniforms(uniforms: string[]): void;
  47741. /**
  47742. * Add the required uniforms to the current buffer.
  47743. * @param uniformBuffer defines the current uniform buffer.
  47744. */
  47745. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47746. /**
  47747. * Add the required samplers to the current list.
  47748. * @param samplers defines the current sampler list.
  47749. */
  47750. static AddSamplers(samplers: string[]): void;
  47751. /**
  47752. * Makes a duplicate of the current configuration into another one.
  47753. * @param sheenConfiguration define the config where to copy the info
  47754. */
  47755. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47756. /**
  47757. * Serializes this BRDF configuration.
  47758. * @returns - An object with the serialized config.
  47759. */
  47760. serialize(): any;
  47761. /**
  47762. * Parses a anisotropy Configuration from a serialized object.
  47763. * @param source - Serialized object.
  47764. * @param scene Defines the scene we are parsing for
  47765. * @param rootUrl Defines the rootUrl to load from
  47766. */
  47767. parse(source: any, scene: Scene, rootUrl: string): void;
  47768. }
  47769. }
  47770. declare module BABYLON {
  47771. /**
  47772. * @hidden
  47773. */
  47774. export interface IMaterialSubSurfaceDefines {
  47775. SUBSURFACE: boolean;
  47776. SS_REFRACTION: boolean;
  47777. SS_TRANSLUCENCY: boolean;
  47778. SS_SCATERRING: boolean;
  47779. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47780. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47781. SS_REFRACTIONMAP_3D: boolean;
  47782. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47783. SS_LODINREFRACTIONALPHA: boolean;
  47784. SS_GAMMAREFRACTION: boolean;
  47785. SS_RGBDREFRACTION: boolean;
  47786. SS_LINEARSPECULARREFRACTION: boolean;
  47787. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47788. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47789. /** @hidden */
  47790. _areTexturesDirty: boolean;
  47791. }
  47792. /**
  47793. * Define the code related to the sub surface parameters of the pbr material.
  47794. */
  47795. export class PBRSubSurfaceConfiguration {
  47796. private _isRefractionEnabled;
  47797. /**
  47798. * Defines if the refraction is enabled in the material.
  47799. */
  47800. isRefractionEnabled: boolean;
  47801. private _isTranslucencyEnabled;
  47802. /**
  47803. * Defines if the translucency is enabled in the material.
  47804. */
  47805. isTranslucencyEnabled: boolean;
  47806. private _isScatteringEnabled;
  47807. /**
  47808. * Defines the refraction intensity of the material.
  47809. * The refraction when enabled replaces the Diffuse part of the material.
  47810. * The intensity helps transitionning between diffuse and refraction.
  47811. */
  47812. refractionIntensity: number;
  47813. /**
  47814. * Defines the translucency intensity of the material.
  47815. * When translucency has been enabled, this defines how much of the "translucency"
  47816. * is addded to the diffuse part of the material.
  47817. */
  47818. translucencyIntensity: number;
  47819. /**
  47820. * Defines the scattering intensity of the material.
  47821. * When scattering has been enabled, this defines how much of the "scattered light"
  47822. * is addded to the diffuse part of the material.
  47823. */
  47824. scatteringIntensity: number;
  47825. private _thicknessTexture;
  47826. /**
  47827. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47828. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47829. * 0 would mean minimumThickness
  47830. * 1 would mean maximumThickness
  47831. * The other channels might be use as a mask to vary the different effects intensity.
  47832. */
  47833. thicknessTexture: Nullable<BaseTexture>;
  47834. private _refractionTexture;
  47835. /**
  47836. * Defines the texture to use for refraction.
  47837. */
  47838. refractionTexture: Nullable<BaseTexture>;
  47839. private _indexOfRefraction;
  47840. /**
  47841. * Defines the index of refraction used in the material.
  47842. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47843. */
  47844. indexOfRefraction: number;
  47845. private _invertRefractionY;
  47846. /**
  47847. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47848. */
  47849. invertRefractionY: boolean;
  47850. private _linkRefractionWithTransparency;
  47851. /**
  47852. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47853. * Materials half opaque for instance using refraction could benefit from this control.
  47854. */
  47855. linkRefractionWithTransparency: boolean;
  47856. /**
  47857. * Defines the minimum thickness stored in the thickness map.
  47858. * If no thickness map is defined, this value will be used to simulate thickness.
  47859. */
  47860. minimumThickness: number;
  47861. /**
  47862. * Defines the maximum thickness stored in the thickness map.
  47863. */
  47864. maximumThickness: number;
  47865. /**
  47866. * Defines the volume tint of the material.
  47867. * This is used for both translucency and scattering.
  47868. */
  47869. tintColor: Color3;
  47870. /**
  47871. * Defines the distance at which the tint color should be found in the media.
  47872. * This is used for refraction only.
  47873. */
  47874. tintColorAtDistance: number;
  47875. /**
  47876. * Defines how far each channel transmit through the media.
  47877. * It is defined as a color to simplify it selection.
  47878. */
  47879. diffusionDistance: Color3;
  47880. private _useMaskFromThicknessTexture;
  47881. /**
  47882. * Stores the intensity of the different subsurface effects in the thickness texture.
  47883. * * the green channel is the translucency intensity.
  47884. * * the blue channel is the scattering intensity.
  47885. * * the alpha channel is the refraction intensity.
  47886. */
  47887. useMaskFromThicknessTexture: boolean;
  47888. /** @hidden */
  47889. private _internalMarkAllSubMeshesAsTexturesDirty;
  47890. /** @hidden */
  47891. _markAllSubMeshesAsTexturesDirty(): void;
  47892. /**
  47893. * Instantiate a new istance of sub surface configuration.
  47894. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47895. */
  47896. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47897. /**
  47898. * Gets wehter the submesh is ready to be used or not.
  47899. * @param defines the list of "defines" to update.
  47900. * @param scene defines the scene the material belongs to.
  47901. * @returns - boolean indicating that the submesh is ready or not.
  47902. */
  47903. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47904. /**
  47905. * Checks to see if a texture is used in the material.
  47906. * @param defines the list of "defines" to update.
  47907. * @param scene defines the scene to the material belongs to.
  47908. */
  47909. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47910. /**
  47911. * Binds the material data.
  47912. * @param uniformBuffer defines the Uniform buffer to fill in.
  47913. * @param scene defines the scene the material belongs to.
  47914. * @param engine defines the engine the material belongs to.
  47915. * @param isFrozen defines wether the material is frozen or not.
  47916. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47917. */
  47918. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47919. /**
  47920. * Unbinds the material from the mesh.
  47921. * @param activeEffect defines the effect that should be unbound from.
  47922. * @returns true if unbound, otherwise false
  47923. */
  47924. unbind(activeEffect: Effect): boolean;
  47925. /**
  47926. * Returns the texture used for refraction or null if none is used.
  47927. * @param scene defines the scene the material belongs to.
  47928. * @returns - Refraction texture if present. If no refraction texture and refraction
  47929. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47930. */
  47931. private _getRefractionTexture;
  47932. /**
  47933. * Returns true if alpha blending should be disabled.
  47934. */
  47935. readonly disableAlphaBlending: boolean;
  47936. /**
  47937. * Fills the list of render target textures.
  47938. * @param renderTargets the list of render targets to update
  47939. */
  47940. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47941. /**
  47942. * Checks to see if a texture is used in the material.
  47943. * @param texture - Base texture to use.
  47944. * @returns - Boolean specifying if a texture is used in the material.
  47945. */
  47946. hasTexture(texture: BaseTexture): boolean;
  47947. /**
  47948. * Gets a boolean indicating that current material needs to register RTT
  47949. * @returns true if this uses a render target otherwise false.
  47950. */
  47951. hasRenderTargetTextures(): boolean;
  47952. /**
  47953. * Returns an array of the actively used textures.
  47954. * @param activeTextures Array of BaseTextures
  47955. */
  47956. getActiveTextures(activeTextures: BaseTexture[]): void;
  47957. /**
  47958. * Returns the animatable textures.
  47959. * @param animatables Array of animatable textures.
  47960. */
  47961. getAnimatables(animatables: IAnimatable[]): void;
  47962. /**
  47963. * Disposes the resources of the material.
  47964. * @param forceDisposeTextures - Forces the disposal of all textures.
  47965. */
  47966. dispose(forceDisposeTextures?: boolean): void;
  47967. /**
  47968. * Get the current class name of the texture useful for serialization or dynamic coding.
  47969. * @returns "PBRSubSurfaceConfiguration"
  47970. */
  47971. getClassName(): string;
  47972. /**
  47973. * Add fallbacks to the effect fallbacks list.
  47974. * @param defines defines the Base texture to use.
  47975. * @param fallbacks defines the current fallback list.
  47976. * @param currentRank defines the current fallback rank.
  47977. * @returns the new fallback rank.
  47978. */
  47979. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47980. /**
  47981. * Add the required uniforms to the current list.
  47982. * @param uniforms defines the current uniform list.
  47983. */
  47984. static AddUniforms(uniforms: string[]): void;
  47985. /**
  47986. * Add the required samplers to the current list.
  47987. * @param samplers defines the current sampler list.
  47988. */
  47989. static AddSamplers(samplers: string[]): void;
  47990. /**
  47991. * Add the required uniforms to the current buffer.
  47992. * @param uniformBuffer defines the current uniform buffer.
  47993. */
  47994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47995. /**
  47996. * Makes a duplicate of the current configuration into another one.
  47997. * @param configuration define the config where to copy the info
  47998. */
  47999. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48000. /**
  48001. * Serializes this Sub Surface configuration.
  48002. * @returns - An object with the serialized config.
  48003. */
  48004. serialize(): any;
  48005. /**
  48006. * Parses a anisotropy Configuration from a serialized object.
  48007. * @param source - Serialized object.
  48008. * @param scene Defines the scene we are parsing for
  48009. * @param rootUrl Defines the rootUrl to load from
  48010. */
  48011. parse(source: any, scene: Scene, rootUrl: string): void;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /** @hidden */
  48016. export var pbrFragmentDeclaration: {
  48017. name: string;
  48018. shader: string;
  48019. };
  48020. }
  48021. declare module BABYLON {
  48022. /** @hidden */
  48023. export var pbrUboDeclaration: {
  48024. name: string;
  48025. shader: string;
  48026. };
  48027. }
  48028. declare module BABYLON {
  48029. /** @hidden */
  48030. export var pbrFragmentExtraDeclaration: {
  48031. name: string;
  48032. shader: string;
  48033. };
  48034. }
  48035. declare module BABYLON {
  48036. /** @hidden */
  48037. export var pbrFragmentSamplersDeclaration: {
  48038. name: string;
  48039. shader: string;
  48040. };
  48041. }
  48042. declare module BABYLON {
  48043. /** @hidden */
  48044. export var pbrHelperFunctions: {
  48045. name: string;
  48046. shader: string;
  48047. };
  48048. }
  48049. declare module BABYLON {
  48050. /** @hidden */
  48051. export var harmonicsFunctions: {
  48052. name: string;
  48053. shader: string;
  48054. };
  48055. }
  48056. declare module BABYLON {
  48057. /** @hidden */
  48058. export var pbrDirectLightingSetupFunctions: {
  48059. name: string;
  48060. shader: string;
  48061. };
  48062. }
  48063. declare module BABYLON {
  48064. /** @hidden */
  48065. export var pbrDirectLightingFalloffFunctions: {
  48066. name: string;
  48067. shader: string;
  48068. };
  48069. }
  48070. declare module BABYLON {
  48071. /** @hidden */
  48072. export var pbrBRDFFunctions: {
  48073. name: string;
  48074. shader: string;
  48075. };
  48076. }
  48077. declare module BABYLON {
  48078. /** @hidden */
  48079. export var pbrDirectLightingFunctions: {
  48080. name: string;
  48081. shader: string;
  48082. };
  48083. }
  48084. declare module BABYLON {
  48085. /** @hidden */
  48086. export var pbrIBLFunctions: {
  48087. name: string;
  48088. shader: string;
  48089. };
  48090. }
  48091. declare module BABYLON {
  48092. /** @hidden */
  48093. export var pbrDebug: {
  48094. name: string;
  48095. shader: string;
  48096. };
  48097. }
  48098. declare module BABYLON {
  48099. /** @hidden */
  48100. export var pbrPixelShader: {
  48101. name: string;
  48102. shader: string;
  48103. };
  48104. }
  48105. declare module BABYLON {
  48106. /** @hidden */
  48107. export var pbrVertexDeclaration: {
  48108. name: string;
  48109. shader: string;
  48110. };
  48111. }
  48112. declare module BABYLON {
  48113. /** @hidden */
  48114. export var pbrVertexShader: {
  48115. name: string;
  48116. shader: string;
  48117. };
  48118. }
  48119. declare module BABYLON {
  48120. /**
  48121. * Manages the defines for the PBR Material.
  48122. * @hidden
  48123. */
  48124. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48125. PBR: boolean;
  48126. MAINUV1: boolean;
  48127. MAINUV2: boolean;
  48128. UV1: boolean;
  48129. UV2: boolean;
  48130. ALBEDO: boolean;
  48131. ALBEDODIRECTUV: number;
  48132. VERTEXCOLOR: boolean;
  48133. AMBIENT: boolean;
  48134. AMBIENTDIRECTUV: number;
  48135. AMBIENTINGRAYSCALE: boolean;
  48136. OPACITY: boolean;
  48137. VERTEXALPHA: boolean;
  48138. OPACITYDIRECTUV: number;
  48139. OPACITYRGB: boolean;
  48140. ALPHATEST: boolean;
  48141. DEPTHPREPASS: boolean;
  48142. ALPHABLEND: boolean;
  48143. ALPHAFROMALBEDO: boolean;
  48144. ALPHATESTVALUE: string;
  48145. SPECULAROVERALPHA: boolean;
  48146. RADIANCEOVERALPHA: boolean;
  48147. ALPHAFRESNEL: boolean;
  48148. LINEARALPHAFRESNEL: boolean;
  48149. PREMULTIPLYALPHA: boolean;
  48150. EMISSIVE: boolean;
  48151. EMISSIVEDIRECTUV: number;
  48152. REFLECTIVITY: boolean;
  48153. REFLECTIVITYDIRECTUV: number;
  48154. SPECULARTERM: boolean;
  48155. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48156. MICROSURFACEAUTOMATIC: boolean;
  48157. LODBASEDMICROSFURACE: boolean;
  48158. MICROSURFACEMAP: boolean;
  48159. MICROSURFACEMAPDIRECTUV: number;
  48160. METALLICWORKFLOW: boolean;
  48161. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48162. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48163. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48164. AOSTOREINMETALMAPRED: boolean;
  48165. METALLICF0FACTORFROMMETALLICMAP: boolean;
  48166. ENVIRONMENTBRDF: boolean;
  48167. ENVIRONMENTBRDF_RGBD: boolean;
  48168. NORMAL: boolean;
  48169. TANGENT: boolean;
  48170. BUMP: boolean;
  48171. BUMPDIRECTUV: number;
  48172. OBJECTSPACE_NORMALMAP: boolean;
  48173. PARALLAX: boolean;
  48174. PARALLAXOCCLUSION: boolean;
  48175. NORMALXYSCALE: boolean;
  48176. LIGHTMAP: boolean;
  48177. LIGHTMAPDIRECTUV: number;
  48178. USELIGHTMAPASSHADOWMAP: boolean;
  48179. GAMMALIGHTMAP: boolean;
  48180. RGBDLIGHTMAP: boolean;
  48181. REFLECTION: boolean;
  48182. REFLECTIONMAP_3D: boolean;
  48183. REFLECTIONMAP_SPHERICAL: boolean;
  48184. REFLECTIONMAP_PLANAR: boolean;
  48185. REFLECTIONMAP_CUBIC: boolean;
  48186. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48187. REFLECTIONMAP_PROJECTION: boolean;
  48188. REFLECTIONMAP_SKYBOX: boolean;
  48189. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48190. REFLECTIONMAP_EXPLICIT: boolean;
  48191. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48192. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48193. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48194. INVERTCUBICMAP: boolean;
  48195. USESPHERICALFROMREFLECTIONMAP: boolean;
  48196. USEIRRADIANCEMAP: boolean;
  48197. SPHERICAL_HARMONICS: boolean;
  48198. USESPHERICALINVERTEX: boolean;
  48199. REFLECTIONMAP_OPPOSITEZ: boolean;
  48200. LODINREFLECTIONALPHA: boolean;
  48201. GAMMAREFLECTION: boolean;
  48202. RGBDREFLECTION: boolean;
  48203. LINEARSPECULARREFLECTION: boolean;
  48204. RADIANCEOCCLUSION: boolean;
  48205. HORIZONOCCLUSION: boolean;
  48206. INSTANCES: boolean;
  48207. NUM_BONE_INFLUENCERS: number;
  48208. BonesPerMesh: number;
  48209. BONETEXTURE: boolean;
  48210. NONUNIFORMSCALING: boolean;
  48211. MORPHTARGETS: boolean;
  48212. MORPHTARGETS_NORMAL: boolean;
  48213. MORPHTARGETS_TANGENT: boolean;
  48214. MORPHTARGETS_UV: boolean;
  48215. NUM_MORPH_INFLUENCERS: number;
  48216. IMAGEPROCESSING: boolean;
  48217. VIGNETTE: boolean;
  48218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48219. VIGNETTEBLENDMODEOPAQUE: boolean;
  48220. TONEMAPPING: boolean;
  48221. TONEMAPPING_ACES: boolean;
  48222. CONTRAST: boolean;
  48223. COLORCURVES: boolean;
  48224. COLORGRADING: boolean;
  48225. COLORGRADING3D: boolean;
  48226. SAMPLER3DGREENDEPTH: boolean;
  48227. SAMPLER3DBGRMAP: boolean;
  48228. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48229. EXPOSURE: boolean;
  48230. MULTIVIEW: boolean;
  48231. USEPHYSICALLIGHTFALLOFF: boolean;
  48232. USEGLTFLIGHTFALLOFF: boolean;
  48233. TWOSIDEDLIGHTING: boolean;
  48234. SHADOWFLOAT: boolean;
  48235. CLIPPLANE: boolean;
  48236. CLIPPLANE2: boolean;
  48237. CLIPPLANE3: boolean;
  48238. CLIPPLANE4: boolean;
  48239. POINTSIZE: boolean;
  48240. FOG: boolean;
  48241. LOGARITHMICDEPTH: boolean;
  48242. FORCENORMALFORWARD: boolean;
  48243. SPECULARAA: boolean;
  48244. CLEARCOAT: boolean;
  48245. CLEARCOAT_DEFAULTIOR: boolean;
  48246. CLEARCOAT_TEXTURE: boolean;
  48247. CLEARCOAT_TEXTUREDIRECTUV: number;
  48248. CLEARCOAT_BUMP: boolean;
  48249. CLEARCOAT_BUMPDIRECTUV: number;
  48250. CLEARCOAT_TINT: boolean;
  48251. CLEARCOAT_TINT_TEXTURE: boolean;
  48252. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48253. ANISOTROPIC: boolean;
  48254. ANISOTROPIC_TEXTURE: boolean;
  48255. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48256. BRDF_V_HEIGHT_CORRELATED: boolean;
  48257. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48258. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48259. SHEEN: boolean;
  48260. SHEEN_TEXTURE: boolean;
  48261. SHEEN_TEXTUREDIRECTUV: number;
  48262. SHEEN_LINKWITHALBEDO: boolean;
  48263. SUBSURFACE: boolean;
  48264. SS_REFRACTION: boolean;
  48265. SS_TRANSLUCENCY: boolean;
  48266. SS_SCATERRING: boolean;
  48267. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48268. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48269. SS_REFRACTIONMAP_3D: boolean;
  48270. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48271. SS_LODINREFRACTIONALPHA: boolean;
  48272. SS_GAMMAREFRACTION: boolean;
  48273. SS_RGBDREFRACTION: boolean;
  48274. SS_LINEARSPECULARREFRACTION: boolean;
  48275. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48276. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48277. UNLIT: boolean;
  48278. DEBUGMODE: number;
  48279. /**
  48280. * Initializes the PBR Material defines.
  48281. */
  48282. constructor();
  48283. /**
  48284. * Resets the PBR Material defines.
  48285. */
  48286. reset(): void;
  48287. }
  48288. /**
  48289. * The Physically based material base class of BJS.
  48290. *
  48291. * This offers the main features of a standard PBR material.
  48292. * For more information, please refer to the documentation :
  48293. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48294. */
  48295. export abstract class PBRBaseMaterial extends PushMaterial {
  48296. /**
  48297. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48298. */
  48299. static readonly PBRMATERIAL_OPAQUE: number;
  48300. /**
  48301. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48302. */
  48303. static readonly PBRMATERIAL_ALPHATEST: number;
  48304. /**
  48305. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48306. */
  48307. static readonly PBRMATERIAL_ALPHABLEND: number;
  48308. /**
  48309. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48310. * They are also discarded below the alpha cutoff threshold to improve performances.
  48311. */
  48312. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48313. /**
  48314. * Defines the default value of how much AO map is occluding the analytical lights
  48315. * (point spot...).
  48316. */
  48317. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48318. /**
  48319. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48320. */
  48321. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48322. /**
  48323. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48324. * to enhance interoperability with other engines.
  48325. */
  48326. static readonly LIGHTFALLOFF_GLTF: number;
  48327. /**
  48328. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48329. * to enhance interoperability with other materials.
  48330. */
  48331. static readonly LIGHTFALLOFF_STANDARD: number;
  48332. /**
  48333. * Intensity of the direct lights e.g. the four lights available in your scene.
  48334. * This impacts both the direct diffuse and specular highlights.
  48335. */
  48336. protected _directIntensity: number;
  48337. /**
  48338. * Intensity of the emissive part of the material.
  48339. * This helps controlling the emissive effect without modifying the emissive color.
  48340. */
  48341. protected _emissiveIntensity: number;
  48342. /**
  48343. * Intensity of the environment e.g. how much the environment will light the object
  48344. * either through harmonics for rough material or through the refelction for shiny ones.
  48345. */
  48346. protected _environmentIntensity: number;
  48347. /**
  48348. * This is a special control allowing the reduction of the specular highlights coming from the
  48349. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48350. */
  48351. protected _specularIntensity: number;
  48352. /**
  48353. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48354. */
  48355. private _lightingInfos;
  48356. /**
  48357. * Debug Control allowing disabling the bump map on this material.
  48358. */
  48359. protected _disableBumpMap: boolean;
  48360. /**
  48361. * AKA Diffuse Texture in standard nomenclature.
  48362. */
  48363. protected _albedoTexture: Nullable<BaseTexture>;
  48364. /**
  48365. * AKA Occlusion Texture in other nomenclature.
  48366. */
  48367. protected _ambientTexture: Nullable<BaseTexture>;
  48368. /**
  48369. * AKA Occlusion Texture Intensity in other nomenclature.
  48370. */
  48371. protected _ambientTextureStrength: number;
  48372. /**
  48373. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48374. * 1 means it completely occludes it
  48375. * 0 mean it has no impact
  48376. */
  48377. protected _ambientTextureImpactOnAnalyticalLights: number;
  48378. /**
  48379. * Stores the alpha values in a texture.
  48380. */
  48381. protected _opacityTexture: Nullable<BaseTexture>;
  48382. /**
  48383. * Stores the reflection values in a texture.
  48384. */
  48385. protected _reflectionTexture: Nullable<BaseTexture>;
  48386. /**
  48387. * Stores the emissive values in a texture.
  48388. */
  48389. protected _emissiveTexture: Nullable<BaseTexture>;
  48390. /**
  48391. * AKA Specular texture in other nomenclature.
  48392. */
  48393. protected _reflectivityTexture: Nullable<BaseTexture>;
  48394. /**
  48395. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48396. */
  48397. protected _metallicTexture: Nullable<BaseTexture>;
  48398. /**
  48399. * Specifies the metallic scalar of the metallic/roughness workflow.
  48400. * Can also be used to scale the metalness values of the metallic texture.
  48401. */
  48402. protected _metallic: Nullable<number>;
  48403. /**
  48404. * Specifies the roughness scalar of the metallic/roughness workflow.
  48405. * Can also be used to scale the roughness values of the metallic texture.
  48406. */
  48407. protected _roughness: Nullable<number>;
  48408. /**
  48409. * Specifies the an F0 factor to help configuring the material F0.
  48410. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48411. * to 0.5 the previously hard coded value stays the same.
  48412. * Can also be used to scale the F0 values of the metallic texture.
  48413. */
  48414. protected _metallicF0Factor: number;
  48415. /**
  48416. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48417. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48418. * your expectation as it multiplies with the texture data.
  48419. */
  48420. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48421. /**
  48422. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48423. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48424. */
  48425. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48426. /**
  48427. * Stores surface normal data used to displace a mesh in a texture.
  48428. */
  48429. protected _bumpTexture: Nullable<BaseTexture>;
  48430. /**
  48431. * Stores the pre-calculated light information of a mesh in a texture.
  48432. */
  48433. protected _lightmapTexture: Nullable<BaseTexture>;
  48434. /**
  48435. * The color of a material in ambient lighting.
  48436. */
  48437. protected _ambientColor: Color3;
  48438. /**
  48439. * AKA Diffuse Color in other nomenclature.
  48440. */
  48441. protected _albedoColor: Color3;
  48442. /**
  48443. * AKA Specular Color in other nomenclature.
  48444. */
  48445. protected _reflectivityColor: Color3;
  48446. /**
  48447. * The color applied when light is reflected from a material.
  48448. */
  48449. protected _reflectionColor: Color3;
  48450. /**
  48451. * The color applied when light is emitted from a material.
  48452. */
  48453. protected _emissiveColor: Color3;
  48454. /**
  48455. * AKA Glossiness in other nomenclature.
  48456. */
  48457. protected _microSurface: number;
  48458. /**
  48459. * Specifies that the material will use the light map as a show map.
  48460. */
  48461. protected _useLightmapAsShadowmap: boolean;
  48462. /**
  48463. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48464. * makes the reflect vector face the model (under horizon).
  48465. */
  48466. protected _useHorizonOcclusion: boolean;
  48467. /**
  48468. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48469. * too much the area relying on ambient texture to define their ambient occlusion.
  48470. */
  48471. protected _useRadianceOcclusion: boolean;
  48472. /**
  48473. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48474. */
  48475. protected _useAlphaFromAlbedoTexture: boolean;
  48476. /**
  48477. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48478. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48479. */
  48480. protected _useSpecularOverAlpha: boolean;
  48481. /**
  48482. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48483. */
  48484. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48485. /**
  48486. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48487. */
  48488. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48489. /**
  48490. * Specifies if the metallic texture contains the roughness information in its green channel.
  48491. */
  48492. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48493. /**
  48494. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48495. */
  48496. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48497. /**
  48498. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48499. */
  48500. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48501. /**
  48502. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48503. */
  48504. protected _useAmbientInGrayScale: boolean;
  48505. /**
  48506. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48507. * The material will try to infer what glossiness each pixel should be.
  48508. */
  48509. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48510. /**
  48511. * Defines the falloff type used in this material.
  48512. * It by default is Physical.
  48513. */
  48514. protected _lightFalloff: number;
  48515. /**
  48516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48518. */
  48519. protected _useRadianceOverAlpha: boolean;
  48520. /**
  48521. * Allows using an object space normal map (instead of tangent space).
  48522. */
  48523. protected _useObjectSpaceNormalMap: boolean;
  48524. /**
  48525. * Allows using the bump map in parallax mode.
  48526. */
  48527. protected _useParallax: boolean;
  48528. /**
  48529. * Allows using the bump map in parallax occlusion mode.
  48530. */
  48531. protected _useParallaxOcclusion: boolean;
  48532. /**
  48533. * Controls the scale bias of the parallax mode.
  48534. */
  48535. protected _parallaxScaleBias: number;
  48536. /**
  48537. * If sets to true, disables all the lights affecting the material.
  48538. */
  48539. protected _disableLighting: boolean;
  48540. /**
  48541. * Number of Simultaneous lights allowed on the material.
  48542. */
  48543. protected _maxSimultaneousLights: number;
  48544. /**
  48545. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48546. */
  48547. protected _invertNormalMapX: boolean;
  48548. /**
  48549. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48550. */
  48551. protected _invertNormalMapY: boolean;
  48552. /**
  48553. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48554. */
  48555. protected _twoSidedLighting: boolean;
  48556. /**
  48557. * Defines the alpha limits in alpha test mode.
  48558. */
  48559. protected _alphaCutOff: number;
  48560. /**
  48561. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48562. */
  48563. protected _forceAlphaTest: boolean;
  48564. /**
  48565. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48566. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48567. */
  48568. protected _useAlphaFresnel: boolean;
  48569. /**
  48570. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48571. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48572. */
  48573. protected _useLinearAlphaFresnel: boolean;
  48574. /**
  48575. * The transparency mode of the material.
  48576. */
  48577. protected _transparencyMode: Nullable<number>;
  48578. /**
  48579. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48580. * from cos thetav and roughness:
  48581. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48582. */
  48583. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48584. /**
  48585. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48586. */
  48587. protected _forceIrradianceInFragment: boolean;
  48588. /**
  48589. * Force normal to face away from face.
  48590. */
  48591. protected _forceNormalForward: boolean;
  48592. /**
  48593. * Enables specular anti aliasing in the PBR shader.
  48594. * It will both interacts on the Geometry for analytical and IBL lighting.
  48595. * It also prefilter the roughness map based on the bump values.
  48596. */
  48597. protected _enableSpecularAntiAliasing: boolean;
  48598. /**
  48599. * Default configuration related to image processing available in the PBR Material.
  48600. */
  48601. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48602. /**
  48603. * Keep track of the image processing observer to allow dispose and replace.
  48604. */
  48605. private _imageProcessingObserver;
  48606. /**
  48607. * Attaches a new image processing configuration to the PBR Material.
  48608. * @param configuration
  48609. */
  48610. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48611. /**
  48612. * Stores the available render targets.
  48613. */
  48614. private _renderTargets;
  48615. /**
  48616. * Sets the global ambient color for the material used in lighting calculations.
  48617. */
  48618. private _globalAmbientColor;
  48619. /**
  48620. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48621. */
  48622. private _useLogarithmicDepth;
  48623. /**
  48624. * If set to true, no lighting calculations will be applied.
  48625. */
  48626. private _unlit;
  48627. private _debugMode;
  48628. /**
  48629. * @hidden
  48630. * This is reserved for the inspector.
  48631. * Defines the material debug mode.
  48632. * It helps seeing only some components of the material while troubleshooting.
  48633. */
  48634. debugMode: number;
  48635. /**
  48636. * @hidden
  48637. * This is reserved for the inspector.
  48638. * Specify from where on screen the debug mode should start.
  48639. * The value goes from -1 (full screen) to 1 (not visible)
  48640. * It helps with side by side comparison against the final render
  48641. * This defaults to -1
  48642. */
  48643. private debugLimit;
  48644. /**
  48645. * @hidden
  48646. * This is reserved for the inspector.
  48647. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48648. * You can use the factor to better multiply the final value.
  48649. */
  48650. private debugFactor;
  48651. /**
  48652. * Defines the clear coat layer parameters for the material.
  48653. */
  48654. readonly clearCoat: PBRClearCoatConfiguration;
  48655. /**
  48656. * Defines the anisotropic parameters for the material.
  48657. */
  48658. readonly anisotropy: PBRAnisotropicConfiguration;
  48659. /**
  48660. * Defines the BRDF parameters for the material.
  48661. */
  48662. readonly brdf: PBRBRDFConfiguration;
  48663. /**
  48664. * Defines the Sheen parameters for the material.
  48665. */
  48666. readonly sheen: PBRSheenConfiguration;
  48667. /**
  48668. * Defines the SubSurface parameters for the material.
  48669. */
  48670. readonly subSurface: PBRSubSurfaceConfiguration;
  48671. /**
  48672. * Custom callback helping to override the default shader used in the material.
  48673. */
  48674. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48675. protected _rebuildInParallel: boolean;
  48676. /**
  48677. * Instantiates a new PBRMaterial instance.
  48678. *
  48679. * @param name The material name
  48680. * @param scene The scene the material will be use in.
  48681. */
  48682. constructor(name: string, scene: Scene);
  48683. /**
  48684. * Gets a boolean indicating that current material needs to register RTT
  48685. */
  48686. readonly hasRenderTargetTextures: boolean;
  48687. /**
  48688. * Gets the name of the material class.
  48689. */
  48690. getClassName(): string;
  48691. /**
  48692. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48693. */
  48694. /**
  48695. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48696. */
  48697. useLogarithmicDepth: boolean;
  48698. /**
  48699. * Gets the current transparency mode.
  48700. */
  48701. /**
  48702. * Sets the transparency mode of the material.
  48703. *
  48704. * | Value | Type | Description |
  48705. * | ----- | ----------------------------------- | ----------- |
  48706. * | 0 | OPAQUE | |
  48707. * | 1 | ALPHATEST | |
  48708. * | 2 | ALPHABLEND | |
  48709. * | 3 | ALPHATESTANDBLEND | |
  48710. *
  48711. */
  48712. transparencyMode: Nullable<number>;
  48713. /**
  48714. * Returns true if alpha blending should be disabled.
  48715. */
  48716. private readonly _disableAlphaBlending;
  48717. /**
  48718. * Specifies whether or not this material should be rendered in alpha blend mode.
  48719. */
  48720. needAlphaBlending(): boolean;
  48721. /**
  48722. * Specifies if the mesh will require alpha blending.
  48723. * @param mesh - BJS mesh.
  48724. */
  48725. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48726. /**
  48727. * Specifies whether or not this material should be rendered in alpha test mode.
  48728. */
  48729. needAlphaTesting(): boolean;
  48730. /**
  48731. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48732. */
  48733. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48734. /**
  48735. * Gets the texture used for the alpha test.
  48736. */
  48737. getAlphaTestTexture(): Nullable<BaseTexture>;
  48738. /**
  48739. * Specifies that the submesh is ready to be used.
  48740. * @param mesh - BJS mesh.
  48741. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48742. * @param useInstances - Specifies that instances should be used.
  48743. * @returns - boolean indicating that the submesh is ready or not.
  48744. */
  48745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48746. /**
  48747. * Specifies if the material uses metallic roughness workflow.
  48748. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48749. */
  48750. isMetallicWorkflow(): boolean;
  48751. private _prepareEffect;
  48752. private _prepareDefines;
  48753. /**
  48754. * Force shader compilation
  48755. */
  48756. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48757. /**
  48758. * Initializes the uniform buffer layout for the shader.
  48759. */
  48760. buildUniformLayout(): void;
  48761. /**
  48762. * Unbinds the material from the mesh
  48763. */
  48764. unbind(): void;
  48765. /**
  48766. * Binds the submesh data.
  48767. * @param world - The world matrix.
  48768. * @param mesh - The BJS mesh.
  48769. * @param subMesh - A submesh of the BJS mesh.
  48770. */
  48771. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48772. /**
  48773. * Returns the animatable textures.
  48774. * @returns - Array of animatable textures.
  48775. */
  48776. getAnimatables(): IAnimatable[];
  48777. /**
  48778. * Returns the texture used for reflections.
  48779. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48780. */
  48781. private _getReflectionTexture;
  48782. /**
  48783. * Returns an array of the actively used textures.
  48784. * @returns - Array of BaseTextures
  48785. */
  48786. getActiveTextures(): BaseTexture[];
  48787. /**
  48788. * Checks to see if a texture is used in the material.
  48789. * @param texture - Base texture to use.
  48790. * @returns - Boolean specifying if a texture is used in the material.
  48791. */
  48792. hasTexture(texture: BaseTexture): boolean;
  48793. /**
  48794. * Disposes the resources of the material.
  48795. * @param forceDisposeEffect - Forces the disposal of effects.
  48796. * @param forceDisposeTextures - Forces the disposal of all textures.
  48797. */
  48798. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48799. }
  48800. }
  48801. declare module BABYLON {
  48802. /**
  48803. * The Physically based material of BJS.
  48804. *
  48805. * This offers the main features of a standard PBR material.
  48806. * For more information, please refer to the documentation :
  48807. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48808. */
  48809. export class PBRMaterial extends PBRBaseMaterial {
  48810. /**
  48811. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48812. */
  48813. static readonly PBRMATERIAL_OPAQUE: number;
  48814. /**
  48815. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48816. */
  48817. static readonly PBRMATERIAL_ALPHATEST: number;
  48818. /**
  48819. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48820. */
  48821. static readonly PBRMATERIAL_ALPHABLEND: number;
  48822. /**
  48823. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48824. * They are also discarded below the alpha cutoff threshold to improve performances.
  48825. */
  48826. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48827. /**
  48828. * Defines the default value of how much AO map is occluding the analytical lights
  48829. * (point spot...).
  48830. */
  48831. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48832. /**
  48833. * Intensity of the direct lights e.g. the four lights available in your scene.
  48834. * This impacts both the direct diffuse and specular highlights.
  48835. */
  48836. directIntensity: number;
  48837. /**
  48838. * Intensity of the emissive part of the material.
  48839. * This helps controlling the emissive effect without modifying the emissive color.
  48840. */
  48841. emissiveIntensity: number;
  48842. /**
  48843. * Intensity of the environment e.g. how much the environment will light the object
  48844. * either through harmonics for rough material or through the refelction for shiny ones.
  48845. */
  48846. environmentIntensity: number;
  48847. /**
  48848. * This is a special control allowing the reduction of the specular highlights coming from the
  48849. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48850. */
  48851. specularIntensity: number;
  48852. /**
  48853. * Debug Control allowing disabling the bump map on this material.
  48854. */
  48855. disableBumpMap: boolean;
  48856. /**
  48857. * AKA Diffuse Texture in standard nomenclature.
  48858. */
  48859. albedoTexture: BaseTexture;
  48860. /**
  48861. * AKA Occlusion Texture in other nomenclature.
  48862. */
  48863. ambientTexture: BaseTexture;
  48864. /**
  48865. * AKA Occlusion Texture Intensity in other nomenclature.
  48866. */
  48867. ambientTextureStrength: number;
  48868. /**
  48869. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48870. * 1 means it completely occludes it
  48871. * 0 mean it has no impact
  48872. */
  48873. ambientTextureImpactOnAnalyticalLights: number;
  48874. /**
  48875. * Stores the alpha values in a texture.
  48876. */
  48877. opacityTexture: BaseTexture;
  48878. /**
  48879. * Stores the reflection values in a texture.
  48880. */
  48881. reflectionTexture: Nullable<BaseTexture>;
  48882. /**
  48883. * Stores the emissive values in a texture.
  48884. */
  48885. emissiveTexture: BaseTexture;
  48886. /**
  48887. * AKA Specular texture in other nomenclature.
  48888. */
  48889. reflectivityTexture: BaseTexture;
  48890. /**
  48891. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48892. */
  48893. metallicTexture: BaseTexture;
  48894. /**
  48895. * Specifies the metallic scalar of the metallic/roughness workflow.
  48896. * Can also be used to scale the metalness values of the metallic texture.
  48897. */
  48898. metallic: Nullable<number>;
  48899. /**
  48900. * Specifies the roughness scalar of the metallic/roughness workflow.
  48901. * Can also be used to scale the roughness values of the metallic texture.
  48902. */
  48903. roughness: Nullable<number>;
  48904. /**
  48905. * Specifies the an F0 factor to help configuring the material F0.
  48906. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48907. * to 0.5 the previously hard coded value stays the same.
  48908. * Can also be used to scale the F0 values of the metallic texture.
  48909. */
  48910. metallicF0Factor: number;
  48911. /**
  48912. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48913. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48914. * your expectation as it multiplies with the texture data.
  48915. */
  48916. useMetallicF0FactorFromMetallicTexture: boolean;
  48917. /**
  48918. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48919. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48920. */
  48921. microSurfaceTexture: BaseTexture;
  48922. /**
  48923. * Stores surface normal data used to displace a mesh in a texture.
  48924. */
  48925. bumpTexture: BaseTexture;
  48926. /**
  48927. * Stores the pre-calculated light information of a mesh in a texture.
  48928. */
  48929. lightmapTexture: BaseTexture;
  48930. /**
  48931. * Stores the refracted light information in a texture.
  48932. */
  48933. refractionTexture: Nullable<BaseTexture>;
  48934. /**
  48935. * The color of a material in ambient lighting.
  48936. */
  48937. ambientColor: Color3;
  48938. /**
  48939. * AKA Diffuse Color in other nomenclature.
  48940. */
  48941. albedoColor: Color3;
  48942. /**
  48943. * AKA Specular Color in other nomenclature.
  48944. */
  48945. reflectivityColor: Color3;
  48946. /**
  48947. * The color reflected from the material.
  48948. */
  48949. reflectionColor: Color3;
  48950. /**
  48951. * The color emitted from the material.
  48952. */
  48953. emissiveColor: Color3;
  48954. /**
  48955. * AKA Glossiness in other nomenclature.
  48956. */
  48957. microSurface: number;
  48958. /**
  48959. * source material index of refraction (IOR)' / 'destination material IOR.
  48960. */
  48961. indexOfRefraction: number;
  48962. /**
  48963. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48964. */
  48965. invertRefractionY: boolean;
  48966. /**
  48967. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48968. * Materials half opaque for instance using refraction could benefit from this control.
  48969. */
  48970. linkRefractionWithTransparency: boolean;
  48971. /**
  48972. * If true, the light map contains occlusion information instead of lighting info.
  48973. */
  48974. useLightmapAsShadowmap: boolean;
  48975. /**
  48976. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48977. */
  48978. useAlphaFromAlbedoTexture: boolean;
  48979. /**
  48980. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48981. */
  48982. forceAlphaTest: boolean;
  48983. /**
  48984. * Defines the alpha limits in alpha test mode.
  48985. */
  48986. alphaCutOff: number;
  48987. /**
  48988. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48989. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48990. */
  48991. useSpecularOverAlpha: boolean;
  48992. /**
  48993. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48994. */
  48995. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48996. /**
  48997. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48998. */
  48999. useRoughnessFromMetallicTextureAlpha: boolean;
  49000. /**
  49001. * Specifies if the metallic texture contains the roughness information in its green channel.
  49002. */
  49003. useRoughnessFromMetallicTextureGreen: boolean;
  49004. /**
  49005. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49006. */
  49007. useMetallnessFromMetallicTextureBlue: boolean;
  49008. /**
  49009. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49010. */
  49011. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49012. /**
  49013. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49014. */
  49015. useAmbientInGrayScale: boolean;
  49016. /**
  49017. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49018. * The material will try to infer what glossiness each pixel should be.
  49019. */
  49020. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49021. /**
  49022. * BJS is using an harcoded light falloff based on a manually sets up range.
  49023. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49024. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49025. */
  49026. /**
  49027. * BJS is using an harcoded light falloff based on a manually sets up range.
  49028. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49029. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49030. */
  49031. usePhysicalLightFalloff: boolean;
  49032. /**
  49033. * In order to support the falloff compatibility with gltf, a special mode has been added
  49034. * to reproduce the gltf light falloff.
  49035. */
  49036. /**
  49037. * In order to support the falloff compatibility with gltf, a special mode has been added
  49038. * to reproduce the gltf light falloff.
  49039. */
  49040. useGLTFLightFalloff: boolean;
  49041. /**
  49042. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49043. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49044. */
  49045. useRadianceOverAlpha: boolean;
  49046. /**
  49047. * Allows using an object space normal map (instead of tangent space).
  49048. */
  49049. useObjectSpaceNormalMap: boolean;
  49050. /**
  49051. * Allows using the bump map in parallax mode.
  49052. */
  49053. useParallax: boolean;
  49054. /**
  49055. * Allows using the bump map in parallax occlusion mode.
  49056. */
  49057. useParallaxOcclusion: boolean;
  49058. /**
  49059. * Controls the scale bias of the parallax mode.
  49060. */
  49061. parallaxScaleBias: number;
  49062. /**
  49063. * If sets to true, disables all the lights affecting the material.
  49064. */
  49065. disableLighting: boolean;
  49066. /**
  49067. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49068. */
  49069. forceIrradianceInFragment: boolean;
  49070. /**
  49071. * Number of Simultaneous lights allowed on the material.
  49072. */
  49073. maxSimultaneousLights: number;
  49074. /**
  49075. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49076. */
  49077. invertNormalMapX: boolean;
  49078. /**
  49079. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49080. */
  49081. invertNormalMapY: boolean;
  49082. /**
  49083. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49084. */
  49085. twoSidedLighting: boolean;
  49086. /**
  49087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49088. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49089. */
  49090. useAlphaFresnel: boolean;
  49091. /**
  49092. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49093. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49094. */
  49095. useLinearAlphaFresnel: boolean;
  49096. /**
  49097. * Let user defines the brdf lookup texture used for IBL.
  49098. * A default 8bit version is embedded but you could point at :
  49099. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49100. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49101. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49102. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49103. */
  49104. environmentBRDFTexture: Nullable<BaseTexture>;
  49105. /**
  49106. * Force normal to face away from face.
  49107. */
  49108. forceNormalForward: boolean;
  49109. /**
  49110. * Enables specular anti aliasing in the PBR shader.
  49111. * It will both interacts on the Geometry for analytical and IBL lighting.
  49112. * It also prefilter the roughness map based on the bump values.
  49113. */
  49114. enableSpecularAntiAliasing: boolean;
  49115. /**
  49116. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49117. * makes the reflect vector face the model (under horizon).
  49118. */
  49119. useHorizonOcclusion: boolean;
  49120. /**
  49121. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49122. * too much the area relying on ambient texture to define their ambient occlusion.
  49123. */
  49124. useRadianceOcclusion: boolean;
  49125. /**
  49126. * If set to true, no lighting calculations will be applied.
  49127. */
  49128. unlit: boolean;
  49129. /**
  49130. * Gets the image processing configuration used either in this material.
  49131. */
  49132. /**
  49133. * Sets the Default image processing configuration used either in the this material.
  49134. *
  49135. * If sets to null, the scene one is in use.
  49136. */
  49137. imageProcessingConfiguration: ImageProcessingConfiguration;
  49138. /**
  49139. * Gets wether the color curves effect is enabled.
  49140. */
  49141. /**
  49142. * Sets wether the color curves effect is enabled.
  49143. */
  49144. cameraColorCurvesEnabled: boolean;
  49145. /**
  49146. * Gets wether the color grading effect is enabled.
  49147. */
  49148. /**
  49149. * Gets wether the color grading effect is enabled.
  49150. */
  49151. cameraColorGradingEnabled: boolean;
  49152. /**
  49153. * Gets wether tonemapping is enabled or not.
  49154. */
  49155. /**
  49156. * Sets wether tonemapping is enabled or not
  49157. */
  49158. cameraToneMappingEnabled: boolean;
  49159. /**
  49160. * The camera exposure used on this material.
  49161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49162. * This corresponds to a photographic exposure.
  49163. */
  49164. /**
  49165. * The camera exposure used on this material.
  49166. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49167. * This corresponds to a photographic exposure.
  49168. */
  49169. cameraExposure: number;
  49170. /**
  49171. * Gets The camera contrast used on this material.
  49172. */
  49173. /**
  49174. * Sets The camera contrast used on this material.
  49175. */
  49176. cameraContrast: number;
  49177. /**
  49178. * Gets the Color Grading 2D Lookup Texture.
  49179. */
  49180. /**
  49181. * Sets the Color Grading 2D Lookup Texture.
  49182. */
  49183. cameraColorGradingTexture: Nullable<BaseTexture>;
  49184. /**
  49185. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49186. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49187. * 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;
  49188. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49189. */
  49190. /**
  49191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49193. * 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;
  49194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49195. */
  49196. cameraColorCurves: Nullable<ColorCurves>;
  49197. /**
  49198. * Instantiates a new PBRMaterial instance.
  49199. *
  49200. * @param name The material name
  49201. * @param scene The scene the material will be use in.
  49202. */
  49203. constructor(name: string, scene: Scene);
  49204. /**
  49205. * Returns the name of this material class.
  49206. */
  49207. getClassName(): string;
  49208. /**
  49209. * Makes a duplicate of the current material.
  49210. * @param name - name to use for the new material.
  49211. */
  49212. clone(name: string): PBRMaterial;
  49213. /**
  49214. * Serializes this PBR Material.
  49215. * @returns - An object with the serialized material.
  49216. */
  49217. serialize(): any;
  49218. /**
  49219. * Parses a PBR Material from a serialized object.
  49220. * @param source - Serialized object.
  49221. * @param scene - BJS scene instance.
  49222. * @param rootUrl - url for the scene object
  49223. * @returns - PBRMaterial
  49224. */
  49225. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49226. }
  49227. }
  49228. declare module BABYLON {
  49229. /**
  49230. * Direct draw surface info
  49231. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49232. */
  49233. export interface DDSInfo {
  49234. /**
  49235. * Width of the texture
  49236. */
  49237. width: number;
  49238. /**
  49239. * Width of the texture
  49240. */
  49241. height: number;
  49242. /**
  49243. * Number of Mipmaps for the texture
  49244. * @see https://en.wikipedia.org/wiki/Mipmap
  49245. */
  49246. mipmapCount: number;
  49247. /**
  49248. * If the textures format is a known fourCC format
  49249. * @see https://www.fourcc.org/
  49250. */
  49251. isFourCC: boolean;
  49252. /**
  49253. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49254. */
  49255. isRGB: boolean;
  49256. /**
  49257. * If the texture is a lumincance format
  49258. */
  49259. isLuminance: boolean;
  49260. /**
  49261. * If this is a cube texture
  49262. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49263. */
  49264. isCube: boolean;
  49265. /**
  49266. * If the texture is a compressed format eg. FOURCC_DXT1
  49267. */
  49268. isCompressed: boolean;
  49269. /**
  49270. * The dxgiFormat of the texture
  49271. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49272. */
  49273. dxgiFormat: number;
  49274. /**
  49275. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49276. */
  49277. textureType: number;
  49278. /**
  49279. * Sphericle polynomial created for the dds texture
  49280. */
  49281. sphericalPolynomial?: SphericalPolynomial;
  49282. }
  49283. /**
  49284. * Class used to provide DDS decompression tools
  49285. */
  49286. export class DDSTools {
  49287. /**
  49288. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49289. */
  49290. static StoreLODInAlphaChannel: boolean;
  49291. /**
  49292. * Gets DDS information from an array buffer
  49293. * @param arrayBuffer defines the array buffer to read data from
  49294. * @returns the DDS information
  49295. */
  49296. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49297. private static _FloatView;
  49298. private static _Int32View;
  49299. private static _ToHalfFloat;
  49300. private static _FromHalfFloat;
  49301. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49302. private static _GetHalfFloatRGBAArrayBuffer;
  49303. private static _GetFloatRGBAArrayBuffer;
  49304. private static _GetFloatAsUIntRGBAArrayBuffer;
  49305. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49306. private static _GetRGBAArrayBuffer;
  49307. private static _ExtractLongWordOrder;
  49308. private static _GetRGBArrayBuffer;
  49309. private static _GetLuminanceArrayBuffer;
  49310. /**
  49311. * Uploads DDS Levels to a Babylon Texture
  49312. * @hidden
  49313. */
  49314. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49315. }
  49316. interface ThinEngine {
  49317. /**
  49318. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49319. * @param rootUrl defines the url where the file to load is located
  49320. * @param scene defines the current scene
  49321. * @param lodScale defines scale to apply to the mip map selection
  49322. * @param lodOffset defines offset to apply to the mip map selection
  49323. * @param onLoad defines an optional callback raised when the texture is loaded
  49324. * @param onError defines an optional callback raised if there is an issue to load the texture
  49325. * @param format defines the format of the data
  49326. * @param forcedExtension defines the extension to use to pick the right loader
  49327. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49328. * @returns the cube texture as an InternalTexture
  49329. */
  49330. 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;
  49331. }
  49332. }
  49333. declare module BABYLON {
  49334. /**
  49335. * Implementation of the DDS Texture Loader.
  49336. * @hidden
  49337. */
  49338. export class _DDSTextureLoader implements IInternalTextureLoader {
  49339. /**
  49340. * Defines wether the loader supports cascade loading the different faces.
  49341. */
  49342. readonly supportCascades: boolean;
  49343. /**
  49344. * This returns if the loader support the current file information.
  49345. * @param extension defines the file extension of the file being loaded
  49346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49347. * @param fallback defines the fallback internal texture if any
  49348. * @param isBase64 defines whether the texture is encoded as a base64
  49349. * @param isBuffer defines whether the texture data are stored as a buffer
  49350. * @returns true if the loader can load the specified file
  49351. */
  49352. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49353. /**
  49354. * Transform the url before loading if required.
  49355. * @param rootUrl the url of the texture
  49356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49357. * @returns the transformed texture
  49358. */
  49359. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49360. /**
  49361. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49362. * @param rootUrl the url of the texture
  49363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49364. * @returns the fallback texture
  49365. */
  49366. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49367. /**
  49368. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49369. * @param data contains the texture data
  49370. * @param texture defines the BabylonJS internal texture
  49371. * @param createPolynomials will be true if polynomials have been requested
  49372. * @param onLoad defines the callback to trigger once the texture is ready
  49373. * @param onError defines the callback to trigger in case of error
  49374. */
  49375. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49376. /**
  49377. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49378. * @param data contains the texture data
  49379. * @param texture defines the BabylonJS internal texture
  49380. * @param callback defines the method to call once ready to upload
  49381. */
  49382. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49383. }
  49384. }
  49385. declare module BABYLON {
  49386. /**
  49387. * Implementation of the ENV Texture Loader.
  49388. * @hidden
  49389. */
  49390. export class _ENVTextureLoader implements IInternalTextureLoader {
  49391. /**
  49392. * Defines wether the loader supports cascade loading the different faces.
  49393. */
  49394. readonly supportCascades: boolean;
  49395. /**
  49396. * This returns if the loader support the current file information.
  49397. * @param extension defines the file extension of the file being loaded
  49398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49399. * @param fallback defines the fallback internal texture if any
  49400. * @param isBase64 defines whether the texture is encoded as a base64
  49401. * @param isBuffer defines whether the texture data are stored as a buffer
  49402. * @returns true if the loader can load the specified file
  49403. */
  49404. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49405. /**
  49406. * Transform the url before loading if required.
  49407. * @param rootUrl the url of the texture
  49408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49409. * @returns the transformed texture
  49410. */
  49411. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49412. /**
  49413. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49414. * @param rootUrl the url of the texture
  49415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49416. * @returns the fallback texture
  49417. */
  49418. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49419. /**
  49420. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49421. * @param data contains the texture data
  49422. * @param texture defines the BabylonJS internal texture
  49423. * @param createPolynomials will be true if polynomials have been requested
  49424. * @param onLoad defines the callback to trigger once the texture is ready
  49425. * @param onError defines the callback to trigger in case of error
  49426. */
  49427. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49428. /**
  49429. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49430. * @param data contains the texture data
  49431. * @param texture defines the BabylonJS internal texture
  49432. * @param callback defines the method to call once ready to upload
  49433. */
  49434. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49435. }
  49436. }
  49437. declare module BABYLON {
  49438. /**
  49439. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49440. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49441. */
  49442. export class KhronosTextureContainer {
  49443. /** contents of the KTX container file */
  49444. arrayBuffer: any;
  49445. private static HEADER_LEN;
  49446. private static COMPRESSED_2D;
  49447. private static COMPRESSED_3D;
  49448. private static TEX_2D;
  49449. private static TEX_3D;
  49450. /**
  49451. * Gets the openGL type
  49452. */
  49453. glType: number;
  49454. /**
  49455. * Gets the openGL type size
  49456. */
  49457. glTypeSize: number;
  49458. /**
  49459. * Gets the openGL format
  49460. */
  49461. glFormat: number;
  49462. /**
  49463. * Gets the openGL internal format
  49464. */
  49465. glInternalFormat: number;
  49466. /**
  49467. * Gets the base internal format
  49468. */
  49469. glBaseInternalFormat: number;
  49470. /**
  49471. * Gets image width in pixel
  49472. */
  49473. pixelWidth: number;
  49474. /**
  49475. * Gets image height in pixel
  49476. */
  49477. pixelHeight: number;
  49478. /**
  49479. * Gets image depth in pixels
  49480. */
  49481. pixelDepth: number;
  49482. /**
  49483. * Gets the number of array elements
  49484. */
  49485. numberOfArrayElements: number;
  49486. /**
  49487. * Gets the number of faces
  49488. */
  49489. numberOfFaces: number;
  49490. /**
  49491. * Gets the number of mipmap levels
  49492. */
  49493. numberOfMipmapLevels: number;
  49494. /**
  49495. * Gets the bytes of key value data
  49496. */
  49497. bytesOfKeyValueData: number;
  49498. /**
  49499. * Gets the load type
  49500. */
  49501. loadType: number;
  49502. /**
  49503. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49504. */
  49505. isInvalid: boolean;
  49506. /**
  49507. * Creates a new KhronosTextureContainer
  49508. * @param arrayBuffer contents of the KTX container file
  49509. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49510. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49511. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49512. */
  49513. constructor(
  49514. /** contents of the KTX container file */
  49515. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49516. /**
  49517. * Uploads KTX content to a Babylon Texture.
  49518. * It is assumed that the texture has already been created & is currently bound
  49519. * @hidden
  49520. */
  49521. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49522. private _upload2DCompressedLevels;
  49523. }
  49524. }
  49525. declare module BABYLON {
  49526. /**
  49527. * Implementation of the KTX Texture Loader.
  49528. * @hidden
  49529. */
  49530. export class _KTXTextureLoader implements IInternalTextureLoader {
  49531. /**
  49532. * Defines wether the loader supports cascade loading the different faces.
  49533. */
  49534. readonly supportCascades: boolean;
  49535. /**
  49536. * This returns if the loader support the current file information.
  49537. * @param extension defines the file extension of the file being loaded
  49538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49539. * @param fallback defines the fallback internal texture if any
  49540. * @param isBase64 defines whether the texture is encoded as a base64
  49541. * @param isBuffer defines whether the texture data are stored as a buffer
  49542. * @returns true if the loader can load the specified file
  49543. */
  49544. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49545. /**
  49546. * Transform the url before loading if required.
  49547. * @param rootUrl the url of the texture
  49548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49549. * @returns the transformed texture
  49550. */
  49551. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49552. /**
  49553. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49554. * @param rootUrl the url of the texture
  49555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49556. * @returns the fallback texture
  49557. */
  49558. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49559. /**
  49560. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49561. * @param data contains the texture data
  49562. * @param texture defines the BabylonJS internal texture
  49563. * @param createPolynomials will be true if polynomials have been requested
  49564. * @param onLoad defines the callback to trigger once the texture is ready
  49565. * @param onError defines the callback to trigger in case of error
  49566. */
  49567. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49568. /**
  49569. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49570. * @param data contains the texture data
  49571. * @param texture defines the BabylonJS internal texture
  49572. * @param callback defines the method to call once ready to upload
  49573. */
  49574. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49575. }
  49576. }
  49577. declare module BABYLON {
  49578. /** @hidden */
  49579. export var _forceSceneHelpersToBundle: boolean;
  49580. interface Scene {
  49581. /**
  49582. * Creates a default light for the scene.
  49583. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49584. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49585. */
  49586. createDefaultLight(replace?: boolean): void;
  49587. /**
  49588. * Creates a default camera for the scene.
  49589. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49590. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49591. * @param replace has default false, when true replaces the active camera in the scene
  49592. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49593. */
  49594. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49595. /**
  49596. * Creates a default camera and a default light.
  49597. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49598. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49599. * @param replace has the default false, when true replaces the active camera/light in the scene
  49600. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49601. */
  49602. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49603. /**
  49604. * Creates a new sky box
  49605. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49606. * @param environmentTexture defines the texture to use as environment texture
  49607. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49608. * @param scale defines the overall scale of the skybox
  49609. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49610. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49611. * @returns a new mesh holding the sky box
  49612. */
  49613. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49614. /**
  49615. * Creates a new environment
  49616. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49617. * @param options defines the options you can use to configure the environment
  49618. * @returns the new EnvironmentHelper
  49619. */
  49620. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49621. /**
  49622. * Creates a new VREXperienceHelper
  49623. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49624. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49625. * @returns a new VREXperienceHelper
  49626. */
  49627. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49628. /**
  49629. * Creates a new WebXRDefaultExperience
  49630. * @see http://doc.babylonjs.com/how_to/webxr
  49631. * @param options experience options
  49632. * @returns a promise for a new WebXRDefaultExperience
  49633. */
  49634. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49640. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49641. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49642. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49643. */
  49644. export class VideoDome extends TransformNode {
  49645. /**
  49646. * Define the video source as a Monoscopic panoramic 360 video.
  49647. */
  49648. static readonly MODE_MONOSCOPIC: number;
  49649. /**
  49650. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49651. */
  49652. static readonly MODE_TOPBOTTOM: number;
  49653. /**
  49654. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49655. */
  49656. static readonly MODE_SIDEBYSIDE: number;
  49657. private _halfDome;
  49658. private _useDirectMapping;
  49659. /**
  49660. * The video texture being displayed on the sphere
  49661. */
  49662. protected _videoTexture: VideoTexture;
  49663. /**
  49664. * Gets the video texture being displayed on the sphere
  49665. */
  49666. readonly videoTexture: VideoTexture;
  49667. /**
  49668. * The skybox material
  49669. */
  49670. protected _material: BackgroundMaterial;
  49671. /**
  49672. * The surface used for the skybox
  49673. */
  49674. protected _mesh: Mesh;
  49675. /**
  49676. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49677. */
  49678. private _halfDomeMask;
  49679. /**
  49680. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49681. * Also see the options.resolution property.
  49682. */
  49683. fovMultiplier: number;
  49684. private _videoMode;
  49685. /**
  49686. * Gets or set the current video mode for the video. It can be:
  49687. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49688. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49689. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49690. */
  49691. videoMode: number;
  49692. /**
  49693. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49694. *
  49695. */
  49696. /**
  49697. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49698. */
  49699. halfDome: boolean;
  49700. /**
  49701. * Oberserver used in Stereoscopic VR Mode.
  49702. */
  49703. private _onBeforeCameraRenderObserver;
  49704. /**
  49705. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49706. * @param name Element's name, child elements will append suffixes for their own names.
  49707. * @param urlsOrVideo defines the url(s) or the video element to use
  49708. * @param options An object containing optional or exposed sub element properties
  49709. */
  49710. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49711. resolution?: number;
  49712. clickToPlay?: boolean;
  49713. autoPlay?: boolean;
  49714. loop?: boolean;
  49715. size?: number;
  49716. poster?: string;
  49717. faceForward?: boolean;
  49718. useDirectMapping?: boolean;
  49719. halfDomeMode?: boolean;
  49720. }, scene: Scene);
  49721. private _changeVideoMode;
  49722. /**
  49723. * Releases resources associated with this node.
  49724. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49725. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49726. */
  49727. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49728. }
  49729. }
  49730. declare module BABYLON {
  49731. /**
  49732. * This class can be used to get instrumentation data from a Babylon engine
  49733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49734. */
  49735. export class EngineInstrumentation implements IDisposable {
  49736. /**
  49737. * Define the instrumented engine.
  49738. */
  49739. engine: Engine;
  49740. private _captureGPUFrameTime;
  49741. private _gpuFrameTimeToken;
  49742. private _gpuFrameTime;
  49743. private _captureShaderCompilationTime;
  49744. private _shaderCompilationTime;
  49745. private _onBeginFrameObserver;
  49746. private _onEndFrameObserver;
  49747. private _onBeforeShaderCompilationObserver;
  49748. private _onAfterShaderCompilationObserver;
  49749. /**
  49750. * Gets the perf counter used for GPU frame time
  49751. */
  49752. readonly gpuFrameTimeCounter: PerfCounter;
  49753. /**
  49754. * Gets the GPU frame time capture status
  49755. */
  49756. /**
  49757. * Enable or disable the GPU frame time capture
  49758. */
  49759. captureGPUFrameTime: boolean;
  49760. /**
  49761. * Gets the perf counter used for shader compilation time
  49762. */
  49763. readonly shaderCompilationTimeCounter: PerfCounter;
  49764. /**
  49765. * Gets the shader compilation time capture status
  49766. */
  49767. /**
  49768. * Enable or disable the shader compilation time capture
  49769. */
  49770. captureShaderCompilationTime: boolean;
  49771. /**
  49772. * Instantiates a new engine instrumentation.
  49773. * This class can be used to get instrumentation data from a Babylon engine
  49774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49775. * @param engine Defines the engine to instrument
  49776. */
  49777. constructor(
  49778. /**
  49779. * Define the instrumented engine.
  49780. */
  49781. engine: Engine);
  49782. /**
  49783. * Dispose and release associated resources.
  49784. */
  49785. dispose(): void;
  49786. }
  49787. }
  49788. declare module BABYLON {
  49789. /**
  49790. * This class can be used to get instrumentation data from a Babylon engine
  49791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49792. */
  49793. export class SceneInstrumentation implements IDisposable {
  49794. /**
  49795. * Defines the scene to instrument
  49796. */
  49797. scene: Scene;
  49798. private _captureActiveMeshesEvaluationTime;
  49799. private _activeMeshesEvaluationTime;
  49800. private _captureRenderTargetsRenderTime;
  49801. private _renderTargetsRenderTime;
  49802. private _captureFrameTime;
  49803. private _frameTime;
  49804. private _captureRenderTime;
  49805. private _renderTime;
  49806. private _captureInterFrameTime;
  49807. private _interFrameTime;
  49808. private _captureParticlesRenderTime;
  49809. private _particlesRenderTime;
  49810. private _captureSpritesRenderTime;
  49811. private _spritesRenderTime;
  49812. private _capturePhysicsTime;
  49813. private _physicsTime;
  49814. private _captureAnimationsTime;
  49815. private _animationsTime;
  49816. private _captureCameraRenderTime;
  49817. private _cameraRenderTime;
  49818. private _onBeforeActiveMeshesEvaluationObserver;
  49819. private _onAfterActiveMeshesEvaluationObserver;
  49820. private _onBeforeRenderTargetsRenderObserver;
  49821. private _onAfterRenderTargetsRenderObserver;
  49822. private _onAfterRenderObserver;
  49823. private _onBeforeDrawPhaseObserver;
  49824. private _onAfterDrawPhaseObserver;
  49825. private _onBeforeAnimationsObserver;
  49826. private _onBeforeParticlesRenderingObserver;
  49827. private _onAfterParticlesRenderingObserver;
  49828. private _onBeforeSpritesRenderingObserver;
  49829. private _onAfterSpritesRenderingObserver;
  49830. private _onBeforePhysicsObserver;
  49831. private _onAfterPhysicsObserver;
  49832. private _onAfterAnimationsObserver;
  49833. private _onBeforeCameraRenderObserver;
  49834. private _onAfterCameraRenderObserver;
  49835. /**
  49836. * Gets the perf counter used for active meshes evaluation time
  49837. */
  49838. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49839. /**
  49840. * Gets the active meshes evaluation time capture status
  49841. */
  49842. /**
  49843. * Enable or disable the active meshes evaluation time capture
  49844. */
  49845. captureActiveMeshesEvaluationTime: boolean;
  49846. /**
  49847. * Gets the perf counter used for render targets render time
  49848. */
  49849. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49850. /**
  49851. * Gets the render targets render time capture status
  49852. */
  49853. /**
  49854. * Enable or disable the render targets render time capture
  49855. */
  49856. captureRenderTargetsRenderTime: boolean;
  49857. /**
  49858. * Gets the perf counter used for particles render time
  49859. */
  49860. readonly particlesRenderTimeCounter: PerfCounter;
  49861. /**
  49862. * Gets the particles render time capture status
  49863. */
  49864. /**
  49865. * Enable or disable the particles render time capture
  49866. */
  49867. captureParticlesRenderTime: boolean;
  49868. /**
  49869. * Gets the perf counter used for sprites render time
  49870. */
  49871. readonly spritesRenderTimeCounter: PerfCounter;
  49872. /**
  49873. * Gets the sprites render time capture status
  49874. */
  49875. /**
  49876. * Enable or disable the sprites render time capture
  49877. */
  49878. captureSpritesRenderTime: boolean;
  49879. /**
  49880. * Gets the perf counter used for physics time
  49881. */
  49882. readonly physicsTimeCounter: PerfCounter;
  49883. /**
  49884. * Gets the physics time capture status
  49885. */
  49886. /**
  49887. * Enable or disable the physics time capture
  49888. */
  49889. capturePhysicsTime: boolean;
  49890. /**
  49891. * Gets the perf counter used for animations time
  49892. */
  49893. readonly animationsTimeCounter: PerfCounter;
  49894. /**
  49895. * Gets the animations time capture status
  49896. */
  49897. /**
  49898. * Enable or disable the animations time capture
  49899. */
  49900. captureAnimationsTime: boolean;
  49901. /**
  49902. * Gets the perf counter used for frame time capture
  49903. */
  49904. readonly frameTimeCounter: PerfCounter;
  49905. /**
  49906. * Gets the frame time capture status
  49907. */
  49908. /**
  49909. * Enable or disable the frame time capture
  49910. */
  49911. captureFrameTime: boolean;
  49912. /**
  49913. * Gets the perf counter used for inter-frames time capture
  49914. */
  49915. readonly interFrameTimeCounter: PerfCounter;
  49916. /**
  49917. * Gets the inter-frames time capture status
  49918. */
  49919. /**
  49920. * Enable or disable the inter-frames time capture
  49921. */
  49922. captureInterFrameTime: boolean;
  49923. /**
  49924. * Gets the perf counter used for render time capture
  49925. */
  49926. readonly renderTimeCounter: PerfCounter;
  49927. /**
  49928. * Gets the render time capture status
  49929. */
  49930. /**
  49931. * Enable or disable the render time capture
  49932. */
  49933. captureRenderTime: boolean;
  49934. /**
  49935. * Gets the perf counter used for camera render time capture
  49936. */
  49937. readonly cameraRenderTimeCounter: PerfCounter;
  49938. /**
  49939. * Gets the camera render time capture status
  49940. */
  49941. /**
  49942. * Enable or disable the camera render time capture
  49943. */
  49944. captureCameraRenderTime: boolean;
  49945. /**
  49946. * Gets the perf counter used for draw calls
  49947. */
  49948. readonly drawCallsCounter: PerfCounter;
  49949. /**
  49950. * Instantiates a new scene instrumentation.
  49951. * This class can be used to get instrumentation data from a Babylon engine
  49952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49953. * @param scene Defines the scene to instrument
  49954. */
  49955. constructor(
  49956. /**
  49957. * Defines the scene to instrument
  49958. */
  49959. scene: Scene);
  49960. /**
  49961. * Dispose and release associated resources.
  49962. */
  49963. dispose(): void;
  49964. }
  49965. }
  49966. declare module BABYLON {
  49967. /** @hidden */
  49968. export var glowMapGenerationPixelShader: {
  49969. name: string;
  49970. shader: string;
  49971. };
  49972. }
  49973. declare module BABYLON {
  49974. /** @hidden */
  49975. export var glowMapGenerationVertexShader: {
  49976. name: string;
  49977. shader: string;
  49978. };
  49979. }
  49980. declare module BABYLON {
  49981. /**
  49982. * Effect layer options. This helps customizing the behaviour
  49983. * of the effect layer.
  49984. */
  49985. export interface IEffectLayerOptions {
  49986. /**
  49987. * Multiplication factor apply to the canvas size to compute the render target size
  49988. * used to generated the objects (the smaller the faster).
  49989. */
  49990. mainTextureRatio: number;
  49991. /**
  49992. * Enforces a fixed size texture to ensure effect stability across devices.
  49993. */
  49994. mainTextureFixedSize?: number;
  49995. /**
  49996. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49997. */
  49998. alphaBlendingMode: number;
  49999. /**
  50000. * The camera attached to the layer.
  50001. */
  50002. camera: Nullable<Camera>;
  50003. /**
  50004. * The rendering group to draw the layer in.
  50005. */
  50006. renderingGroupId: number;
  50007. }
  50008. /**
  50009. * The effect layer Helps adding post process effect blended with the main pass.
  50010. *
  50011. * This can be for instance use to generate glow or higlight effects on the scene.
  50012. *
  50013. * The effect layer class can not be used directly and is intented to inherited from to be
  50014. * customized per effects.
  50015. */
  50016. export abstract class EffectLayer {
  50017. private _vertexBuffers;
  50018. private _indexBuffer;
  50019. private _cachedDefines;
  50020. private _effectLayerMapGenerationEffect;
  50021. private _effectLayerOptions;
  50022. private _mergeEffect;
  50023. protected _scene: Scene;
  50024. protected _engine: Engine;
  50025. protected _maxSize: number;
  50026. protected _mainTextureDesiredSize: ISize;
  50027. protected _mainTexture: RenderTargetTexture;
  50028. protected _shouldRender: boolean;
  50029. protected _postProcesses: PostProcess[];
  50030. protected _textures: BaseTexture[];
  50031. protected _emissiveTextureAndColor: {
  50032. texture: Nullable<BaseTexture>;
  50033. color: Color4;
  50034. };
  50035. /**
  50036. * The name of the layer
  50037. */
  50038. name: string;
  50039. /**
  50040. * The clear color of the texture used to generate the glow map.
  50041. */
  50042. neutralColor: Color4;
  50043. /**
  50044. * Specifies wether the highlight layer is enabled or not.
  50045. */
  50046. isEnabled: boolean;
  50047. /**
  50048. * Gets the camera attached to the layer.
  50049. */
  50050. readonly camera: Nullable<Camera>;
  50051. /**
  50052. * Gets the rendering group id the layer should render in.
  50053. */
  50054. renderingGroupId: number;
  50055. /**
  50056. * An event triggered when the effect layer has been disposed.
  50057. */
  50058. onDisposeObservable: Observable<EffectLayer>;
  50059. /**
  50060. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50061. */
  50062. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50063. /**
  50064. * An event triggered when the generated texture is being merged in the scene.
  50065. */
  50066. onBeforeComposeObservable: Observable<EffectLayer>;
  50067. /**
  50068. * An event triggered when the mesh is rendered into the effect render target.
  50069. */
  50070. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  50071. /**
  50072. * An event triggered after the mesh has been rendered into the effect render target.
  50073. */
  50074. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  50075. /**
  50076. * An event triggered when the generated texture has been merged in the scene.
  50077. */
  50078. onAfterComposeObservable: Observable<EffectLayer>;
  50079. /**
  50080. * An event triggered when the efffect layer changes its size.
  50081. */
  50082. onSizeChangedObservable: Observable<EffectLayer>;
  50083. /** @hidden */
  50084. static _SceneComponentInitialization: (scene: Scene) => void;
  50085. /**
  50086. * Instantiates a new effect Layer and references it in the scene.
  50087. * @param name The name of the layer
  50088. * @param scene The scene to use the layer in
  50089. */
  50090. constructor(
  50091. /** The Friendly of the effect in the scene */
  50092. name: string, scene: Scene);
  50093. /**
  50094. * Get the effect name of the layer.
  50095. * @return The effect name
  50096. */
  50097. abstract getEffectName(): string;
  50098. /**
  50099. * Checks for the readiness of the element composing the layer.
  50100. * @param subMesh the mesh to check for
  50101. * @param useInstances specify wether or not to use instances to render the mesh
  50102. * @return true if ready otherwise, false
  50103. */
  50104. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50105. /**
  50106. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50107. * @returns true if the effect requires stencil during the main canvas render pass.
  50108. */
  50109. abstract needStencil(): boolean;
  50110. /**
  50111. * Create the merge effect. This is the shader use to blit the information back
  50112. * to the main canvas at the end of the scene rendering.
  50113. * @returns The effect containing the shader used to merge the effect on the main canvas
  50114. */
  50115. protected abstract _createMergeEffect(): Effect;
  50116. /**
  50117. * Creates the render target textures and post processes used in the effect layer.
  50118. */
  50119. protected abstract _createTextureAndPostProcesses(): void;
  50120. /**
  50121. * Implementation specific of rendering the generating effect on the main canvas.
  50122. * @param effect The effect used to render through
  50123. */
  50124. protected abstract _internalRender(effect: Effect): void;
  50125. /**
  50126. * Sets the required values for both the emissive texture and and the main color.
  50127. */
  50128. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50129. /**
  50130. * Free any resources and references associated to a mesh.
  50131. * Internal use
  50132. * @param mesh The mesh to free.
  50133. */
  50134. abstract _disposeMesh(mesh: Mesh): void;
  50135. /**
  50136. * Serializes this layer (Glow or Highlight for example)
  50137. * @returns a serialized layer object
  50138. */
  50139. abstract serialize?(): any;
  50140. /**
  50141. * Initializes the effect layer with the required options.
  50142. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50143. */
  50144. protected _init(options: Partial<IEffectLayerOptions>): void;
  50145. /**
  50146. * Generates the index buffer of the full screen quad blending to the main canvas.
  50147. */
  50148. private _generateIndexBuffer;
  50149. /**
  50150. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50151. */
  50152. private _generateVertexBuffer;
  50153. /**
  50154. * Sets the main texture desired size which is the closest power of two
  50155. * of the engine canvas size.
  50156. */
  50157. private _setMainTextureSize;
  50158. /**
  50159. * Creates the main texture for the effect layer.
  50160. */
  50161. protected _createMainTexture(): void;
  50162. /**
  50163. * Adds specific effects defines.
  50164. * @param defines The defines to add specifics to.
  50165. */
  50166. protected _addCustomEffectDefines(defines: string[]): void;
  50167. /**
  50168. * Checks for the readiness of the element composing the layer.
  50169. * @param subMesh the mesh to check for
  50170. * @param useInstances specify wether or not to use instances to render the mesh
  50171. * @param emissiveTexture the associated emissive texture used to generate the glow
  50172. * @return true if ready otherwise, false
  50173. */
  50174. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50175. /**
  50176. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50177. */
  50178. render(): void;
  50179. /**
  50180. * Determine if a given mesh will be used in the current effect.
  50181. * @param mesh mesh to test
  50182. * @returns true if the mesh will be used
  50183. */
  50184. hasMesh(mesh: AbstractMesh): boolean;
  50185. /**
  50186. * Returns true if the layer contains information to display, otherwise false.
  50187. * @returns true if the glow layer should be rendered
  50188. */
  50189. shouldRender(): boolean;
  50190. /**
  50191. * Returns true if the mesh should render, otherwise false.
  50192. * @param mesh The mesh to render
  50193. * @returns true if it should render otherwise false
  50194. */
  50195. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50196. /**
  50197. * Returns true if the mesh can be rendered, otherwise false.
  50198. * @param mesh The mesh to render
  50199. * @param material The material used on the mesh
  50200. * @returns true if it can be rendered otherwise false
  50201. */
  50202. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50203. /**
  50204. * Returns true if the mesh should render, otherwise false.
  50205. * @param mesh The mesh to render
  50206. * @returns true if it should render otherwise false
  50207. */
  50208. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50209. /**
  50210. * Renders the submesh passed in parameter to the generation map.
  50211. */
  50212. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50213. /**
  50214. * Defines wether the current material of the mesh should be use to render the effect.
  50215. * @param mesh defines the current mesh to render
  50216. */
  50217. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50218. /**
  50219. * Rebuild the required buffers.
  50220. * @hidden Internal use only.
  50221. */
  50222. _rebuild(): void;
  50223. /**
  50224. * Dispose only the render target textures and post process.
  50225. */
  50226. private _disposeTextureAndPostProcesses;
  50227. /**
  50228. * Dispose the highlight layer and free resources.
  50229. */
  50230. dispose(): void;
  50231. /**
  50232. * Gets the class name of the effect layer
  50233. * @returns the string with the class name of the effect layer
  50234. */
  50235. getClassName(): string;
  50236. /**
  50237. * Creates an effect layer from parsed effect layer data
  50238. * @param parsedEffectLayer defines effect layer data
  50239. * @param scene defines the current scene
  50240. * @param rootUrl defines the root URL containing the effect layer information
  50241. * @returns a parsed effect Layer
  50242. */
  50243. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50244. }
  50245. }
  50246. declare module BABYLON {
  50247. interface AbstractScene {
  50248. /**
  50249. * The list of effect layers (highlights/glow) added to the scene
  50250. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50251. * @see http://doc.babylonjs.com/how_to/glow_layer
  50252. */
  50253. effectLayers: Array<EffectLayer>;
  50254. /**
  50255. * Removes the given effect layer from this scene.
  50256. * @param toRemove defines the effect layer to remove
  50257. * @returns the index of the removed effect layer
  50258. */
  50259. removeEffectLayer(toRemove: EffectLayer): number;
  50260. /**
  50261. * Adds the given effect layer to this scene
  50262. * @param newEffectLayer defines the effect layer to add
  50263. */
  50264. addEffectLayer(newEffectLayer: EffectLayer): void;
  50265. }
  50266. /**
  50267. * Defines the layer scene component responsible to manage any effect layers
  50268. * in a given scene.
  50269. */
  50270. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50271. /**
  50272. * The component name helpfull to identify the component in the list of scene components.
  50273. */
  50274. readonly name: string;
  50275. /**
  50276. * The scene the component belongs to.
  50277. */
  50278. scene: Scene;
  50279. private _engine;
  50280. private _renderEffects;
  50281. private _needStencil;
  50282. private _previousStencilState;
  50283. /**
  50284. * Creates a new instance of the component for the given scene
  50285. * @param scene Defines the scene to register the component in
  50286. */
  50287. constructor(scene: Scene);
  50288. /**
  50289. * Registers the component in a given scene
  50290. */
  50291. register(): void;
  50292. /**
  50293. * Rebuilds the elements related to this component in case of
  50294. * context lost for instance.
  50295. */
  50296. rebuild(): void;
  50297. /**
  50298. * Serializes the component data to the specified json object
  50299. * @param serializationObject The object to serialize to
  50300. */
  50301. serialize(serializationObject: any): void;
  50302. /**
  50303. * Adds all the elements from the container to the scene
  50304. * @param container the container holding the elements
  50305. */
  50306. addFromContainer(container: AbstractScene): void;
  50307. /**
  50308. * Removes all the elements in the container from the scene
  50309. * @param container contains the elements to remove
  50310. * @param dispose if the removed element should be disposed (default: false)
  50311. */
  50312. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50313. /**
  50314. * Disposes the component and the associated ressources.
  50315. */
  50316. dispose(): void;
  50317. private _isReadyForMesh;
  50318. private _renderMainTexture;
  50319. private _setStencil;
  50320. private _setStencilBack;
  50321. private _draw;
  50322. private _drawCamera;
  50323. private _drawRenderingGroup;
  50324. }
  50325. }
  50326. declare module BABYLON {
  50327. /** @hidden */
  50328. export var glowMapMergePixelShader: {
  50329. name: string;
  50330. shader: string;
  50331. };
  50332. }
  50333. declare module BABYLON {
  50334. /** @hidden */
  50335. export var glowMapMergeVertexShader: {
  50336. name: string;
  50337. shader: string;
  50338. };
  50339. }
  50340. declare module BABYLON {
  50341. interface AbstractScene {
  50342. /**
  50343. * Return a the first highlight layer of the scene with a given name.
  50344. * @param name The name of the highlight layer to look for.
  50345. * @return The highlight layer if found otherwise null.
  50346. */
  50347. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50348. }
  50349. /**
  50350. * Glow layer options. This helps customizing the behaviour
  50351. * of the glow layer.
  50352. */
  50353. export interface IGlowLayerOptions {
  50354. /**
  50355. * Multiplication factor apply to the canvas size to compute the render target size
  50356. * used to generated the glowing objects (the smaller the faster).
  50357. */
  50358. mainTextureRatio: number;
  50359. /**
  50360. * Enforces a fixed size texture to ensure resize independant blur.
  50361. */
  50362. mainTextureFixedSize?: number;
  50363. /**
  50364. * How big is the kernel of the blur texture.
  50365. */
  50366. blurKernelSize: number;
  50367. /**
  50368. * The camera attached to the layer.
  50369. */
  50370. camera: Nullable<Camera>;
  50371. /**
  50372. * Enable MSAA by chosing the number of samples.
  50373. */
  50374. mainTextureSamples?: number;
  50375. /**
  50376. * The rendering group to draw the layer in.
  50377. */
  50378. renderingGroupId: number;
  50379. }
  50380. /**
  50381. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50382. *
  50383. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50384. *
  50385. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50386. */
  50387. export class GlowLayer extends EffectLayer {
  50388. /**
  50389. * Effect Name of the layer.
  50390. */
  50391. static readonly EffectName: string;
  50392. /**
  50393. * The default blur kernel size used for the glow.
  50394. */
  50395. static DefaultBlurKernelSize: number;
  50396. /**
  50397. * The default texture size ratio used for the glow.
  50398. */
  50399. static DefaultTextureRatio: number;
  50400. /**
  50401. * Sets the kernel size of the blur.
  50402. */
  50403. /**
  50404. * Gets the kernel size of the blur.
  50405. */
  50406. blurKernelSize: number;
  50407. /**
  50408. * Sets the glow intensity.
  50409. */
  50410. /**
  50411. * Gets the glow intensity.
  50412. */
  50413. intensity: number;
  50414. private _options;
  50415. private _intensity;
  50416. private _horizontalBlurPostprocess1;
  50417. private _verticalBlurPostprocess1;
  50418. private _horizontalBlurPostprocess2;
  50419. private _verticalBlurPostprocess2;
  50420. private _blurTexture1;
  50421. private _blurTexture2;
  50422. private _postProcesses1;
  50423. private _postProcesses2;
  50424. private _includedOnlyMeshes;
  50425. private _excludedMeshes;
  50426. private _meshesUsingTheirOwnMaterials;
  50427. /**
  50428. * Callback used to let the user override the color selection on a per mesh basis
  50429. */
  50430. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50431. /**
  50432. * Callback used to let the user override the texture selection on a per mesh basis
  50433. */
  50434. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50435. /**
  50436. * Instantiates a new glow Layer and references it to the scene.
  50437. * @param name The name of the layer
  50438. * @param scene The scene to use the layer in
  50439. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50440. */
  50441. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50442. /**
  50443. * Get the effect name of the layer.
  50444. * @return The effect name
  50445. */
  50446. getEffectName(): string;
  50447. /**
  50448. * Create the merge effect. This is the shader use to blit the information back
  50449. * to the main canvas at the end of the scene rendering.
  50450. */
  50451. protected _createMergeEffect(): Effect;
  50452. /**
  50453. * Creates the render target textures and post processes used in the glow layer.
  50454. */
  50455. protected _createTextureAndPostProcesses(): void;
  50456. /**
  50457. * Checks for the readiness of the element composing the layer.
  50458. * @param subMesh the mesh to check for
  50459. * @param useInstances specify wether or not to use instances to render the mesh
  50460. * @param emissiveTexture the associated emissive texture used to generate the glow
  50461. * @return true if ready otherwise, false
  50462. */
  50463. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50464. /**
  50465. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50466. */
  50467. needStencil(): boolean;
  50468. /**
  50469. * Returns true if the mesh can be rendered, otherwise false.
  50470. * @param mesh The mesh to render
  50471. * @param material The material used on the mesh
  50472. * @returns true if it can be rendered otherwise false
  50473. */
  50474. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50475. /**
  50476. * Implementation specific of rendering the generating effect on the main canvas.
  50477. * @param effect The effect used to render through
  50478. */
  50479. protected _internalRender(effect: Effect): void;
  50480. /**
  50481. * Sets the required values for both the emissive texture and and the main color.
  50482. */
  50483. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50484. /**
  50485. * Returns true if the mesh should render, otherwise false.
  50486. * @param mesh The mesh to render
  50487. * @returns true if it should render otherwise false
  50488. */
  50489. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50490. /**
  50491. * Adds specific effects defines.
  50492. * @param defines The defines to add specifics to.
  50493. */
  50494. protected _addCustomEffectDefines(defines: string[]): void;
  50495. /**
  50496. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50497. * @param mesh The mesh to exclude from the glow layer
  50498. */
  50499. addExcludedMesh(mesh: Mesh): void;
  50500. /**
  50501. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50502. * @param mesh The mesh to remove
  50503. */
  50504. removeExcludedMesh(mesh: Mesh): void;
  50505. /**
  50506. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50507. * @param mesh The mesh to include in the glow layer
  50508. */
  50509. addIncludedOnlyMesh(mesh: Mesh): void;
  50510. /**
  50511. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50512. * @param mesh The mesh to remove
  50513. */
  50514. removeIncludedOnlyMesh(mesh: Mesh): void;
  50515. /**
  50516. * Determine if a given mesh will be used in the glow layer
  50517. * @param mesh The mesh to test
  50518. * @returns true if the mesh will be highlighted by the current glow layer
  50519. */
  50520. hasMesh(mesh: AbstractMesh): boolean;
  50521. /**
  50522. * Defines wether the current material of the mesh should be use to render the effect.
  50523. * @param mesh defines the current mesh to render
  50524. */
  50525. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50526. /**
  50527. * Add a mesh to be rendered through its own material and not with emissive only.
  50528. * @param mesh The mesh for which we need to use its material
  50529. */
  50530. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50531. /**
  50532. * Remove a mesh from being rendered through its own material and not with emissive only.
  50533. * @param mesh The mesh for which we need to not use its material
  50534. */
  50535. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50536. /**
  50537. * Free any resources and references associated to a mesh.
  50538. * Internal use
  50539. * @param mesh The mesh to free.
  50540. * @hidden
  50541. */
  50542. _disposeMesh(mesh: Mesh): void;
  50543. /**
  50544. * Gets the class name of the effect layer
  50545. * @returns the string with the class name of the effect layer
  50546. */
  50547. getClassName(): string;
  50548. /**
  50549. * Serializes this glow layer
  50550. * @returns a serialized glow layer object
  50551. */
  50552. serialize(): any;
  50553. /**
  50554. * Creates a Glow Layer from parsed glow layer data
  50555. * @param parsedGlowLayer defines glow layer data
  50556. * @param scene defines the current scene
  50557. * @param rootUrl defines the root URL containing the glow layer information
  50558. * @returns a parsed Glow Layer
  50559. */
  50560. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50561. }
  50562. }
  50563. declare module BABYLON {
  50564. /** @hidden */
  50565. export var glowBlurPostProcessPixelShader: {
  50566. name: string;
  50567. shader: string;
  50568. };
  50569. }
  50570. declare module BABYLON {
  50571. interface AbstractScene {
  50572. /**
  50573. * Return a the first highlight layer of the scene with a given name.
  50574. * @param name The name of the highlight layer to look for.
  50575. * @return The highlight layer if found otherwise null.
  50576. */
  50577. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50578. }
  50579. /**
  50580. * Highlight layer options. This helps customizing the behaviour
  50581. * of the highlight layer.
  50582. */
  50583. export interface IHighlightLayerOptions {
  50584. /**
  50585. * Multiplication factor apply to the canvas size to compute the render target size
  50586. * used to generated the glowing objects (the smaller the faster).
  50587. */
  50588. mainTextureRatio: number;
  50589. /**
  50590. * Enforces a fixed size texture to ensure resize independant blur.
  50591. */
  50592. mainTextureFixedSize?: number;
  50593. /**
  50594. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50595. * of the picture to blur (the smaller the faster).
  50596. */
  50597. blurTextureSizeRatio: number;
  50598. /**
  50599. * How big in texel of the blur texture is the vertical blur.
  50600. */
  50601. blurVerticalSize: number;
  50602. /**
  50603. * How big in texel of the blur texture is the horizontal blur.
  50604. */
  50605. blurHorizontalSize: number;
  50606. /**
  50607. * Alpha blending mode used to apply the blur. Default is combine.
  50608. */
  50609. alphaBlendingMode: number;
  50610. /**
  50611. * The camera attached to the layer.
  50612. */
  50613. camera: Nullable<Camera>;
  50614. /**
  50615. * Should we display highlight as a solid stroke?
  50616. */
  50617. isStroke?: boolean;
  50618. /**
  50619. * The rendering group to draw the layer in.
  50620. */
  50621. renderingGroupId: number;
  50622. }
  50623. /**
  50624. * The highlight layer Helps adding a glow effect around a mesh.
  50625. *
  50626. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50627. * glowy meshes to your scene.
  50628. *
  50629. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50630. */
  50631. export class HighlightLayer extends EffectLayer {
  50632. name: string;
  50633. /**
  50634. * Effect Name of the highlight layer.
  50635. */
  50636. static readonly EffectName: string;
  50637. /**
  50638. * The neutral color used during the preparation of the glow effect.
  50639. * This is black by default as the blend operation is a blend operation.
  50640. */
  50641. static NeutralColor: Color4;
  50642. /**
  50643. * Stencil value used for glowing meshes.
  50644. */
  50645. static GlowingMeshStencilReference: number;
  50646. /**
  50647. * Stencil value used for the other meshes in the scene.
  50648. */
  50649. static NormalMeshStencilReference: number;
  50650. /**
  50651. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50652. */
  50653. innerGlow: boolean;
  50654. /**
  50655. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50656. */
  50657. outerGlow: boolean;
  50658. /**
  50659. * Specifies the horizontal size of the blur.
  50660. */
  50661. /**
  50662. * Gets the horizontal size of the blur.
  50663. */
  50664. blurHorizontalSize: number;
  50665. /**
  50666. * Specifies the vertical size of the blur.
  50667. */
  50668. /**
  50669. * Gets the vertical size of the blur.
  50670. */
  50671. blurVerticalSize: number;
  50672. /**
  50673. * An event triggered when the highlight layer is being blurred.
  50674. */
  50675. onBeforeBlurObservable: Observable<HighlightLayer>;
  50676. /**
  50677. * An event triggered when the highlight layer has been blurred.
  50678. */
  50679. onAfterBlurObservable: Observable<HighlightLayer>;
  50680. private _instanceGlowingMeshStencilReference;
  50681. private _options;
  50682. private _downSamplePostprocess;
  50683. private _horizontalBlurPostprocess;
  50684. private _verticalBlurPostprocess;
  50685. private _blurTexture;
  50686. private _meshes;
  50687. private _excludedMeshes;
  50688. /**
  50689. * Instantiates a new highlight Layer and references it to the scene..
  50690. * @param name The name of the layer
  50691. * @param scene The scene to use the layer in
  50692. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50693. */
  50694. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50695. /**
  50696. * Get the effect name of the layer.
  50697. * @return The effect name
  50698. */
  50699. getEffectName(): string;
  50700. /**
  50701. * Create the merge effect. This is the shader use to blit the information back
  50702. * to the main canvas at the end of the scene rendering.
  50703. */
  50704. protected _createMergeEffect(): Effect;
  50705. /**
  50706. * Creates the render target textures and post processes used in the highlight layer.
  50707. */
  50708. protected _createTextureAndPostProcesses(): void;
  50709. /**
  50710. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50711. */
  50712. needStencil(): boolean;
  50713. /**
  50714. * Checks for the readiness of the element composing the layer.
  50715. * @param subMesh the mesh to check for
  50716. * @param useInstances specify wether or not to use instances to render the mesh
  50717. * @param emissiveTexture the associated emissive texture used to generate the glow
  50718. * @return true if ready otherwise, false
  50719. */
  50720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50721. /**
  50722. * Implementation specific of rendering the generating effect on the main canvas.
  50723. * @param effect The effect used to render through
  50724. */
  50725. protected _internalRender(effect: Effect): void;
  50726. /**
  50727. * Returns true if the layer contains information to display, otherwise false.
  50728. */
  50729. shouldRender(): boolean;
  50730. /**
  50731. * Returns true if the mesh should render, otherwise false.
  50732. * @param mesh The mesh to render
  50733. * @returns true if it should render otherwise false
  50734. */
  50735. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50736. /**
  50737. * Sets the required values for both the emissive texture and and the main color.
  50738. */
  50739. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50740. /**
  50741. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50742. * @param mesh The mesh to exclude from the highlight layer
  50743. */
  50744. addExcludedMesh(mesh: Mesh): void;
  50745. /**
  50746. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50747. * @param mesh The mesh to highlight
  50748. */
  50749. removeExcludedMesh(mesh: Mesh): void;
  50750. /**
  50751. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50752. * @param mesh mesh to test
  50753. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50754. */
  50755. hasMesh(mesh: AbstractMesh): boolean;
  50756. /**
  50757. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50758. * @param mesh The mesh to highlight
  50759. * @param color The color of the highlight
  50760. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50761. */
  50762. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50763. /**
  50764. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50765. * @param mesh The mesh to highlight
  50766. */
  50767. removeMesh(mesh: Mesh): void;
  50768. /**
  50769. * Force the stencil to the normal expected value for none glowing parts
  50770. */
  50771. private _defaultStencilReference;
  50772. /**
  50773. * Free any resources and references associated to a mesh.
  50774. * Internal use
  50775. * @param mesh The mesh to free.
  50776. * @hidden
  50777. */
  50778. _disposeMesh(mesh: Mesh): void;
  50779. /**
  50780. * Dispose the highlight layer and free resources.
  50781. */
  50782. dispose(): void;
  50783. /**
  50784. * Gets the class name of the effect layer
  50785. * @returns the string with the class name of the effect layer
  50786. */
  50787. getClassName(): string;
  50788. /**
  50789. * Serializes this Highlight layer
  50790. * @returns a serialized Highlight layer object
  50791. */
  50792. serialize(): any;
  50793. /**
  50794. * Creates a Highlight layer from parsed Highlight layer data
  50795. * @param parsedHightlightLayer defines the Highlight layer data
  50796. * @param scene defines the current scene
  50797. * @param rootUrl defines the root URL containing the Highlight layer information
  50798. * @returns a parsed Highlight layer
  50799. */
  50800. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50801. }
  50802. }
  50803. declare module BABYLON {
  50804. interface AbstractScene {
  50805. /**
  50806. * The list of layers (background and foreground) of the scene
  50807. */
  50808. layers: Array<Layer>;
  50809. }
  50810. /**
  50811. * Defines the layer scene component responsible to manage any layers
  50812. * in a given scene.
  50813. */
  50814. export class LayerSceneComponent implements ISceneComponent {
  50815. /**
  50816. * The component name helpfull to identify the component in the list of scene components.
  50817. */
  50818. readonly name: string;
  50819. /**
  50820. * The scene the component belongs to.
  50821. */
  50822. scene: Scene;
  50823. private _engine;
  50824. /**
  50825. * Creates a new instance of the component for the given scene
  50826. * @param scene Defines the scene to register the component in
  50827. */
  50828. constructor(scene: Scene);
  50829. /**
  50830. * Registers the component in a given scene
  50831. */
  50832. register(): void;
  50833. /**
  50834. * Rebuilds the elements related to this component in case of
  50835. * context lost for instance.
  50836. */
  50837. rebuild(): void;
  50838. /**
  50839. * Disposes the component and the associated ressources.
  50840. */
  50841. dispose(): void;
  50842. private _draw;
  50843. private _drawCameraPredicate;
  50844. private _drawCameraBackground;
  50845. private _drawCameraForeground;
  50846. private _drawRenderTargetPredicate;
  50847. private _drawRenderTargetBackground;
  50848. private _drawRenderTargetForeground;
  50849. /**
  50850. * Adds all the elements from the container to the scene
  50851. * @param container the container holding the elements
  50852. */
  50853. addFromContainer(container: AbstractScene): void;
  50854. /**
  50855. * Removes all the elements in the container from the scene
  50856. * @param container contains the elements to remove
  50857. * @param dispose if the removed element should be disposed (default: false)
  50858. */
  50859. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50860. }
  50861. }
  50862. declare module BABYLON {
  50863. /** @hidden */
  50864. export var layerPixelShader: {
  50865. name: string;
  50866. shader: string;
  50867. };
  50868. }
  50869. declare module BABYLON {
  50870. /** @hidden */
  50871. export var layerVertexShader: {
  50872. name: string;
  50873. shader: string;
  50874. };
  50875. }
  50876. declare module BABYLON {
  50877. /**
  50878. * This represents a full screen 2d layer.
  50879. * This can be useful to display a picture in the background of your scene for instance.
  50880. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50881. */
  50882. export class Layer {
  50883. /**
  50884. * Define the name of the layer.
  50885. */
  50886. name: string;
  50887. /**
  50888. * Define the texture the layer should display.
  50889. */
  50890. texture: Nullable<Texture>;
  50891. /**
  50892. * Is the layer in background or foreground.
  50893. */
  50894. isBackground: boolean;
  50895. /**
  50896. * Define the color of the layer (instead of texture).
  50897. */
  50898. color: Color4;
  50899. /**
  50900. * Define the scale of the layer in order to zoom in out of the texture.
  50901. */
  50902. scale: Vector2;
  50903. /**
  50904. * Define an offset for the layer in order to shift the texture.
  50905. */
  50906. offset: Vector2;
  50907. /**
  50908. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50909. */
  50910. alphaBlendingMode: number;
  50911. /**
  50912. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50913. * Alpha test will not mix with the background color in case of transparency.
  50914. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50915. */
  50916. alphaTest: boolean;
  50917. /**
  50918. * Define a mask to restrict the layer to only some of the scene cameras.
  50919. */
  50920. layerMask: number;
  50921. /**
  50922. * Define the list of render target the layer is visible into.
  50923. */
  50924. renderTargetTextures: RenderTargetTexture[];
  50925. /**
  50926. * Define if the layer is only used in renderTarget or if it also
  50927. * renders in the main frame buffer of the canvas.
  50928. */
  50929. renderOnlyInRenderTargetTextures: boolean;
  50930. private _scene;
  50931. private _vertexBuffers;
  50932. private _indexBuffer;
  50933. private _effect;
  50934. private _alphaTestEffect;
  50935. /**
  50936. * An event triggered when the layer is disposed.
  50937. */
  50938. onDisposeObservable: Observable<Layer>;
  50939. private _onDisposeObserver;
  50940. /**
  50941. * Back compatibility with callback before the onDisposeObservable existed.
  50942. * The set callback will be triggered when the layer has been disposed.
  50943. */
  50944. onDispose: () => void;
  50945. /**
  50946. * An event triggered before rendering the scene
  50947. */
  50948. onBeforeRenderObservable: Observable<Layer>;
  50949. private _onBeforeRenderObserver;
  50950. /**
  50951. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50952. * The set callback will be triggered just before rendering the layer.
  50953. */
  50954. onBeforeRender: () => void;
  50955. /**
  50956. * An event triggered after rendering the scene
  50957. */
  50958. onAfterRenderObservable: Observable<Layer>;
  50959. private _onAfterRenderObserver;
  50960. /**
  50961. * Back compatibility with callback before the onAfterRenderObservable existed.
  50962. * The set callback will be triggered just after rendering the layer.
  50963. */
  50964. onAfterRender: () => void;
  50965. /**
  50966. * Instantiates a new layer.
  50967. * This represents a full screen 2d layer.
  50968. * This can be useful to display a picture in the background of your scene for instance.
  50969. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50970. * @param name Define the name of the layer in the scene
  50971. * @param imgUrl Define the url of the texture to display in the layer
  50972. * @param scene Define the scene the layer belongs to
  50973. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50974. * @param color Defines a color for the layer
  50975. */
  50976. constructor(
  50977. /**
  50978. * Define the name of the layer.
  50979. */
  50980. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50981. private _createIndexBuffer;
  50982. /** @hidden */
  50983. _rebuild(): void;
  50984. /**
  50985. * Renders the layer in the scene.
  50986. */
  50987. render(): void;
  50988. /**
  50989. * Disposes and releases the associated ressources.
  50990. */
  50991. dispose(): void;
  50992. }
  50993. }
  50994. declare module BABYLON {
  50995. /** @hidden */
  50996. export var lensFlarePixelShader: {
  50997. name: string;
  50998. shader: string;
  50999. };
  51000. }
  51001. declare module BABYLON {
  51002. /** @hidden */
  51003. export var lensFlareVertexShader: {
  51004. name: string;
  51005. shader: string;
  51006. };
  51007. }
  51008. declare module BABYLON {
  51009. /**
  51010. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51011. * It is usually composed of several `lensFlare`.
  51012. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51013. */
  51014. export class LensFlareSystem {
  51015. /**
  51016. * Define the name of the lens flare system
  51017. */
  51018. name: string;
  51019. /**
  51020. * List of lens flares used in this system.
  51021. */
  51022. lensFlares: LensFlare[];
  51023. /**
  51024. * Define a limit from the border the lens flare can be visible.
  51025. */
  51026. borderLimit: number;
  51027. /**
  51028. * Define a viewport border we do not want to see the lens flare in.
  51029. */
  51030. viewportBorder: number;
  51031. /**
  51032. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51033. */
  51034. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51035. /**
  51036. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51037. */
  51038. layerMask: number;
  51039. /**
  51040. * Define the id of the lens flare system in the scene.
  51041. * (equal to name by default)
  51042. */
  51043. id: string;
  51044. private _scene;
  51045. private _emitter;
  51046. private _vertexBuffers;
  51047. private _indexBuffer;
  51048. private _effect;
  51049. private _positionX;
  51050. private _positionY;
  51051. private _isEnabled;
  51052. /** @hidden */
  51053. static _SceneComponentInitialization: (scene: Scene) => void;
  51054. /**
  51055. * Instantiates a lens flare system.
  51056. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51057. * It is usually composed of several `lensFlare`.
  51058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51059. * @param name Define the name of the lens flare system in the scene
  51060. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51061. * @param scene Define the scene the lens flare system belongs to
  51062. */
  51063. constructor(
  51064. /**
  51065. * Define the name of the lens flare system
  51066. */
  51067. name: string, emitter: any, scene: Scene);
  51068. /**
  51069. * Define if the lens flare system is enabled.
  51070. */
  51071. isEnabled: boolean;
  51072. /**
  51073. * Get the scene the effects belongs to.
  51074. * @returns the scene holding the lens flare system
  51075. */
  51076. getScene(): Scene;
  51077. /**
  51078. * Get the emitter of the lens flare system.
  51079. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51080. * @returns the emitter of the lens flare system
  51081. */
  51082. getEmitter(): any;
  51083. /**
  51084. * Set the emitter of the lens flare system.
  51085. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51086. * @param newEmitter Define the new emitter of the system
  51087. */
  51088. setEmitter(newEmitter: any): void;
  51089. /**
  51090. * Get the lens flare system emitter position.
  51091. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51092. * @returns the position
  51093. */
  51094. getEmitterPosition(): Vector3;
  51095. /**
  51096. * @hidden
  51097. */
  51098. computeEffectivePosition(globalViewport: Viewport): boolean;
  51099. /** @hidden */
  51100. _isVisible(): boolean;
  51101. /**
  51102. * @hidden
  51103. */
  51104. render(): boolean;
  51105. /**
  51106. * Dispose and release the lens flare with its associated resources.
  51107. */
  51108. dispose(): void;
  51109. /**
  51110. * Parse a lens flare system from a JSON repressentation
  51111. * @param parsedLensFlareSystem Define the JSON to parse
  51112. * @param scene Define the scene the parsed system should be instantiated in
  51113. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51114. * @returns the parsed system
  51115. */
  51116. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51117. /**
  51118. * Serialize the current Lens Flare System into a JSON representation.
  51119. * @returns the serialized JSON
  51120. */
  51121. serialize(): any;
  51122. }
  51123. }
  51124. declare module BABYLON {
  51125. /**
  51126. * This represents one of the lens effect in a `lensFlareSystem`.
  51127. * It controls one of the indiviual texture used in the effect.
  51128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51129. */
  51130. export class LensFlare {
  51131. /**
  51132. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51133. */
  51134. size: number;
  51135. /**
  51136. * 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.
  51137. */
  51138. position: number;
  51139. /**
  51140. * Define the lens color.
  51141. */
  51142. color: Color3;
  51143. /**
  51144. * Define the lens texture.
  51145. */
  51146. texture: Nullable<Texture>;
  51147. /**
  51148. * Define the alpha mode to render this particular lens.
  51149. */
  51150. alphaMode: number;
  51151. private _system;
  51152. /**
  51153. * Creates a new Lens Flare.
  51154. * This represents one of the lens effect in a `lensFlareSystem`.
  51155. * It controls one of the indiviual texture used in the effect.
  51156. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51157. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51158. * @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.
  51159. * @param color Define the lens color
  51160. * @param imgUrl Define the lens texture url
  51161. * @param system Define the `lensFlareSystem` this flare is part of
  51162. * @returns The newly created Lens Flare
  51163. */
  51164. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51165. /**
  51166. * Instantiates a new Lens Flare.
  51167. * This represents one of the lens effect in a `lensFlareSystem`.
  51168. * It controls one of the indiviual texture used in the effect.
  51169. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51170. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51171. * @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.
  51172. * @param color Define the lens color
  51173. * @param imgUrl Define the lens texture url
  51174. * @param system Define the `lensFlareSystem` this flare is part of
  51175. */
  51176. constructor(
  51177. /**
  51178. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51179. */
  51180. size: number,
  51181. /**
  51182. * 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.
  51183. */
  51184. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51185. /**
  51186. * Dispose and release the lens flare with its associated resources.
  51187. */
  51188. dispose(): void;
  51189. }
  51190. }
  51191. declare module BABYLON {
  51192. interface AbstractScene {
  51193. /**
  51194. * The list of lens flare system added to the scene
  51195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51196. */
  51197. lensFlareSystems: Array<LensFlareSystem>;
  51198. /**
  51199. * Removes the given lens flare system from this scene.
  51200. * @param toRemove The lens flare system to remove
  51201. * @returns The index of the removed lens flare system
  51202. */
  51203. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51204. /**
  51205. * Adds the given lens flare system to this scene
  51206. * @param newLensFlareSystem The lens flare system to add
  51207. */
  51208. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51209. /**
  51210. * Gets a lens flare system using its name
  51211. * @param name defines the name to look for
  51212. * @returns the lens flare system or null if not found
  51213. */
  51214. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51215. /**
  51216. * Gets a lens flare system using its id
  51217. * @param id defines the id to look for
  51218. * @returns the lens flare system or null if not found
  51219. */
  51220. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51221. }
  51222. /**
  51223. * Defines the lens flare scene component responsible to manage any lens flares
  51224. * in a given scene.
  51225. */
  51226. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51227. /**
  51228. * The component name helpfull to identify the component in the list of scene components.
  51229. */
  51230. readonly name: string;
  51231. /**
  51232. * The scene the component belongs to.
  51233. */
  51234. scene: Scene;
  51235. /**
  51236. * Creates a new instance of the component for the given scene
  51237. * @param scene Defines the scene to register the component in
  51238. */
  51239. constructor(scene: Scene);
  51240. /**
  51241. * Registers the component in a given scene
  51242. */
  51243. register(): void;
  51244. /**
  51245. * Rebuilds the elements related to this component in case of
  51246. * context lost for instance.
  51247. */
  51248. rebuild(): void;
  51249. /**
  51250. * Adds all the elements from the container to the scene
  51251. * @param container the container holding the elements
  51252. */
  51253. addFromContainer(container: AbstractScene): void;
  51254. /**
  51255. * Removes all the elements in the container from the scene
  51256. * @param container contains the elements to remove
  51257. * @param dispose if the removed element should be disposed (default: false)
  51258. */
  51259. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51260. /**
  51261. * Serializes the component data to the specified json object
  51262. * @param serializationObject The object to serialize to
  51263. */
  51264. serialize(serializationObject: any): void;
  51265. /**
  51266. * Disposes the component and the associated ressources.
  51267. */
  51268. dispose(): void;
  51269. private _draw;
  51270. }
  51271. }
  51272. declare module BABYLON {
  51273. /**
  51274. * Defines the shadow generator component responsible to manage any shadow generators
  51275. * in a given scene.
  51276. */
  51277. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51278. /**
  51279. * The component name helpfull to identify the component in the list of scene components.
  51280. */
  51281. readonly name: string;
  51282. /**
  51283. * The scene the component belongs to.
  51284. */
  51285. scene: Scene;
  51286. /**
  51287. * Creates a new instance of the component for the given scene
  51288. * @param scene Defines the scene to register the component in
  51289. */
  51290. constructor(scene: Scene);
  51291. /**
  51292. * Registers the component in a given scene
  51293. */
  51294. register(): void;
  51295. /**
  51296. * Rebuilds the elements related to this component in case of
  51297. * context lost for instance.
  51298. */
  51299. rebuild(): void;
  51300. /**
  51301. * Serializes the component data to the specified json object
  51302. * @param serializationObject The object to serialize to
  51303. */
  51304. serialize(serializationObject: any): void;
  51305. /**
  51306. * Adds all the elements from the container to the scene
  51307. * @param container the container holding the elements
  51308. */
  51309. addFromContainer(container: AbstractScene): void;
  51310. /**
  51311. * Removes all the elements in the container from the scene
  51312. * @param container contains the elements to remove
  51313. * @param dispose if the removed element should be disposed (default: false)
  51314. */
  51315. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51316. /**
  51317. * Rebuilds the elements related to this component in case of
  51318. * context lost for instance.
  51319. */
  51320. dispose(): void;
  51321. private _gatherRenderTargets;
  51322. }
  51323. }
  51324. declare module BABYLON {
  51325. /**
  51326. * A point light is a light defined by an unique point in world space.
  51327. * The light is emitted in every direction from this point.
  51328. * A good example of a point light is a standard light bulb.
  51329. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51330. */
  51331. export class PointLight extends ShadowLight {
  51332. private _shadowAngle;
  51333. /**
  51334. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51335. * This specifies what angle the shadow will use to be created.
  51336. *
  51337. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51338. */
  51339. /**
  51340. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51341. * This specifies what angle the shadow will use to be created.
  51342. *
  51343. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51344. */
  51345. shadowAngle: number;
  51346. /**
  51347. * Gets the direction if it has been set.
  51348. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51349. */
  51350. /**
  51351. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51352. */
  51353. direction: Vector3;
  51354. /**
  51355. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51356. * A PointLight emits the light in every direction.
  51357. * It can cast shadows.
  51358. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51359. * ```javascript
  51360. * var pointLight = new PointLight("pl", camera.position, scene);
  51361. * ```
  51362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51363. * @param name The light friendly name
  51364. * @param position The position of the point light in the scene
  51365. * @param scene The scene the lights belongs to
  51366. */
  51367. constructor(name: string, position: Vector3, scene: Scene);
  51368. /**
  51369. * Returns the string "PointLight"
  51370. * @returns the class name
  51371. */
  51372. getClassName(): string;
  51373. /**
  51374. * Returns the integer 0.
  51375. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51376. */
  51377. getTypeID(): number;
  51378. /**
  51379. * Specifies wether or not the shadowmap should be a cube texture.
  51380. * @returns true if the shadowmap needs to be a cube texture.
  51381. */
  51382. needCube(): boolean;
  51383. /**
  51384. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51385. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51386. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51387. */
  51388. getShadowDirection(faceIndex?: number): Vector3;
  51389. /**
  51390. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51391. * - fov = PI / 2
  51392. * - aspect ratio : 1.0
  51393. * - z-near and far equal to the active camera minZ and maxZ.
  51394. * Returns the PointLight.
  51395. */
  51396. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51397. protected _buildUniformLayout(): void;
  51398. /**
  51399. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51400. * @param effect The effect to update
  51401. * @param lightIndex The index of the light in the effect to update
  51402. * @returns The point light
  51403. */
  51404. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51405. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51406. /**
  51407. * Prepares the list of defines specific to the light type.
  51408. * @param defines the list of defines
  51409. * @param lightIndex defines the index of the light for the effect
  51410. */
  51411. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51412. }
  51413. }
  51414. declare module BABYLON {
  51415. /**
  51416. * Header information of HDR texture files.
  51417. */
  51418. export interface HDRInfo {
  51419. /**
  51420. * The height of the texture in pixels.
  51421. */
  51422. height: number;
  51423. /**
  51424. * The width of the texture in pixels.
  51425. */
  51426. width: number;
  51427. /**
  51428. * The index of the beginning of the data in the binary file.
  51429. */
  51430. dataPosition: number;
  51431. }
  51432. /**
  51433. * This groups tools to convert HDR texture to native colors array.
  51434. */
  51435. export class HDRTools {
  51436. private static Ldexp;
  51437. private static Rgbe2float;
  51438. private static readStringLine;
  51439. /**
  51440. * Reads header information from an RGBE texture stored in a native array.
  51441. * More information on this format are available here:
  51442. * https://en.wikipedia.org/wiki/RGBE_image_format
  51443. *
  51444. * @param uint8array The binary file stored in native array.
  51445. * @return The header information.
  51446. */
  51447. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51448. /**
  51449. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51450. * This RGBE texture needs to store the information as a panorama.
  51451. *
  51452. * More information on this format are available here:
  51453. * https://en.wikipedia.org/wiki/RGBE_image_format
  51454. *
  51455. * @param buffer The binary file stored in an array buffer.
  51456. * @param size The expected size of the extracted cubemap.
  51457. * @return The Cube Map information.
  51458. */
  51459. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51460. /**
  51461. * Returns the pixels data extracted from an RGBE texture.
  51462. * This pixels will be stored left to right up to down in the R G B order in one array.
  51463. *
  51464. * More information on this format are available here:
  51465. * https://en.wikipedia.org/wiki/RGBE_image_format
  51466. *
  51467. * @param uint8array The binary file stored in an array buffer.
  51468. * @param hdrInfo The header information of the file.
  51469. * @return The pixels data in RGB right to left up to down order.
  51470. */
  51471. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51472. private static RGBE_ReadPixels_RLE;
  51473. }
  51474. }
  51475. declare module BABYLON {
  51476. /**
  51477. * This represents a texture coming from an HDR input.
  51478. *
  51479. * The only supported format is currently panorama picture stored in RGBE format.
  51480. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51481. */
  51482. export class HDRCubeTexture extends BaseTexture {
  51483. private static _facesMapping;
  51484. private _generateHarmonics;
  51485. private _noMipmap;
  51486. private _textureMatrix;
  51487. private _size;
  51488. private _onLoad;
  51489. private _onError;
  51490. /**
  51491. * The texture URL.
  51492. */
  51493. url: string;
  51494. /**
  51495. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51496. */
  51497. coordinatesMode: number;
  51498. protected _isBlocking: boolean;
  51499. /**
  51500. * Sets wether or not the texture is blocking during loading.
  51501. */
  51502. /**
  51503. * Gets wether or not the texture is blocking during loading.
  51504. */
  51505. isBlocking: boolean;
  51506. protected _rotationY: number;
  51507. /**
  51508. * Sets texture matrix rotation angle around Y axis in radians.
  51509. */
  51510. /**
  51511. * Gets texture matrix rotation angle around Y axis radians.
  51512. */
  51513. rotationY: number;
  51514. /**
  51515. * Gets or sets the center of the bounding box associated with the cube texture
  51516. * It must define where the camera used to render the texture was set
  51517. */
  51518. boundingBoxPosition: Vector3;
  51519. private _boundingBoxSize;
  51520. /**
  51521. * Gets or sets the size of the bounding box associated with the cube texture
  51522. * When defined, the cubemap will switch to local mode
  51523. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51524. * @example https://www.babylonjs-playground.com/#RNASML
  51525. */
  51526. boundingBoxSize: Vector3;
  51527. /**
  51528. * Instantiates an HDRTexture from the following parameters.
  51529. *
  51530. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51531. * @param scene The scene the texture will be used in
  51532. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51533. * @param noMipmap Forces to not generate the mipmap if true
  51534. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51535. * @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)
  51536. * @param reserved Reserved flag for internal use.
  51537. */
  51538. 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>);
  51539. /**
  51540. * Get the current class name of the texture useful for serialization or dynamic coding.
  51541. * @returns "HDRCubeTexture"
  51542. */
  51543. getClassName(): string;
  51544. /**
  51545. * Occurs when the file is raw .hdr file.
  51546. */
  51547. private loadTexture;
  51548. clone(): HDRCubeTexture;
  51549. delayLoad(): void;
  51550. /**
  51551. * Get the texture reflection matrix used to rotate/transform the reflection.
  51552. * @returns the reflection matrix
  51553. */
  51554. getReflectionTextureMatrix(): Matrix;
  51555. /**
  51556. * Set the texture reflection matrix used to rotate/transform the reflection.
  51557. * @param value Define the reflection matrix to set
  51558. */
  51559. setReflectionTextureMatrix(value: Matrix): void;
  51560. /**
  51561. * Parses a JSON representation of an HDR Texture in order to create the texture
  51562. * @param parsedTexture Define the JSON representation
  51563. * @param scene Define the scene the texture should be created in
  51564. * @param rootUrl Define the root url in case we need to load relative dependencies
  51565. * @returns the newly created texture after parsing
  51566. */
  51567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51568. serialize(): any;
  51569. }
  51570. }
  51571. declare module BABYLON {
  51572. /**
  51573. * Class used to control physics engine
  51574. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51575. */
  51576. export class PhysicsEngine implements IPhysicsEngine {
  51577. private _physicsPlugin;
  51578. /**
  51579. * Global value used to control the smallest number supported by the simulation
  51580. */
  51581. static Epsilon: number;
  51582. private _impostors;
  51583. private _joints;
  51584. /**
  51585. * Gets the gravity vector used by the simulation
  51586. */
  51587. gravity: Vector3;
  51588. /**
  51589. * Factory used to create the default physics plugin.
  51590. * @returns The default physics plugin
  51591. */
  51592. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51593. /**
  51594. * Creates a new Physics Engine
  51595. * @param gravity defines the gravity vector used by the simulation
  51596. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51597. */
  51598. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51599. /**
  51600. * Sets the gravity vector used by the simulation
  51601. * @param gravity defines the gravity vector to use
  51602. */
  51603. setGravity(gravity: Vector3): void;
  51604. /**
  51605. * Set the time step of the physics engine.
  51606. * Default is 1/60.
  51607. * To slow it down, enter 1/600 for example.
  51608. * To speed it up, 1/30
  51609. * @param newTimeStep defines the new timestep to apply to this world.
  51610. */
  51611. setTimeStep(newTimeStep?: number): void;
  51612. /**
  51613. * Get the time step of the physics engine.
  51614. * @returns the current time step
  51615. */
  51616. getTimeStep(): number;
  51617. /**
  51618. * Release all resources
  51619. */
  51620. dispose(): void;
  51621. /**
  51622. * Gets the name of the current physics plugin
  51623. * @returns the name of the plugin
  51624. */
  51625. getPhysicsPluginName(): string;
  51626. /**
  51627. * Adding a new impostor for the impostor tracking.
  51628. * This will be done by the impostor itself.
  51629. * @param impostor the impostor to add
  51630. */
  51631. addImpostor(impostor: PhysicsImpostor): void;
  51632. /**
  51633. * Remove an impostor from the engine.
  51634. * This impostor and its mesh will not longer be updated by the physics engine.
  51635. * @param impostor the impostor to remove
  51636. */
  51637. removeImpostor(impostor: PhysicsImpostor): void;
  51638. /**
  51639. * Add a joint to the physics engine
  51640. * @param mainImpostor defines the main impostor to which the joint is added.
  51641. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51642. * @param joint defines the joint that will connect both impostors.
  51643. */
  51644. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51645. /**
  51646. * Removes a joint from the simulation
  51647. * @param mainImpostor defines the impostor used with the joint
  51648. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51649. * @param joint defines the joint to remove
  51650. */
  51651. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51652. /**
  51653. * Called by the scene. No need to call it.
  51654. * @param delta defines the timespam between frames
  51655. */
  51656. _step(delta: number): void;
  51657. /**
  51658. * Gets the current plugin used to run the simulation
  51659. * @returns current plugin
  51660. */
  51661. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51662. /**
  51663. * Gets the list of physic impostors
  51664. * @returns an array of PhysicsImpostor
  51665. */
  51666. getImpostors(): Array<PhysicsImpostor>;
  51667. /**
  51668. * Gets the impostor for a physics enabled object
  51669. * @param object defines the object impersonated by the impostor
  51670. * @returns the PhysicsImpostor or null if not found
  51671. */
  51672. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51673. /**
  51674. * Gets the impostor for a physics body object
  51675. * @param body defines physics body used by the impostor
  51676. * @returns the PhysicsImpostor or null if not found
  51677. */
  51678. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51679. /**
  51680. * Does a raycast in the physics world
  51681. * @param from when should the ray start?
  51682. * @param to when should the ray end?
  51683. * @returns PhysicsRaycastResult
  51684. */
  51685. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51686. }
  51687. }
  51688. declare module BABYLON {
  51689. /** @hidden */
  51690. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51691. private _useDeltaForWorldStep;
  51692. world: any;
  51693. name: string;
  51694. private _physicsMaterials;
  51695. private _fixedTimeStep;
  51696. private _cannonRaycastResult;
  51697. private _raycastResult;
  51698. private _physicsBodysToRemoveAfterStep;
  51699. BJSCANNON: any;
  51700. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51701. setGravity(gravity: Vector3): void;
  51702. setTimeStep(timeStep: number): void;
  51703. getTimeStep(): number;
  51704. executeStep(delta: number): void;
  51705. private _removeMarkedPhysicsBodiesFromWorld;
  51706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51709. private _processChildMeshes;
  51710. removePhysicsBody(impostor: PhysicsImpostor): void;
  51711. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51712. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51713. private _addMaterial;
  51714. private _checkWithEpsilon;
  51715. private _createShape;
  51716. private _createHeightmap;
  51717. private _minus90X;
  51718. private _plus90X;
  51719. private _tmpPosition;
  51720. private _tmpDeltaPosition;
  51721. private _tmpUnityRotation;
  51722. private _updatePhysicsBodyTransformation;
  51723. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51724. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51725. isSupported(): boolean;
  51726. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51727. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51728. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51729. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51730. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51731. getBodyMass(impostor: PhysicsImpostor): number;
  51732. getBodyFriction(impostor: PhysicsImpostor): number;
  51733. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51734. getBodyRestitution(impostor: PhysicsImpostor): number;
  51735. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51736. sleepBody(impostor: PhysicsImpostor): void;
  51737. wakeUpBody(impostor: PhysicsImpostor): void;
  51738. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51739. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51741. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51742. getRadius(impostor: PhysicsImpostor): number;
  51743. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51744. dispose(): void;
  51745. private _extendNamespace;
  51746. /**
  51747. * Does a raycast in the physics world
  51748. * @param from when should the ray start?
  51749. * @param to when should the ray end?
  51750. * @returns PhysicsRaycastResult
  51751. */
  51752. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51753. }
  51754. }
  51755. declare module BABYLON {
  51756. /** @hidden */
  51757. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51758. world: any;
  51759. name: string;
  51760. BJSOIMO: any;
  51761. private _raycastResult;
  51762. constructor(iterations?: number, oimoInjection?: any);
  51763. setGravity(gravity: Vector3): void;
  51764. setTimeStep(timeStep: number): void;
  51765. getTimeStep(): number;
  51766. private _tmpImpostorsArray;
  51767. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51768. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51769. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51770. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51771. private _tmpPositionVector;
  51772. removePhysicsBody(impostor: PhysicsImpostor): void;
  51773. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51774. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51775. isSupported(): boolean;
  51776. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51777. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51778. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51779. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51780. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51781. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51782. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51783. getBodyMass(impostor: PhysicsImpostor): number;
  51784. getBodyFriction(impostor: PhysicsImpostor): number;
  51785. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51786. getBodyRestitution(impostor: PhysicsImpostor): number;
  51787. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51788. sleepBody(impostor: PhysicsImpostor): void;
  51789. wakeUpBody(impostor: PhysicsImpostor): void;
  51790. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51791. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51792. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51793. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51794. getRadius(impostor: PhysicsImpostor): number;
  51795. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51796. dispose(): void;
  51797. /**
  51798. * Does a raycast in the physics world
  51799. * @param from when should the ray start?
  51800. * @param to when should the ray end?
  51801. * @returns PhysicsRaycastResult
  51802. */
  51803. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51804. }
  51805. }
  51806. declare module BABYLON {
  51807. /**
  51808. * Class containing static functions to help procedurally build meshes
  51809. */
  51810. export class RibbonBuilder {
  51811. /**
  51812. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51813. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51814. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51815. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51816. * * 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
  51817. * * 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
  51818. * * 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
  51819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51820. * * 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
  51821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51822. * * 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
  51823. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51824. * * 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
  51825. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51827. * @param name defines the name of the mesh
  51828. * @param options defines the options used to create the mesh
  51829. * @param scene defines the hosting scene
  51830. * @returns the ribbon mesh
  51831. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51832. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51833. */
  51834. static CreateRibbon(name: string, options: {
  51835. pathArray: Vector3[][];
  51836. closeArray?: boolean;
  51837. closePath?: boolean;
  51838. offset?: number;
  51839. updatable?: boolean;
  51840. sideOrientation?: number;
  51841. frontUVs?: Vector4;
  51842. backUVs?: Vector4;
  51843. instance?: Mesh;
  51844. invertUV?: boolean;
  51845. uvs?: Vector2[];
  51846. colors?: Color4[];
  51847. }, scene?: Nullable<Scene>): Mesh;
  51848. }
  51849. }
  51850. declare module BABYLON {
  51851. /**
  51852. * Class containing static functions to help procedurally build meshes
  51853. */
  51854. export class ShapeBuilder {
  51855. /**
  51856. * 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.
  51857. * * 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.
  51858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51859. * * 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.
  51860. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51861. * * 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
  51862. * * 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
  51863. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51865. * * 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
  51866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51868. * @param name defines the name of the mesh
  51869. * @param options defines the options used to create the mesh
  51870. * @param scene defines the hosting scene
  51871. * @returns the extruded shape mesh
  51872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51874. */
  51875. static ExtrudeShape(name: string, options: {
  51876. shape: Vector3[];
  51877. path: Vector3[];
  51878. scale?: number;
  51879. rotation?: number;
  51880. cap?: number;
  51881. updatable?: boolean;
  51882. sideOrientation?: number;
  51883. frontUVs?: Vector4;
  51884. backUVs?: Vector4;
  51885. instance?: Mesh;
  51886. invertUV?: boolean;
  51887. }, scene?: Nullable<Scene>): Mesh;
  51888. /**
  51889. * Creates an custom extruded shape mesh.
  51890. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51891. * * 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.
  51892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51893. * * 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
  51894. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51895. * * 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
  51896. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51897. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51898. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51899. * * 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
  51900. * * 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
  51901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51903. * * 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
  51904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51906. * @param name defines the name of the mesh
  51907. * @param options defines the options used to create the mesh
  51908. * @param scene defines the hosting scene
  51909. * @returns the custom extruded shape mesh
  51910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51913. */
  51914. static ExtrudeShapeCustom(name: string, options: {
  51915. shape: Vector3[];
  51916. path: Vector3[];
  51917. scaleFunction?: any;
  51918. rotationFunction?: any;
  51919. ribbonCloseArray?: boolean;
  51920. ribbonClosePath?: boolean;
  51921. cap?: number;
  51922. updatable?: boolean;
  51923. sideOrientation?: number;
  51924. frontUVs?: Vector4;
  51925. backUVs?: Vector4;
  51926. instance?: Mesh;
  51927. invertUV?: boolean;
  51928. }, scene?: Nullable<Scene>): Mesh;
  51929. private static _ExtrudeShapeGeneric;
  51930. }
  51931. }
  51932. declare module BABYLON {
  51933. /**
  51934. * AmmoJS Physics plugin
  51935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51936. * @see https://github.com/kripken/ammo.js/
  51937. */
  51938. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51939. private _useDeltaForWorldStep;
  51940. /**
  51941. * Reference to the Ammo library
  51942. */
  51943. bjsAMMO: any;
  51944. /**
  51945. * Created ammoJS world which physics bodies are added to
  51946. */
  51947. world: any;
  51948. /**
  51949. * Name of the plugin
  51950. */
  51951. name: string;
  51952. private _timeStep;
  51953. private _fixedTimeStep;
  51954. private _maxSteps;
  51955. private _tmpQuaternion;
  51956. private _tmpAmmoTransform;
  51957. private _tmpAmmoQuaternion;
  51958. private _tmpAmmoConcreteContactResultCallback;
  51959. private _collisionConfiguration;
  51960. private _dispatcher;
  51961. private _overlappingPairCache;
  51962. private _solver;
  51963. private _softBodySolver;
  51964. private _tmpAmmoVectorA;
  51965. private _tmpAmmoVectorB;
  51966. private _tmpAmmoVectorC;
  51967. private _tmpAmmoVectorD;
  51968. private _tmpContactCallbackResult;
  51969. private _tmpAmmoVectorRCA;
  51970. private _tmpAmmoVectorRCB;
  51971. private _raycastResult;
  51972. private static readonly DISABLE_COLLISION_FLAG;
  51973. private static readonly KINEMATIC_FLAG;
  51974. private static readonly DISABLE_DEACTIVATION_FLAG;
  51975. /**
  51976. * Initializes the ammoJS plugin
  51977. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51978. * @param ammoInjection can be used to inject your own ammo reference
  51979. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51980. */
  51981. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51982. /**
  51983. * Sets the gravity of the physics world (m/(s^2))
  51984. * @param gravity Gravity to set
  51985. */
  51986. setGravity(gravity: Vector3): void;
  51987. /**
  51988. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51989. * @param timeStep timestep to use in seconds
  51990. */
  51991. setTimeStep(timeStep: number): void;
  51992. /**
  51993. * 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)
  51994. * @param fixedTimeStep fixedTimeStep to use in seconds
  51995. */
  51996. setFixedTimeStep(fixedTimeStep: number): void;
  51997. /**
  51998. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51999. * @param maxSteps the maximum number of steps by the physics engine per frame
  52000. */
  52001. setMaxSteps(maxSteps: number): void;
  52002. /**
  52003. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52004. * @returns the current timestep in seconds
  52005. */
  52006. getTimeStep(): number;
  52007. private _isImpostorInContact;
  52008. private _isImpostorPairInContact;
  52009. private _stepSimulation;
  52010. /**
  52011. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52012. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52013. * After the step the babylon meshes are set to the position of the physics imposters
  52014. * @param delta amount of time to step forward
  52015. * @param impostors array of imposters to update before/after the step
  52016. */
  52017. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52018. /**
  52019. * Update babylon mesh to match physics world object
  52020. * @param impostor imposter to match
  52021. */
  52022. private _afterSoftStep;
  52023. /**
  52024. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52025. * @param impostor imposter to match
  52026. */
  52027. private _ropeStep;
  52028. /**
  52029. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52030. * @param impostor imposter to match
  52031. */
  52032. private _softbodyOrClothStep;
  52033. private _tmpVector;
  52034. private _tmpMatrix;
  52035. /**
  52036. * Applies an impulse on the imposter
  52037. * @param impostor imposter to apply impulse to
  52038. * @param force amount of force to be applied to the imposter
  52039. * @param contactPoint the location to apply the impulse on the imposter
  52040. */
  52041. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52042. /**
  52043. * Applies a force on the imposter
  52044. * @param impostor imposter to apply force
  52045. * @param force amount of force to be applied to the imposter
  52046. * @param contactPoint the location to apply the force on the imposter
  52047. */
  52048. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52049. /**
  52050. * Creates a physics body using the plugin
  52051. * @param impostor the imposter to create the physics body on
  52052. */
  52053. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52054. /**
  52055. * Removes the physics body from the imposter and disposes of the body's memory
  52056. * @param impostor imposter to remove the physics body from
  52057. */
  52058. removePhysicsBody(impostor: PhysicsImpostor): void;
  52059. /**
  52060. * Generates a joint
  52061. * @param impostorJoint the imposter joint to create the joint with
  52062. */
  52063. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52064. /**
  52065. * Removes a joint
  52066. * @param impostorJoint the imposter joint to remove the joint from
  52067. */
  52068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52069. private _addMeshVerts;
  52070. /**
  52071. * Initialise the soft body vertices to match its object's (mesh) vertices
  52072. * Softbody vertices (nodes) are in world space and to match this
  52073. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52074. * @param impostor to create the softbody for
  52075. */
  52076. private _softVertexData;
  52077. /**
  52078. * Create an impostor's soft body
  52079. * @param impostor to create the softbody for
  52080. */
  52081. private _createSoftbody;
  52082. /**
  52083. * Create cloth for an impostor
  52084. * @param impostor to create the softbody for
  52085. */
  52086. private _createCloth;
  52087. /**
  52088. * Create rope for an impostor
  52089. * @param impostor to create the softbody for
  52090. */
  52091. private _createRope;
  52092. private _addHullVerts;
  52093. private _createShape;
  52094. /**
  52095. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52096. * @param impostor imposter containing the physics body and babylon object
  52097. */
  52098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52099. /**
  52100. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52101. * @param impostor imposter containing the physics body and babylon object
  52102. * @param newPosition new position
  52103. * @param newRotation new rotation
  52104. */
  52105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52106. /**
  52107. * If this plugin is supported
  52108. * @returns true if its supported
  52109. */
  52110. isSupported(): boolean;
  52111. /**
  52112. * Sets the linear velocity of the physics body
  52113. * @param impostor imposter to set the velocity on
  52114. * @param velocity velocity to set
  52115. */
  52116. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52117. /**
  52118. * Sets the angular velocity of the physics body
  52119. * @param impostor imposter to set the velocity on
  52120. * @param velocity velocity to set
  52121. */
  52122. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52123. /**
  52124. * gets the linear velocity
  52125. * @param impostor imposter to get linear velocity from
  52126. * @returns linear velocity
  52127. */
  52128. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52129. /**
  52130. * gets the angular velocity
  52131. * @param impostor imposter to get angular velocity from
  52132. * @returns angular velocity
  52133. */
  52134. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52135. /**
  52136. * Sets the mass of physics body
  52137. * @param impostor imposter to set the mass on
  52138. * @param mass mass to set
  52139. */
  52140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52141. /**
  52142. * Gets the mass of the physics body
  52143. * @param impostor imposter to get the mass from
  52144. * @returns mass
  52145. */
  52146. getBodyMass(impostor: PhysicsImpostor): number;
  52147. /**
  52148. * Gets friction of the impostor
  52149. * @param impostor impostor to get friction from
  52150. * @returns friction value
  52151. */
  52152. getBodyFriction(impostor: PhysicsImpostor): number;
  52153. /**
  52154. * Sets friction of the impostor
  52155. * @param impostor impostor to set friction on
  52156. * @param friction friction value
  52157. */
  52158. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52159. /**
  52160. * Gets restitution of the impostor
  52161. * @param impostor impostor to get restitution from
  52162. * @returns restitution value
  52163. */
  52164. getBodyRestitution(impostor: PhysicsImpostor): number;
  52165. /**
  52166. * Sets resitution of the impostor
  52167. * @param impostor impostor to set resitution on
  52168. * @param restitution resitution value
  52169. */
  52170. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52171. /**
  52172. * Gets pressure inside the impostor
  52173. * @param impostor impostor to get pressure from
  52174. * @returns pressure value
  52175. */
  52176. getBodyPressure(impostor: PhysicsImpostor): number;
  52177. /**
  52178. * Sets pressure inside a soft body impostor
  52179. * Cloth and rope must remain 0 pressure
  52180. * @param impostor impostor to set pressure on
  52181. * @param pressure pressure value
  52182. */
  52183. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52184. /**
  52185. * Gets stiffness of the impostor
  52186. * @param impostor impostor to get stiffness from
  52187. * @returns pressure value
  52188. */
  52189. getBodyStiffness(impostor: PhysicsImpostor): number;
  52190. /**
  52191. * Sets stiffness of the impostor
  52192. * @param impostor impostor to set stiffness on
  52193. * @param stiffness stiffness value from 0 to 1
  52194. */
  52195. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52196. /**
  52197. * Gets velocityIterations of the impostor
  52198. * @param impostor impostor to get velocity iterations from
  52199. * @returns velocityIterations value
  52200. */
  52201. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52202. /**
  52203. * Sets velocityIterations of the impostor
  52204. * @param impostor impostor to set velocity iterations on
  52205. * @param velocityIterations velocityIterations value
  52206. */
  52207. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52208. /**
  52209. * Gets positionIterations of the impostor
  52210. * @param impostor impostor to get position iterations from
  52211. * @returns positionIterations value
  52212. */
  52213. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52214. /**
  52215. * Sets positionIterations of the impostor
  52216. * @param impostor impostor to set position on
  52217. * @param positionIterations positionIterations value
  52218. */
  52219. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52220. /**
  52221. * Append an anchor to a cloth object
  52222. * @param impostor is the cloth impostor to add anchor to
  52223. * @param otherImpostor is the rigid impostor to anchor to
  52224. * @param width ratio across width from 0 to 1
  52225. * @param height ratio up height from 0 to 1
  52226. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52227. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52228. */
  52229. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52230. /**
  52231. * Append an hook to a rope object
  52232. * @param impostor is the rope impostor to add hook to
  52233. * @param otherImpostor is the rigid impostor to hook to
  52234. * @param length ratio along the rope from 0 to 1
  52235. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52236. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52237. */
  52238. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52239. /**
  52240. * Sleeps the physics body and stops it from being active
  52241. * @param impostor impostor to sleep
  52242. */
  52243. sleepBody(impostor: PhysicsImpostor): void;
  52244. /**
  52245. * Activates the physics body
  52246. * @param impostor impostor to activate
  52247. */
  52248. wakeUpBody(impostor: PhysicsImpostor): void;
  52249. /**
  52250. * Updates the distance parameters of the joint
  52251. * @param joint joint to update
  52252. * @param maxDistance maximum distance of the joint
  52253. * @param minDistance minimum distance of the joint
  52254. */
  52255. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52256. /**
  52257. * Sets a motor on the joint
  52258. * @param joint joint to set motor on
  52259. * @param speed speed of the motor
  52260. * @param maxForce maximum force of the motor
  52261. * @param motorIndex index of the motor
  52262. */
  52263. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52264. /**
  52265. * Sets the motors limit
  52266. * @param joint joint to set limit on
  52267. * @param upperLimit upper limit
  52268. * @param lowerLimit lower limit
  52269. */
  52270. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52271. /**
  52272. * Syncs the position and rotation of a mesh with the impostor
  52273. * @param mesh mesh to sync
  52274. * @param impostor impostor to update the mesh with
  52275. */
  52276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52277. /**
  52278. * Gets the radius of the impostor
  52279. * @param impostor impostor to get radius from
  52280. * @returns the radius
  52281. */
  52282. getRadius(impostor: PhysicsImpostor): number;
  52283. /**
  52284. * Gets the box size of the impostor
  52285. * @param impostor impostor to get box size from
  52286. * @param result the resulting box size
  52287. */
  52288. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52289. /**
  52290. * Disposes of the impostor
  52291. */
  52292. dispose(): void;
  52293. /**
  52294. * Does a raycast in the physics world
  52295. * @param from when should the ray start?
  52296. * @param to when should the ray end?
  52297. * @returns PhysicsRaycastResult
  52298. */
  52299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52300. }
  52301. }
  52302. declare module BABYLON {
  52303. interface AbstractScene {
  52304. /**
  52305. * The list of reflection probes added to the scene
  52306. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52307. */
  52308. reflectionProbes: Array<ReflectionProbe>;
  52309. /**
  52310. * Removes the given reflection probe from this scene.
  52311. * @param toRemove The reflection probe to remove
  52312. * @returns The index of the removed reflection probe
  52313. */
  52314. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52315. /**
  52316. * Adds the given reflection probe to this scene.
  52317. * @param newReflectionProbe The reflection probe to add
  52318. */
  52319. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52320. }
  52321. /**
  52322. * Class used to generate realtime reflection / refraction cube textures
  52323. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52324. */
  52325. export class ReflectionProbe {
  52326. /** defines the name of the probe */
  52327. name: string;
  52328. private _scene;
  52329. private _renderTargetTexture;
  52330. private _projectionMatrix;
  52331. private _viewMatrix;
  52332. private _target;
  52333. private _add;
  52334. private _attachedMesh;
  52335. private _invertYAxis;
  52336. /** Gets or sets probe position (center of the cube map) */
  52337. position: Vector3;
  52338. /**
  52339. * Creates a new reflection probe
  52340. * @param name defines the name of the probe
  52341. * @param size defines the texture resolution (for each face)
  52342. * @param scene defines the hosting scene
  52343. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52344. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52345. */
  52346. constructor(
  52347. /** defines the name of the probe */
  52348. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52349. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52350. samples: number;
  52351. /** Gets or sets the refresh rate to use (on every frame by default) */
  52352. refreshRate: number;
  52353. /**
  52354. * Gets the hosting scene
  52355. * @returns a Scene
  52356. */
  52357. getScene(): Scene;
  52358. /** Gets the internal CubeTexture used to render to */
  52359. readonly cubeTexture: RenderTargetTexture;
  52360. /** Gets the list of meshes to render */
  52361. readonly renderList: Nullable<AbstractMesh[]>;
  52362. /**
  52363. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52364. * @param mesh defines the mesh to attach to
  52365. */
  52366. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52367. /**
  52368. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52369. * @param renderingGroupId The rendering group id corresponding to its index
  52370. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52371. */
  52372. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52373. /**
  52374. * Clean all associated resources
  52375. */
  52376. dispose(): void;
  52377. /**
  52378. * Converts the reflection probe information to a readable string for debug purpose.
  52379. * @param fullDetails Supports for multiple levels of logging within scene loading
  52380. * @returns the human readable reflection probe info
  52381. */
  52382. toString(fullDetails?: boolean): string;
  52383. /**
  52384. * Get the class name of the relfection probe.
  52385. * @returns "ReflectionProbe"
  52386. */
  52387. getClassName(): string;
  52388. /**
  52389. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52390. * @returns The JSON representation of the texture
  52391. */
  52392. serialize(): any;
  52393. /**
  52394. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52395. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52396. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52397. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52398. * @returns The parsed reflection probe if successful
  52399. */
  52400. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52401. }
  52402. }
  52403. declare module BABYLON {
  52404. /** @hidden */
  52405. export var _BabylonLoaderRegistered: boolean;
  52406. /**
  52407. * Helps setting up some configuration for the babylon file loader.
  52408. */
  52409. export class BabylonFileLoaderConfiguration {
  52410. /**
  52411. * The loader does not allow injecting custom physix engine into the plugins.
  52412. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52413. * So you could set this variable to your engine import to make it work.
  52414. */
  52415. static LoaderInjectedPhysicsEngine: any;
  52416. }
  52417. }
  52418. declare module BABYLON {
  52419. /**
  52420. * The Physically based simple base material of BJS.
  52421. *
  52422. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52423. * It is used as the base class for both the specGloss and metalRough conventions.
  52424. */
  52425. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52426. /**
  52427. * Number of Simultaneous lights allowed on the material.
  52428. */
  52429. maxSimultaneousLights: number;
  52430. /**
  52431. * If sets to true, disables all the lights affecting the material.
  52432. */
  52433. disableLighting: boolean;
  52434. /**
  52435. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52436. */
  52437. environmentTexture: BaseTexture;
  52438. /**
  52439. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52440. */
  52441. invertNormalMapX: boolean;
  52442. /**
  52443. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52444. */
  52445. invertNormalMapY: boolean;
  52446. /**
  52447. * Normal map used in the model.
  52448. */
  52449. normalTexture: BaseTexture;
  52450. /**
  52451. * Emissivie color used to self-illuminate the model.
  52452. */
  52453. emissiveColor: Color3;
  52454. /**
  52455. * Emissivie texture used to self-illuminate the model.
  52456. */
  52457. emissiveTexture: BaseTexture;
  52458. /**
  52459. * Occlusion Channel Strenght.
  52460. */
  52461. occlusionStrength: number;
  52462. /**
  52463. * Occlusion Texture of the material (adding extra occlusion effects).
  52464. */
  52465. occlusionTexture: BaseTexture;
  52466. /**
  52467. * Defines the alpha limits in alpha test mode.
  52468. */
  52469. alphaCutOff: number;
  52470. /**
  52471. * Gets the current double sided mode.
  52472. */
  52473. /**
  52474. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52475. */
  52476. doubleSided: boolean;
  52477. /**
  52478. * Stores the pre-calculated light information of a mesh in a texture.
  52479. */
  52480. lightmapTexture: BaseTexture;
  52481. /**
  52482. * If true, the light map contains occlusion information instead of lighting info.
  52483. */
  52484. useLightmapAsShadowmap: boolean;
  52485. /**
  52486. * Instantiates a new PBRMaterial instance.
  52487. *
  52488. * @param name The material name
  52489. * @param scene The scene the material will be use in.
  52490. */
  52491. constructor(name: string, scene: Scene);
  52492. getClassName(): string;
  52493. }
  52494. }
  52495. declare module BABYLON {
  52496. /**
  52497. * The PBR material of BJS following the metal roughness convention.
  52498. *
  52499. * This fits to the PBR convention in the GLTF definition:
  52500. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52501. */
  52502. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52503. /**
  52504. * The base color has two different interpretations depending on the value of metalness.
  52505. * When the material is a metal, the base color is the specific measured reflectance value
  52506. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52507. * of the material.
  52508. */
  52509. baseColor: Color3;
  52510. /**
  52511. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52512. * well as opacity information in the alpha channel.
  52513. */
  52514. baseTexture: BaseTexture;
  52515. /**
  52516. * Specifies the metallic scalar value of the material.
  52517. * Can also be used to scale the metalness values of the metallic texture.
  52518. */
  52519. metallic: number;
  52520. /**
  52521. * Specifies the roughness scalar value of the material.
  52522. * Can also be used to scale the roughness values of the metallic texture.
  52523. */
  52524. roughness: number;
  52525. /**
  52526. * Texture containing both the metallic value in the B channel and the
  52527. * roughness value in the G channel to keep better precision.
  52528. */
  52529. metallicRoughnessTexture: BaseTexture;
  52530. /**
  52531. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52532. *
  52533. * @param name The material name
  52534. * @param scene The scene the material will be use in.
  52535. */
  52536. constructor(name: string, scene: Scene);
  52537. /**
  52538. * Return the currrent class name of the material.
  52539. */
  52540. getClassName(): string;
  52541. /**
  52542. * Makes a duplicate of the current material.
  52543. * @param name - name to use for the new material.
  52544. */
  52545. clone(name: string): PBRMetallicRoughnessMaterial;
  52546. /**
  52547. * Serialize the material to a parsable JSON object.
  52548. */
  52549. serialize(): any;
  52550. /**
  52551. * Parses a JSON object correponding to the serialize function.
  52552. */
  52553. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * The PBR material of BJS following the specular glossiness convention.
  52559. *
  52560. * This fits to the PBR convention in the GLTF definition:
  52561. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52562. */
  52563. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52564. /**
  52565. * Specifies the diffuse color of the material.
  52566. */
  52567. diffuseColor: Color3;
  52568. /**
  52569. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52570. * channel.
  52571. */
  52572. diffuseTexture: BaseTexture;
  52573. /**
  52574. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52575. */
  52576. specularColor: Color3;
  52577. /**
  52578. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52579. */
  52580. glossiness: number;
  52581. /**
  52582. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52583. */
  52584. specularGlossinessTexture: BaseTexture;
  52585. /**
  52586. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52587. *
  52588. * @param name The material name
  52589. * @param scene The scene the material will be use in.
  52590. */
  52591. constructor(name: string, scene: Scene);
  52592. /**
  52593. * Return the currrent class name of the material.
  52594. */
  52595. getClassName(): string;
  52596. /**
  52597. * Makes a duplicate of the current material.
  52598. * @param name - name to use for the new material.
  52599. */
  52600. clone(name: string): PBRSpecularGlossinessMaterial;
  52601. /**
  52602. * Serialize the material to a parsable JSON object.
  52603. */
  52604. serialize(): any;
  52605. /**
  52606. * Parses a JSON object correponding to the serialize function.
  52607. */
  52608. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52609. }
  52610. }
  52611. declare module BABYLON {
  52612. /**
  52613. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52614. * It can help converting any input color in a desired output one. This can then be used to create effects
  52615. * from sepia, black and white to sixties or futuristic rendering...
  52616. *
  52617. * The only supported format is currently 3dl.
  52618. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52619. */
  52620. export class ColorGradingTexture extends BaseTexture {
  52621. /**
  52622. * The current texture matrix. (will always be identity in color grading texture)
  52623. */
  52624. private _textureMatrix;
  52625. /**
  52626. * The texture URL.
  52627. */
  52628. url: string;
  52629. /**
  52630. * Empty line regex stored for GC.
  52631. */
  52632. private static _noneEmptyLineRegex;
  52633. private _engine;
  52634. /**
  52635. * Instantiates a ColorGradingTexture from the following parameters.
  52636. *
  52637. * @param url The location of the color gradind data (currently only supporting 3dl)
  52638. * @param scene The scene the texture will be used in
  52639. */
  52640. constructor(url: string, scene: Scene);
  52641. /**
  52642. * Returns the texture matrix used in most of the material.
  52643. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52644. */
  52645. getTextureMatrix(): Matrix;
  52646. /**
  52647. * Occurs when the file being loaded is a .3dl LUT file.
  52648. */
  52649. private load3dlTexture;
  52650. /**
  52651. * Starts the loading process of the texture.
  52652. */
  52653. private loadTexture;
  52654. /**
  52655. * Clones the color gradind texture.
  52656. */
  52657. clone(): ColorGradingTexture;
  52658. /**
  52659. * Called during delayed load for textures.
  52660. */
  52661. delayLoad(): void;
  52662. /**
  52663. * Parses a color grading texture serialized by Babylon.
  52664. * @param parsedTexture The texture information being parsedTexture
  52665. * @param scene The scene to load the texture in
  52666. * @param rootUrl The root url of the data assets to load
  52667. * @return A color gradind texture
  52668. */
  52669. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52670. /**
  52671. * Serializes the LUT texture to json format.
  52672. */
  52673. serialize(): any;
  52674. }
  52675. }
  52676. declare module BABYLON {
  52677. /**
  52678. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52679. */
  52680. export class EquiRectangularCubeTexture extends BaseTexture {
  52681. /** The six faces of the cube. */
  52682. private static _FacesMapping;
  52683. private _noMipmap;
  52684. private _onLoad;
  52685. private _onError;
  52686. /** The size of the cubemap. */
  52687. private _size;
  52688. /** The buffer of the image. */
  52689. private _buffer;
  52690. /** The width of the input image. */
  52691. private _width;
  52692. /** The height of the input image. */
  52693. private _height;
  52694. /** The URL to the image. */
  52695. url: string;
  52696. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52697. coordinatesMode: number;
  52698. /**
  52699. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52700. * @param url The location of the image
  52701. * @param scene The scene the texture will be used in
  52702. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52703. * @param noMipmap Forces to not generate the mipmap if true
  52704. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52705. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52706. * @param onLoad — defines a callback called when texture is loaded
  52707. * @param onError — defines a callback called if there is an error
  52708. */
  52709. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52710. /**
  52711. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52712. */
  52713. private loadImage;
  52714. /**
  52715. * Convert the image buffer into a cubemap and create a CubeTexture.
  52716. */
  52717. private loadTexture;
  52718. /**
  52719. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52720. * @param buffer The ArrayBuffer that should be converted.
  52721. * @returns The buffer as Float32Array.
  52722. */
  52723. private getFloat32ArrayFromArrayBuffer;
  52724. /**
  52725. * Get the current class name of the texture useful for serialization or dynamic coding.
  52726. * @returns "EquiRectangularCubeTexture"
  52727. */
  52728. getClassName(): string;
  52729. /**
  52730. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52731. * @returns A clone of the current EquiRectangularCubeTexture.
  52732. */
  52733. clone(): EquiRectangularCubeTexture;
  52734. }
  52735. }
  52736. declare module BABYLON {
  52737. /**
  52738. * Based on jsTGALoader - Javascript loader for TGA file
  52739. * By Vincent Thibault
  52740. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52741. */
  52742. export class TGATools {
  52743. private static _TYPE_INDEXED;
  52744. private static _TYPE_RGB;
  52745. private static _TYPE_GREY;
  52746. private static _TYPE_RLE_INDEXED;
  52747. private static _TYPE_RLE_RGB;
  52748. private static _TYPE_RLE_GREY;
  52749. private static _ORIGIN_MASK;
  52750. private static _ORIGIN_SHIFT;
  52751. private static _ORIGIN_BL;
  52752. private static _ORIGIN_BR;
  52753. private static _ORIGIN_UL;
  52754. private static _ORIGIN_UR;
  52755. /**
  52756. * Gets the header of a TGA file
  52757. * @param data defines the TGA data
  52758. * @returns the header
  52759. */
  52760. static GetTGAHeader(data: Uint8Array): any;
  52761. /**
  52762. * Uploads TGA content to a Babylon Texture
  52763. * @hidden
  52764. */
  52765. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52766. /** @hidden */
  52767. 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;
  52768. /** @hidden */
  52769. 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;
  52770. /** @hidden */
  52771. 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;
  52772. /** @hidden */
  52773. 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;
  52774. /** @hidden */
  52775. 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;
  52776. /** @hidden */
  52777. 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;
  52778. }
  52779. }
  52780. declare module BABYLON {
  52781. /**
  52782. * Implementation of the TGA Texture Loader.
  52783. * @hidden
  52784. */
  52785. export class _TGATextureLoader implements IInternalTextureLoader {
  52786. /**
  52787. * Defines wether the loader supports cascade loading the different faces.
  52788. */
  52789. readonly supportCascades: boolean;
  52790. /**
  52791. * This returns if the loader support the current file information.
  52792. * @param extension defines the file extension of the file being loaded
  52793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52794. * @param fallback defines the fallback internal texture if any
  52795. * @param isBase64 defines whether the texture is encoded as a base64
  52796. * @param isBuffer defines whether the texture data are stored as a buffer
  52797. * @returns true if the loader can load the specified file
  52798. */
  52799. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52800. /**
  52801. * Transform the url before loading if required.
  52802. * @param rootUrl the url of the texture
  52803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52804. * @returns the transformed texture
  52805. */
  52806. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52807. /**
  52808. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52809. * @param rootUrl the url of the texture
  52810. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52811. * @returns the fallback texture
  52812. */
  52813. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52814. /**
  52815. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52816. * @param data contains the texture data
  52817. * @param texture defines the BabylonJS internal texture
  52818. * @param createPolynomials will be true if polynomials have been requested
  52819. * @param onLoad defines the callback to trigger once the texture is ready
  52820. * @param onError defines the callback to trigger in case of error
  52821. */
  52822. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52823. /**
  52824. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52825. * @param data contains the texture data
  52826. * @param texture defines the BabylonJS internal texture
  52827. * @param callback defines the method to call once ready to upload
  52828. */
  52829. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52830. }
  52831. }
  52832. declare module BABYLON {
  52833. /**
  52834. * Info about the .basis files
  52835. */
  52836. class BasisFileInfo {
  52837. /**
  52838. * If the file has alpha
  52839. */
  52840. hasAlpha: boolean;
  52841. /**
  52842. * Info about each image of the basis file
  52843. */
  52844. images: Array<{
  52845. levels: Array<{
  52846. width: number;
  52847. height: number;
  52848. transcodedPixels: ArrayBufferView;
  52849. }>;
  52850. }>;
  52851. }
  52852. /**
  52853. * Result of transcoding a basis file
  52854. */
  52855. class TranscodeResult {
  52856. /**
  52857. * Info about the .basis file
  52858. */
  52859. fileInfo: BasisFileInfo;
  52860. /**
  52861. * Format to use when loading the file
  52862. */
  52863. format: number;
  52864. }
  52865. /**
  52866. * Configuration options for the Basis transcoder
  52867. */
  52868. export class BasisTranscodeConfiguration {
  52869. /**
  52870. * Supported compression formats used to determine the supported output format of the transcoder
  52871. */
  52872. supportedCompressionFormats?: {
  52873. /**
  52874. * etc1 compression format
  52875. */
  52876. etc1?: boolean;
  52877. /**
  52878. * s3tc compression format
  52879. */
  52880. s3tc?: boolean;
  52881. /**
  52882. * pvrtc compression format
  52883. */
  52884. pvrtc?: boolean;
  52885. /**
  52886. * etc2 compression format
  52887. */
  52888. etc2?: boolean;
  52889. };
  52890. /**
  52891. * If mipmap levels should be loaded for transcoded images (Default: true)
  52892. */
  52893. loadMipmapLevels?: boolean;
  52894. /**
  52895. * Index of a single image to load (Default: all images)
  52896. */
  52897. loadSingleImage?: number;
  52898. }
  52899. /**
  52900. * Used to load .Basis files
  52901. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52902. */
  52903. export class BasisTools {
  52904. private static _IgnoreSupportedFormats;
  52905. /**
  52906. * URL to use when loading the basis transcoder
  52907. */
  52908. static JSModuleURL: string;
  52909. /**
  52910. * URL to use when loading the wasm module for the transcoder
  52911. */
  52912. static WasmModuleURL: string;
  52913. /**
  52914. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52915. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52916. * @returns internal format corresponding to the Basis format
  52917. */
  52918. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52919. private static _WorkerPromise;
  52920. private static _Worker;
  52921. private static _actionId;
  52922. private static _CreateWorkerAsync;
  52923. /**
  52924. * Transcodes a loaded image file to compressed pixel data
  52925. * @param imageData image data to transcode
  52926. * @param config configuration options for the transcoding
  52927. * @returns a promise resulting in the transcoded image
  52928. */
  52929. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52930. /**
  52931. * Loads a texture from the transcode result
  52932. * @param texture texture load to
  52933. * @param transcodeResult the result of transcoding the basis file to load from
  52934. */
  52935. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /**
  52940. * Loader for .basis file format
  52941. */
  52942. export class _BasisTextureLoader implements IInternalTextureLoader {
  52943. /**
  52944. * Defines whether the loader supports cascade loading the different faces.
  52945. */
  52946. readonly supportCascades: boolean;
  52947. /**
  52948. * This returns if the loader support the current file information.
  52949. * @param extension defines the file extension of the file being loaded
  52950. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52951. * @param fallback defines the fallback internal texture if any
  52952. * @param isBase64 defines whether the texture is encoded as a base64
  52953. * @param isBuffer defines whether the texture data are stored as a buffer
  52954. * @returns true if the loader can load the specified file
  52955. */
  52956. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52957. /**
  52958. * Transform the url before loading if required.
  52959. * @param rootUrl the url of the texture
  52960. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52961. * @returns the transformed texture
  52962. */
  52963. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52964. /**
  52965. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52966. * @param rootUrl the url of the texture
  52967. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52968. * @returns the fallback texture
  52969. */
  52970. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52971. /**
  52972. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52973. * @param data contains the texture data
  52974. * @param texture defines the BabylonJS internal texture
  52975. * @param createPolynomials will be true if polynomials have been requested
  52976. * @param onLoad defines the callback to trigger once the texture is ready
  52977. * @param onError defines the callback to trigger in case of error
  52978. */
  52979. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52980. /**
  52981. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52982. * @param data contains the texture data
  52983. * @param texture defines the BabylonJS internal texture
  52984. * @param callback defines the method to call once ready to upload
  52985. */
  52986. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52987. }
  52988. }
  52989. declare module BABYLON {
  52990. /**
  52991. * 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.
  52992. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52993. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52994. */
  52995. export class CustomProceduralTexture extends ProceduralTexture {
  52996. private _animate;
  52997. private _time;
  52998. private _config;
  52999. private _texturePath;
  53000. /**
  53001. * Instantiates a new Custom Procedural Texture.
  53002. * 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.
  53003. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53004. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53005. * @param name Define the name of the texture
  53006. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53007. * @param size Define the size of the texture to create
  53008. * @param scene Define the scene the texture belongs to
  53009. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53010. * @param generateMipMaps Define if the texture should creates mip maps or not
  53011. */
  53012. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53013. private _loadJson;
  53014. /**
  53015. * Is the texture ready to be used ? (rendered at least once)
  53016. * @returns true if ready, otherwise, false.
  53017. */
  53018. isReady(): boolean;
  53019. /**
  53020. * Render the texture to its associated render target.
  53021. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53022. */
  53023. render(useCameraPostProcess?: boolean): void;
  53024. /**
  53025. * Update the list of dependant textures samplers in the shader.
  53026. */
  53027. updateTextures(): void;
  53028. /**
  53029. * Update the uniform values of the procedural texture in the shader.
  53030. */
  53031. updateShaderUniforms(): void;
  53032. /**
  53033. * Define if the texture animates or not.
  53034. */
  53035. animate: boolean;
  53036. }
  53037. }
  53038. declare module BABYLON {
  53039. /** @hidden */
  53040. export var noisePixelShader: {
  53041. name: string;
  53042. shader: string;
  53043. };
  53044. }
  53045. declare module BABYLON {
  53046. /**
  53047. * Class used to generate noise procedural textures
  53048. */
  53049. export class NoiseProceduralTexture extends ProceduralTexture {
  53050. private _time;
  53051. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53052. brightness: number;
  53053. /** Defines the number of octaves to process */
  53054. octaves: number;
  53055. /** Defines the level of persistence (0.8 by default) */
  53056. persistence: number;
  53057. /** Gets or sets animation speed factor (default is 1) */
  53058. animationSpeedFactor: number;
  53059. /**
  53060. * Creates a new NoiseProceduralTexture
  53061. * @param name defines the name fo the texture
  53062. * @param size defines the size of the texture (default is 256)
  53063. * @param scene defines the hosting scene
  53064. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53065. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53066. */
  53067. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53068. private _updateShaderUniforms;
  53069. protected _getDefines(): string;
  53070. /** Generate the current state of the procedural texture */
  53071. render(useCameraPostProcess?: boolean): void;
  53072. /**
  53073. * Serializes this noise procedural texture
  53074. * @returns a serialized noise procedural texture object
  53075. */
  53076. serialize(): any;
  53077. /**
  53078. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53079. * @param parsedTexture defines parsed texture data
  53080. * @param scene defines the current scene
  53081. * @param rootUrl defines the root URL containing noise procedural texture information
  53082. * @returns a parsed NoiseProceduralTexture
  53083. */
  53084. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53085. }
  53086. }
  53087. declare module BABYLON {
  53088. /**
  53089. * Raw cube texture where the raw buffers are passed in
  53090. */
  53091. export class RawCubeTexture extends CubeTexture {
  53092. /**
  53093. * Creates a cube texture where the raw buffers are passed in.
  53094. * @param scene defines the scene the texture is attached to
  53095. * @param data defines the array of data to use to create each face
  53096. * @param size defines the size of the textures
  53097. * @param format defines the format of the data
  53098. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53099. * @param generateMipMaps defines if the engine should generate the mip levels
  53100. * @param invertY defines if data must be stored with Y axis inverted
  53101. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53102. * @param compression defines the compression used (null by default)
  53103. */
  53104. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53105. /**
  53106. * Updates the raw cube texture.
  53107. * @param data defines the data to store
  53108. * @param format defines the data format
  53109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53110. * @param invertY defines if data must be stored with Y axis inverted
  53111. * @param compression defines the compression used (null by default)
  53112. * @param level defines which level of the texture to update
  53113. */
  53114. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53115. /**
  53116. * Updates a raw cube texture with RGBD encoded data.
  53117. * @param data defines the array of data [mipmap][face] to use to create each face
  53118. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53119. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53120. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53121. * @returns a promsie that resolves when the operation is complete
  53122. */
  53123. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53124. /**
  53125. * Clones the raw cube texture.
  53126. * @return a new cube texture
  53127. */
  53128. clone(): CubeTexture;
  53129. /** @hidden */
  53130. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53131. }
  53132. }
  53133. declare module BABYLON {
  53134. /**
  53135. * Class used to store 3D textures containing user data
  53136. */
  53137. export class RawTexture3D extends Texture {
  53138. /** Gets or sets the texture format to use */
  53139. format: number;
  53140. private _engine;
  53141. /**
  53142. * Create a new RawTexture3D
  53143. * @param data defines the data of the texture
  53144. * @param width defines the width of the texture
  53145. * @param height defines the height of the texture
  53146. * @param depth defines the depth of the texture
  53147. * @param format defines the texture format to use
  53148. * @param scene defines the hosting scene
  53149. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53150. * @param invertY defines if texture must be stored with Y axis inverted
  53151. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53152. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53153. */
  53154. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53155. /** Gets or sets the texture format to use */
  53156. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53157. /**
  53158. * Update the texture with new data
  53159. * @param data defines the data to store in the texture
  53160. */
  53161. update(data: ArrayBufferView): void;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * Class used to store 2D array textures containing user data
  53167. */
  53168. export class RawTexture2DArray extends Texture {
  53169. /** Gets or sets the texture format to use */
  53170. format: number;
  53171. private _engine;
  53172. /**
  53173. * Create a new RawTexture2DArray
  53174. * @param data defines the data of the texture
  53175. * @param width defines the width of the texture
  53176. * @param height defines the height of the texture
  53177. * @param depth defines the number of layers of the texture
  53178. * @param format defines the texture format to use
  53179. * @param scene defines the hosting scene
  53180. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53181. * @param invertY defines if texture must be stored with Y axis inverted
  53182. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53183. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53184. */
  53185. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53186. /** Gets or sets the texture format to use */
  53187. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53188. /**
  53189. * Update the texture with new data
  53190. * @param data defines the data to store in the texture
  53191. */
  53192. update(data: ArrayBufferView): void;
  53193. }
  53194. }
  53195. declare module BABYLON {
  53196. /**
  53197. * Creates a refraction texture used by refraction channel of the standard material.
  53198. * It is like a mirror but to see through a material.
  53199. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53200. */
  53201. export class RefractionTexture extends RenderTargetTexture {
  53202. /**
  53203. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53204. * 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.
  53205. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53206. */
  53207. refractionPlane: Plane;
  53208. /**
  53209. * Define how deep under the surface we should see.
  53210. */
  53211. depth: number;
  53212. /**
  53213. * Creates a refraction texture used by refraction channel of the standard material.
  53214. * It is like a mirror but to see through a material.
  53215. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53216. * @param name Define the texture name
  53217. * @param size Define the size of the underlying texture
  53218. * @param scene Define the scene the refraction belongs to
  53219. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53220. */
  53221. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53222. /**
  53223. * Clone the refraction texture.
  53224. * @returns the cloned texture
  53225. */
  53226. clone(): RefractionTexture;
  53227. /**
  53228. * Serialize the texture to a JSON representation you could use in Parse later on
  53229. * @returns the serialized JSON representation
  53230. */
  53231. serialize(): any;
  53232. }
  53233. }
  53234. declare module BABYLON {
  53235. /**
  53236. * Defines the options related to the creation of an HtmlElementTexture
  53237. */
  53238. export interface IHtmlElementTextureOptions {
  53239. /**
  53240. * Defines wether mip maps should be created or not.
  53241. */
  53242. generateMipMaps?: boolean;
  53243. /**
  53244. * Defines the sampling mode of the texture.
  53245. */
  53246. samplingMode?: number;
  53247. /**
  53248. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53249. */
  53250. engine: Nullable<ThinEngine>;
  53251. /**
  53252. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53253. */
  53254. scene: Nullable<Scene>;
  53255. }
  53256. /**
  53257. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53258. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53259. * is automatically managed.
  53260. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53261. * in your application.
  53262. *
  53263. * As the update is not automatic, you need to call them manually.
  53264. */
  53265. export class HtmlElementTexture extends BaseTexture {
  53266. /**
  53267. * The texture URL.
  53268. */
  53269. element: HTMLVideoElement | HTMLCanvasElement;
  53270. private static readonly DefaultOptions;
  53271. private _textureMatrix;
  53272. private _engine;
  53273. private _isVideo;
  53274. private _generateMipMaps;
  53275. private _samplingMode;
  53276. /**
  53277. * Instantiates a HtmlElementTexture from the following parameters.
  53278. *
  53279. * @param name Defines the name of the texture
  53280. * @param element Defines the video or canvas the texture is filled with
  53281. * @param options Defines the other none mandatory texture creation options
  53282. */
  53283. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53284. private _createInternalTexture;
  53285. /**
  53286. * Returns the texture matrix used in most of the material.
  53287. */
  53288. getTextureMatrix(): Matrix;
  53289. /**
  53290. * Updates the content of the texture.
  53291. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53292. */
  53293. update(invertY?: Nullable<boolean>): void;
  53294. }
  53295. }
  53296. declare module BABYLON {
  53297. /**
  53298. * Enum used to define the target of a block
  53299. */
  53300. export enum NodeMaterialBlockTargets {
  53301. /** Vertex shader */
  53302. Vertex = 1,
  53303. /** Fragment shader */
  53304. Fragment = 2,
  53305. /** Neutral */
  53306. Neutral = 4,
  53307. /** Vertex and Fragment */
  53308. VertexAndFragment = 3
  53309. }
  53310. }
  53311. declare module BABYLON {
  53312. /**
  53313. * Defines the kind of connection point for node based material
  53314. */
  53315. export enum NodeMaterialBlockConnectionPointTypes {
  53316. /** Float */
  53317. Float = 1,
  53318. /** Int */
  53319. Int = 2,
  53320. /** Vector2 */
  53321. Vector2 = 4,
  53322. /** Vector3 */
  53323. Vector3 = 8,
  53324. /** Vector4 */
  53325. Vector4 = 16,
  53326. /** Color3 */
  53327. Color3 = 32,
  53328. /** Color4 */
  53329. Color4 = 64,
  53330. /** Matrix */
  53331. Matrix = 128,
  53332. /** Detect type based on connection */
  53333. AutoDetect = 1024,
  53334. /** Output type that will be defined by input type */
  53335. BasedOnInput = 2048
  53336. }
  53337. }
  53338. declare module BABYLON {
  53339. /**
  53340. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53341. */
  53342. export enum NodeMaterialBlockConnectionPointMode {
  53343. /** Value is an uniform */
  53344. Uniform = 0,
  53345. /** Value is a mesh attribute */
  53346. Attribute = 1,
  53347. /** Value is a varying between vertex and fragment shaders */
  53348. Varying = 2,
  53349. /** Mode is undefined */
  53350. Undefined = 3
  53351. }
  53352. }
  53353. declare module BABYLON {
  53354. /**
  53355. * Enum used to define system values e.g. values automatically provided by the system
  53356. */
  53357. export enum NodeMaterialSystemValues {
  53358. /** World */
  53359. World = 1,
  53360. /** View */
  53361. View = 2,
  53362. /** Projection */
  53363. Projection = 3,
  53364. /** ViewProjection */
  53365. ViewProjection = 4,
  53366. /** WorldView */
  53367. WorldView = 5,
  53368. /** WorldViewProjection */
  53369. WorldViewProjection = 6,
  53370. /** CameraPosition */
  53371. CameraPosition = 7,
  53372. /** Fog Color */
  53373. FogColor = 8,
  53374. /** Delta time */
  53375. DeltaTime = 9
  53376. }
  53377. }
  53378. declare module BABYLON {
  53379. /**
  53380. * Root class for all node material optimizers
  53381. */
  53382. export class NodeMaterialOptimizer {
  53383. /**
  53384. * Function used to optimize a NodeMaterial graph
  53385. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53386. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53387. */
  53388. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53389. }
  53390. }
  53391. declare module BABYLON {
  53392. /**
  53393. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53394. */
  53395. export class TransformBlock extends NodeMaterialBlock {
  53396. /**
  53397. * Defines the value to use to complement W value to transform it to a Vector4
  53398. */
  53399. complementW: number;
  53400. /**
  53401. * Defines the value to use to complement z value to transform it to a Vector4
  53402. */
  53403. complementZ: number;
  53404. /**
  53405. * Creates a new TransformBlock
  53406. * @param name defines the block name
  53407. */
  53408. constructor(name: string);
  53409. /**
  53410. * Gets the current class name
  53411. * @returns the class name
  53412. */
  53413. getClassName(): string;
  53414. /**
  53415. * Gets the vector input
  53416. */
  53417. readonly vector: NodeMaterialConnectionPoint;
  53418. /**
  53419. * Gets the output component
  53420. */
  53421. readonly output: NodeMaterialConnectionPoint;
  53422. /**
  53423. * Gets the matrix transform input
  53424. */
  53425. readonly transform: NodeMaterialConnectionPoint;
  53426. protected _buildBlock(state: NodeMaterialBuildState): this;
  53427. serialize(): any;
  53428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53429. protected _dumpPropertiesCode(): string;
  53430. }
  53431. }
  53432. declare module BABYLON {
  53433. /**
  53434. * Block used to output the vertex position
  53435. */
  53436. export class VertexOutputBlock extends NodeMaterialBlock {
  53437. /**
  53438. * Creates a new VertexOutputBlock
  53439. * @param name defines the block name
  53440. */
  53441. constructor(name: string);
  53442. /**
  53443. * Gets the current class name
  53444. * @returns the class name
  53445. */
  53446. getClassName(): string;
  53447. /**
  53448. * Gets the vector input component
  53449. */
  53450. readonly vector: NodeMaterialConnectionPoint;
  53451. protected _buildBlock(state: NodeMaterialBuildState): this;
  53452. }
  53453. }
  53454. declare module BABYLON {
  53455. /**
  53456. * Block used to output the final color
  53457. */
  53458. export class FragmentOutputBlock extends NodeMaterialBlock {
  53459. /**
  53460. * Create a new FragmentOutputBlock
  53461. * @param name defines the block name
  53462. */
  53463. constructor(name: string);
  53464. /**
  53465. * Gets the current class name
  53466. * @returns the class name
  53467. */
  53468. getClassName(): string;
  53469. /**
  53470. * Gets the rgba input component
  53471. */
  53472. readonly rgba: NodeMaterialConnectionPoint;
  53473. /**
  53474. * Gets the rgb input component
  53475. */
  53476. readonly rgb: NodeMaterialConnectionPoint;
  53477. /**
  53478. * Gets the a input component
  53479. */
  53480. readonly a: NodeMaterialConnectionPoint;
  53481. protected _buildBlock(state: NodeMaterialBuildState): this;
  53482. }
  53483. }
  53484. declare module BABYLON {
  53485. /**
  53486. * Block used to read a reflection texture from a sampler
  53487. */
  53488. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53489. private _define3DName;
  53490. private _defineCubicName;
  53491. private _defineExplicitName;
  53492. private _defineProjectionName;
  53493. private _defineLocalCubicName;
  53494. private _defineSphericalName;
  53495. private _definePlanarName;
  53496. private _defineEquirectangularName;
  53497. private _defineMirroredEquirectangularFixedName;
  53498. private _defineEquirectangularFixedName;
  53499. private _defineSkyboxName;
  53500. private _cubeSamplerName;
  53501. private _2DSamplerName;
  53502. private _positionUVWName;
  53503. private _directionWName;
  53504. private _reflectionCoordsName;
  53505. private _reflection2DCoordsName;
  53506. private _reflectionColorName;
  53507. private _reflectionMatrixName;
  53508. /**
  53509. * Gets or sets the texture associated with the node
  53510. */
  53511. texture: Nullable<BaseTexture>;
  53512. /**
  53513. * Create a new TextureBlock
  53514. * @param name defines the block name
  53515. */
  53516. constructor(name: string);
  53517. /**
  53518. * Gets the current class name
  53519. * @returns the class name
  53520. */
  53521. getClassName(): string;
  53522. /**
  53523. * Gets the world position input component
  53524. */
  53525. readonly position: NodeMaterialConnectionPoint;
  53526. /**
  53527. * Gets the world position input component
  53528. */
  53529. readonly worldPosition: NodeMaterialConnectionPoint;
  53530. /**
  53531. * Gets the world normal input component
  53532. */
  53533. readonly worldNormal: NodeMaterialConnectionPoint;
  53534. /**
  53535. * Gets the world input component
  53536. */
  53537. readonly world: NodeMaterialConnectionPoint;
  53538. /**
  53539. * Gets the camera (or eye) position component
  53540. */
  53541. readonly cameraPosition: NodeMaterialConnectionPoint;
  53542. /**
  53543. * Gets the view input component
  53544. */
  53545. readonly view: NodeMaterialConnectionPoint;
  53546. /**
  53547. * Gets the rgb output component
  53548. */
  53549. readonly rgb: NodeMaterialConnectionPoint;
  53550. /**
  53551. * Gets the r output component
  53552. */
  53553. readonly r: NodeMaterialConnectionPoint;
  53554. /**
  53555. * Gets the g output component
  53556. */
  53557. readonly g: NodeMaterialConnectionPoint;
  53558. /**
  53559. * Gets the b output component
  53560. */
  53561. readonly b: NodeMaterialConnectionPoint;
  53562. autoConfigure(material: NodeMaterial): void;
  53563. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53564. isReady(): boolean;
  53565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53566. private _injectVertexCode;
  53567. private _writeOutput;
  53568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53569. protected _dumpPropertiesCode(): string;
  53570. serialize(): any;
  53571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53572. }
  53573. }
  53574. declare module BABYLON {
  53575. /**
  53576. * Interface used to configure the node material editor
  53577. */
  53578. export interface INodeMaterialEditorOptions {
  53579. /** Define the URl to load node editor script */
  53580. editorURL?: string;
  53581. }
  53582. /** @hidden */
  53583. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53584. /** BONES */
  53585. NUM_BONE_INFLUENCERS: number;
  53586. BonesPerMesh: number;
  53587. BONETEXTURE: boolean;
  53588. /** MORPH TARGETS */
  53589. MORPHTARGETS: boolean;
  53590. MORPHTARGETS_NORMAL: boolean;
  53591. MORPHTARGETS_TANGENT: boolean;
  53592. MORPHTARGETS_UV: boolean;
  53593. NUM_MORPH_INFLUENCERS: number;
  53594. /** IMAGE PROCESSING */
  53595. IMAGEPROCESSING: boolean;
  53596. VIGNETTE: boolean;
  53597. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53598. VIGNETTEBLENDMODEOPAQUE: boolean;
  53599. TONEMAPPING: boolean;
  53600. TONEMAPPING_ACES: boolean;
  53601. CONTRAST: boolean;
  53602. EXPOSURE: boolean;
  53603. COLORCURVES: boolean;
  53604. COLORGRADING: boolean;
  53605. COLORGRADING3D: boolean;
  53606. SAMPLER3DGREENDEPTH: boolean;
  53607. SAMPLER3DBGRMAP: boolean;
  53608. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53609. /** MISC. */
  53610. BUMPDIRECTUV: number;
  53611. constructor();
  53612. setValue(name: string, value: boolean): void;
  53613. }
  53614. /**
  53615. * Class used to configure NodeMaterial
  53616. */
  53617. export interface INodeMaterialOptions {
  53618. /**
  53619. * Defines if blocks should emit comments
  53620. */
  53621. emitComments: boolean;
  53622. }
  53623. /**
  53624. * Class used to create a node based material built by assembling shader blocks
  53625. */
  53626. export class NodeMaterial extends PushMaterial {
  53627. private static _BuildIdGenerator;
  53628. private _options;
  53629. private _vertexCompilationState;
  53630. private _fragmentCompilationState;
  53631. private _sharedData;
  53632. private _buildId;
  53633. private _buildWasSuccessful;
  53634. private _cachedWorldViewMatrix;
  53635. private _cachedWorldViewProjectionMatrix;
  53636. private _optimizers;
  53637. private _animationFrame;
  53638. /** Define the URl to load node editor script */
  53639. static EditorURL: string;
  53640. private BJSNODEMATERIALEDITOR;
  53641. /** Get the inspector from bundle or global */
  53642. private _getGlobalNodeMaterialEditor;
  53643. /**
  53644. * Gets or sets data used by visual editor
  53645. * @see https://nme.babylonjs.com
  53646. */
  53647. editorData: any;
  53648. /**
  53649. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  53650. */
  53651. ignoreAlpha: boolean;
  53652. /**
  53653. * Defines the maximum number of lights that can be used in the material
  53654. */
  53655. maxSimultaneousLights: number;
  53656. /**
  53657. * Observable raised when the material is built
  53658. */
  53659. onBuildObservable: Observable<NodeMaterial>;
  53660. /**
  53661. * Gets or sets the root nodes of the material vertex shader
  53662. */
  53663. _vertexOutputNodes: NodeMaterialBlock[];
  53664. /**
  53665. * Gets or sets the root nodes of the material fragment (pixel) shader
  53666. */
  53667. _fragmentOutputNodes: NodeMaterialBlock[];
  53668. /** Gets or sets options to control the node material overall behavior */
  53669. options: INodeMaterialOptions;
  53670. /**
  53671. * Default configuration related to image processing available in the standard Material.
  53672. */
  53673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53674. /**
  53675. * Gets the image processing configuration used either in this material.
  53676. */
  53677. /**
  53678. * Sets the Default image processing configuration used either in the this material.
  53679. *
  53680. * If sets to null, the scene one is in use.
  53681. */
  53682. imageProcessingConfiguration: ImageProcessingConfiguration;
  53683. /**
  53684. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53685. */
  53686. attachedBlocks: NodeMaterialBlock[];
  53687. /**
  53688. * Create a new node based material
  53689. * @param name defines the material name
  53690. * @param scene defines the hosting scene
  53691. * @param options defines creation option
  53692. */
  53693. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53694. /**
  53695. * Gets the current class name of the material e.g. "NodeMaterial"
  53696. * @returns the class name
  53697. */
  53698. getClassName(): string;
  53699. /**
  53700. * Keep track of the image processing observer to allow dispose and replace.
  53701. */
  53702. private _imageProcessingObserver;
  53703. /**
  53704. * Attaches a new image processing configuration to the Standard Material.
  53705. * @param configuration
  53706. */
  53707. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53708. /**
  53709. * Get a block by its name
  53710. * @param name defines the name of the block to retrieve
  53711. * @returns the required block or null if not found
  53712. */
  53713. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53714. /**
  53715. * Get a block by its name
  53716. * @param predicate defines the predicate used to find the good candidate
  53717. * @returns the required block or null if not found
  53718. */
  53719. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53720. /**
  53721. * Get an input block by its name
  53722. * @param predicate defines the predicate used to find the good candidate
  53723. * @returns the required input block or null if not found
  53724. */
  53725. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53726. /**
  53727. * Gets the list of input blocks attached to this material
  53728. * @returns an array of InputBlocks
  53729. */
  53730. getInputBlocks(): InputBlock[];
  53731. /**
  53732. * Adds a new optimizer to the list of optimizers
  53733. * @param optimizer defines the optimizers to add
  53734. * @returns the current material
  53735. */
  53736. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53737. /**
  53738. * Remove an optimizer from the list of optimizers
  53739. * @param optimizer defines the optimizers to remove
  53740. * @returns the current material
  53741. */
  53742. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53743. /**
  53744. * Add a new block to the list of output nodes
  53745. * @param node defines the node to add
  53746. * @returns the current material
  53747. */
  53748. addOutputNode(node: NodeMaterialBlock): this;
  53749. /**
  53750. * Remove a block from the list of root nodes
  53751. * @param node defines the node to remove
  53752. * @returns the current material
  53753. */
  53754. removeOutputNode(node: NodeMaterialBlock): this;
  53755. private _addVertexOutputNode;
  53756. private _removeVertexOutputNode;
  53757. private _addFragmentOutputNode;
  53758. private _removeFragmentOutputNode;
  53759. /**
  53760. * Specifies if the material will require alpha blending
  53761. * @returns a boolean specifying if alpha blending is needed
  53762. */
  53763. needAlphaBlending(): boolean;
  53764. /**
  53765. * Specifies if this material should be rendered in alpha test mode
  53766. * @returns a boolean specifying if an alpha test is needed.
  53767. */
  53768. needAlphaTesting(): boolean;
  53769. private _initializeBlock;
  53770. private _resetDualBlocks;
  53771. /**
  53772. * Build the material and generates the inner effect
  53773. * @param verbose defines if the build should log activity
  53774. */
  53775. build(verbose?: boolean): void;
  53776. /**
  53777. * Runs an otpimization phase to try to improve the shader code
  53778. */
  53779. optimize(): void;
  53780. private _prepareDefinesForAttributes;
  53781. /**
  53782. * Get if the submesh is ready to be used and all its information available.
  53783. * Child classes can use it to update shaders
  53784. * @param mesh defines the mesh to check
  53785. * @param subMesh defines which submesh to check
  53786. * @param useInstances specifies that instances should be used
  53787. * @returns a boolean indicating that the submesh is ready or not
  53788. */
  53789. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53790. /**
  53791. * Get a string representing the shaders built by the current node graph
  53792. */
  53793. readonly compiledShaders: string;
  53794. /**
  53795. * Binds the world matrix to the material
  53796. * @param world defines the world transformation matrix
  53797. */
  53798. bindOnlyWorldMatrix(world: Matrix): void;
  53799. /**
  53800. * Binds the submesh to this material by preparing the effect and shader to draw
  53801. * @param world defines the world transformation matrix
  53802. * @param mesh defines the mesh containing the submesh
  53803. * @param subMesh defines the submesh to bind the material to
  53804. */
  53805. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53806. /**
  53807. * Gets the active textures from the material
  53808. * @returns an array of textures
  53809. */
  53810. getActiveTextures(): BaseTexture[];
  53811. /**
  53812. * Gets the list of texture blocks
  53813. * @returns an array of texture blocks
  53814. */
  53815. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53816. /**
  53817. * Specifies if the material uses a texture
  53818. * @param texture defines the texture to check against the material
  53819. * @returns a boolean specifying if the material uses the texture
  53820. */
  53821. hasTexture(texture: BaseTexture): boolean;
  53822. /**
  53823. * Disposes the material
  53824. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53825. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53826. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53827. */
  53828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53829. /** Creates the node editor window. */
  53830. private _createNodeEditor;
  53831. /**
  53832. * Launch the node material editor
  53833. * @param config Define the configuration of the editor
  53834. * @return a promise fulfilled when the node editor is visible
  53835. */
  53836. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53837. /**
  53838. * Clear the current material
  53839. */
  53840. clear(): void;
  53841. /**
  53842. * Clear the current material and set it to a default state
  53843. */
  53844. setToDefault(): void;
  53845. /**
  53846. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53847. * @param url defines the url to load from
  53848. * @returns a promise that will fullfil when the material is fully loaded
  53849. */
  53850. loadAsync(url: string): Promise<void>;
  53851. private _gatherBlocks;
  53852. /**
  53853. * Generate a string containing the code declaration required to create an equivalent of this material
  53854. * @returns a string
  53855. */
  53856. generateCode(): string;
  53857. /**
  53858. * Serializes this material in a JSON representation
  53859. * @returns the serialized material object
  53860. */
  53861. serialize(): any;
  53862. private _restoreConnections;
  53863. /**
  53864. * Clear the current graph and load a new one from a serialization object
  53865. * @param source defines the JSON representation of the material
  53866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53867. */
  53868. loadFromSerialization(source: any, rootUrl?: string): void;
  53869. /**
  53870. * Creates a node material from parsed material data
  53871. * @param source defines the JSON representation of the material
  53872. * @param scene defines the hosting scene
  53873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53874. * @returns a new node material
  53875. */
  53876. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53877. /**
  53878. * Creates a new node material set to default basic configuration
  53879. * @param name defines the name of the material
  53880. * @param scene defines the hosting scene
  53881. * @returns a new NodeMaterial
  53882. */
  53883. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53884. }
  53885. }
  53886. declare module BABYLON {
  53887. /**
  53888. * Block used to read a texture from a sampler
  53889. */
  53890. export class TextureBlock extends NodeMaterialBlock {
  53891. private _defineName;
  53892. private _linearDefineName;
  53893. private _samplerName;
  53894. private _transformedUVName;
  53895. private _textureTransformName;
  53896. private _textureInfoName;
  53897. private _mainUVName;
  53898. private _mainUVDefineName;
  53899. /**
  53900. * Gets or sets the texture associated with the node
  53901. */
  53902. texture: Nullable<Texture>;
  53903. /**
  53904. * Create a new TextureBlock
  53905. * @param name defines the block name
  53906. */
  53907. constructor(name: string);
  53908. /**
  53909. * Gets the current class name
  53910. * @returns the class name
  53911. */
  53912. getClassName(): string;
  53913. /**
  53914. * Gets the uv input component
  53915. */
  53916. readonly uv: NodeMaterialConnectionPoint;
  53917. /**
  53918. * Gets the rgba output component
  53919. */
  53920. readonly rgba: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the rgb output component
  53923. */
  53924. readonly rgb: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the r output component
  53927. */
  53928. readonly r: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Gets the g output component
  53931. */
  53932. readonly g: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the b output component
  53935. */
  53936. readonly b: NodeMaterialConnectionPoint;
  53937. /**
  53938. * Gets the a output component
  53939. */
  53940. readonly a: NodeMaterialConnectionPoint;
  53941. readonly target: NodeMaterialBlockTargets;
  53942. autoConfigure(material: NodeMaterial): void;
  53943. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53945. isReady(): boolean;
  53946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53947. private readonly _isMixed;
  53948. private _injectVertexCode;
  53949. private _writeOutput;
  53950. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53951. protected _dumpPropertiesCode(): string;
  53952. serialize(): any;
  53953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53954. }
  53955. }
  53956. declare module BABYLON {
  53957. /**
  53958. * Class used to store shared data between 2 NodeMaterialBuildState
  53959. */
  53960. export class NodeMaterialBuildStateSharedData {
  53961. /**
  53962. * Gets the list of emitted varyings
  53963. */
  53964. temps: string[];
  53965. /**
  53966. * Gets the list of emitted varyings
  53967. */
  53968. varyings: string[];
  53969. /**
  53970. * Gets the varying declaration string
  53971. */
  53972. varyingDeclaration: string;
  53973. /**
  53974. * Input blocks
  53975. */
  53976. inputBlocks: InputBlock[];
  53977. /**
  53978. * Input blocks
  53979. */
  53980. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53981. /**
  53982. * Bindable blocks (Blocks that need to set data to the effect)
  53983. */
  53984. bindableBlocks: NodeMaterialBlock[];
  53985. /**
  53986. * List of blocks that can provide a compilation fallback
  53987. */
  53988. blocksWithFallbacks: NodeMaterialBlock[];
  53989. /**
  53990. * List of blocks that can provide a define update
  53991. */
  53992. blocksWithDefines: NodeMaterialBlock[];
  53993. /**
  53994. * List of blocks that can provide a repeatable content
  53995. */
  53996. repeatableContentBlocks: NodeMaterialBlock[];
  53997. /**
  53998. * List of blocks that can provide a dynamic list of uniforms
  53999. */
  54000. dynamicUniformBlocks: NodeMaterialBlock[];
  54001. /**
  54002. * List of blocks that can block the isReady function for the material
  54003. */
  54004. blockingBlocks: NodeMaterialBlock[];
  54005. /**
  54006. * Gets the list of animated inputs
  54007. */
  54008. animatedInputs: InputBlock[];
  54009. /**
  54010. * Build Id used to avoid multiple recompilations
  54011. */
  54012. buildId: number;
  54013. /** List of emitted variables */
  54014. variableNames: {
  54015. [key: string]: number;
  54016. };
  54017. /** List of emitted defines */
  54018. defineNames: {
  54019. [key: string]: number;
  54020. };
  54021. /** Should emit comments? */
  54022. emitComments: boolean;
  54023. /** Emit build activity */
  54024. verbose: boolean;
  54025. /** Gets or sets the hosting scene */
  54026. scene: Scene;
  54027. /**
  54028. * Gets the compilation hints emitted at compilation time
  54029. */
  54030. hints: {
  54031. needWorldViewMatrix: boolean;
  54032. needWorldViewProjectionMatrix: boolean;
  54033. needAlphaBlending: boolean;
  54034. needAlphaTesting: boolean;
  54035. };
  54036. /**
  54037. * List of compilation checks
  54038. */
  54039. checks: {
  54040. emitVertex: boolean;
  54041. emitFragment: boolean;
  54042. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54043. };
  54044. /** Creates a new shared data */
  54045. constructor();
  54046. /**
  54047. * Emits console errors and exceptions if there is a failing check
  54048. */
  54049. emitErrors(): void;
  54050. }
  54051. }
  54052. declare module BABYLON {
  54053. /**
  54054. * Class used to store node based material build state
  54055. */
  54056. export class NodeMaterialBuildState {
  54057. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54058. supportUniformBuffers: boolean;
  54059. /**
  54060. * Gets the list of emitted attributes
  54061. */
  54062. attributes: string[];
  54063. /**
  54064. * Gets the list of emitted uniforms
  54065. */
  54066. uniforms: string[];
  54067. /**
  54068. * Gets the list of emitted constants
  54069. */
  54070. constants: string[];
  54071. /**
  54072. * Gets the list of emitted samplers
  54073. */
  54074. samplers: string[];
  54075. /**
  54076. * Gets the list of emitted functions
  54077. */
  54078. functions: {
  54079. [key: string]: string;
  54080. };
  54081. /**
  54082. * Gets the list of emitted extensions
  54083. */
  54084. extensions: {
  54085. [key: string]: string;
  54086. };
  54087. /**
  54088. * Gets the target of the compilation state
  54089. */
  54090. target: NodeMaterialBlockTargets;
  54091. /**
  54092. * Gets the list of emitted counters
  54093. */
  54094. counters: {
  54095. [key: string]: number;
  54096. };
  54097. /**
  54098. * Shared data between multiple NodeMaterialBuildState instances
  54099. */
  54100. sharedData: NodeMaterialBuildStateSharedData;
  54101. /** @hidden */
  54102. _vertexState: NodeMaterialBuildState;
  54103. /** @hidden */
  54104. _attributeDeclaration: string;
  54105. /** @hidden */
  54106. _uniformDeclaration: string;
  54107. /** @hidden */
  54108. _constantDeclaration: string;
  54109. /** @hidden */
  54110. _samplerDeclaration: string;
  54111. /** @hidden */
  54112. _varyingTransfer: string;
  54113. private _repeatableContentAnchorIndex;
  54114. /** @hidden */
  54115. _builtCompilationString: string;
  54116. /**
  54117. * Gets the emitted compilation strings
  54118. */
  54119. compilationString: string;
  54120. /**
  54121. * Finalize the compilation strings
  54122. * @param state defines the current compilation state
  54123. */
  54124. finalize(state: NodeMaterialBuildState): void;
  54125. /** @hidden */
  54126. readonly _repeatableContentAnchor: string;
  54127. /** @hidden */
  54128. _getFreeVariableName(prefix: string): string;
  54129. /** @hidden */
  54130. _getFreeDefineName(prefix: string): string;
  54131. /** @hidden */
  54132. _excludeVariableName(name: string): void;
  54133. /** @hidden */
  54134. _emit2DSampler(name: string): void;
  54135. /** @hidden */
  54136. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54137. /** @hidden */
  54138. _emitExtension(name: string, extension: string): void;
  54139. /** @hidden */
  54140. _emitFunction(name: string, code: string, comments: string): void;
  54141. /** @hidden */
  54142. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54143. replaceStrings?: {
  54144. search: RegExp;
  54145. replace: string;
  54146. }[];
  54147. repeatKey?: string;
  54148. }): string;
  54149. /** @hidden */
  54150. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54151. repeatKey?: string;
  54152. removeAttributes?: boolean;
  54153. removeUniforms?: boolean;
  54154. removeVaryings?: boolean;
  54155. removeIfDef?: boolean;
  54156. replaceStrings?: {
  54157. search: RegExp;
  54158. replace: string;
  54159. }[];
  54160. }, storeKey?: string): void;
  54161. /** @hidden */
  54162. _registerTempVariable(name: string): boolean;
  54163. /** @hidden */
  54164. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54165. /** @hidden */
  54166. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54167. /** @hidden */
  54168. _emitFloat(value: number): string;
  54169. }
  54170. }
  54171. declare module BABYLON {
  54172. /**
  54173. * Defines a block that can be used inside a node based material
  54174. */
  54175. export class NodeMaterialBlock {
  54176. private _buildId;
  54177. private _buildTarget;
  54178. private _target;
  54179. private _isFinalMerger;
  54180. private _isInput;
  54181. protected _isUnique: boolean;
  54182. /** @hidden */
  54183. _codeVariableName: string;
  54184. /** @hidden */
  54185. _inputs: NodeMaterialConnectionPoint[];
  54186. /** @hidden */
  54187. _outputs: NodeMaterialConnectionPoint[];
  54188. /** @hidden */
  54189. _preparationId: number;
  54190. /**
  54191. * Gets or sets the name of the block
  54192. */
  54193. name: string;
  54194. /**
  54195. * Gets or sets the unique id of the node
  54196. */
  54197. uniqueId: number;
  54198. /**
  54199. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54200. */
  54201. readonly isUnique: boolean;
  54202. /**
  54203. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54204. */
  54205. readonly isFinalMerger: boolean;
  54206. /**
  54207. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54208. */
  54209. readonly isInput: boolean;
  54210. /**
  54211. * Gets or sets the build Id
  54212. */
  54213. buildId: number;
  54214. /**
  54215. * Gets or sets the target of the block
  54216. */
  54217. target: NodeMaterialBlockTargets;
  54218. /**
  54219. * Gets the list of input points
  54220. */
  54221. readonly inputs: NodeMaterialConnectionPoint[];
  54222. /** Gets the list of output points */
  54223. readonly outputs: NodeMaterialConnectionPoint[];
  54224. /**
  54225. * Find an input by its name
  54226. * @param name defines the name of the input to look for
  54227. * @returns the input or null if not found
  54228. */
  54229. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54230. /**
  54231. * Find an output by its name
  54232. * @param name defines the name of the outputto look for
  54233. * @returns the output or null if not found
  54234. */
  54235. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54236. /**
  54237. * Creates a new NodeMaterialBlock
  54238. * @param name defines the block name
  54239. * @param target defines the target of that block (Vertex by default)
  54240. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54241. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54242. */
  54243. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54244. /**
  54245. * Initialize the block and prepare the context for build
  54246. * @param state defines the state that will be used for the build
  54247. */
  54248. initialize(state: NodeMaterialBuildState): void;
  54249. /**
  54250. * Bind data to effect. Will only be called for blocks with isBindable === true
  54251. * @param effect defines the effect to bind data to
  54252. * @param nodeMaterial defines the hosting NodeMaterial
  54253. * @param mesh defines the mesh that will be rendered
  54254. */
  54255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54256. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54257. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54258. protected _writeFloat(value: number): string;
  54259. /**
  54260. * Gets the current class name e.g. "NodeMaterialBlock"
  54261. * @returns the class name
  54262. */
  54263. getClassName(): string;
  54264. /**
  54265. * Register a new input. Must be called inside a block constructor
  54266. * @param name defines the connection point name
  54267. * @param type defines the connection point type
  54268. * @param isOptional defines a boolean indicating that this input can be omitted
  54269. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54270. * @returns the current block
  54271. */
  54272. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54273. /**
  54274. * Register a new output. Must be called inside a block constructor
  54275. * @param name defines the connection point name
  54276. * @param type defines the connection point type
  54277. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54278. * @returns the current block
  54279. */
  54280. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54281. /**
  54282. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54283. * @param forOutput defines an optional connection point to check compatibility with
  54284. * @returns the first available input or null
  54285. */
  54286. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54287. /**
  54288. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54289. * @param forBlock defines an optional block to check compatibility with
  54290. * @returns the first available input or null
  54291. */
  54292. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54293. /**
  54294. * Gets the sibling of the given output
  54295. * @param current defines the current output
  54296. * @returns the next output in the list or null
  54297. */
  54298. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54299. /**
  54300. * Connect current block with another block
  54301. * @param other defines the block to connect with
  54302. * @param options define the various options to help pick the right connections
  54303. * @returns the current block
  54304. */
  54305. connectTo(other: NodeMaterialBlock, options?: {
  54306. input?: string;
  54307. output?: string;
  54308. outputSwizzle?: string;
  54309. }): this | undefined;
  54310. protected _buildBlock(state: NodeMaterialBuildState): void;
  54311. /**
  54312. * Add uniforms, samplers and uniform buffers at compilation time
  54313. * @param state defines the state to update
  54314. * @param nodeMaterial defines the node material requesting the update
  54315. * @param defines defines the material defines to update
  54316. * @param uniformBuffers defines the list of uniform buffer names
  54317. */
  54318. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54319. /**
  54320. * Add potential fallbacks if shader compilation fails
  54321. * @param mesh defines the mesh to be rendered
  54322. * @param fallbacks defines the current prioritized list of fallbacks
  54323. */
  54324. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54325. /**
  54326. * Initialize defines for shader compilation
  54327. * @param mesh defines the mesh to be rendered
  54328. * @param nodeMaterial defines the node material requesting the update
  54329. * @param defines defines the material defines to update
  54330. * @param useInstances specifies that instances should be used
  54331. */
  54332. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54333. /**
  54334. * Update defines for shader compilation
  54335. * @param mesh defines the mesh to be rendered
  54336. * @param nodeMaterial defines the node material requesting the update
  54337. * @param defines defines the material defines to update
  54338. * @param useInstances specifies that instances should be used
  54339. */
  54340. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54341. /**
  54342. * Lets the block try to connect some inputs automatically
  54343. * @param material defines the hosting NodeMaterial
  54344. */
  54345. autoConfigure(material: NodeMaterial): void;
  54346. /**
  54347. * Function called when a block is declared as repeatable content generator
  54348. * @param vertexShaderState defines the current compilation state for the vertex shader
  54349. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54350. * @param mesh defines the mesh to be rendered
  54351. * @param defines defines the material defines to update
  54352. */
  54353. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54354. /**
  54355. * Checks if the block is ready
  54356. * @param mesh defines the mesh to be rendered
  54357. * @param nodeMaterial defines the node material requesting the update
  54358. * @param defines defines the material defines to update
  54359. * @param useInstances specifies that instances should be used
  54360. * @returns true if the block is ready
  54361. */
  54362. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54363. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54364. private _processBuild;
  54365. /**
  54366. * Compile the current node and generate the shader code
  54367. * @param state defines the current compilation state (uniforms, samplers, current string)
  54368. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54369. * @returns true if already built
  54370. */
  54371. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54372. protected _inputRename(name: string): string;
  54373. protected _outputRename(name: string): string;
  54374. protected _dumpPropertiesCode(): string;
  54375. /** @hidden */
  54376. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54377. /** @hidden */
  54378. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54379. /**
  54380. * Clone the current block to a new identical block
  54381. * @param scene defines the hosting scene
  54382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54383. * @returns a copy of the current block
  54384. */
  54385. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54386. /**
  54387. * Serializes this block in a JSON representation
  54388. * @returns the serialized block object
  54389. */
  54390. serialize(): any;
  54391. /** @hidden */
  54392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54393. /**
  54394. * Release resources
  54395. */
  54396. dispose(): void;
  54397. }
  54398. }
  54399. declare module BABYLON {
  54400. /**
  54401. * Enum defining the type of animations supported by InputBlock
  54402. */
  54403. export enum AnimatedInputBlockTypes {
  54404. /** No animation */
  54405. None = 0,
  54406. /** Time based animation. Will only work for floats */
  54407. Time = 1
  54408. }
  54409. }
  54410. declare module BABYLON {
  54411. /**
  54412. * Block used to expose an input value
  54413. */
  54414. export class InputBlock extends NodeMaterialBlock {
  54415. private _mode;
  54416. private _associatedVariableName;
  54417. private _storedValue;
  54418. private _valueCallback;
  54419. private _type;
  54420. private _animationType;
  54421. /** Gets or set a value used to limit the range of float values */
  54422. min: number;
  54423. /** Gets or set a value used to limit the range of float values */
  54424. max: number;
  54425. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54426. matrixMode: number;
  54427. /** @hidden */
  54428. _systemValue: Nullable<NodeMaterialSystemValues>;
  54429. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54430. visibleInInspector: boolean;
  54431. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54432. isConstant: boolean;
  54433. /**
  54434. * Gets or sets the connection point type (default is float)
  54435. */
  54436. readonly type: NodeMaterialBlockConnectionPointTypes;
  54437. /**
  54438. * Creates a new InputBlock
  54439. * @param name defines the block name
  54440. * @param target defines the target of that block (Vertex by default)
  54441. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54442. */
  54443. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54444. /**
  54445. * Gets the output component
  54446. */
  54447. readonly output: NodeMaterialConnectionPoint;
  54448. /**
  54449. * Set the source of this connection point to a vertex attribute
  54450. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54451. * @returns the current connection point
  54452. */
  54453. setAsAttribute(attributeName?: string): InputBlock;
  54454. /**
  54455. * Set the source of this connection point to a system value
  54456. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54457. * @returns the current connection point
  54458. */
  54459. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54460. /**
  54461. * Gets or sets the value of that point.
  54462. * Please note that this value will be ignored if valueCallback is defined
  54463. */
  54464. value: any;
  54465. /**
  54466. * Gets or sets a callback used to get the value of that point.
  54467. * Please note that setting this value will force the connection point to ignore the value property
  54468. */
  54469. valueCallback: () => any;
  54470. /**
  54471. * Gets or sets the associated variable name in the shader
  54472. */
  54473. associatedVariableName: string;
  54474. /** Gets or sets the type of animation applied to the input */
  54475. animationType: AnimatedInputBlockTypes;
  54476. /**
  54477. * Gets a boolean indicating that this connection point not defined yet
  54478. */
  54479. readonly isUndefined: boolean;
  54480. /**
  54481. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54482. * In this case the connection point name must be the name of the uniform to use.
  54483. * Can only be set on inputs
  54484. */
  54485. isUniform: boolean;
  54486. /**
  54487. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54488. * In this case the connection point name must be the name of the attribute to use
  54489. * Can only be set on inputs
  54490. */
  54491. isAttribute: boolean;
  54492. /**
  54493. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54494. * Can only be set on exit points
  54495. */
  54496. isVarying: boolean;
  54497. /**
  54498. * Gets a boolean indicating that the current connection point is a system value
  54499. */
  54500. readonly isSystemValue: boolean;
  54501. /**
  54502. * Gets or sets the current well known value or null if not defined as a system value
  54503. */
  54504. systemValue: Nullable<NodeMaterialSystemValues>;
  54505. /**
  54506. * Gets the current class name
  54507. * @returns the class name
  54508. */
  54509. getClassName(): string;
  54510. /**
  54511. * Animate the input if animationType !== None
  54512. * @param scene defines the rendering scene
  54513. */
  54514. animate(scene: Scene): void;
  54515. private _emitDefine;
  54516. initialize(state: NodeMaterialBuildState): void;
  54517. /**
  54518. * Set the input block to its default value (based on its type)
  54519. */
  54520. setDefaultValue(): void;
  54521. private _emitConstant;
  54522. private _emit;
  54523. /** @hidden */
  54524. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54525. /** @hidden */
  54526. _transmit(effect: Effect, scene: Scene): void;
  54527. protected _buildBlock(state: NodeMaterialBuildState): void;
  54528. protected _dumpPropertiesCode(): string;
  54529. serialize(): any;
  54530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54531. }
  54532. }
  54533. declare module BABYLON {
  54534. /**
  54535. * Enum used to define the compatibility state between two connection points
  54536. */
  54537. export enum NodeMaterialConnectionPointCompatibilityStates {
  54538. /** Points are compatibles */
  54539. Compatible = 0,
  54540. /** Points are incompatible because of their types */
  54541. TypeIncompatible = 1,
  54542. /** Points are incompatible because of their targets (vertex vs fragment) */
  54543. TargetIncompatible = 2
  54544. }
  54545. /**
  54546. * Defines a connection point for a block
  54547. */
  54548. export class NodeMaterialConnectionPoint {
  54549. /** @hidden */
  54550. _ownerBlock: NodeMaterialBlock;
  54551. /** @hidden */
  54552. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54553. private _endpoints;
  54554. private _associatedVariableName;
  54555. /** @hidden */
  54556. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54557. /** @hidden */
  54558. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54559. private _type;
  54560. /** @hidden */
  54561. _enforceAssociatedVariableName: boolean;
  54562. /**
  54563. * Gets or sets the additional types supported by this connection point
  54564. */
  54565. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54566. /**
  54567. * Gets or sets the additional types excluded by this connection point
  54568. */
  54569. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54570. /**
  54571. * Observable triggered when this point is connected
  54572. */
  54573. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54574. /**
  54575. * Gets or sets the associated variable name in the shader
  54576. */
  54577. associatedVariableName: string;
  54578. /**
  54579. * Gets or sets the connection point type (default is float)
  54580. */
  54581. type: NodeMaterialBlockConnectionPointTypes;
  54582. /**
  54583. * Gets or sets the connection point name
  54584. */
  54585. name: string;
  54586. /**
  54587. * Gets or sets a boolean indicating that this connection point can be omitted
  54588. */
  54589. isOptional: boolean;
  54590. /**
  54591. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54592. */
  54593. define: string;
  54594. /** @hidden */
  54595. _prioritizeVertex: boolean;
  54596. private _target;
  54597. /** Gets or sets the target of that connection point */
  54598. target: NodeMaterialBlockTargets;
  54599. /**
  54600. * Gets a boolean indicating that the current point is connected
  54601. */
  54602. readonly isConnected: boolean;
  54603. /**
  54604. * Gets a boolean indicating that the current point is connected to an input block
  54605. */
  54606. readonly isConnectedToInputBlock: boolean;
  54607. /**
  54608. * Gets a the connected input block (if any)
  54609. */
  54610. readonly connectInputBlock: Nullable<InputBlock>;
  54611. /** Get the other side of the connection (if any) */
  54612. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54613. /** Get the block that owns this connection point */
  54614. readonly ownerBlock: NodeMaterialBlock;
  54615. /** Get the block connected on the other side of this connection (if any) */
  54616. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54617. /** Get the block connected on the endpoints of this connection (if any) */
  54618. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54619. /** Gets the list of connected endpoints */
  54620. readonly endpoints: NodeMaterialConnectionPoint[];
  54621. /** Gets a boolean indicating if that output point is connected to at least one input */
  54622. readonly hasEndpoints: boolean;
  54623. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54624. readonly isConnectedInVertexShader: boolean;
  54625. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54626. readonly isConnectedInFragmentShader: boolean;
  54627. /**
  54628. * Creates a new connection point
  54629. * @param name defines the connection point name
  54630. * @param ownerBlock defines the block hosting this connection point
  54631. */
  54632. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54633. /**
  54634. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54635. * @returns the class name
  54636. */
  54637. getClassName(): string;
  54638. /**
  54639. * Gets a boolean indicating if the current point can be connected to another point
  54640. * @param connectionPoint defines the other connection point
  54641. * @returns a boolean
  54642. */
  54643. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54644. /**
  54645. * Gets a number indicating if the current point can be connected to another point
  54646. * @param connectionPoint defines the other connection point
  54647. * @returns a number defining the compatibility state
  54648. */
  54649. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  54650. /**
  54651. * Connect this point to another connection point
  54652. * @param connectionPoint defines the other connection point
  54653. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54654. * @returns the current connection point
  54655. */
  54656. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54657. /**
  54658. * Disconnect this point from one of his endpoint
  54659. * @param endpoint defines the other connection point
  54660. * @returns the current connection point
  54661. */
  54662. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54663. /**
  54664. * Serializes this point in a JSON representation
  54665. * @returns the serialized point object
  54666. */
  54667. serialize(): any;
  54668. /**
  54669. * Release resources
  54670. */
  54671. dispose(): void;
  54672. }
  54673. }
  54674. declare module BABYLON {
  54675. /**
  54676. * Block used to add support for vertex skinning (bones)
  54677. */
  54678. export class BonesBlock extends NodeMaterialBlock {
  54679. /**
  54680. * Creates a new BonesBlock
  54681. * @param name defines the block name
  54682. */
  54683. constructor(name: string);
  54684. /**
  54685. * Initialize the block and prepare the context for build
  54686. * @param state defines the state that will be used for the build
  54687. */
  54688. initialize(state: NodeMaterialBuildState): void;
  54689. /**
  54690. * Gets the current class name
  54691. * @returns the class name
  54692. */
  54693. getClassName(): string;
  54694. /**
  54695. * Gets the matrix indices input component
  54696. */
  54697. readonly matricesIndices: NodeMaterialConnectionPoint;
  54698. /**
  54699. * Gets the matrix weights input component
  54700. */
  54701. readonly matricesWeights: NodeMaterialConnectionPoint;
  54702. /**
  54703. * Gets the extra matrix indices input component
  54704. */
  54705. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54706. /**
  54707. * Gets the extra matrix weights input component
  54708. */
  54709. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54710. /**
  54711. * Gets the world input component
  54712. */
  54713. readonly world: NodeMaterialConnectionPoint;
  54714. /**
  54715. * Gets the output component
  54716. */
  54717. readonly output: NodeMaterialConnectionPoint;
  54718. autoConfigure(material: NodeMaterial): void;
  54719. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54722. protected _buildBlock(state: NodeMaterialBuildState): this;
  54723. }
  54724. }
  54725. declare module BABYLON {
  54726. /**
  54727. * Block used to add support for instances
  54728. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54729. */
  54730. export class InstancesBlock extends NodeMaterialBlock {
  54731. /**
  54732. * Creates a new InstancesBlock
  54733. * @param name defines the block name
  54734. */
  54735. constructor(name: string);
  54736. /**
  54737. * Gets the current class name
  54738. * @returns the class name
  54739. */
  54740. getClassName(): string;
  54741. /**
  54742. * Gets the first world row input component
  54743. */
  54744. readonly world0: NodeMaterialConnectionPoint;
  54745. /**
  54746. * Gets the second world row input component
  54747. */
  54748. readonly world1: NodeMaterialConnectionPoint;
  54749. /**
  54750. * Gets the third world row input component
  54751. */
  54752. readonly world2: NodeMaterialConnectionPoint;
  54753. /**
  54754. * Gets the forth world row input component
  54755. */
  54756. readonly world3: NodeMaterialConnectionPoint;
  54757. /**
  54758. * Gets the world input component
  54759. */
  54760. readonly world: NodeMaterialConnectionPoint;
  54761. /**
  54762. * Gets the output component
  54763. */
  54764. readonly output: NodeMaterialConnectionPoint;
  54765. autoConfigure(material: NodeMaterial): void;
  54766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54767. protected _buildBlock(state: NodeMaterialBuildState): this;
  54768. }
  54769. }
  54770. declare module BABYLON {
  54771. /**
  54772. * Block used to add morph targets support to vertex shader
  54773. */
  54774. export class MorphTargetsBlock extends NodeMaterialBlock {
  54775. private _repeatableContentAnchor;
  54776. private _repeatebleContentGenerated;
  54777. /**
  54778. * Create a new MorphTargetsBlock
  54779. * @param name defines the block name
  54780. */
  54781. constructor(name: string);
  54782. /**
  54783. * Gets the current class name
  54784. * @returns the class name
  54785. */
  54786. getClassName(): string;
  54787. /**
  54788. * Gets the position input component
  54789. */
  54790. readonly position: NodeMaterialConnectionPoint;
  54791. /**
  54792. * Gets the normal input component
  54793. */
  54794. readonly normal: NodeMaterialConnectionPoint;
  54795. /**
  54796. * Gets the tangent input component
  54797. */
  54798. readonly tangent: NodeMaterialConnectionPoint;
  54799. /**
  54800. * Gets the tangent input component
  54801. */
  54802. readonly uv: NodeMaterialConnectionPoint;
  54803. /**
  54804. * Gets the position output component
  54805. */
  54806. readonly positionOutput: NodeMaterialConnectionPoint;
  54807. /**
  54808. * Gets the normal output component
  54809. */
  54810. readonly normalOutput: NodeMaterialConnectionPoint;
  54811. /**
  54812. * Gets the tangent output component
  54813. */
  54814. readonly tangentOutput: NodeMaterialConnectionPoint;
  54815. /**
  54816. * Gets the tangent output component
  54817. */
  54818. readonly uvOutput: NodeMaterialConnectionPoint;
  54819. initialize(state: NodeMaterialBuildState): void;
  54820. autoConfigure(material: NodeMaterial): void;
  54821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54823. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54824. protected _buildBlock(state: NodeMaterialBuildState): this;
  54825. }
  54826. }
  54827. declare module BABYLON {
  54828. /**
  54829. * Block used to get data information from a light
  54830. */
  54831. export class LightInformationBlock extends NodeMaterialBlock {
  54832. private _lightDataUniformName;
  54833. private _lightColorUniformName;
  54834. private _lightTypeDefineName;
  54835. /**
  54836. * Gets or sets the light associated with this block
  54837. */
  54838. light: Nullable<Light>;
  54839. /**
  54840. * Creates a new LightInformationBlock
  54841. * @param name defines the block name
  54842. */
  54843. constructor(name: string);
  54844. /**
  54845. * Gets the current class name
  54846. * @returns the class name
  54847. */
  54848. getClassName(): string;
  54849. /**
  54850. * Gets the world position input component
  54851. */
  54852. readonly worldPosition: NodeMaterialConnectionPoint;
  54853. /**
  54854. * Gets the direction output component
  54855. */
  54856. readonly direction: NodeMaterialConnectionPoint;
  54857. /**
  54858. * Gets the direction output component
  54859. */
  54860. readonly color: NodeMaterialConnectionPoint;
  54861. /**
  54862. * Gets the direction output component
  54863. */
  54864. readonly intensity: NodeMaterialConnectionPoint;
  54865. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54866. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54867. protected _buildBlock(state: NodeMaterialBuildState): this;
  54868. serialize(): any;
  54869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54870. }
  54871. }
  54872. declare module BABYLON {
  54873. /**
  54874. * Block used to add image processing support to fragment shader
  54875. */
  54876. export class ImageProcessingBlock extends NodeMaterialBlock {
  54877. /**
  54878. * Create a new ImageProcessingBlock
  54879. * @param name defines the block name
  54880. */
  54881. constructor(name: string);
  54882. /**
  54883. * Gets the current class name
  54884. * @returns the class name
  54885. */
  54886. getClassName(): string;
  54887. /**
  54888. * Gets the color input component
  54889. */
  54890. readonly color: NodeMaterialConnectionPoint;
  54891. /**
  54892. * Gets the output component
  54893. */
  54894. readonly output: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Initialize the block and prepare the context for build
  54897. * @param state defines the state that will be used for the build
  54898. */
  54899. initialize(state: NodeMaterialBuildState): void;
  54900. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54903. protected _buildBlock(state: NodeMaterialBuildState): this;
  54904. }
  54905. }
  54906. declare module BABYLON {
  54907. /**
  54908. * Block used to pertub normals based on a normal map
  54909. */
  54910. export class PerturbNormalBlock extends NodeMaterialBlock {
  54911. private _tangentSpaceParameterName;
  54912. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54913. invertX: boolean;
  54914. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54915. invertY: boolean;
  54916. /**
  54917. * Create a new PerturbNormalBlock
  54918. * @param name defines the block name
  54919. */
  54920. constructor(name: string);
  54921. /**
  54922. * Gets the current class name
  54923. * @returns the class name
  54924. */
  54925. getClassName(): string;
  54926. /**
  54927. * Gets the world position input component
  54928. */
  54929. readonly worldPosition: NodeMaterialConnectionPoint;
  54930. /**
  54931. * Gets the world normal input component
  54932. */
  54933. readonly worldNormal: NodeMaterialConnectionPoint;
  54934. /**
  54935. * Gets the uv input component
  54936. */
  54937. readonly uv: NodeMaterialConnectionPoint;
  54938. /**
  54939. * Gets the normal map color input component
  54940. */
  54941. readonly normalMapColor: NodeMaterialConnectionPoint;
  54942. /**
  54943. * Gets the strength input component
  54944. */
  54945. readonly strength: NodeMaterialConnectionPoint;
  54946. /**
  54947. * Gets the output component
  54948. */
  54949. readonly output: NodeMaterialConnectionPoint;
  54950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54951. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54952. autoConfigure(material: NodeMaterial): void;
  54953. protected _buildBlock(state: NodeMaterialBuildState): this;
  54954. protected _dumpPropertiesCode(): string;
  54955. serialize(): any;
  54956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /**
  54961. * Block used to discard a pixel if a value is smaller than a cutoff
  54962. */
  54963. export class DiscardBlock extends NodeMaterialBlock {
  54964. /**
  54965. * Create a new DiscardBlock
  54966. * @param name defines the block name
  54967. */
  54968. constructor(name: string);
  54969. /**
  54970. * Gets the current class name
  54971. * @returns the class name
  54972. */
  54973. getClassName(): string;
  54974. /**
  54975. * Gets the color input component
  54976. */
  54977. readonly value: NodeMaterialConnectionPoint;
  54978. /**
  54979. * Gets the cutoff input component
  54980. */
  54981. readonly cutoff: NodeMaterialConnectionPoint;
  54982. protected _buildBlock(state: NodeMaterialBuildState): this;
  54983. }
  54984. }
  54985. declare module BABYLON {
  54986. /**
  54987. * Block used to test if the fragment shader is front facing
  54988. */
  54989. export class FrontFacingBlock extends NodeMaterialBlock {
  54990. /**
  54991. * Creates a new FrontFacingBlock
  54992. * @param name defines the block name
  54993. */
  54994. constructor(name: string);
  54995. /**
  54996. * Gets the current class name
  54997. * @returns the class name
  54998. */
  54999. getClassName(): string;
  55000. /**
  55001. * Gets the output component
  55002. */
  55003. readonly output: NodeMaterialConnectionPoint;
  55004. protected _buildBlock(state: NodeMaterialBuildState): this;
  55005. }
  55006. }
  55007. declare module BABYLON {
  55008. /**
  55009. * Block used to add support for scene fog
  55010. */
  55011. export class FogBlock extends NodeMaterialBlock {
  55012. private _fogDistanceName;
  55013. private _fogParameters;
  55014. /**
  55015. * Create a new FogBlock
  55016. * @param name defines the block name
  55017. */
  55018. constructor(name: string);
  55019. /**
  55020. * Gets the current class name
  55021. * @returns the class name
  55022. */
  55023. getClassName(): string;
  55024. /**
  55025. * Gets the world position input component
  55026. */
  55027. readonly worldPosition: NodeMaterialConnectionPoint;
  55028. /**
  55029. * Gets the view input component
  55030. */
  55031. readonly view: NodeMaterialConnectionPoint;
  55032. /**
  55033. * Gets the color input component
  55034. */
  55035. readonly input: NodeMaterialConnectionPoint;
  55036. /**
  55037. * Gets the fog color input component
  55038. */
  55039. readonly fogColor: NodeMaterialConnectionPoint;
  55040. /**
  55041. * Gets the output component
  55042. */
  55043. readonly output: NodeMaterialConnectionPoint;
  55044. autoConfigure(material: NodeMaterial): void;
  55045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55046. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55047. protected _buildBlock(state: NodeMaterialBuildState): this;
  55048. }
  55049. }
  55050. declare module BABYLON {
  55051. /**
  55052. * Block used to add light in the fragment shader
  55053. */
  55054. export class LightBlock extends NodeMaterialBlock {
  55055. private _lightId;
  55056. /**
  55057. * Gets or sets the light associated with this block
  55058. */
  55059. light: Nullable<Light>;
  55060. /**
  55061. * Create a new LightBlock
  55062. * @param name defines the block name
  55063. */
  55064. constructor(name: string);
  55065. /**
  55066. * Gets the current class name
  55067. * @returns the class name
  55068. */
  55069. getClassName(): string;
  55070. /**
  55071. * Gets the world position input component
  55072. */
  55073. readonly worldPosition: NodeMaterialConnectionPoint;
  55074. /**
  55075. * Gets the world normal input component
  55076. */
  55077. readonly worldNormal: NodeMaterialConnectionPoint;
  55078. /**
  55079. * Gets the camera (or eye) position component
  55080. */
  55081. readonly cameraPosition: NodeMaterialConnectionPoint;
  55082. /**
  55083. * Gets the glossiness component
  55084. */
  55085. readonly glossiness: NodeMaterialConnectionPoint;
  55086. /**
  55087. * Gets the glossinness power component
  55088. */
  55089. readonly glossPower: NodeMaterialConnectionPoint;
  55090. /**
  55091. * Gets the diffuse color component
  55092. */
  55093. readonly diffuseColor: NodeMaterialConnectionPoint;
  55094. /**
  55095. * Gets the specular color component
  55096. */
  55097. readonly specularColor: NodeMaterialConnectionPoint;
  55098. /**
  55099. * Gets the diffuse output component
  55100. */
  55101. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55102. /**
  55103. * Gets the specular output component
  55104. */
  55105. readonly specularOutput: NodeMaterialConnectionPoint;
  55106. autoConfigure(material: NodeMaterial): void;
  55107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55108. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  55109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55110. private _injectVertexCode;
  55111. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55112. serialize(): any;
  55113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55114. }
  55115. }
  55116. declare module BABYLON {
  55117. /**
  55118. * Block used to multiply 2 values
  55119. */
  55120. export class MultiplyBlock extends NodeMaterialBlock {
  55121. /**
  55122. * Creates a new MultiplyBlock
  55123. * @param name defines the block name
  55124. */
  55125. constructor(name: string);
  55126. /**
  55127. * Gets the current class name
  55128. * @returns the class name
  55129. */
  55130. getClassName(): string;
  55131. /**
  55132. * Gets the left operand input component
  55133. */
  55134. readonly left: NodeMaterialConnectionPoint;
  55135. /**
  55136. * Gets the right operand input component
  55137. */
  55138. readonly right: NodeMaterialConnectionPoint;
  55139. /**
  55140. * Gets the output component
  55141. */
  55142. readonly output: NodeMaterialConnectionPoint;
  55143. protected _buildBlock(state: NodeMaterialBuildState): this;
  55144. }
  55145. }
  55146. declare module BABYLON {
  55147. /**
  55148. * Block used to add 2 vectors
  55149. */
  55150. export class AddBlock extends NodeMaterialBlock {
  55151. /**
  55152. * Creates a new AddBlock
  55153. * @param name defines the block name
  55154. */
  55155. constructor(name: string);
  55156. /**
  55157. * Gets the current class name
  55158. * @returns the class name
  55159. */
  55160. getClassName(): string;
  55161. /**
  55162. * Gets the left operand input component
  55163. */
  55164. readonly left: NodeMaterialConnectionPoint;
  55165. /**
  55166. * Gets the right operand input component
  55167. */
  55168. readonly right: NodeMaterialConnectionPoint;
  55169. /**
  55170. * Gets the output component
  55171. */
  55172. readonly output: NodeMaterialConnectionPoint;
  55173. protected _buildBlock(state: NodeMaterialBuildState): this;
  55174. }
  55175. }
  55176. declare module BABYLON {
  55177. /**
  55178. * Block used to scale a vector by a float
  55179. */
  55180. export class ScaleBlock extends NodeMaterialBlock {
  55181. /**
  55182. * Creates a new ScaleBlock
  55183. * @param name defines the block name
  55184. */
  55185. constructor(name: string);
  55186. /**
  55187. * Gets the current class name
  55188. * @returns the class name
  55189. */
  55190. getClassName(): string;
  55191. /**
  55192. * Gets the input component
  55193. */
  55194. readonly input: NodeMaterialConnectionPoint;
  55195. /**
  55196. * Gets the factor input component
  55197. */
  55198. readonly factor: NodeMaterialConnectionPoint;
  55199. /**
  55200. * Gets the output component
  55201. */
  55202. readonly output: NodeMaterialConnectionPoint;
  55203. protected _buildBlock(state: NodeMaterialBuildState): this;
  55204. }
  55205. }
  55206. declare module BABYLON {
  55207. /**
  55208. * Block used to clamp a float
  55209. */
  55210. export class ClampBlock extends NodeMaterialBlock {
  55211. /** Gets or sets the minimum range */
  55212. minimum: number;
  55213. /** Gets or sets the maximum range */
  55214. maximum: number;
  55215. /**
  55216. * Creates a new ClampBlock
  55217. * @param name defines the block name
  55218. */
  55219. constructor(name: string);
  55220. /**
  55221. * Gets the current class name
  55222. * @returns the class name
  55223. */
  55224. getClassName(): string;
  55225. /**
  55226. * Gets the value input component
  55227. */
  55228. readonly value: NodeMaterialConnectionPoint;
  55229. /**
  55230. * Gets the output component
  55231. */
  55232. readonly output: NodeMaterialConnectionPoint;
  55233. protected _buildBlock(state: NodeMaterialBuildState): this;
  55234. protected _dumpPropertiesCode(): string;
  55235. serialize(): any;
  55236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55237. }
  55238. }
  55239. declare module BABYLON {
  55240. /**
  55241. * Block used to apply a cross product between 2 vectors
  55242. */
  55243. export class CrossBlock extends NodeMaterialBlock {
  55244. /**
  55245. * Creates a new CrossBlock
  55246. * @param name defines the block name
  55247. */
  55248. constructor(name: string);
  55249. /**
  55250. * Gets the current class name
  55251. * @returns the class name
  55252. */
  55253. getClassName(): string;
  55254. /**
  55255. * Gets the left operand input component
  55256. */
  55257. readonly left: NodeMaterialConnectionPoint;
  55258. /**
  55259. * Gets the right operand input component
  55260. */
  55261. readonly right: NodeMaterialConnectionPoint;
  55262. /**
  55263. * Gets the output component
  55264. */
  55265. readonly output: NodeMaterialConnectionPoint;
  55266. protected _buildBlock(state: NodeMaterialBuildState): this;
  55267. }
  55268. }
  55269. declare module BABYLON {
  55270. /**
  55271. * Block used to apply a dot product between 2 vectors
  55272. */
  55273. export class DotBlock extends NodeMaterialBlock {
  55274. /**
  55275. * Creates a new DotBlock
  55276. * @param name defines the block name
  55277. */
  55278. constructor(name: string);
  55279. /**
  55280. * Gets the current class name
  55281. * @returns the class name
  55282. */
  55283. getClassName(): string;
  55284. /**
  55285. * Gets the left operand input component
  55286. */
  55287. readonly left: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the right operand input component
  55290. */
  55291. readonly right: NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the output component
  55294. */
  55295. readonly output: NodeMaterialConnectionPoint;
  55296. protected _buildBlock(state: NodeMaterialBuildState): this;
  55297. }
  55298. }
  55299. declare module BABYLON {
  55300. /**
  55301. * Block used to remap a float from a range to a new one
  55302. */
  55303. export class RemapBlock extends NodeMaterialBlock {
  55304. /**
  55305. * Gets or sets the source range
  55306. */
  55307. sourceRange: Vector2;
  55308. /**
  55309. * Gets or sets the target range
  55310. */
  55311. targetRange: Vector2;
  55312. /**
  55313. * Creates a new RemapBlock
  55314. * @param name defines the block name
  55315. */
  55316. constructor(name: string);
  55317. /**
  55318. * Gets the current class name
  55319. * @returns the class name
  55320. */
  55321. getClassName(): string;
  55322. /**
  55323. * Gets the input component
  55324. */
  55325. readonly input: NodeMaterialConnectionPoint;
  55326. /**
  55327. * Gets the source min input component
  55328. */
  55329. readonly sourceMin: NodeMaterialConnectionPoint;
  55330. /**
  55331. * Gets the source max input component
  55332. */
  55333. readonly sourceMax: NodeMaterialConnectionPoint;
  55334. /**
  55335. * Gets the target min input component
  55336. */
  55337. readonly targetMin: NodeMaterialConnectionPoint;
  55338. /**
  55339. * Gets the target max input component
  55340. */
  55341. readonly targetMax: NodeMaterialConnectionPoint;
  55342. /**
  55343. * Gets the output component
  55344. */
  55345. readonly output: NodeMaterialConnectionPoint;
  55346. protected _buildBlock(state: NodeMaterialBuildState): this;
  55347. protected _dumpPropertiesCode(): string;
  55348. serialize(): any;
  55349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55350. }
  55351. }
  55352. declare module BABYLON {
  55353. /**
  55354. * Block used to normalize a vector
  55355. */
  55356. export class NormalizeBlock extends NodeMaterialBlock {
  55357. /**
  55358. * Creates a new NormalizeBlock
  55359. * @param name defines the block name
  55360. */
  55361. constructor(name: string);
  55362. /**
  55363. * Gets the current class name
  55364. * @returns the class name
  55365. */
  55366. getClassName(): string;
  55367. /**
  55368. * Gets the input component
  55369. */
  55370. readonly input: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the output component
  55373. */
  55374. readonly output: NodeMaterialConnectionPoint;
  55375. protected _buildBlock(state: NodeMaterialBuildState): this;
  55376. }
  55377. }
  55378. declare module BABYLON {
  55379. /**
  55380. * Operations supported by the Trigonometry block
  55381. */
  55382. export enum TrigonometryBlockOperations {
  55383. /** Cos */
  55384. Cos = 0,
  55385. /** Sin */
  55386. Sin = 1,
  55387. /** Abs */
  55388. Abs = 2,
  55389. /** Exp */
  55390. Exp = 3,
  55391. /** Exp2 */
  55392. Exp2 = 4,
  55393. /** Round */
  55394. Round = 5,
  55395. /** Floor */
  55396. Floor = 6,
  55397. /** Ceiling */
  55398. Ceiling = 7,
  55399. /** Square root */
  55400. Sqrt = 8,
  55401. /** Log */
  55402. Log = 9,
  55403. /** Tangent */
  55404. Tan = 10,
  55405. /** Arc tangent */
  55406. ArcTan = 11,
  55407. /** Arc cosinus */
  55408. ArcCos = 12,
  55409. /** Arc sinus */
  55410. ArcSin = 13,
  55411. /** Fraction */
  55412. Fract = 14,
  55413. /** Sign */
  55414. Sign = 15,
  55415. /** To radians (from degrees) */
  55416. Radians = 16,
  55417. /** To degrees (from radians) */
  55418. Degrees = 17
  55419. }
  55420. /**
  55421. * Block used to apply trigonometry operation to floats
  55422. */
  55423. export class TrigonometryBlock extends NodeMaterialBlock {
  55424. /**
  55425. * Gets or sets the operation applied by the block
  55426. */
  55427. operation: TrigonometryBlockOperations;
  55428. /**
  55429. * Creates a new TrigonometryBlock
  55430. * @param name defines the block name
  55431. */
  55432. constructor(name: string);
  55433. /**
  55434. * Gets the current class name
  55435. * @returns the class name
  55436. */
  55437. getClassName(): string;
  55438. /**
  55439. * Gets the input component
  55440. */
  55441. readonly input: NodeMaterialConnectionPoint;
  55442. /**
  55443. * Gets the output component
  55444. */
  55445. readonly output: NodeMaterialConnectionPoint;
  55446. protected _buildBlock(state: NodeMaterialBuildState): this;
  55447. serialize(): any;
  55448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55449. protected _dumpPropertiesCode(): string;
  55450. }
  55451. }
  55452. declare module BABYLON {
  55453. /**
  55454. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55455. */
  55456. export class ColorMergerBlock extends NodeMaterialBlock {
  55457. /**
  55458. * Create a new ColorMergerBlock
  55459. * @param name defines the block name
  55460. */
  55461. constructor(name: string);
  55462. /**
  55463. * Gets the current class name
  55464. * @returns the class name
  55465. */
  55466. getClassName(): string;
  55467. /**
  55468. * Gets the r component (input)
  55469. */
  55470. readonly r: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the g component (input)
  55473. */
  55474. readonly g: NodeMaterialConnectionPoint;
  55475. /**
  55476. * Gets the b component (input)
  55477. */
  55478. readonly b: NodeMaterialConnectionPoint;
  55479. /**
  55480. * Gets the a component (input)
  55481. */
  55482. readonly a: NodeMaterialConnectionPoint;
  55483. /**
  55484. * Gets the rgba component (output)
  55485. */
  55486. readonly rgba: NodeMaterialConnectionPoint;
  55487. /**
  55488. * Gets the rgb component (output)
  55489. */
  55490. readonly rgb: NodeMaterialConnectionPoint;
  55491. protected _buildBlock(state: NodeMaterialBuildState): this;
  55492. }
  55493. }
  55494. declare module BABYLON {
  55495. /**
  55496. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55497. */
  55498. export class VectorMergerBlock extends NodeMaterialBlock {
  55499. /**
  55500. * Create a new VectorMergerBlock
  55501. * @param name defines the block name
  55502. */
  55503. constructor(name: string);
  55504. /**
  55505. * Gets the current class name
  55506. * @returns the class name
  55507. */
  55508. getClassName(): string;
  55509. /**
  55510. * Gets the x component (input)
  55511. */
  55512. readonly x: NodeMaterialConnectionPoint;
  55513. /**
  55514. * Gets the y component (input)
  55515. */
  55516. readonly y: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the z component (input)
  55519. */
  55520. readonly z: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Gets the w component (input)
  55523. */
  55524. readonly w: NodeMaterialConnectionPoint;
  55525. /**
  55526. * Gets the xyzw component (output)
  55527. */
  55528. readonly xyzw: NodeMaterialConnectionPoint;
  55529. /**
  55530. * Gets the xyz component (output)
  55531. */
  55532. readonly xyz: NodeMaterialConnectionPoint;
  55533. /**
  55534. * Gets the xy component (output)
  55535. */
  55536. readonly xy: NodeMaterialConnectionPoint;
  55537. protected _buildBlock(state: NodeMaterialBuildState): this;
  55538. }
  55539. }
  55540. declare module BABYLON {
  55541. /**
  55542. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55543. */
  55544. export class ColorSplitterBlock extends NodeMaterialBlock {
  55545. /**
  55546. * Create a new ColorSplitterBlock
  55547. * @param name defines the block name
  55548. */
  55549. constructor(name: string);
  55550. /**
  55551. * Gets the current class name
  55552. * @returns the class name
  55553. */
  55554. getClassName(): string;
  55555. /**
  55556. * Gets the rgba component (input)
  55557. */
  55558. readonly rgba: NodeMaterialConnectionPoint;
  55559. /**
  55560. * Gets the rgb component (input)
  55561. */
  55562. readonly rgbIn: NodeMaterialConnectionPoint;
  55563. /**
  55564. * Gets the rgb component (output)
  55565. */
  55566. readonly rgbOut: NodeMaterialConnectionPoint;
  55567. /**
  55568. * Gets the r component (output)
  55569. */
  55570. readonly r: NodeMaterialConnectionPoint;
  55571. /**
  55572. * Gets the g component (output)
  55573. */
  55574. readonly g: NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the b component (output)
  55577. */
  55578. readonly b: NodeMaterialConnectionPoint;
  55579. /**
  55580. * Gets the a component (output)
  55581. */
  55582. readonly a: NodeMaterialConnectionPoint;
  55583. protected _inputRename(name: string): string;
  55584. protected _outputRename(name: string): string;
  55585. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55586. }
  55587. }
  55588. declare module BABYLON {
  55589. /**
  55590. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55591. */
  55592. export class VectorSplitterBlock extends NodeMaterialBlock {
  55593. /**
  55594. * Create a new VectorSplitterBlock
  55595. * @param name defines the block name
  55596. */
  55597. constructor(name: string);
  55598. /**
  55599. * Gets the current class name
  55600. * @returns the class name
  55601. */
  55602. getClassName(): string;
  55603. /**
  55604. * Gets the xyzw component (input)
  55605. */
  55606. readonly xyzw: NodeMaterialConnectionPoint;
  55607. /**
  55608. * Gets the xyz component (input)
  55609. */
  55610. readonly xyzIn: NodeMaterialConnectionPoint;
  55611. /**
  55612. * Gets the xy component (input)
  55613. */
  55614. readonly xyIn: NodeMaterialConnectionPoint;
  55615. /**
  55616. * Gets the xyz component (output)
  55617. */
  55618. readonly xyzOut: NodeMaterialConnectionPoint;
  55619. /**
  55620. * Gets the xy component (output)
  55621. */
  55622. readonly xyOut: NodeMaterialConnectionPoint;
  55623. /**
  55624. * Gets the x component (output)
  55625. */
  55626. readonly x: NodeMaterialConnectionPoint;
  55627. /**
  55628. * Gets the y component (output)
  55629. */
  55630. readonly y: NodeMaterialConnectionPoint;
  55631. /**
  55632. * Gets the z component (output)
  55633. */
  55634. readonly z: NodeMaterialConnectionPoint;
  55635. /**
  55636. * Gets the w component (output)
  55637. */
  55638. readonly w: NodeMaterialConnectionPoint;
  55639. protected _inputRename(name: string): string;
  55640. protected _outputRename(name: string): string;
  55641. protected _buildBlock(state: NodeMaterialBuildState): this;
  55642. }
  55643. }
  55644. declare module BABYLON {
  55645. /**
  55646. * Block used to lerp between 2 values
  55647. */
  55648. export class LerpBlock extends NodeMaterialBlock {
  55649. /**
  55650. * Creates a new LerpBlock
  55651. * @param name defines the block name
  55652. */
  55653. constructor(name: string);
  55654. /**
  55655. * Gets the current class name
  55656. * @returns the class name
  55657. */
  55658. getClassName(): string;
  55659. /**
  55660. * Gets the left operand input component
  55661. */
  55662. readonly left: NodeMaterialConnectionPoint;
  55663. /**
  55664. * Gets the right operand input component
  55665. */
  55666. readonly right: NodeMaterialConnectionPoint;
  55667. /**
  55668. * Gets the gradient operand input component
  55669. */
  55670. readonly gradient: NodeMaterialConnectionPoint;
  55671. /**
  55672. * Gets the output component
  55673. */
  55674. readonly output: NodeMaterialConnectionPoint;
  55675. protected _buildBlock(state: NodeMaterialBuildState): this;
  55676. }
  55677. }
  55678. declare module BABYLON {
  55679. /**
  55680. * Block used to divide 2 vectors
  55681. */
  55682. export class DivideBlock extends NodeMaterialBlock {
  55683. /**
  55684. * Creates a new DivideBlock
  55685. * @param name defines the block name
  55686. */
  55687. constructor(name: string);
  55688. /**
  55689. * Gets the current class name
  55690. * @returns the class name
  55691. */
  55692. getClassName(): string;
  55693. /**
  55694. * Gets the left operand input component
  55695. */
  55696. readonly left: NodeMaterialConnectionPoint;
  55697. /**
  55698. * Gets the right operand input component
  55699. */
  55700. readonly right: NodeMaterialConnectionPoint;
  55701. /**
  55702. * Gets the output component
  55703. */
  55704. readonly output: NodeMaterialConnectionPoint;
  55705. protected _buildBlock(state: NodeMaterialBuildState): this;
  55706. }
  55707. }
  55708. declare module BABYLON {
  55709. /**
  55710. * Block used to subtract 2 vectors
  55711. */
  55712. export class SubtractBlock extends NodeMaterialBlock {
  55713. /**
  55714. * Creates a new SubtractBlock
  55715. * @param name defines the block name
  55716. */
  55717. constructor(name: string);
  55718. /**
  55719. * Gets the current class name
  55720. * @returns the class name
  55721. */
  55722. getClassName(): string;
  55723. /**
  55724. * Gets the left operand input component
  55725. */
  55726. readonly left: NodeMaterialConnectionPoint;
  55727. /**
  55728. * Gets the right operand input component
  55729. */
  55730. readonly right: NodeMaterialConnectionPoint;
  55731. /**
  55732. * Gets the output component
  55733. */
  55734. readonly output: NodeMaterialConnectionPoint;
  55735. protected _buildBlock(state: NodeMaterialBuildState): this;
  55736. }
  55737. }
  55738. declare module BABYLON {
  55739. /**
  55740. * Block used to step a value
  55741. */
  55742. export class StepBlock extends NodeMaterialBlock {
  55743. /**
  55744. * Creates a new StepBlock
  55745. * @param name defines the block name
  55746. */
  55747. constructor(name: string);
  55748. /**
  55749. * Gets the current class name
  55750. * @returns the class name
  55751. */
  55752. getClassName(): string;
  55753. /**
  55754. * Gets the value operand input component
  55755. */
  55756. readonly value: NodeMaterialConnectionPoint;
  55757. /**
  55758. * Gets the edge operand input component
  55759. */
  55760. readonly edge: NodeMaterialConnectionPoint;
  55761. /**
  55762. * Gets the output component
  55763. */
  55764. readonly output: NodeMaterialConnectionPoint;
  55765. protected _buildBlock(state: NodeMaterialBuildState): this;
  55766. }
  55767. }
  55768. declare module BABYLON {
  55769. /**
  55770. * Block used to get the opposite (1 - x) of a value
  55771. */
  55772. export class OneMinusBlock extends NodeMaterialBlock {
  55773. /**
  55774. * Creates a new OneMinusBlock
  55775. * @param name defines the block name
  55776. */
  55777. constructor(name: string);
  55778. /**
  55779. * Gets the current class name
  55780. * @returns the class name
  55781. */
  55782. getClassName(): string;
  55783. /**
  55784. * Gets the input component
  55785. */
  55786. readonly input: NodeMaterialConnectionPoint;
  55787. /**
  55788. * Gets the output component
  55789. */
  55790. readonly output: NodeMaterialConnectionPoint;
  55791. protected _buildBlock(state: NodeMaterialBuildState): this;
  55792. }
  55793. }
  55794. declare module BABYLON {
  55795. /**
  55796. * Block used to get the view direction
  55797. */
  55798. export class ViewDirectionBlock extends NodeMaterialBlock {
  55799. /**
  55800. * Creates a new ViewDirectionBlock
  55801. * @param name defines the block name
  55802. */
  55803. constructor(name: string);
  55804. /**
  55805. * Gets the current class name
  55806. * @returns the class name
  55807. */
  55808. getClassName(): string;
  55809. /**
  55810. * Gets the world position component
  55811. */
  55812. readonly worldPosition: NodeMaterialConnectionPoint;
  55813. /**
  55814. * Gets the camera position component
  55815. */
  55816. readonly cameraPosition: NodeMaterialConnectionPoint;
  55817. /**
  55818. * Gets the output component
  55819. */
  55820. readonly output: NodeMaterialConnectionPoint;
  55821. autoConfigure(material: NodeMaterial): void;
  55822. protected _buildBlock(state: NodeMaterialBuildState): this;
  55823. }
  55824. }
  55825. declare module BABYLON {
  55826. /**
  55827. * Block used to compute fresnel value
  55828. */
  55829. export class FresnelBlock extends NodeMaterialBlock {
  55830. /**
  55831. * Create a new FresnelBlock
  55832. * @param name defines the block name
  55833. */
  55834. constructor(name: string);
  55835. /**
  55836. * Gets the current class name
  55837. * @returns the class name
  55838. */
  55839. getClassName(): string;
  55840. /**
  55841. * Gets the world normal input component
  55842. */
  55843. readonly worldNormal: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the view direction input component
  55846. */
  55847. readonly viewDirection: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the bias input component
  55850. */
  55851. readonly bias: NodeMaterialConnectionPoint;
  55852. /**
  55853. * Gets the camera (or eye) position component
  55854. */
  55855. readonly power: NodeMaterialConnectionPoint;
  55856. /**
  55857. * Gets the fresnel output component
  55858. */
  55859. readonly fresnel: NodeMaterialConnectionPoint;
  55860. autoConfigure(material: NodeMaterial): void;
  55861. protected _buildBlock(state: NodeMaterialBuildState): this;
  55862. }
  55863. }
  55864. declare module BABYLON {
  55865. /**
  55866. * Block used to get the max of 2 values
  55867. */
  55868. export class MaxBlock extends NodeMaterialBlock {
  55869. /**
  55870. * Creates a new MaxBlock
  55871. * @param name defines the block name
  55872. */
  55873. constructor(name: string);
  55874. /**
  55875. * Gets the current class name
  55876. * @returns the class name
  55877. */
  55878. getClassName(): string;
  55879. /**
  55880. * Gets the left operand input component
  55881. */
  55882. readonly left: NodeMaterialConnectionPoint;
  55883. /**
  55884. * Gets the right operand input component
  55885. */
  55886. readonly right: NodeMaterialConnectionPoint;
  55887. /**
  55888. * Gets the output component
  55889. */
  55890. readonly output: NodeMaterialConnectionPoint;
  55891. protected _buildBlock(state: NodeMaterialBuildState): this;
  55892. }
  55893. }
  55894. declare module BABYLON {
  55895. /**
  55896. * Block used to get the min of 2 values
  55897. */
  55898. export class MinBlock extends NodeMaterialBlock {
  55899. /**
  55900. * Creates a new MinBlock
  55901. * @param name defines the block name
  55902. */
  55903. constructor(name: string);
  55904. /**
  55905. * Gets the current class name
  55906. * @returns the class name
  55907. */
  55908. getClassName(): string;
  55909. /**
  55910. * Gets the left operand input component
  55911. */
  55912. readonly left: NodeMaterialConnectionPoint;
  55913. /**
  55914. * Gets the right operand input component
  55915. */
  55916. readonly right: NodeMaterialConnectionPoint;
  55917. /**
  55918. * Gets the output component
  55919. */
  55920. readonly output: NodeMaterialConnectionPoint;
  55921. protected _buildBlock(state: NodeMaterialBuildState): this;
  55922. }
  55923. }
  55924. declare module BABYLON {
  55925. /**
  55926. * Block used to get the distance between 2 values
  55927. */
  55928. export class DistanceBlock extends NodeMaterialBlock {
  55929. /**
  55930. * Creates a new DistanceBlock
  55931. * @param name defines the block name
  55932. */
  55933. constructor(name: string);
  55934. /**
  55935. * Gets the current class name
  55936. * @returns the class name
  55937. */
  55938. getClassName(): string;
  55939. /**
  55940. * Gets the left operand input component
  55941. */
  55942. readonly left: NodeMaterialConnectionPoint;
  55943. /**
  55944. * Gets the right operand input component
  55945. */
  55946. readonly right: NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the output component
  55949. */
  55950. readonly output: NodeMaterialConnectionPoint;
  55951. protected _buildBlock(state: NodeMaterialBuildState): this;
  55952. }
  55953. }
  55954. declare module BABYLON {
  55955. /**
  55956. * Block used to get the length of a vector
  55957. */
  55958. export class LengthBlock extends NodeMaterialBlock {
  55959. /**
  55960. * Creates a new LengthBlock
  55961. * @param name defines the block name
  55962. */
  55963. constructor(name: string);
  55964. /**
  55965. * Gets the current class name
  55966. * @returns the class name
  55967. */
  55968. getClassName(): string;
  55969. /**
  55970. * Gets the value input component
  55971. */
  55972. readonly value: NodeMaterialConnectionPoint;
  55973. /**
  55974. * Gets the output component
  55975. */
  55976. readonly output: NodeMaterialConnectionPoint;
  55977. protected _buildBlock(state: NodeMaterialBuildState): this;
  55978. }
  55979. }
  55980. declare module BABYLON {
  55981. /**
  55982. * Block used to get negative version of a value (i.e. x * -1)
  55983. */
  55984. export class NegateBlock extends NodeMaterialBlock {
  55985. /**
  55986. * Creates a new NegateBlock
  55987. * @param name defines the block name
  55988. */
  55989. constructor(name: string);
  55990. /**
  55991. * Gets the current class name
  55992. * @returns the class name
  55993. */
  55994. getClassName(): string;
  55995. /**
  55996. * Gets the value input component
  55997. */
  55998. readonly value: NodeMaterialConnectionPoint;
  55999. /**
  56000. * Gets the output component
  56001. */
  56002. readonly output: NodeMaterialConnectionPoint;
  56003. protected _buildBlock(state: NodeMaterialBuildState): this;
  56004. }
  56005. }
  56006. declare module BABYLON {
  56007. /**
  56008. * Block used to get the value of the first parameter raised to the power of the second
  56009. */
  56010. export class PowBlock extends NodeMaterialBlock {
  56011. /**
  56012. * Creates a new PowBlock
  56013. * @param name defines the block name
  56014. */
  56015. constructor(name: string);
  56016. /**
  56017. * Gets the current class name
  56018. * @returns the class name
  56019. */
  56020. getClassName(): string;
  56021. /**
  56022. * Gets the value operand input component
  56023. */
  56024. readonly value: NodeMaterialConnectionPoint;
  56025. /**
  56026. * Gets the power operand input component
  56027. */
  56028. readonly power: NodeMaterialConnectionPoint;
  56029. /**
  56030. * Gets the output component
  56031. */
  56032. readonly output: NodeMaterialConnectionPoint;
  56033. protected _buildBlock(state: NodeMaterialBuildState): this;
  56034. }
  56035. }
  56036. declare module BABYLON {
  56037. /**
  56038. * Block used to get a random number
  56039. */
  56040. export class RandomNumberBlock extends NodeMaterialBlock {
  56041. /**
  56042. * Creates a new RandomNumberBlock
  56043. * @param name defines the block name
  56044. */
  56045. constructor(name: string);
  56046. /**
  56047. * Gets the current class name
  56048. * @returns the class name
  56049. */
  56050. getClassName(): string;
  56051. /**
  56052. * Gets the seed input component
  56053. */
  56054. readonly seed: NodeMaterialConnectionPoint;
  56055. /**
  56056. * Gets the output component
  56057. */
  56058. readonly output: NodeMaterialConnectionPoint;
  56059. protected _buildBlock(state: NodeMaterialBuildState): this;
  56060. }
  56061. }
  56062. declare module BABYLON {
  56063. /**
  56064. * Block used to compute arc tangent of 2 values
  56065. */
  56066. export class ArcTan2Block extends NodeMaterialBlock {
  56067. /**
  56068. * Creates a new ArcTan2Block
  56069. * @param name defines the block name
  56070. */
  56071. constructor(name: string);
  56072. /**
  56073. * Gets the current class name
  56074. * @returns the class name
  56075. */
  56076. getClassName(): string;
  56077. /**
  56078. * Gets the x operand input component
  56079. */
  56080. readonly x: NodeMaterialConnectionPoint;
  56081. /**
  56082. * Gets the y operand input component
  56083. */
  56084. readonly y: NodeMaterialConnectionPoint;
  56085. /**
  56086. * Gets the output component
  56087. */
  56088. readonly output: NodeMaterialConnectionPoint;
  56089. protected _buildBlock(state: NodeMaterialBuildState): this;
  56090. }
  56091. }
  56092. declare module BABYLON {
  56093. /**
  56094. * Block used to smooth step a value
  56095. */
  56096. export class SmoothStepBlock extends NodeMaterialBlock {
  56097. /**
  56098. * Creates a new SmoothStepBlock
  56099. * @param name defines the block name
  56100. */
  56101. constructor(name: string);
  56102. /**
  56103. * Gets the current class name
  56104. * @returns the class name
  56105. */
  56106. getClassName(): string;
  56107. /**
  56108. * Gets the value operand input component
  56109. */
  56110. readonly value: NodeMaterialConnectionPoint;
  56111. /**
  56112. * Gets the first edge operand input component
  56113. */
  56114. readonly edge0: NodeMaterialConnectionPoint;
  56115. /**
  56116. * Gets the second edge operand input component
  56117. */
  56118. readonly edge1: NodeMaterialConnectionPoint;
  56119. /**
  56120. * Gets the output component
  56121. */
  56122. readonly output: NodeMaterialConnectionPoint;
  56123. protected _buildBlock(state: NodeMaterialBuildState): this;
  56124. }
  56125. }
  56126. declare module BABYLON {
  56127. /**
  56128. * Block used to get the reciprocal (1 / x) of a value
  56129. */
  56130. export class ReciprocalBlock extends NodeMaterialBlock {
  56131. /**
  56132. * Creates a new ReciprocalBlock
  56133. * @param name defines the block name
  56134. */
  56135. constructor(name: string);
  56136. /**
  56137. * Gets the current class name
  56138. * @returns the class name
  56139. */
  56140. getClassName(): string;
  56141. /**
  56142. * Gets the input component
  56143. */
  56144. readonly input: NodeMaterialConnectionPoint;
  56145. /**
  56146. * Gets the output component
  56147. */
  56148. readonly output: NodeMaterialConnectionPoint;
  56149. protected _buildBlock(state: NodeMaterialBuildState): this;
  56150. }
  56151. }
  56152. declare module BABYLON {
  56153. /**
  56154. * Block used to replace a color by another one
  56155. */
  56156. export class ReplaceColorBlock extends NodeMaterialBlock {
  56157. /**
  56158. * Creates a new ReplaceColorBlock
  56159. * @param name defines the block name
  56160. */
  56161. constructor(name: string);
  56162. /**
  56163. * Gets the current class name
  56164. * @returns the class name
  56165. */
  56166. getClassName(): string;
  56167. /**
  56168. * Gets the value input component
  56169. */
  56170. readonly value: NodeMaterialConnectionPoint;
  56171. /**
  56172. * Gets the reference input component
  56173. */
  56174. readonly reference: NodeMaterialConnectionPoint;
  56175. /**
  56176. * Gets the distance input component
  56177. */
  56178. readonly distance: NodeMaterialConnectionPoint;
  56179. /**
  56180. * Gets the replacement input component
  56181. */
  56182. readonly replacement: NodeMaterialConnectionPoint;
  56183. /**
  56184. * Gets the output component
  56185. */
  56186. readonly output: NodeMaterialConnectionPoint;
  56187. protected _buildBlock(state: NodeMaterialBuildState): this;
  56188. }
  56189. }
  56190. declare module BABYLON {
  56191. /**
  56192. * Block used to posterize a value
  56193. * @see https://en.wikipedia.org/wiki/Posterization
  56194. */
  56195. export class PosterizeBlock extends NodeMaterialBlock {
  56196. /**
  56197. * Creates a new PosterizeBlock
  56198. * @param name defines the block name
  56199. */
  56200. constructor(name: string);
  56201. /**
  56202. * Gets the current class name
  56203. * @returns the class name
  56204. */
  56205. getClassName(): string;
  56206. /**
  56207. * Gets the value input component
  56208. */
  56209. readonly value: NodeMaterialConnectionPoint;
  56210. /**
  56211. * Gets the steps input component
  56212. */
  56213. readonly steps: NodeMaterialConnectionPoint;
  56214. /**
  56215. * Gets the output component
  56216. */
  56217. readonly output: NodeMaterialConnectionPoint;
  56218. protected _buildBlock(state: NodeMaterialBuildState): this;
  56219. }
  56220. }
  56221. declare module BABYLON {
  56222. /**
  56223. * Operations supported by the Wave block
  56224. */
  56225. export enum WaveBlockKind {
  56226. /** SawTooth */
  56227. SawTooth = 0,
  56228. /** Square */
  56229. Square = 1,
  56230. /** Triangle */
  56231. Triangle = 2
  56232. }
  56233. /**
  56234. * Block used to apply wave operation to floats
  56235. */
  56236. export class WaveBlock extends NodeMaterialBlock {
  56237. /**
  56238. * Gets or sets the kibnd of wave to be applied by the block
  56239. */
  56240. kind: WaveBlockKind;
  56241. /**
  56242. * Creates a new WaveBlock
  56243. * @param name defines the block name
  56244. */
  56245. constructor(name: string);
  56246. /**
  56247. * Gets the current class name
  56248. * @returns the class name
  56249. */
  56250. getClassName(): string;
  56251. /**
  56252. * Gets the input component
  56253. */
  56254. readonly input: NodeMaterialConnectionPoint;
  56255. /**
  56256. * Gets the output component
  56257. */
  56258. readonly output: NodeMaterialConnectionPoint;
  56259. protected _buildBlock(state: NodeMaterialBuildState): this;
  56260. serialize(): any;
  56261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56262. }
  56263. }
  56264. declare module BABYLON {
  56265. /**
  56266. * Class used to store a color step for the GradientBlock
  56267. */
  56268. export class GradientBlockColorStep {
  56269. /**
  56270. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56271. */
  56272. step: number;
  56273. /**
  56274. * Gets or sets the color associated with this step
  56275. */
  56276. color: Color3;
  56277. /**
  56278. * Creates a new GradientBlockColorStep
  56279. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56280. * @param color defines the color associated with this step
  56281. */
  56282. constructor(
  56283. /**
  56284. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56285. */
  56286. step: number,
  56287. /**
  56288. * Gets or sets the color associated with this step
  56289. */
  56290. color: Color3);
  56291. }
  56292. /**
  56293. * Block used to return a color from a gradient based on an input value between 0 and 1
  56294. */
  56295. export class GradientBlock extends NodeMaterialBlock {
  56296. /**
  56297. * Gets or sets the list of color steps
  56298. */
  56299. colorSteps: GradientBlockColorStep[];
  56300. /**
  56301. * Creates a new GradientBlock
  56302. * @param name defines the block name
  56303. */
  56304. constructor(name: string);
  56305. /**
  56306. * Gets the current class name
  56307. * @returns the class name
  56308. */
  56309. getClassName(): string;
  56310. /**
  56311. * Gets the gradient input component
  56312. */
  56313. readonly gradient: NodeMaterialConnectionPoint;
  56314. /**
  56315. * Gets the output component
  56316. */
  56317. readonly output: NodeMaterialConnectionPoint;
  56318. private _writeColorConstant;
  56319. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56320. serialize(): any;
  56321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56322. protected _dumpPropertiesCode(): string;
  56323. }
  56324. }
  56325. declare module BABYLON {
  56326. /**
  56327. * Block used to normalize lerp between 2 values
  56328. */
  56329. export class NLerpBlock extends NodeMaterialBlock {
  56330. /**
  56331. * Creates a new NLerpBlock
  56332. * @param name defines the block name
  56333. */
  56334. constructor(name: string);
  56335. /**
  56336. * Gets the current class name
  56337. * @returns the class name
  56338. */
  56339. getClassName(): string;
  56340. /**
  56341. * Gets the left operand input component
  56342. */
  56343. readonly left: NodeMaterialConnectionPoint;
  56344. /**
  56345. * Gets the right operand input component
  56346. */
  56347. readonly right: NodeMaterialConnectionPoint;
  56348. /**
  56349. * Gets the gradient operand input component
  56350. */
  56351. readonly gradient: NodeMaterialConnectionPoint;
  56352. /**
  56353. * Gets the output component
  56354. */
  56355. readonly output: NodeMaterialConnectionPoint;
  56356. protected _buildBlock(state: NodeMaterialBuildState): this;
  56357. }
  56358. }
  56359. declare module BABYLON {
  56360. /**
  56361. * block used to Generate a Worley Noise 3D Noise Pattern
  56362. */
  56363. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  56364. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56365. manhattanDistance: boolean;
  56366. /**
  56367. * Creates a new WorleyNoise3DBlock
  56368. * @param name defines the block name
  56369. */
  56370. constructor(name: string);
  56371. /**
  56372. * Gets the current class name
  56373. * @returns the class name
  56374. */
  56375. getClassName(): string;
  56376. /**
  56377. * Gets the position input component
  56378. */
  56379. readonly position: NodeMaterialConnectionPoint;
  56380. /**
  56381. * Gets the jitter input component
  56382. */
  56383. readonly jitter: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the output component
  56386. */
  56387. readonly output: NodeMaterialConnectionPoint;
  56388. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56389. /**
  56390. * Exposes the properties to the UI?
  56391. */
  56392. protected _dumpPropertiesCode(): string;
  56393. /**
  56394. * Exposes the properties to the Seralize?
  56395. */
  56396. serialize(): any;
  56397. /**
  56398. * Exposes the properties to the deseralize?
  56399. */
  56400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56401. }
  56402. }
  56403. declare module BABYLON {
  56404. /**
  56405. * block used to Generate a Simplex Perlin 3d Noise Pattern
  56406. */
  56407. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  56408. /**
  56409. * Creates a new SimplexPerlin3DBlock
  56410. * @param name defines the block name
  56411. */
  56412. constructor(name: string);
  56413. /**
  56414. * Gets the current class name
  56415. * @returns the class name
  56416. */
  56417. getClassName(): string;
  56418. /**
  56419. * Gets the position operand input component
  56420. */
  56421. readonly position: NodeMaterialConnectionPoint;
  56422. /**
  56423. * Gets the output component
  56424. */
  56425. readonly output: NodeMaterialConnectionPoint;
  56426. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56427. }
  56428. }
  56429. declare module BABYLON {
  56430. /**
  56431. * Effect Render Options
  56432. */
  56433. export interface IEffectRendererOptions {
  56434. /**
  56435. * Defines the vertices positions.
  56436. */
  56437. positions?: number[];
  56438. /**
  56439. * Defines the indices.
  56440. */
  56441. indices?: number[];
  56442. }
  56443. /**
  56444. * Helper class to render one or more effects
  56445. */
  56446. export class EffectRenderer {
  56447. private engine;
  56448. private static _DefaultOptions;
  56449. private _vertexBuffers;
  56450. private _indexBuffer;
  56451. private _ringBufferIndex;
  56452. private _ringScreenBuffer;
  56453. private _fullscreenViewport;
  56454. private _getNextFrameBuffer;
  56455. /**
  56456. * Creates an effect renderer
  56457. * @param engine the engine to use for rendering
  56458. * @param options defines the options of the effect renderer
  56459. */
  56460. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  56461. /**
  56462. * Sets the current viewport in normalized coordinates 0-1
  56463. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56464. */
  56465. setViewport(viewport?: Viewport): void;
  56466. /**
  56467. * Binds the embedded attributes buffer to the effect.
  56468. * @param effect Defines the effect to bind the attributes for
  56469. */
  56470. bindBuffers(effect: Effect): void;
  56471. /**
  56472. * Sets the current effect wrapper to use during draw.
  56473. * The effect needs to be ready before calling this api.
  56474. * This also sets the default full screen position attribute.
  56475. * @param effectWrapper Defines the effect to draw with
  56476. */
  56477. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56478. /**
  56479. * Draws a full screen quad.
  56480. */
  56481. draw(): void;
  56482. /**
  56483. * renders one or more effects to a specified texture
  56484. * @param effectWrappers list of effects to renderer
  56485. * @param outputTexture texture to draw to, if null it will render to the screen
  56486. */
  56487. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56488. /**
  56489. * Disposes of the effect renderer
  56490. */
  56491. dispose(): void;
  56492. }
  56493. /**
  56494. * Options to create an EffectWrapper
  56495. */
  56496. interface EffectWrapperCreationOptions {
  56497. /**
  56498. * Engine to use to create the effect
  56499. */
  56500. engine: ThinEngine;
  56501. /**
  56502. * Fragment shader for the effect
  56503. */
  56504. fragmentShader: string;
  56505. /**
  56506. * Vertex shader for the effect
  56507. */
  56508. vertexShader?: string;
  56509. /**
  56510. * Attributes to use in the shader
  56511. */
  56512. attributeNames?: Array<string>;
  56513. /**
  56514. * Uniforms to use in the shader
  56515. */
  56516. uniformNames?: Array<string>;
  56517. /**
  56518. * Texture sampler names to use in the shader
  56519. */
  56520. samplerNames?: Array<string>;
  56521. /**
  56522. * The friendly name of the effect displayed in Spector.
  56523. */
  56524. name?: string;
  56525. }
  56526. /**
  56527. * Wraps an effect to be used for rendering
  56528. */
  56529. export class EffectWrapper {
  56530. /**
  56531. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56532. */
  56533. onApplyObservable: Observable<{}>;
  56534. /**
  56535. * The underlying effect
  56536. */
  56537. effect: Effect;
  56538. /**
  56539. * Creates an effect to be renderer
  56540. * @param creationOptions options to create the effect
  56541. */
  56542. constructor(creationOptions: EffectWrapperCreationOptions);
  56543. /**
  56544. * Disposes of the effect wrapper
  56545. */
  56546. dispose(): void;
  56547. }
  56548. }
  56549. declare module BABYLON {
  56550. /**
  56551. * Helper class to push actions to a pool of workers.
  56552. */
  56553. export class WorkerPool implements IDisposable {
  56554. private _workerInfos;
  56555. private _pendingActions;
  56556. /**
  56557. * Constructor
  56558. * @param workers Array of workers to use for actions
  56559. */
  56560. constructor(workers: Array<Worker>);
  56561. /**
  56562. * Terminates all workers and clears any pending actions.
  56563. */
  56564. dispose(): void;
  56565. /**
  56566. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56567. * pended until a worker has completed its action.
  56568. * @param action The action to perform. Call onComplete when the action is complete.
  56569. */
  56570. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56571. private _execute;
  56572. }
  56573. }
  56574. declare module BABYLON {
  56575. /**
  56576. * Configuration for Draco compression
  56577. */
  56578. export interface IDracoCompressionConfiguration {
  56579. /**
  56580. * Configuration for the decoder.
  56581. */
  56582. decoder: {
  56583. /**
  56584. * The url to the WebAssembly module.
  56585. */
  56586. wasmUrl?: string;
  56587. /**
  56588. * The url to the WebAssembly binary.
  56589. */
  56590. wasmBinaryUrl?: string;
  56591. /**
  56592. * The url to the fallback JavaScript module.
  56593. */
  56594. fallbackUrl?: string;
  56595. };
  56596. }
  56597. /**
  56598. * Draco compression (https://google.github.io/draco/)
  56599. *
  56600. * This class wraps the Draco module.
  56601. *
  56602. * **Encoder**
  56603. *
  56604. * The encoder is not currently implemented.
  56605. *
  56606. * **Decoder**
  56607. *
  56608. * 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.
  56609. *
  56610. * To update the configuration, use the following code:
  56611. * ```javascript
  56612. * DracoCompression.Configuration = {
  56613. * decoder: {
  56614. * wasmUrl: "<url to the WebAssembly library>",
  56615. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56616. * fallbackUrl: "<url to the fallback JavaScript library>",
  56617. * }
  56618. * };
  56619. * ```
  56620. *
  56621. * 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.
  56622. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56623. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56624. *
  56625. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56626. * ```javascript
  56627. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56628. * ```
  56629. *
  56630. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56631. */
  56632. export class DracoCompression implements IDisposable {
  56633. private _workerPoolPromise?;
  56634. private _decoderModulePromise?;
  56635. /**
  56636. * The configuration. Defaults to the following urls:
  56637. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56638. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56639. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56640. */
  56641. static Configuration: IDracoCompressionConfiguration;
  56642. /**
  56643. * Returns true if the decoder configuration is available.
  56644. */
  56645. static readonly DecoderAvailable: boolean;
  56646. /**
  56647. * Default number of workers to create when creating the draco compression object.
  56648. */
  56649. static DefaultNumWorkers: number;
  56650. private static GetDefaultNumWorkers;
  56651. private static _Default;
  56652. /**
  56653. * Default instance for the draco compression object.
  56654. */
  56655. static readonly Default: DracoCompression;
  56656. /**
  56657. * Constructor
  56658. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56659. */
  56660. constructor(numWorkers?: number);
  56661. /**
  56662. * Stop all async operations and release resources.
  56663. */
  56664. dispose(): void;
  56665. /**
  56666. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56667. * @returns a promise that resolves when ready
  56668. */
  56669. whenReadyAsync(): Promise<void>;
  56670. /**
  56671. * Decode Draco compressed mesh data to vertex data.
  56672. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56673. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56674. * @returns A promise that resolves with the decoded vertex data
  56675. */
  56676. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56677. [kind: string]: number;
  56678. }): Promise<VertexData>;
  56679. }
  56680. }
  56681. declare module BABYLON {
  56682. /**
  56683. * Class for building Constructive Solid Geometry
  56684. */
  56685. export class CSG {
  56686. private polygons;
  56687. /**
  56688. * The world matrix
  56689. */
  56690. matrix: Matrix;
  56691. /**
  56692. * Stores the position
  56693. */
  56694. position: Vector3;
  56695. /**
  56696. * Stores the rotation
  56697. */
  56698. rotation: Vector3;
  56699. /**
  56700. * Stores the rotation quaternion
  56701. */
  56702. rotationQuaternion: Nullable<Quaternion>;
  56703. /**
  56704. * Stores the scaling vector
  56705. */
  56706. scaling: Vector3;
  56707. /**
  56708. * Convert the Mesh to CSG
  56709. * @param mesh The Mesh to convert to CSG
  56710. * @returns A new CSG from the Mesh
  56711. */
  56712. static FromMesh(mesh: Mesh): CSG;
  56713. /**
  56714. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56715. * @param polygons Polygons used to construct a CSG solid
  56716. */
  56717. private static FromPolygons;
  56718. /**
  56719. * Clones, or makes a deep copy, of the CSG
  56720. * @returns A new CSG
  56721. */
  56722. clone(): CSG;
  56723. /**
  56724. * Unions this CSG with another CSG
  56725. * @param csg The CSG to union against this CSG
  56726. * @returns The unioned CSG
  56727. */
  56728. union(csg: CSG): CSG;
  56729. /**
  56730. * Unions this CSG with another CSG in place
  56731. * @param csg The CSG to union against this CSG
  56732. */
  56733. unionInPlace(csg: CSG): void;
  56734. /**
  56735. * Subtracts this CSG with another CSG
  56736. * @param csg The CSG to subtract against this CSG
  56737. * @returns A new CSG
  56738. */
  56739. subtract(csg: CSG): CSG;
  56740. /**
  56741. * Subtracts this CSG with another CSG in place
  56742. * @param csg The CSG to subtact against this CSG
  56743. */
  56744. subtractInPlace(csg: CSG): void;
  56745. /**
  56746. * Intersect this CSG with another CSG
  56747. * @param csg The CSG to intersect against this CSG
  56748. * @returns A new CSG
  56749. */
  56750. intersect(csg: CSG): CSG;
  56751. /**
  56752. * Intersects this CSG with another CSG in place
  56753. * @param csg The CSG to intersect against this CSG
  56754. */
  56755. intersectInPlace(csg: CSG): void;
  56756. /**
  56757. * Return a new CSG solid with solid and empty space switched. This solid is
  56758. * not modified.
  56759. * @returns A new CSG solid with solid and empty space switched
  56760. */
  56761. inverse(): CSG;
  56762. /**
  56763. * Inverses the CSG in place
  56764. */
  56765. inverseInPlace(): void;
  56766. /**
  56767. * This is used to keep meshes transformations so they can be restored
  56768. * when we build back a Babylon Mesh
  56769. * NB : All CSG operations are performed in world coordinates
  56770. * @param csg The CSG to copy the transform attributes from
  56771. * @returns This CSG
  56772. */
  56773. copyTransformAttributes(csg: CSG): CSG;
  56774. /**
  56775. * Build Raw mesh from CSG
  56776. * Coordinates here are in world space
  56777. * @param name The name of the mesh geometry
  56778. * @param scene The Scene
  56779. * @param keepSubMeshes Specifies if the submeshes should be kept
  56780. * @returns A new Mesh
  56781. */
  56782. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56783. /**
  56784. * Build Mesh from CSG taking material and transforms into account
  56785. * @param name The name of the Mesh
  56786. * @param material The material of the Mesh
  56787. * @param scene The Scene
  56788. * @param keepSubMeshes Specifies if submeshes should be kept
  56789. * @returns The new Mesh
  56790. */
  56791. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56792. }
  56793. }
  56794. declare module BABYLON {
  56795. /**
  56796. * Class used to create a trail following a mesh
  56797. */
  56798. export class TrailMesh extends Mesh {
  56799. private _generator;
  56800. private _autoStart;
  56801. private _running;
  56802. private _diameter;
  56803. private _length;
  56804. private _sectionPolygonPointsCount;
  56805. private _sectionVectors;
  56806. private _sectionNormalVectors;
  56807. private _beforeRenderObserver;
  56808. /**
  56809. * @constructor
  56810. * @param name The value used by scene.getMeshByName() to do a lookup.
  56811. * @param generator The mesh to generate a trail.
  56812. * @param scene The scene to add this mesh to.
  56813. * @param diameter Diameter of trailing mesh. Default is 1.
  56814. * @param length Length of trailing mesh. Default is 60.
  56815. * @param autoStart Automatically start trailing mesh. Default true.
  56816. */
  56817. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56818. /**
  56819. * "TrailMesh"
  56820. * @returns "TrailMesh"
  56821. */
  56822. getClassName(): string;
  56823. private _createMesh;
  56824. /**
  56825. * Start trailing mesh.
  56826. */
  56827. start(): void;
  56828. /**
  56829. * Stop trailing mesh.
  56830. */
  56831. stop(): void;
  56832. /**
  56833. * Update trailing mesh geometry.
  56834. */
  56835. update(): void;
  56836. /**
  56837. * Returns a new TrailMesh object.
  56838. * @param name is a string, the name given to the new mesh
  56839. * @param newGenerator use new generator object for cloned trail mesh
  56840. * @returns a new mesh
  56841. */
  56842. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56843. /**
  56844. * Serializes this trail mesh
  56845. * @param serializationObject object to write serialization to
  56846. */
  56847. serialize(serializationObject: any): void;
  56848. /**
  56849. * Parses a serialized trail mesh
  56850. * @param parsedMesh the serialized mesh
  56851. * @param scene the scene to create the trail mesh in
  56852. * @returns the created trail mesh
  56853. */
  56854. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56855. }
  56856. }
  56857. declare module BABYLON {
  56858. /**
  56859. * Class containing static functions to help procedurally build meshes
  56860. */
  56861. export class TiledBoxBuilder {
  56862. /**
  56863. * Creates a box mesh
  56864. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  56865. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56867. * * 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
  56868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56869. * @param name defines the name of the mesh
  56870. * @param options defines the options used to create the mesh
  56871. * @param scene defines the hosting scene
  56872. * @returns the box mesh
  56873. */
  56874. static CreateTiledBox(name: string, options: {
  56875. pattern?: number;
  56876. width?: number;
  56877. height?: number;
  56878. depth?: number;
  56879. tileSize?: number;
  56880. tileWidth?: number;
  56881. tileHeight?: number;
  56882. alignHorizontal?: number;
  56883. alignVertical?: number;
  56884. faceUV?: Vector4[];
  56885. faceColors?: Color4[];
  56886. sideOrientation?: number;
  56887. updatable?: boolean;
  56888. }, scene?: Nullable<Scene>): Mesh;
  56889. }
  56890. }
  56891. declare module BABYLON {
  56892. /**
  56893. * Class containing static functions to help procedurally build meshes
  56894. */
  56895. export class TorusKnotBuilder {
  56896. /**
  56897. * Creates a torus knot mesh
  56898. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56899. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56900. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56901. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56903. * * 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
  56904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56905. * @param name defines the name of the mesh
  56906. * @param options defines the options used to create the mesh
  56907. * @param scene defines the hosting scene
  56908. * @returns the torus knot mesh
  56909. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56910. */
  56911. static CreateTorusKnot(name: string, options: {
  56912. radius?: number;
  56913. tube?: number;
  56914. radialSegments?: number;
  56915. tubularSegments?: number;
  56916. p?: number;
  56917. q?: number;
  56918. updatable?: boolean;
  56919. sideOrientation?: number;
  56920. frontUVs?: Vector4;
  56921. backUVs?: Vector4;
  56922. }, scene: any): Mesh;
  56923. }
  56924. }
  56925. declare module BABYLON {
  56926. /**
  56927. * Polygon
  56928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56929. */
  56930. export class Polygon {
  56931. /**
  56932. * Creates a rectangle
  56933. * @param xmin bottom X coord
  56934. * @param ymin bottom Y coord
  56935. * @param xmax top X coord
  56936. * @param ymax top Y coord
  56937. * @returns points that make the resulting rectation
  56938. */
  56939. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56940. /**
  56941. * Creates a circle
  56942. * @param radius radius of circle
  56943. * @param cx scale in x
  56944. * @param cy scale in y
  56945. * @param numberOfSides number of sides that make up the circle
  56946. * @returns points that make the resulting circle
  56947. */
  56948. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56949. /**
  56950. * Creates a polygon from input string
  56951. * @param input Input polygon data
  56952. * @returns the parsed points
  56953. */
  56954. static Parse(input: string): Vector2[];
  56955. /**
  56956. * Starts building a polygon from x and y coordinates
  56957. * @param x x coordinate
  56958. * @param y y coordinate
  56959. * @returns the started path2
  56960. */
  56961. static StartingAt(x: number, y: number): Path2;
  56962. }
  56963. /**
  56964. * Builds a polygon
  56965. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56966. */
  56967. export class PolygonMeshBuilder {
  56968. private _points;
  56969. private _outlinepoints;
  56970. private _holes;
  56971. private _name;
  56972. private _scene;
  56973. private _epoints;
  56974. private _eholes;
  56975. private _addToepoint;
  56976. /**
  56977. * Babylon reference to the earcut plugin.
  56978. */
  56979. bjsEarcut: any;
  56980. /**
  56981. * Creates a PolygonMeshBuilder
  56982. * @param name name of the builder
  56983. * @param contours Path of the polygon
  56984. * @param scene scene to add to when creating the mesh
  56985. * @param earcutInjection can be used to inject your own earcut reference
  56986. */
  56987. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56988. /**
  56989. * Adds a whole within the polygon
  56990. * @param hole Array of points defining the hole
  56991. * @returns this
  56992. */
  56993. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56994. /**
  56995. * Creates the polygon
  56996. * @param updatable If the mesh should be updatable
  56997. * @param depth The depth of the mesh created
  56998. * @returns the created mesh
  56999. */
  57000. build(updatable?: boolean, depth?: number): Mesh;
  57001. /**
  57002. * Creates the polygon
  57003. * @param depth The depth of the mesh created
  57004. * @returns the created VertexData
  57005. */
  57006. buildVertexData(depth?: number): VertexData;
  57007. /**
  57008. * Adds a side to the polygon
  57009. * @param positions points that make the polygon
  57010. * @param normals normals of the polygon
  57011. * @param uvs uvs of the polygon
  57012. * @param indices indices of the polygon
  57013. * @param bounds bounds of the polygon
  57014. * @param points points of the polygon
  57015. * @param depth depth of the polygon
  57016. * @param flip flip of the polygon
  57017. */
  57018. private addSide;
  57019. }
  57020. }
  57021. declare module BABYLON {
  57022. /**
  57023. * Class containing static functions to help procedurally build meshes
  57024. */
  57025. export class PolygonBuilder {
  57026. /**
  57027. * Creates a polygon mesh
  57028. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57029. * * 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
  57030. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57032. * * 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)
  57033. * * Remember you can only change the shape positions, not their number when updating a polygon
  57034. * @param name defines the name of the mesh
  57035. * @param options defines the options used to create the mesh
  57036. * @param scene defines the hosting scene
  57037. * @param earcutInjection can be used to inject your own earcut reference
  57038. * @returns the polygon mesh
  57039. */
  57040. static CreatePolygon(name: string, options: {
  57041. shape: Vector3[];
  57042. holes?: Vector3[][];
  57043. depth?: number;
  57044. faceUV?: Vector4[];
  57045. faceColors?: Color4[];
  57046. updatable?: boolean;
  57047. sideOrientation?: number;
  57048. frontUVs?: Vector4;
  57049. backUVs?: Vector4;
  57050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57051. /**
  57052. * Creates an extruded polygon mesh, with depth in the Y direction.
  57053. * * 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)
  57054. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57055. * @param name defines the name of the mesh
  57056. * @param options defines the options used to create the mesh
  57057. * @param scene defines the hosting scene
  57058. * @param earcutInjection can be used to inject your own earcut reference
  57059. * @returns the polygon mesh
  57060. */
  57061. static ExtrudePolygon(name: string, options: {
  57062. shape: Vector3[];
  57063. holes?: Vector3[][];
  57064. depth?: number;
  57065. faceUV?: Vector4[];
  57066. faceColors?: Color4[];
  57067. updatable?: boolean;
  57068. sideOrientation?: number;
  57069. frontUVs?: Vector4;
  57070. backUVs?: Vector4;
  57071. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /**
  57076. * Class containing static functions to help procedurally build meshes
  57077. */
  57078. export class LatheBuilder {
  57079. /**
  57080. * Creates lathe mesh.
  57081. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57082. * * 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
  57083. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57084. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57085. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57086. * * 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
  57087. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57088. * * 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
  57089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57090. * * 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
  57091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57093. * @param name defines the name of the mesh
  57094. * @param options defines the options used to create the mesh
  57095. * @param scene defines the hosting scene
  57096. * @returns the lathe mesh
  57097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57098. */
  57099. static CreateLathe(name: string, options: {
  57100. shape: Vector3[];
  57101. radius?: number;
  57102. tessellation?: number;
  57103. clip?: number;
  57104. arc?: number;
  57105. closed?: boolean;
  57106. updatable?: boolean;
  57107. sideOrientation?: number;
  57108. frontUVs?: Vector4;
  57109. backUVs?: Vector4;
  57110. cap?: number;
  57111. invertUV?: boolean;
  57112. }, scene?: Nullable<Scene>): Mesh;
  57113. }
  57114. }
  57115. declare module BABYLON {
  57116. /**
  57117. * Class containing static functions to help procedurally build meshes
  57118. */
  57119. export class TiledPlaneBuilder {
  57120. /**
  57121. * Creates a tiled plane mesh
  57122. * * The parameter `pattern` will, depending on value, do nothing or
  57123. * * * flip (reflect about central vertical) alternate tiles across and up
  57124. * * * flip every tile on alternate rows
  57125. * * * rotate (180 degs) alternate tiles across and up
  57126. * * * rotate every tile on alternate rows
  57127. * * * flip and rotate alternate tiles across and up
  57128. * * * flip and rotate every tile on alternate rows
  57129. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57130. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57131. * * 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
  57132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57133. * * 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)
  57134. * * 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)
  57135. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57136. * @param name defines the name of the mesh
  57137. * @param options defines the options used to create the mesh
  57138. * @param scene defines the hosting scene
  57139. * @returns the box mesh
  57140. */
  57141. static CreateTiledPlane(name: string, options: {
  57142. pattern?: number;
  57143. tileSize?: number;
  57144. tileWidth?: number;
  57145. tileHeight?: number;
  57146. size?: number;
  57147. width?: number;
  57148. height?: number;
  57149. alignHorizontal?: number;
  57150. alignVertical?: number;
  57151. sideOrientation?: number;
  57152. frontUVs?: Vector4;
  57153. backUVs?: Vector4;
  57154. updatable?: boolean;
  57155. }, scene?: Nullable<Scene>): Mesh;
  57156. }
  57157. }
  57158. declare module BABYLON {
  57159. /**
  57160. * Class containing static functions to help procedurally build meshes
  57161. */
  57162. export class TubeBuilder {
  57163. /**
  57164. * Creates a tube mesh.
  57165. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57166. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57167. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57168. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57169. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57170. * * 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)
  57171. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57172. * * 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
  57173. * * 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
  57174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57175. * * 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
  57176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57178. * @param name defines the name of the mesh
  57179. * @param options defines the options used to create the mesh
  57180. * @param scene defines the hosting scene
  57181. * @returns the tube mesh
  57182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57183. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57184. */
  57185. static CreateTube(name: string, options: {
  57186. path: Vector3[];
  57187. radius?: number;
  57188. tessellation?: number;
  57189. radiusFunction?: {
  57190. (i: number, distance: number): number;
  57191. };
  57192. cap?: number;
  57193. arc?: number;
  57194. updatable?: boolean;
  57195. sideOrientation?: number;
  57196. frontUVs?: Vector4;
  57197. backUVs?: Vector4;
  57198. instance?: Mesh;
  57199. invertUV?: boolean;
  57200. }, scene?: Nullable<Scene>): Mesh;
  57201. }
  57202. }
  57203. declare module BABYLON {
  57204. /**
  57205. * Class containing static functions to help procedurally build meshes
  57206. */
  57207. export class IcoSphereBuilder {
  57208. /**
  57209. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57210. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57211. * * 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`)
  57212. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57213. * * 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
  57214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57215. * * 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
  57216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57217. * @param name defines the name of the mesh
  57218. * @param options defines the options used to create the mesh
  57219. * @param scene defines the hosting scene
  57220. * @returns the icosahedron mesh
  57221. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57222. */
  57223. static CreateIcoSphere(name: string, options: {
  57224. radius?: number;
  57225. radiusX?: number;
  57226. radiusY?: number;
  57227. radiusZ?: number;
  57228. flat?: boolean;
  57229. subdivisions?: number;
  57230. sideOrientation?: number;
  57231. frontUVs?: Vector4;
  57232. backUVs?: Vector4;
  57233. updatable?: boolean;
  57234. }, scene?: Nullable<Scene>): Mesh;
  57235. }
  57236. }
  57237. declare module BABYLON {
  57238. /**
  57239. * Class containing static functions to help procedurally build meshes
  57240. */
  57241. export class DecalBuilder {
  57242. /**
  57243. * Creates a decal mesh.
  57244. * 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
  57245. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57246. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57247. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57248. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57249. * @param name defines the name of the mesh
  57250. * @param sourceMesh defines the mesh where the decal must be applied
  57251. * @param options defines the options used to create the mesh
  57252. * @param scene defines the hosting scene
  57253. * @returns the decal mesh
  57254. * @see https://doc.babylonjs.com/how_to/decals
  57255. */
  57256. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57257. position?: Vector3;
  57258. normal?: Vector3;
  57259. size?: Vector3;
  57260. angle?: number;
  57261. }): Mesh;
  57262. }
  57263. }
  57264. declare module BABYLON {
  57265. /**
  57266. * Class containing static functions to help procedurally build meshes
  57267. */
  57268. export class MeshBuilder {
  57269. /**
  57270. * Creates a box mesh
  57271. * * The parameter `size` sets the size (float) of each box side (default 1)
  57272. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57273. * * 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)
  57274. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57276. * * 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
  57277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57278. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57279. * @param name defines the name of the mesh
  57280. * @param options defines the options used to create the mesh
  57281. * @param scene defines the hosting scene
  57282. * @returns the box mesh
  57283. */
  57284. static CreateBox(name: string, options: {
  57285. size?: number;
  57286. width?: number;
  57287. height?: number;
  57288. depth?: number;
  57289. faceUV?: Vector4[];
  57290. faceColors?: Color4[];
  57291. sideOrientation?: number;
  57292. frontUVs?: Vector4;
  57293. backUVs?: Vector4;
  57294. updatable?: boolean;
  57295. }, scene?: Nullable<Scene>): Mesh;
  57296. /**
  57297. * Creates a tiled box mesh
  57298. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57300. * @param name defines the name of the mesh
  57301. * @param options defines the options used to create the mesh
  57302. * @param scene defines the hosting scene
  57303. * @returns the tiled box mesh
  57304. */
  57305. static CreateTiledBox(name: string, options: {
  57306. pattern?: number;
  57307. size?: number;
  57308. width?: number;
  57309. height?: number;
  57310. depth: number;
  57311. tileSize?: number;
  57312. tileWidth?: number;
  57313. tileHeight?: number;
  57314. faceUV?: Vector4[];
  57315. faceColors?: Color4[];
  57316. alignHorizontal?: number;
  57317. alignVertical?: number;
  57318. sideOrientation?: number;
  57319. updatable?: boolean;
  57320. }, scene?: Nullable<Scene>): Mesh;
  57321. /**
  57322. * Creates a sphere mesh
  57323. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57324. * * 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`)
  57325. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57326. * * 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
  57327. * * 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)
  57328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57329. * * 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
  57330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57331. * @param name defines the name of the mesh
  57332. * @param options defines the options used to create the mesh
  57333. * @param scene defines the hosting scene
  57334. * @returns the sphere mesh
  57335. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57336. */
  57337. static CreateSphere(name: string, options: {
  57338. segments?: number;
  57339. diameter?: number;
  57340. diameterX?: number;
  57341. diameterY?: number;
  57342. diameterZ?: number;
  57343. arc?: number;
  57344. slice?: number;
  57345. sideOrientation?: number;
  57346. frontUVs?: Vector4;
  57347. backUVs?: Vector4;
  57348. updatable?: boolean;
  57349. }, scene?: Nullable<Scene>): Mesh;
  57350. /**
  57351. * Creates a plane polygonal mesh. By default, this is a disc
  57352. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57353. * * 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
  57354. * * 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
  57355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57356. * * 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
  57357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57358. * @param name defines the name of the mesh
  57359. * @param options defines the options used to create the mesh
  57360. * @param scene defines the hosting scene
  57361. * @returns the plane polygonal mesh
  57362. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57363. */
  57364. static CreateDisc(name: string, options: {
  57365. radius?: number;
  57366. tessellation?: number;
  57367. arc?: number;
  57368. updatable?: boolean;
  57369. sideOrientation?: number;
  57370. frontUVs?: Vector4;
  57371. backUVs?: Vector4;
  57372. }, scene?: Nullable<Scene>): Mesh;
  57373. /**
  57374. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57375. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57376. * * 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`)
  57377. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57378. * * 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
  57379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57380. * * 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
  57381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57382. * @param name defines the name of the mesh
  57383. * @param options defines the options used to create the mesh
  57384. * @param scene defines the hosting scene
  57385. * @returns the icosahedron mesh
  57386. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57387. */
  57388. static CreateIcoSphere(name: string, options: {
  57389. radius?: number;
  57390. radiusX?: number;
  57391. radiusY?: number;
  57392. radiusZ?: number;
  57393. flat?: boolean;
  57394. subdivisions?: number;
  57395. sideOrientation?: number;
  57396. frontUVs?: Vector4;
  57397. backUVs?: Vector4;
  57398. updatable?: boolean;
  57399. }, scene?: Nullable<Scene>): Mesh;
  57400. /**
  57401. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57402. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57403. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57404. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57405. * * 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
  57406. * * 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
  57407. * * 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
  57408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57409. * * 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
  57410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57411. * * 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
  57412. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57413. * * 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
  57414. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57416. * @param name defines the name of the mesh
  57417. * @param options defines the options used to create the mesh
  57418. * @param scene defines the hosting scene
  57419. * @returns the ribbon mesh
  57420. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57422. */
  57423. static CreateRibbon(name: string, options: {
  57424. pathArray: Vector3[][];
  57425. closeArray?: boolean;
  57426. closePath?: boolean;
  57427. offset?: number;
  57428. updatable?: boolean;
  57429. sideOrientation?: number;
  57430. frontUVs?: Vector4;
  57431. backUVs?: Vector4;
  57432. instance?: Mesh;
  57433. invertUV?: boolean;
  57434. uvs?: Vector2[];
  57435. colors?: Color4[];
  57436. }, scene?: Nullable<Scene>): Mesh;
  57437. /**
  57438. * Creates a cylinder or a cone mesh
  57439. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57440. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57441. * * 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.
  57442. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57443. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57444. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57445. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57446. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  57447. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57448. * * 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).
  57449. * * 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
  57450. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57451. * * 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
  57452. * * 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.
  57453. * * If `enclose` is false, a ring surface is one element.
  57454. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57455. * * 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
  57456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57457. * * 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
  57458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57459. * @param name defines the name of the mesh
  57460. * @param options defines the options used to create the mesh
  57461. * @param scene defines the hosting scene
  57462. * @returns the cylinder mesh
  57463. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57464. */
  57465. static CreateCylinder(name: string, options: {
  57466. height?: number;
  57467. diameterTop?: number;
  57468. diameterBottom?: number;
  57469. diameter?: number;
  57470. tessellation?: number;
  57471. subdivisions?: number;
  57472. arc?: number;
  57473. faceColors?: Color4[];
  57474. faceUV?: Vector4[];
  57475. updatable?: boolean;
  57476. hasRings?: boolean;
  57477. enclose?: boolean;
  57478. cap?: number;
  57479. sideOrientation?: number;
  57480. frontUVs?: Vector4;
  57481. backUVs?: Vector4;
  57482. }, scene?: Nullable<Scene>): Mesh;
  57483. /**
  57484. * Creates a torus mesh
  57485. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57486. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57487. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57489. * * 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
  57490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57491. * @param name defines the name of the mesh
  57492. * @param options defines the options used to create the mesh
  57493. * @param scene defines the hosting scene
  57494. * @returns the torus mesh
  57495. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57496. */
  57497. static CreateTorus(name: string, options: {
  57498. diameter?: number;
  57499. thickness?: number;
  57500. tessellation?: number;
  57501. updatable?: boolean;
  57502. sideOrientation?: number;
  57503. frontUVs?: Vector4;
  57504. backUVs?: Vector4;
  57505. }, scene?: Nullable<Scene>): Mesh;
  57506. /**
  57507. * Creates a torus knot mesh
  57508. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57509. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57510. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57511. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57513. * * 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
  57514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57515. * @param name defines the name of the mesh
  57516. * @param options defines the options used to create the mesh
  57517. * @param scene defines the hosting scene
  57518. * @returns the torus knot mesh
  57519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57520. */
  57521. static CreateTorusKnot(name: string, options: {
  57522. radius?: number;
  57523. tube?: number;
  57524. radialSegments?: number;
  57525. tubularSegments?: number;
  57526. p?: number;
  57527. q?: number;
  57528. updatable?: boolean;
  57529. sideOrientation?: number;
  57530. frontUVs?: Vector4;
  57531. backUVs?: Vector4;
  57532. }, scene?: Nullable<Scene>): Mesh;
  57533. /**
  57534. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57535. * * 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
  57536. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57537. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57538. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57539. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57540. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57541. * * 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
  57542. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57545. * @param name defines the name of the new line system
  57546. * @param options defines the options used to create the line system
  57547. * @param scene defines the hosting scene
  57548. * @returns a new line system mesh
  57549. */
  57550. static CreateLineSystem(name: string, options: {
  57551. lines: Vector3[][];
  57552. updatable?: boolean;
  57553. instance?: Nullable<LinesMesh>;
  57554. colors?: Nullable<Color4[][]>;
  57555. useVertexAlpha?: boolean;
  57556. }, scene: Nullable<Scene>): LinesMesh;
  57557. /**
  57558. * Creates a line mesh
  57559. * 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
  57560. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57561. * * The parameter `points` is an array successive Vector3
  57562. * * 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
  57563. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57564. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57565. * * When updating an instance, remember that only point positions can change, not the number of points
  57566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57568. * @param name defines the name of the new line system
  57569. * @param options defines the options used to create the line system
  57570. * @param scene defines the hosting scene
  57571. * @returns a new line mesh
  57572. */
  57573. static CreateLines(name: string, options: {
  57574. points: Vector3[];
  57575. updatable?: boolean;
  57576. instance?: Nullable<LinesMesh>;
  57577. colors?: Color4[];
  57578. useVertexAlpha?: boolean;
  57579. }, scene?: Nullable<Scene>): LinesMesh;
  57580. /**
  57581. * Creates a dashed line mesh
  57582. * * 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
  57583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57584. * * The parameter `points` is an array successive Vector3
  57585. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57586. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57587. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57588. * * 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
  57589. * * When updating an instance, remember that only point positions can change, not the number of points
  57590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57591. * @param name defines the name of the mesh
  57592. * @param options defines the options used to create the mesh
  57593. * @param scene defines the hosting scene
  57594. * @returns the dashed line mesh
  57595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57596. */
  57597. static CreateDashedLines(name: string, options: {
  57598. points: Vector3[];
  57599. dashSize?: number;
  57600. gapSize?: number;
  57601. dashNb?: number;
  57602. updatable?: boolean;
  57603. instance?: LinesMesh;
  57604. }, scene?: Nullable<Scene>): LinesMesh;
  57605. /**
  57606. * 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.
  57607. * * 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.
  57608. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57609. * * 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.
  57610. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57611. * * 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
  57612. * * 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
  57613. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57615. * * 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
  57616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57618. * @param name defines the name of the mesh
  57619. * @param options defines the options used to create the mesh
  57620. * @param scene defines the hosting scene
  57621. * @returns the extruded shape mesh
  57622. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57624. */
  57625. static ExtrudeShape(name: string, options: {
  57626. shape: Vector3[];
  57627. path: Vector3[];
  57628. scale?: number;
  57629. rotation?: number;
  57630. cap?: number;
  57631. updatable?: boolean;
  57632. sideOrientation?: number;
  57633. frontUVs?: Vector4;
  57634. backUVs?: Vector4;
  57635. instance?: Mesh;
  57636. invertUV?: boolean;
  57637. }, scene?: Nullable<Scene>): Mesh;
  57638. /**
  57639. * Creates an custom extruded shape mesh.
  57640. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57641. * * 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.
  57642. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57643. * * 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
  57644. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57645. * * 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
  57646. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57647. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57648. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57649. * * 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
  57650. * * 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
  57651. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57653. * * 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
  57654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57656. * @param name defines the name of the mesh
  57657. * @param options defines the options used to create the mesh
  57658. * @param scene defines the hosting scene
  57659. * @returns the custom extruded shape mesh
  57660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57661. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57663. */
  57664. static ExtrudeShapeCustom(name: string, options: {
  57665. shape: Vector3[];
  57666. path: Vector3[];
  57667. scaleFunction?: any;
  57668. rotationFunction?: any;
  57669. ribbonCloseArray?: boolean;
  57670. ribbonClosePath?: boolean;
  57671. cap?: number;
  57672. updatable?: boolean;
  57673. sideOrientation?: number;
  57674. frontUVs?: Vector4;
  57675. backUVs?: Vector4;
  57676. instance?: Mesh;
  57677. invertUV?: boolean;
  57678. }, scene?: Nullable<Scene>): Mesh;
  57679. /**
  57680. * Creates lathe mesh.
  57681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57682. * * 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
  57683. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57684. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57685. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57686. * * 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
  57687. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57688. * * 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
  57689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57690. * * 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
  57691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57693. * @param name defines the name of the mesh
  57694. * @param options defines the options used to create the mesh
  57695. * @param scene defines the hosting scene
  57696. * @returns the lathe mesh
  57697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57698. */
  57699. static CreateLathe(name: string, options: {
  57700. shape: Vector3[];
  57701. radius?: number;
  57702. tessellation?: number;
  57703. clip?: number;
  57704. arc?: number;
  57705. closed?: boolean;
  57706. updatable?: boolean;
  57707. sideOrientation?: number;
  57708. frontUVs?: Vector4;
  57709. backUVs?: Vector4;
  57710. cap?: number;
  57711. invertUV?: boolean;
  57712. }, scene?: Nullable<Scene>): Mesh;
  57713. /**
  57714. * Creates a tiled plane mesh
  57715. * * You can set a limited pattern arrangement with the tiles
  57716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57717. * * 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
  57718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57719. * @param name defines the name of the mesh
  57720. * @param options defines the options used to create the mesh
  57721. * @param scene defines the hosting scene
  57722. * @returns the plane mesh
  57723. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57724. */
  57725. static CreateTiledPlane(name: string, options: {
  57726. pattern?: number;
  57727. tileSize?: number;
  57728. tileWidth?: number;
  57729. tileHeight?: number;
  57730. size?: number;
  57731. width?: number;
  57732. height?: number;
  57733. alignHorizontal?: number;
  57734. alignVertical?: number;
  57735. sideOrientation?: number;
  57736. frontUVs?: Vector4;
  57737. backUVs?: Vector4;
  57738. updatable?: boolean;
  57739. }, scene?: Nullable<Scene>): Mesh;
  57740. /**
  57741. * Creates a plane mesh
  57742. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57743. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57744. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57746. * * 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
  57747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57748. * @param name defines the name of the mesh
  57749. * @param options defines the options used to create the mesh
  57750. * @param scene defines the hosting scene
  57751. * @returns the plane mesh
  57752. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57753. */
  57754. static CreatePlane(name: string, options: {
  57755. size?: number;
  57756. width?: number;
  57757. height?: number;
  57758. sideOrientation?: number;
  57759. frontUVs?: Vector4;
  57760. backUVs?: Vector4;
  57761. updatable?: boolean;
  57762. sourcePlane?: Plane;
  57763. }, scene?: Nullable<Scene>): Mesh;
  57764. /**
  57765. * Creates a ground mesh
  57766. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57767. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57769. * @param name defines the name of the mesh
  57770. * @param options defines the options used to create the mesh
  57771. * @param scene defines the hosting scene
  57772. * @returns the ground mesh
  57773. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57774. */
  57775. static CreateGround(name: string, options: {
  57776. width?: number;
  57777. height?: number;
  57778. subdivisions?: number;
  57779. subdivisionsX?: number;
  57780. subdivisionsY?: number;
  57781. updatable?: boolean;
  57782. }, scene?: Nullable<Scene>): Mesh;
  57783. /**
  57784. * Creates a tiled ground mesh
  57785. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57786. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57787. * * 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
  57788. * * 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
  57789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57790. * @param name defines the name of the mesh
  57791. * @param options defines the options used to create the mesh
  57792. * @param scene defines the hosting scene
  57793. * @returns the tiled ground mesh
  57794. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57795. */
  57796. static CreateTiledGround(name: string, options: {
  57797. xmin: number;
  57798. zmin: number;
  57799. xmax: number;
  57800. zmax: number;
  57801. subdivisions?: {
  57802. w: number;
  57803. h: number;
  57804. };
  57805. precision?: {
  57806. w: number;
  57807. h: number;
  57808. };
  57809. updatable?: boolean;
  57810. }, scene?: Nullable<Scene>): Mesh;
  57811. /**
  57812. * Creates a ground mesh from a height map
  57813. * * The parameter `url` sets the URL of the height map image resource.
  57814. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57815. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57816. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57817. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57818. * * 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.
  57819. * * 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).
  57820. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57822. * @param name defines the name of the mesh
  57823. * @param url defines the url to the height map
  57824. * @param options defines the options used to create the mesh
  57825. * @param scene defines the hosting scene
  57826. * @returns the ground mesh
  57827. * @see https://doc.babylonjs.com/babylon101/height_map
  57828. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57829. */
  57830. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57831. width?: number;
  57832. height?: number;
  57833. subdivisions?: number;
  57834. minHeight?: number;
  57835. maxHeight?: number;
  57836. colorFilter?: Color3;
  57837. alphaFilter?: number;
  57838. updatable?: boolean;
  57839. onReady?: (mesh: GroundMesh) => void;
  57840. }, scene?: Nullable<Scene>): GroundMesh;
  57841. /**
  57842. * Creates a polygon mesh
  57843. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57844. * * 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
  57845. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57847. * * 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)
  57848. * * Remember you can only change the shape positions, not their number when updating a polygon
  57849. * @param name defines the name of the mesh
  57850. * @param options defines the options used to create the mesh
  57851. * @param scene defines the hosting scene
  57852. * @param earcutInjection can be used to inject your own earcut reference
  57853. * @returns the polygon mesh
  57854. */
  57855. static CreatePolygon(name: string, options: {
  57856. shape: Vector3[];
  57857. holes?: Vector3[][];
  57858. depth?: number;
  57859. faceUV?: Vector4[];
  57860. faceColors?: Color4[];
  57861. updatable?: boolean;
  57862. sideOrientation?: number;
  57863. frontUVs?: Vector4;
  57864. backUVs?: Vector4;
  57865. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57866. /**
  57867. * Creates an extruded polygon mesh, with depth in the Y direction.
  57868. * * 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)
  57869. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57870. * @param name defines the name of the mesh
  57871. * @param options defines the options used to create the mesh
  57872. * @param scene defines the hosting scene
  57873. * @param earcutInjection can be used to inject your own earcut reference
  57874. * @returns the polygon mesh
  57875. */
  57876. static ExtrudePolygon(name: string, options: {
  57877. shape: Vector3[];
  57878. holes?: Vector3[][];
  57879. depth?: number;
  57880. faceUV?: Vector4[];
  57881. faceColors?: Color4[];
  57882. updatable?: boolean;
  57883. sideOrientation?: number;
  57884. frontUVs?: Vector4;
  57885. backUVs?: Vector4;
  57886. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57887. /**
  57888. * Creates a tube mesh.
  57889. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57890. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57891. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57892. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57893. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57894. * * 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)
  57895. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57896. * * 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
  57897. * * 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
  57898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57899. * * 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
  57900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57902. * @param name defines the name of the mesh
  57903. * @param options defines the options used to create the mesh
  57904. * @param scene defines the hosting scene
  57905. * @returns the tube mesh
  57906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57907. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57908. */
  57909. static CreateTube(name: string, options: {
  57910. path: Vector3[];
  57911. radius?: number;
  57912. tessellation?: number;
  57913. radiusFunction?: {
  57914. (i: number, distance: number): number;
  57915. };
  57916. cap?: number;
  57917. arc?: number;
  57918. updatable?: boolean;
  57919. sideOrientation?: number;
  57920. frontUVs?: Vector4;
  57921. backUVs?: Vector4;
  57922. instance?: Mesh;
  57923. invertUV?: boolean;
  57924. }, scene?: Nullable<Scene>): Mesh;
  57925. /**
  57926. * Creates a polyhedron mesh
  57927. * * 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
  57928. * * The parameter `size` (positive float, default 1) sets the polygon size
  57929. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57930. * * 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`
  57931. * * 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
  57932. * * 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)`)
  57933. * * 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
  57934. * * 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
  57935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57936. * * 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
  57937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57938. * @param name defines the name of the mesh
  57939. * @param options defines the options used to create the mesh
  57940. * @param scene defines the hosting scene
  57941. * @returns the polyhedron mesh
  57942. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57943. */
  57944. static CreatePolyhedron(name: string, options: {
  57945. type?: number;
  57946. size?: number;
  57947. sizeX?: number;
  57948. sizeY?: number;
  57949. sizeZ?: number;
  57950. custom?: any;
  57951. faceUV?: Vector4[];
  57952. faceColors?: Color4[];
  57953. flat?: boolean;
  57954. updatable?: boolean;
  57955. sideOrientation?: number;
  57956. frontUVs?: Vector4;
  57957. backUVs?: Vector4;
  57958. }, scene?: Nullable<Scene>): Mesh;
  57959. /**
  57960. * Creates a decal mesh.
  57961. * 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
  57962. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57963. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57964. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57965. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57966. * @param name defines the name of the mesh
  57967. * @param sourceMesh defines the mesh where the decal must be applied
  57968. * @param options defines the options used to create the mesh
  57969. * @param scene defines the hosting scene
  57970. * @returns the decal mesh
  57971. * @see https://doc.babylonjs.com/how_to/decals
  57972. */
  57973. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57974. position?: Vector3;
  57975. normal?: Vector3;
  57976. size?: Vector3;
  57977. angle?: number;
  57978. }): Mesh;
  57979. }
  57980. }
  57981. declare module BABYLON {
  57982. /**
  57983. * A simplifier interface for future simplification implementations
  57984. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57985. */
  57986. export interface ISimplifier {
  57987. /**
  57988. * Simplification of a given mesh according to the given settings.
  57989. * Since this requires computation, it is assumed that the function runs async.
  57990. * @param settings The settings of the simplification, including quality and distance
  57991. * @param successCallback A callback that will be called after the mesh was simplified.
  57992. * @param errorCallback in case of an error, this callback will be called. optional.
  57993. */
  57994. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57995. }
  57996. /**
  57997. * Expected simplification settings.
  57998. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57999. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58000. */
  58001. export interface ISimplificationSettings {
  58002. /**
  58003. * Gets or sets the expected quality
  58004. */
  58005. quality: number;
  58006. /**
  58007. * Gets or sets the distance when this optimized version should be used
  58008. */
  58009. distance: number;
  58010. /**
  58011. * Gets an already optimized mesh
  58012. */
  58013. optimizeMesh?: boolean;
  58014. }
  58015. /**
  58016. * Class used to specify simplification options
  58017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58018. */
  58019. export class SimplificationSettings implements ISimplificationSettings {
  58020. /** expected quality */
  58021. quality: number;
  58022. /** distance when this optimized version should be used */
  58023. distance: number;
  58024. /** already optimized mesh */
  58025. optimizeMesh?: boolean | undefined;
  58026. /**
  58027. * Creates a SimplificationSettings
  58028. * @param quality expected quality
  58029. * @param distance distance when this optimized version should be used
  58030. * @param optimizeMesh already optimized mesh
  58031. */
  58032. constructor(
  58033. /** expected quality */
  58034. quality: number,
  58035. /** distance when this optimized version should be used */
  58036. distance: number,
  58037. /** already optimized mesh */
  58038. optimizeMesh?: boolean | undefined);
  58039. }
  58040. /**
  58041. * Interface used to define a simplification task
  58042. */
  58043. export interface ISimplificationTask {
  58044. /**
  58045. * Array of settings
  58046. */
  58047. settings: Array<ISimplificationSettings>;
  58048. /**
  58049. * Simplification type
  58050. */
  58051. simplificationType: SimplificationType;
  58052. /**
  58053. * Mesh to simplify
  58054. */
  58055. mesh: Mesh;
  58056. /**
  58057. * Callback called on success
  58058. */
  58059. successCallback?: () => void;
  58060. /**
  58061. * Defines if parallel processing can be used
  58062. */
  58063. parallelProcessing: boolean;
  58064. }
  58065. /**
  58066. * Queue used to order the simplification tasks
  58067. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58068. */
  58069. export class SimplificationQueue {
  58070. private _simplificationArray;
  58071. /**
  58072. * Gets a boolean indicating that the process is still running
  58073. */
  58074. running: boolean;
  58075. /**
  58076. * Creates a new queue
  58077. */
  58078. constructor();
  58079. /**
  58080. * Adds a new simplification task
  58081. * @param task defines a task to add
  58082. */
  58083. addTask(task: ISimplificationTask): void;
  58084. /**
  58085. * Execute next task
  58086. */
  58087. executeNext(): void;
  58088. /**
  58089. * Execute a simplification task
  58090. * @param task defines the task to run
  58091. */
  58092. runSimplification(task: ISimplificationTask): void;
  58093. private getSimplifier;
  58094. }
  58095. /**
  58096. * The implemented types of simplification
  58097. * At the moment only Quadratic Error Decimation is implemented
  58098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58099. */
  58100. export enum SimplificationType {
  58101. /** Quadratic error decimation */
  58102. QUADRATIC = 0
  58103. }
  58104. }
  58105. declare module BABYLON {
  58106. interface Scene {
  58107. /** @hidden (Backing field) */
  58108. _simplificationQueue: SimplificationQueue;
  58109. /**
  58110. * Gets or sets the simplification queue attached to the scene
  58111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58112. */
  58113. simplificationQueue: SimplificationQueue;
  58114. }
  58115. interface Mesh {
  58116. /**
  58117. * Simplify the mesh according to the given array of settings.
  58118. * Function will return immediately and will simplify async
  58119. * @param settings a collection of simplification settings
  58120. * @param parallelProcessing should all levels calculate parallel or one after the other
  58121. * @param simplificationType the type of simplification to run
  58122. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58123. * @returns the current mesh
  58124. */
  58125. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58126. }
  58127. /**
  58128. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58129. * created in a scene
  58130. */
  58131. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58132. /**
  58133. * The component name helpfull to identify the component in the list of scene components.
  58134. */
  58135. readonly name: string;
  58136. /**
  58137. * The scene the component belongs to.
  58138. */
  58139. scene: Scene;
  58140. /**
  58141. * Creates a new instance of the component for the given scene
  58142. * @param scene Defines the scene to register the component in
  58143. */
  58144. constructor(scene: Scene);
  58145. /**
  58146. * Registers the component in a given scene
  58147. */
  58148. register(): void;
  58149. /**
  58150. * Rebuilds the elements related to this component in case of
  58151. * context lost for instance.
  58152. */
  58153. rebuild(): void;
  58154. /**
  58155. * Disposes the component and the associated ressources
  58156. */
  58157. dispose(): void;
  58158. private _beforeCameraUpdate;
  58159. }
  58160. }
  58161. declare module BABYLON {
  58162. /**
  58163. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58164. */
  58165. export interface INavigationEnginePlugin {
  58166. /**
  58167. * plugin name
  58168. */
  58169. name: string;
  58170. /**
  58171. * Creates a navigation mesh
  58172. * @param meshes array of all the geometry used to compute the navigatio mesh
  58173. * @param parameters bunch of parameters used to filter geometry
  58174. */
  58175. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58176. /**
  58177. * Create a navigation mesh debug mesh
  58178. * @param scene is where the mesh will be added
  58179. * @returns debug display mesh
  58180. */
  58181. createDebugNavMesh(scene: Scene): Mesh;
  58182. /**
  58183. * Get a navigation mesh constrained position, closest to the parameter position
  58184. * @param position world position
  58185. * @returns the closest point to position constrained by the navigation mesh
  58186. */
  58187. getClosestPoint(position: Vector3): Vector3;
  58188. /**
  58189. * Get a navigation mesh constrained position, within a particular radius
  58190. * @param position world position
  58191. * @param maxRadius the maximum distance to the constrained world position
  58192. * @returns the closest point to position constrained by the navigation mesh
  58193. */
  58194. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58195. /**
  58196. * Compute the final position from a segment made of destination-position
  58197. * @param position world position
  58198. * @param destination world position
  58199. * @returns the resulting point along the navmesh
  58200. */
  58201. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58202. /**
  58203. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58204. * @param start world position
  58205. * @param end world position
  58206. * @returns array containing world position composing the path
  58207. */
  58208. computePath(start: Vector3, end: Vector3): Vector3[];
  58209. /**
  58210. * If this plugin is supported
  58211. * @returns true if plugin is supported
  58212. */
  58213. isSupported(): boolean;
  58214. /**
  58215. * Create a new Crowd so you can add agents
  58216. * @param maxAgents the maximum agent count in the crowd
  58217. * @param maxAgentRadius the maximum radius an agent can have
  58218. * @param scene to attach the crowd to
  58219. * @returns the crowd you can add agents to
  58220. */
  58221. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58222. /**
  58223. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58224. * The queries will try to find a solution within those bounds
  58225. * default is (1,1,1)
  58226. * @param extent x,y,z value that define the extent around the queries point of reference
  58227. */
  58228. setDefaultQueryExtent(extent: Vector3): void;
  58229. /**
  58230. * Get the Bounding box extent specified by setDefaultQueryExtent
  58231. * @returns the box extent values
  58232. */
  58233. getDefaultQueryExtent(): Vector3;
  58234. /**
  58235. * Release all resources
  58236. */
  58237. dispose(): void;
  58238. }
  58239. /**
  58240. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58241. */
  58242. export interface ICrowd {
  58243. /**
  58244. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58245. * You can attach anything to that node. The node position is updated in the scene update tick.
  58246. * @param pos world position that will be constrained by the navigation mesh
  58247. * @param parameters agent parameters
  58248. * @param transform hooked to the agent that will be update by the scene
  58249. * @returns agent index
  58250. */
  58251. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58252. /**
  58253. * Returns the agent position in world space
  58254. * @param index agent index returned by addAgent
  58255. * @returns world space position
  58256. */
  58257. getAgentPosition(index: number): Vector3;
  58258. /**
  58259. * Gets the agent velocity in world space
  58260. * @param index agent index returned by addAgent
  58261. * @returns world space velocity
  58262. */
  58263. getAgentVelocity(index: number): Vector3;
  58264. /**
  58265. * remove a particular agent previously created
  58266. * @param index agent index returned by addAgent
  58267. */
  58268. removeAgent(index: number): void;
  58269. /**
  58270. * get the list of all agents attached to this crowd
  58271. * @returns list of agent indices
  58272. */
  58273. getAgents(): number[];
  58274. /**
  58275. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58276. * @param deltaTime in seconds
  58277. */
  58278. update(deltaTime: number): void;
  58279. /**
  58280. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58281. * @param index agent index returned by addAgent
  58282. * @param destination targeted world position
  58283. */
  58284. agentGoto(index: number, destination: Vector3): void;
  58285. /**
  58286. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58287. * The queries will try to find a solution within those bounds
  58288. * default is (1,1,1)
  58289. * @param extent x,y,z value that define the extent around the queries point of reference
  58290. */
  58291. setDefaultQueryExtent(extent: Vector3): void;
  58292. /**
  58293. * Get the Bounding box extent specified by setDefaultQueryExtent
  58294. * @returns the box extent values
  58295. */
  58296. getDefaultQueryExtent(): Vector3;
  58297. /**
  58298. * Release all resources
  58299. */
  58300. dispose(): void;
  58301. }
  58302. /**
  58303. * Configures an agent
  58304. */
  58305. export interface IAgentParameters {
  58306. /**
  58307. * Agent radius. [Limit: >= 0]
  58308. */
  58309. radius: number;
  58310. /**
  58311. * Agent height. [Limit: > 0]
  58312. */
  58313. height: number;
  58314. /**
  58315. * Maximum allowed acceleration. [Limit: >= 0]
  58316. */
  58317. maxAcceleration: number;
  58318. /**
  58319. * Maximum allowed speed. [Limit: >= 0]
  58320. */
  58321. maxSpeed: number;
  58322. /**
  58323. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58324. */
  58325. collisionQueryRange: number;
  58326. /**
  58327. * The path visibility optimization range. [Limit: > 0]
  58328. */
  58329. pathOptimizationRange: number;
  58330. /**
  58331. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58332. */
  58333. separationWeight: number;
  58334. }
  58335. /**
  58336. * Configures the navigation mesh creation
  58337. */
  58338. export interface INavMeshParameters {
  58339. /**
  58340. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58341. */
  58342. cs: number;
  58343. /**
  58344. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58345. */
  58346. ch: number;
  58347. /**
  58348. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58349. */
  58350. walkableSlopeAngle: number;
  58351. /**
  58352. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58353. * be considered walkable. [Limit: >= 3] [Units: vx]
  58354. */
  58355. walkableHeight: number;
  58356. /**
  58357. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58358. */
  58359. walkableClimb: number;
  58360. /**
  58361. * The distance to erode/shrink the walkable area of the heightfield away from
  58362. * obstructions. [Limit: >=0] [Units: vx]
  58363. */
  58364. walkableRadius: number;
  58365. /**
  58366. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58367. */
  58368. maxEdgeLen: number;
  58369. /**
  58370. * The maximum distance a simplfied contour's border edges should deviate
  58371. * the original raw contour. [Limit: >=0] [Units: vx]
  58372. */
  58373. maxSimplificationError: number;
  58374. /**
  58375. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58376. */
  58377. minRegionArea: number;
  58378. /**
  58379. * Any regions with a span count smaller than this value will, if possible,
  58380. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58381. */
  58382. mergeRegionArea: number;
  58383. /**
  58384. * The maximum number of vertices allowed for polygons generated during the
  58385. * contour to polygon conversion process. [Limit: >= 3]
  58386. */
  58387. maxVertsPerPoly: number;
  58388. /**
  58389. * Sets the sampling distance to use when generating the detail mesh.
  58390. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58391. */
  58392. detailSampleDist: number;
  58393. /**
  58394. * The maximum distance the detail mesh surface should deviate from heightfield
  58395. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58396. */
  58397. detailSampleMaxError: number;
  58398. }
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. * RecastJS navigation plugin
  58403. */
  58404. export class RecastJSPlugin implements INavigationEnginePlugin {
  58405. /**
  58406. * Reference to the Recast library
  58407. */
  58408. bjsRECAST: any;
  58409. /**
  58410. * plugin name
  58411. */
  58412. name: string;
  58413. /**
  58414. * the first navmesh created. We might extend this to support multiple navmeshes
  58415. */
  58416. navMesh: any;
  58417. /**
  58418. * Initializes the recastJS plugin
  58419. * @param recastInjection can be used to inject your own recast reference
  58420. */
  58421. constructor(recastInjection?: any);
  58422. /**
  58423. * Creates a navigation mesh
  58424. * @param meshes array of all the geometry used to compute the navigatio mesh
  58425. * @param parameters bunch of parameters used to filter geometry
  58426. */
  58427. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58428. /**
  58429. * Create a navigation mesh debug mesh
  58430. * @param scene is where the mesh will be added
  58431. * @returns debug display mesh
  58432. */
  58433. createDebugNavMesh(scene: Scene): Mesh;
  58434. /**
  58435. * Get a navigation mesh constrained position, closest to the parameter position
  58436. * @param position world position
  58437. * @returns the closest point to position constrained by the navigation mesh
  58438. */
  58439. getClosestPoint(position: Vector3): Vector3;
  58440. /**
  58441. * Get a navigation mesh constrained position, within a particular radius
  58442. * @param position world position
  58443. * @param maxRadius the maximum distance to the constrained world position
  58444. * @returns the closest point to position constrained by the navigation mesh
  58445. */
  58446. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58447. /**
  58448. * Compute the final position from a segment made of destination-position
  58449. * @param position world position
  58450. * @param destination world position
  58451. * @returns the resulting point along the navmesh
  58452. */
  58453. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58454. /**
  58455. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58456. * @param start world position
  58457. * @param end world position
  58458. * @returns array containing world position composing the path
  58459. */
  58460. computePath(start: Vector3, end: Vector3): Vector3[];
  58461. /**
  58462. * Create a new Crowd so you can add agents
  58463. * @param maxAgents the maximum agent count in the crowd
  58464. * @param maxAgentRadius the maximum radius an agent can have
  58465. * @param scene to attach the crowd to
  58466. * @returns the crowd you can add agents to
  58467. */
  58468. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58469. /**
  58470. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58471. * The queries will try to find a solution within those bounds
  58472. * default is (1,1,1)
  58473. * @param extent x,y,z value that define the extent around the queries point of reference
  58474. */
  58475. setDefaultQueryExtent(extent: Vector3): void;
  58476. /**
  58477. * Get the Bounding box extent specified by setDefaultQueryExtent
  58478. * @returns the box extent values
  58479. */
  58480. getDefaultQueryExtent(): Vector3;
  58481. /**
  58482. * Disposes
  58483. */
  58484. dispose(): void;
  58485. /**
  58486. * If this plugin is supported
  58487. * @returns true if plugin is supported
  58488. */
  58489. isSupported(): boolean;
  58490. }
  58491. /**
  58492. * Recast detour crowd implementation
  58493. */
  58494. export class RecastJSCrowd implements ICrowd {
  58495. /**
  58496. * Recast/detour plugin
  58497. */
  58498. bjsRECASTPlugin: RecastJSPlugin;
  58499. /**
  58500. * Link to the detour crowd
  58501. */
  58502. recastCrowd: any;
  58503. /**
  58504. * One transform per agent
  58505. */
  58506. transforms: TransformNode[];
  58507. /**
  58508. * All agents created
  58509. */
  58510. agents: number[];
  58511. /**
  58512. * Link to the scene is kept to unregister the crowd from the scene
  58513. */
  58514. private _scene;
  58515. /**
  58516. * Observer for crowd updates
  58517. */
  58518. private _onBeforeAnimationsObserver;
  58519. /**
  58520. * Constructor
  58521. * @param plugin recastJS plugin
  58522. * @param maxAgents the maximum agent count in the crowd
  58523. * @param maxAgentRadius the maximum radius an agent can have
  58524. * @param scene to attach the crowd to
  58525. * @returns the crowd you can add agents to
  58526. */
  58527. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58528. /**
  58529. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58530. * You can attach anything to that node. The node position is updated in the scene update tick.
  58531. * @param pos world position that will be constrained by the navigation mesh
  58532. * @param parameters agent parameters
  58533. * @param transform hooked to the agent that will be update by the scene
  58534. * @returns agent index
  58535. */
  58536. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58537. /**
  58538. * Returns the agent position in world space
  58539. * @param index agent index returned by addAgent
  58540. * @returns world space position
  58541. */
  58542. getAgentPosition(index: number): Vector3;
  58543. /**
  58544. * Returns the agent velocity in world space
  58545. * @param index agent index returned by addAgent
  58546. * @returns world space velocity
  58547. */
  58548. getAgentVelocity(index: number): Vector3;
  58549. /**
  58550. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58551. * @param index agent index returned by addAgent
  58552. * @param destination targeted world position
  58553. */
  58554. agentGoto(index: number, destination: Vector3): void;
  58555. /**
  58556. * remove a particular agent previously created
  58557. * @param index agent index returned by addAgent
  58558. */
  58559. removeAgent(index: number): void;
  58560. /**
  58561. * get the list of all agents attached to this crowd
  58562. * @returns list of agent indices
  58563. */
  58564. getAgents(): number[];
  58565. /**
  58566. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58567. * @param deltaTime in seconds
  58568. */
  58569. update(deltaTime: number): void;
  58570. /**
  58571. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58572. * The queries will try to find a solution within those bounds
  58573. * default is (1,1,1)
  58574. * @param extent x,y,z value that define the extent around the queries point of reference
  58575. */
  58576. setDefaultQueryExtent(extent: Vector3): void;
  58577. /**
  58578. * Get the Bounding box extent specified by setDefaultQueryExtent
  58579. * @returns the box extent values
  58580. */
  58581. getDefaultQueryExtent(): Vector3;
  58582. /**
  58583. * Release all resources
  58584. */
  58585. dispose(): void;
  58586. }
  58587. }
  58588. declare module BABYLON {
  58589. /**
  58590. * Class used to enable access to IndexedDB
  58591. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58592. */
  58593. export class Database implements IOfflineProvider {
  58594. private _callbackManifestChecked;
  58595. private _currentSceneUrl;
  58596. private _db;
  58597. private _enableSceneOffline;
  58598. private _enableTexturesOffline;
  58599. private _manifestVersionFound;
  58600. private _mustUpdateRessources;
  58601. private _hasReachedQuota;
  58602. private _isSupported;
  58603. private _idbFactory;
  58604. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58605. private static IsUASupportingBlobStorage;
  58606. /**
  58607. * Gets a boolean indicating if Database storate is enabled (off by default)
  58608. */
  58609. static IDBStorageEnabled: boolean;
  58610. /**
  58611. * Gets a boolean indicating if scene must be saved in the database
  58612. */
  58613. readonly enableSceneOffline: boolean;
  58614. /**
  58615. * Gets a boolean indicating if textures must be saved in the database
  58616. */
  58617. readonly enableTexturesOffline: boolean;
  58618. /**
  58619. * Creates a new Database
  58620. * @param urlToScene defines the url to load the scene
  58621. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58622. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58623. */
  58624. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58625. private static _ParseURL;
  58626. private static _ReturnFullUrlLocation;
  58627. private _checkManifestFile;
  58628. /**
  58629. * Open the database and make it available
  58630. * @param successCallback defines the callback to call on success
  58631. * @param errorCallback defines the callback to call on error
  58632. */
  58633. open(successCallback: () => void, errorCallback: () => void): void;
  58634. /**
  58635. * Loads an image from the database
  58636. * @param url defines the url to load from
  58637. * @param image defines the target DOM image
  58638. */
  58639. loadImage(url: string, image: HTMLImageElement): void;
  58640. private _loadImageFromDBAsync;
  58641. private _saveImageIntoDBAsync;
  58642. private _checkVersionFromDB;
  58643. private _loadVersionFromDBAsync;
  58644. private _saveVersionIntoDBAsync;
  58645. /**
  58646. * Loads a file from database
  58647. * @param url defines the URL to load from
  58648. * @param sceneLoaded defines a callback to call on success
  58649. * @param progressCallBack defines a callback to call when progress changed
  58650. * @param errorCallback defines a callback to call on error
  58651. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58652. */
  58653. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58654. private _loadFileAsync;
  58655. private _saveFileAsync;
  58656. /**
  58657. * Validates if xhr data is correct
  58658. * @param xhr defines the request to validate
  58659. * @param dataType defines the expected data type
  58660. * @returns true if data is correct
  58661. */
  58662. private static _ValidateXHRData;
  58663. }
  58664. }
  58665. declare module BABYLON {
  58666. /** @hidden */
  58667. export var gpuUpdateParticlesPixelShader: {
  58668. name: string;
  58669. shader: string;
  58670. };
  58671. }
  58672. declare module BABYLON {
  58673. /** @hidden */
  58674. export var gpuUpdateParticlesVertexShader: {
  58675. name: string;
  58676. shader: string;
  58677. };
  58678. }
  58679. declare module BABYLON {
  58680. /** @hidden */
  58681. export var clipPlaneFragmentDeclaration2: {
  58682. name: string;
  58683. shader: string;
  58684. };
  58685. }
  58686. declare module BABYLON {
  58687. /** @hidden */
  58688. export var gpuRenderParticlesPixelShader: {
  58689. name: string;
  58690. shader: string;
  58691. };
  58692. }
  58693. declare module BABYLON {
  58694. /** @hidden */
  58695. export var clipPlaneVertexDeclaration2: {
  58696. name: string;
  58697. shader: string;
  58698. };
  58699. }
  58700. declare module BABYLON {
  58701. /** @hidden */
  58702. export var gpuRenderParticlesVertexShader: {
  58703. name: string;
  58704. shader: string;
  58705. };
  58706. }
  58707. declare module BABYLON {
  58708. /**
  58709. * This represents a GPU particle system in Babylon
  58710. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58711. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58712. */
  58713. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58714. /**
  58715. * The layer mask we are rendering the particles through.
  58716. */
  58717. layerMask: number;
  58718. private _capacity;
  58719. private _activeCount;
  58720. private _currentActiveCount;
  58721. private _accumulatedCount;
  58722. private _renderEffect;
  58723. private _updateEffect;
  58724. private _buffer0;
  58725. private _buffer1;
  58726. private _spriteBuffer;
  58727. private _updateVAO;
  58728. private _renderVAO;
  58729. private _targetIndex;
  58730. private _sourceBuffer;
  58731. private _targetBuffer;
  58732. private _engine;
  58733. private _currentRenderId;
  58734. private _started;
  58735. private _stopped;
  58736. private _timeDelta;
  58737. private _randomTexture;
  58738. private _randomTexture2;
  58739. private _attributesStrideSize;
  58740. private _updateEffectOptions;
  58741. private _randomTextureSize;
  58742. private _actualFrame;
  58743. private readonly _rawTextureWidth;
  58744. /**
  58745. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58746. */
  58747. static readonly IsSupported: boolean;
  58748. /**
  58749. * An event triggered when the system is disposed.
  58750. */
  58751. onDisposeObservable: Observable<GPUParticleSystem>;
  58752. /**
  58753. * Gets the maximum number of particles active at the same time.
  58754. * @returns The max number of active particles.
  58755. */
  58756. getCapacity(): number;
  58757. /**
  58758. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58759. * to override the particles.
  58760. */
  58761. forceDepthWrite: boolean;
  58762. /**
  58763. * Gets or set the number of active particles
  58764. */
  58765. activeParticleCount: number;
  58766. private _preWarmDone;
  58767. /**
  58768. * Is this system ready to be used/rendered
  58769. * @return true if the system is ready
  58770. */
  58771. isReady(): boolean;
  58772. /**
  58773. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58774. * @returns True if it has been started, otherwise false.
  58775. */
  58776. isStarted(): boolean;
  58777. /**
  58778. * Starts the particle system and begins to emit
  58779. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58780. */
  58781. start(delay?: number): void;
  58782. /**
  58783. * Stops the particle system.
  58784. */
  58785. stop(): void;
  58786. /**
  58787. * Remove all active particles
  58788. */
  58789. reset(): void;
  58790. /**
  58791. * Returns the string "GPUParticleSystem"
  58792. * @returns a string containing the class name
  58793. */
  58794. getClassName(): string;
  58795. private _colorGradientsTexture;
  58796. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58797. /**
  58798. * Adds a new color gradient
  58799. * @param gradient defines the gradient to use (between 0 and 1)
  58800. * @param color1 defines the color to affect to the specified gradient
  58801. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58802. * @returns the current particle system
  58803. */
  58804. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58805. /**
  58806. * Remove a specific color gradient
  58807. * @param gradient defines the gradient to remove
  58808. * @returns the current particle system
  58809. */
  58810. removeColorGradient(gradient: number): GPUParticleSystem;
  58811. private _angularSpeedGradientsTexture;
  58812. private _sizeGradientsTexture;
  58813. private _velocityGradientsTexture;
  58814. private _limitVelocityGradientsTexture;
  58815. private _dragGradientsTexture;
  58816. private _addFactorGradient;
  58817. /**
  58818. * Adds a new size gradient
  58819. * @param gradient defines the gradient to use (between 0 and 1)
  58820. * @param factor defines the size factor to affect to the specified gradient
  58821. * @returns the current particle system
  58822. */
  58823. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58824. /**
  58825. * Remove a specific size gradient
  58826. * @param gradient defines the gradient to remove
  58827. * @returns the current particle system
  58828. */
  58829. removeSizeGradient(gradient: number): GPUParticleSystem;
  58830. /**
  58831. * Adds a new angular speed gradient
  58832. * @param gradient defines the gradient to use (between 0 and 1)
  58833. * @param factor defines the angular speed to affect to the specified gradient
  58834. * @returns the current particle system
  58835. */
  58836. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58837. /**
  58838. * Remove a specific angular speed gradient
  58839. * @param gradient defines the gradient to remove
  58840. * @returns the current particle system
  58841. */
  58842. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58843. /**
  58844. * Adds a new velocity gradient
  58845. * @param gradient defines the gradient to use (between 0 and 1)
  58846. * @param factor defines the velocity to affect to the specified gradient
  58847. * @returns the current particle system
  58848. */
  58849. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58850. /**
  58851. * Remove a specific velocity gradient
  58852. * @param gradient defines the gradient to remove
  58853. * @returns the current particle system
  58854. */
  58855. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58856. /**
  58857. * Adds a new limit velocity gradient
  58858. * @param gradient defines the gradient to use (between 0 and 1)
  58859. * @param factor defines the limit velocity value to affect to the specified gradient
  58860. * @returns the current particle system
  58861. */
  58862. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58863. /**
  58864. * Remove a specific limit velocity gradient
  58865. * @param gradient defines the gradient to remove
  58866. * @returns the current particle system
  58867. */
  58868. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58869. /**
  58870. * Adds a new drag gradient
  58871. * @param gradient defines the gradient to use (between 0 and 1)
  58872. * @param factor defines the drag value to affect to the specified gradient
  58873. * @returns the current particle system
  58874. */
  58875. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58876. /**
  58877. * Remove a specific drag gradient
  58878. * @param gradient defines the gradient to remove
  58879. * @returns the current particle system
  58880. */
  58881. removeDragGradient(gradient: number): GPUParticleSystem;
  58882. /**
  58883. * Not supported by GPUParticleSystem
  58884. * @param gradient defines the gradient to use (between 0 and 1)
  58885. * @param factor defines the emit rate value to affect to the specified gradient
  58886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58887. * @returns the current particle system
  58888. */
  58889. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58890. /**
  58891. * Not supported by GPUParticleSystem
  58892. * @param gradient defines the gradient to remove
  58893. * @returns the current particle system
  58894. */
  58895. removeEmitRateGradient(gradient: number): IParticleSystem;
  58896. /**
  58897. * Not supported by GPUParticleSystem
  58898. * @param gradient defines the gradient to use (between 0 and 1)
  58899. * @param factor defines the start size value to affect to the specified gradient
  58900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58901. * @returns the current particle system
  58902. */
  58903. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58904. /**
  58905. * Not supported by GPUParticleSystem
  58906. * @param gradient defines the gradient to remove
  58907. * @returns the current particle system
  58908. */
  58909. removeStartSizeGradient(gradient: number): IParticleSystem;
  58910. /**
  58911. * Not supported by GPUParticleSystem
  58912. * @param gradient defines the gradient to use (between 0 and 1)
  58913. * @param min defines the color remap minimal range
  58914. * @param max defines the color remap maximal range
  58915. * @returns the current particle system
  58916. */
  58917. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58918. /**
  58919. * Not supported by GPUParticleSystem
  58920. * @param gradient defines the gradient to remove
  58921. * @returns the current particle system
  58922. */
  58923. removeColorRemapGradient(): IParticleSystem;
  58924. /**
  58925. * Not supported by GPUParticleSystem
  58926. * @param gradient defines the gradient to use (between 0 and 1)
  58927. * @param min defines the alpha remap minimal range
  58928. * @param max defines the alpha remap maximal range
  58929. * @returns the current particle system
  58930. */
  58931. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58932. /**
  58933. * Not supported by GPUParticleSystem
  58934. * @param gradient defines the gradient to remove
  58935. * @returns the current particle system
  58936. */
  58937. removeAlphaRemapGradient(): IParticleSystem;
  58938. /**
  58939. * Not supported by GPUParticleSystem
  58940. * @param gradient defines the gradient to use (between 0 and 1)
  58941. * @param color defines the color to affect to the specified gradient
  58942. * @returns the current particle system
  58943. */
  58944. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58945. /**
  58946. * Not supported by GPUParticleSystem
  58947. * @param gradient defines the gradient to remove
  58948. * @returns the current particle system
  58949. */
  58950. removeRampGradient(): IParticleSystem;
  58951. /**
  58952. * Not supported by GPUParticleSystem
  58953. * @returns the list of ramp gradients
  58954. */
  58955. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58956. /**
  58957. * Not supported by GPUParticleSystem
  58958. * Gets or sets a boolean indicating that ramp gradients must be used
  58959. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58960. */
  58961. useRampGradients: boolean;
  58962. /**
  58963. * Not supported by GPUParticleSystem
  58964. * @param gradient defines the gradient to use (between 0 and 1)
  58965. * @param factor defines the life time factor to affect to the specified gradient
  58966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58967. * @returns the current particle system
  58968. */
  58969. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58970. /**
  58971. * Not supported by GPUParticleSystem
  58972. * @param gradient defines the gradient to remove
  58973. * @returns the current particle system
  58974. */
  58975. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58976. /**
  58977. * Instantiates a GPU particle system.
  58978. * 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.
  58979. * @param name The name of the particle system
  58980. * @param options The options used to create the system
  58981. * @param scene The scene the particle system belongs to
  58982. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58983. */
  58984. constructor(name: string, options: Partial<{
  58985. capacity: number;
  58986. randomTextureSize: number;
  58987. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58988. protected _reset(): void;
  58989. private _createUpdateVAO;
  58990. private _createRenderVAO;
  58991. private _initialize;
  58992. /** @hidden */
  58993. _recreateUpdateEffect(): void;
  58994. /** @hidden */
  58995. _recreateRenderEffect(): void;
  58996. /**
  58997. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58998. * @param preWarm defines if we are in the pre-warmimg phase
  58999. */
  59000. animate(preWarm?: boolean): void;
  59001. private _createFactorGradientTexture;
  59002. private _createSizeGradientTexture;
  59003. private _createAngularSpeedGradientTexture;
  59004. private _createVelocityGradientTexture;
  59005. private _createLimitVelocityGradientTexture;
  59006. private _createDragGradientTexture;
  59007. private _createColorGradientTexture;
  59008. /**
  59009. * Renders the particle system in its current state
  59010. * @param preWarm defines if the system should only update the particles but not render them
  59011. * @returns the current number of particles
  59012. */
  59013. render(preWarm?: boolean): number;
  59014. /**
  59015. * Rebuilds the particle system
  59016. */
  59017. rebuild(): void;
  59018. private _releaseBuffers;
  59019. private _releaseVAOs;
  59020. /**
  59021. * Disposes the particle system and free the associated resources
  59022. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59023. */
  59024. dispose(disposeTexture?: boolean): void;
  59025. /**
  59026. * Clones the particle system.
  59027. * @param name The name of the cloned object
  59028. * @param newEmitter The new emitter to use
  59029. * @returns the cloned particle system
  59030. */
  59031. clone(name: string, newEmitter: any): GPUParticleSystem;
  59032. /**
  59033. * Serializes the particle system to a JSON object.
  59034. * @returns the JSON object
  59035. */
  59036. serialize(): any;
  59037. /**
  59038. * Parses a JSON object to create a GPU particle system.
  59039. * @param parsedParticleSystem The JSON object to parse
  59040. * @param scene The scene to create the particle system in
  59041. * @param rootUrl The root url to use to load external dependencies like texture
  59042. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59043. * @returns the parsed GPU particle system
  59044. */
  59045. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59046. }
  59047. }
  59048. declare module BABYLON {
  59049. /**
  59050. * Represents a set of particle systems working together to create a specific effect
  59051. */
  59052. export class ParticleSystemSet implements IDisposable {
  59053. /**
  59054. * Gets or sets base Assets URL
  59055. */
  59056. static BaseAssetsUrl: string;
  59057. private _emitterCreationOptions;
  59058. private _emitterNode;
  59059. /**
  59060. * Gets the particle system list
  59061. */
  59062. systems: IParticleSystem[];
  59063. /**
  59064. * Gets the emitter node used with this set
  59065. */
  59066. readonly emitterNode: Nullable<TransformNode>;
  59067. /**
  59068. * Creates a new emitter mesh as a sphere
  59069. * @param options defines the options used to create the sphere
  59070. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59071. * @param scene defines the hosting scene
  59072. */
  59073. setEmitterAsSphere(options: {
  59074. diameter: number;
  59075. segments: number;
  59076. color: Color3;
  59077. }, renderingGroupId: number, scene: Scene): void;
  59078. /**
  59079. * Starts all particle systems of the set
  59080. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59081. */
  59082. start(emitter?: AbstractMesh): void;
  59083. /**
  59084. * Release all associated resources
  59085. */
  59086. dispose(): void;
  59087. /**
  59088. * Serialize the set into a JSON compatible object
  59089. * @returns a JSON compatible representation of the set
  59090. */
  59091. serialize(): any;
  59092. /**
  59093. * Parse a new ParticleSystemSet from a serialized source
  59094. * @param data defines a JSON compatible representation of the set
  59095. * @param scene defines the hosting scene
  59096. * @param gpu defines if we want GPU particles or CPU particles
  59097. * @returns a new ParticleSystemSet
  59098. */
  59099. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59100. }
  59101. }
  59102. declare module BABYLON {
  59103. /**
  59104. * This class is made for on one-liner static method to help creating particle system set.
  59105. */
  59106. export class ParticleHelper {
  59107. /**
  59108. * Gets or sets base Assets URL
  59109. */
  59110. static BaseAssetsUrl: string;
  59111. /**
  59112. * Create a default particle system that you can tweak
  59113. * @param emitter defines the emitter to use
  59114. * @param capacity defines the system capacity (default is 500 particles)
  59115. * @param scene defines the hosting scene
  59116. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59117. * @returns the new Particle system
  59118. */
  59119. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59120. /**
  59121. * This is the main static method (one-liner) of this helper to create different particle systems
  59122. * @param type This string represents the type to the particle system to create
  59123. * @param scene The scene where the particle system should live
  59124. * @param gpu If the system will use gpu
  59125. * @returns the ParticleSystemSet created
  59126. */
  59127. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59128. /**
  59129. * Static function used to export a particle system to a ParticleSystemSet variable.
  59130. * Please note that the emitter shape is not exported
  59131. * @param systems defines the particle systems to export
  59132. * @returns the created particle system set
  59133. */
  59134. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59135. }
  59136. }
  59137. declare module BABYLON {
  59138. interface Engine {
  59139. /**
  59140. * Create an effect to use with particle systems.
  59141. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59142. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59143. * @param uniformsNames defines a list of attribute names
  59144. * @param samplers defines an array of string used to represent textures
  59145. * @param defines defines the string containing the defines to use to compile the shaders
  59146. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59147. * @param onCompiled defines a function to call when the effect creation is successful
  59148. * @param onError defines a function to call when the effect creation has failed
  59149. * @returns the new Effect
  59150. */
  59151. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59152. }
  59153. interface Mesh {
  59154. /**
  59155. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59156. * @returns an array of IParticleSystem
  59157. */
  59158. getEmittedParticleSystems(): IParticleSystem[];
  59159. /**
  59160. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59161. * @returns an array of IParticleSystem
  59162. */
  59163. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59164. }
  59165. /**
  59166. * @hidden
  59167. */
  59168. export var _IDoNeedToBeInTheBuild: number;
  59169. }
  59170. declare module BABYLON {
  59171. /** Defines the 4 color options */
  59172. export enum PointColor {
  59173. /** color value */
  59174. Color = 2,
  59175. /** uv value */
  59176. UV = 1,
  59177. /** random value */
  59178. Random = 0,
  59179. /** stated value */
  59180. Stated = 3
  59181. }
  59182. /**
  59183. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  59184. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  59185. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  59186. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  59187. *
  59188. * Full documentation here : TO BE ENTERED
  59189. */
  59190. export class PointsCloudSystem implements IDisposable {
  59191. /**
  59192. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  59193. * Example : var p = SPS.particles[i];
  59194. */
  59195. particles: CloudPoint[];
  59196. /**
  59197. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  59198. */
  59199. nbParticles: number;
  59200. /**
  59201. * This a counter for your own usage. It's not set by any SPS functions.
  59202. */
  59203. counter: number;
  59204. /**
  59205. * The PCS name. This name is also given to the underlying mesh.
  59206. */
  59207. name: string;
  59208. /**
  59209. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  59210. */
  59211. mesh: Mesh;
  59212. /**
  59213. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  59214. * Please read :
  59215. */
  59216. vars: any;
  59217. /**
  59218. * @hidden
  59219. */
  59220. _size: number;
  59221. private _scene;
  59222. private _promises;
  59223. private _positions;
  59224. private _indices;
  59225. private _normals;
  59226. private _colors;
  59227. private _uvs;
  59228. private _indices32;
  59229. private _positions32;
  59230. private _colors32;
  59231. private _uvs32;
  59232. private _updatable;
  59233. private _isVisibilityBoxLocked;
  59234. private _alwaysVisible;
  59235. private _groups;
  59236. private _groupCounter;
  59237. private _computeParticleColor;
  59238. private _computeParticleTexture;
  59239. private _computeParticleRotation;
  59240. private _computeBoundingBox;
  59241. private _isReady;
  59242. /**
  59243. * Creates a PCS (Points Cloud System) object
  59244. * @param name (String) is the PCS name, this will be the underlying mesh name
  59245. * @param pointSize (number) is the size for each point
  59246. * @param scene (Scene) is the scene in which the PCS is added
  59247. * @param options defines the options of the PCS e.g.
  59248. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59249. */
  59250. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59251. updatable?: boolean;
  59252. });
  59253. /**
  59254. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59255. * If no points were added to the PCS, the returned mesh is just a single point.
  59256. * @returns a promise for the created mesh
  59257. */
  59258. buildMeshAsync(): Promise<Mesh>;
  59259. /**
  59260. * @hidden
  59261. */
  59262. private _buildMesh;
  59263. private _addParticle;
  59264. private _randomUnitVector;
  59265. private _getColorIndicesForCoord;
  59266. private _setPointsColorOrUV;
  59267. private _colorFromTexture;
  59268. private _calculateDensity;
  59269. /**
  59270. * Adds points to the PCS in random positions within a unit sphere
  59271. * @param nb (positive integer) the number of particles to be created from this model
  59272. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59273. * @returns the number of groups in the system
  59274. */
  59275. addPoints(nb: number, pointFunction?: any): number;
  59276. /**
  59277. * Adds points to the PCS from the surface of the model shape
  59278. * @param mesh is any Mesh object that will be used as a surface model for the points
  59279. * @param nb (positive integer) the number of particles to be created from this model
  59280. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59281. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59282. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59283. * @returns the number of groups in the system
  59284. */
  59285. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59286. /**
  59287. * Adds points to the PCS inside the model shape
  59288. * @param mesh is any Mesh object that will be used as a surface model for the points
  59289. * @param nb (positive integer) the number of particles to be created from this model
  59290. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59291. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59292. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59293. * @returns the number of groups in the system
  59294. */
  59295. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59296. /**
  59297. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59298. * This method calls `updateParticle()` for each particle of the SPS.
  59299. * For an animated SPS, it is usually called within the render loop.
  59300. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59301. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59302. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59303. * @returns the PCS.
  59304. */
  59305. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59306. /**
  59307. * Disposes the PCS.
  59308. */
  59309. dispose(): void;
  59310. /**
  59311. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59312. * doc :
  59313. * @returns the PCS.
  59314. */
  59315. refreshVisibleSize(): PointsCloudSystem;
  59316. /**
  59317. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59318. * @param size the size (float) of the visibility box
  59319. * note : this doesn't lock the PCS mesh bounding box.
  59320. * doc :
  59321. */
  59322. setVisibilityBox(size: number): void;
  59323. /**
  59324. * Gets whether the PCS is always visible or not
  59325. * doc :
  59326. */
  59327. /**
  59328. * Sets the PCS as always visible or not
  59329. * doc :
  59330. */
  59331. isAlwaysVisible: boolean;
  59332. /**
  59333. * Tells to `setParticles()` to compute the particle rotations or not
  59334. * Default value : false. The PCS is faster when it's set to false
  59335. * Note : particle rotations are only applied to parent particles
  59336. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59337. */
  59338. computeParticleRotation: boolean;
  59339. /**
  59340. * Tells to `setParticles()` to compute the particle colors or not.
  59341. * Default value : true. The PCS is faster when it's set to false.
  59342. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59343. */
  59344. /**
  59345. * Gets if `setParticles()` computes the particle colors or not.
  59346. * Default value : false. The PCS is faster when it's set to false.
  59347. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59348. */
  59349. computeParticleColor: boolean;
  59350. /**
  59351. * Gets if `setParticles()` computes the particle textures or not.
  59352. * Default value : false. The PCS is faster when it's set to false.
  59353. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59354. */
  59355. computeParticleTexture: boolean;
  59356. /**
  59357. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59358. */
  59359. /**
  59360. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59361. */
  59362. computeBoundingBox: boolean;
  59363. /**
  59364. * This function does nothing. It may be overwritten to set all the particle first values.
  59365. * The PCS doesn't call this function, you may have to call it by your own.
  59366. * doc :
  59367. */
  59368. initParticles(): void;
  59369. /**
  59370. * This function does nothing. It may be overwritten to recycle a particle
  59371. * The PCS doesn't call this function, you can to call it
  59372. * doc :
  59373. * @param particle The particle to recycle
  59374. * @returns the recycled particle
  59375. */
  59376. recycleParticle(particle: CloudPoint): CloudPoint;
  59377. /**
  59378. * Updates a particle : this function should be overwritten by the user.
  59379. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59380. * doc :
  59381. * @example : just set a particle position or velocity and recycle conditions
  59382. * @param particle The particle to update
  59383. * @returns the updated particle
  59384. */
  59385. updateParticle(particle: CloudPoint): CloudPoint;
  59386. /**
  59387. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59388. * This does nothing and may be overwritten by the user.
  59389. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59390. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59391. * @param update the boolean update value actually passed to setParticles()
  59392. */
  59393. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59394. /**
  59395. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59396. * This will be passed three parameters.
  59397. * This does nothing and may be overwritten by the user.
  59398. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59399. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59400. * @param update the boolean update value actually passed to setParticles()
  59401. */
  59402. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59403. }
  59404. }
  59405. declare module BABYLON {
  59406. /**
  59407. * Represents one particle of a points cloud system.
  59408. */
  59409. export class CloudPoint {
  59410. /**
  59411. * particle global index
  59412. */
  59413. idx: number;
  59414. /**
  59415. * The color of the particle
  59416. */
  59417. color: Nullable<Color4>;
  59418. /**
  59419. * The world space position of the particle.
  59420. */
  59421. position: Vector3;
  59422. /**
  59423. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  59424. */
  59425. rotation: Vector3;
  59426. /**
  59427. * The world space rotation quaternion of the particle.
  59428. */
  59429. rotationQuaternion: Nullable<Quaternion>;
  59430. /**
  59431. * The uv of the particle.
  59432. */
  59433. uv: Nullable<Vector2>;
  59434. /**
  59435. * The current speed of the particle.
  59436. */
  59437. velocity: Vector3;
  59438. /**
  59439. * The pivot point in the particle local space.
  59440. */
  59441. pivot: Vector3;
  59442. /**
  59443. * Must the particle be translated from its pivot point in its local space ?
  59444. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  59445. * Default : false
  59446. */
  59447. translateFromPivot: boolean;
  59448. /**
  59449. * Index of this particle in the global "positions" array (Internal use)
  59450. * @hidden
  59451. */
  59452. _pos: number;
  59453. /**
  59454. * @hidden Index of this particle in the global "indices" array (Internal use)
  59455. */
  59456. _ind: number;
  59457. /**
  59458. * Group this particle belongs to
  59459. */
  59460. _group: PointsGroup;
  59461. /**
  59462. * Group id of this particle
  59463. */
  59464. groupId: number;
  59465. /**
  59466. * Index of the particle in its group id (Internal use)
  59467. */
  59468. idxInGroup: number;
  59469. /**
  59470. * @hidden Particle BoundingInfo object (Internal use)
  59471. */
  59472. _boundingInfo: BoundingInfo;
  59473. /**
  59474. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  59475. */
  59476. _pcs: PointsCloudSystem;
  59477. /**
  59478. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59479. */
  59480. _stillInvisible: boolean;
  59481. /**
  59482. * @hidden Last computed particle rotation matrix
  59483. */
  59484. _rotationMatrix: number[];
  59485. /**
  59486. * Parent particle Id, if any.
  59487. * Default null.
  59488. */
  59489. parentId: Nullable<number>;
  59490. /**
  59491. * @hidden Internal global position in the PCS.
  59492. */
  59493. _globalPosition: Vector3;
  59494. /**
  59495. * Creates a Point Cloud object.
  59496. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59497. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59498. * @param group (PointsGroup) is the group the particle belongs to
  59499. * @param groupId (integer) is the group identifier in the PCS.
  59500. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59501. * @param pcs defines the PCS it is associated to
  59502. */
  59503. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59504. /**
  59505. * get point size
  59506. */
  59507. /**
  59508. * Set point size
  59509. */
  59510. size: Vector3;
  59511. /**
  59512. * Legacy support, changed quaternion to rotationQuaternion
  59513. */
  59514. /**
  59515. * Legacy support, changed quaternion to rotationQuaternion
  59516. */
  59517. quaternion: Nullable<Quaternion>;
  59518. /**
  59519. * Returns a boolean. True if the particle intersects a mesh, else false
  59520. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59521. * @param target is the object (point or mesh) what the intersection is computed against
  59522. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59523. * @returns true if it intersects
  59524. */
  59525. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59526. /**
  59527. * get the rotation matrix of the particle
  59528. * @hidden
  59529. */
  59530. getRotationMatrix(m: Matrix): void;
  59531. }
  59532. /**
  59533. * Represents a group of points in a points cloud system
  59534. * * PCS internal tool, don't use it manually.
  59535. */
  59536. export class PointsGroup {
  59537. /**
  59538. * The group id
  59539. * @hidden
  59540. */
  59541. groupID: number;
  59542. /**
  59543. * image data for group (internal use)
  59544. * @hidden
  59545. */
  59546. _groupImageData: Nullable<ArrayBufferView>;
  59547. /**
  59548. * Image Width (internal use)
  59549. * @hidden
  59550. */
  59551. _groupImgWidth: number;
  59552. /**
  59553. * Image Height (internal use)
  59554. * @hidden
  59555. */
  59556. _groupImgHeight: number;
  59557. /**
  59558. * Custom position function (internal use)
  59559. * @hidden
  59560. */
  59561. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59562. /**
  59563. * density per facet for surface points
  59564. * @hidden
  59565. */
  59566. _groupDensity: number[];
  59567. /**
  59568. * Only when points are colored by texture carries pointer to texture list array
  59569. * @hidden
  59570. */
  59571. _textureNb: number;
  59572. /**
  59573. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59574. * PCS internal tool, don't use it manually.
  59575. * @hidden
  59576. */
  59577. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59578. }
  59579. }
  59580. declare module BABYLON {
  59581. interface Scene {
  59582. /** @hidden (Backing field) */
  59583. _physicsEngine: Nullable<IPhysicsEngine>;
  59584. /**
  59585. * Gets the current physics engine
  59586. * @returns a IPhysicsEngine or null if none attached
  59587. */
  59588. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59589. /**
  59590. * Enables physics to the current scene
  59591. * @param gravity defines the scene's gravity for the physics engine
  59592. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59593. * @return a boolean indicating if the physics engine was initialized
  59594. */
  59595. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59596. /**
  59597. * Disables and disposes the physics engine associated with the scene
  59598. */
  59599. disablePhysicsEngine(): void;
  59600. /**
  59601. * Gets a boolean indicating if there is an active physics engine
  59602. * @returns a boolean indicating if there is an active physics engine
  59603. */
  59604. isPhysicsEnabled(): boolean;
  59605. /**
  59606. * Deletes a physics compound impostor
  59607. * @param compound defines the compound to delete
  59608. */
  59609. deleteCompoundImpostor(compound: any): void;
  59610. /**
  59611. * An event triggered when physic simulation is about to be run
  59612. */
  59613. onBeforePhysicsObservable: Observable<Scene>;
  59614. /**
  59615. * An event triggered when physic simulation has been done
  59616. */
  59617. onAfterPhysicsObservable: Observable<Scene>;
  59618. }
  59619. interface AbstractMesh {
  59620. /** @hidden */
  59621. _physicsImpostor: Nullable<PhysicsImpostor>;
  59622. /**
  59623. * Gets or sets impostor used for physic simulation
  59624. * @see http://doc.babylonjs.com/features/physics_engine
  59625. */
  59626. physicsImpostor: Nullable<PhysicsImpostor>;
  59627. /**
  59628. * Gets the current physics impostor
  59629. * @see http://doc.babylonjs.com/features/physics_engine
  59630. * @returns a physics impostor or null
  59631. */
  59632. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59633. /** Apply a physic impulse to the mesh
  59634. * @param force defines the force to apply
  59635. * @param contactPoint defines where to apply the force
  59636. * @returns the current mesh
  59637. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59638. */
  59639. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59640. /**
  59641. * Creates a physic joint between two meshes
  59642. * @param otherMesh defines the other mesh to use
  59643. * @param pivot1 defines the pivot to use on this mesh
  59644. * @param pivot2 defines the pivot to use on the other mesh
  59645. * @param options defines additional options (can be plugin dependent)
  59646. * @returns the current mesh
  59647. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59648. */
  59649. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59650. /** @hidden */
  59651. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59652. }
  59653. /**
  59654. * Defines the physics engine scene component responsible to manage a physics engine
  59655. */
  59656. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59657. /**
  59658. * The component name helpful to identify the component in the list of scene components.
  59659. */
  59660. readonly name: string;
  59661. /**
  59662. * The scene the component belongs to.
  59663. */
  59664. scene: Scene;
  59665. /**
  59666. * Creates a new instance of the component for the given scene
  59667. * @param scene Defines the scene to register the component in
  59668. */
  59669. constructor(scene: Scene);
  59670. /**
  59671. * Registers the component in a given scene
  59672. */
  59673. register(): void;
  59674. /**
  59675. * Rebuilds the elements related to this component in case of
  59676. * context lost for instance.
  59677. */
  59678. rebuild(): void;
  59679. /**
  59680. * Disposes the component and the associated ressources
  59681. */
  59682. dispose(): void;
  59683. }
  59684. }
  59685. declare module BABYLON {
  59686. /**
  59687. * A helper for physics simulations
  59688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59689. */
  59690. export class PhysicsHelper {
  59691. private _scene;
  59692. private _physicsEngine;
  59693. /**
  59694. * Initializes the Physics helper
  59695. * @param scene Babylon.js scene
  59696. */
  59697. constructor(scene: Scene);
  59698. /**
  59699. * Applies a radial explosion impulse
  59700. * @param origin the origin of the explosion
  59701. * @param radiusOrEventOptions the radius or the options of radial explosion
  59702. * @param strength the explosion strength
  59703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59704. * @returns A physics radial explosion event, or null
  59705. */
  59706. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59707. /**
  59708. * Applies a radial explosion force
  59709. * @param origin the origin of the explosion
  59710. * @param radiusOrEventOptions the radius or the options of radial explosion
  59711. * @param strength the explosion strength
  59712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59713. * @returns A physics radial explosion event, or null
  59714. */
  59715. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59716. /**
  59717. * Creates a gravitational field
  59718. * @param origin the origin of the explosion
  59719. * @param radiusOrEventOptions the radius or the options of radial explosion
  59720. * @param strength the explosion strength
  59721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59722. * @returns A physics gravitational field event, or null
  59723. */
  59724. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59725. /**
  59726. * Creates a physics updraft event
  59727. * @param origin the origin of the updraft
  59728. * @param radiusOrEventOptions the radius or the options of the updraft
  59729. * @param strength the strength of the updraft
  59730. * @param height the height of the updraft
  59731. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59732. * @returns A physics updraft event, or null
  59733. */
  59734. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59735. /**
  59736. * Creates a physics vortex event
  59737. * @param origin the of the vortex
  59738. * @param radiusOrEventOptions the radius or the options of the vortex
  59739. * @param strength the strength of the vortex
  59740. * @param height the height of the vortex
  59741. * @returns a Physics vortex event, or null
  59742. * A physics vortex event or null
  59743. */
  59744. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59745. }
  59746. /**
  59747. * Represents a physics radial explosion event
  59748. */
  59749. class PhysicsRadialExplosionEvent {
  59750. private _scene;
  59751. private _options;
  59752. private _sphere;
  59753. private _dataFetched;
  59754. /**
  59755. * Initializes a radial explosioin event
  59756. * @param _scene BabylonJS scene
  59757. * @param _options The options for the vortex event
  59758. */
  59759. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59760. /**
  59761. * Returns the data related to the radial explosion event (sphere).
  59762. * @returns The radial explosion event data
  59763. */
  59764. getData(): PhysicsRadialExplosionEventData;
  59765. /**
  59766. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59767. * @param impostor A physics imposter
  59768. * @param origin the origin of the explosion
  59769. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59770. */
  59771. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59772. /**
  59773. * Triggers affecterd impostors callbacks
  59774. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59775. */
  59776. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59777. /**
  59778. * Disposes the sphere.
  59779. * @param force Specifies if the sphere should be disposed by force
  59780. */
  59781. dispose(force?: boolean): void;
  59782. /*** Helpers ***/
  59783. private _prepareSphere;
  59784. private _intersectsWithSphere;
  59785. }
  59786. /**
  59787. * Represents a gravitational field event
  59788. */
  59789. class PhysicsGravitationalFieldEvent {
  59790. private _physicsHelper;
  59791. private _scene;
  59792. private _origin;
  59793. private _options;
  59794. private _tickCallback;
  59795. private _sphere;
  59796. private _dataFetched;
  59797. /**
  59798. * Initializes the physics gravitational field event
  59799. * @param _physicsHelper A physics helper
  59800. * @param _scene BabylonJS scene
  59801. * @param _origin The origin position of the gravitational field event
  59802. * @param _options The options for the vortex event
  59803. */
  59804. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59805. /**
  59806. * Returns the data related to the gravitational field event (sphere).
  59807. * @returns A gravitational field event
  59808. */
  59809. getData(): PhysicsGravitationalFieldEventData;
  59810. /**
  59811. * Enables the gravitational field.
  59812. */
  59813. enable(): void;
  59814. /**
  59815. * Disables the gravitational field.
  59816. */
  59817. disable(): void;
  59818. /**
  59819. * Disposes the sphere.
  59820. * @param force The force to dispose from the gravitational field event
  59821. */
  59822. dispose(force?: boolean): void;
  59823. private _tick;
  59824. }
  59825. /**
  59826. * Represents a physics updraft event
  59827. */
  59828. class PhysicsUpdraftEvent {
  59829. private _scene;
  59830. private _origin;
  59831. private _options;
  59832. private _physicsEngine;
  59833. private _originTop;
  59834. private _originDirection;
  59835. private _tickCallback;
  59836. private _cylinder;
  59837. private _cylinderPosition;
  59838. private _dataFetched;
  59839. /**
  59840. * Initializes the physics updraft event
  59841. * @param _scene BabylonJS scene
  59842. * @param _origin The origin position of the updraft
  59843. * @param _options The options for the updraft event
  59844. */
  59845. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59846. /**
  59847. * Returns the data related to the updraft event (cylinder).
  59848. * @returns A physics updraft event
  59849. */
  59850. getData(): PhysicsUpdraftEventData;
  59851. /**
  59852. * Enables the updraft.
  59853. */
  59854. enable(): void;
  59855. /**
  59856. * Disables the updraft.
  59857. */
  59858. disable(): void;
  59859. /**
  59860. * Disposes the cylinder.
  59861. * @param force Specifies if the updraft should be disposed by force
  59862. */
  59863. dispose(force?: boolean): void;
  59864. private getImpostorHitData;
  59865. private _tick;
  59866. /*** Helpers ***/
  59867. private _prepareCylinder;
  59868. private _intersectsWithCylinder;
  59869. }
  59870. /**
  59871. * Represents a physics vortex event
  59872. */
  59873. class PhysicsVortexEvent {
  59874. private _scene;
  59875. private _origin;
  59876. private _options;
  59877. private _physicsEngine;
  59878. private _originTop;
  59879. private _tickCallback;
  59880. private _cylinder;
  59881. private _cylinderPosition;
  59882. private _dataFetched;
  59883. /**
  59884. * Initializes the physics vortex event
  59885. * @param _scene The BabylonJS scene
  59886. * @param _origin The origin position of the vortex
  59887. * @param _options The options for the vortex event
  59888. */
  59889. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59890. /**
  59891. * Returns the data related to the vortex event (cylinder).
  59892. * @returns The physics vortex event data
  59893. */
  59894. getData(): PhysicsVortexEventData;
  59895. /**
  59896. * Enables the vortex.
  59897. */
  59898. enable(): void;
  59899. /**
  59900. * Disables the cortex.
  59901. */
  59902. disable(): void;
  59903. /**
  59904. * Disposes the sphere.
  59905. * @param force
  59906. */
  59907. dispose(force?: boolean): void;
  59908. private getImpostorHitData;
  59909. private _tick;
  59910. /*** Helpers ***/
  59911. private _prepareCylinder;
  59912. private _intersectsWithCylinder;
  59913. }
  59914. /**
  59915. * Options fot the radial explosion event
  59916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59917. */
  59918. export class PhysicsRadialExplosionEventOptions {
  59919. /**
  59920. * The radius of the sphere for the radial explosion.
  59921. */
  59922. radius: number;
  59923. /**
  59924. * The strenth of the explosion.
  59925. */
  59926. strength: number;
  59927. /**
  59928. * The strenght of the force in correspondence to the distance of the affected object
  59929. */
  59930. falloff: PhysicsRadialImpulseFalloff;
  59931. /**
  59932. * Sphere options for the radial explosion.
  59933. */
  59934. sphere: {
  59935. segments: number;
  59936. diameter: number;
  59937. };
  59938. /**
  59939. * Sphere options for the radial explosion.
  59940. */
  59941. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59942. }
  59943. /**
  59944. * Options fot the updraft event
  59945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59946. */
  59947. export class PhysicsUpdraftEventOptions {
  59948. /**
  59949. * The radius of the cylinder for the vortex
  59950. */
  59951. radius: number;
  59952. /**
  59953. * The strenth of the updraft.
  59954. */
  59955. strength: number;
  59956. /**
  59957. * The height of the cylinder for the updraft.
  59958. */
  59959. height: number;
  59960. /**
  59961. * The mode for the the updraft.
  59962. */
  59963. updraftMode: PhysicsUpdraftMode;
  59964. }
  59965. /**
  59966. * Options fot the vortex event
  59967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59968. */
  59969. export class PhysicsVortexEventOptions {
  59970. /**
  59971. * The radius of the cylinder for the vortex
  59972. */
  59973. radius: number;
  59974. /**
  59975. * The strenth of the vortex.
  59976. */
  59977. strength: number;
  59978. /**
  59979. * The height of the cylinder for the vortex.
  59980. */
  59981. height: number;
  59982. /**
  59983. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59984. */
  59985. centripetalForceThreshold: number;
  59986. /**
  59987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59988. */
  59989. centripetalForceMultiplier: number;
  59990. /**
  59991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59992. */
  59993. centrifugalForceMultiplier: number;
  59994. /**
  59995. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59996. */
  59997. updraftForceMultiplier: number;
  59998. }
  59999. /**
  60000. * The strenght of the force in correspondence to the distance of the affected object
  60001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60002. */
  60003. export enum PhysicsRadialImpulseFalloff {
  60004. /** Defines that impulse is constant in strength across it's whole radius */
  60005. Constant = 0,
  60006. /** Defines that impulse gets weaker if it's further from the origin */
  60007. Linear = 1
  60008. }
  60009. /**
  60010. * The strength of the force in correspondence to the distance of the affected object
  60011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60012. */
  60013. export enum PhysicsUpdraftMode {
  60014. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60015. Center = 0,
  60016. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60017. Perpendicular = 1
  60018. }
  60019. /**
  60020. * Interface for a physics hit data
  60021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60022. */
  60023. export interface PhysicsHitData {
  60024. /**
  60025. * The force applied at the contact point
  60026. */
  60027. force: Vector3;
  60028. /**
  60029. * The contact point
  60030. */
  60031. contactPoint: Vector3;
  60032. /**
  60033. * The distance from the origin to the contact point
  60034. */
  60035. distanceFromOrigin: number;
  60036. }
  60037. /**
  60038. * Interface for radial explosion event data
  60039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60040. */
  60041. export interface PhysicsRadialExplosionEventData {
  60042. /**
  60043. * A sphere used for the radial explosion event
  60044. */
  60045. sphere: Mesh;
  60046. }
  60047. /**
  60048. * Interface for gravitational field event data
  60049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60050. */
  60051. export interface PhysicsGravitationalFieldEventData {
  60052. /**
  60053. * A sphere mesh used for the gravitational field event
  60054. */
  60055. sphere: Mesh;
  60056. }
  60057. /**
  60058. * Interface for updraft event data
  60059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60060. */
  60061. export interface PhysicsUpdraftEventData {
  60062. /**
  60063. * A cylinder used for the updraft event
  60064. */
  60065. cylinder: Mesh;
  60066. }
  60067. /**
  60068. * Interface for vortex event data
  60069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60070. */
  60071. export interface PhysicsVortexEventData {
  60072. /**
  60073. * A cylinder used for the vortex event
  60074. */
  60075. cylinder: Mesh;
  60076. }
  60077. /**
  60078. * Interface for an affected physics impostor
  60079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60080. */
  60081. export interface PhysicsAffectedImpostorWithData {
  60082. /**
  60083. * The impostor affected by the effect
  60084. */
  60085. impostor: PhysicsImpostor;
  60086. /**
  60087. * The data about the hit/horce from the explosion
  60088. */
  60089. hitData: PhysicsHitData;
  60090. }
  60091. }
  60092. declare module BABYLON {
  60093. /** @hidden */
  60094. export var blackAndWhitePixelShader: {
  60095. name: string;
  60096. shader: string;
  60097. };
  60098. }
  60099. declare module BABYLON {
  60100. /**
  60101. * Post process used to render in black and white
  60102. */
  60103. export class BlackAndWhitePostProcess extends PostProcess {
  60104. /**
  60105. * Linear about to convert he result to black and white (default: 1)
  60106. */
  60107. degree: number;
  60108. /**
  60109. * Creates a black and white post process
  60110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60111. * @param name The name of the effect.
  60112. * @param options The required width/height ratio to downsize to before computing the render pass.
  60113. * @param camera The camera to apply the render pass to.
  60114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60115. * @param engine The engine which the post process will be applied. (default: current engine)
  60116. * @param reusable If the post process can be reused on the same frame. (default: false)
  60117. */
  60118. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60119. }
  60120. }
  60121. declare module BABYLON {
  60122. /**
  60123. * This represents a set of one or more post processes in Babylon.
  60124. * A post process can be used to apply a shader to a texture after it is rendered.
  60125. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60126. */
  60127. export class PostProcessRenderEffect {
  60128. private _postProcesses;
  60129. private _getPostProcesses;
  60130. private _singleInstance;
  60131. private _cameras;
  60132. private _indicesForCamera;
  60133. /**
  60134. * Name of the effect
  60135. * @hidden
  60136. */
  60137. _name: string;
  60138. /**
  60139. * Instantiates a post process render effect.
  60140. * A post process can be used to apply a shader to a texture after it is rendered.
  60141. * @param engine The engine the effect is tied to
  60142. * @param name The name of the effect
  60143. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60144. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60145. */
  60146. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60147. /**
  60148. * Checks if all the post processes in the effect are supported.
  60149. */
  60150. readonly isSupported: boolean;
  60151. /**
  60152. * Updates the current state of the effect
  60153. * @hidden
  60154. */
  60155. _update(): void;
  60156. /**
  60157. * Attaches the effect on cameras
  60158. * @param cameras The camera to attach to.
  60159. * @hidden
  60160. */
  60161. _attachCameras(cameras: Camera): void;
  60162. /**
  60163. * Attaches the effect on cameras
  60164. * @param cameras The camera to attach to.
  60165. * @hidden
  60166. */
  60167. _attachCameras(cameras: Camera[]): void;
  60168. /**
  60169. * Detaches the effect on cameras
  60170. * @param cameras The camera to detatch from.
  60171. * @hidden
  60172. */
  60173. _detachCameras(cameras: Camera): void;
  60174. /**
  60175. * Detatches the effect on cameras
  60176. * @param cameras The camera to detatch from.
  60177. * @hidden
  60178. */
  60179. _detachCameras(cameras: Camera[]): void;
  60180. /**
  60181. * Enables the effect on given cameras
  60182. * @param cameras The camera to enable.
  60183. * @hidden
  60184. */
  60185. _enable(cameras: Camera): void;
  60186. /**
  60187. * Enables the effect on given cameras
  60188. * @param cameras The camera to enable.
  60189. * @hidden
  60190. */
  60191. _enable(cameras: Nullable<Camera[]>): void;
  60192. /**
  60193. * Disables the effect on the given cameras
  60194. * @param cameras The camera to disable.
  60195. * @hidden
  60196. */
  60197. _disable(cameras: Camera): void;
  60198. /**
  60199. * Disables the effect on the given cameras
  60200. * @param cameras The camera to disable.
  60201. * @hidden
  60202. */
  60203. _disable(cameras: Nullable<Camera[]>): void;
  60204. /**
  60205. * Gets a list of the post processes contained in the effect.
  60206. * @param camera The camera to get the post processes on.
  60207. * @returns The list of the post processes in the effect.
  60208. */
  60209. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60210. }
  60211. }
  60212. declare module BABYLON {
  60213. /** @hidden */
  60214. export var extractHighlightsPixelShader: {
  60215. name: string;
  60216. shader: string;
  60217. };
  60218. }
  60219. declare module BABYLON {
  60220. /**
  60221. * 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.
  60222. */
  60223. export class ExtractHighlightsPostProcess extends PostProcess {
  60224. /**
  60225. * The luminance threshold, pixels below this value will be set to black.
  60226. */
  60227. threshold: number;
  60228. /** @hidden */
  60229. _exposure: number;
  60230. /**
  60231. * Post process which has the input texture to be used when performing highlight extraction
  60232. * @hidden
  60233. */
  60234. _inputPostProcess: Nullable<PostProcess>;
  60235. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /** @hidden */
  60240. export var bloomMergePixelShader: {
  60241. name: string;
  60242. shader: string;
  60243. };
  60244. }
  60245. declare module BABYLON {
  60246. /**
  60247. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60248. */
  60249. export class BloomMergePostProcess extends PostProcess {
  60250. /** Weight of the bloom to be added to the original input. */
  60251. weight: number;
  60252. /**
  60253. * Creates a new instance of @see BloomMergePostProcess
  60254. * @param name The name of the effect.
  60255. * @param originalFromInput Post process which's input will be used for the merge.
  60256. * @param blurred Blurred highlights post process which's output will be used.
  60257. * @param weight Weight of the bloom to be added to the original input.
  60258. * @param options The required width/height ratio to downsize to before computing the render pass.
  60259. * @param camera The camera to apply the render pass to.
  60260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60261. * @param engine The engine which the post process will be applied. (default: current engine)
  60262. * @param reusable If the post process can be reused on the same frame. (default: false)
  60263. * @param textureType Type of textures used when performing the post process. (default: 0)
  60264. * @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)
  60265. */
  60266. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60267. /** Weight of the bloom to be added to the original input. */
  60268. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60269. }
  60270. }
  60271. declare module BABYLON {
  60272. /**
  60273. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60274. */
  60275. export class BloomEffect extends PostProcessRenderEffect {
  60276. private bloomScale;
  60277. /**
  60278. * @hidden Internal
  60279. */
  60280. _effects: Array<PostProcess>;
  60281. /**
  60282. * @hidden Internal
  60283. */
  60284. _downscale: ExtractHighlightsPostProcess;
  60285. private _blurX;
  60286. private _blurY;
  60287. private _merge;
  60288. /**
  60289. * The luminance threshold to find bright areas of the image to bloom.
  60290. */
  60291. threshold: number;
  60292. /**
  60293. * The strength of the bloom.
  60294. */
  60295. weight: number;
  60296. /**
  60297. * Specifies the size of the bloom blur kernel, relative to the final output size
  60298. */
  60299. kernel: number;
  60300. /**
  60301. * Creates a new instance of @see BloomEffect
  60302. * @param scene The scene the effect belongs to.
  60303. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60304. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60305. * @param bloomWeight The the strength of bloom.
  60306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60307. * @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)
  60308. */
  60309. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60310. /**
  60311. * Disposes each of the internal effects for a given camera.
  60312. * @param camera The camera to dispose the effect on.
  60313. */
  60314. disposeEffects(camera: Camera): void;
  60315. /**
  60316. * @hidden Internal
  60317. */
  60318. _updateEffects(): void;
  60319. /**
  60320. * Internal
  60321. * @returns if all the contained post processes are ready.
  60322. * @hidden
  60323. */
  60324. _isReady(): boolean;
  60325. }
  60326. }
  60327. declare module BABYLON {
  60328. /** @hidden */
  60329. export var chromaticAberrationPixelShader: {
  60330. name: string;
  60331. shader: string;
  60332. };
  60333. }
  60334. declare module BABYLON {
  60335. /**
  60336. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60337. */
  60338. export class ChromaticAberrationPostProcess extends PostProcess {
  60339. /**
  60340. * The amount of seperation of rgb channels (default: 30)
  60341. */
  60342. aberrationAmount: number;
  60343. /**
  60344. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60345. */
  60346. radialIntensity: number;
  60347. /**
  60348. * 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))
  60349. */
  60350. direction: Vector2;
  60351. /**
  60352. * 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))
  60353. */
  60354. centerPosition: Vector2;
  60355. /**
  60356. * Creates a new instance ChromaticAberrationPostProcess
  60357. * @param name The name of the effect.
  60358. * @param screenWidth The width of the screen to apply the effect on.
  60359. * @param screenHeight The height of the screen to apply the effect on.
  60360. * @param options The required width/height ratio to downsize to before computing the render pass.
  60361. * @param camera The camera to apply the render pass to.
  60362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60363. * @param engine The engine which the post process will be applied. (default: current engine)
  60364. * @param reusable If the post process can be reused on the same frame. (default: false)
  60365. * @param textureType Type of textures used when performing the post process. (default: 0)
  60366. * @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)
  60367. */
  60368. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60369. }
  60370. }
  60371. declare module BABYLON {
  60372. /** @hidden */
  60373. export var circleOfConfusionPixelShader: {
  60374. name: string;
  60375. shader: string;
  60376. };
  60377. }
  60378. declare module BABYLON {
  60379. /**
  60380. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60381. */
  60382. export class CircleOfConfusionPostProcess extends PostProcess {
  60383. /**
  60384. * 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.
  60385. */
  60386. lensSize: number;
  60387. /**
  60388. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60389. */
  60390. fStop: number;
  60391. /**
  60392. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60393. */
  60394. focusDistance: number;
  60395. /**
  60396. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60397. */
  60398. focalLength: number;
  60399. private _depthTexture;
  60400. /**
  60401. * Creates a new instance CircleOfConfusionPostProcess
  60402. * @param name The name of the effect.
  60403. * @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.
  60404. * @param options The required width/height ratio to downsize to before computing the render pass.
  60405. * @param camera The camera to apply the render pass to.
  60406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60407. * @param engine The engine which the post process will be applied. (default: current engine)
  60408. * @param reusable If the post process can be reused on the same frame. (default: false)
  60409. * @param textureType Type of textures used when performing the post process. (default: 0)
  60410. * @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)
  60411. */
  60412. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60413. /**
  60414. * 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.
  60415. */
  60416. depthTexture: RenderTargetTexture;
  60417. }
  60418. }
  60419. declare module BABYLON {
  60420. /** @hidden */
  60421. export var colorCorrectionPixelShader: {
  60422. name: string;
  60423. shader: string;
  60424. };
  60425. }
  60426. declare module BABYLON {
  60427. /**
  60428. *
  60429. * This post-process allows the modification of rendered colors by using
  60430. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60431. *
  60432. * The object needs to be provided an url to a texture containing the color
  60433. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60434. * Use an image editing software to tweak the LUT to match your needs.
  60435. *
  60436. * For an example of a color LUT, see here:
  60437. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60438. * For explanations on color grading, see here:
  60439. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60440. *
  60441. */
  60442. export class ColorCorrectionPostProcess extends PostProcess {
  60443. private _colorTableTexture;
  60444. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60445. }
  60446. }
  60447. declare module BABYLON {
  60448. /** @hidden */
  60449. export var convolutionPixelShader: {
  60450. name: string;
  60451. shader: string;
  60452. };
  60453. }
  60454. declare module BABYLON {
  60455. /**
  60456. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60457. * input texture to perform effects such as edge detection or sharpening
  60458. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60459. */
  60460. export class ConvolutionPostProcess extends PostProcess {
  60461. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60462. kernel: number[];
  60463. /**
  60464. * Creates a new instance ConvolutionPostProcess
  60465. * @param name The name of the effect.
  60466. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60467. * @param options The required width/height ratio to downsize to before computing the render pass.
  60468. * @param camera The camera to apply the render pass to.
  60469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60470. * @param engine The engine which the post process will be applied. (default: current engine)
  60471. * @param reusable If the post process can be reused on the same frame. (default: false)
  60472. * @param textureType Type of textures used when performing the post process. (default: 0)
  60473. */
  60474. constructor(name: string,
  60475. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60476. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60477. /**
  60478. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60479. */
  60480. static EdgeDetect0Kernel: number[];
  60481. /**
  60482. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60483. */
  60484. static EdgeDetect1Kernel: number[];
  60485. /**
  60486. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60487. */
  60488. static EdgeDetect2Kernel: number[];
  60489. /**
  60490. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60491. */
  60492. static SharpenKernel: number[];
  60493. /**
  60494. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60495. */
  60496. static EmbossKernel: number[];
  60497. /**
  60498. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60499. */
  60500. static GaussianKernel: number[];
  60501. }
  60502. }
  60503. declare module BABYLON {
  60504. /**
  60505. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60506. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60507. * based on samples that have a large difference in distance than the center pixel.
  60508. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60509. */
  60510. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60511. direction: Vector2;
  60512. /**
  60513. * Creates a new instance CircleOfConfusionPostProcess
  60514. * @param name The name of the effect.
  60515. * @param scene The scene the effect belongs to.
  60516. * @param direction The direction the blur should be applied.
  60517. * @param kernel The size of the kernel used to blur.
  60518. * @param options The required width/height ratio to downsize to before computing the render pass.
  60519. * @param camera The camera to apply the render pass to.
  60520. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60521. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60523. * @param engine The engine which the post process will be applied. (default: current engine)
  60524. * @param reusable If the post process can be reused on the same frame. (default: false)
  60525. * @param textureType Type of textures used when performing the post process. (default: 0)
  60526. * @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)
  60527. */
  60528. 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);
  60529. }
  60530. }
  60531. declare module BABYLON {
  60532. /** @hidden */
  60533. export var depthOfFieldMergePixelShader: {
  60534. name: string;
  60535. shader: string;
  60536. };
  60537. }
  60538. declare module BABYLON {
  60539. /**
  60540. * Options to be set when merging outputs from the default pipeline.
  60541. */
  60542. export class DepthOfFieldMergePostProcessOptions {
  60543. /**
  60544. * The original image to merge on top of
  60545. */
  60546. originalFromInput: PostProcess;
  60547. /**
  60548. * Parameters to perform the merge of the depth of field effect
  60549. */
  60550. depthOfField?: {
  60551. circleOfConfusion: PostProcess;
  60552. blurSteps: Array<PostProcess>;
  60553. };
  60554. /**
  60555. * Parameters to perform the merge of bloom effect
  60556. */
  60557. bloom?: {
  60558. blurred: PostProcess;
  60559. weight: number;
  60560. };
  60561. }
  60562. /**
  60563. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60564. */
  60565. export class DepthOfFieldMergePostProcess extends PostProcess {
  60566. private blurSteps;
  60567. /**
  60568. * Creates a new instance of DepthOfFieldMergePostProcess
  60569. * @param name The name of the effect.
  60570. * @param originalFromInput Post process which's input will be used for the merge.
  60571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60573. * @param options The required width/height ratio to downsize to before computing the render pass.
  60574. * @param camera The camera to apply the render pass to.
  60575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60576. * @param engine The engine which the post process will be applied. (default: current engine)
  60577. * @param reusable If the post process can be reused on the same frame. (default: false)
  60578. * @param textureType Type of textures used when performing the post process. (default: 0)
  60579. * @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)
  60580. */
  60581. 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);
  60582. /**
  60583. * Updates the effect with the current post process compile time values and recompiles the shader.
  60584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60587. * @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
  60588. * @param onCompiled Called when the shader has been compiled.
  60589. * @param onError Called if there is an error when compiling a shader.
  60590. */
  60591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60592. }
  60593. }
  60594. declare module BABYLON {
  60595. /**
  60596. * Specifies the level of max blur that should be applied when using the depth of field effect
  60597. */
  60598. export enum DepthOfFieldEffectBlurLevel {
  60599. /**
  60600. * Subtle blur
  60601. */
  60602. Low = 0,
  60603. /**
  60604. * Medium blur
  60605. */
  60606. Medium = 1,
  60607. /**
  60608. * Large blur
  60609. */
  60610. High = 2
  60611. }
  60612. /**
  60613. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60614. */
  60615. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60616. private _circleOfConfusion;
  60617. /**
  60618. * @hidden Internal, blurs from high to low
  60619. */
  60620. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60621. private _depthOfFieldBlurY;
  60622. private _dofMerge;
  60623. /**
  60624. * @hidden Internal post processes in depth of field effect
  60625. */
  60626. _effects: Array<PostProcess>;
  60627. /**
  60628. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60629. */
  60630. focalLength: number;
  60631. /**
  60632. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60633. */
  60634. fStop: number;
  60635. /**
  60636. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60637. */
  60638. focusDistance: number;
  60639. /**
  60640. * 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.
  60641. */
  60642. lensSize: number;
  60643. /**
  60644. * Creates a new instance DepthOfFieldEffect
  60645. * @param scene The scene the effect belongs to.
  60646. * @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.
  60647. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60648. * @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)
  60649. */
  60650. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60651. /**
  60652. * Get the current class name of the current effet
  60653. * @returns "DepthOfFieldEffect"
  60654. */
  60655. getClassName(): string;
  60656. /**
  60657. * 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.
  60658. */
  60659. depthTexture: RenderTargetTexture;
  60660. /**
  60661. * Disposes each of the internal effects for a given camera.
  60662. * @param camera The camera to dispose the effect on.
  60663. */
  60664. disposeEffects(camera: Camera): void;
  60665. /**
  60666. * @hidden Internal
  60667. */
  60668. _updateEffects(): void;
  60669. /**
  60670. * Internal
  60671. * @returns if all the contained post processes are ready.
  60672. * @hidden
  60673. */
  60674. _isReady(): boolean;
  60675. }
  60676. }
  60677. declare module BABYLON {
  60678. /** @hidden */
  60679. export var displayPassPixelShader: {
  60680. name: string;
  60681. shader: string;
  60682. };
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * DisplayPassPostProcess which produces an output the same as it's input
  60687. */
  60688. export class DisplayPassPostProcess extends PostProcess {
  60689. /**
  60690. * Creates the DisplayPassPostProcess
  60691. * @param name The name of the effect.
  60692. * @param options The required width/height ratio to downsize to before computing the render pass.
  60693. * @param camera The camera to apply the render pass to.
  60694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60695. * @param engine The engine which the post process will be applied. (default: current engine)
  60696. * @param reusable If the post process can be reused on the same frame. (default: false)
  60697. */
  60698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60699. }
  60700. }
  60701. declare module BABYLON {
  60702. /** @hidden */
  60703. export var filterPixelShader: {
  60704. name: string;
  60705. shader: string;
  60706. };
  60707. }
  60708. declare module BABYLON {
  60709. /**
  60710. * Applies a kernel filter to the image
  60711. */
  60712. export class FilterPostProcess extends PostProcess {
  60713. /** The matrix to be applied to the image */
  60714. kernelMatrix: Matrix;
  60715. /**
  60716. *
  60717. * @param name The name of the effect.
  60718. * @param kernelMatrix The matrix to be applied to the image
  60719. * @param options The required width/height ratio to downsize to before computing the render pass.
  60720. * @param camera The camera to apply the render pass to.
  60721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60722. * @param engine The engine which the post process will be applied. (default: current engine)
  60723. * @param reusable If the post process can be reused on the same frame. (default: false)
  60724. */
  60725. constructor(name: string,
  60726. /** The matrix to be applied to the image */
  60727. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60728. }
  60729. }
  60730. declare module BABYLON {
  60731. /** @hidden */
  60732. export var fxaaPixelShader: {
  60733. name: string;
  60734. shader: string;
  60735. };
  60736. }
  60737. declare module BABYLON {
  60738. /** @hidden */
  60739. export var fxaaVertexShader: {
  60740. name: string;
  60741. shader: string;
  60742. };
  60743. }
  60744. declare module BABYLON {
  60745. /**
  60746. * Fxaa post process
  60747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60748. */
  60749. export class FxaaPostProcess extends PostProcess {
  60750. /** @hidden */
  60751. texelWidth: number;
  60752. /** @hidden */
  60753. texelHeight: number;
  60754. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60755. private _getDefines;
  60756. }
  60757. }
  60758. declare module BABYLON {
  60759. /** @hidden */
  60760. export var grainPixelShader: {
  60761. name: string;
  60762. shader: string;
  60763. };
  60764. }
  60765. declare module BABYLON {
  60766. /**
  60767. * The GrainPostProcess adds noise to the image at mid luminance levels
  60768. */
  60769. export class GrainPostProcess extends PostProcess {
  60770. /**
  60771. * The intensity of the grain added (default: 30)
  60772. */
  60773. intensity: number;
  60774. /**
  60775. * If the grain should be randomized on every frame
  60776. */
  60777. animated: boolean;
  60778. /**
  60779. * Creates a new instance of @see GrainPostProcess
  60780. * @param name The name of the effect.
  60781. * @param options The required width/height ratio to downsize to before computing the render pass.
  60782. * @param camera The camera to apply the render pass to.
  60783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60784. * @param engine The engine which the post process will be applied. (default: current engine)
  60785. * @param reusable If the post process can be reused on the same frame. (default: false)
  60786. * @param textureType Type of textures used when performing the post process. (default: 0)
  60787. * @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)
  60788. */
  60789. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60790. }
  60791. }
  60792. declare module BABYLON {
  60793. /** @hidden */
  60794. export var highlightsPixelShader: {
  60795. name: string;
  60796. shader: string;
  60797. };
  60798. }
  60799. declare module BABYLON {
  60800. /**
  60801. * Extracts highlights from the image
  60802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60803. */
  60804. export class HighlightsPostProcess extends PostProcess {
  60805. /**
  60806. * Extracts highlights from the image
  60807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60808. * @param name The name of the effect.
  60809. * @param options The required width/height ratio to downsize to before computing the render pass.
  60810. * @param camera The camera to apply the render pass to.
  60811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60812. * @param engine The engine which the post process will be applied. (default: current engine)
  60813. * @param reusable If the post process can be reused on the same frame. (default: false)
  60814. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60815. */
  60816. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60817. }
  60818. }
  60819. declare module BABYLON {
  60820. /** @hidden */
  60821. export var mrtFragmentDeclaration: {
  60822. name: string;
  60823. shader: string;
  60824. };
  60825. }
  60826. declare module BABYLON {
  60827. /** @hidden */
  60828. export var geometryPixelShader: {
  60829. name: string;
  60830. shader: string;
  60831. };
  60832. }
  60833. declare module BABYLON {
  60834. /** @hidden */
  60835. export var geometryVertexShader: {
  60836. name: string;
  60837. shader: string;
  60838. };
  60839. }
  60840. declare module BABYLON {
  60841. /** @hidden */
  60842. interface ISavedTransformationMatrix {
  60843. world: Matrix;
  60844. viewProjection: Matrix;
  60845. }
  60846. /**
  60847. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60848. */
  60849. export class GeometryBufferRenderer {
  60850. /**
  60851. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60852. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60853. */
  60854. static readonly POSITION_TEXTURE_TYPE: number;
  60855. /**
  60856. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60857. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60858. */
  60859. static readonly VELOCITY_TEXTURE_TYPE: number;
  60860. /**
  60861. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60862. * in order to compute objects velocities when enableVelocity is set to "true"
  60863. * @hidden
  60864. */
  60865. _previousTransformationMatrices: {
  60866. [index: number]: ISavedTransformationMatrix;
  60867. };
  60868. /**
  60869. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60870. * in order to compute objects velocities when enableVelocity is set to "true"
  60871. * @hidden
  60872. */
  60873. _previousBonesTransformationMatrices: {
  60874. [index: number]: Float32Array;
  60875. };
  60876. /**
  60877. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60878. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60879. */
  60880. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60881. private _scene;
  60882. private _multiRenderTarget;
  60883. private _ratio;
  60884. private _enablePosition;
  60885. private _enableVelocity;
  60886. private _positionIndex;
  60887. private _velocityIndex;
  60888. protected _effect: Effect;
  60889. protected _cachedDefines: string;
  60890. /**
  60891. * Set the render list (meshes to be rendered) used in the G buffer.
  60892. */
  60893. renderList: Mesh[];
  60894. /**
  60895. * Gets wether or not G buffer are supported by the running hardware.
  60896. * This requires draw buffer supports
  60897. */
  60898. readonly isSupported: boolean;
  60899. /**
  60900. * Returns the index of the given texture type in the G-Buffer textures array
  60901. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60902. * @returns the index of the given texture type in the G-Buffer textures array
  60903. */
  60904. getTextureIndex(textureType: number): number;
  60905. /**
  60906. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60907. */
  60908. /**
  60909. * Sets whether or not objects positions are enabled for the G buffer.
  60910. */
  60911. enablePosition: boolean;
  60912. /**
  60913. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60914. */
  60915. /**
  60916. * Sets wether or not objects velocities are enabled for the G buffer.
  60917. */
  60918. enableVelocity: boolean;
  60919. /**
  60920. * Gets the scene associated with the buffer.
  60921. */
  60922. readonly scene: Scene;
  60923. /**
  60924. * Gets the ratio used by the buffer during its creation.
  60925. * How big is the buffer related to the main canvas.
  60926. */
  60927. readonly ratio: number;
  60928. /** @hidden */
  60929. static _SceneComponentInitialization: (scene: Scene) => void;
  60930. /**
  60931. * Creates a new G Buffer for the scene
  60932. * @param scene The scene the buffer belongs to
  60933. * @param ratio How big is the buffer related to the main canvas.
  60934. */
  60935. constructor(scene: Scene, ratio?: number);
  60936. /**
  60937. * Checks wether everything is ready to render a submesh to the G buffer.
  60938. * @param subMesh the submesh to check readiness for
  60939. * @param useInstances is the mesh drawn using instance or not
  60940. * @returns true if ready otherwise false
  60941. */
  60942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60943. /**
  60944. * Gets the current underlying G Buffer.
  60945. * @returns the buffer
  60946. */
  60947. getGBuffer(): MultiRenderTarget;
  60948. /**
  60949. * Gets the number of samples used to render the buffer (anti aliasing).
  60950. */
  60951. /**
  60952. * Sets the number of samples used to render the buffer (anti aliasing).
  60953. */
  60954. samples: number;
  60955. /**
  60956. * Disposes the renderer and frees up associated resources.
  60957. */
  60958. dispose(): void;
  60959. protected _createRenderTargets(): void;
  60960. private _copyBonesTransformationMatrices;
  60961. }
  60962. }
  60963. declare module BABYLON {
  60964. interface Scene {
  60965. /** @hidden (Backing field) */
  60966. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60967. /**
  60968. * Gets or Sets the current geometry buffer associated to the scene.
  60969. */
  60970. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60971. /**
  60972. * Enables a GeometryBufferRender and associates it with the scene
  60973. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60974. * @returns the GeometryBufferRenderer
  60975. */
  60976. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60977. /**
  60978. * Disables the GeometryBufferRender associated with the scene
  60979. */
  60980. disableGeometryBufferRenderer(): void;
  60981. }
  60982. /**
  60983. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60984. * in several rendering techniques.
  60985. */
  60986. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60987. /**
  60988. * The component name helpful to identify the component in the list of scene components.
  60989. */
  60990. readonly name: string;
  60991. /**
  60992. * The scene the component belongs to.
  60993. */
  60994. scene: Scene;
  60995. /**
  60996. * Creates a new instance of the component for the given scene
  60997. * @param scene Defines the scene to register the component in
  60998. */
  60999. constructor(scene: Scene);
  61000. /**
  61001. * Registers the component in a given scene
  61002. */
  61003. register(): void;
  61004. /**
  61005. * Rebuilds the elements related to this component in case of
  61006. * context lost for instance.
  61007. */
  61008. rebuild(): void;
  61009. /**
  61010. * Disposes the component and the associated ressources
  61011. */
  61012. dispose(): void;
  61013. private _gatherRenderTargets;
  61014. }
  61015. }
  61016. declare module BABYLON {
  61017. /** @hidden */
  61018. export var motionBlurPixelShader: {
  61019. name: string;
  61020. shader: string;
  61021. };
  61022. }
  61023. declare module BABYLON {
  61024. /**
  61025. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61026. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61027. * As an example, all you have to do is to create the post-process:
  61028. * var mb = new BABYLON.MotionBlurPostProcess(
  61029. * 'mb', // The name of the effect.
  61030. * scene, // The scene containing the objects to blur according to their velocity.
  61031. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61032. * camera // The camera to apply the render pass to.
  61033. * );
  61034. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61035. */
  61036. export class MotionBlurPostProcess extends PostProcess {
  61037. /**
  61038. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61039. */
  61040. motionStrength: number;
  61041. /**
  61042. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61043. */
  61044. /**
  61045. * Sets the number of iterations to be used for motion blur quality
  61046. */
  61047. motionBlurSamples: number;
  61048. private _motionBlurSamples;
  61049. private _geometryBufferRenderer;
  61050. /**
  61051. * Creates a new instance MotionBlurPostProcess
  61052. * @param name The name of the effect.
  61053. * @param scene The scene containing the objects to blur according to their velocity.
  61054. * @param options The required width/height ratio to downsize to before computing the render pass.
  61055. * @param camera The camera to apply the render pass to.
  61056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61057. * @param engine The engine which the post process will be applied. (default: current engine)
  61058. * @param reusable If the post process can be reused on the same frame. (default: false)
  61059. * @param textureType Type of textures used when performing the post process. (default: 0)
  61060. * @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)
  61061. */
  61062. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61063. /**
  61064. * Excludes the given skinned mesh from computing bones velocities.
  61065. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  61066. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61067. */
  61068. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61069. /**
  61070. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61071. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61072. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61073. */
  61074. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61075. /**
  61076. * Disposes the post process.
  61077. * @param camera The camera to dispose the post process on.
  61078. */
  61079. dispose(camera?: Camera): void;
  61080. }
  61081. }
  61082. declare module BABYLON {
  61083. /** @hidden */
  61084. export var refractionPixelShader: {
  61085. name: string;
  61086. shader: string;
  61087. };
  61088. }
  61089. declare module BABYLON {
  61090. /**
  61091. * Post process which applies a refractin texture
  61092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61093. */
  61094. export class RefractionPostProcess extends PostProcess {
  61095. /** the base color of the refraction (used to taint the rendering) */
  61096. color: Color3;
  61097. /** simulated refraction depth */
  61098. depth: number;
  61099. /** the coefficient of the base color (0 to remove base color tainting) */
  61100. colorLevel: number;
  61101. private _refTexture;
  61102. private _ownRefractionTexture;
  61103. /**
  61104. * Gets or sets the refraction texture
  61105. * Please note that you are responsible for disposing the texture if you set it manually
  61106. */
  61107. refractionTexture: Texture;
  61108. /**
  61109. * Initializes the RefractionPostProcess
  61110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61111. * @param name The name of the effect.
  61112. * @param refractionTextureUrl Url of the refraction texture to use
  61113. * @param color the base color of the refraction (used to taint the rendering)
  61114. * @param depth simulated refraction depth
  61115. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61116. * @param camera The camera to apply the render pass to.
  61117. * @param options The required width/height ratio to downsize to before computing the render pass.
  61118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61119. * @param engine The engine which the post process will be applied. (default: current engine)
  61120. * @param reusable If the post process can be reused on the same frame. (default: false)
  61121. */
  61122. constructor(name: string, refractionTextureUrl: string,
  61123. /** the base color of the refraction (used to taint the rendering) */
  61124. color: Color3,
  61125. /** simulated refraction depth */
  61126. depth: number,
  61127. /** the coefficient of the base color (0 to remove base color tainting) */
  61128. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61129. /**
  61130. * Disposes of the post process
  61131. * @param camera Camera to dispose post process on
  61132. */
  61133. dispose(camera: Camera): void;
  61134. }
  61135. }
  61136. declare module BABYLON {
  61137. /** @hidden */
  61138. export var sharpenPixelShader: {
  61139. name: string;
  61140. shader: string;
  61141. };
  61142. }
  61143. declare module BABYLON {
  61144. /**
  61145. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61146. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61147. */
  61148. export class SharpenPostProcess extends PostProcess {
  61149. /**
  61150. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61151. */
  61152. colorAmount: number;
  61153. /**
  61154. * How much sharpness should be applied (default: 0.3)
  61155. */
  61156. edgeAmount: number;
  61157. /**
  61158. * Creates a new instance ConvolutionPostProcess
  61159. * @param name The name of the effect.
  61160. * @param options The required width/height ratio to downsize to before computing the render pass.
  61161. * @param camera The camera to apply the render pass to.
  61162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61163. * @param engine The engine which the post process will be applied. (default: current engine)
  61164. * @param reusable If the post process can be reused on the same frame. (default: false)
  61165. * @param textureType Type of textures used when performing the post process. (default: 0)
  61166. * @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)
  61167. */
  61168. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61169. }
  61170. }
  61171. declare module BABYLON {
  61172. /**
  61173. * PostProcessRenderPipeline
  61174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61175. */
  61176. export class PostProcessRenderPipeline {
  61177. private engine;
  61178. private _renderEffects;
  61179. private _renderEffectsForIsolatedPass;
  61180. /**
  61181. * List of inspectable custom properties (used by the Inspector)
  61182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61183. */
  61184. inspectableCustomProperties: IInspectable[];
  61185. /**
  61186. * @hidden
  61187. */
  61188. protected _cameras: Camera[];
  61189. /** @hidden */
  61190. _name: string;
  61191. /**
  61192. * Gets pipeline name
  61193. */
  61194. readonly name: string;
  61195. /** Gets the list of attached cameras */
  61196. readonly cameras: Camera[];
  61197. /**
  61198. * Initializes a PostProcessRenderPipeline
  61199. * @param engine engine to add the pipeline to
  61200. * @param name name of the pipeline
  61201. */
  61202. constructor(engine: Engine, name: string);
  61203. /**
  61204. * Gets the class name
  61205. * @returns "PostProcessRenderPipeline"
  61206. */
  61207. getClassName(): string;
  61208. /**
  61209. * If all the render effects in the pipeline are supported
  61210. */
  61211. readonly isSupported: boolean;
  61212. /**
  61213. * Adds an effect to the pipeline
  61214. * @param renderEffect the effect to add
  61215. */
  61216. addEffect(renderEffect: PostProcessRenderEffect): void;
  61217. /** @hidden */
  61218. _rebuild(): void;
  61219. /** @hidden */
  61220. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61221. /** @hidden */
  61222. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61223. /** @hidden */
  61224. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61225. /** @hidden */
  61226. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61227. /** @hidden */
  61228. _attachCameras(cameras: Camera, unique: boolean): void;
  61229. /** @hidden */
  61230. _attachCameras(cameras: Camera[], unique: boolean): void;
  61231. /** @hidden */
  61232. _detachCameras(cameras: Camera): void;
  61233. /** @hidden */
  61234. _detachCameras(cameras: Nullable<Camera[]>): void;
  61235. /** @hidden */
  61236. _update(): void;
  61237. /** @hidden */
  61238. _reset(): void;
  61239. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61240. /**
  61241. * Disposes of the pipeline
  61242. */
  61243. dispose(): void;
  61244. }
  61245. }
  61246. declare module BABYLON {
  61247. /**
  61248. * PostProcessRenderPipelineManager class
  61249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61250. */
  61251. export class PostProcessRenderPipelineManager {
  61252. private _renderPipelines;
  61253. /**
  61254. * Initializes a PostProcessRenderPipelineManager
  61255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61256. */
  61257. constructor();
  61258. /**
  61259. * Gets the list of supported render pipelines
  61260. */
  61261. readonly supportedPipelines: PostProcessRenderPipeline[];
  61262. /**
  61263. * Adds a pipeline to the manager
  61264. * @param renderPipeline The pipeline to add
  61265. */
  61266. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61267. /**
  61268. * Attaches a camera to the pipeline
  61269. * @param renderPipelineName The name of the pipeline to attach to
  61270. * @param cameras the camera to attach
  61271. * @param unique if the camera can be attached multiple times to the pipeline
  61272. */
  61273. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61274. /**
  61275. * Detaches a camera from the pipeline
  61276. * @param renderPipelineName The name of the pipeline to detach from
  61277. * @param cameras the camera to detach
  61278. */
  61279. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61280. /**
  61281. * Enables an effect by name on a pipeline
  61282. * @param renderPipelineName the name of the pipeline to enable the effect in
  61283. * @param renderEffectName the name of the effect to enable
  61284. * @param cameras the cameras that the effect should be enabled on
  61285. */
  61286. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61287. /**
  61288. * Disables an effect by name on a pipeline
  61289. * @param renderPipelineName the name of the pipeline to disable the effect in
  61290. * @param renderEffectName the name of the effect to disable
  61291. * @param cameras the cameras that the effect should be disabled on
  61292. */
  61293. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61294. /**
  61295. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61296. */
  61297. update(): void;
  61298. /** @hidden */
  61299. _rebuild(): void;
  61300. /**
  61301. * Disposes of the manager and pipelines
  61302. */
  61303. dispose(): void;
  61304. }
  61305. }
  61306. declare module BABYLON {
  61307. interface Scene {
  61308. /** @hidden (Backing field) */
  61309. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61310. /**
  61311. * Gets the postprocess render pipeline manager
  61312. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61313. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61314. */
  61315. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61316. }
  61317. /**
  61318. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61319. */
  61320. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61321. /**
  61322. * The component name helpfull to identify the component in the list of scene components.
  61323. */
  61324. readonly name: string;
  61325. /**
  61326. * The scene the component belongs to.
  61327. */
  61328. scene: Scene;
  61329. /**
  61330. * Creates a new instance of the component for the given scene
  61331. * @param scene Defines the scene to register the component in
  61332. */
  61333. constructor(scene: Scene);
  61334. /**
  61335. * Registers the component in a given scene
  61336. */
  61337. register(): void;
  61338. /**
  61339. * Rebuilds the elements related to this component in case of
  61340. * context lost for instance.
  61341. */
  61342. rebuild(): void;
  61343. /**
  61344. * Disposes the component and the associated ressources
  61345. */
  61346. dispose(): void;
  61347. private _gatherRenderTargets;
  61348. }
  61349. }
  61350. declare module BABYLON {
  61351. /**
  61352. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61353. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61354. */
  61355. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61356. private _scene;
  61357. private _camerasToBeAttached;
  61358. /**
  61359. * ID of the sharpen post process,
  61360. */
  61361. private readonly SharpenPostProcessId;
  61362. /**
  61363. * @ignore
  61364. * ID of the image processing post process;
  61365. */
  61366. readonly ImageProcessingPostProcessId: string;
  61367. /**
  61368. * @ignore
  61369. * ID of the Fast Approximate Anti-Aliasing post process;
  61370. */
  61371. readonly FxaaPostProcessId: string;
  61372. /**
  61373. * ID of the chromatic aberration post process,
  61374. */
  61375. private readonly ChromaticAberrationPostProcessId;
  61376. /**
  61377. * ID of the grain post process
  61378. */
  61379. private readonly GrainPostProcessId;
  61380. /**
  61381. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61382. */
  61383. sharpen: SharpenPostProcess;
  61384. private _sharpenEffect;
  61385. private bloom;
  61386. /**
  61387. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61388. */
  61389. depthOfField: DepthOfFieldEffect;
  61390. /**
  61391. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61392. */
  61393. fxaa: FxaaPostProcess;
  61394. /**
  61395. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61396. */
  61397. imageProcessing: ImageProcessingPostProcess;
  61398. /**
  61399. * Chromatic aberration post process which will shift rgb colors in the image
  61400. */
  61401. chromaticAberration: ChromaticAberrationPostProcess;
  61402. private _chromaticAberrationEffect;
  61403. /**
  61404. * Grain post process which add noise to the image
  61405. */
  61406. grain: GrainPostProcess;
  61407. private _grainEffect;
  61408. /**
  61409. * Glow post process which adds a glow to emissive areas of the image
  61410. */
  61411. private _glowLayer;
  61412. /**
  61413. * Animations which can be used to tweak settings over a period of time
  61414. */
  61415. animations: Animation[];
  61416. private _imageProcessingConfigurationObserver;
  61417. private _sharpenEnabled;
  61418. private _bloomEnabled;
  61419. private _depthOfFieldEnabled;
  61420. private _depthOfFieldBlurLevel;
  61421. private _fxaaEnabled;
  61422. private _imageProcessingEnabled;
  61423. private _defaultPipelineTextureType;
  61424. private _bloomScale;
  61425. private _chromaticAberrationEnabled;
  61426. private _grainEnabled;
  61427. private _buildAllowed;
  61428. /**
  61429. * Gets active scene
  61430. */
  61431. readonly scene: Scene;
  61432. /**
  61433. * Enable or disable the sharpen process from the pipeline
  61434. */
  61435. sharpenEnabled: boolean;
  61436. private _resizeObserver;
  61437. private _hardwareScaleLevel;
  61438. private _bloomKernel;
  61439. /**
  61440. * Specifies the size of the bloom blur kernel, relative to the final output size
  61441. */
  61442. bloomKernel: number;
  61443. /**
  61444. * Specifies the weight of the bloom in the final rendering
  61445. */
  61446. private _bloomWeight;
  61447. /**
  61448. * Specifies the luma threshold for the area that will be blurred by the bloom
  61449. */
  61450. private _bloomThreshold;
  61451. private _hdr;
  61452. /**
  61453. * The strength of the bloom.
  61454. */
  61455. bloomWeight: number;
  61456. /**
  61457. * The strength of the bloom.
  61458. */
  61459. bloomThreshold: number;
  61460. /**
  61461. * The scale of the bloom, lower value will provide better performance.
  61462. */
  61463. bloomScale: number;
  61464. /**
  61465. * Enable or disable the bloom from the pipeline
  61466. */
  61467. bloomEnabled: boolean;
  61468. private _rebuildBloom;
  61469. /**
  61470. * If the depth of field is enabled.
  61471. */
  61472. depthOfFieldEnabled: boolean;
  61473. /**
  61474. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61475. */
  61476. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61477. /**
  61478. * If the anti aliasing is enabled.
  61479. */
  61480. fxaaEnabled: boolean;
  61481. private _samples;
  61482. /**
  61483. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61484. */
  61485. samples: number;
  61486. /**
  61487. * If image processing is enabled.
  61488. */
  61489. imageProcessingEnabled: boolean;
  61490. /**
  61491. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61492. */
  61493. glowLayerEnabled: boolean;
  61494. /**
  61495. * Gets the glow layer (or null if not defined)
  61496. */
  61497. readonly glowLayer: Nullable<GlowLayer>;
  61498. /**
  61499. * Enable or disable the chromaticAberration process from the pipeline
  61500. */
  61501. chromaticAberrationEnabled: boolean;
  61502. /**
  61503. * Enable or disable the grain process from the pipeline
  61504. */
  61505. grainEnabled: boolean;
  61506. /**
  61507. * @constructor
  61508. * @param name - The rendering pipeline name (default: "")
  61509. * @param hdr - If high dynamic range textures should be used (default: true)
  61510. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61511. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61512. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61513. */
  61514. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61515. /**
  61516. * Get the class name
  61517. * @returns "DefaultRenderingPipeline"
  61518. */
  61519. getClassName(): string;
  61520. /**
  61521. * Force the compilation of the entire pipeline.
  61522. */
  61523. prepare(): void;
  61524. private _hasCleared;
  61525. private _prevPostProcess;
  61526. private _prevPrevPostProcess;
  61527. private _setAutoClearAndTextureSharing;
  61528. private _depthOfFieldSceneObserver;
  61529. private _buildPipeline;
  61530. private _disposePostProcesses;
  61531. /**
  61532. * Adds a camera to the pipeline
  61533. * @param camera the camera to be added
  61534. */
  61535. addCamera(camera: Camera): void;
  61536. /**
  61537. * Removes a camera from the pipeline
  61538. * @param camera the camera to remove
  61539. */
  61540. removeCamera(camera: Camera): void;
  61541. /**
  61542. * Dispose of the pipeline and stop all post processes
  61543. */
  61544. dispose(): void;
  61545. /**
  61546. * Serialize the rendering pipeline (Used when exporting)
  61547. * @returns the serialized object
  61548. */
  61549. serialize(): any;
  61550. /**
  61551. * Parse the serialized pipeline
  61552. * @param source Source pipeline.
  61553. * @param scene The scene to load the pipeline to.
  61554. * @param rootUrl The URL of the serialized pipeline.
  61555. * @returns An instantiated pipeline from the serialized object.
  61556. */
  61557. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61558. }
  61559. }
  61560. declare module BABYLON {
  61561. /** @hidden */
  61562. export var lensHighlightsPixelShader: {
  61563. name: string;
  61564. shader: string;
  61565. };
  61566. }
  61567. declare module BABYLON {
  61568. /** @hidden */
  61569. export var depthOfFieldPixelShader: {
  61570. name: string;
  61571. shader: string;
  61572. };
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * BABYLON.JS Chromatic Aberration GLSL Shader
  61577. * Author: Olivier Guyot
  61578. * Separates very slightly R, G and B colors on the edges of the screen
  61579. * Inspired by Francois Tarlier & Martins Upitis
  61580. */
  61581. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61582. /**
  61583. * @ignore
  61584. * The chromatic aberration PostProcess id in the pipeline
  61585. */
  61586. LensChromaticAberrationEffect: string;
  61587. /**
  61588. * @ignore
  61589. * The highlights enhancing PostProcess id in the pipeline
  61590. */
  61591. HighlightsEnhancingEffect: string;
  61592. /**
  61593. * @ignore
  61594. * The depth-of-field PostProcess id in the pipeline
  61595. */
  61596. LensDepthOfFieldEffect: string;
  61597. private _scene;
  61598. private _depthTexture;
  61599. private _grainTexture;
  61600. private _chromaticAberrationPostProcess;
  61601. private _highlightsPostProcess;
  61602. private _depthOfFieldPostProcess;
  61603. private _edgeBlur;
  61604. private _grainAmount;
  61605. private _chromaticAberration;
  61606. private _distortion;
  61607. private _highlightsGain;
  61608. private _highlightsThreshold;
  61609. private _dofDistance;
  61610. private _dofAperture;
  61611. private _dofDarken;
  61612. private _dofPentagon;
  61613. private _blurNoise;
  61614. /**
  61615. * @constructor
  61616. *
  61617. * Effect parameters are as follow:
  61618. * {
  61619. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61620. * edge_blur: number; // from 0 to x (1 for realism)
  61621. * distortion: number; // from 0 to x (1 for realism)
  61622. * grain_amount: number; // from 0 to 1
  61623. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61624. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61625. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61626. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61627. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61628. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61629. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61630. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61631. * }
  61632. * Note: if an effect parameter is unset, effect is disabled
  61633. *
  61634. * @param name The rendering pipeline name
  61635. * @param parameters - An object containing all parameters (see above)
  61636. * @param scene The scene linked to this pipeline
  61637. * @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)
  61638. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61639. */
  61640. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61641. /**
  61642. * Get the class name
  61643. * @returns "LensRenderingPipeline"
  61644. */
  61645. getClassName(): string;
  61646. /**
  61647. * Gets associated scene
  61648. */
  61649. readonly scene: Scene;
  61650. /**
  61651. * Gets or sets the edge blur
  61652. */
  61653. edgeBlur: number;
  61654. /**
  61655. * Gets or sets the grain amount
  61656. */
  61657. grainAmount: number;
  61658. /**
  61659. * Gets or sets the chromatic aberration amount
  61660. */
  61661. chromaticAberration: number;
  61662. /**
  61663. * Gets or sets the depth of field aperture
  61664. */
  61665. dofAperture: number;
  61666. /**
  61667. * Gets or sets the edge distortion
  61668. */
  61669. edgeDistortion: number;
  61670. /**
  61671. * Gets or sets the depth of field distortion
  61672. */
  61673. dofDistortion: number;
  61674. /**
  61675. * Gets or sets the darken out of focus amount
  61676. */
  61677. darkenOutOfFocus: number;
  61678. /**
  61679. * Gets or sets a boolean indicating if blur noise is enabled
  61680. */
  61681. blurNoise: boolean;
  61682. /**
  61683. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61684. */
  61685. pentagonBokeh: boolean;
  61686. /**
  61687. * Gets or sets the highlight grain amount
  61688. */
  61689. highlightsGain: number;
  61690. /**
  61691. * Gets or sets the highlight threshold
  61692. */
  61693. highlightsThreshold: number;
  61694. /**
  61695. * Sets the amount of blur at the edges
  61696. * @param amount blur amount
  61697. */
  61698. setEdgeBlur(amount: number): void;
  61699. /**
  61700. * Sets edge blur to 0
  61701. */
  61702. disableEdgeBlur(): void;
  61703. /**
  61704. * Sets the amout of grain
  61705. * @param amount Amount of grain
  61706. */
  61707. setGrainAmount(amount: number): void;
  61708. /**
  61709. * Set grain amount to 0
  61710. */
  61711. disableGrain(): void;
  61712. /**
  61713. * Sets the chromatic aberration amount
  61714. * @param amount amount of chromatic aberration
  61715. */
  61716. setChromaticAberration(amount: number): void;
  61717. /**
  61718. * Sets chromatic aberration amount to 0
  61719. */
  61720. disableChromaticAberration(): void;
  61721. /**
  61722. * Sets the EdgeDistortion amount
  61723. * @param amount amount of EdgeDistortion
  61724. */
  61725. setEdgeDistortion(amount: number): void;
  61726. /**
  61727. * Sets edge distortion to 0
  61728. */
  61729. disableEdgeDistortion(): void;
  61730. /**
  61731. * Sets the FocusDistance amount
  61732. * @param amount amount of FocusDistance
  61733. */
  61734. setFocusDistance(amount: number): void;
  61735. /**
  61736. * Disables depth of field
  61737. */
  61738. disableDepthOfField(): void;
  61739. /**
  61740. * Sets the Aperture amount
  61741. * @param amount amount of Aperture
  61742. */
  61743. setAperture(amount: number): void;
  61744. /**
  61745. * Sets the DarkenOutOfFocus amount
  61746. * @param amount amount of DarkenOutOfFocus
  61747. */
  61748. setDarkenOutOfFocus(amount: number): void;
  61749. private _pentagonBokehIsEnabled;
  61750. /**
  61751. * Creates a pentagon bokeh effect
  61752. */
  61753. enablePentagonBokeh(): void;
  61754. /**
  61755. * Disables the pentagon bokeh effect
  61756. */
  61757. disablePentagonBokeh(): void;
  61758. /**
  61759. * Enables noise blur
  61760. */
  61761. enableNoiseBlur(): void;
  61762. /**
  61763. * Disables noise blur
  61764. */
  61765. disableNoiseBlur(): void;
  61766. /**
  61767. * Sets the HighlightsGain amount
  61768. * @param amount amount of HighlightsGain
  61769. */
  61770. setHighlightsGain(amount: number): void;
  61771. /**
  61772. * Sets the HighlightsThreshold amount
  61773. * @param amount amount of HighlightsThreshold
  61774. */
  61775. setHighlightsThreshold(amount: number): void;
  61776. /**
  61777. * Disables highlights
  61778. */
  61779. disableHighlights(): void;
  61780. /**
  61781. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61782. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61783. */
  61784. dispose(disableDepthRender?: boolean): void;
  61785. private _createChromaticAberrationPostProcess;
  61786. private _createHighlightsPostProcess;
  61787. private _createDepthOfFieldPostProcess;
  61788. private _createGrainTexture;
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /** @hidden */
  61793. export var ssao2PixelShader: {
  61794. name: string;
  61795. shader: string;
  61796. };
  61797. }
  61798. declare module BABYLON {
  61799. /** @hidden */
  61800. export var ssaoCombinePixelShader: {
  61801. name: string;
  61802. shader: string;
  61803. };
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Render pipeline to produce ssao effect
  61808. */
  61809. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61810. /**
  61811. * @ignore
  61812. * The PassPostProcess id in the pipeline that contains the original scene color
  61813. */
  61814. SSAOOriginalSceneColorEffect: string;
  61815. /**
  61816. * @ignore
  61817. * The SSAO PostProcess id in the pipeline
  61818. */
  61819. SSAORenderEffect: string;
  61820. /**
  61821. * @ignore
  61822. * The horizontal blur PostProcess id in the pipeline
  61823. */
  61824. SSAOBlurHRenderEffect: string;
  61825. /**
  61826. * @ignore
  61827. * The vertical blur PostProcess id in the pipeline
  61828. */
  61829. SSAOBlurVRenderEffect: string;
  61830. /**
  61831. * @ignore
  61832. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61833. */
  61834. SSAOCombineRenderEffect: string;
  61835. /**
  61836. * The output strength of the SSAO post-process. Default value is 1.0.
  61837. */
  61838. totalStrength: number;
  61839. /**
  61840. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61841. */
  61842. maxZ: number;
  61843. /**
  61844. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61845. */
  61846. minZAspect: number;
  61847. private _samples;
  61848. /**
  61849. * Number of samples used for the SSAO calculations. Default value is 8
  61850. */
  61851. samples: number;
  61852. private _textureSamples;
  61853. /**
  61854. * Number of samples to use for antialiasing
  61855. */
  61856. textureSamples: number;
  61857. /**
  61858. * Ratio object used for SSAO ratio and blur ratio
  61859. */
  61860. private _ratio;
  61861. /**
  61862. * Dynamically generated sphere sampler.
  61863. */
  61864. private _sampleSphere;
  61865. /**
  61866. * Blur filter offsets
  61867. */
  61868. private _samplerOffsets;
  61869. private _expensiveBlur;
  61870. /**
  61871. * If bilateral blur should be used
  61872. */
  61873. expensiveBlur: boolean;
  61874. /**
  61875. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61876. */
  61877. radius: number;
  61878. /**
  61879. * The base color of the SSAO post-process
  61880. * The final result is "base + ssao" between [0, 1]
  61881. */
  61882. base: number;
  61883. /**
  61884. * Support test.
  61885. */
  61886. static readonly IsSupported: boolean;
  61887. private _scene;
  61888. private _depthTexture;
  61889. private _normalTexture;
  61890. private _randomTexture;
  61891. private _originalColorPostProcess;
  61892. private _ssaoPostProcess;
  61893. private _blurHPostProcess;
  61894. private _blurVPostProcess;
  61895. private _ssaoCombinePostProcess;
  61896. /**
  61897. * Gets active scene
  61898. */
  61899. readonly scene: Scene;
  61900. /**
  61901. * @constructor
  61902. * @param name The rendering pipeline name
  61903. * @param scene The scene linked to this pipeline
  61904. * @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 }
  61905. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61906. */
  61907. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61908. /**
  61909. * Get the class name
  61910. * @returns "SSAO2RenderingPipeline"
  61911. */
  61912. getClassName(): string;
  61913. /**
  61914. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61915. */
  61916. dispose(disableGeometryBufferRenderer?: boolean): void;
  61917. private _createBlurPostProcess;
  61918. /** @hidden */
  61919. _rebuild(): void;
  61920. private _bits;
  61921. private _radicalInverse_VdC;
  61922. private _hammersley;
  61923. private _hemisphereSample_uniform;
  61924. private _generateHemisphere;
  61925. private _createSSAOPostProcess;
  61926. private _createSSAOCombinePostProcess;
  61927. private _createRandomTexture;
  61928. /**
  61929. * Serialize the rendering pipeline (Used when exporting)
  61930. * @returns the serialized object
  61931. */
  61932. serialize(): any;
  61933. /**
  61934. * Parse the serialized pipeline
  61935. * @param source Source pipeline.
  61936. * @param scene The scene to load the pipeline to.
  61937. * @param rootUrl The URL of the serialized pipeline.
  61938. * @returns An instantiated pipeline from the serialized object.
  61939. */
  61940. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61941. }
  61942. }
  61943. declare module BABYLON {
  61944. /** @hidden */
  61945. export var ssaoPixelShader: {
  61946. name: string;
  61947. shader: string;
  61948. };
  61949. }
  61950. declare module BABYLON {
  61951. /**
  61952. * Render pipeline to produce ssao effect
  61953. */
  61954. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61955. /**
  61956. * @ignore
  61957. * The PassPostProcess id in the pipeline that contains the original scene color
  61958. */
  61959. SSAOOriginalSceneColorEffect: string;
  61960. /**
  61961. * @ignore
  61962. * The SSAO PostProcess id in the pipeline
  61963. */
  61964. SSAORenderEffect: string;
  61965. /**
  61966. * @ignore
  61967. * The horizontal blur PostProcess id in the pipeline
  61968. */
  61969. SSAOBlurHRenderEffect: string;
  61970. /**
  61971. * @ignore
  61972. * The vertical blur PostProcess id in the pipeline
  61973. */
  61974. SSAOBlurVRenderEffect: string;
  61975. /**
  61976. * @ignore
  61977. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61978. */
  61979. SSAOCombineRenderEffect: string;
  61980. /**
  61981. * The output strength of the SSAO post-process. Default value is 1.0.
  61982. */
  61983. totalStrength: number;
  61984. /**
  61985. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61986. */
  61987. radius: number;
  61988. /**
  61989. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61990. * Must not be equal to fallOff and superior to fallOff.
  61991. * Default value is 0.0075
  61992. */
  61993. area: number;
  61994. /**
  61995. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61996. * Must not be equal to area and inferior to area.
  61997. * Default value is 0.000001
  61998. */
  61999. fallOff: number;
  62000. /**
  62001. * The base color of the SSAO post-process
  62002. * The final result is "base + ssao" between [0, 1]
  62003. */
  62004. base: number;
  62005. private _scene;
  62006. private _depthTexture;
  62007. private _randomTexture;
  62008. private _originalColorPostProcess;
  62009. private _ssaoPostProcess;
  62010. private _blurHPostProcess;
  62011. private _blurVPostProcess;
  62012. private _ssaoCombinePostProcess;
  62013. private _firstUpdate;
  62014. /**
  62015. * Gets active scene
  62016. */
  62017. readonly scene: Scene;
  62018. /**
  62019. * @constructor
  62020. * @param name - The rendering pipeline name
  62021. * @param scene - The scene linked to this pipeline
  62022. * @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 }
  62023. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62024. */
  62025. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62026. /**
  62027. * Get the class name
  62028. * @returns "SSAORenderingPipeline"
  62029. */
  62030. getClassName(): string;
  62031. /**
  62032. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62033. */
  62034. dispose(disableDepthRender?: boolean): void;
  62035. private _createBlurPostProcess;
  62036. /** @hidden */
  62037. _rebuild(): void;
  62038. private _createSSAOPostProcess;
  62039. private _createSSAOCombinePostProcess;
  62040. private _createRandomTexture;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /** @hidden */
  62045. export var standardPixelShader: {
  62046. name: string;
  62047. shader: string;
  62048. };
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * Standard rendering pipeline
  62053. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62054. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62055. */
  62056. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62057. /**
  62058. * Public members
  62059. */
  62060. /**
  62061. * Post-process which contains the original scene color before the pipeline applies all the effects
  62062. */
  62063. originalPostProcess: Nullable<PostProcess>;
  62064. /**
  62065. * Post-process used to down scale an image x4
  62066. */
  62067. downSampleX4PostProcess: Nullable<PostProcess>;
  62068. /**
  62069. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62070. */
  62071. brightPassPostProcess: Nullable<PostProcess>;
  62072. /**
  62073. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62074. */
  62075. blurHPostProcesses: PostProcess[];
  62076. /**
  62077. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62078. */
  62079. blurVPostProcesses: PostProcess[];
  62080. /**
  62081. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62082. */
  62083. textureAdderPostProcess: Nullable<PostProcess>;
  62084. /**
  62085. * Post-process used to create volumetric lighting effect
  62086. */
  62087. volumetricLightPostProcess: Nullable<PostProcess>;
  62088. /**
  62089. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62090. */
  62091. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62092. /**
  62093. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62094. */
  62095. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62096. /**
  62097. * Post-process used to merge the volumetric light effect and the real scene color
  62098. */
  62099. volumetricLightMergePostProces: Nullable<PostProcess>;
  62100. /**
  62101. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62102. */
  62103. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62104. /**
  62105. * Base post-process used to calculate the average luminance of the final image for HDR
  62106. */
  62107. luminancePostProcess: Nullable<PostProcess>;
  62108. /**
  62109. * Post-processes used to create down sample post-processes in order to get
  62110. * the average luminance of the final image for HDR
  62111. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62112. */
  62113. luminanceDownSamplePostProcesses: PostProcess[];
  62114. /**
  62115. * Post-process used to create a HDR effect (light adaptation)
  62116. */
  62117. hdrPostProcess: Nullable<PostProcess>;
  62118. /**
  62119. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62120. */
  62121. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62122. /**
  62123. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62124. */
  62125. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62126. /**
  62127. * Post-process used to merge the final HDR post-process and the real scene color
  62128. */
  62129. hdrFinalPostProcess: Nullable<PostProcess>;
  62130. /**
  62131. * Post-process used to create a lens flare effect
  62132. */
  62133. lensFlarePostProcess: Nullable<PostProcess>;
  62134. /**
  62135. * Post-process that merges the result of the lens flare post-process and the real scene color
  62136. */
  62137. lensFlareComposePostProcess: Nullable<PostProcess>;
  62138. /**
  62139. * Post-process used to create a motion blur effect
  62140. */
  62141. motionBlurPostProcess: Nullable<PostProcess>;
  62142. /**
  62143. * Post-process used to create a depth of field effect
  62144. */
  62145. depthOfFieldPostProcess: Nullable<PostProcess>;
  62146. /**
  62147. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62148. */
  62149. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62150. /**
  62151. * Represents the brightness threshold in order to configure the illuminated surfaces
  62152. */
  62153. brightThreshold: number;
  62154. /**
  62155. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62156. */
  62157. blurWidth: number;
  62158. /**
  62159. * Sets if the blur for highlighted surfaces must be only horizontal
  62160. */
  62161. horizontalBlur: boolean;
  62162. /**
  62163. * Gets the overall exposure used by the pipeline
  62164. */
  62165. /**
  62166. * Sets the overall exposure used by the pipeline
  62167. */
  62168. exposure: number;
  62169. /**
  62170. * Texture used typically to simulate "dirty" on camera lens
  62171. */
  62172. lensTexture: Nullable<Texture>;
  62173. /**
  62174. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62175. */
  62176. volumetricLightCoefficient: number;
  62177. /**
  62178. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62179. */
  62180. volumetricLightPower: number;
  62181. /**
  62182. * Used the set the blur intensity to smooth the volumetric lights
  62183. */
  62184. volumetricLightBlurScale: number;
  62185. /**
  62186. * Light (spot or directional) used to generate the volumetric lights rays
  62187. * The source light must have a shadow generate so the pipeline can get its
  62188. * depth map
  62189. */
  62190. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62191. /**
  62192. * For eye adaptation, represents the minimum luminance the eye can see
  62193. */
  62194. hdrMinimumLuminance: number;
  62195. /**
  62196. * For eye adaptation, represents the decrease luminance speed
  62197. */
  62198. hdrDecreaseRate: number;
  62199. /**
  62200. * For eye adaptation, represents the increase luminance speed
  62201. */
  62202. hdrIncreaseRate: number;
  62203. /**
  62204. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62205. */
  62206. /**
  62207. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62208. */
  62209. hdrAutoExposure: boolean;
  62210. /**
  62211. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62212. */
  62213. lensColorTexture: Nullable<Texture>;
  62214. /**
  62215. * The overall strengh for the lens flare effect
  62216. */
  62217. lensFlareStrength: number;
  62218. /**
  62219. * Dispersion coefficient for lens flare ghosts
  62220. */
  62221. lensFlareGhostDispersal: number;
  62222. /**
  62223. * Main lens flare halo width
  62224. */
  62225. lensFlareHaloWidth: number;
  62226. /**
  62227. * Based on the lens distortion effect, defines how much the lens flare result
  62228. * is distorted
  62229. */
  62230. lensFlareDistortionStrength: number;
  62231. /**
  62232. * Configures the blur intensity used for for lens flare (halo)
  62233. */
  62234. lensFlareBlurWidth: number;
  62235. /**
  62236. * Lens star texture must be used to simulate rays on the flares and is available
  62237. * in the documentation
  62238. */
  62239. lensStarTexture: Nullable<Texture>;
  62240. /**
  62241. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62242. * flare effect by taking account of the dirt texture
  62243. */
  62244. lensFlareDirtTexture: Nullable<Texture>;
  62245. /**
  62246. * Represents the focal length for the depth of field effect
  62247. */
  62248. depthOfFieldDistance: number;
  62249. /**
  62250. * Represents the blur intensity for the blurred part of the depth of field effect
  62251. */
  62252. depthOfFieldBlurWidth: number;
  62253. /**
  62254. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62255. */
  62256. /**
  62257. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62258. */
  62259. motionStrength: number;
  62260. /**
  62261. * Gets wether or not the motion blur post-process is object based or screen based.
  62262. */
  62263. /**
  62264. * Sets wether or not the motion blur post-process should be object based or screen based
  62265. */
  62266. objectBasedMotionBlur: boolean;
  62267. /**
  62268. * List of animations for the pipeline (IAnimatable implementation)
  62269. */
  62270. animations: Animation[];
  62271. /**
  62272. * Private members
  62273. */
  62274. private _scene;
  62275. private _currentDepthOfFieldSource;
  62276. private _basePostProcess;
  62277. private _fixedExposure;
  62278. private _currentExposure;
  62279. private _hdrAutoExposure;
  62280. private _hdrCurrentLuminance;
  62281. private _motionStrength;
  62282. private _isObjectBasedMotionBlur;
  62283. private _floatTextureType;
  62284. private _camerasToBeAttached;
  62285. private _ratio;
  62286. private _bloomEnabled;
  62287. private _depthOfFieldEnabled;
  62288. private _vlsEnabled;
  62289. private _lensFlareEnabled;
  62290. private _hdrEnabled;
  62291. private _motionBlurEnabled;
  62292. private _fxaaEnabled;
  62293. private _motionBlurSamples;
  62294. private _volumetricLightStepsCount;
  62295. private _samples;
  62296. /**
  62297. * @ignore
  62298. * Specifies if the bloom pipeline is enabled
  62299. */
  62300. BloomEnabled: boolean;
  62301. /**
  62302. * @ignore
  62303. * Specifies if the depth of field pipeline is enabed
  62304. */
  62305. DepthOfFieldEnabled: boolean;
  62306. /**
  62307. * @ignore
  62308. * Specifies if the lens flare pipeline is enabed
  62309. */
  62310. LensFlareEnabled: boolean;
  62311. /**
  62312. * @ignore
  62313. * Specifies if the HDR pipeline is enabled
  62314. */
  62315. HDREnabled: boolean;
  62316. /**
  62317. * @ignore
  62318. * Specifies if the volumetric lights scattering effect is enabled
  62319. */
  62320. VLSEnabled: boolean;
  62321. /**
  62322. * @ignore
  62323. * Specifies if the motion blur effect is enabled
  62324. */
  62325. MotionBlurEnabled: boolean;
  62326. /**
  62327. * Specifies if anti-aliasing is enabled
  62328. */
  62329. fxaaEnabled: boolean;
  62330. /**
  62331. * Specifies the number of steps used to calculate the volumetric lights
  62332. * Typically in interval [50, 200]
  62333. */
  62334. volumetricLightStepsCount: number;
  62335. /**
  62336. * Specifies the number of samples used for the motion blur effect
  62337. * Typically in interval [16, 64]
  62338. */
  62339. motionBlurSamples: number;
  62340. /**
  62341. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62342. */
  62343. samples: number;
  62344. /**
  62345. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62346. * @constructor
  62347. * @param name The rendering pipeline name
  62348. * @param scene The scene linked to this pipeline
  62349. * @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)
  62350. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62351. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62352. */
  62353. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62354. private _buildPipeline;
  62355. private _createDownSampleX4PostProcess;
  62356. private _createBrightPassPostProcess;
  62357. private _createBlurPostProcesses;
  62358. private _createTextureAdderPostProcess;
  62359. private _createVolumetricLightPostProcess;
  62360. private _createLuminancePostProcesses;
  62361. private _createHdrPostProcess;
  62362. private _createLensFlarePostProcess;
  62363. private _createDepthOfFieldPostProcess;
  62364. private _createMotionBlurPostProcess;
  62365. private _getDepthTexture;
  62366. private _disposePostProcesses;
  62367. /**
  62368. * Dispose of the pipeline and stop all post processes
  62369. */
  62370. dispose(): void;
  62371. /**
  62372. * Serialize the rendering pipeline (Used when exporting)
  62373. * @returns the serialized object
  62374. */
  62375. serialize(): any;
  62376. /**
  62377. * Parse the serialized pipeline
  62378. * @param source Source pipeline.
  62379. * @param scene The scene to load the pipeline to.
  62380. * @param rootUrl The URL of the serialized pipeline.
  62381. * @returns An instantiated pipeline from the serialized object.
  62382. */
  62383. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62384. /**
  62385. * Luminance steps
  62386. */
  62387. static LuminanceSteps: number;
  62388. }
  62389. }
  62390. declare module BABYLON {
  62391. /** @hidden */
  62392. export var tonemapPixelShader: {
  62393. name: string;
  62394. shader: string;
  62395. };
  62396. }
  62397. declare module BABYLON {
  62398. /** Defines operator used for tonemapping */
  62399. export enum TonemappingOperator {
  62400. /** Hable */
  62401. Hable = 0,
  62402. /** Reinhard */
  62403. Reinhard = 1,
  62404. /** HejiDawson */
  62405. HejiDawson = 2,
  62406. /** Photographic */
  62407. Photographic = 3
  62408. }
  62409. /**
  62410. * Defines a post process to apply tone mapping
  62411. */
  62412. export class TonemapPostProcess extends PostProcess {
  62413. private _operator;
  62414. /** Defines the required exposure adjustement */
  62415. exposureAdjustment: number;
  62416. /**
  62417. * Creates a new TonemapPostProcess
  62418. * @param name defines the name of the postprocess
  62419. * @param _operator defines the operator to use
  62420. * @param exposureAdjustment defines the required exposure adjustement
  62421. * @param camera defines the camera to use (can be null)
  62422. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62423. * @param engine defines the hosting engine (can be ignore if camera is set)
  62424. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62425. */
  62426. constructor(name: string, _operator: TonemappingOperator,
  62427. /** Defines the required exposure adjustement */
  62428. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62429. }
  62430. }
  62431. declare module BABYLON {
  62432. /** @hidden */
  62433. export var depthVertexShader: {
  62434. name: string;
  62435. shader: string;
  62436. };
  62437. }
  62438. declare module BABYLON {
  62439. /** @hidden */
  62440. export var volumetricLightScatteringPixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module BABYLON {
  62446. /** @hidden */
  62447. export var volumetricLightScatteringPassVertexShader: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. declare module BABYLON {
  62453. /** @hidden */
  62454. export var volumetricLightScatteringPassPixelShader: {
  62455. name: string;
  62456. shader: string;
  62457. };
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62462. */
  62463. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62464. private _volumetricLightScatteringPass;
  62465. private _volumetricLightScatteringRTT;
  62466. private _viewPort;
  62467. private _screenCoordinates;
  62468. private _cachedDefines;
  62469. /**
  62470. * If not undefined, the mesh position is computed from the attached node position
  62471. */
  62472. attachedNode: {
  62473. position: Vector3;
  62474. };
  62475. /**
  62476. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62477. */
  62478. customMeshPosition: Vector3;
  62479. /**
  62480. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62481. */
  62482. useCustomMeshPosition: boolean;
  62483. /**
  62484. * If the post-process should inverse the light scattering direction
  62485. */
  62486. invert: boolean;
  62487. /**
  62488. * The internal mesh used by the post-process
  62489. */
  62490. mesh: Mesh;
  62491. /**
  62492. * @hidden
  62493. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62494. */
  62495. useDiffuseColor: boolean;
  62496. /**
  62497. * Array containing the excluded meshes not rendered in the internal pass
  62498. */
  62499. excludedMeshes: AbstractMesh[];
  62500. /**
  62501. * Controls the overall intensity of the post-process
  62502. */
  62503. exposure: number;
  62504. /**
  62505. * Dissipates each sample's contribution in range [0, 1]
  62506. */
  62507. decay: number;
  62508. /**
  62509. * Controls the overall intensity of each sample
  62510. */
  62511. weight: number;
  62512. /**
  62513. * Controls the density of each sample
  62514. */
  62515. density: number;
  62516. /**
  62517. * @constructor
  62518. * @param name The post-process name
  62519. * @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)
  62520. * @param camera The camera that the post-process will be attached to
  62521. * @param mesh The mesh used to create the light scattering
  62522. * @param samples The post-process quality, default 100
  62523. * @param samplingModeThe post-process filtering mode
  62524. * @param engine The babylon engine
  62525. * @param reusable If the post-process is reusable
  62526. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62527. */
  62528. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62529. /**
  62530. * Returns the string "VolumetricLightScatteringPostProcess"
  62531. * @returns "VolumetricLightScatteringPostProcess"
  62532. */
  62533. getClassName(): string;
  62534. private _isReady;
  62535. /**
  62536. * Sets the new light position for light scattering effect
  62537. * @param position The new custom light position
  62538. */
  62539. setCustomMeshPosition(position: Vector3): void;
  62540. /**
  62541. * Returns the light position for light scattering effect
  62542. * @return Vector3 The custom light position
  62543. */
  62544. getCustomMeshPosition(): Vector3;
  62545. /**
  62546. * Disposes the internal assets and detaches the post-process from the camera
  62547. */
  62548. dispose(camera: Camera): void;
  62549. /**
  62550. * Returns the render target texture used by the post-process
  62551. * @return the render target texture used by the post-process
  62552. */
  62553. getPass(): RenderTargetTexture;
  62554. private _meshExcluded;
  62555. private _createPass;
  62556. private _updateMeshScreenCoordinates;
  62557. /**
  62558. * Creates a default mesh for the Volumeric Light Scattering post-process
  62559. * @param name The mesh name
  62560. * @param scene The scene where to create the mesh
  62561. * @return the default mesh
  62562. */
  62563. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62564. }
  62565. }
  62566. declare module BABYLON {
  62567. interface Scene {
  62568. /** @hidden (Backing field) */
  62569. _boundingBoxRenderer: BoundingBoxRenderer;
  62570. /** @hidden (Backing field) */
  62571. _forceShowBoundingBoxes: boolean;
  62572. /**
  62573. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62574. */
  62575. forceShowBoundingBoxes: boolean;
  62576. /**
  62577. * Gets the bounding box renderer associated with the scene
  62578. * @returns a BoundingBoxRenderer
  62579. */
  62580. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62581. }
  62582. interface AbstractMesh {
  62583. /** @hidden (Backing field) */
  62584. _showBoundingBox: boolean;
  62585. /**
  62586. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62587. */
  62588. showBoundingBox: boolean;
  62589. }
  62590. /**
  62591. * Component responsible of rendering the bounding box of the meshes in a scene.
  62592. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62593. */
  62594. export class BoundingBoxRenderer implements ISceneComponent {
  62595. /**
  62596. * The component name helpfull to identify the component in the list of scene components.
  62597. */
  62598. readonly name: string;
  62599. /**
  62600. * The scene the component belongs to.
  62601. */
  62602. scene: Scene;
  62603. /**
  62604. * Color of the bounding box lines placed in front of an object
  62605. */
  62606. frontColor: Color3;
  62607. /**
  62608. * Color of the bounding box lines placed behind an object
  62609. */
  62610. backColor: Color3;
  62611. /**
  62612. * Defines if the renderer should show the back lines or not
  62613. */
  62614. showBackLines: boolean;
  62615. /**
  62616. * @hidden
  62617. */
  62618. renderList: SmartArray<BoundingBox>;
  62619. private _colorShader;
  62620. private _vertexBuffers;
  62621. private _indexBuffer;
  62622. private _fillIndexBuffer;
  62623. private _fillIndexData;
  62624. /**
  62625. * Instantiates a new bounding box renderer in a scene.
  62626. * @param scene the scene the renderer renders in
  62627. */
  62628. constructor(scene: Scene);
  62629. /**
  62630. * Registers the component in a given scene
  62631. */
  62632. register(): void;
  62633. private _evaluateSubMesh;
  62634. private _activeMesh;
  62635. private _prepareRessources;
  62636. private _createIndexBuffer;
  62637. /**
  62638. * Rebuilds the elements related to this component in case of
  62639. * context lost for instance.
  62640. */
  62641. rebuild(): void;
  62642. /**
  62643. * @hidden
  62644. */
  62645. reset(): void;
  62646. /**
  62647. * Render the bounding boxes of a specific rendering group
  62648. * @param renderingGroupId defines the rendering group to render
  62649. */
  62650. render(renderingGroupId: number): void;
  62651. /**
  62652. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62653. * @param mesh Define the mesh to render the occlusion bounding box for
  62654. */
  62655. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62656. /**
  62657. * Dispose and release the resources attached to this renderer.
  62658. */
  62659. dispose(): void;
  62660. }
  62661. }
  62662. declare module BABYLON {
  62663. /** @hidden */
  62664. export var depthPixelShader: {
  62665. name: string;
  62666. shader: string;
  62667. };
  62668. }
  62669. declare module BABYLON {
  62670. /**
  62671. * This represents a depth renderer in Babylon.
  62672. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62673. */
  62674. export class DepthRenderer {
  62675. private _scene;
  62676. private _depthMap;
  62677. private _effect;
  62678. private readonly _storeNonLinearDepth;
  62679. private readonly _clearColor;
  62680. /** Get if the depth renderer is using packed depth or not */
  62681. readonly isPacked: boolean;
  62682. private _cachedDefines;
  62683. private _camera;
  62684. /**
  62685. * Specifiess that the depth renderer will only be used within
  62686. * the camera it is created for.
  62687. * This can help forcing its rendering during the camera processing.
  62688. */
  62689. useOnlyInActiveCamera: boolean;
  62690. /** @hidden */
  62691. static _SceneComponentInitialization: (scene: Scene) => void;
  62692. /**
  62693. * Instantiates a depth renderer
  62694. * @param scene The scene the renderer belongs to
  62695. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62696. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62697. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62698. */
  62699. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62700. /**
  62701. * Creates the depth rendering effect and checks if the effect is ready.
  62702. * @param subMesh The submesh to be used to render the depth map of
  62703. * @param useInstances If multiple world instances should be used
  62704. * @returns if the depth renderer is ready to render the depth map
  62705. */
  62706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62707. /**
  62708. * Gets the texture which the depth map will be written to.
  62709. * @returns The depth map texture
  62710. */
  62711. getDepthMap(): RenderTargetTexture;
  62712. /**
  62713. * Disposes of the depth renderer.
  62714. */
  62715. dispose(): void;
  62716. }
  62717. }
  62718. declare module BABYLON {
  62719. interface Scene {
  62720. /** @hidden (Backing field) */
  62721. _depthRenderer: {
  62722. [id: string]: DepthRenderer;
  62723. };
  62724. /**
  62725. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62726. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62727. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62728. * @returns the created depth renderer
  62729. */
  62730. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62731. /**
  62732. * Disables a depth renderer for a given camera
  62733. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62734. */
  62735. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62736. }
  62737. /**
  62738. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62739. * in several rendering techniques.
  62740. */
  62741. export class DepthRendererSceneComponent implements ISceneComponent {
  62742. /**
  62743. * The component name helpfull to identify the component in the list of scene components.
  62744. */
  62745. readonly name: string;
  62746. /**
  62747. * The scene the component belongs to.
  62748. */
  62749. scene: Scene;
  62750. /**
  62751. * Creates a new instance of the component for the given scene
  62752. * @param scene Defines the scene to register the component in
  62753. */
  62754. constructor(scene: Scene);
  62755. /**
  62756. * Registers the component in a given scene
  62757. */
  62758. register(): void;
  62759. /**
  62760. * Rebuilds the elements related to this component in case of
  62761. * context lost for instance.
  62762. */
  62763. rebuild(): void;
  62764. /**
  62765. * Disposes the component and the associated ressources
  62766. */
  62767. dispose(): void;
  62768. private _gatherRenderTargets;
  62769. private _gatherActiveCameraRenderTargets;
  62770. }
  62771. }
  62772. declare module BABYLON {
  62773. /** @hidden */
  62774. export var outlinePixelShader: {
  62775. name: string;
  62776. shader: string;
  62777. };
  62778. }
  62779. declare module BABYLON {
  62780. /** @hidden */
  62781. export var outlineVertexShader: {
  62782. name: string;
  62783. shader: string;
  62784. };
  62785. }
  62786. declare module BABYLON {
  62787. interface Scene {
  62788. /** @hidden */
  62789. _outlineRenderer: OutlineRenderer;
  62790. /**
  62791. * Gets the outline renderer associated with the scene
  62792. * @returns a OutlineRenderer
  62793. */
  62794. getOutlineRenderer(): OutlineRenderer;
  62795. }
  62796. interface AbstractMesh {
  62797. /** @hidden (Backing field) */
  62798. _renderOutline: boolean;
  62799. /**
  62800. * Gets or sets a boolean indicating if the outline must be rendered as well
  62801. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62802. */
  62803. renderOutline: boolean;
  62804. /** @hidden (Backing field) */
  62805. _renderOverlay: boolean;
  62806. /**
  62807. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62808. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62809. */
  62810. renderOverlay: boolean;
  62811. }
  62812. /**
  62813. * This class is responsible to draw bothe outline/overlay of meshes.
  62814. * It should not be used directly but through the available method on mesh.
  62815. */
  62816. export class OutlineRenderer implements ISceneComponent {
  62817. /**
  62818. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62819. */
  62820. private static _StencilReference;
  62821. /**
  62822. * The name of the component. Each component must have a unique name.
  62823. */
  62824. name: string;
  62825. /**
  62826. * The scene the component belongs to.
  62827. */
  62828. scene: Scene;
  62829. /**
  62830. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62831. */
  62832. zOffset: number;
  62833. private _engine;
  62834. private _effect;
  62835. private _cachedDefines;
  62836. private _savedDepthWrite;
  62837. /**
  62838. * Instantiates a new outline renderer. (There could be only one per scene).
  62839. * @param scene Defines the scene it belongs to
  62840. */
  62841. constructor(scene: Scene);
  62842. /**
  62843. * Register the component to one instance of a scene.
  62844. */
  62845. register(): void;
  62846. /**
  62847. * Rebuilds the elements related to this component in case of
  62848. * context lost for instance.
  62849. */
  62850. rebuild(): void;
  62851. /**
  62852. * Disposes the component and the associated ressources.
  62853. */
  62854. dispose(): void;
  62855. /**
  62856. * Renders the outline in the canvas.
  62857. * @param subMesh Defines the sumesh to render
  62858. * @param batch Defines the batch of meshes in case of instances
  62859. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62860. */
  62861. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62862. /**
  62863. * Returns whether or not the outline renderer is ready for a given submesh.
  62864. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62865. * @param subMesh Defines the submesh to check readyness for
  62866. * @param useInstances Defines wheter wee are trying to render instances or not
  62867. * @returns true if ready otherwise false
  62868. */
  62869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62870. private _beforeRenderingMesh;
  62871. private _afterRenderingMesh;
  62872. }
  62873. }
  62874. declare module BABYLON {
  62875. /**
  62876. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62877. * @see http://doc.babylonjs.com/babylon101/sprites
  62878. */
  62879. export class SpritePackedManager extends SpriteManager {
  62880. /** defines the packed manager's name */
  62881. name: string;
  62882. /**
  62883. * Creates a new sprite manager from a packed sprite sheet
  62884. * @param name defines the manager's name
  62885. * @param imgUrl defines the sprite sheet url
  62886. * @param capacity defines the maximum allowed number of sprites
  62887. * @param scene defines the hosting scene
  62888. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62889. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62890. * @param samplingMode defines the smapling mode to use with spritesheet
  62891. * @param fromPacked set to true; do not alter
  62892. */
  62893. constructor(
  62894. /** defines the packed manager's name */
  62895. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62896. }
  62897. }
  62898. declare module BABYLON {
  62899. /**
  62900. * Defines the list of states available for a task inside a AssetsManager
  62901. */
  62902. export enum AssetTaskState {
  62903. /**
  62904. * Initialization
  62905. */
  62906. INIT = 0,
  62907. /**
  62908. * Running
  62909. */
  62910. RUNNING = 1,
  62911. /**
  62912. * Done
  62913. */
  62914. DONE = 2,
  62915. /**
  62916. * Error
  62917. */
  62918. ERROR = 3
  62919. }
  62920. /**
  62921. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62922. */
  62923. export abstract class AbstractAssetTask {
  62924. /**
  62925. * Task name
  62926. */ name: string;
  62927. /**
  62928. * Callback called when the task is successful
  62929. */
  62930. onSuccess: (task: any) => void;
  62931. /**
  62932. * Callback called when the task is not successful
  62933. */
  62934. onError: (task: any, message?: string, exception?: any) => void;
  62935. /**
  62936. * Creates a new AssetsManager
  62937. * @param name defines the name of the task
  62938. */
  62939. constructor(
  62940. /**
  62941. * Task name
  62942. */ name: string);
  62943. private _isCompleted;
  62944. private _taskState;
  62945. private _errorObject;
  62946. /**
  62947. * Get if the task is completed
  62948. */
  62949. readonly isCompleted: boolean;
  62950. /**
  62951. * Gets the current state of the task
  62952. */
  62953. readonly taskState: AssetTaskState;
  62954. /**
  62955. * Gets the current error object (if task is in error)
  62956. */
  62957. readonly errorObject: {
  62958. message?: string;
  62959. exception?: any;
  62960. };
  62961. /**
  62962. * Internal only
  62963. * @hidden
  62964. */
  62965. _setErrorObject(message?: string, exception?: any): void;
  62966. /**
  62967. * Execute the current task
  62968. * @param scene defines the scene where you want your assets to be loaded
  62969. * @param onSuccess is a callback called when the task is successfully executed
  62970. * @param onError is a callback called if an error occurs
  62971. */
  62972. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62973. /**
  62974. * Execute the current task
  62975. * @param scene defines the scene where you want your assets to be loaded
  62976. * @param onSuccess is a callback called when the task is successfully executed
  62977. * @param onError is a callback called if an error occurs
  62978. */
  62979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62980. /**
  62981. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62982. * This can be used with failed tasks that have the reason for failure fixed.
  62983. */
  62984. reset(): void;
  62985. private onErrorCallback;
  62986. private onDoneCallback;
  62987. }
  62988. /**
  62989. * Define the interface used by progress events raised during assets loading
  62990. */
  62991. export interface IAssetsProgressEvent {
  62992. /**
  62993. * Defines the number of remaining tasks to process
  62994. */
  62995. remainingCount: number;
  62996. /**
  62997. * Defines the total number of tasks
  62998. */
  62999. totalCount: number;
  63000. /**
  63001. * Defines the task that was just processed
  63002. */
  63003. task: AbstractAssetTask;
  63004. }
  63005. /**
  63006. * Class used to share progress information about assets loading
  63007. */
  63008. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63009. /**
  63010. * Defines the number of remaining tasks to process
  63011. */
  63012. remainingCount: number;
  63013. /**
  63014. * Defines the total number of tasks
  63015. */
  63016. totalCount: number;
  63017. /**
  63018. * Defines the task that was just processed
  63019. */
  63020. task: AbstractAssetTask;
  63021. /**
  63022. * Creates a AssetsProgressEvent
  63023. * @param remainingCount defines the number of remaining tasks to process
  63024. * @param totalCount defines the total number of tasks
  63025. * @param task defines the task that was just processed
  63026. */
  63027. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63028. }
  63029. /**
  63030. * Define a task used by AssetsManager to load meshes
  63031. */
  63032. export class MeshAssetTask extends AbstractAssetTask {
  63033. /**
  63034. * Defines the name of the task
  63035. */
  63036. name: string;
  63037. /**
  63038. * Defines the list of mesh's names you want to load
  63039. */
  63040. meshesNames: any;
  63041. /**
  63042. * Defines the root url to use as a base to load your meshes and associated resources
  63043. */
  63044. rootUrl: string;
  63045. /**
  63046. * Defines the filename of the scene to load from
  63047. */
  63048. sceneFilename: string;
  63049. /**
  63050. * Gets the list of loaded meshes
  63051. */
  63052. loadedMeshes: Array<AbstractMesh>;
  63053. /**
  63054. * Gets the list of loaded particle systems
  63055. */
  63056. loadedParticleSystems: Array<IParticleSystem>;
  63057. /**
  63058. * Gets the list of loaded skeletons
  63059. */
  63060. loadedSkeletons: Array<Skeleton>;
  63061. /**
  63062. * Gets the list of loaded animation groups
  63063. */
  63064. loadedAnimationGroups: Array<AnimationGroup>;
  63065. /**
  63066. * Callback called when the task is successful
  63067. */
  63068. onSuccess: (task: MeshAssetTask) => void;
  63069. /**
  63070. * Callback called when the task is successful
  63071. */
  63072. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63073. /**
  63074. * Creates a new MeshAssetTask
  63075. * @param name defines the name of the task
  63076. * @param meshesNames defines the list of mesh's names you want to load
  63077. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63078. * @param sceneFilename defines the filename of the scene to load from
  63079. */
  63080. constructor(
  63081. /**
  63082. * Defines the name of the task
  63083. */
  63084. name: string,
  63085. /**
  63086. * Defines the list of mesh's names you want to load
  63087. */
  63088. meshesNames: any,
  63089. /**
  63090. * Defines the root url to use as a base to load your meshes and associated resources
  63091. */
  63092. rootUrl: string,
  63093. /**
  63094. * Defines the filename of the scene to load from
  63095. */
  63096. sceneFilename: string);
  63097. /**
  63098. * Execute the current task
  63099. * @param scene defines the scene where you want your assets to be loaded
  63100. * @param onSuccess is a callback called when the task is successfully executed
  63101. * @param onError is a callback called if an error occurs
  63102. */
  63103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63104. }
  63105. /**
  63106. * Define a task used by AssetsManager to load text content
  63107. */
  63108. export class TextFileAssetTask extends AbstractAssetTask {
  63109. /**
  63110. * Defines the name of the task
  63111. */
  63112. name: string;
  63113. /**
  63114. * Defines the location of the file to load
  63115. */
  63116. url: string;
  63117. /**
  63118. * Gets the loaded text string
  63119. */
  63120. text: string;
  63121. /**
  63122. * Callback called when the task is successful
  63123. */
  63124. onSuccess: (task: TextFileAssetTask) => void;
  63125. /**
  63126. * Callback called when the task is successful
  63127. */
  63128. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63129. /**
  63130. * Creates a new TextFileAssetTask object
  63131. * @param name defines the name of the task
  63132. * @param url defines the location of the file to load
  63133. */
  63134. constructor(
  63135. /**
  63136. * Defines the name of the task
  63137. */
  63138. name: string,
  63139. /**
  63140. * Defines the location of the file to load
  63141. */
  63142. url: string);
  63143. /**
  63144. * Execute the current task
  63145. * @param scene defines the scene where you want your assets to be loaded
  63146. * @param onSuccess is a callback called when the task is successfully executed
  63147. * @param onError is a callback called if an error occurs
  63148. */
  63149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63150. }
  63151. /**
  63152. * Define a task used by AssetsManager to load binary data
  63153. */
  63154. export class BinaryFileAssetTask extends AbstractAssetTask {
  63155. /**
  63156. * Defines the name of the task
  63157. */
  63158. name: string;
  63159. /**
  63160. * Defines the location of the file to load
  63161. */
  63162. url: string;
  63163. /**
  63164. * Gets the lodaded data (as an array buffer)
  63165. */
  63166. data: ArrayBuffer;
  63167. /**
  63168. * Callback called when the task is successful
  63169. */
  63170. onSuccess: (task: BinaryFileAssetTask) => void;
  63171. /**
  63172. * Callback called when the task is successful
  63173. */
  63174. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63175. /**
  63176. * Creates a new BinaryFileAssetTask object
  63177. * @param name defines the name of the new task
  63178. * @param url defines the location of the file to load
  63179. */
  63180. constructor(
  63181. /**
  63182. * Defines the name of the task
  63183. */
  63184. name: string,
  63185. /**
  63186. * Defines the location of the file to load
  63187. */
  63188. url: string);
  63189. /**
  63190. * Execute the current task
  63191. * @param scene defines the scene where you want your assets to be loaded
  63192. * @param onSuccess is a callback called when the task is successfully executed
  63193. * @param onError is a callback called if an error occurs
  63194. */
  63195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63196. }
  63197. /**
  63198. * Define a task used by AssetsManager to load images
  63199. */
  63200. export class ImageAssetTask extends AbstractAssetTask {
  63201. /**
  63202. * Defines the name of the task
  63203. */
  63204. name: string;
  63205. /**
  63206. * Defines the location of the image to load
  63207. */
  63208. url: string;
  63209. /**
  63210. * Gets the loaded images
  63211. */
  63212. image: HTMLImageElement;
  63213. /**
  63214. * Callback called when the task is successful
  63215. */
  63216. onSuccess: (task: ImageAssetTask) => void;
  63217. /**
  63218. * Callback called when the task is successful
  63219. */
  63220. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63221. /**
  63222. * Creates a new ImageAssetTask
  63223. * @param name defines the name of the task
  63224. * @param url defines the location of the image to load
  63225. */
  63226. constructor(
  63227. /**
  63228. * Defines the name of the task
  63229. */
  63230. name: string,
  63231. /**
  63232. * Defines the location of the image to load
  63233. */
  63234. url: string);
  63235. /**
  63236. * Execute the current task
  63237. * @param scene defines the scene where you want your assets to be loaded
  63238. * @param onSuccess is a callback called when the task is successfully executed
  63239. * @param onError is a callback called if an error occurs
  63240. */
  63241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63242. }
  63243. /**
  63244. * Defines the interface used by texture loading tasks
  63245. */
  63246. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63247. /**
  63248. * Gets the loaded texture
  63249. */
  63250. texture: TEX;
  63251. }
  63252. /**
  63253. * Define a task used by AssetsManager to load 2D textures
  63254. */
  63255. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63256. /**
  63257. * Defines the name of the task
  63258. */
  63259. name: string;
  63260. /**
  63261. * Defines the location of the file to load
  63262. */
  63263. url: string;
  63264. /**
  63265. * Defines if mipmap should not be generated (default is false)
  63266. */
  63267. noMipmap?: boolean | undefined;
  63268. /**
  63269. * Defines if texture must be inverted on Y axis (default is false)
  63270. */
  63271. invertY?: boolean | undefined;
  63272. /**
  63273. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63274. */
  63275. samplingMode: number;
  63276. /**
  63277. * Gets the loaded texture
  63278. */
  63279. texture: Texture;
  63280. /**
  63281. * Callback called when the task is successful
  63282. */
  63283. onSuccess: (task: TextureAssetTask) => void;
  63284. /**
  63285. * Callback called when the task is successful
  63286. */
  63287. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63288. /**
  63289. * Creates a new TextureAssetTask object
  63290. * @param name defines the name of the task
  63291. * @param url defines the location of the file to load
  63292. * @param noMipmap defines if mipmap should not be generated (default is false)
  63293. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63294. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63295. */
  63296. constructor(
  63297. /**
  63298. * Defines the name of the task
  63299. */
  63300. name: string,
  63301. /**
  63302. * Defines the location of the file to load
  63303. */
  63304. url: string,
  63305. /**
  63306. * Defines if mipmap should not be generated (default is false)
  63307. */
  63308. noMipmap?: boolean | undefined,
  63309. /**
  63310. * Defines if texture must be inverted on Y axis (default is false)
  63311. */
  63312. invertY?: boolean | undefined,
  63313. /**
  63314. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63315. */
  63316. samplingMode?: number);
  63317. /**
  63318. * Execute the current task
  63319. * @param scene defines the scene where you want your assets to be loaded
  63320. * @param onSuccess is a callback called when the task is successfully executed
  63321. * @param onError is a callback called if an error occurs
  63322. */
  63323. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63324. }
  63325. /**
  63326. * Define a task used by AssetsManager to load cube textures
  63327. */
  63328. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63329. /**
  63330. * Defines the name of the task
  63331. */
  63332. name: string;
  63333. /**
  63334. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63335. */
  63336. url: string;
  63337. /**
  63338. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63339. */
  63340. extensions?: string[] | undefined;
  63341. /**
  63342. * Defines if mipmaps should not be generated (default is false)
  63343. */
  63344. noMipmap?: boolean | undefined;
  63345. /**
  63346. * Defines the explicit list of files (undefined by default)
  63347. */
  63348. files?: string[] | undefined;
  63349. /**
  63350. * Gets the loaded texture
  63351. */
  63352. texture: CubeTexture;
  63353. /**
  63354. * Callback called when the task is successful
  63355. */
  63356. onSuccess: (task: CubeTextureAssetTask) => void;
  63357. /**
  63358. * Callback called when the task is successful
  63359. */
  63360. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63361. /**
  63362. * Creates a new CubeTextureAssetTask
  63363. * @param name defines the name of the task
  63364. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63365. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63366. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63367. * @param files defines the explicit list of files (undefined by default)
  63368. */
  63369. constructor(
  63370. /**
  63371. * Defines the name of the task
  63372. */
  63373. name: string,
  63374. /**
  63375. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63376. */
  63377. url: string,
  63378. /**
  63379. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63380. */
  63381. extensions?: string[] | undefined,
  63382. /**
  63383. * Defines if mipmaps should not be generated (default is false)
  63384. */
  63385. noMipmap?: boolean | undefined,
  63386. /**
  63387. * Defines the explicit list of files (undefined by default)
  63388. */
  63389. files?: string[] | undefined);
  63390. /**
  63391. * Execute the current task
  63392. * @param scene defines the scene where you want your assets to be loaded
  63393. * @param onSuccess is a callback called when the task is successfully executed
  63394. * @param onError is a callback called if an error occurs
  63395. */
  63396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63397. }
  63398. /**
  63399. * Define a task used by AssetsManager to load HDR cube textures
  63400. */
  63401. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63402. /**
  63403. * Defines the name of the task
  63404. */
  63405. name: string;
  63406. /**
  63407. * Defines the location of the file to load
  63408. */
  63409. url: string;
  63410. /**
  63411. * Defines the desired size (the more it increases the longer the generation will be)
  63412. */
  63413. size: number;
  63414. /**
  63415. * Defines if mipmaps should not be generated (default is false)
  63416. */
  63417. noMipmap: boolean;
  63418. /**
  63419. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63420. */
  63421. generateHarmonics: boolean;
  63422. /**
  63423. * 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)
  63424. */
  63425. gammaSpace: boolean;
  63426. /**
  63427. * Internal Use Only
  63428. */
  63429. reserved: boolean;
  63430. /**
  63431. * Gets the loaded texture
  63432. */
  63433. texture: HDRCubeTexture;
  63434. /**
  63435. * Callback called when the task is successful
  63436. */
  63437. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63438. /**
  63439. * Callback called when the task is successful
  63440. */
  63441. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63442. /**
  63443. * Creates a new HDRCubeTextureAssetTask object
  63444. * @param name defines the name of the task
  63445. * @param url defines the location of the file to load
  63446. * @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.
  63447. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63448. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63449. * @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)
  63450. * @param reserved Internal use only
  63451. */
  63452. constructor(
  63453. /**
  63454. * Defines the name of the task
  63455. */
  63456. name: string,
  63457. /**
  63458. * Defines the location of the file to load
  63459. */
  63460. url: string,
  63461. /**
  63462. * Defines the desired size (the more it increases the longer the generation will be)
  63463. */
  63464. size: number,
  63465. /**
  63466. * Defines if mipmaps should not be generated (default is false)
  63467. */
  63468. noMipmap?: boolean,
  63469. /**
  63470. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63471. */
  63472. generateHarmonics?: boolean,
  63473. /**
  63474. * 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)
  63475. */
  63476. gammaSpace?: boolean,
  63477. /**
  63478. * Internal Use Only
  63479. */
  63480. reserved?: boolean);
  63481. /**
  63482. * Execute the current task
  63483. * @param scene defines the scene where you want your assets to be loaded
  63484. * @param onSuccess is a callback called when the task is successfully executed
  63485. * @param onError is a callback called if an error occurs
  63486. */
  63487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63488. }
  63489. /**
  63490. * Define a task used by AssetsManager to load Equirectangular cube textures
  63491. */
  63492. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63493. /**
  63494. * Defines the name of the task
  63495. */
  63496. name: string;
  63497. /**
  63498. * Defines the location of the file to load
  63499. */
  63500. url: string;
  63501. /**
  63502. * Defines the desired size (the more it increases the longer the generation will be)
  63503. */
  63504. size: number;
  63505. /**
  63506. * Defines if mipmaps should not be generated (default is false)
  63507. */
  63508. noMipmap: boolean;
  63509. /**
  63510. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63511. * but the standard material would require them in Gamma space) (default is true)
  63512. */
  63513. gammaSpace: boolean;
  63514. /**
  63515. * Gets the loaded texture
  63516. */
  63517. texture: EquiRectangularCubeTexture;
  63518. /**
  63519. * Callback called when the task is successful
  63520. */
  63521. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63522. /**
  63523. * Callback called when the task is successful
  63524. */
  63525. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63526. /**
  63527. * Creates a new EquiRectangularCubeTextureAssetTask object
  63528. * @param name defines the name of the task
  63529. * @param url defines the location of the file to load
  63530. * @param size defines the desired size (the more it increases the longer the generation will be)
  63531. * If the size is omitted this implies you are using a preprocessed cubemap.
  63532. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63533. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63534. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63535. * (default is true)
  63536. */
  63537. constructor(
  63538. /**
  63539. * Defines the name of the task
  63540. */
  63541. name: string,
  63542. /**
  63543. * Defines the location of the file to load
  63544. */
  63545. url: string,
  63546. /**
  63547. * Defines the desired size (the more it increases the longer the generation will be)
  63548. */
  63549. size: number,
  63550. /**
  63551. * Defines if mipmaps should not be generated (default is false)
  63552. */
  63553. noMipmap?: boolean,
  63554. /**
  63555. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63556. * but the standard material would require them in Gamma space) (default is true)
  63557. */
  63558. gammaSpace?: boolean);
  63559. /**
  63560. * Execute the current task
  63561. * @param scene defines the scene where you want your assets to be loaded
  63562. * @param onSuccess is a callback called when the task is successfully executed
  63563. * @param onError is a callback called if an error occurs
  63564. */
  63565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63566. }
  63567. /**
  63568. * This class can be used to easily import assets into a scene
  63569. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63570. */
  63571. export class AssetsManager {
  63572. private _scene;
  63573. private _isLoading;
  63574. protected _tasks: AbstractAssetTask[];
  63575. protected _waitingTasksCount: number;
  63576. protected _totalTasksCount: number;
  63577. /**
  63578. * Callback called when all tasks are processed
  63579. */
  63580. onFinish: (tasks: AbstractAssetTask[]) => void;
  63581. /**
  63582. * Callback called when a task is successful
  63583. */
  63584. onTaskSuccess: (task: AbstractAssetTask) => void;
  63585. /**
  63586. * Callback called when a task had an error
  63587. */
  63588. onTaskError: (task: AbstractAssetTask) => void;
  63589. /**
  63590. * Callback called when a task is done (whatever the result is)
  63591. */
  63592. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63593. /**
  63594. * Observable called when all tasks are processed
  63595. */
  63596. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63597. /**
  63598. * Observable called when a task had an error
  63599. */
  63600. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63601. /**
  63602. * Observable called when all tasks were executed
  63603. */
  63604. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63605. /**
  63606. * Observable called when a task is done (whatever the result is)
  63607. */
  63608. onProgressObservable: Observable<IAssetsProgressEvent>;
  63609. /**
  63610. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63612. */
  63613. useDefaultLoadingScreen: boolean;
  63614. /**
  63615. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63616. * when all assets have been downloaded.
  63617. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63618. */
  63619. autoHideLoadingUI: boolean;
  63620. /**
  63621. * Creates a new AssetsManager
  63622. * @param scene defines the scene to work on
  63623. */
  63624. constructor(scene: Scene);
  63625. /**
  63626. * Add a MeshAssetTask to the list of active tasks
  63627. * @param taskName defines the name of the new task
  63628. * @param meshesNames defines the name of meshes to load
  63629. * @param rootUrl defines the root url to use to locate files
  63630. * @param sceneFilename defines the filename of the scene file
  63631. * @returns a new MeshAssetTask object
  63632. */
  63633. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63634. /**
  63635. * Add a TextFileAssetTask to the list of active tasks
  63636. * @param taskName defines the name of the new task
  63637. * @param url defines the url of the file to load
  63638. * @returns a new TextFileAssetTask object
  63639. */
  63640. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63641. /**
  63642. * Add a BinaryFileAssetTask to the list of active tasks
  63643. * @param taskName defines the name of the new task
  63644. * @param url defines the url of the file to load
  63645. * @returns a new BinaryFileAssetTask object
  63646. */
  63647. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63648. /**
  63649. * Add a ImageAssetTask to the list of active tasks
  63650. * @param taskName defines the name of the new task
  63651. * @param url defines the url of the file to load
  63652. * @returns a new ImageAssetTask object
  63653. */
  63654. addImageTask(taskName: string, url: string): ImageAssetTask;
  63655. /**
  63656. * Add a TextureAssetTask to the list of active tasks
  63657. * @param taskName defines the name of the new task
  63658. * @param url defines the url of the file to load
  63659. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63660. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63661. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63662. * @returns a new TextureAssetTask object
  63663. */
  63664. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63665. /**
  63666. * Add a CubeTextureAssetTask to the list of active tasks
  63667. * @param taskName defines the name of the new task
  63668. * @param url defines the url of the file to load
  63669. * @param extensions defines the extension to use to load the cube map (can be null)
  63670. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63671. * @param files defines the list of files to load (can be null)
  63672. * @returns a new CubeTextureAssetTask object
  63673. */
  63674. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63675. /**
  63676. *
  63677. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63678. * @param taskName defines the name of the new task
  63679. * @param url defines the url of the file to load
  63680. * @param size defines the size you want for the cubemap (can be null)
  63681. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63682. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63683. * @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)
  63684. * @param reserved Internal use only
  63685. * @returns a new HDRCubeTextureAssetTask object
  63686. */
  63687. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63688. /**
  63689. *
  63690. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63691. * @param taskName defines the name of the new task
  63692. * @param url defines the url of the file to load
  63693. * @param size defines the size you want for the cubemap (can be null)
  63694. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63695. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63696. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63697. * @returns a new EquiRectangularCubeTextureAssetTask object
  63698. */
  63699. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63700. /**
  63701. * Remove a task from the assets manager.
  63702. * @param task the task to remove
  63703. */
  63704. removeTask(task: AbstractAssetTask): void;
  63705. private _decreaseWaitingTasksCount;
  63706. private _runTask;
  63707. /**
  63708. * Reset the AssetsManager and remove all tasks
  63709. * @return the current instance of the AssetsManager
  63710. */
  63711. reset(): AssetsManager;
  63712. /**
  63713. * Start the loading process
  63714. * @return the current instance of the AssetsManager
  63715. */
  63716. load(): AssetsManager;
  63717. /**
  63718. * Start the loading process as an async operation
  63719. * @return a promise returning the list of failed tasks
  63720. */
  63721. loadAsync(): Promise<void>;
  63722. }
  63723. }
  63724. declare module BABYLON {
  63725. /**
  63726. * Wrapper class for promise with external resolve and reject.
  63727. */
  63728. export class Deferred<T> {
  63729. /**
  63730. * The promise associated with this deferred object.
  63731. */
  63732. readonly promise: Promise<T>;
  63733. private _resolve;
  63734. private _reject;
  63735. /**
  63736. * The resolve method of the promise associated with this deferred object.
  63737. */
  63738. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63739. /**
  63740. * The reject method of the promise associated with this deferred object.
  63741. */
  63742. readonly reject: (reason?: any) => void;
  63743. /**
  63744. * Constructor for this deferred object.
  63745. */
  63746. constructor();
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63752. */
  63753. export class MeshExploder {
  63754. private _centerMesh;
  63755. private _meshes;
  63756. private _meshesOrigins;
  63757. private _toCenterVectors;
  63758. private _scaledDirection;
  63759. private _newPosition;
  63760. private _centerPosition;
  63761. /**
  63762. * Explodes meshes from a center mesh.
  63763. * @param meshes The meshes to explode.
  63764. * @param centerMesh The mesh to be center of explosion.
  63765. */
  63766. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63767. private _setCenterMesh;
  63768. /**
  63769. * Get class name
  63770. * @returns "MeshExploder"
  63771. */
  63772. getClassName(): string;
  63773. /**
  63774. * "Exploded meshes"
  63775. * @returns Array of meshes with the centerMesh at index 0.
  63776. */
  63777. getMeshes(): Array<Mesh>;
  63778. /**
  63779. * Explodes meshes giving a specific direction
  63780. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63781. */
  63782. explode(direction?: number): void;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /**
  63787. * Class used to help managing file picking and drag'n'drop
  63788. */
  63789. export class FilesInput {
  63790. /**
  63791. * List of files ready to be loaded
  63792. */
  63793. static readonly FilesToLoad: {
  63794. [key: string]: File;
  63795. };
  63796. /**
  63797. * Callback called when a file is processed
  63798. */
  63799. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63800. private _engine;
  63801. private _currentScene;
  63802. private _sceneLoadedCallback;
  63803. private _progressCallback;
  63804. private _additionalRenderLoopLogicCallback;
  63805. private _textureLoadingCallback;
  63806. private _startingProcessingFilesCallback;
  63807. private _onReloadCallback;
  63808. private _errorCallback;
  63809. private _elementToMonitor;
  63810. private _sceneFileToLoad;
  63811. private _filesToLoad;
  63812. /**
  63813. * Creates a new FilesInput
  63814. * @param engine defines the rendering engine
  63815. * @param scene defines the hosting scene
  63816. * @param sceneLoadedCallback callback called when scene is loaded
  63817. * @param progressCallback callback called to track progress
  63818. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63819. * @param textureLoadingCallback callback called when a texture is loading
  63820. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63821. * @param onReloadCallback callback called when a reload is requested
  63822. * @param errorCallback callback call if an error occurs
  63823. */
  63824. 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);
  63825. private _dragEnterHandler;
  63826. private _dragOverHandler;
  63827. private _dropHandler;
  63828. /**
  63829. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63830. * @param elementToMonitor defines the DOM element to track
  63831. */
  63832. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63833. /**
  63834. * Release all associated resources
  63835. */
  63836. dispose(): void;
  63837. private renderFunction;
  63838. private drag;
  63839. private drop;
  63840. private _traverseFolder;
  63841. private _processFiles;
  63842. /**
  63843. * Load files from a drop event
  63844. * @param event defines the drop event to use as source
  63845. */
  63846. loadFiles(event: any): void;
  63847. private _processReload;
  63848. /**
  63849. * Reload the current scene from the loaded files
  63850. */
  63851. reload(): void;
  63852. }
  63853. }
  63854. declare module BABYLON {
  63855. /**
  63856. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63858. */
  63859. export class SceneOptimization {
  63860. /**
  63861. * Defines the priority of this optimization (0 by default which means first in the list)
  63862. */
  63863. priority: number;
  63864. /**
  63865. * Gets a string describing the action executed by the current optimization
  63866. * @returns description string
  63867. */
  63868. getDescription(): string;
  63869. /**
  63870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63871. * @param scene defines the current scene where to apply this optimization
  63872. * @param optimizer defines the current optimizer
  63873. * @returns true if everything that can be done was applied
  63874. */
  63875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63876. /**
  63877. * Creates the SceneOptimization object
  63878. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63879. * @param desc defines the description associated with the optimization
  63880. */
  63881. constructor(
  63882. /**
  63883. * Defines the priority of this optimization (0 by default which means first in the list)
  63884. */
  63885. priority?: number);
  63886. }
  63887. /**
  63888. * Defines an optimization used to reduce the size of render target textures
  63889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63890. */
  63891. export class TextureOptimization extends SceneOptimization {
  63892. /**
  63893. * Defines the priority of this optimization (0 by default which means first in the list)
  63894. */
  63895. priority: number;
  63896. /**
  63897. * 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
  63898. */
  63899. maximumSize: number;
  63900. /**
  63901. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63902. */
  63903. step: number;
  63904. /**
  63905. * Gets a string describing the action executed by the current optimization
  63906. * @returns description string
  63907. */
  63908. getDescription(): string;
  63909. /**
  63910. * Creates the TextureOptimization object
  63911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63912. * @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
  63913. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63914. */
  63915. constructor(
  63916. /**
  63917. * Defines the priority of this optimization (0 by default which means first in the list)
  63918. */
  63919. priority?: number,
  63920. /**
  63921. * 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
  63922. */
  63923. maximumSize?: number,
  63924. /**
  63925. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63926. */
  63927. step?: number);
  63928. /**
  63929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63930. * @param scene defines the current scene where to apply this optimization
  63931. * @param optimizer defines the current optimizer
  63932. * @returns true if everything that can be done was applied
  63933. */
  63934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63935. }
  63936. /**
  63937. * Defines an optimization used to increase or decrease the rendering resolution
  63938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63939. */
  63940. export class HardwareScalingOptimization extends SceneOptimization {
  63941. /**
  63942. * Defines the priority of this optimization (0 by default which means first in the list)
  63943. */
  63944. priority: number;
  63945. /**
  63946. * Defines the maximum scale to use (2 by default)
  63947. */
  63948. maximumScale: number;
  63949. /**
  63950. * Defines the step to use between two passes (0.5 by default)
  63951. */
  63952. step: number;
  63953. private _currentScale;
  63954. private _directionOffset;
  63955. /**
  63956. * Gets a string describing the action executed by the current optimization
  63957. * @return description string
  63958. */
  63959. getDescription(): string;
  63960. /**
  63961. * Creates the HardwareScalingOptimization object
  63962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63963. * @param maximumScale defines the maximum scale to use (2 by default)
  63964. * @param step defines the step to use between two passes (0.5 by default)
  63965. */
  63966. constructor(
  63967. /**
  63968. * Defines the priority of this optimization (0 by default which means first in the list)
  63969. */
  63970. priority?: number,
  63971. /**
  63972. * Defines the maximum scale to use (2 by default)
  63973. */
  63974. maximumScale?: number,
  63975. /**
  63976. * Defines the step to use between two passes (0.5 by default)
  63977. */
  63978. step?: number);
  63979. /**
  63980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63981. * @param scene defines the current scene where to apply this optimization
  63982. * @param optimizer defines the current optimizer
  63983. * @returns true if everything that can be done was applied
  63984. */
  63985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63986. }
  63987. /**
  63988. * Defines an optimization used to remove shadows
  63989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63990. */
  63991. export class ShadowsOptimization extends SceneOptimization {
  63992. /**
  63993. * Gets a string describing the action executed by the current optimization
  63994. * @return description string
  63995. */
  63996. getDescription(): string;
  63997. /**
  63998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63999. * @param scene defines the current scene where to apply this optimization
  64000. * @param optimizer defines the current optimizer
  64001. * @returns true if everything that can be done was applied
  64002. */
  64003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64004. }
  64005. /**
  64006. * Defines an optimization used to turn post-processes off
  64007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64008. */
  64009. export class PostProcessesOptimization extends SceneOptimization {
  64010. /**
  64011. * Gets a string describing the action executed by the current optimization
  64012. * @return description string
  64013. */
  64014. getDescription(): string;
  64015. /**
  64016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64017. * @param scene defines the current scene where to apply this optimization
  64018. * @param optimizer defines the current optimizer
  64019. * @returns true if everything that can be done was applied
  64020. */
  64021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64022. }
  64023. /**
  64024. * Defines an optimization used to turn lens flares off
  64025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64026. */
  64027. export class LensFlaresOptimization extends SceneOptimization {
  64028. /**
  64029. * Gets a string describing the action executed by the current optimization
  64030. * @return description string
  64031. */
  64032. getDescription(): string;
  64033. /**
  64034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64035. * @param scene defines the current scene where to apply this optimization
  64036. * @param optimizer defines the current optimizer
  64037. * @returns true if everything that can be done was applied
  64038. */
  64039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64040. }
  64041. /**
  64042. * Defines an optimization based on user defined callback.
  64043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64044. */
  64045. export class CustomOptimization extends SceneOptimization {
  64046. /**
  64047. * Callback called to apply the custom optimization.
  64048. */
  64049. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64050. /**
  64051. * Callback called to get custom description
  64052. */
  64053. onGetDescription: () => string;
  64054. /**
  64055. * Gets a string describing the action executed by the current optimization
  64056. * @returns description string
  64057. */
  64058. getDescription(): string;
  64059. /**
  64060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64061. * @param scene defines the current scene where to apply this optimization
  64062. * @param optimizer defines the current optimizer
  64063. * @returns true if everything that can be done was applied
  64064. */
  64065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64066. }
  64067. /**
  64068. * Defines an optimization used to turn particles off
  64069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64070. */
  64071. export class ParticlesOptimization extends SceneOptimization {
  64072. /**
  64073. * Gets a string describing the action executed by the current optimization
  64074. * @return description string
  64075. */
  64076. getDescription(): string;
  64077. /**
  64078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64079. * @param scene defines the current scene where to apply this optimization
  64080. * @param optimizer defines the current optimizer
  64081. * @returns true if everything that can be done was applied
  64082. */
  64083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64084. }
  64085. /**
  64086. * Defines an optimization used to turn render targets off
  64087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64088. */
  64089. export class RenderTargetsOptimization extends SceneOptimization {
  64090. /**
  64091. * Gets a string describing the action executed by the current optimization
  64092. * @return description string
  64093. */
  64094. getDescription(): string;
  64095. /**
  64096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64097. * @param scene defines the current scene where to apply this optimization
  64098. * @param optimizer defines the current optimizer
  64099. * @returns true if everything that can be done was applied
  64100. */
  64101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64102. }
  64103. /**
  64104. * Defines an optimization used to merge meshes with compatible materials
  64105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64106. */
  64107. export class MergeMeshesOptimization extends SceneOptimization {
  64108. private static _UpdateSelectionTree;
  64109. /**
  64110. * Gets or sets a boolean which defines if optimization octree has to be updated
  64111. */
  64112. /**
  64113. * Gets or sets a boolean which defines if optimization octree has to be updated
  64114. */
  64115. static UpdateSelectionTree: boolean;
  64116. /**
  64117. * Gets a string describing the action executed by the current optimization
  64118. * @return description string
  64119. */
  64120. getDescription(): string;
  64121. private _canBeMerged;
  64122. /**
  64123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64124. * @param scene defines the current scene where to apply this optimization
  64125. * @param optimizer defines the current optimizer
  64126. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64127. * @returns true if everything that can be done was applied
  64128. */
  64129. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64130. }
  64131. /**
  64132. * Defines a list of options used by SceneOptimizer
  64133. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64134. */
  64135. export class SceneOptimizerOptions {
  64136. /**
  64137. * Defines the target frame rate to reach (60 by default)
  64138. */
  64139. targetFrameRate: number;
  64140. /**
  64141. * Defines the interval between two checkes (2000ms by default)
  64142. */
  64143. trackerDuration: number;
  64144. /**
  64145. * Gets the list of optimizations to apply
  64146. */
  64147. optimizations: SceneOptimization[];
  64148. /**
  64149. * Creates a new list of options used by SceneOptimizer
  64150. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64151. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64152. */
  64153. constructor(
  64154. /**
  64155. * Defines the target frame rate to reach (60 by default)
  64156. */
  64157. targetFrameRate?: number,
  64158. /**
  64159. * Defines the interval between two checkes (2000ms by default)
  64160. */
  64161. trackerDuration?: number);
  64162. /**
  64163. * Add a new optimization
  64164. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64165. * @returns the current SceneOptimizerOptions
  64166. */
  64167. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64168. /**
  64169. * Add a new custom optimization
  64170. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64171. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64172. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64173. * @returns the current SceneOptimizerOptions
  64174. */
  64175. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64176. /**
  64177. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64178. * @param targetFrameRate defines the target frame rate (60 by default)
  64179. * @returns a SceneOptimizerOptions object
  64180. */
  64181. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64182. /**
  64183. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64184. * @param targetFrameRate defines the target frame rate (60 by default)
  64185. * @returns a SceneOptimizerOptions object
  64186. */
  64187. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64188. /**
  64189. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64190. * @param targetFrameRate defines the target frame rate (60 by default)
  64191. * @returns a SceneOptimizerOptions object
  64192. */
  64193. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64194. }
  64195. /**
  64196. * Class used to run optimizations in order to reach a target frame rate
  64197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64198. */
  64199. export class SceneOptimizer implements IDisposable {
  64200. private _isRunning;
  64201. private _options;
  64202. private _scene;
  64203. private _currentPriorityLevel;
  64204. private _targetFrameRate;
  64205. private _trackerDuration;
  64206. private _currentFrameRate;
  64207. private _sceneDisposeObserver;
  64208. private _improvementMode;
  64209. /**
  64210. * Defines an observable called when the optimizer reaches the target frame rate
  64211. */
  64212. onSuccessObservable: Observable<SceneOptimizer>;
  64213. /**
  64214. * Defines an observable called when the optimizer enables an optimization
  64215. */
  64216. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64217. /**
  64218. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64219. */
  64220. onFailureObservable: Observable<SceneOptimizer>;
  64221. /**
  64222. * Gets a boolean indicating if the optimizer is in improvement mode
  64223. */
  64224. readonly isInImprovementMode: boolean;
  64225. /**
  64226. * Gets the current priority level (0 at start)
  64227. */
  64228. readonly currentPriorityLevel: number;
  64229. /**
  64230. * Gets the current frame rate checked by the SceneOptimizer
  64231. */
  64232. readonly currentFrameRate: number;
  64233. /**
  64234. * Gets or sets the current target frame rate (60 by default)
  64235. */
  64236. /**
  64237. * Gets or sets the current target frame rate (60 by default)
  64238. */
  64239. targetFrameRate: number;
  64240. /**
  64241. * Gets or sets the current interval between two checks (every 2000ms by default)
  64242. */
  64243. /**
  64244. * Gets or sets the current interval between two checks (every 2000ms by default)
  64245. */
  64246. trackerDuration: number;
  64247. /**
  64248. * Gets the list of active optimizations
  64249. */
  64250. readonly optimizations: SceneOptimization[];
  64251. /**
  64252. * Creates a new SceneOptimizer
  64253. * @param scene defines the scene to work on
  64254. * @param options defines the options to use with the SceneOptimizer
  64255. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64256. * @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)
  64257. */
  64258. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64259. /**
  64260. * Stops the current optimizer
  64261. */
  64262. stop(): void;
  64263. /**
  64264. * Reset the optimizer to initial step (current priority level = 0)
  64265. */
  64266. reset(): void;
  64267. /**
  64268. * Start the optimizer. By default it will try to reach a specific framerate
  64269. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64270. */
  64271. start(): void;
  64272. private _checkCurrentState;
  64273. /**
  64274. * Release all resources
  64275. */
  64276. dispose(): void;
  64277. /**
  64278. * Helper function to create a SceneOptimizer with one single line of code
  64279. * @param scene defines the scene to work on
  64280. * @param options defines the options to use with the SceneOptimizer
  64281. * @param onSuccess defines a callback to call on success
  64282. * @param onFailure defines a callback to call on failure
  64283. * @returns the new SceneOptimizer object
  64284. */
  64285. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /**
  64290. * Class used to serialize a scene into a string
  64291. */
  64292. export class SceneSerializer {
  64293. /**
  64294. * Clear cache used by a previous serialization
  64295. */
  64296. static ClearCache(): void;
  64297. /**
  64298. * Serialize a scene into a JSON compatible object
  64299. * @param scene defines the scene to serialize
  64300. * @returns a JSON compatible object
  64301. */
  64302. static Serialize(scene: Scene): any;
  64303. /**
  64304. * Serialize a mesh into a JSON compatible object
  64305. * @param toSerialize defines the mesh to serialize
  64306. * @param withParents defines if parents must be serialized as well
  64307. * @param withChildren defines if children must be serialized as well
  64308. * @returns a JSON compatible object
  64309. */
  64310. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Class used to host texture specific utilities
  64316. */
  64317. export class TextureTools {
  64318. /**
  64319. * Uses the GPU to create a copy texture rescaled at a given size
  64320. * @param texture Texture to copy from
  64321. * @param width defines the desired width
  64322. * @param height defines the desired height
  64323. * @param useBilinearMode defines if bilinear mode has to be used
  64324. * @return the generated texture
  64325. */
  64326. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64327. }
  64328. }
  64329. declare module BABYLON {
  64330. /**
  64331. * This represents the different options available for the video capture.
  64332. */
  64333. export interface VideoRecorderOptions {
  64334. /** Defines the mime type of the video. */
  64335. mimeType: string;
  64336. /** Defines the FPS the video should be recorded at. */
  64337. fps: number;
  64338. /** Defines the chunk size for the recording data. */
  64339. recordChunckSize: number;
  64340. /** The audio tracks to attach to the recording. */
  64341. audioTracks?: MediaStreamTrack[];
  64342. }
  64343. /**
  64344. * This can help with recording videos from BabylonJS.
  64345. * This is based on the available WebRTC functionalities of the browser.
  64346. *
  64347. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64348. */
  64349. export class VideoRecorder {
  64350. private static readonly _defaultOptions;
  64351. /**
  64352. * Returns whether or not the VideoRecorder is available in your browser.
  64353. * @param engine Defines the Babylon Engine.
  64354. * @returns true if supported otherwise false.
  64355. */
  64356. static IsSupported(engine: Engine): boolean;
  64357. private readonly _options;
  64358. private _canvas;
  64359. private _mediaRecorder;
  64360. private _recordedChunks;
  64361. private _fileName;
  64362. private _resolve;
  64363. private _reject;
  64364. /**
  64365. * True when a recording is already in progress.
  64366. */
  64367. readonly isRecording: boolean;
  64368. /**
  64369. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64370. * @param engine Defines the BabylonJS Engine you wish to record.
  64371. * @param options Defines options that can be used to customize the capture.
  64372. */
  64373. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64374. /**
  64375. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64376. */
  64377. stopRecording(): void;
  64378. /**
  64379. * Starts recording the canvas for a max duration specified in parameters.
  64380. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64381. * If null no automatic download will start and you can rely on the promise to get the data back.
  64382. * @param maxDuration Defines the maximum recording time in seconds.
  64383. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64384. * @return A promise callback at the end of the recording with the video data in Blob.
  64385. */
  64386. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64387. /**
  64388. * Releases internal resources used during the recording.
  64389. */
  64390. dispose(): void;
  64391. private _handleDataAvailable;
  64392. private _handleError;
  64393. private _handleStop;
  64394. }
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * Class containing a set of static utilities functions for screenshots
  64399. */
  64400. export class ScreenshotTools {
  64401. /**
  64402. * Captures a screenshot of the current rendering
  64403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64404. * @param engine defines the rendering engine
  64405. * @param camera defines the source camera
  64406. * @param size This parameter can be set to a single number or to an object with the
  64407. * following (optional) properties: precision, width, height. If a single number is passed,
  64408. * it will be used for both width and height. If an object is passed, the screenshot size
  64409. * will be derived from the parameters. The precision property is a multiplier allowing
  64410. * rendering at a higher or lower resolution
  64411. * @param successCallback defines the callback receives a single parameter which contains the
  64412. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64413. * src parameter of an <img> to display it
  64414. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64415. * Check your browser for supported MIME types
  64416. */
  64417. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64418. /**
  64419. * Captures a screenshot of the current rendering
  64420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64421. * @param engine defines the rendering engine
  64422. * @param camera defines the source camera
  64423. * @param size This parameter can be set to a single number or to an object with the
  64424. * following (optional) properties: precision, width, height. If a single number is passed,
  64425. * it will be used for both width and height. If an object is passed, the screenshot size
  64426. * will be derived from the parameters. The precision property is a multiplier allowing
  64427. * rendering at a higher or lower resolution
  64428. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64429. * Check your browser for supported MIME types
  64430. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64431. * to the src parameter of an <img> to display it
  64432. */
  64433. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64434. /**
  64435. * Generates an image screenshot from the specified camera.
  64436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64437. * @param engine The engine to use for rendering
  64438. * @param camera The camera to use for rendering
  64439. * @param size This parameter can be set to a single number or to an object with the
  64440. * following (optional) properties: precision, width, height. If a single number is passed,
  64441. * it will be used for both width and height. If an object is passed, the screenshot size
  64442. * will be derived from the parameters. The precision property is a multiplier allowing
  64443. * rendering at a higher or lower resolution
  64444. * @param successCallback The callback receives a single parameter which contains the
  64445. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64446. * src parameter of an <img> to display it
  64447. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64448. * Check your browser for supported MIME types
  64449. * @param samples Texture samples (default: 1)
  64450. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64451. * @param fileName A name for for the downloaded file.
  64452. */
  64453. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64454. /**
  64455. * Generates an image screenshot from the specified camera.
  64456. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64457. * @param engine The engine to use for rendering
  64458. * @param camera The camera to use for rendering
  64459. * @param size This parameter can be set to a single number or to an object with the
  64460. * following (optional) properties: precision, width, height. If a single number is passed,
  64461. * it will be used for both width and height. If an object is passed, the screenshot size
  64462. * will be derived from the parameters. The precision property is a multiplier allowing
  64463. * rendering at a higher or lower resolution
  64464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64465. * Check your browser for supported MIME types
  64466. * @param samples Texture samples (default: 1)
  64467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64468. * @param fileName A name for for the downloaded file.
  64469. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64470. * to the src parameter of an <img> to display it
  64471. */
  64472. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64473. /**
  64474. * Gets height and width for screenshot size
  64475. * @private
  64476. */
  64477. private static _getScreenshotSize;
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Interface for a data buffer
  64483. */
  64484. export interface IDataBuffer {
  64485. /**
  64486. * Reads bytes from the data buffer.
  64487. * @param byteOffset The byte offset to read
  64488. * @param byteLength The byte length to read
  64489. * @returns A promise that resolves when the bytes are read
  64490. */
  64491. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64492. /**
  64493. * The byte length of the buffer.
  64494. */
  64495. readonly byteLength: number;
  64496. }
  64497. /**
  64498. * Utility class for reading from a data buffer
  64499. */
  64500. export class DataReader {
  64501. /**
  64502. * The data buffer associated with this data reader.
  64503. */
  64504. readonly buffer: IDataBuffer;
  64505. /**
  64506. * The current byte offset from the beginning of the data buffer.
  64507. */
  64508. byteOffset: number;
  64509. private _dataView;
  64510. private _dataByteOffset;
  64511. /**
  64512. * Constructor
  64513. * @param buffer The buffer to read
  64514. */
  64515. constructor(buffer: IDataBuffer);
  64516. /**
  64517. * Loads the given byte length.
  64518. * @param byteLength The byte length to load
  64519. * @returns A promise that resolves when the load is complete
  64520. */
  64521. loadAsync(byteLength: number): Promise<void>;
  64522. /**
  64523. * Read a unsigned 32-bit integer from the currently loaded data range.
  64524. * @returns The 32-bit integer read
  64525. */
  64526. readUint32(): number;
  64527. /**
  64528. * Read a byte array from the currently loaded data range.
  64529. * @param byteLength The byte length to read
  64530. * @returns The byte array read
  64531. */
  64532. readUint8Array(byteLength: number): Uint8Array;
  64533. /**
  64534. * Read a string from the currently loaded data range.
  64535. * @param byteLength The byte length to read
  64536. * @returns The string read
  64537. */
  64538. readString(byteLength: number): string;
  64539. /**
  64540. * Skips the given byte length the currently loaded data range.
  64541. * @param byteLength The byte length to skip
  64542. */
  64543. skipBytes(byteLength: number): void;
  64544. }
  64545. }
  64546. declare module BABYLON {
  64547. /**
  64548. * A cursor which tracks a point on a path
  64549. */
  64550. export class PathCursor {
  64551. private path;
  64552. /**
  64553. * Stores path cursor callbacks for when an onchange event is triggered
  64554. */
  64555. private _onchange;
  64556. /**
  64557. * The value of the path cursor
  64558. */
  64559. value: number;
  64560. /**
  64561. * The animation array of the path cursor
  64562. */
  64563. animations: Animation[];
  64564. /**
  64565. * Initializes the path cursor
  64566. * @param path The path to track
  64567. */
  64568. constructor(path: Path2);
  64569. /**
  64570. * Gets the cursor point on the path
  64571. * @returns A point on the path cursor at the cursor location
  64572. */
  64573. getPoint(): Vector3;
  64574. /**
  64575. * Moves the cursor ahead by the step amount
  64576. * @param step The amount to move the cursor forward
  64577. * @returns This path cursor
  64578. */
  64579. moveAhead(step?: number): PathCursor;
  64580. /**
  64581. * Moves the cursor behind by the step amount
  64582. * @param step The amount to move the cursor back
  64583. * @returns This path cursor
  64584. */
  64585. moveBack(step?: number): PathCursor;
  64586. /**
  64587. * Moves the cursor by the step amount
  64588. * If the step amount is greater than one, an exception is thrown
  64589. * @param step The amount to move the cursor
  64590. * @returns This path cursor
  64591. */
  64592. move(step: number): PathCursor;
  64593. /**
  64594. * Ensures that the value is limited between zero and one
  64595. * @returns This path cursor
  64596. */
  64597. private ensureLimits;
  64598. /**
  64599. * Runs onchange callbacks on change (used by the animation engine)
  64600. * @returns This path cursor
  64601. */
  64602. private raiseOnChange;
  64603. /**
  64604. * Executes a function on change
  64605. * @param f A path cursor onchange callback
  64606. * @returns This path cursor
  64607. */
  64608. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64609. }
  64610. }
  64611. declare module BABYLON {
  64612. /** @hidden */
  64613. export var blurPixelShader: {
  64614. name: string;
  64615. shader: string;
  64616. };
  64617. }
  64618. declare module BABYLON {
  64619. /** @hidden */
  64620. export var pointCloudVertexDeclaration: {
  64621. name: string;
  64622. shader: string;
  64623. };
  64624. }
  64625. // Mixins
  64626. interface Window {
  64627. mozIndexedDB: IDBFactory;
  64628. webkitIndexedDB: IDBFactory;
  64629. msIndexedDB: IDBFactory;
  64630. webkitURL: typeof URL;
  64631. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64632. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64633. WebGLRenderingContext: WebGLRenderingContext;
  64634. MSGesture: MSGesture;
  64635. CANNON: any;
  64636. AudioContext: AudioContext;
  64637. webkitAudioContext: AudioContext;
  64638. PointerEvent: any;
  64639. Math: Math;
  64640. Uint8Array: Uint8ArrayConstructor;
  64641. Float32Array: Float32ArrayConstructor;
  64642. mozURL: typeof URL;
  64643. msURL: typeof URL;
  64644. VRFrameData: any; // WebVR, from specs 1.1
  64645. DracoDecoderModule: any;
  64646. setImmediate(handler: (...args: any[]) => void): number;
  64647. }
  64648. interface HTMLCanvasElement {
  64649. requestPointerLock(): void;
  64650. msRequestPointerLock?(): void;
  64651. mozRequestPointerLock?(): void;
  64652. webkitRequestPointerLock?(): void;
  64653. /** Track wether a record is in progress */
  64654. isRecording: boolean;
  64655. /** Capture Stream method defined by some browsers */
  64656. captureStream(fps?: number): MediaStream;
  64657. }
  64658. interface CanvasRenderingContext2D {
  64659. msImageSmoothingEnabled: boolean;
  64660. }
  64661. interface MouseEvent {
  64662. mozMovementX: number;
  64663. mozMovementY: number;
  64664. webkitMovementX: number;
  64665. webkitMovementY: number;
  64666. msMovementX: number;
  64667. msMovementY: number;
  64668. }
  64669. interface Navigator {
  64670. mozGetVRDevices: (any: any) => any;
  64671. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64672. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64673. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64674. webkitGetGamepads(): Gamepad[];
  64675. msGetGamepads(): Gamepad[];
  64676. webkitGamepads(): Gamepad[];
  64677. }
  64678. interface HTMLVideoElement {
  64679. mozSrcObject: any;
  64680. }
  64681. interface Math {
  64682. fround(x: number): number;
  64683. imul(a: number, b: number): number;
  64684. }
  64685. interface WebGLRenderingContext {
  64686. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64687. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64688. vertexAttribDivisor(index: number, divisor: number): void;
  64689. createVertexArray(): any;
  64690. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64691. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64692. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64693. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64694. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64695. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64696. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64697. // Queries
  64698. createQuery(): WebGLQuery;
  64699. deleteQuery(query: WebGLQuery): void;
  64700. beginQuery(target: number, query: WebGLQuery): void;
  64701. endQuery(target: number): void;
  64702. getQueryParameter(query: WebGLQuery, pname: number): any;
  64703. getQuery(target: number, pname: number): any;
  64704. MAX_SAMPLES: number;
  64705. RGBA8: number;
  64706. READ_FRAMEBUFFER: number;
  64707. DRAW_FRAMEBUFFER: number;
  64708. UNIFORM_BUFFER: number;
  64709. HALF_FLOAT_OES: number;
  64710. RGBA16F: number;
  64711. RGBA32F: number;
  64712. R32F: number;
  64713. RG32F: number;
  64714. RGB32F: number;
  64715. R16F: number;
  64716. RG16F: number;
  64717. RGB16F: number;
  64718. RED: number;
  64719. RG: number;
  64720. R8: number;
  64721. RG8: number;
  64722. UNSIGNED_INT_24_8: number;
  64723. DEPTH24_STENCIL8: number;
  64724. MIN: number;
  64725. MAX: number;
  64726. /* Multiple Render Targets */
  64727. drawBuffers(buffers: number[]): void;
  64728. readBuffer(src: number): void;
  64729. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64730. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64731. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64732. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64733. // Occlusion Query
  64734. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64735. ANY_SAMPLES_PASSED: number;
  64736. QUERY_RESULT_AVAILABLE: number;
  64737. QUERY_RESULT: number;
  64738. }
  64739. interface WebGLProgram {
  64740. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64741. }
  64742. interface EXT_disjoint_timer_query {
  64743. QUERY_COUNTER_BITS_EXT: number;
  64744. TIME_ELAPSED_EXT: number;
  64745. TIMESTAMP_EXT: number;
  64746. GPU_DISJOINT_EXT: number;
  64747. QUERY_RESULT_EXT: number;
  64748. QUERY_RESULT_AVAILABLE_EXT: number;
  64749. queryCounterEXT(query: WebGLQuery, target: number): void;
  64750. createQueryEXT(): WebGLQuery;
  64751. beginQueryEXT(target: number, query: WebGLQuery): void;
  64752. endQueryEXT(target: number): void;
  64753. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64754. deleteQueryEXT(query: WebGLQuery): void;
  64755. }
  64756. interface WebGLUniformLocation {
  64757. _currentState: any;
  64758. }
  64759. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64760. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64761. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64762. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64763. interface WebGLRenderingContext {
  64764. readonly RASTERIZER_DISCARD: number;
  64765. readonly DEPTH_COMPONENT24: number;
  64766. readonly TEXTURE_3D: number;
  64767. readonly TEXTURE_2D_ARRAY: number;
  64768. readonly TEXTURE_COMPARE_FUNC: number;
  64769. readonly TEXTURE_COMPARE_MODE: number;
  64770. readonly COMPARE_REF_TO_TEXTURE: number;
  64771. readonly TEXTURE_WRAP_R: number;
  64772. readonly HALF_FLOAT: number;
  64773. readonly RGB8: number;
  64774. readonly RED_INTEGER: number;
  64775. readonly RG_INTEGER: number;
  64776. readonly RGB_INTEGER: number;
  64777. readonly RGBA_INTEGER: number;
  64778. readonly R8_SNORM: number;
  64779. readonly RG8_SNORM: number;
  64780. readonly RGB8_SNORM: number;
  64781. readonly RGBA8_SNORM: number;
  64782. readonly R8I: number;
  64783. readonly RG8I: number;
  64784. readonly RGB8I: number;
  64785. readonly RGBA8I: number;
  64786. readonly R8UI: number;
  64787. readonly RG8UI: number;
  64788. readonly RGB8UI: number;
  64789. readonly RGBA8UI: number;
  64790. readonly R16I: number;
  64791. readonly RG16I: number;
  64792. readonly RGB16I: number;
  64793. readonly RGBA16I: number;
  64794. readonly R16UI: number;
  64795. readonly RG16UI: number;
  64796. readonly RGB16UI: number;
  64797. readonly RGBA16UI: number;
  64798. readonly R32I: number;
  64799. readonly RG32I: number;
  64800. readonly RGB32I: number;
  64801. readonly RGBA32I: number;
  64802. readonly R32UI: number;
  64803. readonly RG32UI: number;
  64804. readonly RGB32UI: number;
  64805. readonly RGBA32UI: number;
  64806. readonly RGB10_A2UI: number;
  64807. readonly R11F_G11F_B10F: number;
  64808. readonly RGB9_E5: number;
  64809. readonly RGB10_A2: number;
  64810. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64811. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64812. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64813. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64814. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64815. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64816. 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;
  64817. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64818. readonly TRANSFORM_FEEDBACK: number;
  64819. readonly INTERLEAVED_ATTRIBS: number;
  64820. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64821. createTransformFeedback(): WebGLTransformFeedback;
  64822. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64823. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64824. beginTransformFeedback(primitiveMode: number): void;
  64825. endTransformFeedback(): void;
  64826. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64827. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64828. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64829. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64830. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64831. }
  64832. interface ImageBitmap {
  64833. readonly width: number;
  64834. readonly height: number;
  64835. close(): void;
  64836. }
  64837. interface WebGLQuery extends WebGLObject {
  64838. }
  64839. declare var WebGLQuery: {
  64840. prototype: WebGLQuery;
  64841. new(): WebGLQuery;
  64842. };
  64843. interface WebGLSampler extends WebGLObject {
  64844. }
  64845. declare var WebGLSampler: {
  64846. prototype: WebGLSampler;
  64847. new(): WebGLSampler;
  64848. };
  64849. interface WebGLSync extends WebGLObject {
  64850. }
  64851. declare var WebGLSync: {
  64852. prototype: WebGLSync;
  64853. new(): WebGLSync;
  64854. };
  64855. interface WebGLTransformFeedback extends WebGLObject {
  64856. }
  64857. declare var WebGLTransformFeedback: {
  64858. prototype: WebGLTransformFeedback;
  64859. new(): WebGLTransformFeedback;
  64860. };
  64861. interface WebGLVertexArrayObject extends WebGLObject {
  64862. }
  64863. declare var WebGLVertexArrayObject: {
  64864. prototype: WebGLVertexArrayObject;
  64865. new(): WebGLVertexArrayObject;
  64866. };
  64867. // Type definitions for WebVR API
  64868. // Project: https://w3c.github.io/webvr/
  64869. // Definitions by: six a <https://github.com/lostfictions>
  64870. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64871. interface VRDisplay extends EventTarget {
  64872. /**
  64873. * Dictionary of capabilities describing the VRDisplay.
  64874. */
  64875. readonly capabilities: VRDisplayCapabilities;
  64876. /**
  64877. * z-depth defining the far plane of the eye view frustum
  64878. * enables mapping of values in the render target depth
  64879. * attachment to scene coordinates. Initially set to 10000.0.
  64880. */
  64881. depthFar: number;
  64882. /**
  64883. * z-depth defining the near plane of the eye view frustum
  64884. * enables mapping of values in the render target depth
  64885. * attachment to scene coordinates. Initially set to 0.01.
  64886. */
  64887. depthNear: number;
  64888. /**
  64889. * An identifier for this distinct VRDisplay. Used as an
  64890. * association point in the Gamepad API.
  64891. */
  64892. readonly displayId: number;
  64893. /**
  64894. * A display name, a user-readable name identifying it.
  64895. */
  64896. readonly displayName: string;
  64897. readonly isConnected: boolean;
  64898. readonly isPresenting: boolean;
  64899. /**
  64900. * If this VRDisplay supports room-scale experiences, the optional
  64901. * stage attribute contains details on the room-scale parameters.
  64902. */
  64903. readonly stageParameters: VRStageParameters | null;
  64904. /**
  64905. * Passing the value returned by `requestAnimationFrame` to
  64906. * `cancelAnimationFrame` will unregister the callback.
  64907. * @param handle Define the hanle of the request to cancel
  64908. */
  64909. cancelAnimationFrame(handle: number): void;
  64910. /**
  64911. * Stops presenting to the VRDisplay.
  64912. * @returns a promise to know when it stopped
  64913. */
  64914. exitPresent(): Promise<void>;
  64915. /**
  64916. * Return the current VREyeParameters for the given eye.
  64917. * @param whichEye Define the eye we want the parameter for
  64918. * @returns the eye parameters
  64919. */
  64920. getEyeParameters(whichEye: string): VREyeParameters;
  64921. /**
  64922. * Populates the passed VRFrameData with the information required to render
  64923. * the current frame.
  64924. * @param frameData Define the data structure to populate
  64925. * @returns true if ok otherwise false
  64926. */
  64927. getFrameData(frameData: VRFrameData): boolean;
  64928. /**
  64929. * Get the layers currently being presented.
  64930. * @returns the list of VR layers
  64931. */
  64932. getLayers(): VRLayer[];
  64933. /**
  64934. * Return a VRPose containing the future predicted pose of the VRDisplay
  64935. * when the current frame will be presented. The value returned will not
  64936. * change until JavaScript has returned control to the browser.
  64937. *
  64938. * The VRPose will contain the position, orientation, velocity,
  64939. * and acceleration of each of these properties.
  64940. * @returns the pose object
  64941. */
  64942. getPose(): VRPose;
  64943. /**
  64944. * Return the current instantaneous pose of the VRDisplay, with no
  64945. * prediction applied.
  64946. * @returns the current instantaneous pose
  64947. */
  64948. getImmediatePose(): VRPose;
  64949. /**
  64950. * The callback passed to `requestAnimationFrame` will be called
  64951. * any time a new frame should be rendered. When the VRDisplay is
  64952. * presenting the callback will be called at the native refresh
  64953. * rate of the HMD. When not presenting this function acts
  64954. * identically to how window.requestAnimationFrame acts. Content should
  64955. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64956. * asynchronously from other displays and at differing refresh rates.
  64957. * @param callback Define the eaction to run next frame
  64958. * @returns the request handle it
  64959. */
  64960. requestAnimationFrame(callback: FrameRequestCallback): number;
  64961. /**
  64962. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64963. * Repeat calls while already presenting will update the VRLayers being displayed.
  64964. * @param layers Define the list of layer to present
  64965. * @returns a promise to know when the request has been fulfilled
  64966. */
  64967. requestPresent(layers: VRLayer[]): Promise<void>;
  64968. /**
  64969. * Reset the pose for this display, treating its current position and
  64970. * orientation as the "origin/zero" values. VRPose.position,
  64971. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64972. * updated when calling resetPose(). This should be called in only
  64973. * sitting-space experiences.
  64974. */
  64975. resetPose(): void;
  64976. /**
  64977. * The VRLayer provided to the VRDisplay will be captured and presented
  64978. * in the HMD. Calling this function has the same effect on the source
  64979. * canvas as any other operation that uses its source image, and canvases
  64980. * created without preserveDrawingBuffer set to true will be cleared.
  64981. * @param pose Define the pose to submit
  64982. */
  64983. submitFrame(pose?: VRPose): void;
  64984. }
  64985. declare var VRDisplay: {
  64986. prototype: VRDisplay;
  64987. new(): VRDisplay;
  64988. };
  64989. interface VRLayer {
  64990. leftBounds?: number[] | Float32Array | null;
  64991. rightBounds?: number[] | Float32Array | null;
  64992. source?: HTMLCanvasElement | null;
  64993. }
  64994. interface VRDisplayCapabilities {
  64995. readonly canPresent: boolean;
  64996. readonly hasExternalDisplay: boolean;
  64997. readonly hasOrientation: boolean;
  64998. readonly hasPosition: boolean;
  64999. readonly maxLayers: number;
  65000. }
  65001. interface VREyeParameters {
  65002. /** @deprecated */
  65003. readonly fieldOfView: VRFieldOfView;
  65004. readonly offset: Float32Array;
  65005. readonly renderHeight: number;
  65006. readonly renderWidth: number;
  65007. }
  65008. interface VRFieldOfView {
  65009. readonly downDegrees: number;
  65010. readonly leftDegrees: number;
  65011. readonly rightDegrees: number;
  65012. readonly upDegrees: number;
  65013. }
  65014. interface VRFrameData {
  65015. readonly leftProjectionMatrix: Float32Array;
  65016. readonly leftViewMatrix: Float32Array;
  65017. readonly pose: VRPose;
  65018. readonly rightProjectionMatrix: Float32Array;
  65019. readonly rightViewMatrix: Float32Array;
  65020. readonly timestamp: number;
  65021. }
  65022. interface VRPose {
  65023. readonly angularAcceleration: Float32Array | null;
  65024. readonly angularVelocity: Float32Array | null;
  65025. readonly linearAcceleration: Float32Array | null;
  65026. readonly linearVelocity: Float32Array | null;
  65027. readonly orientation: Float32Array | null;
  65028. readonly position: Float32Array | null;
  65029. readonly timestamp: number;
  65030. }
  65031. interface VRStageParameters {
  65032. sittingToStandingTransform?: Float32Array;
  65033. sizeX?: number;
  65034. sizeY?: number;
  65035. }
  65036. interface Navigator {
  65037. getVRDisplays(): Promise<VRDisplay[]>;
  65038. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  65039. }
  65040. interface Window {
  65041. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  65042. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  65043. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  65044. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65045. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  65046. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  65047. }
  65048. interface Gamepad {
  65049. readonly displayId: number;
  65050. }
  65051. type XRSessionMode =
  65052. | "inline"
  65053. | "immersive-vr"
  65054. | "immersive-ar";
  65055. type XRReferenceSpaceType =
  65056. | "viewer"
  65057. | "local"
  65058. | "local-floor"
  65059. | "bounded-floor"
  65060. | "unbounded";
  65061. type XREnvironmentBlendMode =
  65062. | "opaque"
  65063. | "additive"
  65064. | "alpha-blend";
  65065. type XRVisibilityState =
  65066. | "visible"
  65067. | "visible-blurred"
  65068. | "hidden";
  65069. type XRHandedness =
  65070. | "none"
  65071. | "left"
  65072. | "right";
  65073. type XRTargetRayMode =
  65074. | "gaze"
  65075. | "tracked-pointer"
  65076. | "screen";
  65077. type XREye =
  65078. | "none"
  65079. | "left"
  65080. | "right";
  65081. interface XRSpace extends EventTarget {
  65082. }
  65083. interface XRRenderState {
  65084. depthNear?: number;
  65085. depthFar?: number;
  65086. inlineVerticalFieldOfView?: number;
  65087. baseLayer?: XRWebGLLayer;
  65088. }
  65089. interface XRInputSource {
  65090. handedness: XRHandedness;
  65091. targetRayMode: XRTargetRayMode;
  65092. targetRaySpace: XRSpace;
  65093. gripSpace: XRSpace | undefined;
  65094. gamepad: Gamepad | undefined;
  65095. profiles: Array<string>;
  65096. }
  65097. interface XRSession {
  65098. addEventListener: Function;
  65099. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  65100. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  65101. requestAnimationFrame: Function;
  65102. end(): Promise<void>;
  65103. renderState: XRRenderState;
  65104. inputSources: Array<XRInputSource>;
  65105. }
  65106. interface XRReferenceSpace extends XRSpace {
  65107. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  65108. onreset: any;
  65109. }
  65110. interface XRFrame {
  65111. session: XRSession;
  65112. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  65113. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  65114. }
  65115. interface XRViewerPose extends XRPose {
  65116. views: Array<XRView>;
  65117. }
  65118. interface XRPose {
  65119. transform: XRRigidTransform;
  65120. emulatedPosition: boolean;
  65121. }
  65122. interface XRWebGLLayerOptions {
  65123. antialias ?: boolean;
  65124. depth ?: boolean;
  65125. stencil ?: boolean;
  65126. alpha ?: boolean;
  65127. multiview ?: boolean;
  65128. framebufferScaleFactor ?: number;
  65129. }
  65130. declare var XRWebGLLayer: {
  65131. prototype: XRWebGLLayer;
  65132. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  65133. };
  65134. interface XRWebGLLayer {
  65135. framebuffer: WebGLFramebuffer;
  65136. framebufferWidth: number;
  65137. framebufferHeight: number;
  65138. getViewport: Function;
  65139. }
  65140. interface XRRigidTransform {
  65141. position: DOMPointReadOnly;
  65142. orientation: DOMPointReadOnly;
  65143. matrix: Float32Array;
  65144. inverse: XRRigidTransform;
  65145. }
  65146. interface XRView {
  65147. eye: XREye;
  65148. projectionMatrix: Float32Array;
  65149. transform: XRRigidTransform;
  65150. }
  65151. interface XRInputSourceChangeEvent {
  65152. session: XRSession;
  65153. removed: Array<XRInputSource>;
  65154. added: Array<XRInputSource>;
  65155. }