documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975
  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. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. /**
  497. * Sets the value of a request header.
  498. * @param name The name of the header whose value is to be set
  499. * @param value The value to set as the body of the header
  500. */
  501. setRequestHeader(name: string, value: string): void;
  502. /**
  503. * Get the string containing the text of a particular header's value.
  504. * @param name The name of the header
  505. * @returns The string containing the text of the given header name
  506. */
  507. getResponseHeader(name: string): Nullable<string>;
  508. }
  509. }
  510. declare module BABYLON {
  511. /**
  512. * File request interface
  513. */
  514. export interface IFileRequest {
  515. /**
  516. * Raised when the request is complete (success or error).
  517. */
  518. onCompleteObservable: Observable<IFileRequest>;
  519. /**
  520. * Aborts the request for a file.
  521. */
  522. abort: () => void;
  523. }
  524. }
  525. declare module BABYLON {
  526. /**
  527. * Define options used to create a render target texture
  528. */
  529. export class RenderTargetCreationOptions {
  530. /**
  531. * Specifies is mipmaps must be generated
  532. */
  533. generateMipMaps?: boolean;
  534. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  535. generateDepthBuffer?: boolean;
  536. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  537. generateStencilBuffer?: boolean;
  538. /** Defines texture type (int by default) */
  539. type?: number;
  540. /** Defines sampling mode (trilinear by default) */
  541. samplingMode?: number;
  542. /** Defines format (RGBA by default) */
  543. format?: number;
  544. }
  545. }
  546. declare module BABYLON {
  547. /**
  548. * @hidden
  549. **/
  550. export class _TimeToken {
  551. _startTimeQuery: Nullable<WebGLQuery>;
  552. _endTimeQuery: Nullable<WebGLQuery>;
  553. _timeElapsedQuery: Nullable<WebGLQuery>;
  554. _timeElapsedQueryEnded: boolean;
  555. }
  556. }
  557. declare module BABYLON {
  558. /** Defines the cross module used constants to avoid circular dependncies */
  559. export class Constants {
  560. /** Defines that alpha blending is disabled */
  561. static readonly ALPHA_DISABLE: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  563. static readonly ALPHA_ADD: number;
  564. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  565. static readonly ALPHA_COMBINE: number;
  566. /** Defines that alpha blending to DEST - SRC * DEST */
  567. static readonly ALPHA_SUBTRACT: number;
  568. /** Defines that alpha blending to SRC * DEST */
  569. static readonly ALPHA_MULTIPLY: number;
  570. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  571. static readonly ALPHA_MAXIMIZED: number;
  572. /** Defines that alpha blending to SRC + DEST */
  573. static readonly ALPHA_ONEONE: number;
  574. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  575. static readonly ALPHA_PREMULTIPLIED: number;
  576. /**
  577. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  578. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  579. */
  580. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  581. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  582. static readonly ALPHA_INTERPOLATE: number;
  583. /**
  584. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  585. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  586. */
  587. static readonly ALPHA_SCREENMODE: number;
  588. /**
  589. * Defines that alpha blending to SRC + DST
  590. * Alpha will be set to SRC ALPHA + DST ALPHA
  591. */
  592. static readonly ALPHA_ONEONE_ONEONE: number;
  593. /**
  594. * Defines that alpha blending to SRC * DST ALPHA + DST
  595. * Alpha will be set to 0
  596. */
  597. static readonly ALPHA_ALPHATOCOLOR: number;
  598. /**
  599. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  600. */
  601. static readonly ALPHA_REVERSEONEMINUS: number;
  602. /**
  603. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  604. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  605. */
  606. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST
  609. * Alpha will be set to SRC ALPHA
  610. */
  611. static readonly ALPHA_ONEONE_ONEZERO: number;
  612. /** Defines that alpha blending equation a SUM */
  613. static readonly ALPHA_EQUATION_ADD: number;
  614. /** Defines that alpha blending equation a SUBSTRACTION */
  615. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  616. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  617. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  618. /** Defines that alpha blending equation a MAX operation */
  619. static readonly ALPHA_EQUATION_MAX: number;
  620. /** Defines that alpha blending equation a MIN operation */
  621. static readonly ALPHA_EQUATION_MIN: number;
  622. /**
  623. * Defines that alpha blending equation a DARKEN operation:
  624. * It takes the min of the src and sums the alpha channels.
  625. */
  626. static readonly ALPHA_EQUATION_DARKEN: number;
  627. /** Defines that the ressource is not delayed*/
  628. static readonly DELAYLOADSTATE_NONE: number;
  629. /** Defines that the ressource was successfully delay loaded */
  630. static readonly DELAYLOADSTATE_LOADED: number;
  631. /** Defines that the ressource is currently delay loading */
  632. static readonly DELAYLOADSTATE_LOADING: number;
  633. /** Defines that the ressource is delayed and has not started loading */
  634. static readonly DELAYLOADSTATE_NOTLOADED: number;
  635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  636. static readonly NEVER: number;
  637. /** 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 */
  638. static readonly ALWAYS: number;
  639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  640. static readonly LESS: number;
  641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  642. static readonly EQUAL: number;
  643. /** 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 */
  644. static readonly LEQUAL: number;
  645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  646. static readonly GREATER: number;
  647. /** 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 */
  648. static readonly GEQUAL: number;
  649. /** 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 */
  650. static readonly NOTEQUAL: number;
  651. /** Passed to stencilOperation to specify that stencil value must be kept */
  652. static readonly KEEP: number;
  653. /** Passed to stencilOperation to specify that stencil value must be replaced */
  654. static readonly REPLACE: number;
  655. /** Passed to stencilOperation to specify that stencil value must be incremented */
  656. static readonly INCR: number;
  657. /** Passed to stencilOperation to specify that stencil value must be decremented */
  658. static readonly DECR: number;
  659. /** Passed to stencilOperation to specify that stencil value must be inverted */
  660. static readonly INVERT: number;
  661. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  662. static readonly INCR_WRAP: number;
  663. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  664. static readonly DECR_WRAP: number;
  665. /** Texture is not repeating outside of 0..1 UVs */
  666. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  667. /** Texture is repeating outside of 0..1 UVs */
  668. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  669. /** Texture is repeating and mirrored */
  670. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  671. /** ALPHA */
  672. static readonly TEXTUREFORMAT_ALPHA: number;
  673. /** LUMINANCE */
  674. static readonly TEXTUREFORMAT_LUMINANCE: number;
  675. /** LUMINANCE_ALPHA */
  676. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  677. /** RGB */
  678. static readonly TEXTUREFORMAT_RGB: number;
  679. /** RGBA */
  680. static readonly TEXTUREFORMAT_RGBA: number;
  681. /** RED */
  682. static readonly TEXTUREFORMAT_RED: number;
  683. /** RED (2nd reference) */
  684. static readonly TEXTUREFORMAT_R: number;
  685. /** RG */
  686. static readonly TEXTUREFORMAT_RG: number;
  687. /** RED_INTEGER */
  688. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  689. /** RED_INTEGER (2nd reference) */
  690. static readonly TEXTUREFORMAT_R_INTEGER: number;
  691. /** RG_INTEGER */
  692. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  693. /** RGB_INTEGER */
  694. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  695. /** RGBA_INTEGER */
  696. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  697. /** UNSIGNED_BYTE */
  698. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  699. /** UNSIGNED_BYTE (2nd reference) */
  700. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  701. /** FLOAT */
  702. static readonly TEXTURETYPE_FLOAT: number;
  703. /** HALF_FLOAT */
  704. static readonly TEXTURETYPE_HALF_FLOAT: number;
  705. /** BYTE */
  706. static readonly TEXTURETYPE_BYTE: number;
  707. /** SHORT */
  708. static readonly TEXTURETYPE_SHORT: number;
  709. /** UNSIGNED_SHORT */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  711. /** INT */
  712. static readonly TEXTURETYPE_INT: number;
  713. /** UNSIGNED_INT */
  714. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  715. /** UNSIGNED_SHORT_4_4_4_4 */
  716. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  717. /** UNSIGNED_SHORT_5_5_5_1 */
  718. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  719. /** UNSIGNED_SHORT_5_6_5 */
  720. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  721. /** UNSIGNED_INT_2_10_10_10_REV */
  722. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  723. /** UNSIGNED_INT_24_8 */
  724. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  725. /** UNSIGNED_INT_10F_11F_11F_REV */
  726. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  727. /** UNSIGNED_INT_5_9_9_9_REV */
  728. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  729. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  730. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  731. /** nearest is mag = nearest and min = nearest and mip = linear */
  732. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  733. /** Bilinear is mag = linear and min = linear and mip = nearest */
  734. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  735. /** Trilinear is mag = linear and min = linear and mip = linear */
  736. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  737. /** nearest is mag = nearest and min = nearest and mip = linear */
  738. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  739. /** Bilinear is mag = linear and min = linear and mip = nearest */
  740. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  741. /** Trilinear is mag = linear and min = linear and mip = linear */
  742. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  743. /** mag = nearest and min = nearest and mip = nearest */
  744. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  745. /** mag = nearest and min = linear and mip = nearest */
  746. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  747. /** mag = nearest and min = linear and mip = linear */
  748. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  749. /** mag = nearest and min = linear and mip = none */
  750. static readonly TEXTURE_NEAREST_LINEAR: number;
  751. /** mag = nearest and min = nearest and mip = none */
  752. static readonly TEXTURE_NEAREST_NEAREST: number;
  753. /** mag = linear and min = nearest and mip = nearest */
  754. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  755. /** mag = linear and min = nearest and mip = linear */
  756. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  757. /** mag = linear and min = linear and mip = none */
  758. static readonly TEXTURE_LINEAR_LINEAR: number;
  759. /** mag = linear and min = nearest and mip = none */
  760. static readonly TEXTURE_LINEAR_NEAREST: number;
  761. /** Explicit coordinates mode */
  762. static readonly TEXTURE_EXPLICIT_MODE: number;
  763. /** Spherical coordinates mode */
  764. static readonly TEXTURE_SPHERICAL_MODE: number;
  765. /** Planar coordinates mode */
  766. static readonly TEXTURE_PLANAR_MODE: number;
  767. /** Cubic coordinates mode */
  768. static readonly TEXTURE_CUBIC_MODE: number;
  769. /** Projection coordinates mode */
  770. static readonly TEXTURE_PROJECTION_MODE: number;
  771. /** Skybox coordinates mode */
  772. static readonly TEXTURE_SKYBOX_MODE: number;
  773. /** Inverse Cubic coordinates mode */
  774. static readonly TEXTURE_INVCUBIC_MODE: number;
  775. /** Equirectangular coordinates mode */
  776. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  777. /** Equirectangular Fixed coordinates mode */
  778. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  779. /** Equirectangular Fixed Mirrored coordinates mode */
  780. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  781. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  782. static readonly SCALEMODE_FLOOR: number;
  783. /** Defines that texture rescaling will look for the nearest power of 2 size */
  784. static readonly SCALEMODE_NEAREST: number;
  785. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  786. static readonly SCALEMODE_CEILING: number;
  787. /**
  788. * The dirty texture flag value
  789. */
  790. static readonly MATERIAL_TextureDirtyFlag: number;
  791. /**
  792. * The dirty light flag value
  793. */
  794. static readonly MATERIAL_LightDirtyFlag: number;
  795. /**
  796. * The dirty fresnel flag value
  797. */
  798. static readonly MATERIAL_FresnelDirtyFlag: number;
  799. /**
  800. * The dirty attribute flag value
  801. */
  802. static readonly MATERIAL_AttributesDirtyFlag: number;
  803. /**
  804. * The dirty misc flag value
  805. */
  806. static readonly MATERIAL_MiscDirtyFlag: number;
  807. /**
  808. * The all dirty flag value
  809. */
  810. static readonly MATERIAL_AllDirtyFlag: number;
  811. /**
  812. * Returns the triangle fill mode
  813. */
  814. static readonly MATERIAL_TriangleFillMode: number;
  815. /**
  816. * Returns the wireframe mode
  817. */
  818. static readonly MATERIAL_WireFrameFillMode: number;
  819. /**
  820. * Returns the point fill mode
  821. */
  822. static readonly MATERIAL_PointFillMode: number;
  823. /**
  824. * Returns the point list draw mode
  825. */
  826. static readonly MATERIAL_PointListDrawMode: number;
  827. /**
  828. * Returns the line list draw mode
  829. */
  830. static readonly MATERIAL_LineListDrawMode: number;
  831. /**
  832. * Returns the line loop draw mode
  833. */
  834. static readonly MATERIAL_LineLoopDrawMode: number;
  835. /**
  836. * Returns the line strip draw mode
  837. */
  838. static readonly MATERIAL_LineStripDrawMode: number;
  839. /**
  840. * Returns the triangle strip draw mode
  841. */
  842. static readonly MATERIAL_TriangleStripDrawMode: number;
  843. /**
  844. * Returns the triangle fan draw mode
  845. */
  846. static readonly MATERIAL_TriangleFanDrawMode: number;
  847. /**
  848. * Stores the clock-wise side orientation
  849. */
  850. static readonly MATERIAL_ClockWiseSideOrientation: number;
  851. /**
  852. * Stores the counter clock-wise side orientation
  853. */
  854. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  855. /**
  856. * Nothing
  857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  858. */
  859. static readonly ACTION_NothingTrigger: number;
  860. /**
  861. * On pick
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_OnPickTrigger: number;
  865. /**
  866. * On left pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnLeftPickTrigger: number;
  870. /**
  871. * On right pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnRightPickTrigger: number;
  875. /**
  876. * On center pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnCenterPickTrigger: number;
  880. /**
  881. * On pick down
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnPickDownTrigger: number;
  885. /**
  886. * On double pick
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnDoublePickTrigger: number;
  890. /**
  891. * On pick up
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnPickUpTrigger: number;
  895. /**
  896. * On pick out.
  897. * This trigger will only be raised if you also declared a OnPickDown
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickOutTrigger: number;
  901. /**
  902. * On long press
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLongPressTrigger: number;
  906. /**
  907. * On pointer over
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnPointerOverTrigger: number;
  911. /**
  912. * On pointer out
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOutTrigger: number;
  916. /**
  917. * On every frame
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnEveryFrameTrigger: number;
  921. /**
  922. * On intersection enter
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnIntersectionEnterTrigger: number;
  926. /**
  927. * On intersection exit
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionExitTrigger: number;
  931. /**
  932. * On key down
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnKeyDownTrigger: number;
  936. /**
  937. * On key up
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyUpTrigger: number;
  941. /**
  942. * Billboard mode will only apply to Y axis
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  945. /**
  946. * Billboard mode will apply to all axes
  947. */
  948. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  949. /**
  950. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  951. */
  952. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  953. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  954. * Test order :
  955. * Is the bounding sphere outside the frustum ?
  956. * If not, are the bounding box vertices outside the frustum ?
  957. * It not, then the cullable object is in the frustum.
  958. */
  959. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  960. /** Culling strategy : Bounding Sphere Only.
  961. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  962. * It's also less accurate than the standard because some not visible objects can still be selected.
  963. * Test : is the bounding sphere outside the frustum ?
  964. * If not, then the cullable object is in the frustum.
  965. */
  966. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  967. /** Culling strategy : Optimistic Inclusion.
  968. * This in an inclusion test first, then the standard exclusion test.
  969. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  970. * 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.
  971. * Anyway, it's as accurate as the standard strategy.
  972. * Test :
  973. * Is the cullable object bounding sphere center in the frustum ?
  974. * If not, apply the default culling strategy.
  975. */
  976. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  977. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  978. * This in an inclusion test first, then the bounding sphere only exclusion test.
  979. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  980. * 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.
  981. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  982. * Test :
  983. * Is the cullable object bounding sphere center in the frustum ?
  984. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  985. */
  986. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  987. /**
  988. * No logging while loading
  989. */
  990. static readonly SCENELOADER_NO_LOGGING: number;
  991. /**
  992. * Minimal logging while loading
  993. */
  994. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  995. /**
  996. * Summary logging while loading
  997. */
  998. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  999. /**
  1000. * Detailled logging while loading
  1001. */
  1002. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1003. }
  1004. }
  1005. declare module BABYLON {
  1006. /**
  1007. * This represents the required contract to create a new type of texture loader.
  1008. */
  1009. export interface IInternalTextureLoader {
  1010. /**
  1011. * Defines wether the loader supports cascade loading the different faces.
  1012. */
  1013. supportCascades: boolean;
  1014. /**
  1015. * This returns if the loader support the current file information.
  1016. * @param extension defines the file extension of the file being loaded
  1017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1018. * @param fallback defines the fallback internal texture if any
  1019. * @param isBase64 defines whether the texture is encoded as a base64
  1020. * @param isBuffer defines whether the texture data are stored as a buffer
  1021. * @returns true if the loader can load the specified file
  1022. */
  1023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1024. /**
  1025. * Transform the url before loading if required.
  1026. * @param rootUrl the url of the texture
  1027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1028. * @returns the transformed texture
  1029. */
  1030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1031. /**
  1032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the fallback texture
  1036. */
  1037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1038. /**
  1039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1040. * @param data contains the texture data
  1041. * @param texture defines the BabylonJS internal texture
  1042. * @param createPolynomials will be true if polynomials have been requested
  1043. * @param onLoad defines the callback to trigger once the texture is ready
  1044. * @param onError defines the callback to trigger in case of error
  1045. */
  1046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1047. /**
  1048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1049. * @param data contains the texture data
  1050. * @param texture defines the BabylonJS internal texture
  1051. * @param callback defines the method to call once ready to upload
  1052. */
  1053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1054. }
  1055. }
  1056. declare module BABYLON {
  1057. /**
  1058. * Class used to store and describe the pipeline context associated with an effect
  1059. */
  1060. export interface IPipelineContext {
  1061. /**
  1062. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1063. */
  1064. isAsync: boolean;
  1065. /**
  1066. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1067. */
  1068. isReady: boolean;
  1069. /** @hidden */
  1070. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1071. }
  1072. }
  1073. declare module BABYLON {
  1074. /**
  1075. * Class used to store gfx data (like WebGLBuffer)
  1076. */
  1077. export class DataBuffer {
  1078. /**
  1079. * Gets or sets the number of objects referencing this buffer
  1080. */
  1081. references: number;
  1082. /** Gets or sets the size of the underlying buffer */
  1083. capacity: number;
  1084. /**
  1085. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1086. */
  1087. is32Bits: boolean;
  1088. /**
  1089. * Gets the underlying buffer
  1090. */
  1091. readonly underlyingResource: any;
  1092. }
  1093. }
  1094. declare module BABYLON {
  1095. /** @hidden */
  1096. export interface IShaderProcessor {
  1097. attributeProcessor?: (attribute: string) => string;
  1098. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1099. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1100. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1101. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1102. lineProcessor?: (line: string, isFragment: boolean) => string;
  1103. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1104. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1105. }
  1106. }
  1107. declare module BABYLON {
  1108. /** @hidden */
  1109. export interface ProcessingOptions {
  1110. defines: string[];
  1111. indexParameters: any;
  1112. isFragment: boolean;
  1113. shouldUseHighPrecisionShader: boolean;
  1114. supportsUniformBuffers: boolean;
  1115. shadersRepository: string;
  1116. includesShadersStore: {
  1117. [key: string]: string;
  1118. };
  1119. processor?: IShaderProcessor;
  1120. version: string;
  1121. platformName: string;
  1122. lookForClosingBracketForUniformBuffer?: boolean;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Helper to manipulate strings
  1128. */
  1129. export class StringTools {
  1130. /**
  1131. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1132. * @param str Source string
  1133. * @param suffix Suffix to search for in the source string
  1134. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1135. */
  1136. static EndsWith(str: string, suffix: string): boolean;
  1137. /**
  1138. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1139. * @param str Source string
  1140. * @param suffix Suffix to search for in the source string
  1141. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1142. */
  1143. static StartsWith(str: string, suffix: string): boolean;
  1144. /**
  1145. * Decodes a buffer into a string
  1146. * @param buffer The buffer to decode
  1147. * @returns The decoded string
  1148. */
  1149. static Decode(buffer: Uint8Array | Uint16Array): string;
  1150. /**
  1151. * Encode a buffer to a base64 string
  1152. * @param buffer defines the buffer to encode
  1153. * @returns the encoded string
  1154. */
  1155. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  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. /**
  4752. * new Path3D(path, normal, raw)
  4753. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4754. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4755. * @param path an array of Vector3, the curve axis of the Path3D
  4756. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4757. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4758. */
  4759. constructor(
  4760. /**
  4761. * an array of Vector3, the curve axis of the Path3D
  4762. */
  4763. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4764. /**
  4765. * Returns the Path3D array of successive Vector3 designing its curve.
  4766. * @returns the Path3D array of successive Vector3 designing its curve.
  4767. */
  4768. getCurve(): Vector3[];
  4769. /**
  4770. * Returns an array populated with tangent vectors on each Path3D curve point.
  4771. * @returns an array populated with tangent vectors on each Path3D curve point.
  4772. */
  4773. getTangents(): Vector3[];
  4774. /**
  4775. * Returns an array populated with normal vectors on each Path3D curve point.
  4776. * @returns an array populated with normal vectors on each Path3D curve point.
  4777. */
  4778. getNormals(): Vector3[];
  4779. /**
  4780. * Returns an array populated with binormal vectors on each Path3D curve point.
  4781. * @returns an array populated with binormal vectors on each Path3D curve point.
  4782. */
  4783. getBinormals(): Vector3[];
  4784. /**
  4785. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4786. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4787. */
  4788. getDistances(): number[];
  4789. /**
  4790. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4791. * @param path path which all values are copied into the curves points
  4792. * @param firstNormal which should be projected onto the curve
  4793. * @returns the same object updated.
  4794. */
  4795. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4796. private _compute;
  4797. private _getFirstNonNullVector;
  4798. private _getLastNonNullVector;
  4799. private _normalVector;
  4800. }
  4801. /**
  4802. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4803. * A Curve3 is designed from a series of successive Vector3.
  4804. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4805. */
  4806. export class Curve3 {
  4807. private _points;
  4808. private _length;
  4809. /**
  4810. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4811. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4812. * @param v1 (Vector3) the control point
  4813. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4820. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4821. * @param v1 (Vector3) the first control point
  4822. * @param v2 (Vector3) the second control point
  4823. * @param v3 (Vector3) the end point of the Cubic Bezier
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4830. * @param p1 (Vector3) the origin point of the Hermite Spline
  4831. * @param t1 (Vector3) the tangent vector at the origin point
  4832. * @param p2 (Vector3) the end point of the Hermite Spline
  4833. * @param t2 (Vector3) the tangent vector at the end point
  4834. * @param nbPoints (integer) the wanted number of points in the curve
  4835. * @returns the created Curve3
  4836. */
  4837. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4838. /**
  4839. * Returns a Curve3 object along a CatmullRom Spline curve :
  4840. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4841. * @param nbPoints (integer) the wanted number of points between each curve control points
  4842. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4843. * @returns the created Curve3
  4844. */
  4845. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4846. /**
  4847. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4848. * A Curve3 is designed from a series of successive Vector3.
  4849. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4850. * @param points points which make up the curve
  4851. */
  4852. constructor(points: Vector3[]);
  4853. /**
  4854. * @returns the Curve3 stored array of successive Vector3
  4855. */
  4856. getPoints(): Vector3[];
  4857. /**
  4858. * @returns the computed length (float) of the curve.
  4859. */
  4860. length(): number;
  4861. /**
  4862. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4863. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4864. * curveA and curveB keep unchanged.
  4865. * @param curve the curve to continue from this curve
  4866. * @returns the newly constructed curve
  4867. */
  4868. continue(curve: DeepImmutable<Curve3>): Curve3;
  4869. private _computeLength;
  4870. }
  4871. }
  4872. declare module BABYLON {
  4873. /**
  4874. * This represents the main contract an easing function should follow.
  4875. * Easing functions are used throughout the animation system.
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. export interface IEasingFunction {
  4879. /**
  4880. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4881. * of the easing function.
  4882. * The link below provides some of the most common examples of easing functions.
  4883. * @see https://easings.net/
  4884. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4885. * @returns the corresponding value on the curve defined by the easing function
  4886. */
  4887. ease(gradient: number): number;
  4888. }
  4889. /**
  4890. * Base class used for every default easing function.
  4891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4892. */
  4893. export class EasingFunction implements IEasingFunction {
  4894. /**
  4895. * Interpolation follows the mathematical formula associated with the easing function.
  4896. */
  4897. static readonly EASINGMODE_EASEIN: number;
  4898. /**
  4899. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4900. */
  4901. static readonly EASINGMODE_EASEOUT: number;
  4902. /**
  4903. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4904. */
  4905. static readonly EASINGMODE_EASEINOUT: number;
  4906. private _easingMode;
  4907. /**
  4908. * Sets the easing mode of the current function.
  4909. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4910. */
  4911. setEasingMode(easingMode: number): void;
  4912. /**
  4913. * Gets the current easing mode.
  4914. * @returns the easing mode
  4915. */
  4916. getEasingMode(): number;
  4917. /**
  4918. * @hidden
  4919. */
  4920. easeInCore(gradient: number): number;
  4921. /**
  4922. * Given an input gradient between 0 and 1, this returns the corresponding value
  4923. * of the easing function.
  4924. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4925. * @returns the corresponding value on the curve defined by the easing function
  4926. */
  4927. ease(gradient: number): number;
  4928. }
  4929. /**
  4930. * Easing function with a circle shape (see link below).
  4931. * @see https://easings.net/#easeInCirc
  4932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4933. */
  4934. export class CircleEase extends EasingFunction implements IEasingFunction {
  4935. /** @hidden */
  4936. easeInCore(gradient: number): number;
  4937. }
  4938. /**
  4939. * Easing function with a ease back shape (see link below).
  4940. * @see https://easings.net/#easeInBack
  4941. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4942. */
  4943. export class BackEase extends EasingFunction implements IEasingFunction {
  4944. /** Defines the amplitude of the function */
  4945. amplitude: number;
  4946. /**
  4947. * Instantiates a back ease easing
  4948. * @see https://easings.net/#easeInBack
  4949. * @param amplitude Defines the amplitude of the function
  4950. */
  4951. constructor(
  4952. /** Defines the amplitude of the function */
  4953. amplitude?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a bouncing shape (see link below).
  4959. * @see https://easings.net/#easeInBounce
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class BounceEase extends EasingFunction implements IEasingFunction {
  4963. /** Defines the number of bounces */
  4964. bounces: number;
  4965. /** Defines the amplitude of the bounce */
  4966. bounciness: number;
  4967. /**
  4968. * Instantiates a bounce easing
  4969. * @see https://easings.net/#easeInBounce
  4970. * @param bounces Defines the number of bounces
  4971. * @param bounciness Defines the amplitude of the bounce
  4972. */
  4973. constructor(
  4974. /** Defines the number of bounces */
  4975. bounces?: number,
  4976. /** Defines the amplitude of the bounce */
  4977. bounciness?: number);
  4978. /** @hidden */
  4979. easeInCore(gradient: number): number;
  4980. }
  4981. /**
  4982. * Easing function with a power of 3 shape (see link below).
  4983. * @see https://easings.net/#easeInCubic
  4984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4985. */
  4986. export class CubicEase extends EasingFunction implements IEasingFunction {
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an elastic shape (see link below).
  4992. * @see https://easings.net/#easeInElastic
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the number of oscillations*/
  4997. oscillations: number;
  4998. /** Defines the amplitude of the oscillations*/
  4999. springiness: number;
  5000. /**
  5001. * Instantiates an elastic easing function
  5002. * @see https://easings.net/#easeInElastic
  5003. * @param oscillations Defines the number of oscillations
  5004. * @param springiness Defines the amplitude of the oscillations
  5005. */
  5006. constructor(
  5007. /** Defines the number of oscillations*/
  5008. oscillations?: number,
  5009. /** Defines the amplitude of the oscillations*/
  5010. springiness?: number);
  5011. /** @hidden */
  5012. easeInCore(gradient: number): number;
  5013. }
  5014. /**
  5015. * Easing function with an exponential shape (see link below).
  5016. * @see https://easings.net/#easeInExpo
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5020. /** Defines the exponent of the function */
  5021. exponent: number;
  5022. /**
  5023. * Instantiates an exponential easing function
  5024. * @see https://easings.net/#easeInExpo
  5025. * @param exponent Defines the exponent of the function
  5026. */
  5027. constructor(
  5028. /** Defines the exponent of the function */
  5029. exponent?: number);
  5030. /** @hidden */
  5031. easeInCore(gradient: number): number;
  5032. }
  5033. /**
  5034. * Easing function with a power shape (see link below).
  5035. * @see https://easings.net/#easeInQuad
  5036. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5037. */
  5038. export class PowerEase extends EasingFunction implements IEasingFunction {
  5039. /** Defines the power of the function */
  5040. power: number;
  5041. /**
  5042. * Instantiates an power base easing function
  5043. * @see https://easings.net/#easeInQuad
  5044. * @param power Defines the power of the function
  5045. */
  5046. constructor(
  5047. /** Defines the power of the function */
  5048. power?: number);
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a power of 2 shape (see link below).
  5054. * @see https://easings.net/#easeInQuad
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5058. /** @hidden */
  5059. easeInCore(gradient: number): number;
  5060. }
  5061. /**
  5062. * Easing function with a power of 4 shape (see link below).
  5063. * @see https://easings.net/#easeInQuart
  5064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5065. */
  5066. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5067. /** @hidden */
  5068. easeInCore(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a power of 5 shape (see link below).
  5072. * @see https://easings.net/#easeInQuint
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a sin shape (see link below).
  5081. * @see https://easings.net/#easeInSine
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class SineEase extends EasingFunction implements IEasingFunction {
  5085. /** @hidden */
  5086. easeInCore(gradient: number): number;
  5087. }
  5088. /**
  5089. * Easing function with a bezier shape (see link below).
  5090. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5092. */
  5093. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5094. /** Defines the x component of the start tangent in the bezier curve */
  5095. x1: number;
  5096. /** Defines the y component of the start tangent in the bezier curve */
  5097. y1: number;
  5098. /** Defines the x component of the end tangent in the bezier curve */
  5099. x2: number;
  5100. /** Defines the y component of the end tangent in the bezier curve */
  5101. y2: number;
  5102. /**
  5103. * Instantiates a bezier function
  5104. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5105. * @param x1 Defines the x component of the start tangent in the bezier curve
  5106. * @param y1 Defines the y component of the start tangent in the bezier curve
  5107. * @param x2 Defines the x component of the end tangent in the bezier curve
  5108. * @param y2 Defines the y component of the end tangent in the bezier curve
  5109. */
  5110. constructor(
  5111. /** Defines the x component of the start tangent in the bezier curve */
  5112. x1?: number,
  5113. /** Defines the y component of the start tangent in the bezier curve */
  5114. y1?: number,
  5115. /** Defines the x component of the end tangent in the bezier curve */
  5116. x2?: number,
  5117. /** Defines the y component of the end tangent in the bezier curve */
  5118. y2?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. }
  5123. declare module BABYLON {
  5124. /**
  5125. * Class used to hold a RBG color
  5126. */
  5127. export class Color3 {
  5128. /**
  5129. * Defines the red component (between 0 and 1, default is 0)
  5130. */
  5131. r: number;
  5132. /**
  5133. * Defines the green component (between 0 and 1, default is 0)
  5134. */
  5135. g: number;
  5136. /**
  5137. * Defines the blue component (between 0 and 1, default is 0)
  5138. */
  5139. b: number;
  5140. /**
  5141. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5142. * @param r defines the red component (between 0 and 1, default is 0)
  5143. * @param g defines the green component (between 0 and 1, default is 0)
  5144. * @param b defines the blue component (between 0 and 1, default is 0)
  5145. */
  5146. constructor(
  5147. /**
  5148. * Defines the red component (between 0 and 1, default is 0)
  5149. */
  5150. r?: number,
  5151. /**
  5152. * Defines the green component (between 0 and 1, default is 0)
  5153. */
  5154. g?: number,
  5155. /**
  5156. * Defines the blue component (between 0 and 1, default is 0)
  5157. */
  5158. b?: number);
  5159. /**
  5160. * Creates a string with the Color3 current values
  5161. * @returns the string representation of the Color3 object
  5162. */
  5163. toString(): string;
  5164. /**
  5165. * Returns the string "Color3"
  5166. * @returns "Color3"
  5167. */
  5168. getClassName(): string;
  5169. /**
  5170. * Compute the Color3 hash code
  5171. * @returns an unique number that can be used to hash Color3 objects
  5172. */
  5173. getHashCode(): number;
  5174. /**
  5175. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5176. * @param array defines the array where to store the r,g,b components
  5177. * @param index defines an optional index in the target array to define where to start storing values
  5178. * @returns the current Color3 object
  5179. */
  5180. toArray(array: FloatArray, index?: number): Color3;
  5181. /**
  5182. * Returns a new Color4 object from the current Color3 and the given alpha
  5183. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5184. * @returns a new Color4 object
  5185. */
  5186. toColor4(alpha?: number): Color4;
  5187. /**
  5188. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5189. * @returns the new array
  5190. */
  5191. asArray(): number[];
  5192. /**
  5193. * Returns the luminance value
  5194. * @returns a float value
  5195. */
  5196. toLuminance(): number;
  5197. /**
  5198. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5199. * @param otherColor defines the second operand
  5200. * @returns the new Color3 object
  5201. */
  5202. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5203. /**
  5204. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5205. * @param otherColor defines the second operand
  5206. * @param result defines the Color3 object where to store the result
  5207. * @returns the current Color3
  5208. */
  5209. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5210. /**
  5211. * Determines equality between Color3 objects
  5212. * @param otherColor defines the second operand
  5213. * @returns true if the rgb values are equal to the given ones
  5214. */
  5215. equals(otherColor: DeepImmutable<Color3>): boolean;
  5216. /**
  5217. * Determines equality between the current Color3 object and a set of r,b,g values
  5218. * @param r defines the red component to check
  5219. * @param g defines the green component to check
  5220. * @param b defines the blue component to check
  5221. * @returns true if the rgb values are equal to the given ones
  5222. */
  5223. equalsFloats(r: number, g: number, b: number): boolean;
  5224. /**
  5225. * Multiplies in place each rgb value by scale
  5226. * @param scale defines the scaling factor
  5227. * @returns the updated Color3
  5228. */
  5229. scale(scale: number): Color3;
  5230. /**
  5231. * Multiplies the rgb values by scale and stores the result into "result"
  5232. * @param scale defines the scaling factor
  5233. * @param result defines the Color3 object where to store the result
  5234. * @returns the unmodified current Color3
  5235. */
  5236. scaleToRef(scale: number, result: Color3): Color3;
  5237. /**
  5238. * Scale the current Color3 values by a factor and add the result to a given Color3
  5239. * @param scale defines the scale factor
  5240. * @param result defines color to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5244. /**
  5245. * Clamps the rgb values by the min and max values and stores the result into "result"
  5246. * @param min defines minimum clamping value (default is 0)
  5247. * @param max defines maximum clamping value (default is 1)
  5248. * @param result defines color to store the result into
  5249. * @returns the original Color3
  5250. */
  5251. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5252. /**
  5253. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5254. * @param otherColor defines the second operand
  5255. * @returns the new Color3
  5256. */
  5257. add(otherColor: DeepImmutable<Color3>): Color3;
  5258. /**
  5259. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5260. * @param otherColor defines the second operand
  5261. * @param result defines Color3 object to store the result into
  5262. * @returns the unmodified current Color3
  5263. */
  5264. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5265. /**
  5266. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5267. * @param otherColor defines the second operand
  5268. * @returns the new Color3
  5269. */
  5270. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5271. /**
  5272. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5273. * @param otherColor defines the second operand
  5274. * @param result defines Color3 object to store the result into
  5275. * @returns the unmodified current Color3
  5276. */
  5277. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5278. /**
  5279. * Copy the current object
  5280. * @returns a new Color3 copied the current one
  5281. */
  5282. clone(): Color3;
  5283. /**
  5284. * Copies the rgb values from the source in the current Color3
  5285. * @param source defines the source Color3 object
  5286. * @returns the updated Color3 object
  5287. */
  5288. copyFrom(source: DeepImmutable<Color3>): Color3;
  5289. /**
  5290. * Updates the Color3 rgb values from the given floats
  5291. * @param r defines the red component to read from
  5292. * @param g defines the green component to read from
  5293. * @param b defines the blue component to read from
  5294. * @returns the current Color3 object
  5295. */
  5296. copyFromFloats(r: number, g: number, b: number): Color3;
  5297. /**
  5298. * Updates the Color3 rgb values from the given floats
  5299. * @param r defines the red component to read from
  5300. * @param g defines the green component to read from
  5301. * @param b defines the blue component to read from
  5302. * @returns the current Color3 object
  5303. */
  5304. set(r: number, g: number, b: number): Color3;
  5305. /**
  5306. * Compute the Color3 hexadecimal code as a string
  5307. * @returns a string containing the hexadecimal representation of the Color3 object
  5308. */
  5309. toHexString(): string;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to linear space
  5312. * @returns a new Color3 object
  5313. */
  5314. toLinearSpace(): Color3;
  5315. /**
  5316. * Converts current color in rgb space to HSV values
  5317. * @returns a new color3 representing the HSV values
  5318. */
  5319. toHSV(): Color3;
  5320. /**
  5321. * Converts current color in rgb space to HSV values
  5322. * @param result defines the Color3 where to store the HSV values
  5323. */
  5324. toHSVToRef(result: Color3): void;
  5325. /**
  5326. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5327. * @param convertedColor defines the Color3 object where to store the linear space version
  5328. * @returns the unmodified Color3
  5329. */
  5330. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5331. /**
  5332. * Computes a new Color3 converted from the current one to gamma space
  5333. * @returns a new Color3 object
  5334. */
  5335. toGammaSpace(): Color3;
  5336. /**
  5337. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5338. * @param convertedColor defines the Color3 object where to store the gamma space version
  5339. * @returns the unmodified Color3
  5340. */
  5341. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5342. private static _BlackReadOnly;
  5343. /**
  5344. * Convert Hue, saturation and value to a Color3 (RGB)
  5345. * @param hue defines the hue
  5346. * @param saturation defines the saturation
  5347. * @param value defines the value
  5348. * @param result defines the Color3 where to store the RGB values
  5349. */
  5350. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5351. /**
  5352. * Creates a new Color3 from the string containing valid hexadecimal values
  5353. * @param hex defines a string containing valid hexadecimal values
  5354. * @returns a new Color3 object
  5355. */
  5356. static FromHexString(hex: string): Color3;
  5357. /**
  5358. * Creates a new Color3 from the starting index of the given array
  5359. * @param array defines the source array
  5360. * @param offset defines an offset in the source array
  5361. * @returns a new Color3 object
  5362. */
  5363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5364. /**
  5365. * Creates a new Color3 from integer values (< 256)
  5366. * @param r defines the red component to read from (value between 0 and 255)
  5367. * @param g defines the green component to read from (value between 0 and 255)
  5368. * @param b defines the blue component to read from (value between 0 and 255)
  5369. * @returns a new Color3 object
  5370. */
  5371. static FromInts(r: number, g: number, b: number): Color3;
  5372. /**
  5373. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5374. * @param start defines the start Color3 value
  5375. * @param end defines the end Color3 value
  5376. * @param amount defines the gradient value between start and end
  5377. * @returns a new Color3 object
  5378. */
  5379. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5380. /**
  5381. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5382. * @param left defines the start value
  5383. * @param right defines the end value
  5384. * @param amount defines the gradient factor
  5385. * @param result defines the Color3 object where to store the result
  5386. */
  5387. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5388. /**
  5389. * Returns a Color3 value containing a red color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Red(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a green color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Green(): Color3;
  5398. /**
  5399. * Returns a Color3 value containing a blue color
  5400. * @returns a new Color3 object
  5401. */
  5402. static Blue(): Color3;
  5403. /**
  5404. * Returns a Color3 value containing a black color
  5405. * @returns a new Color3 object
  5406. */
  5407. static Black(): Color3;
  5408. /**
  5409. * Gets a Color3 value containing a black color that must not be updated
  5410. */
  5411. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5412. /**
  5413. * Returns a Color3 value containing a white color
  5414. * @returns a new Color3 object
  5415. */
  5416. static White(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a purple color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Purple(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a magenta color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Magenta(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a yellow color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Yellow(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a gray color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Gray(): Color3;
  5437. /**
  5438. * Returns a Color3 value containing a teal color
  5439. * @returns a new Color3 object
  5440. */
  5441. static Teal(): Color3;
  5442. /**
  5443. * Returns a Color3 value containing a random color
  5444. * @returns a new Color3 object
  5445. */
  5446. static Random(): Color3;
  5447. }
  5448. /**
  5449. * Class used to hold a RBGA color
  5450. */
  5451. export class Color4 {
  5452. /**
  5453. * Defines the red component (between 0 and 1, default is 0)
  5454. */
  5455. r: number;
  5456. /**
  5457. * Defines the green component (between 0 and 1, default is 0)
  5458. */
  5459. g: number;
  5460. /**
  5461. * Defines the blue component (between 0 and 1, default is 0)
  5462. */
  5463. b: number;
  5464. /**
  5465. * Defines the alpha component (between 0 and 1, default is 1)
  5466. */
  5467. a: number;
  5468. /**
  5469. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5470. * @param r defines the red component (between 0 and 1, default is 0)
  5471. * @param g defines the green component (between 0 and 1, default is 0)
  5472. * @param b defines the blue component (between 0 and 1, default is 0)
  5473. * @param a defines the alpha component (between 0 and 1, default is 1)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number,
  5488. /**
  5489. * Defines the alpha component (between 0 and 1, default is 1)
  5490. */
  5491. a?: number);
  5492. /**
  5493. * Adds in place the given Color4 values to the current Color4 object
  5494. * @param right defines the second operand
  5495. * @returns the current updated Color4 object
  5496. */
  5497. addInPlace(right: DeepImmutable<Color4>): Color4;
  5498. /**
  5499. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5500. * @returns the new array
  5501. */
  5502. asArray(): number[];
  5503. /**
  5504. * Stores from the starting index in the given array the Color4 successive values
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color4 object
  5508. */
  5509. toArray(array: number[], index?: number): Color4;
  5510. /**
  5511. * Determines equality between Color4 objects
  5512. * @param otherColor defines the second operand
  5513. * @returns true if the rgba values are equal to the given ones
  5514. */
  5515. equals(otherColor: DeepImmutable<Color4>): boolean;
  5516. /**
  5517. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5518. * @param right defines the second operand
  5519. * @returns a new Color4 object
  5520. */
  5521. add(right: DeepImmutable<Color4>): Color4;
  5522. /**
  5523. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5524. * @param right defines the second operand
  5525. * @returns a new Color4 object
  5526. */
  5527. subtract(right: DeepImmutable<Color4>): Color4;
  5528. /**
  5529. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5530. * @param right defines the second operand
  5531. * @param result defines the Color4 object where to store the result
  5532. * @returns the current Color4 object
  5533. */
  5534. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5535. /**
  5536. * Creates a new Color4 with the current Color4 values multiplied by scale
  5537. * @param scale defines the scaling factor to apply
  5538. * @returns a new Color4 object
  5539. */
  5540. scale(scale: number): Color4;
  5541. /**
  5542. * Multiplies the current Color4 values by scale and stores the result in "result"
  5543. * @param scale defines the scaling factor to apply
  5544. * @param result defines the Color4 object where to store the result
  5545. * @returns the current unmodified Color4
  5546. */
  5547. scaleToRef(scale: number, result: Color4): Color4;
  5548. /**
  5549. * Scale the current Color4 values by a factor and add the result to a given Color4
  5550. * @param scale defines the scale factor
  5551. * @param result defines the Color4 object where to store the result
  5552. * @returns the unmodified current Color4
  5553. */
  5554. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5555. /**
  5556. * Clamps the rgb values by the min and max values and stores the result into "result"
  5557. * @param min defines minimum clamping value (default is 0)
  5558. * @param max defines maximum clamping value (default is 1)
  5559. * @param result defines color to store the result into.
  5560. * @returns the cuurent Color4
  5561. */
  5562. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5563. /**
  5564. * Multipy an Color4 value by another and return a new Color4 object
  5565. * @param color defines the Color4 value to multiply by
  5566. * @returns a new Color4 object
  5567. */
  5568. multiply(color: Color4): Color4;
  5569. /**
  5570. * Multipy a Color4 value by another and push the result in a reference value
  5571. * @param color defines the Color4 value to multiply by
  5572. * @param result defines the Color4 to fill the result in
  5573. * @returns the result Color4
  5574. */
  5575. multiplyToRef(color: Color4, result: Color4): Color4;
  5576. /**
  5577. * Creates a string with the Color4 current values
  5578. * @returns the string representation of the Color4 object
  5579. */
  5580. toString(): string;
  5581. /**
  5582. * Returns the string "Color4"
  5583. * @returns "Color4"
  5584. */
  5585. getClassName(): string;
  5586. /**
  5587. * Compute the Color4 hash code
  5588. * @returns an unique number that can be used to hash Color4 objects
  5589. */
  5590. getHashCode(): number;
  5591. /**
  5592. * Creates a new Color4 copied from the current one
  5593. * @returns a new Color4 object
  5594. */
  5595. clone(): Color4;
  5596. /**
  5597. * Copies the given Color4 values into the current one
  5598. * @param source defines the source Color4 object
  5599. * @returns the current updated Color4 object
  5600. */
  5601. copyFrom(source: Color4): Color4;
  5602. /**
  5603. * Copies the given float values into the current one
  5604. * @param r defines the red component to read from
  5605. * @param g defines the green component to read from
  5606. * @param b defines the blue component to read from
  5607. * @param a defines the alpha component to read from
  5608. * @returns the current updated Color4 object
  5609. */
  5610. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5611. /**
  5612. * Copies the given float values into the current one
  5613. * @param r defines the red component to read from
  5614. * @param g defines the green component to read from
  5615. * @param b defines the blue component to read from
  5616. * @param a defines the alpha component to read from
  5617. * @returns the current updated Color4 object
  5618. */
  5619. set(r: number, g: number, b: number, a: number): Color4;
  5620. /**
  5621. * Compute the Color4 hexadecimal code as a string
  5622. * @returns a string containing the hexadecimal representation of the Color4 object
  5623. */
  5624. toHexString(): string;
  5625. /**
  5626. * Computes a new Color4 converted from the current one to linear space
  5627. * @returns a new Color4 object
  5628. */
  5629. toLinearSpace(): Color4;
  5630. /**
  5631. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5632. * @param convertedColor defines the Color4 object where to store the linear space version
  5633. * @returns the unmodified Color4
  5634. */
  5635. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5636. /**
  5637. * Computes a new Color4 converted from the current one to gamma space
  5638. * @returns a new Color4 object
  5639. */
  5640. toGammaSpace(): Color4;
  5641. /**
  5642. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5643. * @param convertedColor defines the Color4 object where to store the gamma space version
  5644. * @returns the unmodified Color4
  5645. */
  5646. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5647. /**
  5648. * Creates a new Color4 from the string containing valid hexadecimal values
  5649. * @param hex defines a string containing valid hexadecimal values
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromHexString(hex: string): Color4;
  5653. /**
  5654. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5655. * @param left defines the start value
  5656. * @param right defines the end value
  5657. * @param amount defines the gradient factor
  5658. * @returns a new Color4 object
  5659. */
  5660. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5661. /**
  5662. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5663. * @param left defines the start value
  5664. * @param right defines the end value
  5665. * @param amount defines the gradient factor
  5666. * @param result defines the Color4 object where to store data
  5667. */
  5668. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5669. /**
  5670. * Creates a new Color4 from a Color3 and an alpha value
  5671. * @param color3 defines the source Color3 to read from
  5672. * @param alpha defines the alpha component (1.0 by default)
  5673. * @returns a new Color4 object
  5674. */
  5675. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5676. /**
  5677. * Creates a new Color4 from the starting index element of the given array
  5678. * @param array defines the source array to read from
  5679. * @param offset defines the offset in the source array
  5680. * @returns a new Color4 object
  5681. */
  5682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5683. /**
  5684. * Creates a new Color3 from integer values (< 256)
  5685. * @param r defines the red component to read from (value between 0 and 255)
  5686. * @param g defines the green component to read from (value between 0 and 255)
  5687. * @param b defines the blue component to read from (value between 0 and 255)
  5688. * @param a defines the alpha component to read from (value between 0 and 255)
  5689. * @returns a new Color3 object
  5690. */
  5691. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5692. /**
  5693. * Check the content of a given array and convert it to an array containing RGBA data
  5694. * If the original array was already containing count * 4 values then it is returned directly
  5695. * @param colors defines the array to check
  5696. * @param count defines the number of RGBA data to expect
  5697. * @returns an array containing count * 4 values (RGBA)
  5698. */
  5699. static CheckColors4(colors: number[], count: number): number[];
  5700. }
  5701. /**
  5702. * @hidden
  5703. */
  5704. export class TmpColors {
  5705. static Color3: Color3[];
  5706. static Color4: Color4[];
  5707. }
  5708. }
  5709. declare module BABYLON {
  5710. /**
  5711. * Defines an interface which represents an animation key frame
  5712. */
  5713. export interface IAnimationKey {
  5714. /**
  5715. * Frame of the key frame
  5716. */
  5717. frame: number;
  5718. /**
  5719. * Value at the specifies key frame
  5720. */
  5721. value: any;
  5722. /**
  5723. * The input tangent for the cubic hermite spline
  5724. */
  5725. inTangent?: any;
  5726. /**
  5727. * The output tangent for the cubic hermite spline
  5728. */
  5729. outTangent?: any;
  5730. /**
  5731. * The animation interpolation type
  5732. */
  5733. interpolation?: AnimationKeyInterpolation;
  5734. }
  5735. /**
  5736. * Enum for the animation key frame interpolation type
  5737. */
  5738. export enum AnimationKeyInterpolation {
  5739. /**
  5740. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5741. */
  5742. STEP = 1
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Represents the range of an animation
  5748. */
  5749. export class AnimationRange {
  5750. /**The name of the animation range**/
  5751. name: string;
  5752. /**The starting frame of the animation */
  5753. from: number;
  5754. /**The ending frame of the animation*/
  5755. to: number;
  5756. /**
  5757. * Initializes the range of an animation
  5758. * @param name The name of the animation range
  5759. * @param from The starting frame of the animation
  5760. * @param to The ending frame of the animation
  5761. */
  5762. constructor(
  5763. /**The name of the animation range**/
  5764. name: string,
  5765. /**The starting frame of the animation */
  5766. from: number,
  5767. /**The ending frame of the animation*/
  5768. to: number);
  5769. /**
  5770. * Makes a copy of the animation range
  5771. * @returns A copy of the animation range
  5772. */
  5773. clone(): AnimationRange;
  5774. }
  5775. }
  5776. declare module BABYLON {
  5777. /**
  5778. * Composed of a frame, and an action function
  5779. */
  5780. export class AnimationEvent {
  5781. /** The frame for which the event is triggered **/
  5782. frame: number;
  5783. /** The event to perform when triggered **/
  5784. action: (currentFrame: number) => void;
  5785. /** Specifies if the event should be triggered only once**/
  5786. onlyOnce?: boolean | undefined;
  5787. /**
  5788. * Specifies if the animation event is done
  5789. */
  5790. isDone: boolean;
  5791. /**
  5792. * Initializes the animation event
  5793. * @param frame The frame for which the event is triggered
  5794. * @param action The event to perform when triggered
  5795. * @param onlyOnce Specifies if the event should be triggered only once
  5796. */
  5797. constructor(
  5798. /** The frame for which the event is triggered **/
  5799. frame: number,
  5800. /** The event to perform when triggered **/
  5801. action: (currentFrame: number) => void,
  5802. /** Specifies if the event should be triggered only once**/
  5803. onlyOnce?: boolean | undefined);
  5804. /** @hidden */
  5805. _clone(): AnimationEvent;
  5806. }
  5807. }
  5808. declare module BABYLON {
  5809. /**
  5810. * Interface used to define a behavior
  5811. */
  5812. export interface Behavior<T> {
  5813. /** gets or sets behavior's name */
  5814. name: string;
  5815. /**
  5816. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5817. */
  5818. init(): void;
  5819. /**
  5820. * Called when the behavior is attached to a target
  5821. * @param target defines the target where the behavior is attached to
  5822. */
  5823. attach(target: T): void;
  5824. /**
  5825. * Called when the behavior is detached from its target
  5826. */
  5827. detach(): void;
  5828. }
  5829. /**
  5830. * Interface implemented by classes supporting behaviors
  5831. */
  5832. export interface IBehaviorAware<T> {
  5833. /**
  5834. * Attach a behavior
  5835. * @param behavior defines the behavior to attach
  5836. * @returns the current host
  5837. */
  5838. addBehavior(behavior: Behavior<T>): T;
  5839. /**
  5840. * Remove a behavior from the current object
  5841. * @param behavior defines the behavior to detach
  5842. * @returns the current host
  5843. */
  5844. removeBehavior(behavior: Behavior<T>): T;
  5845. /**
  5846. * Gets a behavior using its name to search
  5847. * @param name defines the name to search
  5848. * @returns the behavior or null if not found
  5849. */
  5850. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. /**
  5855. * Defines an array and its length.
  5856. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5857. */
  5858. export interface ISmartArrayLike<T> {
  5859. /**
  5860. * The data of the array.
  5861. */
  5862. data: Array<T>;
  5863. /**
  5864. * The active length of the array.
  5865. */
  5866. length: number;
  5867. }
  5868. /**
  5869. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5870. */
  5871. export class SmartArray<T> implements ISmartArrayLike<T> {
  5872. /**
  5873. * The full set of data from the array.
  5874. */
  5875. data: Array<T>;
  5876. /**
  5877. * The active length of the array.
  5878. */
  5879. length: number;
  5880. protected _id: number;
  5881. /**
  5882. * Instantiates a Smart Array.
  5883. * @param capacity defines the default capacity of the array.
  5884. */
  5885. constructor(capacity: number);
  5886. /**
  5887. * Pushes a value at the end of the active data.
  5888. * @param value defines the object to push in the array.
  5889. */
  5890. push(value: T): void;
  5891. /**
  5892. * Iterates over the active data and apply the lambda to them.
  5893. * @param func defines the action to apply on each value.
  5894. */
  5895. forEach(func: (content: T) => void): void;
  5896. /**
  5897. * Sorts the full sets of data.
  5898. * @param compareFn defines the comparison function to apply.
  5899. */
  5900. sort(compareFn: (a: T, b: T) => number): void;
  5901. /**
  5902. * Resets the active data to an empty array.
  5903. */
  5904. reset(): void;
  5905. /**
  5906. * Releases all the data from the array as well as the array.
  5907. */
  5908. dispose(): void;
  5909. /**
  5910. * Concats the active data with a given array.
  5911. * @param array defines the data to concatenate with.
  5912. */
  5913. concat(array: any): void;
  5914. /**
  5915. * Returns the position of a value in the active data.
  5916. * @param value defines the value to find the index for
  5917. * @returns the index if found in the active data otherwise -1
  5918. */
  5919. indexOf(value: T): number;
  5920. /**
  5921. * Returns whether an element is part of the active data.
  5922. * @param value defines the value to look for
  5923. * @returns true if found in the active data otherwise false
  5924. */
  5925. contains(value: T): boolean;
  5926. private static _GlobalId;
  5927. }
  5928. /**
  5929. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5930. * The data in this array can only be present once
  5931. */
  5932. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5933. private _duplicateId;
  5934. /**
  5935. * Pushes a value at the end of the active data.
  5936. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5937. * @param value defines the object to push in the array.
  5938. */
  5939. push(value: T): void;
  5940. /**
  5941. * Pushes a value at the end of the active data.
  5942. * If the data is already present, it won t be added again
  5943. * @param value defines the object to push in the array.
  5944. * @returns true if added false if it was already present
  5945. */
  5946. pushNoDuplicate(value: T): boolean;
  5947. /**
  5948. * Resets the active data to an empty array.
  5949. */
  5950. reset(): void;
  5951. /**
  5952. * Concats the active data with a given array.
  5953. * This ensures no dupplicate will be present in the result.
  5954. * @param array defines the data to concatenate with.
  5955. */
  5956. concatWithNoDuplicate(array: any): void;
  5957. }
  5958. }
  5959. declare module BABYLON {
  5960. /**
  5961. * @ignore
  5962. * This is a list of all the different input types that are available in the application.
  5963. * Fo instance: ArcRotateCameraGamepadInput...
  5964. */
  5965. export var CameraInputTypes: {};
  5966. /**
  5967. * This is the contract to implement in order to create a new input class.
  5968. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5969. */
  5970. export interface ICameraInput<TCamera extends Camera> {
  5971. /**
  5972. * Defines the camera the input is attached to.
  5973. */
  5974. camera: Nullable<TCamera>;
  5975. /**
  5976. * Gets the class name of the current intput.
  5977. * @returns the class name
  5978. */
  5979. getClassName(): string;
  5980. /**
  5981. * Get the friendly name associated with the input class.
  5982. * @returns the input friendly name
  5983. */
  5984. getSimpleName(): string;
  5985. /**
  5986. * Attach the input controls to a specific dom element to get the input from.
  5987. * @param element Defines the element the controls should be listened from
  5988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5989. */
  5990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5991. /**
  5992. * Detach the current controls from the specified dom element.
  5993. * @param element Defines the element to stop listening the inputs from
  5994. */
  5995. detachControl(element: Nullable<HTMLElement>): void;
  5996. /**
  5997. * Update the current camera state depending on the inputs that have been used this frame.
  5998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5999. */
  6000. checkInputs?: () => void;
  6001. }
  6002. /**
  6003. * Represents a map of input types to input instance or input index to input instance.
  6004. */
  6005. export interface CameraInputsMap<TCamera extends Camera> {
  6006. /**
  6007. * Accessor to the input by input type.
  6008. */
  6009. [name: string]: ICameraInput<TCamera>;
  6010. /**
  6011. * Accessor to the input by input index.
  6012. */
  6013. [idx: number]: ICameraInput<TCamera>;
  6014. }
  6015. /**
  6016. * This represents the input manager used within a camera.
  6017. * It helps dealing with all the different kind of input attached to a camera.
  6018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6019. */
  6020. export class CameraInputsManager<TCamera extends Camera> {
  6021. /**
  6022. * Defines the list of inputs attahed to the camera.
  6023. */
  6024. attached: CameraInputsMap<TCamera>;
  6025. /**
  6026. * Defines the dom element the camera is collecting inputs from.
  6027. * This is null if the controls have not been attached.
  6028. */
  6029. attachedElement: Nullable<HTMLElement>;
  6030. /**
  6031. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6032. */
  6033. noPreventDefault: boolean;
  6034. /**
  6035. * Defined the camera the input manager belongs to.
  6036. */
  6037. camera: TCamera;
  6038. /**
  6039. * Update the current camera state depending on the inputs that have been used this frame.
  6040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6041. */
  6042. checkInputs: () => void;
  6043. /**
  6044. * Instantiate a new Camera Input Manager.
  6045. * @param camera Defines the camera the input manager blongs to
  6046. */
  6047. constructor(camera: TCamera);
  6048. /**
  6049. * Add an input method to a camera
  6050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6051. * @param input camera input method
  6052. */
  6053. add(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Remove a specific input method from a camera
  6056. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6057. * @param inputToRemove camera input method
  6058. */
  6059. remove(inputToRemove: ICameraInput<TCamera>): void;
  6060. /**
  6061. * Remove a specific input type from a camera
  6062. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6063. * @param inputType the type of the input to remove
  6064. */
  6065. removeByType(inputType: string): void;
  6066. private _addCheckInputs;
  6067. /**
  6068. * Attach the input controls to the currently attached dom element to listen the events from.
  6069. * @param input Defines the input to attach
  6070. */
  6071. attachInput(input: ICameraInput<TCamera>): void;
  6072. /**
  6073. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6074. * @param element Defines the dom element to collect the events from
  6075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6076. */
  6077. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6078. /**
  6079. * Detach the current manager inputs controls from a specific dom element.
  6080. * @param element Defines the dom element to collect the events from
  6081. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6082. */
  6083. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6084. /**
  6085. * Rebuild the dynamic inputCheck function from the current list of
  6086. * defined inputs in the manager.
  6087. */
  6088. rebuildInputCheck(): void;
  6089. /**
  6090. * Remove all attached input methods from a camera
  6091. */
  6092. clear(): void;
  6093. /**
  6094. * Serialize the current input manager attached to a camera.
  6095. * This ensures than once parsed,
  6096. * the input associated to the camera will be identical to the current ones
  6097. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6098. */
  6099. serialize(serializedCamera: any): void;
  6100. /**
  6101. * Parses an input manager serialized JSON to restore the previous list of inputs
  6102. * and states associated to a camera.
  6103. * @param parsedCamera Defines the JSON to parse
  6104. */
  6105. parse(parsedCamera: any): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * Class used to store data that will be store in GPU memory
  6111. */
  6112. export class Buffer {
  6113. private _engine;
  6114. private _buffer;
  6115. /** @hidden */
  6116. _data: Nullable<DataArray>;
  6117. private _updatable;
  6118. private _instanced;
  6119. private _divisor;
  6120. /**
  6121. * Gets the byte stride.
  6122. */
  6123. readonly byteStride: number;
  6124. /**
  6125. * Constructor
  6126. * @param engine the engine
  6127. * @param data the data to use for this buffer
  6128. * @param updatable whether the data is updatable
  6129. * @param stride the stride (optional)
  6130. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6131. * @param instanced whether the buffer is instanced (optional)
  6132. * @param useBytes set to true if the stride in in bytes (optional)
  6133. * @param divisor sets an optional divisor for instances (1 by default)
  6134. */
  6135. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6136. /**
  6137. * Create a new VertexBuffer based on the current buffer
  6138. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6139. * @param offset defines offset in the buffer (0 by default)
  6140. * @param size defines the size in floats of attributes (position is 3 for instance)
  6141. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6142. * @param instanced defines if the vertex buffer contains indexed data
  6143. * @param useBytes defines if the offset and stride are in bytes *
  6144. * @param divisor sets an optional divisor for instances (1 by default)
  6145. * @returns the new vertex buffer
  6146. */
  6147. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6148. /**
  6149. * Gets a boolean indicating if the Buffer is updatable?
  6150. * @returns true if the buffer is updatable
  6151. */
  6152. isUpdatable(): boolean;
  6153. /**
  6154. * Gets current buffer's data
  6155. * @returns a DataArray or null
  6156. */
  6157. getData(): Nullable<DataArray>;
  6158. /**
  6159. * Gets underlying native buffer
  6160. * @returns underlying native buffer
  6161. */
  6162. getBuffer(): Nullable<DataBuffer>;
  6163. /**
  6164. * Gets the stride in float32 units (i.e. byte stride / 4).
  6165. * May not be an integer if the byte stride is not divisible by 4.
  6166. * DEPRECATED. Use byteStride instead.
  6167. * @returns the stride in float32 units
  6168. */
  6169. getStrideSize(): number;
  6170. /**
  6171. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6172. * @param data defines the data to store
  6173. */
  6174. create(data?: Nullable<DataArray>): void;
  6175. /** @hidden */
  6176. _rebuild(): void;
  6177. /**
  6178. * Update current buffer data
  6179. * @param data defines the data to store
  6180. */
  6181. update(data: DataArray): void;
  6182. /**
  6183. * Updates the data directly.
  6184. * @param data the new data
  6185. * @param offset the new offset
  6186. * @param vertexCount the vertex count (optional)
  6187. * @param useBytes set to true if the offset is in bytes
  6188. */
  6189. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6190. /**
  6191. * Release all resources
  6192. */
  6193. dispose(): void;
  6194. }
  6195. /**
  6196. * Specialized buffer used to store vertex data
  6197. */
  6198. export class VertexBuffer {
  6199. /** @hidden */
  6200. _buffer: Buffer;
  6201. private _kind;
  6202. private _size;
  6203. private _ownsBuffer;
  6204. private _instanced;
  6205. private _instanceDivisor;
  6206. /**
  6207. * The byte type.
  6208. */
  6209. static readonly BYTE: number;
  6210. /**
  6211. * The unsigned byte type.
  6212. */
  6213. static readonly UNSIGNED_BYTE: number;
  6214. /**
  6215. * The short type.
  6216. */
  6217. static readonly SHORT: number;
  6218. /**
  6219. * The unsigned short type.
  6220. */
  6221. static readonly UNSIGNED_SHORT: number;
  6222. /**
  6223. * The integer type.
  6224. */
  6225. static readonly INT: number;
  6226. /**
  6227. * The unsigned integer type.
  6228. */
  6229. static readonly UNSIGNED_INT: number;
  6230. /**
  6231. * The float type.
  6232. */
  6233. static readonly FLOAT: number;
  6234. /**
  6235. * Gets or sets the instance divisor when in instanced mode
  6236. */
  6237. instanceDivisor: number;
  6238. /**
  6239. * Gets the byte stride.
  6240. */
  6241. readonly byteStride: number;
  6242. /**
  6243. * Gets the byte offset.
  6244. */
  6245. readonly byteOffset: number;
  6246. /**
  6247. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6248. */
  6249. readonly normalized: boolean;
  6250. /**
  6251. * Gets the data type of each component in the array.
  6252. */
  6253. readonly type: number;
  6254. /**
  6255. * Constructor
  6256. * @param engine the engine
  6257. * @param data the data to use for this vertex buffer
  6258. * @param kind the vertex buffer kind
  6259. * @param updatable whether the data is updatable
  6260. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6261. * @param stride the stride (optional)
  6262. * @param instanced whether the buffer is instanced (optional)
  6263. * @param offset the offset of the data (optional)
  6264. * @param size the number of components (optional)
  6265. * @param type the type of the component (optional)
  6266. * @param normalized whether the data contains normalized data (optional)
  6267. * @param useBytes set to true if stride and offset are in bytes (optional)
  6268. * @param divisor defines the instance divisor to use (1 by default)
  6269. */
  6270. 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);
  6271. /** @hidden */
  6272. _rebuild(): void;
  6273. /**
  6274. * Returns the kind of the VertexBuffer (string)
  6275. * @returns a string
  6276. */
  6277. getKind(): string;
  6278. /**
  6279. * Gets a boolean indicating if the VertexBuffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Returns the offset as a multiple of the type byte length.
  6302. * DEPRECATED. Use byteOffset instead.
  6303. * @returns the offset in bytes
  6304. */
  6305. getOffset(): number;
  6306. /**
  6307. * Returns the number of components per vertex attribute (integer)
  6308. * @returns the size in float
  6309. */
  6310. getSize(): number;
  6311. /**
  6312. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6313. * @returns true if this buffer is instanced
  6314. */
  6315. getIsInstanced(): boolean;
  6316. /**
  6317. * Returns the instancing divisor, zero for non-instanced (integer).
  6318. * @returns a number
  6319. */
  6320. getInstanceDivisor(): number;
  6321. /**
  6322. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6323. * @param data defines the data to store
  6324. */
  6325. create(data?: DataArray): void;
  6326. /**
  6327. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6328. * This function will create a new buffer if the current one is not updatable
  6329. * @param data defines the data to store
  6330. */
  6331. update(data: DataArray): void;
  6332. /**
  6333. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6334. * Returns the directly updated WebGLBuffer.
  6335. * @param data the new data
  6336. * @param offset the new offset
  6337. * @param useBytes set to true if the offset is in bytes
  6338. */
  6339. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6340. /**
  6341. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6342. */
  6343. dispose(): void;
  6344. /**
  6345. * Enumerates each value of this vertex buffer as numbers.
  6346. * @param count the number of values to enumerate
  6347. * @param callback the callback function called for each value
  6348. */
  6349. forEach(count: number, callback: (value: number, index: number) => void): void;
  6350. /**
  6351. * Positions
  6352. */
  6353. static readonly PositionKind: string;
  6354. /**
  6355. * Normals
  6356. */
  6357. static readonly NormalKind: string;
  6358. /**
  6359. * Tangents
  6360. */
  6361. static readonly TangentKind: string;
  6362. /**
  6363. * Texture coordinates
  6364. */
  6365. static readonly UVKind: string;
  6366. /**
  6367. * Texture coordinates 2
  6368. */
  6369. static readonly UV2Kind: string;
  6370. /**
  6371. * Texture coordinates 3
  6372. */
  6373. static readonly UV3Kind: string;
  6374. /**
  6375. * Texture coordinates 4
  6376. */
  6377. static readonly UV4Kind: string;
  6378. /**
  6379. * Texture coordinates 5
  6380. */
  6381. static readonly UV5Kind: string;
  6382. /**
  6383. * Texture coordinates 6
  6384. */
  6385. static readonly UV6Kind: string;
  6386. /**
  6387. * Colors
  6388. */
  6389. static readonly ColorKind: string;
  6390. /**
  6391. * Matrix indices (for bones)
  6392. */
  6393. static readonly MatricesIndicesKind: string;
  6394. /**
  6395. * Matrix weights (for bones)
  6396. */
  6397. static readonly MatricesWeightsKind: string;
  6398. /**
  6399. * Additional matrix indices (for bones)
  6400. */
  6401. static readonly MatricesIndicesExtraKind: string;
  6402. /**
  6403. * Additional matrix weights (for bones)
  6404. */
  6405. static readonly MatricesWeightsExtraKind: string;
  6406. /**
  6407. * Deduces the stride given a kind.
  6408. * @param kind The kind string to deduce
  6409. * @returns The deduced stride
  6410. */
  6411. static DeduceStride(kind: string): number;
  6412. /**
  6413. * Gets the byte length of the given type.
  6414. * @param type the type
  6415. * @returns the number of bytes
  6416. */
  6417. static GetTypeByteLength(type: number): number;
  6418. /**
  6419. * Enumerates each value of the given parameters as numbers.
  6420. * @param data the data to enumerate
  6421. * @param byteOffset the byte offset of the data
  6422. * @param byteStride the byte stride of the data
  6423. * @param componentCount the number of components per element
  6424. * @param componentType the type of the component
  6425. * @param count the number of values to enumerate
  6426. * @param normalized whether the data is normalized
  6427. * @param callback the callback function called for each value
  6428. */
  6429. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6430. private static _GetFloatValue;
  6431. }
  6432. }
  6433. declare module BABYLON {
  6434. /**
  6435. * @hidden
  6436. */
  6437. export class IntersectionInfo {
  6438. bu: Nullable<number>;
  6439. bv: Nullable<number>;
  6440. distance: number;
  6441. faceId: number;
  6442. subMeshId: number;
  6443. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Represens a plane by the equation ax + by + cz + d = 0
  6449. */
  6450. export class Plane {
  6451. private static _TmpMatrix;
  6452. /**
  6453. * Normal of the plane (a,b,c)
  6454. */
  6455. normal: Vector3;
  6456. /**
  6457. * d component of the plane
  6458. */
  6459. d: number;
  6460. /**
  6461. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6462. * @param a a component of the plane
  6463. * @param b b component of the plane
  6464. * @param c c component of the plane
  6465. * @param d d component of the plane
  6466. */
  6467. constructor(a: number, b: number, c: number, d: number);
  6468. /**
  6469. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6470. */
  6471. asArray(): number[];
  6472. /**
  6473. * @returns a new plane copied from the current Plane.
  6474. */
  6475. clone(): Plane;
  6476. /**
  6477. * @returns the string "Plane".
  6478. */
  6479. getClassName(): string;
  6480. /**
  6481. * @returns the Plane hash code.
  6482. */
  6483. getHashCode(): number;
  6484. /**
  6485. * Normalize the current Plane in place.
  6486. * @returns the updated Plane.
  6487. */
  6488. normalize(): Plane;
  6489. /**
  6490. * Applies a transformation the plane and returns the result
  6491. * @param transformation the transformation matrix to be applied to the plane
  6492. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6493. */
  6494. transform(transformation: DeepImmutable<Matrix>): Plane;
  6495. /**
  6496. * Calcualtte the dot product between the point and the plane normal
  6497. * @param point point to calculate the dot product with
  6498. * @returns the dot product (float) of the point coordinates and the plane normal.
  6499. */
  6500. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6501. /**
  6502. * Updates the current Plane from the plane defined by the three given points.
  6503. * @param point1 one of the points used to contruct the plane
  6504. * @param point2 one of the points used to contruct the plane
  6505. * @param point3 one of the points used to contruct the plane
  6506. * @returns the updated Plane.
  6507. */
  6508. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6509. /**
  6510. * Checks if the plane is facing a given direction
  6511. * @param direction the direction to check if the plane is facing
  6512. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6513. * @returns True is the vector "direction" is the same side than the plane normal.
  6514. */
  6515. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6516. /**
  6517. * Calculates the distance to a point
  6518. * @param point point to calculate distance to
  6519. * @returns the signed distance (float) from the given point to the Plane.
  6520. */
  6521. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6522. /**
  6523. * Creates a plane from an array
  6524. * @param array the array to create a plane from
  6525. * @returns a new Plane from the given array.
  6526. */
  6527. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6528. /**
  6529. * Creates a plane from three points
  6530. * @param point1 point used to create the plane
  6531. * @param point2 point used to create the plane
  6532. * @param point3 point used to create the plane
  6533. * @returns a new Plane defined by the three given points.
  6534. */
  6535. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6536. /**
  6537. * Creates a plane from an origin point and a normal
  6538. * @param origin origin of the plane to be constructed
  6539. * @param normal normal of the plane to be constructed
  6540. * @returns a new Plane the normal vector to this plane at the given origin point.
  6541. * Note : the vector "normal" is updated because normalized.
  6542. */
  6543. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6544. /**
  6545. * Calculates the distance from a plane and a point
  6546. * @param origin origin of the plane to be constructed
  6547. * @param normal normal of the plane to be constructed
  6548. * @param point point to calculate distance to
  6549. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6550. */
  6551. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6552. }
  6553. }
  6554. declare module BABYLON {
  6555. /**
  6556. * Class used to store bounding sphere information
  6557. */
  6558. export class BoundingSphere {
  6559. /**
  6560. * Gets the center of the bounding sphere in local space
  6561. */
  6562. readonly center: Vector3;
  6563. /**
  6564. * Radius of the bounding sphere in local space
  6565. */
  6566. radius: number;
  6567. /**
  6568. * Gets the center of the bounding sphere in world space
  6569. */
  6570. readonly centerWorld: Vector3;
  6571. /**
  6572. * Radius of the bounding sphere in world space
  6573. */
  6574. radiusWorld: number;
  6575. /**
  6576. * Gets the minimum vector in local space
  6577. */
  6578. readonly minimum: Vector3;
  6579. /**
  6580. * Gets the maximum vector in local space
  6581. */
  6582. readonly maximum: Vector3;
  6583. private _worldMatrix;
  6584. private static readonly TmpVector3;
  6585. /**
  6586. * Creates a new bounding sphere
  6587. * @param min defines the minimum vector (in local space)
  6588. * @param max defines the maximum vector (in local space)
  6589. * @param worldMatrix defines the new world matrix
  6590. */
  6591. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6592. /**
  6593. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6594. * @param min defines the new minimum vector (in local space)
  6595. * @param max defines the new maximum vector (in local space)
  6596. * @param worldMatrix defines the new world matrix
  6597. */
  6598. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6599. /**
  6600. * Scale the current bounding sphere by applying a scale factor
  6601. * @param factor defines the scale factor to apply
  6602. * @returns the current bounding box
  6603. */
  6604. scale(factor: number): BoundingSphere;
  6605. /**
  6606. * Gets the world matrix of the bounding box
  6607. * @returns a matrix
  6608. */
  6609. getWorldMatrix(): DeepImmutable<Matrix>;
  6610. /** @hidden */
  6611. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6612. /**
  6613. * Tests if the bounding sphere is intersecting the frustum planes
  6614. * @param frustumPlanes defines the frustum planes to test
  6615. * @returns true if there is an intersection
  6616. */
  6617. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6618. /**
  6619. * Tests if the bounding sphere center is in between the frustum planes.
  6620. * Used for optimistic fast inclusion.
  6621. * @param frustumPlanes defines the frustum planes to test
  6622. * @returns true if the sphere center is in between the frustum planes
  6623. */
  6624. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6625. /**
  6626. * Tests if a point is inside the bounding sphere
  6627. * @param point defines the point to test
  6628. * @returns true if the point is inside the bounding sphere
  6629. */
  6630. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6631. /**
  6632. * Checks if two sphere intersct
  6633. * @param sphere0 sphere 0
  6634. * @param sphere1 sphere 1
  6635. * @returns true if the speres intersect
  6636. */
  6637. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6638. }
  6639. }
  6640. declare module BABYLON {
  6641. /**
  6642. * Class used to store bounding box information
  6643. */
  6644. export class BoundingBox implements ICullable {
  6645. /**
  6646. * Gets the 8 vectors representing the bounding box in local space
  6647. */
  6648. readonly vectors: Vector3[];
  6649. /**
  6650. * Gets the center of the bounding box in local space
  6651. */
  6652. readonly center: Vector3;
  6653. /**
  6654. * Gets the center of the bounding box in world space
  6655. */
  6656. readonly centerWorld: Vector3;
  6657. /**
  6658. * Gets the extend size in local space
  6659. */
  6660. readonly extendSize: Vector3;
  6661. /**
  6662. * Gets the extend size in world space
  6663. */
  6664. readonly extendSizeWorld: Vector3;
  6665. /**
  6666. * Gets the OBB (object bounding box) directions
  6667. */
  6668. readonly directions: Vector3[];
  6669. /**
  6670. * Gets the 8 vectors representing the bounding box in world space
  6671. */
  6672. readonly vectorsWorld: Vector3[];
  6673. /**
  6674. * Gets the minimum vector in world space
  6675. */
  6676. readonly minimumWorld: Vector3;
  6677. /**
  6678. * Gets the maximum vector in world space
  6679. */
  6680. readonly maximumWorld: Vector3;
  6681. /**
  6682. * Gets the minimum vector in local space
  6683. */
  6684. readonly minimum: Vector3;
  6685. /**
  6686. * Gets the maximum vector in local space
  6687. */
  6688. readonly maximum: Vector3;
  6689. private _worldMatrix;
  6690. private static readonly TmpVector3;
  6691. /**
  6692. * @hidden
  6693. */
  6694. _tag: number;
  6695. /**
  6696. * Creates a new bounding box
  6697. * @param min defines the minimum vector (in local space)
  6698. * @param max defines the maximum vector (in local space)
  6699. * @param worldMatrix defines the new world matrix
  6700. */
  6701. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6702. /**
  6703. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6709. /**
  6710. * Scale the current bounding box by applying a scale factor
  6711. * @param factor defines the scale factor to apply
  6712. * @returns the current bounding box
  6713. */
  6714. scale(factor: number): BoundingBox;
  6715. /**
  6716. * Gets the world matrix of the bounding box
  6717. * @returns a matrix
  6718. */
  6719. getWorldMatrix(): DeepImmutable<Matrix>;
  6720. /** @hidden */
  6721. _update(world: DeepImmutable<Matrix>): void;
  6722. /**
  6723. * Tests if the bounding box is intersecting the frustum planes
  6724. * @param frustumPlanes defines the frustum planes to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6728. /**
  6729. * Tests if the bounding box is entirely inside the frustum planes
  6730. * @param frustumPlanes defines the frustum planes to test
  6731. * @returns true if there is an inclusion
  6732. */
  6733. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6734. /**
  6735. * Tests if a point is inside the bounding box
  6736. * @param point defines the point to test
  6737. * @returns true if the point is inside the bounding box
  6738. */
  6739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6740. /**
  6741. * Tests if the bounding box intersects with a bounding sphere
  6742. * @param sphere defines the sphere to test
  6743. * @returns true if there is an intersection
  6744. */
  6745. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6746. /**
  6747. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6748. * @param min defines the min vector to use
  6749. * @param max defines the max vector to use
  6750. * @returns true if there is an intersection
  6751. */
  6752. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6753. /**
  6754. * Tests if two bounding boxes are intersections
  6755. * @param box0 defines the first box to test
  6756. * @param box1 defines the second box to test
  6757. * @returns true if there is an intersection
  6758. */
  6759. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6760. /**
  6761. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6762. * @param minPoint defines the minimum vector of the bounding box
  6763. * @param maxPoint defines the maximum vector of the bounding box
  6764. * @param sphereCenter defines the sphere center
  6765. * @param sphereRadius defines the sphere radius
  6766. * @returns true if there is an intersection
  6767. */
  6768. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6769. /**
  6770. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6771. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @return true if there is an inclusion
  6774. */
  6775. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6778. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @return true if there is an intersection
  6781. */
  6782. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. export class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /**
  6849. * Interface for cullable objects
  6850. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6851. */
  6852. export interface ICullable {
  6853. /**
  6854. * Checks if the object or part of the object is in the frustum
  6855. * @param frustumPlanes Camera near/planes
  6856. * @returns true if the object is in frustum otherwise false
  6857. */
  6858. isInFrustum(frustumPlanes: Plane[]): boolean;
  6859. /**
  6860. * Checks if a cullable object (mesh...) is in the camera frustum
  6861. * Unlike isInFrustum this cheks the full bounding box
  6862. * @param frustumPlanes Camera near/planes
  6863. * @returns true if the object is in frustum otherwise false
  6864. */
  6865. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6866. }
  6867. /**
  6868. * Info for a bounding data of a mesh
  6869. */
  6870. export class BoundingInfo implements ICullable {
  6871. /**
  6872. * Bounding box for the mesh
  6873. */
  6874. readonly boundingBox: BoundingBox;
  6875. /**
  6876. * Bounding sphere for the mesh
  6877. */
  6878. readonly boundingSphere: BoundingSphere;
  6879. private _isLocked;
  6880. private static readonly TmpVector3;
  6881. /**
  6882. * Constructs bounding info
  6883. * @param minimum min vector of the bounding box/sphere
  6884. * @param maximum max vector of the bounding box/sphere
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6888. /**
  6889. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6890. * @param min defines the new minimum vector (in local space)
  6891. * @param max defines the new maximum vector (in local space)
  6892. * @param worldMatrix defines the new world matrix
  6893. */
  6894. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6895. /**
  6896. * min vector of the bounding box/sphere
  6897. */
  6898. readonly minimum: Vector3;
  6899. /**
  6900. * max vector of the bounding box/sphere
  6901. */
  6902. readonly maximum: Vector3;
  6903. /**
  6904. * If the info is locked and won't be updated to avoid perf overhead
  6905. */
  6906. isLocked: boolean;
  6907. /**
  6908. * Updates the bounding sphere and box
  6909. * @param world world matrix to be used to update
  6910. */
  6911. update(world: DeepImmutable<Matrix>): void;
  6912. /**
  6913. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6914. * @param center New center of the bounding info
  6915. * @param extend New extend of the bounding info
  6916. * @returns the current bounding info
  6917. */
  6918. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6919. /**
  6920. * Scale the current bounding info by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding info
  6923. */
  6924. scale(factor: number): BoundingInfo;
  6925. /**
  6926. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6927. * @param frustumPlanes defines the frustum to test
  6928. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6929. * @returns true if the bounding info is in the frustum planes
  6930. */
  6931. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6932. /**
  6933. * Gets the world distance between the min and max points of the bounding box
  6934. */
  6935. readonly diagonalLength: number;
  6936. /**
  6937. * Checks if a cullable object (mesh...) is in the camera frustum
  6938. * Unlike isInFrustum this cheks the full bounding box
  6939. * @param frustumPlanes Camera near/planes
  6940. * @returns true if the object is in frustum otherwise false
  6941. */
  6942. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /** @hidden */
  6944. _checkCollision(collider: Collider): boolean;
  6945. /**
  6946. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6947. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6948. * @param point the point to check intersection with
  6949. * @returns if the point intersects
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6954. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6955. * @param boundingInfo the bounding info to check intersection with
  6956. * @param precise if the intersection should be done using OBB
  6957. * @returns if the bounding info intersects
  6958. */
  6959. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6960. }
  6961. }
  6962. declare module BABYLON {
  6963. /**
  6964. * Extracts minimum and maximum values from a list of indexed positions
  6965. * @param positions defines the positions to use
  6966. * @param indices defines the indices to the positions
  6967. * @param indexStart defines the start index
  6968. * @param indexCount defines the end index
  6969. * @param bias defines bias value to add to the result
  6970. * @return minimum and maximum values
  6971. */
  6972. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6973. minimum: Vector3;
  6974. maximum: Vector3;
  6975. };
  6976. /**
  6977. * Extracts minimum and maximum values from a list of positions
  6978. * @param positions defines the positions to use
  6979. * @param start defines the start index in the positions array
  6980. * @param count defines the number of positions to handle
  6981. * @param bias defines bias value to add to the result
  6982. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6983. * @return minimum and maximum values
  6984. */
  6985. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6986. minimum: Vector3;
  6987. maximum: Vector3;
  6988. };
  6989. }
  6990. declare module BABYLON {
  6991. /** @hidden */
  6992. export class WebGLDataBuffer extends DataBuffer {
  6993. private _buffer;
  6994. constructor(resource: WebGLBuffer);
  6995. readonly underlyingResource: any;
  6996. }
  6997. }
  6998. declare module BABYLON {
  6999. /** @hidden */
  7000. export class WebGLPipelineContext implements IPipelineContext {
  7001. engine: ThinEngine;
  7002. program: Nullable<WebGLProgram>;
  7003. context?: WebGLRenderingContext;
  7004. vertexShader?: WebGLShader;
  7005. fragmentShader?: WebGLShader;
  7006. isParallelCompiled: boolean;
  7007. onCompiled?: () => void;
  7008. transformFeedback?: WebGLTransformFeedback | null;
  7009. readonly isAsync: boolean;
  7010. readonly isReady: boolean;
  7011. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7012. }
  7013. }
  7014. declare module BABYLON {
  7015. interface ThinEngine {
  7016. /**
  7017. * Create an uniform buffer
  7018. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7019. * @param elements defines the content of the uniform buffer
  7020. * @returns the webGL uniform buffer
  7021. */
  7022. createUniformBuffer(elements: FloatArray): DataBuffer;
  7023. /**
  7024. * Create a dynamic uniform buffer
  7025. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7026. * @param elements defines the content of the uniform buffer
  7027. * @returns the webGL uniform buffer
  7028. */
  7029. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7030. /**
  7031. * Update an existing uniform buffer
  7032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7033. * @param uniformBuffer defines the target uniform buffer
  7034. * @param elements defines the content to update
  7035. * @param offset defines the offset in the uniform buffer where update should start
  7036. * @param count defines the size of the data to update
  7037. */
  7038. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7039. /**
  7040. * Bind an uniform buffer to the current webGL context
  7041. * @param buffer defines the buffer to bind
  7042. */
  7043. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7044. /**
  7045. * Bind a buffer to the current webGL context at a given location
  7046. * @param buffer defines the buffer to bind
  7047. * @param location defines the index where to bind the buffer
  7048. */
  7049. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7050. /**
  7051. * Bind a specific block at a given index in a specific shader program
  7052. * @param pipelineContext defines the pipeline context to use
  7053. * @param blockName defines the block name
  7054. * @param index defines the index where to bind the block
  7055. */
  7056. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Uniform buffer objects.
  7062. *
  7063. * Handles blocks of uniform on the GPU.
  7064. *
  7065. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7066. *
  7067. * For more information, please refer to :
  7068. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7069. */
  7070. export class UniformBuffer {
  7071. private _engine;
  7072. private _buffer;
  7073. private _data;
  7074. private _bufferData;
  7075. private _dynamic?;
  7076. private _uniformLocations;
  7077. private _uniformSizes;
  7078. private _uniformLocationPointer;
  7079. private _needSync;
  7080. private _noUBO;
  7081. private _currentEffect;
  7082. /** @hidden */
  7083. _alreadyBound: boolean;
  7084. private static _MAX_UNIFORM_SIZE;
  7085. private static _tempBuffer;
  7086. /**
  7087. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7088. * This is dynamic to allow compat with webgl 1 and 2.
  7089. * You will need to pass the name of the uniform as well as the value.
  7090. */
  7091. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7092. /**
  7093. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7094. * This is dynamic to allow compat with webgl 1 and 2.
  7095. * You will need to pass the name of the uniform as well as the value.
  7096. */
  7097. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7098. /**
  7099. * Lambda to Update a single float in a uniform buffer.
  7100. * This is dynamic to allow compat with webgl 1 and 2.
  7101. * You will need to pass the name of the uniform as well as the value.
  7102. */
  7103. updateFloat: (name: string, x: number) => void;
  7104. /**
  7105. * Lambda to Update a vec2 of float in a uniform buffer.
  7106. * This is dynamic to allow compat with webgl 1 and 2.
  7107. * You will need to pass the name of the uniform as well as the value.
  7108. */
  7109. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7110. /**
  7111. * Lambda to Update a vec3 of float in a uniform buffer.
  7112. * This is dynamic to allow compat with webgl 1 and 2.
  7113. * You will need to pass the name of the uniform as well as the value.
  7114. */
  7115. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7116. /**
  7117. * Lambda to Update a vec4 of float in a uniform buffer.
  7118. * This is dynamic to allow compat with webgl 1 and 2.
  7119. * You will need to pass the name of the uniform as well as the value.
  7120. */
  7121. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7122. /**
  7123. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7124. * This is dynamic to allow compat with webgl 1 and 2.
  7125. * You will need to pass the name of the uniform as well as the value.
  7126. */
  7127. updateMatrix: (name: string, mat: Matrix) => void;
  7128. /**
  7129. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7130. * This is dynamic to allow compat with webgl 1 and 2.
  7131. * You will need to pass the name of the uniform as well as the value.
  7132. */
  7133. updateVector3: (name: string, vector: Vector3) => void;
  7134. /**
  7135. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7136. * This is dynamic to allow compat with webgl 1 and 2.
  7137. * You will need to pass the name of the uniform as well as the value.
  7138. */
  7139. updateVector4: (name: string, vector: Vector4) => void;
  7140. /**
  7141. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7142. * This is dynamic to allow compat with webgl 1 and 2.
  7143. * You will need to pass the name of the uniform as well as the value.
  7144. */
  7145. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7146. /**
  7147. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7148. * This is dynamic to allow compat with webgl 1 and 2.
  7149. * You will need to pass the name of the uniform as well as the value.
  7150. */
  7151. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7152. /**
  7153. * Instantiates a new Uniform buffer objects.
  7154. *
  7155. * Handles blocks of uniform on the GPU.
  7156. *
  7157. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7158. *
  7159. * For more information, please refer to :
  7160. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7161. * @param engine Define the engine the buffer is associated with
  7162. * @param data Define the data contained in the buffer
  7163. * @param dynamic Define if the buffer is updatable
  7164. */
  7165. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7166. /**
  7167. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7168. * or just falling back on setUniformXXX calls.
  7169. */
  7170. readonly useUbo: boolean;
  7171. /**
  7172. * Indicates if the WebGL underlying uniform buffer is in sync
  7173. * with the javascript cache data.
  7174. */
  7175. readonly isSync: boolean;
  7176. /**
  7177. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7178. * Also, a dynamic UniformBuffer will disable cache verification and always
  7179. * update the underlying WebGL uniform buffer to the GPU.
  7180. * @returns if Dynamic, otherwise false
  7181. */
  7182. isDynamic(): boolean;
  7183. /**
  7184. * The data cache on JS side.
  7185. * @returns the underlying data as a float array
  7186. */
  7187. getData(): Float32Array;
  7188. /**
  7189. * The underlying WebGL Uniform buffer.
  7190. * @returns the webgl buffer
  7191. */
  7192. getBuffer(): Nullable<DataBuffer>;
  7193. /**
  7194. * std140 layout specifies how to align data within an UBO structure.
  7195. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7196. * for specs.
  7197. */
  7198. private _fillAlignment;
  7199. /**
  7200. * Adds an uniform in the buffer.
  7201. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7202. * for the layout to be correct !
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param size Data size, or data directly.
  7205. */
  7206. addUniform(name: string, size: number | number[]): void;
  7207. /**
  7208. * Adds a Matrix 4x4 to the uniform buffer.
  7209. * @param name Name of the uniform, as used in the uniform block in the shader.
  7210. * @param mat A 4x4 matrix.
  7211. */
  7212. addMatrix(name: string, mat: Matrix): void;
  7213. /**
  7214. * Adds a vec2 to the uniform buffer.
  7215. * @param name Name of the uniform, as used in the uniform block in the shader.
  7216. * @param x Define the x component value of the vec2
  7217. * @param y Define the y component value of the vec2
  7218. */
  7219. addFloat2(name: string, x: number, y: number): void;
  7220. /**
  7221. * Adds a vec3 to the uniform buffer.
  7222. * @param name Name of the uniform, as used in the uniform block in the shader.
  7223. * @param x Define the x component value of the vec3
  7224. * @param y Define the y component value of the vec3
  7225. * @param z Define the z component value of the vec3
  7226. */
  7227. addFloat3(name: string, x: number, y: number, z: number): void;
  7228. /**
  7229. * Adds a vec3 to the uniform buffer.
  7230. * @param name Name of the uniform, as used in the uniform block in the shader.
  7231. * @param color Define the vec3 from a Color
  7232. */
  7233. addColor3(name: string, color: Color3): void;
  7234. /**
  7235. * Adds a vec4 to the uniform buffer.
  7236. * @param name Name of the uniform, as used in the uniform block in the shader.
  7237. * @param color Define the rgb components from a Color
  7238. * @param alpha Define the a component of the vec4
  7239. */
  7240. addColor4(name: string, color: Color3, alpha: number): void;
  7241. /**
  7242. * Adds a vec3 to the uniform buffer.
  7243. * @param name Name of the uniform, as used in the uniform block in the shader.
  7244. * @param vector Define the vec3 components from a Vector
  7245. */
  7246. addVector3(name: string, vector: Vector3): void;
  7247. /**
  7248. * Adds a Matrix 3x3 to the uniform buffer.
  7249. * @param name Name of the uniform, as used in the uniform block in the shader.
  7250. */
  7251. addMatrix3x3(name: string): void;
  7252. /**
  7253. * Adds a Matrix 2x2 to the uniform buffer.
  7254. * @param name Name of the uniform, as used in the uniform block in the shader.
  7255. */
  7256. addMatrix2x2(name: string): void;
  7257. /**
  7258. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7259. */
  7260. create(): void;
  7261. /** @hidden */
  7262. _rebuild(): void;
  7263. /**
  7264. * Updates the WebGL Uniform Buffer on the GPU.
  7265. * If the `dynamic` flag is set to true, no cache comparison is done.
  7266. * Otherwise, the buffer will be updated only if the cache differs.
  7267. */
  7268. update(): void;
  7269. /**
  7270. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7271. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7272. * @param data Define the flattened data
  7273. * @param size Define the size of the data.
  7274. */
  7275. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7276. private _valueCache;
  7277. private _cacheMatrix;
  7278. private _updateMatrix3x3ForUniform;
  7279. private _updateMatrix3x3ForEffect;
  7280. private _updateMatrix2x2ForEffect;
  7281. private _updateMatrix2x2ForUniform;
  7282. private _updateFloatForEffect;
  7283. private _updateFloatForUniform;
  7284. private _updateFloat2ForEffect;
  7285. private _updateFloat2ForUniform;
  7286. private _updateFloat3ForEffect;
  7287. private _updateFloat3ForUniform;
  7288. private _updateFloat4ForEffect;
  7289. private _updateFloat4ForUniform;
  7290. private _updateMatrixForEffect;
  7291. private _updateMatrixForUniform;
  7292. private _updateVector3ForEffect;
  7293. private _updateVector3ForUniform;
  7294. private _updateVector4ForEffect;
  7295. private _updateVector4ForUniform;
  7296. private _updateColor3ForEffect;
  7297. private _updateColor3ForUniform;
  7298. private _updateColor4ForEffect;
  7299. private _updateColor4ForUniform;
  7300. /**
  7301. * Sets a sampler uniform on the effect.
  7302. * @param name Define the name of the sampler.
  7303. * @param texture Define the texture to set in the sampler
  7304. */
  7305. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7306. /**
  7307. * Directly updates the value of the uniform in the cache AND on the GPU.
  7308. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7309. * @param data Define the flattened data
  7310. */
  7311. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7312. /**
  7313. * Binds this uniform buffer to an effect.
  7314. * @param effect Define the effect to bind the buffer to
  7315. * @param name Name of the uniform block in the shader.
  7316. */
  7317. bindToEffect(effect: Effect, name: string): void;
  7318. /**
  7319. * Disposes the uniform buffer.
  7320. */
  7321. dispose(): void;
  7322. }
  7323. }
  7324. declare module BABYLON {
  7325. /**
  7326. * Enum that determines the text-wrapping mode to use.
  7327. */
  7328. export enum InspectableType {
  7329. /**
  7330. * Checkbox for booleans
  7331. */
  7332. Checkbox = 0,
  7333. /**
  7334. * Sliders for numbers
  7335. */
  7336. Slider = 1,
  7337. /**
  7338. * Vector3
  7339. */
  7340. Vector3 = 2,
  7341. /**
  7342. * Quaternions
  7343. */
  7344. Quaternion = 3,
  7345. /**
  7346. * Color3
  7347. */
  7348. Color3 = 4,
  7349. /**
  7350. * String
  7351. */
  7352. String = 5
  7353. }
  7354. /**
  7355. * Interface used to define custom inspectable properties.
  7356. * This interface is used by the inspector to display custom property grids
  7357. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7358. */
  7359. export interface IInspectable {
  7360. /**
  7361. * Gets the label to display
  7362. */
  7363. label: string;
  7364. /**
  7365. * Gets the name of the property to edit
  7366. */
  7367. propertyName: string;
  7368. /**
  7369. * Gets the type of the editor to use
  7370. */
  7371. type: InspectableType;
  7372. /**
  7373. * Gets the minimum value of the property when using in "slider" mode
  7374. */
  7375. min?: number;
  7376. /**
  7377. * Gets the maximum value of the property when using in "slider" mode
  7378. */
  7379. max?: number;
  7380. /**
  7381. * Gets the setp to use when using in "slider" mode
  7382. */
  7383. step?: number;
  7384. }
  7385. }
  7386. declare module BABYLON {
  7387. /**
  7388. * Class used to provide helper for timing
  7389. */
  7390. export class TimingTools {
  7391. /**
  7392. * Polyfill for setImmediate
  7393. * @param action defines the action to execute after the current execution block
  7394. */
  7395. static SetImmediate(action: () => void): void;
  7396. }
  7397. }
  7398. declare module BABYLON {
  7399. /**
  7400. * Class used to enable instatition of objects by class name
  7401. */
  7402. export class InstantiationTools {
  7403. /**
  7404. * Use this object to register external classes like custom textures or material
  7405. * to allow the laoders to instantiate them
  7406. */
  7407. static RegisteredExternalClasses: {
  7408. [key: string]: Object;
  7409. };
  7410. /**
  7411. * Tries to instantiate a new object from a given class name
  7412. * @param className defines the class name to instantiate
  7413. * @returns the new object or null if the system was not able to do the instantiation
  7414. */
  7415. static Instantiate(className: string): any;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * Define options used to create a depth texture
  7421. */
  7422. export class DepthTextureCreationOptions {
  7423. /** Specifies whether or not a stencil should be allocated in the texture */
  7424. generateStencil?: boolean;
  7425. /** Specifies whether or not bilinear filtering is enable on the texture */
  7426. bilinearFiltering?: boolean;
  7427. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7428. comparisonFunction?: number;
  7429. /** Specifies if the created texture is a cube texture */
  7430. isCube?: boolean;
  7431. }
  7432. }
  7433. declare module BABYLON {
  7434. interface ThinEngine {
  7435. /**
  7436. * Creates a depth stencil cube texture.
  7437. * This is only available in WebGL 2.
  7438. * @param size The size of face edge in the cube texture.
  7439. * @param options The options defining the cube texture.
  7440. * @returns The cube texture
  7441. */
  7442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7443. /**
  7444. * Creates a cube texture
  7445. * @param rootUrl defines the url where the files to load is located
  7446. * @param scene defines the current scene
  7447. * @param files defines the list of files to load (1 per face)
  7448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7449. * @param onLoad defines an optional callback raised when the texture is loaded
  7450. * @param onError defines an optional callback raised if there is an issue to load the texture
  7451. * @param format defines the format of the data
  7452. * @param forcedExtension defines the extension to use to pick the right loader
  7453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7458. * @returns the cube texture as an InternalTexture
  7459. */
  7460. 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;
  7461. /**
  7462. * Creates a cube texture
  7463. * @param rootUrl defines the url where the files to load is located
  7464. * @param scene defines the current scene
  7465. * @param files defines the list of files to load (1 per face)
  7466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7467. * @param onLoad defines an optional callback raised when the texture is loaded
  7468. * @param onError defines an optional callback raised if there is an issue to load the texture
  7469. * @param format defines the format of the data
  7470. * @param forcedExtension defines the extension to use to pick the right loader
  7471. * @returns the cube texture as an InternalTexture
  7472. */
  7473. 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;
  7474. /**
  7475. * Creates a cube texture
  7476. * @param rootUrl defines the url where the files to load is located
  7477. * @param scene defines the current scene
  7478. * @param files defines the list of files to load (1 per face)
  7479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7480. * @param onLoad defines an optional callback raised when the texture is loaded
  7481. * @param onError defines an optional callback raised if there is an issue to load the texture
  7482. * @param format defines the format of the data
  7483. * @param forcedExtension defines the extension to use to pick the right loader
  7484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7487. * @returns the cube texture as an InternalTexture
  7488. */
  7489. 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;
  7490. /** @hidden */
  7491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7492. /** @hidden */
  7493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7494. /** @hidden */
  7495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7496. /** @hidden */
  7497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7498. /**
  7499. * @hidden
  7500. */
  7501. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7502. }
  7503. }
  7504. declare module BABYLON {
  7505. /**
  7506. * Class for creating a cube texture
  7507. */
  7508. export class CubeTexture extends BaseTexture {
  7509. private _delayedOnLoad;
  7510. /**
  7511. * The url of the texture
  7512. */
  7513. url: string;
  7514. /**
  7515. * Gets or sets the center of the bounding box associated with the cube texture.
  7516. * It must define where the camera used to render the texture was set
  7517. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7518. */
  7519. boundingBoxPosition: Vector3;
  7520. private _boundingBoxSize;
  7521. /**
  7522. * Gets or sets the size of the bounding box associated with the cube texture
  7523. * When defined, the cubemap will switch to local mode
  7524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7525. * @example https://www.babylonjs-playground.com/#RNASML
  7526. */
  7527. /**
  7528. * Returns the bounding box size
  7529. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7530. */
  7531. boundingBoxSize: Vector3;
  7532. protected _rotationY: number;
  7533. /**
  7534. * Sets texture matrix rotation angle around Y axis in radians.
  7535. */
  7536. /**
  7537. * Gets texture matrix rotation angle around Y axis radians.
  7538. */
  7539. rotationY: number;
  7540. /**
  7541. * Are mip maps generated for this texture or not.
  7542. */
  7543. readonly noMipmap: boolean;
  7544. private _noMipmap;
  7545. private _files;
  7546. protected _forcedExtension: Nullable<string>;
  7547. private _extensions;
  7548. private _textureMatrix;
  7549. private _format;
  7550. private _createPolynomials;
  7551. /** @hidden */
  7552. _prefiltered: boolean;
  7553. /**
  7554. * Creates a cube texture from an array of image urls
  7555. * @param files defines an array of image urls
  7556. * @param scene defines the hosting scene
  7557. * @param noMipmap specifies if mip maps are not used
  7558. * @returns a cube texture
  7559. */
  7560. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7561. /**
  7562. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7563. * @param url defines the url of the prefiltered texture
  7564. * @param scene defines the scene the texture is attached to
  7565. * @param forcedExtension defines the extension of the file if different from the url
  7566. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7567. * @return the prefiltered texture
  7568. */
  7569. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7570. /**
  7571. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7572. * as prefiltered data.
  7573. * @param rootUrl defines the url of the texture or the root name of the six images
  7574. * @param scene defines the scene the texture is attached to
  7575. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7576. * @param noMipmap defines if mipmaps should be created or not
  7577. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7578. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7579. * @param onError defines a callback triggered in case of error during load
  7580. * @param format defines the internal format to use for the texture once loaded
  7581. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7582. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7583. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7584. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7585. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7586. * @return the cube texture
  7587. */
  7588. 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);
  7589. /**
  7590. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7591. */
  7592. readonly isPrefiltered: boolean;
  7593. /**
  7594. * Get the current class name of the texture useful for serialization or dynamic coding.
  7595. * @returns "CubeTexture"
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Update the url (and optional buffer) of this texture if url was null during construction.
  7600. * @param url the url of the texture
  7601. * @param forcedExtension defines the extension to use
  7602. * @param onLoad callback called when the texture is loaded (defaults to null)
  7603. */
  7604. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7605. /**
  7606. * Delays loading of the cube texture
  7607. * @param forcedExtension defines the extension to use
  7608. */
  7609. delayLoad(forcedExtension?: string): void;
  7610. /**
  7611. * Returns the reflection texture matrix
  7612. * @returns the reflection texture matrix
  7613. */
  7614. getReflectionTextureMatrix(): Matrix;
  7615. /**
  7616. * Sets the reflection texture matrix
  7617. * @param value Reflection texture matrix
  7618. */
  7619. setReflectionTextureMatrix(value: Matrix): void;
  7620. /**
  7621. * Parses text to create a cube texture
  7622. * @param parsedTexture define the serialized text to read from
  7623. * @param scene defines the hosting scene
  7624. * @param rootUrl defines the root url of the cube texture
  7625. * @returns a cube texture
  7626. */
  7627. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7628. /**
  7629. * Makes a clone, or deep copy, of the cube texture
  7630. * @returns a new cube texture
  7631. */
  7632. clone(): CubeTexture;
  7633. }
  7634. }
  7635. declare module BABYLON {
  7636. /**
  7637. * Manages the defines for the Material
  7638. */
  7639. export class MaterialDefines {
  7640. /** @hidden */
  7641. protected _keys: string[];
  7642. private _isDirty;
  7643. /** @hidden */
  7644. _renderId: number;
  7645. /** @hidden */
  7646. _areLightsDirty: boolean;
  7647. /** @hidden */
  7648. _areLightsDisposed: boolean;
  7649. /** @hidden */
  7650. _areAttributesDirty: boolean;
  7651. /** @hidden */
  7652. _areTexturesDirty: boolean;
  7653. /** @hidden */
  7654. _areFresnelDirty: boolean;
  7655. /** @hidden */
  7656. _areMiscDirty: boolean;
  7657. /** @hidden */
  7658. _areImageProcessingDirty: boolean;
  7659. /** @hidden */
  7660. _normals: boolean;
  7661. /** @hidden */
  7662. _uvs: boolean;
  7663. /** @hidden */
  7664. _needNormals: boolean;
  7665. /** @hidden */
  7666. _needUVs: boolean;
  7667. [id: string]: any;
  7668. /**
  7669. * Specifies if the material needs to be re-calculated
  7670. */
  7671. readonly isDirty: boolean;
  7672. /**
  7673. * Marks the material to indicate that it has been re-calculated
  7674. */
  7675. markAsProcessed(): void;
  7676. /**
  7677. * Marks the material to indicate that it needs to be re-calculated
  7678. */
  7679. markAsUnprocessed(): void;
  7680. /**
  7681. * Marks the material to indicate all of its defines need to be re-calculated
  7682. */
  7683. markAllAsDirty(): void;
  7684. /**
  7685. * Marks the material to indicate that image processing needs to be re-calculated
  7686. */
  7687. markAsImageProcessingDirty(): void;
  7688. /**
  7689. * Marks the material to indicate the lights need to be re-calculated
  7690. * @param disposed Defines whether the light is dirty due to dispose or not
  7691. */
  7692. markAsLightDirty(disposed?: boolean): void;
  7693. /**
  7694. * Marks the attribute state as changed
  7695. */
  7696. markAsAttributesDirty(): void;
  7697. /**
  7698. * Marks the texture state as changed
  7699. */
  7700. markAsTexturesDirty(): void;
  7701. /**
  7702. * Marks the fresnel state as changed
  7703. */
  7704. markAsFresnelDirty(): void;
  7705. /**
  7706. * Marks the misc state as changed
  7707. */
  7708. markAsMiscDirty(): void;
  7709. /**
  7710. * Rebuilds the material defines
  7711. */
  7712. rebuild(): void;
  7713. /**
  7714. * Specifies if two material defines are equal
  7715. * @param other - A material define instance to compare to
  7716. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7717. */
  7718. isEqual(other: MaterialDefines): boolean;
  7719. /**
  7720. * Clones this instance's defines to another instance
  7721. * @param other - material defines to clone values to
  7722. */
  7723. cloneTo(other: MaterialDefines): void;
  7724. /**
  7725. * Resets the material define values
  7726. */
  7727. reset(): void;
  7728. /**
  7729. * Converts the material define values to a string
  7730. * @returns - String of material define information
  7731. */
  7732. toString(): string;
  7733. }
  7734. }
  7735. declare module BABYLON {
  7736. /**
  7737. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7738. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7739. * 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;
  7740. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7741. */
  7742. export class ColorCurves {
  7743. private _dirty;
  7744. private _tempColor;
  7745. private _globalCurve;
  7746. private _highlightsCurve;
  7747. private _midtonesCurve;
  7748. private _shadowsCurve;
  7749. private _positiveCurve;
  7750. private _negativeCurve;
  7751. private _globalHue;
  7752. private _globalDensity;
  7753. private _globalSaturation;
  7754. private _globalExposure;
  7755. /**
  7756. * Gets the global Hue value.
  7757. * 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).
  7758. */
  7759. /**
  7760. * Sets the global Hue value.
  7761. * 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).
  7762. */
  7763. globalHue: number;
  7764. /**
  7765. * Gets the global Density value.
  7766. * 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.
  7767. * Values less than zero provide a filter of opposite hue.
  7768. */
  7769. /**
  7770. * Sets the global Density value.
  7771. * 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.
  7772. * Values less than zero provide a filter of opposite hue.
  7773. */
  7774. globalDensity: number;
  7775. /**
  7776. * Gets the global Saturation value.
  7777. * 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.
  7778. */
  7779. /**
  7780. * Sets the global Saturation value.
  7781. * 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.
  7782. */
  7783. globalSaturation: number;
  7784. /**
  7785. * Gets the global Exposure value.
  7786. * 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.
  7787. */
  7788. /**
  7789. * Sets the global Exposure value.
  7790. * 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.
  7791. */
  7792. globalExposure: number;
  7793. private _highlightsHue;
  7794. private _highlightsDensity;
  7795. private _highlightsSaturation;
  7796. private _highlightsExposure;
  7797. /**
  7798. * Gets the highlights Hue value.
  7799. * 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).
  7800. */
  7801. /**
  7802. * Sets the highlights Hue value.
  7803. * 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).
  7804. */
  7805. highlightsHue: number;
  7806. /**
  7807. * Gets the highlights Density value.
  7808. * 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.
  7809. * Values less than zero provide a filter of opposite hue.
  7810. */
  7811. /**
  7812. * Sets the highlights Density value.
  7813. * 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.
  7814. * Values less than zero provide a filter of opposite hue.
  7815. */
  7816. highlightsDensity: number;
  7817. /**
  7818. * Gets the highlights Saturation value.
  7819. * 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.
  7820. */
  7821. /**
  7822. * Sets the highlights Saturation value.
  7823. * 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.
  7824. */
  7825. highlightsSaturation: number;
  7826. /**
  7827. * Gets the highlights Exposure value.
  7828. * 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.
  7829. */
  7830. /**
  7831. * Sets the highlights Exposure value.
  7832. * 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.
  7833. */
  7834. highlightsExposure: number;
  7835. private _midtonesHue;
  7836. private _midtonesDensity;
  7837. private _midtonesSaturation;
  7838. private _midtonesExposure;
  7839. /**
  7840. * Gets the midtones Hue value.
  7841. * 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).
  7842. */
  7843. /**
  7844. * Sets the midtones Hue value.
  7845. * 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).
  7846. */
  7847. midtonesHue: number;
  7848. /**
  7849. * Gets the midtones Density value.
  7850. * 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.
  7851. * Values less than zero provide a filter of opposite hue.
  7852. */
  7853. /**
  7854. * Sets the midtones 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. midtonesDensity: number;
  7859. /**
  7860. * Gets the midtones Saturation value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the midtones Saturation value.
  7865. * 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.
  7866. */
  7867. midtonesSaturation: number;
  7868. /**
  7869. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  7871. */
  7872. /**
  7873. * Sets the midtones Exposure value.
  7874. * 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.
  7875. */
  7876. midtonesExposure: number;
  7877. private _shadowsHue;
  7878. private _shadowsDensity;
  7879. private _shadowsSaturation;
  7880. private _shadowsExposure;
  7881. /**
  7882. * Gets the shadows Hue value.
  7883. * 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).
  7884. */
  7885. /**
  7886. * Sets the shadows Hue value.
  7887. * 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).
  7888. */
  7889. shadowsHue: number;
  7890. /**
  7891. * Gets the shadows Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. /**
  7896. * Sets the shadows 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. shadowsDensity: number;
  7901. /**
  7902. * Gets the shadows Saturation value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the shadows Saturation value.
  7907. * 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.
  7908. */
  7909. shadowsSaturation: number;
  7910. /**
  7911. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  7913. */
  7914. /**
  7915. * Sets the shadows Exposure value.
  7916. * 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.
  7917. */
  7918. shadowsExposure: number;
  7919. /**
  7920. * Returns the class name
  7921. * @returns The class name
  7922. */
  7923. getClassName(): string;
  7924. /**
  7925. * Binds the color curves to the shader.
  7926. * @param colorCurves The color curve to bind
  7927. * @param effect The effect to bind to
  7928. * @param positiveUniform The positive uniform shader parameter
  7929. * @param neutralUniform The neutral uniform shader parameter
  7930. * @param negativeUniform The negative uniform shader parameter
  7931. */
  7932. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7933. /**
  7934. * Prepare the list of uniforms associated with the ColorCurves effects.
  7935. * @param uniformsList The list of uniforms used in the effect
  7936. */
  7937. static PrepareUniforms(uniformsList: string[]): void;
  7938. /**
  7939. * Returns color grading data based on a hue, density, saturation and exposure value.
  7940. * @param filterHue The hue of the color filter.
  7941. * @param filterDensity The density of the color filter.
  7942. * @param saturation The saturation.
  7943. * @param exposure The exposure.
  7944. * @param result The result data container.
  7945. */
  7946. private getColorGradingDataToRef;
  7947. /**
  7948. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7949. * @param value The input slider value in range [-100,100].
  7950. * @returns Adjusted value.
  7951. */
  7952. private static applyColorGradingSliderNonlinear;
  7953. /**
  7954. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7955. * @param hue The hue (H) input.
  7956. * @param saturation The saturation (S) input.
  7957. * @param brightness The brightness (B) input.
  7958. * @result An RGBA color represented as Vector4.
  7959. */
  7960. private static fromHSBToRef;
  7961. /**
  7962. * Returns a value clamped between min and max
  7963. * @param value The value to clamp
  7964. * @param min The minimum of value
  7965. * @param max The maximum of value
  7966. * @returns The clamped value.
  7967. */
  7968. private static clamp;
  7969. /**
  7970. * Clones the current color curve instance.
  7971. * @return The cloned curves
  7972. */
  7973. clone(): ColorCurves;
  7974. /**
  7975. * Serializes the current color curve instance to a json representation.
  7976. * @return a JSON representation
  7977. */
  7978. serialize(): any;
  7979. /**
  7980. * Parses the color curve from a json representation.
  7981. * @param source the JSON source to parse
  7982. * @return The parsed curves
  7983. */
  7984. static Parse(source: any): ColorCurves;
  7985. }
  7986. }
  7987. declare module BABYLON {
  7988. /**
  7989. * Interface to follow in your material defines to integrate easily the
  7990. * Image proccessing functions.
  7991. * @hidden
  7992. */
  7993. export interface IImageProcessingConfigurationDefines {
  7994. IMAGEPROCESSING: boolean;
  7995. VIGNETTE: boolean;
  7996. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7997. VIGNETTEBLENDMODEOPAQUE: boolean;
  7998. TONEMAPPING: boolean;
  7999. TONEMAPPING_ACES: boolean;
  8000. CONTRAST: boolean;
  8001. EXPOSURE: boolean;
  8002. COLORCURVES: boolean;
  8003. COLORGRADING: boolean;
  8004. COLORGRADING3D: boolean;
  8005. SAMPLER3DGREENDEPTH: boolean;
  8006. SAMPLER3DBGRMAP: boolean;
  8007. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8008. }
  8009. /**
  8010. * @hidden
  8011. */
  8012. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8013. IMAGEPROCESSING: boolean;
  8014. VIGNETTE: boolean;
  8015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8016. VIGNETTEBLENDMODEOPAQUE: boolean;
  8017. TONEMAPPING: boolean;
  8018. TONEMAPPING_ACES: boolean;
  8019. CONTRAST: boolean;
  8020. COLORCURVES: boolean;
  8021. COLORGRADING: boolean;
  8022. COLORGRADING3D: boolean;
  8023. SAMPLER3DGREENDEPTH: boolean;
  8024. SAMPLER3DBGRMAP: boolean;
  8025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8026. EXPOSURE: boolean;
  8027. constructor();
  8028. }
  8029. /**
  8030. * This groups together the common properties used for image processing either in direct forward pass
  8031. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8032. * or not.
  8033. */
  8034. export class ImageProcessingConfiguration {
  8035. /**
  8036. * Default tone mapping applied in BabylonJS.
  8037. */
  8038. static readonly TONEMAPPING_STANDARD: number;
  8039. /**
  8040. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8041. * to other engines rendering to increase portability.
  8042. */
  8043. static readonly TONEMAPPING_ACES: number;
  8044. /**
  8045. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8046. */
  8047. colorCurves: Nullable<ColorCurves>;
  8048. private _colorCurvesEnabled;
  8049. /**
  8050. * Gets wether the color curves effect is enabled.
  8051. */
  8052. /**
  8053. * Sets wether the color curves effect is enabled.
  8054. */
  8055. colorCurvesEnabled: boolean;
  8056. private _colorGradingTexture;
  8057. /**
  8058. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8059. */
  8060. /**
  8061. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8062. */
  8063. colorGradingTexture: Nullable<BaseTexture>;
  8064. private _colorGradingEnabled;
  8065. /**
  8066. * Gets wether the color grading effect is enabled.
  8067. */
  8068. /**
  8069. * Sets wether the color grading effect is enabled.
  8070. */
  8071. colorGradingEnabled: boolean;
  8072. private _colorGradingWithGreenDepth;
  8073. /**
  8074. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8075. */
  8076. /**
  8077. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8078. */
  8079. colorGradingWithGreenDepth: boolean;
  8080. private _colorGradingBGR;
  8081. /**
  8082. * Gets wether the color grading texture contains BGR values.
  8083. */
  8084. /**
  8085. * Sets wether the color grading texture contains BGR values.
  8086. */
  8087. colorGradingBGR: boolean;
  8088. /** @hidden */
  8089. _exposure: number;
  8090. /**
  8091. * Gets the Exposure used in the effect.
  8092. */
  8093. /**
  8094. * Sets the Exposure used in the effect.
  8095. */
  8096. exposure: number;
  8097. private _toneMappingEnabled;
  8098. /**
  8099. * Gets wether the tone mapping effect is enabled.
  8100. */
  8101. /**
  8102. * Sets wether the tone mapping effect is enabled.
  8103. */
  8104. toneMappingEnabled: boolean;
  8105. private _toneMappingType;
  8106. /**
  8107. * Gets the type of tone mapping effect.
  8108. */
  8109. /**
  8110. * Sets the type of tone mapping effect used in BabylonJS.
  8111. */
  8112. toneMappingType: number;
  8113. protected _contrast: number;
  8114. /**
  8115. * Gets the contrast used in the effect.
  8116. */
  8117. /**
  8118. * Sets the contrast used in the effect.
  8119. */
  8120. contrast: number;
  8121. /**
  8122. * Vignette stretch size.
  8123. */
  8124. vignetteStretch: number;
  8125. /**
  8126. * Vignette centre X Offset.
  8127. */
  8128. vignetteCentreX: number;
  8129. /**
  8130. * Vignette centre Y Offset.
  8131. */
  8132. vignetteCentreY: number;
  8133. /**
  8134. * Vignette weight or intensity of the vignette effect.
  8135. */
  8136. vignetteWeight: number;
  8137. /**
  8138. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8139. * if vignetteEnabled is set to true.
  8140. */
  8141. vignetteColor: Color4;
  8142. /**
  8143. * Camera field of view used by the Vignette effect.
  8144. */
  8145. vignetteCameraFov: number;
  8146. private _vignetteBlendMode;
  8147. /**
  8148. * Gets the vignette blend mode allowing different kind of effect.
  8149. */
  8150. /**
  8151. * Sets the vignette blend mode allowing different kind of effect.
  8152. */
  8153. vignetteBlendMode: number;
  8154. private _vignetteEnabled;
  8155. /**
  8156. * Gets wether the vignette effect is enabled.
  8157. */
  8158. /**
  8159. * Sets wether the vignette effect is enabled.
  8160. */
  8161. vignetteEnabled: boolean;
  8162. private _applyByPostProcess;
  8163. /**
  8164. * Gets wether the image processing is applied through a post process or not.
  8165. */
  8166. /**
  8167. * Sets wether the image processing is applied through a post process or not.
  8168. */
  8169. applyByPostProcess: boolean;
  8170. private _isEnabled;
  8171. /**
  8172. * Gets wether the image processing is enabled or not.
  8173. */
  8174. /**
  8175. * Sets wether the image processing is enabled or not.
  8176. */
  8177. isEnabled: boolean;
  8178. /**
  8179. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8180. */
  8181. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8182. /**
  8183. * Method called each time the image processing information changes requires to recompile the effect.
  8184. */
  8185. protected _updateParameters(): void;
  8186. /**
  8187. * Gets the current class name.
  8188. * @return "ImageProcessingConfiguration"
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * Prepare the list of uniforms associated with the Image Processing effects.
  8193. * @param uniforms The list of uniforms used in the effect
  8194. * @param defines the list of defines currently in use
  8195. */
  8196. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8197. /**
  8198. * Prepare the list of samplers associated with the Image Processing effects.
  8199. * @param samplersList The list of uniforms used in the effect
  8200. * @param defines the list of defines currently in use
  8201. */
  8202. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8203. /**
  8204. * Prepare the list of defines associated to the shader.
  8205. * @param defines the list of defines to complete
  8206. * @param forPostProcess Define if we are currently in post process mode or not
  8207. */
  8208. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8209. /**
  8210. * Returns true if all the image processing information are ready.
  8211. * @returns True if ready, otherwise, false
  8212. */
  8213. isReady(): boolean;
  8214. /**
  8215. * Binds the image processing to the shader.
  8216. * @param effect The effect to bind to
  8217. * @param aspectRatio Define the current aspect ratio of the effect
  8218. */
  8219. bind(effect: Effect, aspectRatio?: number): void;
  8220. /**
  8221. * Clones the current image processing instance.
  8222. * @return The cloned image processing
  8223. */
  8224. clone(): ImageProcessingConfiguration;
  8225. /**
  8226. * Serializes the current image processing instance to a json representation.
  8227. * @return a JSON representation
  8228. */
  8229. serialize(): any;
  8230. /**
  8231. * Parses the image processing from a json representation.
  8232. * @param source the JSON source to parse
  8233. * @return The parsed image processing
  8234. */
  8235. static Parse(source: any): ImageProcessingConfiguration;
  8236. private static _VIGNETTEMODE_MULTIPLY;
  8237. private static _VIGNETTEMODE_OPAQUE;
  8238. /**
  8239. * Used to apply the vignette as a mix with the pixel color.
  8240. */
  8241. static readonly VIGNETTEMODE_MULTIPLY: number;
  8242. /**
  8243. * Used to apply the vignette as a replacement of the pixel color.
  8244. */
  8245. static readonly VIGNETTEMODE_OPAQUE: number;
  8246. }
  8247. }
  8248. declare module BABYLON {
  8249. /** @hidden */
  8250. export var postprocessVertexShader: {
  8251. name: string;
  8252. shader: string;
  8253. };
  8254. }
  8255. declare module BABYLON {
  8256. interface ThinEngine {
  8257. /**
  8258. * Creates a new render target texture
  8259. * @param size defines the size of the texture
  8260. * @param options defines the options used to create the texture
  8261. * @returns a new render target texture stored in an InternalTexture
  8262. */
  8263. createRenderTargetTexture(size: number | {
  8264. width: number;
  8265. height: number;
  8266. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8267. /**
  8268. * Creates a depth stencil texture.
  8269. * This is only available in WebGL 2 or with the depth texture extension available.
  8270. * @param size The size of face edge in the texture.
  8271. * @param options The options defining the texture.
  8272. * @returns The texture
  8273. */
  8274. createDepthStencilTexture(size: number | {
  8275. width: number;
  8276. height: number;
  8277. }, options: DepthTextureCreationOptions): InternalTexture;
  8278. /** @hidden */
  8279. _createDepthStencilTexture(size: number | {
  8280. width: number;
  8281. height: number;
  8282. }, options: DepthTextureCreationOptions): InternalTexture;
  8283. }
  8284. }
  8285. declare module BABYLON {
  8286. /** Defines supported spaces */
  8287. export enum Space {
  8288. /** Local (object) space */
  8289. LOCAL = 0,
  8290. /** World space */
  8291. WORLD = 1,
  8292. /** Bone space */
  8293. BONE = 2
  8294. }
  8295. /** Defines the 3 main axes */
  8296. export class Axis {
  8297. /** X axis */
  8298. static X: Vector3;
  8299. /** Y axis */
  8300. static Y: Vector3;
  8301. /** Z axis */
  8302. static Z: Vector3;
  8303. }
  8304. }
  8305. declare module BABYLON {
  8306. /**
  8307. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8308. * This is the base of the follow, arc rotate cameras and Free camera
  8309. * @see http://doc.babylonjs.com/features/cameras
  8310. */
  8311. export class TargetCamera extends Camera {
  8312. private static _RigCamTransformMatrix;
  8313. private static _TargetTransformMatrix;
  8314. private static _TargetFocalPoint;
  8315. /**
  8316. * Define the current direction the camera is moving to
  8317. */
  8318. cameraDirection: Vector3;
  8319. /**
  8320. * Define the current rotation the camera is rotating to
  8321. */
  8322. cameraRotation: Vector2;
  8323. /**
  8324. * When set, the up vector of the camera will be updated by the rotation of the camera
  8325. */
  8326. updateUpVectorFromRotation: boolean;
  8327. private _tmpQuaternion;
  8328. /**
  8329. * Define the current rotation of the camera
  8330. */
  8331. rotation: Vector3;
  8332. /**
  8333. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8334. */
  8335. rotationQuaternion: Quaternion;
  8336. /**
  8337. * Define the current speed of the camera
  8338. */
  8339. speed: number;
  8340. /**
  8341. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8342. * around all axis.
  8343. */
  8344. noRotationConstraint: boolean;
  8345. /**
  8346. * Define the current target of the camera as an object or a position.
  8347. */
  8348. lockedTarget: any;
  8349. /** @hidden */
  8350. _currentTarget: Vector3;
  8351. /** @hidden */
  8352. _initialFocalDistance: number;
  8353. /** @hidden */
  8354. _viewMatrix: Matrix;
  8355. /** @hidden */
  8356. _camMatrix: Matrix;
  8357. /** @hidden */
  8358. _cameraTransformMatrix: Matrix;
  8359. /** @hidden */
  8360. _cameraRotationMatrix: Matrix;
  8361. /** @hidden */
  8362. _referencePoint: Vector3;
  8363. /** @hidden */
  8364. _transformedReferencePoint: Vector3;
  8365. protected _globalCurrentTarget: Vector3;
  8366. protected _globalCurrentUpVector: Vector3;
  8367. /** @hidden */
  8368. _reset: () => void;
  8369. private _defaultUp;
  8370. /**
  8371. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8372. * This is the base of the follow, arc rotate cameras and Free camera
  8373. * @see http://doc.babylonjs.com/features/cameras
  8374. * @param name Defines the name of the camera in the scene
  8375. * @param position Defines the start position of the camera in the scene
  8376. * @param scene Defines the scene the camera belongs to
  8377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8378. */
  8379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8380. /**
  8381. * Gets the position in front of the camera at a given distance.
  8382. * @param distance The distance from the camera we want the position to be
  8383. * @returns the position
  8384. */
  8385. getFrontPosition(distance: number): Vector3;
  8386. /** @hidden */
  8387. _getLockedTargetPosition(): Nullable<Vector3>;
  8388. private _storedPosition;
  8389. private _storedRotation;
  8390. private _storedRotationQuaternion;
  8391. /**
  8392. * Store current camera state of the camera (fov, position, rotation, etc..)
  8393. * @returns the camera
  8394. */
  8395. storeState(): Camera;
  8396. /**
  8397. * Restored camera state. You must call storeState() first
  8398. * @returns whether it was successful or not
  8399. * @hidden
  8400. */
  8401. _restoreStateValues(): boolean;
  8402. /** @hidden */
  8403. _initCache(): void;
  8404. /** @hidden */
  8405. _updateCache(ignoreParentClass?: boolean): void;
  8406. /** @hidden */
  8407. _isSynchronizedViewMatrix(): boolean;
  8408. /** @hidden */
  8409. _computeLocalCameraSpeed(): number;
  8410. /**
  8411. * Defines the target the camera should look at.
  8412. * @param target Defines the new target as a Vector or a mesh
  8413. */
  8414. setTarget(target: Vector3): void;
  8415. /**
  8416. * Return the current target position of the camera. This value is expressed in local space.
  8417. * @returns the target position
  8418. */
  8419. getTarget(): Vector3;
  8420. /** @hidden */
  8421. _decideIfNeedsToMove(): boolean;
  8422. /** @hidden */
  8423. _updatePosition(): void;
  8424. /** @hidden */
  8425. _checkInputs(): void;
  8426. protected _updateCameraRotationMatrix(): void;
  8427. /**
  8428. * 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)
  8429. * @returns the current camera
  8430. */
  8431. private _rotateUpVectorWithCameraRotationMatrix;
  8432. private _cachedRotationZ;
  8433. private _cachedQuaternionRotationZ;
  8434. /** @hidden */
  8435. _getViewMatrix(): Matrix;
  8436. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8437. /**
  8438. * @hidden
  8439. */
  8440. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8441. /**
  8442. * @hidden
  8443. */
  8444. _updateRigCameras(): void;
  8445. private _getRigCamPositionAndTarget;
  8446. /**
  8447. * Gets the current object class name.
  8448. * @return the class name
  8449. */
  8450. getClassName(): string;
  8451. }
  8452. }
  8453. declare module BABYLON {
  8454. /**
  8455. * Gather the list of keyboard event types as constants.
  8456. */
  8457. export class KeyboardEventTypes {
  8458. /**
  8459. * The keydown event is fired when a key becomes active (pressed).
  8460. */
  8461. static readonly KEYDOWN: number;
  8462. /**
  8463. * The keyup event is fired when a key has been released.
  8464. */
  8465. static readonly KEYUP: number;
  8466. }
  8467. /**
  8468. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8469. */
  8470. export class KeyboardInfo {
  8471. /**
  8472. * Defines the type of event (KeyboardEventTypes)
  8473. */
  8474. type: number;
  8475. /**
  8476. * Defines the related dom event
  8477. */
  8478. event: KeyboardEvent;
  8479. /**
  8480. * Instantiates a new keyboard info.
  8481. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8482. * @param type Defines the type of event (KeyboardEventTypes)
  8483. * @param event Defines the related dom event
  8484. */
  8485. constructor(
  8486. /**
  8487. * Defines the type of event (KeyboardEventTypes)
  8488. */
  8489. type: number,
  8490. /**
  8491. * Defines the related dom event
  8492. */
  8493. event: KeyboardEvent);
  8494. }
  8495. /**
  8496. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8497. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8498. */
  8499. export class KeyboardInfoPre extends KeyboardInfo {
  8500. /**
  8501. * Defines the type of event (KeyboardEventTypes)
  8502. */
  8503. type: number;
  8504. /**
  8505. * Defines the related dom event
  8506. */
  8507. event: KeyboardEvent;
  8508. /**
  8509. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8510. */
  8511. skipOnPointerObservable: boolean;
  8512. /**
  8513. * Instantiates a new keyboard pre info.
  8514. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8515. * @param type Defines the type of event (KeyboardEventTypes)
  8516. * @param event Defines the related dom event
  8517. */
  8518. constructor(
  8519. /**
  8520. * Defines the type of event (KeyboardEventTypes)
  8521. */
  8522. type: number,
  8523. /**
  8524. * Defines the related dom event
  8525. */
  8526. event: KeyboardEvent);
  8527. }
  8528. }
  8529. declare module BABYLON {
  8530. /**
  8531. * Manage the keyboard inputs to control the movement of a free camera.
  8532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8533. */
  8534. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8535. /**
  8536. * Defines the camera the input is attached to.
  8537. */
  8538. camera: FreeCamera;
  8539. /**
  8540. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8541. */
  8542. keysUp: number[];
  8543. /**
  8544. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8545. */
  8546. keysDown: number[];
  8547. /**
  8548. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8549. */
  8550. keysLeft: number[];
  8551. /**
  8552. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8553. */
  8554. keysRight: number[];
  8555. private _keys;
  8556. private _onCanvasBlurObserver;
  8557. private _onKeyboardObserver;
  8558. private _engine;
  8559. private _scene;
  8560. /**
  8561. * Attach the input controls to a specific dom element to get the input from.
  8562. * @param element Defines the element the controls should be listened from
  8563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8564. */
  8565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8566. /**
  8567. * Detach the current controls from the specified dom element.
  8568. * @param element Defines the element to stop listening the inputs from
  8569. */
  8570. detachControl(element: Nullable<HTMLElement>): void;
  8571. /**
  8572. * Update the current camera state depending on the inputs that have been used this frame.
  8573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8574. */
  8575. checkInputs(): void;
  8576. /**
  8577. * Gets the class name of the current intput.
  8578. * @returns the class name
  8579. */
  8580. getClassName(): string;
  8581. /** @hidden */
  8582. _onLostFocus(): void;
  8583. /**
  8584. * Get the friendly name associated with the input class.
  8585. * @returns the input friendly name
  8586. */
  8587. getSimpleName(): string;
  8588. }
  8589. }
  8590. declare module BABYLON {
  8591. /**
  8592. * Interface describing all the common properties and methods a shadow light needs to implement.
  8593. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8594. * as well as binding the different shadow properties to the effects.
  8595. */
  8596. export interface IShadowLight extends Light {
  8597. /**
  8598. * The light id in the scene (used in scene.findLighById for instance)
  8599. */
  8600. id: string;
  8601. /**
  8602. * The position the shdow will be casted from.
  8603. */
  8604. position: Vector3;
  8605. /**
  8606. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8607. */
  8608. direction: Vector3;
  8609. /**
  8610. * The transformed position. Position of the light in world space taking parenting in account.
  8611. */
  8612. transformedPosition: Vector3;
  8613. /**
  8614. * The transformed direction. Direction of the light in world space taking parenting in account.
  8615. */
  8616. transformedDirection: Vector3;
  8617. /**
  8618. * The friendly name of the light in the scene.
  8619. */
  8620. name: string;
  8621. /**
  8622. * Defines the shadow projection clipping minimum z value.
  8623. */
  8624. shadowMinZ: number;
  8625. /**
  8626. * Defines the shadow projection clipping maximum z value.
  8627. */
  8628. shadowMaxZ: number;
  8629. /**
  8630. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8631. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8632. */
  8633. computeTransformedInformation(): boolean;
  8634. /**
  8635. * Gets the scene the light belongs to.
  8636. * @returns The scene
  8637. */
  8638. getScene(): Scene;
  8639. /**
  8640. * Callback defining a custom Projection Matrix Builder.
  8641. * This can be used to override the default projection matrix computation.
  8642. */
  8643. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8644. /**
  8645. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8646. * @param matrix The materix to updated with the projection information
  8647. * @param viewMatrix The transform matrix of the light
  8648. * @param renderList The list of mesh to render in the map
  8649. * @returns The current light
  8650. */
  8651. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8652. /**
  8653. * Gets the current depth scale used in ESM.
  8654. * @returns The scale
  8655. */
  8656. getDepthScale(): number;
  8657. /**
  8658. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8659. * @returns true if a cube texture needs to be use
  8660. */
  8661. needCube(): boolean;
  8662. /**
  8663. * Detects if the projection matrix requires to be recomputed this frame.
  8664. * @returns true if it requires to be recomputed otherwise, false.
  8665. */
  8666. needProjectionMatrixCompute(): boolean;
  8667. /**
  8668. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8669. */
  8670. forceProjectionMatrixCompute(): void;
  8671. /**
  8672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8675. */
  8676. getShadowDirection(faceIndex?: number): Vector3;
  8677. /**
  8678. * Gets the minZ used for shadow according to both the scene and the light.
  8679. * @param activeCamera The camera we are returning the min for
  8680. * @returns the depth min z
  8681. */
  8682. getDepthMinZ(activeCamera: Camera): number;
  8683. /**
  8684. * Gets the maxZ used for shadow according to both the scene and the light.
  8685. * @param activeCamera The camera we are returning the max for
  8686. * @returns the depth max z
  8687. */
  8688. getDepthMaxZ(activeCamera: Camera): number;
  8689. }
  8690. /**
  8691. * Base implementation IShadowLight
  8692. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8693. */
  8694. export abstract class ShadowLight extends Light implements IShadowLight {
  8695. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8696. protected _position: Vector3;
  8697. protected _setPosition(value: Vector3): void;
  8698. /**
  8699. * Sets the position the shadow will be casted from. Also use as the light position for both
  8700. * point and spot lights.
  8701. */
  8702. /**
  8703. * Sets the position the shadow will be casted from. Also use as the light position for both
  8704. * point and spot lights.
  8705. */
  8706. position: Vector3;
  8707. protected _direction: Vector3;
  8708. protected _setDirection(value: Vector3): void;
  8709. /**
  8710. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8711. * Also use as the light direction on spot and directional lights.
  8712. */
  8713. /**
  8714. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8715. * Also use as the light direction on spot and directional lights.
  8716. */
  8717. direction: Vector3;
  8718. private _shadowMinZ;
  8719. /**
  8720. * Gets the shadow projection clipping minimum z value.
  8721. */
  8722. /**
  8723. * Sets the shadow projection clipping minimum z value.
  8724. */
  8725. shadowMinZ: number;
  8726. private _shadowMaxZ;
  8727. /**
  8728. * Sets the shadow projection clipping maximum z value.
  8729. */
  8730. /**
  8731. * Gets the shadow projection clipping maximum z value.
  8732. */
  8733. shadowMaxZ: number;
  8734. /**
  8735. * Callback defining a custom Projection Matrix Builder.
  8736. * This can be used to override the default projection matrix computation.
  8737. */
  8738. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8739. /**
  8740. * The transformed position. Position of the light in world space taking parenting in account.
  8741. */
  8742. transformedPosition: Vector3;
  8743. /**
  8744. * The transformed direction. Direction of the light in world space taking parenting in account.
  8745. */
  8746. transformedDirection: Vector3;
  8747. private _needProjectionMatrixCompute;
  8748. /**
  8749. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8750. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8751. */
  8752. computeTransformedInformation(): boolean;
  8753. /**
  8754. * Return the depth scale used for the shadow map.
  8755. * @returns the depth scale.
  8756. */
  8757. getDepthScale(): number;
  8758. /**
  8759. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8760. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8761. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8762. */
  8763. getShadowDirection(faceIndex?: number): Vector3;
  8764. /**
  8765. * Returns the ShadowLight absolute position in the World.
  8766. * @returns the position vector in world space
  8767. */
  8768. getAbsolutePosition(): Vector3;
  8769. /**
  8770. * Sets the ShadowLight direction toward the passed target.
  8771. * @param target The point to target in local space
  8772. * @returns the updated ShadowLight direction
  8773. */
  8774. setDirectionToTarget(target: Vector3): Vector3;
  8775. /**
  8776. * Returns the light rotation in euler definition.
  8777. * @returns the x y z rotation in local space.
  8778. */
  8779. getRotation(): Vector3;
  8780. /**
  8781. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8782. * @returns true if a cube texture needs to be use
  8783. */
  8784. needCube(): boolean;
  8785. /**
  8786. * Detects if the projection matrix requires to be recomputed this frame.
  8787. * @returns true if it requires to be recomputed otherwise, false.
  8788. */
  8789. needProjectionMatrixCompute(): boolean;
  8790. /**
  8791. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8792. */
  8793. forceProjectionMatrixCompute(): void;
  8794. /** @hidden */
  8795. _initCache(): void;
  8796. /** @hidden */
  8797. _isSynchronized(): boolean;
  8798. /**
  8799. * Computes the world matrix of the node
  8800. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8801. * @returns the world matrix
  8802. */
  8803. computeWorldMatrix(force?: boolean): Matrix;
  8804. /**
  8805. * Gets the minZ used for shadow according to both the scene and the light.
  8806. * @param activeCamera The camera we are returning the min for
  8807. * @returns the depth min z
  8808. */
  8809. getDepthMinZ(activeCamera: Camera): number;
  8810. /**
  8811. * Gets the maxZ used for shadow according to both the scene and the light.
  8812. * @param activeCamera The camera we are returning the max for
  8813. * @returns the depth max z
  8814. */
  8815. getDepthMaxZ(activeCamera: Camera): number;
  8816. /**
  8817. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8818. * @param matrix The materix to updated with the projection information
  8819. * @param viewMatrix The transform matrix of the light
  8820. * @param renderList The list of mesh to render in the map
  8821. * @returns The current light
  8822. */
  8823. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8824. }
  8825. }
  8826. declare module BABYLON {
  8827. /**
  8828. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8829. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8830. */
  8831. export class EffectFallbacks implements IEffectFallbacks {
  8832. private _defines;
  8833. private _currentRank;
  8834. private _maxRank;
  8835. private _mesh;
  8836. /**
  8837. * Removes the fallback from the bound mesh.
  8838. */
  8839. unBindMesh(): void;
  8840. /**
  8841. * Adds a fallback on the specified property.
  8842. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8843. * @param define The name of the define in the shader
  8844. */
  8845. addFallback(rank: number, define: string): void;
  8846. /**
  8847. * Sets the mesh to use CPU skinning when needing to fallback.
  8848. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8849. * @param mesh The mesh to use the fallbacks.
  8850. */
  8851. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8852. /**
  8853. * Checks to see if more fallbacks are still availible.
  8854. */
  8855. readonly hasMoreFallbacks: boolean;
  8856. /**
  8857. * Removes the defines that should be removed when falling back.
  8858. * @param currentDefines defines the current define statements for the shader.
  8859. * @param effect defines the current effect we try to compile
  8860. * @returns The resulting defines with defines of the current rank removed.
  8861. */
  8862. reduce(currentDefines: string, effect: Effect): string;
  8863. }
  8864. }
  8865. declare module BABYLON {
  8866. /**
  8867. * "Static Class" containing the most commonly used helper while dealing with material for
  8868. * rendering purpose.
  8869. *
  8870. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8871. *
  8872. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8873. */
  8874. export class MaterialHelper {
  8875. /**
  8876. * Bind the current view position to an effect.
  8877. * @param effect The effect to be bound
  8878. * @param scene The scene the eyes position is used from
  8879. */
  8880. static BindEyePosition(effect: Effect, scene: Scene): void;
  8881. /**
  8882. * Helps preparing the defines values about the UVs in used in the effect.
  8883. * UVs are shared as much as we can accross channels in the shaders.
  8884. * @param texture The texture we are preparing the UVs for
  8885. * @param defines The defines to update
  8886. * @param key The channel key "diffuse", "specular"... used in the shader
  8887. */
  8888. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8889. /**
  8890. * Binds a texture matrix value to its corrsponding uniform
  8891. * @param texture The texture to bind the matrix for
  8892. * @param uniformBuffer The uniform buffer receivin the data
  8893. * @param key The channel key "diffuse", "specular"... used in the shader
  8894. */
  8895. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8896. /**
  8897. * Gets the current status of the fog (should it be enabled?)
  8898. * @param mesh defines the mesh to evaluate for fog support
  8899. * @param scene defines the hosting scene
  8900. * @returns true if fog must be enabled
  8901. */
  8902. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8903. /**
  8904. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8905. * @param mesh defines the current mesh
  8906. * @param scene defines the current scene
  8907. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8908. * @param pointsCloud defines if point cloud rendering has to be turned on
  8909. * @param fogEnabled defines if fog has to be turned on
  8910. * @param alphaTest defines if alpha testing has to be turned on
  8911. * @param defines defines the current list of defines
  8912. */
  8913. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8914. /**
  8915. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8916. * @param scene defines the current scene
  8917. * @param engine defines the current engine
  8918. * @param defines specifies the list of active defines
  8919. * @param useInstances defines if instances have to be turned on
  8920. * @param useClipPlane defines if clip plane have to be turned on
  8921. */
  8922. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8923. /**
  8924. * Prepares the defines for bones
  8925. * @param mesh The mesh containing the geometry data we will draw
  8926. * @param defines The defines to update
  8927. */
  8928. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8929. /**
  8930. * Prepares the defines for morph targets
  8931. * @param mesh The mesh containing the geometry data we will draw
  8932. * @param defines The defines to update
  8933. */
  8934. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8935. /**
  8936. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8937. * @param mesh The mesh containing the geometry data we will draw
  8938. * @param defines The defines to update
  8939. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8940. * @param useBones Precise whether bones should be used or not (override mesh info)
  8941. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8942. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8943. * @returns false if defines are considered not dirty and have not been checked
  8944. */
  8945. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8946. /**
  8947. * Prepares the defines related to multiview
  8948. * @param scene The scene we are intending to draw
  8949. * @param defines The defines to update
  8950. */
  8951. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8952. /**
  8953. * Prepares the defines related to the light information passed in parameter
  8954. * @param scene The scene we are intending to draw
  8955. * @param mesh The mesh the effect is compiling for
  8956. * @param light The light the effect is compiling for
  8957. * @param lightIndex The index of the light
  8958. * @param defines The defines to update
  8959. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8960. * @param state Defines the current state regarding what is needed (normals, etc...)
  8961. */
  8962. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8963. needNormals: boolean;
  8964. needRebuild: boolean;
  8965. shadowEnabled: boolean;
  8966. specularEnabled: boolean;
  8967. lightmapMode: boolean;
  8968. }): void;
  8969. /**
  8970. * Prepares the defines related to the light information passed in parameter
  8971. * @param scene The scene we are intending to draw
  8972. * @param mesh The mesh the effect is compiling for
  8973. * @param defines The defines to update
  8974. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8975. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8976. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8977. * @returns true if normals will be required for the rest of the effect
  8978. */
  8979. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8980. /**
  8981. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8982. * @param lightIndex defines the light index
  8983. * @param uniformsList The uniform list
  8984. * @param samplersList The sampler list
  8985. * @param projectedLightTexture defines if projected texture must be used
  8986. * @param uniformBuffersList defines an optional list of uniform buffers
  8987. */
  8988. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect
  8991. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8992. * @param samplersList The sampler list
  8993. * @param defines The defines helping in the list generation
  8994. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8995. */
  8996. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8997. /**
  8998. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8999. * @param defines The defines to update while falling back
  9000. * @param fallbacks The authorized effect fallbacks
  9001. * @param maxSimultaneousLights The maximum number of lights allowed
  9002. * @param rank the current rank of the Effect
  9003. * @returns The newly affected rank
  9004. */
  9005. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9006. private static _TmpMorphInfluencers;
  9007. /**
  9008. * Prepares the list of attributes required for morph targets according to the effect defines.
  9009. * @param attribs The current list of supported attribs
  9010. * @param mesh The mesh to prepare the morph targets attributes for
  9011. * @param influencers The number of influencers
  9012. */
  9013. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9014. /**
  9015. * Prepares the list of attributes required for morph targets according to the effect defines.
  9016. * @param attribs The current list of supported attribs
  9017. * @param mesh The mesh to prepare the morph targets attributes for
  9018. * @param defines The current Defines of the effect
  9019. */
  9020. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9021. /**
  9022. * Prepares the list of attributes required for bones according to the effect defines.
  9023. * @param attribs The current list of supported attribs
  9024. * @param mesh The mesh to prepare the bones attributes for
  9025. * @param defines The current Defines of the effect
  9026. * @param fallbacks The current efffect fallback strategy
  9027. */
  9028. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9029. /**
  9030. * Check and prepare the list of attributes required for instances according to the effect defines.
  9031. * @param attribs The current list of supported attribs
  9032. * @param defines The current MaterialDefines of the effect
  9033. */
  9034. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9035. /**
  9036. * Add the list of attributes required for instances to the attribs array.
  9037. * @param attribs The current list of supported attribs
  9038. */
  9039. static PushAttributesForInstances(attribs: string[]): void;
  9040. /**
  9041. * Binds the light information to the effect.
  9042. * @param light The light containing the generator
  9043. * @param effect The effect we are binding the data to
  9044. * @param lightIndex The light index in the effect used to render
  9045. */
  9046. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9047. /**
  9048. * Binds the lights information from the scene to the effect for the given mesh.
  9049. * @param light Light to bind
  9050. * @param lightIndex Light index
  9051. * @param scene The scene where the light belongs to
  9052. * @param effect The effect we are binding the data to
  9053. * @param useSpecular Defines if specular is supported
  9054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9055. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9056. */
  9057. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9058. /**
  9059. * Binds the lights information from the scene to the effect for the given mesh.
  9060. * @param scene The scene the lights belongs to
  9061. * @param mesh The mesh we are binding the information to render
  9062. * @param effect The effect we are binding the data to
  9063. * @param defines The generated defines for the effect
  9064. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9067. */
  9068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9069. private static _tempFogColor;
  9070. /**
  9071. * Binds the fog information from the scene to the effect for the given mesh.
  9072. * @param scene The scene the lights belongs to
  9073. * @param mesh The mesh we are binding the information to render
  9074. * @param effect The effect we are binding the data to
  9075. * @param linearSpace Defines if the fog effect is applied in linear space
  9076. */
  9077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9078. /**
  9079. * Binds the bones information from the mesh to the effect.
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. */
  9083. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9084. /**
  9085. * Binds the morph targets information from the mesh to the effect.
  9086. * @param abstractMesh The mesh we are binding the information to render
  9087. * @param effect The effect we are binding the data to
  9088. */
  9089. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9090. /**
  9091. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9092. * @param defines The generated defines used in the effect
  9093. * @param effect The effect we are binding the data to
  9094. * @param scene The scene we are willing to render with logarithmic scale for
  9095. */
  9096. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9097. /**
  9098. * Binds the clip plane information from the scene to the effect.
  9099. * @param scene The scene the clip plane information are extracted from
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindClipPlane(effect: Effect, scene: Scene): void;
  9103. }
  9104. }
  9105. declare module BABYLON {
  9106. /** @hidden */
  9107. export var packingFunctions: {
  9108. name: string;
  9109. shader: string;
  9110. };
  9111. }
  9112. declare module BABYLON {
  9113. /** @hidden */
  9114. export var shadowMapPixelShader: {
  9115. name: string;
  9116. shader: string;
  9117. };
  9118. }
  9119. declare module BABYLON {
  9120. /** @hidden */
  9121. export var bonesDeclaration: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module BABYLON {
  9127. /** @hidden */
  9128. export var morphTargetsVertexGlobalDeclaration: {
  9129. name: string;
  9130. shader: string;
  9131. };
  9132. }
  9133. declare module BABYLON {
  9134. /** @hidden */
  9135. export var morphTargetsVertexDeclaration: {
  9136. name: string;
  9137. shader: string;
  9138. };
  9139. }
  9140. declare module BABYLON {
  9141. /** @hidden */
  9142. export var instancesDeclaration: {
  9143. name: string;
  9144. shader: string;
  9145. };
  9146. }
  9147. declare module BABYLON {
  9148. /** @hidden */
  9149. export var helperFunctions: {
  9150. name: string;
  9151. shader: string;
  9152. };
  9153. }
  9154. declare module BABYLON {
  9155. /** @hidden */
  9156. export var morphTargetsVertex: {
  9157. name: string;
  9158. shader: string;
  9159. };
  9160. }
  9161. declare module BABYLON {
  9162. /** @hidden */
  9163. export var instancesVertex: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module BABYLON {
  9169. /** @hidden */
  9170. export var bonesVertex: {
  9171. name: string;
  9172. shader: string;
  9173. };
  9174. }
  9175. declare module BABYLON {
  9176. /** @hidden */
  9177. export var shadowMapVertexShader: {
  9178. name: string;
  9179. shader: string;
  9180. };
  9181. }
  9182. declare module BABYLON {
  9183. /** @hidden */
  9184. export var depthBoxBlurPixelShader: {
  9185. name: string;
  9186. shader: string;
  9187. };
  9188. }
  9189. declare module BABYLON {
  9190. /**
  9191. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9192. */
  9193. export interface ICustomShaderOptions {
  9194. /**
  9195. * Gets or sets the custom shader name to use
  9196. */
  9197. shaderName: string;
  9198. /**
  9199. * The list of attribute names used in the shader
  9200. */
  9201. attributes?: string[];
  9202. /**
  9203. * The list of unifrom names used in the shader
  9204. */
  9205. uniforms?: string[];
  9206. /**
  9207. * The list of sampler names used in the shader
  9208. */
  9209. samplers?: string[];
  9210. /**
  9211. * The list of defines used in the shader
  9212. */
  9213. defines?: string[];
  9214. }
  9215. /**
  9216. * Interface to implement to create a shadow generator compatible with BJS.
  9217. */
  9218. export interface IShadowGenerator {
  9219. /**
  9220. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9221. * @returns The render target texture if present otherwise, null
  9222. */
  9223. getShadowMap(): Nullable<RenderTargetTexture>;
  9224. /**
  9225. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9226. * @returns The render target texture if the shadow map is present otherwise, null
  9227. */
  9228. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9229. /**
  9230. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9231. * @param subMesh The submesh we want to render in the shadow map
  9232. * @param useInstances Defines wether will draw in the map using instances
  9233. * @returns true if ready otherwise, false
  9234. */
  9235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9236. /**
  9237. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9238. * @param defines Defines of the material we want to update
  9239. * @param lightIndex Index of the light in the enabled light list of the material
  9240. */
  9241. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9242. /**
  9243. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9244. * defined in the generator but impacting the effect).
  9245. * It implies the unifroms available on the materials are the standard BJS ones.
  9246. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9247. * @param effect The effect we are binfing the information for
  9248. */
  9249. bindShadowLight(lightIndex: string, effect: Effect): void;
  9250. /**
  9251. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9252. * (eq to shadow prjection matrix * light transform matrix)
  9253. * @returns The transform matrix used to create the shadow map
  9254. */
  9255. getTransformMatrix(): Matrix;
  9256. /**
  9257. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9258. * Cube and 2D textures for instance.
  9259. */
  9260. recreateShadowMap(): void;
  9261. /**
  9262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9263. * @param onCompiled Callback triggered at the and of the effects compilation
  9264. * @param options Sets of optional options forcing the compilation with different modes
  9265. */
  9266. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9267. useInstances: boolean;
  9268. }>): void;
  9269. /**
  9270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9271. * @param options Sets of optional options forcing the compilation with different modes
  9272. * @returns A promise that resolves when the compilation completes
  9273. */
  9274. forceCompilationAsync(options?: Partial<{
  9275. useInstances: boolean;
  9276. }>): Promise<void>;
  9277. /**
  9278. * Serializes the shadow generator setup to a json object.
  9279. * @returns The serialized JSON object
  9280. */
  9281. serialize(): any;
  9282. /**
  9283. * Disposes the Shadow map and related Textures and effects.
  9284. */
  9285. dispose(): void;
  9286. }
  9287. /**
  9288. * Default implementation IShadowGenerator.
  9289. * This is the main object responsible of generating shadows in the framework.
  9290. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9291. */
  9292. export class ShadowGenerator implements IShadowGenerator {
  9293. /**
  9294. * Shadow generator mode None: no filtering applied.
  9295. */
  9296. static readonly FILTER_NONE: number;
  9297. /**
  9298. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9299. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9300. */
  9301. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9302. /**
  9303. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9304. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9305. */
  9306. static readonly FILTER_POISSONSAMPLING: number;
  9307. /**
  9308. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9309. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9310. */
  9311. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9312. /**
  9313. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9314. * edge artifacts on steep falloff.
  9315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9316. */
  9317. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9318. /**
  9319. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9320. * edge artifacts on steep falloff.
  9321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9322. */
  9323. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9324. /**
  9325. * Shadow generator mode PCF: Percentage Closer Filtering
  9326. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9327. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9328. */
  9329. static readonly FILTER_PCF: number;
  9330. /**
  9331. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9333. * Contact Hardening
  9334. */
  9335. static readonly FILTER_PCSS: number;
  9336. /**
  9337. * Reserved for PCF and PCSS
  9338. * Highest Quality.
  9339. *
  9340. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9341. *
  9342. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9343. */
  9344. static readonly QUALITY_HIGH: number;
  9345. /**
  9346. * Reserved for PCF and PCSS
  9347. * Good tradeoff for quality/perf cross devices
  9348. *
  9349. * Execute PCF on a 3*3 kernel.
  9350. *
  9351. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9352. */
  9353. static readonly QUALITY_MEDIUM: number;
  9354. /**
  9355. * Reserved for PCF and PCSS
  9356. * The lowest quality but the fastest.
  9357. *
  9358. * Execute PCF on a 1*1 kernel.
  9359. *
  9360. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9361. */
  9362. static readonly QUALITY_LOW: number;
  9363. /** Gets or sets the custom shader name to use */
  9364. customShaderOptions: ICustomShaderOptions;
  9365. /**
  9366. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9367. */
  9368. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9369. /**
  9370. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9371. */
  9372. onAfterShadowMapRenderObservable: Observable<Effect>;
  9373. /**
  9374. * Observable triggered before a mesh is rendered in the shadow map.
  9375. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9376. */
  9377. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9378. /**
  9379. * Observable triggered after a mesh is rendered in the shadow map.
  9380. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9381. */
  9382. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9383. private _bias;
  9384. /**
  9385. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9386. */
  9387. /**
  9388. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9389. */
  9390. bias: number;
  9391. private _normalBias;
  9392. /**
  9393. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9394. */
  9395. /**
  9396. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9397. */
  9398. normalBias: number;
  9399. private _blurBoxOffset;
  9400. /**
  9401. * Gets the blur box offset: offset applied during the blur pass.
  9402. * Only useful if useKernelBlur = false
  9403. */
  9404. /**
  9405. * Sets the blur box offset: offset applied during the blur pass.
  9406. * Only useful if useKernelBlur = false
  9407. */
  9408. blurBoxOffset: number;
  9409. private _blurScale;
  9410. /**
  9411. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9412. * 2 means half of the size.
  9413. */
  9414. /**
  9415. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9416. * 2 means half of the size.
  9417. */
  9418. blurScale: number;
  9419. private _blurKernel;
  9420. /**
  9421. * Gets the blur kernel: kernel size of the blur pass.
  9422. * Only useful if useKernelBlur = true
  9423. */
  9424. /**
  9425. * Sets the blur kernel: kernel size of the blur pass.
  9426. * Only useful if useKernelBlur = true
  9427. */
  9428. blurKernel: number;
  9429. private _useKernelBlur;
  9430. /**
  9431. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9432. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9433. */
  9434. /**
  9435. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9436. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9437. */
  9438. useKernelBlur: boolean;
  9439. private _depthScale;
  9440. /**
  9441. * Gets the depth scale used in ESM mode.
  9442. */
  9443. /**
  9444. * Sets the depth scale used in ESM mode.
  9445. * This can override the scale stored on the light.
  9446. */
  9447. depthScale: number;
  9448. private _filter;
  9449. /**
  9450. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9451. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9452. */
  9453. /**
  9454. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9455. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9456. */
  9457. filter: number;
  9458. /**
  9459. * Gets if the current filter is set to Poisson Sampling.
  9460. */
  9461. /**
  9462. * Sets the current filter to Poisson Sampling.
  9463. */
  9464. usePoissonSampling: boolean;
  9465. /**
  9466. * Gets if the current filter is set to ESM.
  9467. */
  9468. /**
  9469. * Sets the current filter is to ESM.
  9470. */
  9471. useExponentialShadowMap: boolean;
  9472. /**
  9473. * Gets if the current filter is set to filtered ESM.
  9474. */
  9475. /**
  9476. * Gets if the current filter is set to filtered ESM.
  9477. */
  9478. useBlurExponentialShadowMap: boolean;
  9479. /**
  9480. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9481. * exponential to prevent steep falloff artifacts).
  9482. */
  9483. /**
  9484. * Sets the current filter to "close ESM" (using the inverse of the
  9485. * exponential to prevent steep falloff artifacts).
  9486. */
  9487. useCloseExponentialShadowMap: boolean;
  9488. /**
  9489. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9490. * exponential to prevent steep falloff artifacts).
  9491. */
  9492. /**
  9493. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9494. * exponential to prevent steep falloff artifacts).
  9495. */
  9496. useBlurCloseExponentialShadowMap: boolean;
  9497. /**
  9498. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9499. */
  9500. /**
  9501. * Sets the current filter to "PCF" (percentage closer filtering).
  9502. */
  9503. usePercentageCloserFiltering: boolean;
  9504. private _filteringQuality;
  9505. /**
  9506. * Gets the PCF or PCSS Quality.
  9507. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9508. */
  9509. /**
  9510. * Sets the PCF or PCSS Quality.
  9511. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9512. */
  9513. filteringQuality: number;
  9514. /**
  9515. * Gets if the current filter is set to "PCSS" (contact hardening).
  9516. */
  9517. /**
  9518. * Sets the current filter to "PCSS" (contact hardening).
  9519. */
  9520. useContactHardeningShadow: boolean;
  9521. private _contactHardeningLightSizeUVRatio;
  9522. /**
  9523. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9524. * Using a ratio helps keeping shape stability independently of the map size.
  9525. *
  9526. * It does not account for the light projection as it was having too much
  9527. * instability during the light setup or during light position changes.
  9528. *
  9529. * Only valid if useContactHardeningShadow is true.
  9530. */
  9531. /**
  9532. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9533. * Using a ratio helps keeping shape stability independently of the map size.
  9534. *
  9535. * It does not account for the light projection as it was having too much
  9536. * instability during the light setup or during light position changes.
  9537. *
  9538. * Only valid if useContactHardeningShadow is true.
  9539. */
  9540. contactHardeningLightSizeUVRatio: number;
  9541. private _darkness;
  9542. /** Gets or sets the actual darkness of a shadow */
  9543. darkness: number;
  9544. /**
  9545. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9546. * 0 means strongest and 1 would means no shadow.
  9547. * @returns the darkness.
  9548. */
  9549. getDarkness(): number;
  9550. /**
  9551. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9552. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9553. * @returns the shadow generator allowing fluent coding.
  9554. */
  9555. setDarkness(darkness: number): ShadowGenerator;
  9556. private _transparencyShadow;
  9557. /** Gets or sets the ability to have transparent shadow */
  9558. transparencyShadow: boolean;
  9559. /**
  9560. * Sets the ability to have transparent shadow (boolean).
  9561. * @param transparent True if transparent else False
  9562. * @returns the shadow generator allowing fluent coding
  9563. */
  9564. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9565. private _shadowMap;
  9566. private _shadowMap2;
  9567. /**
  9568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9569. * @returns The render target texture if present otherwise, null
  9570. */
  9571. getShadowMap(): Nullable<RenderTargetTexture>;
  9572. /**
  9573. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9574. * @returns The render target texture if the shadow map is present otherwise, null
  9575. */
  9576. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9577. /**
  9578. * Gets the class name of that object
  9579. * @returns "ShadowGenerator"
  9580. */
  9581. getClassName(): string;
  9582. /**
  9583. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9584. * @param mesh Mesh to add
  9585. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9586. * @returns the Shadow Generator itself
  9587. */
  9588. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9589. /**
  9590. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9591. * @param mesh Mesh to remove
  9592. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9593. * @returns the Shadow Generator itself
  9594. */
  9595. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9596. /**
  9597. * Controls the extent to which the shadows fade out at the edge of the frustum
  9598. * Used only by directionals and spots
  9599. */
  9600. frustumEdgeFalloff: number;
  9601. private _light;
  9602. /**
  9603. * Returns the associated light object.
  9604. * @returns the light generating the shadow
  9605. */
  9606. getLight(): IShadowLight;
  9607. /**
  9608. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9609. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9610. * It might on the other hand introduce peter panning.
  9611. */
  9612. forceBackFacesOnly: boolean;
  9613. private _scene;
  9614. private _lightDirection;
  9615. private _effect;
  9616. private _viewMatrix;
  9617. private _projectionMatrix;
  9618. private _transformMatrix;
  9619. private _cachedPosition;
  9620. private _cachedDirection;
  9621. private _cachedDefines;
  9622. private _currentRenderID;
  9623. private _boxBlurPostprocess;
  9624. private _kernelBlurXPostprocess;
  9625. private _kernelBlurYPostprocess;
  9626. private _blurPostProcesses;
  9627. private _mapSize;
  9628. private _currentFaceIndex;
  9629. private _currentFaceIndexCache;
  9630. private _textureType;
  9631. private _defaultTextureMatrix;
  9632. private _storedUniqueId;
  9633. /** @hidden */
  9634. static _SceneComponentInitialization: (scene: Scene) => void;
  9635. /**
  9636. * Creates a ShadowGenerator object.
  9637. * A ShadowGenerator is the required tool to use the shadows.
  9638. * Each light casting shadows needs to use its own ShadowGenerator.
  9639. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9640. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9641. * @param light The light object generating the shadows.
  9642. * @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.
  9643. */
  9644. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9645. private _initializeGenerator;
  9646. private _initializeShadowMap;
  9647. private _initializeBlurRTTAndPostProcesses;
  9648. private _renderForShadowMap;
  9649. private _renderSubMeshForShadowMap;
  9650. private _applyFilterValues;
  9651. /**
  9652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9653. * @param onCompiled Callback triggered at the and of the effects compilation
  9654. * @param options Sets of optional options forcing the compilation with different modes
  9655. */
  9656. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9657. useInstances: boolean;
  9658. }>): void;
  9659. /**
  9660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9661. * @param options Sets of optional options forcing the compilation with different modes
  9662. * @returns A promise that resolves when the compilation completes
  9663. */
  9664. forceCompilationAsync(options?: Partial<{
  9665. useInstances: boolean;
  9666. }>): Promise<void>;
  9667. /**
  9668. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9669. * @param subMesh The submesh we want to render in the shadow map
  9670. * @param useInstances Defines wether will draw in the map using instances
  9671. * @returns true if ready otherwise, false
  9672. */
  9673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9674. /**
  9675. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9676. * @param defines Defines of the material we want to update
  9677. * @param lightIndex Index of the light in the enabled light list of the material
  9678. */
  9679. prepareDefines(defines: any, lightIndex: number): void;
  9680. /**
  9681. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9682. * defined in the generator but impacting the effect).
  9683. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9684. * @param effect The effect we are binfing the information for
  9685. */
  9686. bindShadowLight(lightIndex: string, effect: Effect): void;
  9687. /**
  9688. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9689. * (eq to shadow prjection matrix * light transform matrix)
  9690. * @returns The transform matrix used to create the shadow map
  9691. */
  9692. getTransformMatrix(): Matrix;
  9693. /**
  9694. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9695. * Cube and 2D textures for instance.
  9696. */
  9697. recreateShadowMap(): void;
  9698. private _disposeBlurPostProcesses;
  9699. private _disposeRTTandPostProcesses;
  9700. /**
  9701. * Disposes the ShadowGenerator.
  9702. * Returns nothing.
  9703. */
  9704. dispose(): void;
  9705. /**
  9706. * Serializes the shadow generator setup to a json object.
  9707. * @returns The serialized JSON object
  9708. */
  9709. serialize(): any;
  9710. /**
  9711. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9712. * @param parsedShadowGenerator The JSON object to parse
  9713. * @param scene The scene to create the shadow map for
  9714. * @returns The parsed shadow generator
  9715. */
  9716. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9717. }
  9718. }
  9719. declare module BABYLON {
  9720. /**
  9721. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9722. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9723. * 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.
  9724. */
  9725. export abstract class Light extends Node {
  9726. /**
  9727. * Falloff Default: light is falling off following the material specification:
  9728. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9729. */
  9730. static readonly FALLOFF_DEFAULT: number;
  9731. /**
  9732. * Falloff Physical: light is falling off following the inverse squared distance law.
  9733. */
  9734. static readonly FALLOFF_PHYSICAL: number;
  9735. /**
  9736. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9737. * to enhance interoperability with other engines.
  9738. */
  9739. static readonly FALLOFF_GLTF: number;
  9740. /**
  9741. * Falloff Standard: light is falling off like in the standard material
  9742. * to enhance interoperability with other materials.
  9743. */
  9744. static readonly FALLOFF_STANDARD: number;
  9745. /**
  9746. * If every light affecting the material is in this lightmapMode,
  9747. * material.lightmapTexture adds or multiplies
  9748. * (depends on material.useLightmapAsShadowmap)
  9749. * after every other light calculations.
  9750. */
  9751. static readonly LIGHTMAP_DEFAULT: number;
  9752. /**
  9753. * material.lightmapTexture as only diffuse lighting from this light
  9754. * adds only specular lighting from this light
  9755. * adds dynamic shadows
  9756. */
  9757. static readonly LIGHTMAP_SPECULAR: number;
  9758. /**
  9759. * material.lightmapTexture as only lighting
  9760. * no light calculation from this light
  9761. * only adds dynamic shadows from this light
  9762. */
  9763. static readonly LIGHTMAP_SHADOWSONLY: number;
  9764. /**
  9765. * Each light type uses the default quantity according to its type:
  9766. * point/spot lights use luminous intensity
  9767. * directional lights use illuminance
  9768. */
  9769. static readonly INTENSITYMODE_AUTOMATIC: number;
  9770. /**
  9771. * lumen (lm)
  9772. */
  9773. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9774. /**
  9775. * candela (lm/sr)
  9776. */
  9777. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9778. /**
  9779. * lux (lm/m^2)
  9780. */
  9781. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9782. /**
  9783. * nit (cd/m^2)
  9784. */
  9785. static readonly INTENSITYMODE_LUMINANCE: number;
  9786. /**
  9787. * Light type const id of the point light.
  9788. */
  9789. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9790. /**
  9791. * Light type const id of the directional light.
  9792. */
  9793. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9794. /**
  9795. * Light type const id of the spot light.
  9796. */
  9797. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9798. /**
  9799. * Light type const id of the hemispheric light.
  9800. */
  9801. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9802. /**
  9803. * Diffuse gives the basic color to an object.
  9804. */
  9805. diffuse: Color3;
  9806. /**
  9807. * Specular produces a highlight color on an object.
  9808. * Note: This is note affecting PBR materials.
  9809. */
  9810. specular: Color3;
  9811. /**
  9812. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9813. * falling off base on range or angle.
  9814. * This can be set to any values in Light.FALLOFF_x.
  9815. *
  9816. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9817. * other types of materials.
  9818. */
  9819. falloffType: number;
  9820. /**
  9821. * Strength of the light.
  9822. * Note: By default it is define in the framework own unit.
  9823. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9824. */
  9825. intensity: number;
  9826. private _range;
  9827. protected _inverseSquaredRange: number;
  9828. /**
  9829. * Defines how far from the source the light is impacting in scene units.
  9830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9831. */
  9832. /**
  9833. * Defines how far from the source the light is impacting in scene units.
  9834. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9835. */
  9836. range: number;
  9837. /**
  9838. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9839. * of light.
  9840. */
  9841. private _photometricScale;
  9842. private _intensityMode;
  9843. /**
  9844. * Gets the photometric scale used to interpret the intensity.
  9845. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9846. */
  9847. /**
  9848. * Sets the photometric scale used to interpret the intensity.
  9849. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9850. */
  9851. intensityMode: number;
  9852. private _radius;
  9853. /**
  9854. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9855. */
  9856. /**
  9857. * sets the light radius used by PBR Materials to simulate soft area lights.
  9858. */
  9859. radius: number;
  9860. private _renderPriority;
  9861. /**
  9862. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9863. * exceeding the number allowed of the materials.
  9864. */
  9865. renderPriority: number;
  9866. private _shadowEnabled;
  9867. /**
  9868. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9869. * the current shadow generator.
  9870. */
  9871. /**
  9872. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9873. * the current shadow generator.
  9874. */
  9875. shadowEnabled: boolean;
  9876. private _includedOnlyMeshes;
  9877. /**
  9878. * Gets the only meshes impacted by this light.
  9879. */
  9880. /**
  9881. * Sets the only meshes impacted by this light.
  9882. */
  9883. includedOnlyMeshes: AbstractMesh[];
  9884. private _excludedMeshes;
  9885. /**
  9886. * Gets the meshes not impacted by this light.
  9887. */
  9888. /**
  9889. * Sets the meshes not impacted by this light.
  9890. */
  9891. excludedMeshes: AbstractMesh[];
  9892. private _excludeWithLayerMask;
  9893. /**
  9894. * Gets the layer id use to find what meshes are not impacted by the light.
  9895. * Inactive if 0
  9896. */
  9897. /**
  9898. * Sets the layer id use to find what meshes are not impacted by the light.
  9899. * Inactive if 0
  9900. */
  9901. excludeWithLayerMask: number;
  9902. private _includeOnlyWithLayerMask;
  9903. /**
  9904. * Gets the layer id use to find what meshes are impacted by the light.
  9905. * Inactive if 0
  9906. */
  9907. /**
  9908. * Sets the layer id use to find what meshes are impacted by the light.
  9909. * Inactive if 0
  9910. */
  9911. includeOnlyWithLayerMask: number;
  9912. private _lightmapMode;
  9913. /**
  9914. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9915. */
  9916. /**
  9917. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9918. */
  9919. lightmapMode: number;
  9920. /**
  9921. * Shadow generator associted to the light.
  9922. * @hidden Internal use only.
  9923. */
  9924. _shadowGenerator: Nullable<IShadowGenerator>;
  9925. /**
  9926. * @hidden Internal use only.
  9927. */
  9928. _excludedMeshesIds: string[];
  9929. /**
  9930. * @hidden Internal use only.
  9931. */
  9932. _includedOnlyMeshesIds: string[];
  9933. /**
  9934. * The current light unifom buffer.
  9935. * @hidden Internal use only.
  9936. */
  9937. _uniformBuffer: UniformBuffer;
  9938. /** @hidden */
  9939. _renderId: number;
  9940. /**
  9941. * Creates a Light object in the scene.
  9942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9943. * @param name The firendly name of the light
  9944. * @param scene The scene the light belongs too
  9945. */
  9946. constructor(name: string, scene: Scene);
  9947. protected abstract _buildUniformLayout(): void;
  9948. /**
  9949. * Sets the passed Effect "effect" with the Light information.
  9950. * @param effect The effect to update
  9951. * @param lightIndex The index of the light in the effect to update
  9952. * @returns The light
  9953. */
  9954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9955. /**
  9956. * Sets the passed Effect "effect" with the Light information.
  9957. * @param effect The effect to update
  9958. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9959. * @returns The light
  9960. */
  9961. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9962. /**
  9963. * Returns the string "Light".
  9964. * @returns the class name
  9965. */
  9966. getClassName(): string;
  9967. /** @hidden */
  9968. readonly _isLight: boolean;
  9969. /**
  9970. * Converts the light information to a readable string for debug purpose.
  9971. * @param fullDetails Supports for multiple levels of logging within scene loading
  9972. * @returns the human readable light info
  9973. */
  9974. toString(fullDetails?: boolean): string;
  9975. /** @hidden */
  9976. protected _syncParentEnabledState(): void;
  9977. /**
  9978. * Set the enabled state of this node.
  9979. * @param value - the new enabled state
  9980. */
  9981. setEnabled(value: boolean): void;
  9982. /**
  9983. * Returns the Light associated shadow generator if any.
  9984. * @return the associated shadow generator.
  9985. */
  9986. getShadowGenerator(): Nullable<IShadowGenerator>;
  9987. /**
  9988. * Returns a Vector3, the absolute light position in the World.
  9989. * @returns the world space position of the light
  9990. */
  9991. getAbsolutePosition(): Vector3;
  9992. /**
  9993. * Specifies if the light will affect the passed mesh.
  9994. * @param mesh The mesh to test against the light
  9995. * @return true the mesh is affected otherwise, false.
  9996. */
  9997. canAffectMesh(mesh: AbstractMesh): boolean;
  9998. /**
  9999. * Sort function to order lights for rendering.
  10000. * @param a First Light object to compare to second.
  10001. * @param b Second Light object to compare first.
  10002. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10003. */
  10004. static CompareLightsPriority(a: Light, b: Light): number;
  10005. /**
  10006. * Releases resources associated with this node.
  10007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10009. */
  10010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10011. /**
  10012. * Returns the light type ID (integer).
  10013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10014. */
  10015. getTypeID(): number;
  10016. /**
  10017. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10018. * @returns the scaled intensity in intensity mode unit
  10019. */
  10020. getScaledIntensity(): number;
  10021. /**
  10022. * Returns a new Light object, named "name", from the current one.
  10023. * @param name The name of the cloned light
  10024. * @returns the new created light
  10025. */
  10026. clone(name: string): Nullable<Light>;
  10027. /**
  10028. * Serializes the current light into a Serialization object.
  10029. * @returns the serialized object.
  10030. */
  10031. serialize(): any;
  10032. /**
  10033. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10034. * This new light is named "name" and added to the passed scene.
  10035. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10036. * @param name The friendly name of the light
  10037. * @param scene The scene the new light will belong to
  10038. * @returns the constructor function
  10039. */
  10040. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10041. /**
  10042. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10043. * @param parsedLight The JSON representation of the light
  10044. * @param scene The scene to create the parsed light in
  10045. * @returns the created light after parsing
  10046. */
  10047. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10048. private _hookArrayForExcluded;
  10049. private _hookArrayForIncludedOnly;
  10050. private _resyncMeshes;
  10051. /**
  10052. * Forces the meshes to update their light related information in their rendering used effects
  10053. * @hidden Internal Use Only
  10054. */
  10055. _markMeshesAsLightDirty(): void;
  10056. /**
  10057. * Recomputes the cached photometric scale if needed.
  10058. */
  10059. private _computePhotometricScale;
  10060. /**
  10061. * Returns the Photometric Scale according to the light type and intensity mode.
  10062. */
  10063. private _getPhotometricScale;
  10064. /**
  10065. * Reorder the light in the scene according to their defined priority.
  10066. * @hidden Internal Use Only
  10067. */
  10068. _reorderLightsInScene(): void;
  10069. /**
  10070. * Prepares the list of defines specific to the light type.
  10071. * @param defines the list of defines
  10072. * @param lightIndex defines the index of the light for the effect
  10073. */
  10074. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10075. }
  10076. }
  10077. declare module BABYLON {
  10078. /**
  10079. * Interface used to define Action
  10080. */
  10081. export interface IAction {
  10082. /**
  10083. * Trigger for the action
  10084. */
  10085. trigger: number;
  10086. /** Options of the trigger */
  10087. triggerOptions: any;
  10088. /**
  10089. * Gets the trigger parameters
  10090. * @returns the trigger parameters
  10091. */
  10092. getTriggerParameter(): any;
  10093. /**
  10094. * Internal only - executes current action event
  10095. * @hidden
  10096. */
  10097. _executeCurrent(evt?: ActionEvent): void;
  10098. /**
  10099. * Serialize placeholder for child classes
  10100. * @param parent of child
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. /**
  10105. * Internal only
  10106. * @hidden
  10107. */
  10108. _prepare(): void;
  10109. /**
  10110. * Internal only - manager for action
  10111. * @hidden
  10112. */
  10113. _actionManager: AbstractActionManager;
  10114. /**
  10115. * Adds action to chain of actions, may be a DoNothingAction
  10116. * @param action defines the next action to execute
  10117. * @returns The action passed in
  10118. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10119. */
  10120. then(action: IAction): IAction;
  10121. }
  10122. /**
  10123. * The action to be carried out following a trigger
  10124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10125. */
  10126. export class Action implements IAction {
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any;
  10129. /**
  10130. * Trigger for the action
  10131. */
  10132. trigger: number;
  10133. /**
  10134. * Internal only - manager for action
  10135. * @hidden
  10136. */
  10137. _actionManager: ActionManager;
  10138. private _nextActiveAction;
  10139. private _child;
  10140. private _condition?;
  10141. private _triggerParameter;
  10142. /**
  10143. * An event triggered prior to action being executed.
  10144. */
  10145. onBeforeExecuteObservable: Observable<Action>;
  10146. /**
  10147. * Creates a new Action
  10148. * @param triggerOptions the trigger, with or without parameters, for the action
  10149. * @param condition an optional determinant of action
  10150. */
  10151. constructor(
  10152. /** the trigger, with or without parameters, for the action */
  10153. triggerOptions: any, condition?: Condition);
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. _prepare(): void;
  10159. /**
  10160. * Gets the trigger parameters
  10161. * @returns the trigger parameters
  10162. */
  10163. getTriggerParameter(): any;
  10164. /**
  10165. * Internal only - executes current action event
  10166. * @hidden
  10167. */
  10168. _executeCurrent(evt?: ActionEvent): void;
  10169. /**
  10170. * Execute placeholder for child classes
  10171. * @param evt optional action event
  10172. */
  10173. execute(evt?: ActionEvent): void;
  10174. /**
  10175. * Skips to next active action
  10176. */
  10177. skipToNextActiveAction(): void;
  10178. /**
  10179. * Adds action to chain of actions, may be a DoNothingAction
  10180. * @param action defines the next action to execute
  10181. * @returns The action passed in
  10182. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10183. */
  10184. then(action: Action): Action;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. _getProperty(propertyPath: string): string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _getEffectiveTarget(target: any, propertyPath: string): any;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @param parent of child
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. /**
  10202. * Internal only called by serialize
  10203. * @hidden
  10204. */
  10205. protected _serialize(serializedAction: any, parent?: any): any;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. static _SerializeValueAsString: (value: any) => string;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. static _GetTargetProperty: (target: Node | Scene) => {
  10216. name: string;
  10217. targetType: string;
  10218. value: string;
  10219. };
  10220. }
  10221. }
  10222. declare module BABYLON {
  10223. /**
  10224. * A Condition applied to an Action
  10225. */
  10226. export class Condition {
  10227. /**
  10228. * Internal only - manager for action
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. _evaluationId: number;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. _currentResult: boolean;
  10242. /**
  10243. * Creates a new Condition
  10244. * @param actionManager the manager of the action the condition is applied to
  10245. */
  10246. constructor(actionManager: ActionManager);
  10247. /**
  10248. * Check if the current condition is valid
  10249. * @returns a boolean
  10250. */
  10251. isValid(): boolean;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. _getProperty(propertyPath: string): string;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _getEffectiveTarget(target: any, propertyPath: string): any;
  10262. /**
  10263. * Serialize placeholder for child classes
  10264. * @returns the serialized object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. protected _serialize(serializedCondition: any): any;
  10272. }
  10273. /**
  10274. * Defines specific conditional operators as extensions of Condition
  10275. */
  10276. export class ValueCondition extends Condition {
  10277. /** path to specify the property of the target the conditional operator uses */
  10278. propertyPath: string;
  10279. /** the value compared by the conditional operator against the current value of the property */
  10280. value: any;
  10281. /** the conditional operator, default ValueCondition.IsEqual */
  10282. operator: number;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private static _IsEqual;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. private static _IsDifferent;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. private static _IsGreater;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. private static _IsLesser;
  10303. /**
  10304. * returns the number for IsEqual
  10305. */
  10306. static readonly IsEqual: number;
  10307. /**
  10308. * Returns the number for IsDifferent
  10309. */
  10310. static readonly IsDifferent: number;
  10311. /**
  10312. * Returns the number for IsGreater
  10313. */
  10314. static readonly IsGreater: number;
  10315. /**
  10316. * Returns the number for IsLesser
  10317. */
  10318. static readonly IsLesser: number;
  10319. /**
  10320. * Internal only The action manager for the condition
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. private _target;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _effectiveTarget;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private _property;
  10339. /**
  10340. * Creates a new ValueCondition
  10341. * @param actionManager manager for the action the condition applies to
  10342. * @param target for the action
  10343. * @param propertyPath path to specify the property of the target the conditional operator uses
  10344. * @param value the value compared by the conditional operator against the current value of the property
  10345. * @param operator the conditional operator, default ValueCondition.IsEqual
  10346. */
  10347. constructor(actionManager: ActionManager, target: any,
  10348. /** path to specify the property of the target the conditional operator uses */
  10349. propertyPath: string,
  10350. /** the value compared by the conditional operator against the current value of the property */
  10351. value: any,
  10352. /** the conditional operator, default ValueCondition.IsEqual */
  10353. operator?: number);
  10354. /**
  10355. * Compares the given value with the property value for the specified conditional operator
  10356. * @returns the result of the comparison
  10357. */
  10358. isValid(): boolean;
  10359. /**
  10360. * Serialize the ValueCondition into a JSON compatible object
  10361. * @returns serialization object
  10362. */
  10363. serialize(): any;
  10364. /**
  10365. * Gets the name of the conditional operator for the ValueCondition
  10366. * @param operator the conditional operator
  10367. * @returns the name
  10368. */
  10369. static GetOperatorName(operator: number): string;
  10370. }
  10371. /**
  10372. * Defines a predicate condition as an extension of Condition
  10373. */
  10374. export class PredicateCondition extends Condition {
  10375. /** defines the predicate function used to validate the condition */
  10376. predicate: () => boolean;
  10377. /**
  10378. * Internal only - manager for action
  10379. * @hidden
  10380. */
  10381. _actionManager: ActionManager;
  10382. /**
  10383. * Creates a new PredicateCondition
  10384. * @param actionManager manager for the action the condition applies to
  10385. * @param predicate defines the predicate function used to validate the condition
  10386. */
  10387. constructor(actionManager: ActionManager,
  10388. /** defines the predicate function used to validate the condition */
  10389. predicate: () => boolean);
  10390. /**
  10391. * @returns the validity of the predicate condition
  10392. */
  10393. isValid(): boolean;
  10394. }
  10395. /**
  10396. * Defines a state condition as an extension of Condition
  10397. */
  10398. export class StateCondition extends Condition {
  10399. /** Value to compare with target state */
  10400. value: string;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: ActionManager;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private _target;
  10411. /**
  10412. * Creates a new StateCondition
  10413. * @param actionManager manager for the action the condition applies to
  10414. * @param target of the condition
  10415. * @param value to compare with target state
  10416. */
  10417. constructor(actionManager: ActionManager, target: any,
  10418. /** Value to compare with target state */
  10419. value: string);
  10420. /**
  10421. * Gets a boolean indicating if the current condition is met
  10422. * @returns the validity of the state
  10423. */
  10424. isValid(): boolean;
  10425. /**
  10426. * Serialize the StateCondition into a JSON compatible object
  10427. * @returns serialization object
  10428. */
  10429. serialize(): any;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * This defines an action responsible to toggle a boolean once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SwitchBooleanAction extends Action {
  10438. /**
  10439. * The path to the boolean property in the target object
  10440. */
  10441. propertyPath: string;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the boolean
  10449. * @param propertyPath defines the path to the boolean property in the target object
  10450. * @param condition defines the trigger related conditions
  10451. */
  10452. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10453. /** @hidden */
  10454. _prepare(): void;
  10455. /**
  10456. * Execute the action toggle the boolean value.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to set a the state field of the target
  10468. * to a desired value once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class SetStateAction extends Action {
  10472. /**
  10473. * The value to store in the state field.
  10474. */
  10475. value: string;
  10476. private _target;
  10477. /**
  10478. * Instantiate the action
  10479. * @param triggerOptions defines the trigger options
  10480. * @param target defines the object containing the state property
  10481. * @param value defines the value to store in the state field
  10482. * @param condition defines the trigger related conditions
  10483. */
  10484. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10485. /**
  10486. * Execute the action and store the value on the target state property.
  10487. */
  10488. execute(): void;
  10489. /**
  10490. * Serializes the actions and its related information.
  10491. * @param parent defines the object to serialize in
  10492. * @returns the serialized object
  10493. */
  10494. serialize(parent: any): any;
  10495. }
  10496. /**
  10497. * This defines an action responsible to set a property of the target
  10498. * to a desired value once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SetValueAction extends Action {
  10502. /**
  10503. * The path of the property to set in the target.
  10504. */
  10505. propertyPath: string;
  10506. /**
  10507. * The value to set in the property
  10508. */
  10509. value: any;
  10510. private _target;
  10511. private _effectiveTarget;
  10512. private _property;
  10513. /**
  10514. * Instantiate the action
  10515. * @param triggerOptions defines the trigger options
  10516. * @param target defines the object containing the property
  10517. * @param propertyPath defines the path of the property to set in the target
  10518. * @param value defines the value to set in the property
  10519. * @param condition defines the trigger related conditions
  10520. */
  10521. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10522. /** @hidden */
  10523. _prepare(): void;
  10524. /**
  10525. * Execute the action and set the targetted property to the desired value.
  10526. */
  10527. execute(): void;
  10528. /**
  10529. * Serializes the actions and its related information.
  10530. * @param parent defines the object to serialize in
  10531. * @returns the serialized object
  10532. */
  10533. serialize(parent: any): any;
  10534. }
  10535. /**
  10536. * This defines an action responsible to increment the target value
  10537. * to a desired value once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class IncrementValueAction extends Action {
  10541. /**
  10542. * The path of the property to increment in the target.
  10543. */
  10544. propertyPath: string;
  10545. /**
  10546. * The value we should increment the property by.
  10547. */
  10548. value: any;
  10549. private _target;
  10550. private _effectiveTarget;
  10551. private _property;
  10552. /**
  10553. * Instantiate the action
  10554. * @param triggerOptions defines the trigger options
  10555. * @param target defines the object containing the property
  10556. * @param propertyPath defines the path of the property to increment in the target
  10557. * @param value defines the value value we should increment the property by
  10558. * @param condition defines the trigger related conditions
  10559. */
  10560. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10561. /** @hidden */
  10562. _prepare(): void;
  10563. /**
  10564. * Execute the action and increment the target of the value amount.
  10565. */
  10566. execute(): void;
  10567. /**
  10568. * Serializes the actions and its related information.
  10569. * @param parent defines the object to serialize in
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. }
  10574. /**
  10575. * This defines an action responsible to start an animation once triggered.
  10576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10577. */
  10578. export class PlayAnimationAction extends Action {
  10579. /**
  10580. * Where the animation should start (animation frame)
  10581. */
  10582. from: number;
  10583. /**
  10584. * Where the animation should stop (animation frame)
  10585. */
  10586. to: number;
  10587. /**
  10588. * Define if the animation should loop or stop after the first play.
  10589. */
  10590. loop?: boolean;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the target animation or animation name
  10596. * @param from defines from where the animation should start (animation frame)
  10597. * @param end defines where the animation should stop (animation frame)
  10598. * @param loop defines if the animation should loop or stop after the first play
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and play the animation.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to stop an animation once triggered.
  10617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class StopAnimationAction extends Action {
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target animation or animation name
  10625. * @param condition defines the trigger related conditions
  10626. */
  10627. constructor(triggerOptions: any, target: any, condition?: Condition);
  10628. /** @hidden */
  10629. _prepare(): void;
  10630. /**
  10631. * Execute the action and stop the animation.
  10632. */
  10633. execute(): void;
  10634. /**
  10635. * Serializes the actions and its related information.
  10636. * @param parent defines the object to serialize in
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. }
  10641. /**
  10642. * This defines an action responsible that does nothing once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class DoNothingAction extends Action {
  10646. /**
  10647. * Instantiate the action
  10648. * @param triggerOptions defines the trigger options
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions?: any, condition?: Condition);
  10652. /**
  10653. * Execute the action and do nothing.
  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 trigger several actions once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class CombineAction extends Action {
  10668. /**
  10669. * The list of aggregated animations to run.
  10670. */
  10671. children: Action[];
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param children defines the list of aggregated animations to run
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action and executes all the aggregated actions.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to run code (external event) once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class ExecuteCodeAction extends Action {
  10697. /**
  10698. * The callback function to run.
  10699. */
  10700. func: (evt: ActionEvent) => void;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param func defines the callback function to run
  10705. * @param condition defines the trigger related conditions
  10706. */
  10707. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10708. /**
  10709. * Execute the action and run the attached code.
  10710. */
  10711. execute(evt: ActionEvent): void;
  10712. }
  10713. /**
  10714. * This defines an action responsible to set the parent property of the target once triggered.
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10716. */
  10717. export class SetParentAction extends Action {
  10718. private _parent;
  10719. private _target;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the target containing the parent property
  10724. * @param parent defines from where the animation should start (animation frame)
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and set the parent property.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. }
  10742. declare module BABYLON {
  10743. /**
  10744. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10745. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class ActionManager extends AbstractActionManager {
  10749. /**
  10750. * Nothing
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly NothingTrigger: number;
  10754. /**
  10755. * On pick
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnPickTrigger: number;
  10759. /**
  10760. * On left pick
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnLeftPickTrigger: number;
  10764. /**
  10765. * On right pick
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10767. */
  10768. static readonly OnRightPickTrigger: number;
  10769. /**
  10770. * On center pick
  10771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnCenterPickTrigger: number;
  10774. /**
  10775. * On pick down
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnPickDownTrigger: number;
  10779. /**
  10780. * On double pick
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnDoublePickTrigger: number;
  10784. /**
  10785. * On pick up
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPickUpTrigger: number;
  10789. /**
  10790. * On pick out.
  10791. * This trigger will only be raised if you also declared a OnPickDown
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10793. */
  10794. static readonly OnPickOutTrigger: number;
  10795. /**
  10796. * On long press
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly OnLongPressTrigger: number;
  10800. /**
  10801. * On pointer over
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPointerOverTrigger: number;
  10805. /**
  10806. * On pointer out
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPointerOutTrigger: number;
  10810. /**
  10811. * On every frame
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnEveryFrameTrigger: number;
  10815. /**
  10816. * On intersection enter
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnIntersectionEnterTrigger: number;
  10820. /**
  10821. * On intersection exit
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnIntersectionExitTrigger: number;
  10825. /**
  10826. * On key down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnKeyDownTrigger: number;
  10830. /**
  10831. * On key up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnKeyUpTrigger: number;
  10835. private _scene;
  10836. /**
  10837. * Creates a new action manager
  10838. * @param scene defines the hosting scene
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Releases all associated resources
  10843. */
  10844. dispose(): void;
  10845. /**
  10846. * Gets hosting scene
  10847. * @returns the hosting scene
  10848. */
  10849. getScene(): Scene;
  10850. /**
  10851. * Does this action manager handles actions of any of the given triggers
  10852. * @param triggers defines the triggers to be tested
  10853. * @return a boolean indicating whether one (or more) of the triggers is handled
  10854. */
  10855. hasSpecificTriggers(triggers: number[]): boolean;
  10856. /**
  10857. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10858. * speed.
  10859. * @param triggerA defines the trigger to be tested
  10860. * @param triggerB defines the trigger to be tested
  10861. * @return a boolean indicating whether one (or more) of the triggers is handled
  10862. */
  10863. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10864. /**
  10865. * Does this action manager handles actions of a given trigger
  10866. * @param trigger defines the trigger to be tested
  10867. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10868. * @return whether the trigger is handled
  10869. */
  10870. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10871. /**
  10872. * Does this action manager has pointer triggers
  10873. */
  10874. readonly hasPointerTriggers: boolean;
  10875. /**
  10876. * Does this action manager has pick triggers
  10877. */
  10878. readonly hasPickTriggers: boolean;
  10879. /**
  10880. * Registers an action to this action manager
  10881. * @param action defines the action to be registered
  10882. * @return the action amended (prepared) after registration
  10883. */
  10884. registerAction(action: IAction): Nullable<IAction>;
  10885. /**
  10886. * Unregisters an action to this action manager
  10887. * @param action defines the action to be unregistered
  10888. * @return a boolean indicating whether the action has been unregistered
  10889. */
  10890. unregisterAction(action: IAction): Boolean;
  10891. /**
  10892. * Process a specific trigger
  10893. * @param trigger defines the trigger to process
  10894. * @param evt defines the event details to be processed
  10895. */
  10896. processTrigger(trigger: number, evt?: IActionEvent): void;
  10897. /** @hidden */
  10898. _getEffectiveTarget(target: any, propertyPath: string): any;
  10899. /** @hidden */
  10900. _getProperty(propertyPath: string): string;
  10901. /**
  10902. * Serialize this manager to a JSON object
  10903. * @param name defines the property name to store this manager
  10904. * @returns a JSON representation of this manager
  10905. */
  10906. serialize(name: string): any;
  10907. /**
  10908. * Creates a new ActionManager from a JSON data
  10909. * @param parsedActions defines the JSON data to read from
  10910. * @param object defines the hosting mesh
  10911. * @param scene defines the hosting scene
  10912. */
  10913. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10914. /**
  10915. * Get a trigger name by index
  10916. * @param trigger defines the trigger index
  10917. * @returns a trigger name
  10918. */
  10919. static GetTriggerName(trigger: number): string;
  10920. }
  10921. }
  10922. declare module BABYLON {
  10923. /**
  10924. * Class representing a ray with position and direction
  10925. */
  10926. export class Ray {
  10927. /** origin point */
  10928. origin: Vector3;
  10929. /** direction */
  10930. direction: Vector3;
  10931. /** length of the ray */
  10932. length: number;
  10933. private static readonly TmpVector3;
  10934. private _tmpRay;
  10935. /**
  10936. * Creates a new ray
  10937. * @param origin origin point
  10938. * @param direction direction
  10939. * @param length length of the ray
  10940. */
  10941. constructor(
  10942. /** origin point */
  10943. origin: Vector3,
  10944. /** direction */
  10945. direction: Vector3,
  10946. /** length of the ray */
  10947. length?: number);
  10948. /**
  10949. * Checks if the ray intersects a box
  10950. * @param minimum bound of the box
  10951. * @param maximum bound of the box
  10952. * @param intersectionTreshold extra extend to be added to the box in all direction
  10953. * @returns if the box was hit
  10954. */
  10955. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10956. /**
  10957. * Checks if the ray intersects a box
  10958. * @param box the bounding box to check
  10959. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10960. * @returns if the box was hit
  10961. */
  10962. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10963. /**
  10964. * If the ray hits a sphere
  10965. * @param sphere the bounding sphere to check
  10966. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10967. * @returns true if it hits the sphere
  10968. */
  10969. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10970. /**
  10971. * If the ray hits a triange
  10972. * @param vertex0 triangle vertex
  10973. * @param vertex1 triangle vertex
  10974. * @param vertex2 triangle vertex
  10975. * @returns intersection information if hit
  10976. */
  10977. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10978. /**
  10979. * Checks if ray intersects a plane
  10980. * @param plane the plane to check
  10981. * @returns the distance away it was hit
  10982. */
  10983. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10984. /**
  10985. * Calculate the intercept of a ray on a given axis
  10986. * @param axis to check 'x' | 'y' | 'z'
  10987. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10988. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10989. */
  10990. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10991. /**
  10992. * Checks if ray intersects a mesh
  10993. * @param mesh the mesh to check
  10994. * @param fastCheck if only the bounding box should checked
  10995. * @returns picking info of the intersecton
  10996. */
  10997. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10998. /**
  10999. * Checks if ray intersects a mesh
  11000. * @param meshes the meshes to check
  11001. * @param fastCheck if only the bounding box should checked
  11002. * @param results array to store result in
  11003. * @returns Array of picking infos
  11004. */
  11005. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11006. private _comparePickingInfo;
  11007. private static smallnum;
  11008. private static rayl;
  11009. /**
  11010. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11011. * @param sega the first point of the segment to test the intersection against
  11012. * @param segb the second point of the segment to test the intersection against
  11013. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11014. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11015. */
  11016. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11017. /**
  11018. * Update the ray from viewport position
  11019. * @param x position
  11020. * @param y y position
  11021. * @param viewportWidth viewport width
  11022. * @param viewportHeight viewport height
  11023. * @param world world matrix
  11024. * @param view view matrix
  11025. * @param projection projection matrix
  11026. * @returns this ray updated
  11027. */
  11028. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11029. /**
  11030. * Creates a ray with origin and direction of 0,0,0
  11031. * @returns the new ray
  11032. */
  11033. static Zero(): Ray;
  11034. /**
  11035. * Creates a new ray from screen space and viewport
  11036. * @param x position
  11037. * @param y y position
  11038. * @param viewportWidth viewport width
  11039. * @param viewportHeight viewport height
  11040. * @param world world matrix
  11041. * @param view view matrix
  11042. * @param projection projection matrix
  11043. * @returns new ray
  11044. */
  11045. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11046. /**
  11047. * 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
  11048. * transformed to the given world matrix.
  11049. * @param origin The origin point
  11050. * @param end The end point
  11051. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11052. * @returns the new ray
  11053. */
  11054. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11055. /**
  11056. * Transforms a ray by a matrix
  11057. * @param ray ray to transform
  11058. * @param matrix matrix to apply
  11059. * @returns the resulting new ray
  11060. */
  11061. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11062. /**
  11063. * Transforms a ray by a matrix
  11064. * @param ray ray to transform
  11065. * @param matrix matrix to apply
  11066. * @param result ray to store result in
  11067. */
  11068. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11069. /**
  11070. * Unproject a ray from screen space to object space
  11071. * @param sourceX defines the screen space x coordinate to use
  11072. * @param sourceY defines the screen space y coordinate to use
  11073. * @param viewportWidth defines the current width of the viewport
  11074. * @param viewportHeight defines the current height of the viewport
  11075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11076. * @param view defines the view matrix to use
  11077. * @param projection defines the projection matrix to use
  11078. */
  11079. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11080. }
  11081. /**
  11082. * Type used to define predicate used to select faces when a mesh intersection is detected
  11083. */
  11084. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11085. interface Scene {
  11086. /** @hidden */
  11087. _tempPickingRay: Nullable<Ray>;
  11088. /** @hidden */
  11089. _cachedRayForTransform: Ray;
  11090. /** @hidden */
  11091. _pickWithRayInverseMatrix: Matrix;
  11092. /** @hidden */
  11093. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11094. /** @hidden */
  11095. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11096. }
  11097. }
  11098. declare module BABYLON {
  11099. /**
  11100. * Groups all the scene component constants in one place to ease maintenance.
  11101. * @hidden
  11102. */
  11103. export class SceneComponentConstants {
  11104. static readonly NAME_EFFECTLAYER: string;
  11105. static readonly NAME_LAYER: string;
  11106. static readonly NAME_LENSFLARESYSTEM: string;
  11107. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11108. static readonly NAME_PARTICLESYSTEM: string;
  11109. static readonly NAME_GAMEPAD: string;
  11110. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11111. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11112. static readonly NAME_DEPTHRENDERER: string;
  11113. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11114. static readonly NAME_SPRITE: string;
  11115. static readonly NAME_OUTLINERENDERER: string;
  11116. static readonly NAME_PROCEDURALTEXTURE: string;
  11117. static readonly NAME_SHADOWGENERATOR: string;
  11118. static readonly NAME_OCTREE: string;
  11119. static readonly NAME_PHYSICSENGINE: string;
  11120. static readonly NAME_AUDIO: string;
  11121. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11122. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11123. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11125. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11126. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11127. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11128. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11129. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11130. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11131. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11132. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11133. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11134. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11135. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11136. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11137. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11138. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11139. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11140. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11141. static readonly STEP_AFTERRENDER_AUDIO: number;
  11142. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11143. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11144. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11145. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11146. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11147. static readonly STEP_POINTERMOVE_SPRITE: number;
  11148. static readonly STEP_POINTERDOWN_SPRITE: number;
  11149. static readonly STEP_POINTERUP_SPRITE: number;
  11150. }
  11151. /**
  11152. * This represents a scene component.
  11153. *
  11154. * This is used to decouple the dependency the scene is having on the different workloads like
  11155. * layers, post processes...
  11156. */
  11157. export interface ISceneComponent {
  11158. /**
  11159. * The name of the component. Each component must have a unique name.
  11160. */
  11161. name: string;
  11162. /**
  11163. * The scene the component belongs to.
  11164. */
  11165. scene: Scene;
  11166. /**
  11167. * Register the component to one instance of a scene.
  11168. */
  11169. register(): void;
  11170. /**
  11171. * Rebuilds the elements related to this component in case of
  11172. * context lost for instance.
  11173. */
  11174. rebuild(): void;
  11175. /**
  11176. * Disposes the component and the associated ressources.
  11177. */
  11178. dispose(): void;
  11179. }
  11180. /**
  11181. * This represents a SERIALIZABLE scene component.
  11182. *
  11183. * This extends Scene Component to add Serialization methods on top.
  11184. */
  11185. export interface ISceneSerializableComponent extends ISceneComponent {
  11186. /**
  11187. * Adds all the elements from the container to the scene
  11188. * @param container the container holding the elements
  11189. */
  11190. addFromContainer(container: AbstractScene): void;
  11191. /**
  11192. * Removes all the elements in the container from the scene
  11193. * @param container contains the elements to remove
  11194. * @param dispose if the removed element should be disposed (default: false)
  11195. */
  11196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11197. /**
  11198. * Serializes the component data to the specified json object
  11199. * @param serializationObject The object to serialize to
  11200. */
  11201. serialize(serializationObject: any): void;
  11202. }
  11203. /**
  11204. * Strong typing of a Mesh related stage step action
  11205. */
  11206. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11207. /**
  11208. * Strong typing of a Evaluate Sub Mesh related stage step action
  11209. */
  11210. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11211. /**
  11212. * Strong typing of a Active Mesh related stage step action
  11213. */
  11214. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11215. /**
  11216. * Strong typing of a Camera related stage step action
  11217. */
  11218. export type CameraStageAction = (camera: Camera) => void;
  11219. /**
  11220. * Strong typing of a Camera Frame buffer related stage step action
  11221. */
  11222. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11223. /**
  11224. * Strong typing of a Render Target related stage step action
  11225. */
  11226. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11227. /**
  11228. * Strong typing of a RenderingGroup related stage step action
  11229. */
  11230. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11231. /**
  11232. * Strong typing of a Mesh Render related stage step action
  11233. */
  11234. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11235. /**
  11236. * Strong typing of a simple stage step action
  11237. */
  11238. export type SimpleStageAction = () => void;
  11239. /**
  11240. * Strong typing of a render target action.
  11241. */
  11242. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11243. /**
  11244. * Strong typing of a pointer move action.
  11245. */
  11246. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11247. /**
  11248. * Strong typing of a pointer up/down action.
  11249. */
  11250. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11251. /**
  11252. * Representation of a stage in the scene (Basically a list of ordered steps)
  11253. * @hidden
  11254. */
  11255. export class Stage<T extends Function> extends Array<{
  11256. index: number;
  11257. component: ISceneComponent;
  11258. action: T;
  11259. }> {
  11260. /**
  11261. * Hide ctor from the rest of the world.
  11262. * @param items The items to add.
  11263. */
  11264. private constructor();
  11265. /**
  11266. * Creates a new Stage.
  11267. * @returns A new instance of a Stage
  11268. */
  11269. static Create<T extends Function>(): Stage<T>;
  11270. /**
  11271. * Registers a step in an ordered way in the targeted stage.
  11272. * @param index Defines the position to register the step in
  11273. * @param component Defines the component attached to the step
  11274. * @param action Defines the action to launch during the step
  11275. */
  11276. registerStep(index: number, component: ISceneComponent, action: T): void;
  11277. /**
  11278. * Clears all the steps from the stage.
  11279. */
  11280. clear(): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface Scene {
  11285. /** @hidden */
  11286. _pointerOverSprite: Nullable<Sprite>;
  11287. /** @hidden */
  11288. _pickedDownSprite: Nullable<Sprite>;
  11289. /** @hidden */
  11290. _tempSpritePickingRay: Nullable<Ray>;
  11291. /**
  11292. * All of the sprite managers added to this scene
  11293. * @see http://doc.babylonjs.com/babylon101/sprites
  11294. */
  11295. spriteManagers: Array<ISpriteManager>;
  11296. /**
  11297. * An event triggered when sprites rendering is about to start
  11298. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11299. */
  11300. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11301. /**
  11302. * An event triggered when sprites rendering is done
  11303. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11304. */
  11305. onAfterSpritesRenderingObservable: Observable<Scene>;
  11306. /** @hidden */
  11307. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11308. /** Launch a ray to try to pick a sprite in the scene
  11309. * @param x position on screen
  11310. * @param y position on screen
  11311. * @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
  11312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11314. * @returns a PickingInfo
  11315. */
  11316. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11317. /** Use the given ray to pick a sprite in the scene
  11318. * @param ray The ray (in world space) to use to pick meshes
  11319. * @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
  11320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11322. * @returns a PickingInfo
  11323. */
  11324. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11325. /** @hidden */
  11326. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11327. /** Launch a ray to try to pick sprites in the scene
  11328. * @param x position on screen
  11329. * @param y position on screen
  11330. * @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
  11331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /** Use the given ray to pick sprites in the scene
  11336. * @param ray The ray (in world space) to use to pick meshes
  11337. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11339. * @returns a PickingInfo array
  11340. */
  11341. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11342. /**
  11343. * Force the sprite under the pointer
  11344. * @param sprite defines the sprite to use
  11345. */
  11346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11347. /**
  11348. * Gets the sprite under the pointer
  11349. * @returns a Sprite or null if no sprite is under the pointer
  11350. */
  11351. getPointerOverSprite(): Nullable<Sprite>;
  11352. }
  11353. /**
  11354. * Defines the sprite scene component responsible to manage sprites
  11355. * in a given scene.
  11356. */
  11357. export class SpriteSceneComponent implements ISceneComponent {
  11358. /**
  11359. * The component name helpfull to identify the component in the list of scene components.
  11360. */
  11361. readonly name: string;
  11362. /**
  11363. * The scene the component belongs to.
  11364. */
  11365. scene: Scene;
  11366. /** @hidden */
  11367. private _spritePredicate;
  11368. /**
  11369. * Creates a new instance of the component for the given scene
  11370. * @param scene Defines the scene to register the component in
  11371. */
  11372. constructor(scene: Scene);
  11373. /**
  11374. * Registers the component in a given scene
  11375. */
  11376. register(): void;
  11377. /**
  11378. * Rebuilds the elements related to this component in case of
  11379. * context lost for instance.
  11380. */
  11381. rebuild(): void;
  11382. /**
  11383. * Disposes the component and the associated ressources.
  11384. */
  11385. dispose(): void;
  11386. private _pickSpriteButKeepRay;
  11387. private _pointerMove;
  11388. private _pointerDown;
  11389. private _pointerUp;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /** @hidden */
  11394. export var fogFragmentDeclaration: {
  11395. name: string;
  11396. shader: string;
  11397. };
  11398. }
  11399. declare module BABYLON {
  11400. /** @hidden */
  11401. export var fogFragment: {
  11402. name: string;
  11403. shader: string;
  11404. };
  11405. }
  11406. declare module BABYLON {
  11407. /** @hidden */
  11408. export var spritesPixelShader: {
  11409. name: string;
  11410. shader: string;
  11411. };
  11412. }
  11413. declare module BABYLON {
  11414. /** @hidden */
  11415. export var fogVertexDeclaration: {
  11416. name: string;
  11417. shader: string;
  11418. };
  11419. }
  11420. declare module BABYLON {
  11421. /** @hidden */
  11422. export var spritesVertexShader: {
  11423. name: string;
  11424. shader: string;
  11425. };
  11426. }
  11427. declare module BABYLON {
  11428. /**
  11429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11430. */
  11431. export interface ISpriteManager extends IDisposable {
  11432. /**
  11433. * Restricts the camera to viewing objects with the same layerMask.
  11434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11435. */
  11436. layerMask: number;
  11437. /**
  11438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11439. */
  11440. isPickable: boolean;
  11441. /**
  11442. * Specifies the rendering group id for this mesh (0 by default)
  11443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11444. */
  11445. renderingGroupId: number;
  11446. /**
  11447. * Defines the list of sprites managed by the manager.
  11448. */
  11449. sprites: Array<Sprite>;
  11450. /**
  11451. * Tests the intersection of a sprite with a specific ray.
  11452. * @param ray The ray we are sending to test the collision
  11453. * @param camera The camera space we are sending rays in
  11454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11456. * @returns picking info or null.
  11457. */
  11458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11459. /**
  11460. * Intersects the sprites with a ray
  11461. * @param ray defines the ray to intersect with
  11462. * @param camera defines the current active camera
  11463. * @param predicate defines a predicate used to select candidate sprites
  11464. * @returns null if no hit or a PickingInfo array
  11465. */
  11466. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11467. /**
  11468. * Renders the list of sprites on screen.
  11469. */
  11470. render(): void;
  11471. }
  11472. /**
  11473. * Class used to manage multiple sprites on the same spritesheet
  11474. * @see http://doc.babylonjs.com/babylon101/sprites
  11475. */
  11476. export class SpriteManager implements ISpriteManager {
  11477. /** defines the manager's name */
  11478. name: string;
  11479. /** Gets the list of sprites */
  11480. sprites: Sprite[];
  11481. /** Gets or sets the rendering group id (0 by default) */
  11482. renderingGroupId: number;
  11483. /** Gets or sets camera layer mask */
  11484. layerMask: number;
  11485. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11486. fogEnabled: boolean;
  11487. /** Gets or sets a boolean indicating if the sprites are pickable */
  11488. isPickable: boolean;
  11489. /** Defines the default width of a cell in the spritesheet */
  11490. cellWidth: number;
  11491. /** Defines the default height of a cell in the spritesheet */
  11492. cellHeight: number;
  11493. /** Associative array from JSON sprite data file */
  11494. private _cellData;
  11495. /** Array of sprite names from JSON sprite data file */
  11496. private _spriteMap;
  11497. /** True when packed cell data from JSON file is ready*/
  11498. private _packedAndReady;
  11499. /**
  11500. * An event triggered when the manager is disposed.
  11501. */
  11502. onDisposeObservable: Observable<SpriteManager>;
  11503. private _onDisposeObserver;
  11504. /**
  11505. * Callback called when the manager is disposed
  11506. */
  11507. onDispose: () => void;
  11508. private _capacity;
  11509. private _fromPacked;
  11510. private _spriteTexture;
  11511. private _epsilon;
  11512. private _scene;
  11513. private _vertexData;
  11514. private _buffer;
  11515. private _vertexBuffers;
  11516. private _indexBuffer;
  11517. private _effectBase;
  11518. private _effectFog;
  11519. /**
  11520. * Gets or sets the spritesheet texture
  11521. */
  11522. texture: Texture;
  11523. /**
  11524. * Creates a new sprite manager
  11525. * @param name defines the manager's name
  11526. * @param imgUrl defines the sprite sheet url
  11527. * @param capacity defines the maximum allowed number of sprites
  11528. * @param cellSize defines the size of a sprite cell
  11529. * @param scene defines the hosting scene
  11530. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11531. * @param samplingMode defines the smapling mode to use with spritesheet
  11532. * @param fromPacked set to false; do not alter
  11533. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11534. */
  11535. constructor(
  11536. /** defines the manager's name */
  11537. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11538. private _makePacked;
  11539. private _appendSpriteVertex;
  11540. /**
  11541. * Intersects the sprites with a ray
  11542. * @param ray defines the ray to intersect with
  11543. * @param camera defines the current active camera
  11544. * @param predicate defines a predicate used to select candidate sprites
  11545. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11546. * @returns null if no hit or a PickingInfo
  11547. */
  11548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11549. /**
  11550. * Intersects the sprites with a ray
  11551. * @param ray defines the ray to intersect with
  11552. * @param camera defines the current active camera
  11553. * @param predicate defines a predicate used to select candidate sprites
  11554. * @returns null if no hit or a PickingInfo array
  11555. */
  11556. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Render all child sprites
  11559. */
  11560. render(): void;
  11561. /**
  11562. * Release associated resources
  11563. */
  11564. dispose(): void;
  11565. }
  11566. }
  11567. declare module BABYLON {
  11568. /**
  11569. * Class used to represent a sprite
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. export class Sprite {
  11573. /** defines the name */
  11574. name: string;
  11575. /** Gets or sets the current world position */
  11576. position: Vector3;
  11577. /** Gets or sets the main color */
  11578. color: Color4;
  11579. /** Gets or sets the width */
  11580. width: number;
  11581. /** Gets or sets the height */
  11582. height: number;
  11583. /** Gets or sets rotation angle */
  11584. angle: number;
  11585. /** Gets or sets the cell index in the sprite sheet */
  11586. cellIndex: number;
  11587. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11588. cellRef: string;
  11589. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11590. invertU: number;
  11591. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11592. invertV: number;
  11593. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11594. disposeWhenFinishedAnimating: boolean;
  11595. /** Gets the list of attached animations */
  11596. animations: Animation[];
  11597. /** Gets or sets a boolean indicating if the sprite can be picked */
  11598. isPickable: boolean;
  11599. /**
  11600. * Gets or sets the associated action manager
  11601. */
  11602. actionManager: Nullable<ActionManager>;
  11603. private _animationStarted;
  11604. private _loopAnimation;
  11605. private _fromIndex;
  11606. private _toIndex;
  11607. private _delay;
  11608. private _direction;
  11609. private _manager;
  11610. private _time;
  11611. private _onAnimationEnd;
  11612. /**
  11613. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11614. */
  11615. isVisible: boolean;
  11616. /**
  11617. * Gets or sets the sprite size
  11618. */
  11619. size: number;
  11620. /**
  11621. * Creates a new Sprite
  11622. * @param name defines the name
  11623. * @param manager defines the manager
  11624. */
  11625. constructor(
  11626. /** defines the name */
  11627. name: string, manager: ISpriteManager);
  11628. /**
  11629. * Starts an animation
  11630. * @param from defines the initial key
  11631. * @param to defines the end key
  11632. * @param loop defines if the animation must loop
  11633. * @param delay defines the start delay (in ms)
  11634. * @param onAnimationEnd defines a callback to call when animation ends
  11635. */
  11636. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11637. /** Stops current animation (if any) */
  11638. stopAnimation(): void;
  11639. /** @hidden */
  11640. _animate(deltaTime: number): void;
  11641. /** Release associated resources */
  11642. dispose(): void;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /**
  11647. * Information about the result of picking within a scene
  11648. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11649. */
  11650. export class PickingInfo {
  11651. /** @hidden */
  11652. _pickingUnavailable: boolean;
  11653. /**
  11654. * If the pick collided with an object
  11655. */
  11656. hit: boolean;
  11657. /**
  11658. * Distance away where the pick collided
  11659. */
  11660. distance: number;
  11661. /**
  11662. * The location of pick collision
  11663. */
  11664. pickedPoint: Nullable<Vector3>;
  11665. /**
  11666. * The mesh corresponding the the pick collision
  11667. */
  11668. pickedMesh: Nullable<AbstractMesh>;
  11669. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11670. bu: number;
  11671. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11672. bv: number;
  11673. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11674. faceId: number;
  11675. /** Id of the the submesh that was picked */
  11676. subMeshId: number;
  11677. /** If a sprite was picked, this will be the sprite the pick collided with */
  11678. pickedSprite: Nullable<Sprite>;
  11679. /**
  11680. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11681. */
  11682. originMesh: Nullable<AbstractMesh>;
  11683. /**
  11684. * The ray that was used to perform the picking.
  11685. */
  11686. ray: Nullable<Ray>;
  11687. /**
  11688. * Gets the normal correspodning to the face the pick collided with
  11689. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11690. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11691. * @returns The normal correspodning to the face the pick collided with
  11692. */
  11693. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11694. /**
  11695. * Gets the texture coordinates of where the pick occured
  11696. * @returns the vector containing the coordnates of the texture
  11697. */
  11698. getTextureCoordinates(): Nullable<Vector2>;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. /**
  11703. * Gather the list of pointer event types as constants.
  11704. */
  11705. export class PointerEventTypes {
  11706. /**
  11707. * 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.
  11708. */
  11709. static readonly POINTERDOWN: number;
  11710. /**
  11711. * The pointerup event is fired when a pointer is no longer active.
  11712. */
  11713. static readonly POINTERUP: number;
  11714. /**
  11715. * The pointermove event is fired when a pointer changes coordinates.
  11716. */
  11717. static readonly POINTERMOVE: number;
  11718. /**
  11719. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11720. */
  11721. static readonly POINTERWHEEL: number;
  11722. /**
  11723. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11724. */
  11725. static readonly POINTERPICK: number;
  11726. /**
  11727. * The pointertap event is fired when a the object has been touched and released without drag.
  11728. */
  11729. static readonly POINTERTAP: number;
  11730. /**
  11731. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11732. */
  11733. static readonly POINTERDOUBLETAP: number;
  11734. }
  11735. /**
  11736. * Base class of pointer info types.
  11737. */
  11738. export class PointerInfoBase {
  11739. /**
  11740. * Defines the type of event (PointerEventTypes)
  11741. */
  11742. type: number;
  11743. /**
  11744. * Defines the related dom event
  11745. */
  11746. event: PointerEvent | MouseWheelEvent;
  11747. /**
  11748. * Instantiates the base class of pointers info.
  11749. * @param type Defines the type of event (PointerEventTypes)
  11750. * @param event Defines the related dom event
  11751. */
  11752. constructor(
  11753. /**
  11754. * Defines the type of event (PointerEventTypes)
  11755. */
  11756. type: number,
  11757. /**
  11758. * Defines the related dom event
  11759. */
  11760. event: PointerEvent | MouseWheelEvent);
  11761. }
  11762. /**
  11763. * This class is used to store pointer related info for the onPrePointerObservable event.
  11764. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11765. */
  11766. export class PointerInfoPre extends PointerInfoBase {
  11767. /**
  11768. * Ray from a pointer if availible (eg. 6dof controller)
  11769. */
  11770. ray: Nullable<Ray>;
  11771. /**
  11772. * Defines the local position of the pointer on the canvas.
  11773. */
  11774. localPosition: Vector2;
  11775. /**
  11776. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11777. */
  11778. skipOnPointerObservable: boolean;
  11779. /**
  11780. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11781. * @param type Defines the type of event (PointerEventTypes)
  11782. * @param event Defines the related dom event
  11783. * @param localX Defines the local x coordinates of the pointer when the event occured
  11784. * @param localY Defines the local y coordinates of the pointer when the event occured
  11785. */
  11786. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11787. }
  11788. /**
  11789. * This type contains all the data related to a pointer event in Babylon.js.
  11790. * 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.
  11791. */
  11792. export class PointerInfo extends PointerInfoBase {
  11793. /**
  11794. * Defines the picking info associated to the info (if any)\
  11795. */
  11796. pickInfo: Nullable<PickingInfo>;
  11797. /**
  11798. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11799. * @param type Defines the type of event (PointerEventTypes)
  11800. * @param event Defines the related dom event
  11801. * @param pickInfo Defines the picking info associated to the info (if any)\
  11802. */
  11803. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11804. /**
  11805. * Defines the picking info associated to the info (if any)\
  11806. */
  11807. pickInfo: Nullable<PickingInfo>);
  11808. }
  11809. /**
  11810. * Data relating to a touch event on the screen.
  11811. */
  11812. export interface PointerTouch {
  11813. /**
  11814. * X coordinate of touch.
  11815. */
  11816. x: number;
  11817. /**
  11818. * Y coordinate of touch.
  11819. */
  11820. y: number;
  11821. /**
  11822. * Id of touch. Unique for each finger.
  11823. */
  11824. pointerId: number;
  11825. /**
  11826. * Event type passed from DOM.
  11827. */
  11828. type: any;
  11829. }
  11830. }
  11831. declare module BABYLON {
  11832. /**
  11833. * Manage the mouse inputs to control the movement of a free camera.
  11834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11835. */
  11836. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11837. /**
  11838. * Define if touch is enabled in the mouse input
  11839. */
  11840. touchEnabled: boolean;
  11841. /**
  11842. * Defines the camera the input is attached to.
  11843. */
  11844. camera: FreeCamera;
  11845. /**
  11846. * Defines the buttons associated with the input to handle camera move.
  11847. */
  11848. buttons: number[];
  11849. /**
  11850. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11851. */
  11852. angularSensibility: number;
  11853. private _pointerInput;
  11854. private _onMouseMove;
  11855. private _observer;
  11856. private previousPosition;
  11857. /**
  11858. * Observable for when a pointer move event occurs containing the move offset
  11859. */
  11860. onPointerMovedObservable: Observable<{
  11861. offsetX: number;
  11862. offsetY: number;
  11863. }>;
  11864. /**
  11865. * @hidden
  11866. * If the camera should be rotated automatically based on pointer movement
  11867. */
  11868. _allowCameraRotation: boolean;
  11869. /**
  11870. * Manage the mouse inputs to control the movement of a free camera.
  11871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11872. * @param touchEnabled Defines if touch is enabled or not
  11873. */
  11874. constructor(
  11875. /**
  11876. * Define if touch is enabled in the mouse input
  11877. */
  11878. touchEnabled?: boolean);
  11879. /**
  11880. * Attach the input controls to a specific dom element to get the input from.
  11881. * @param element Defines the element the controls should be listened from
  11882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11883. */
  11884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11885. /**
  11886. * Called on JS contextmenu event.
  11887. * Override this method to provide functionality.
  11888. */
  11889. protected onContextMenu(evt: PointerEvent): void;
  11890. /**
  11891. * Detach the current controls from the specified dom element.
  11892. * @param element Defines the element to stop listening the inputs from
  11893. */
  11894. detachControl(element: Nullable<HTMLElement>): void;
  11895. /**
  11896. * Gets the class name of the current intput.
  11897. * @returns the class name
  11898. */
  11899. getClassName(): string;
  11900. /**
  11901. * Get the friendly name associated with the input class.
  11902. * @returns the input friendly name
  11903. */
  11904. getSimpleName(): string;
  11905. }
  11906. }
  11907. declare module BABYLON {
  11908. /**
  11909. * Manage the touch inputs to control the movement of a free camera.
  11910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11911. */
  11912. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11913. /**
  11914. * Defines the camera the input is attached to.
  11915. */
  11916. camera: FreeCamera;
  11917. /**
  11918. * Defines the touch sensibility for rotation.
  11919. * The higher the faster.
  11920. */
  11921. touchAngularSensibility: number;
  11922. /**
  11923. * Defines the touch sensibility for move.
  11924. * The higher the faster.
  11925. */
  11926. touchMoveSensibility: number;
  11927. private _offsetX;
  11928. private _offsetY;
  11929. private _pointerPressed;
  11930. private _pointerInput;
  11931. private _observer;
  11932. private _onLostFocus;
  11933. /**
  11934. * Attach the input controls to a specific dom element to get the input from.
  11935. * @param element Defines the element the controls should be listened from
  11936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11937. */
  11938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11939. /**
  11940. * Detach the current controls from the specified dom element.
  11941. * @param element Defines the element to stop listening the inputs from
  11942. */
  11943. detachControl(element: Nullable<HTMLElement>): void;
  11944. /**
  11945. * Update the current camera state depending on the inputs that have been used this frame.
  11946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11947. */
  11948. checkInputs(): void;
  11949. /**
  11950. * Gets the class name of the current intput.
  11951. * @returns the class name
  11952. */
  11953. getClassName(): string;
  11954. /**
  11955. * Get the friendly name associated with the input class.
  11956. * @returns the input friendly name
  11957. */
  11958. getSimpleName(): string;
  11959. }
  11960. }
  11961. declare module BABYLON {
  11962. /**
  11963. * Default Inputs manager for the FreeCamera.
  11964. * It groups all the default supported inputs for ease of use.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11968. /**
  11969. * @hidden
  11970. */
  11971. _mouseInput: Nullable<FreeCameraMouseInput>;
  11972. /**
  11973. * Instantiates a new FreeCameraInputsManager.
  11974. * @param camera Defines the camera the inputs belong to
  11975. */
  11976. constructor(camera: FreeCamera);
  11977. /**
  11978. * Add keyboard input support to the input manager.
  11979. * @returns the current input manager
  11980. */
  11981. addKeyboard(): FreeCameraInputsManager;
  11982. /**
  11983. * Add mouse input support to the input manager.
  11984. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11985. * @returns the current input manager
  11986. */
  11987. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11988. /**
  11989. * Removes the mouse input support from the manager
  11990. * @returns the current input manager
  11991. */
  11992. removeMouse(): FreeCameraInputsManager;
  11993. /**
  11994. * Add touch input support to the input manager.
  11995. * @returns the current input manager
  11996. */
  11997. addTouch(): FreeCameraInputsManager;
  11998. /**
  11999. * Remove all attached input methods from a camera
  12000. */
  12001. clear(): void;
  12002. }
  12003. }
  12004. declare module BABYLON {
  12005. /**
  12006. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12007. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12009. */
  12010. export class FreeCamera extends TargetCamera {
  12011. /**
  12012. * Define the collision ellipsoid of the camera.
  12013. * This is helpful to simulate a camera body like the player body around the camera
  12014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12015. */
  12016. ellipsoid: Vector3;
  12017. /**
  12018. * Define an offset for the position of the ellipsoid around the camera.
  12019. * This can be helpful to determine the center of the body near the gravity center of the body
  12020. * instead of its head.
  12021. */
  12022. ellipsoidOffset: Vector3;
  12023. /**
  12024. * Enable or disable collisions of the camera with the rest of the scene objects.
  12025. */
  12026. checkCollisions: boolean;
  12027. /**
  12028. * Enable or disable gravity on the camera.
  12029. */
  12030. applyGravity: boolean;
  12031. /**
  12032. * Define the input manager associated to the camera.
  12033. */
  12034. inputs: FreeCameraInputsManager;
  12035. /**
  12036. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12037. * Higher values reduce sensitivity.
  12038. */
  12039. /**
  12040. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12041. * Higher values reduce sensitivity.
  12042. */
  12043. angularSensibility: number;
  12044. /**
  12045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12046. */
  12047. keysUp: number[];
  12048. /**
  12049. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12050. */
  12051. keysDown: number[];
  12052. /**
  12053. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12054. */
  12055. keysLeft: number[];
  12056. /**
  12057. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12058. */
  12059. keysRight: number[];
  12060. /**
  12061. * Event raised when the camera collide with a mesh in the scene.
  12062. */
  12063. onCollide: (collidedMesh: AbstractMesh) => void;
  12064. private _collider;
  12065. private _needMoveForGravity;
  12066. private _oldPosition;
  12067. private _diffPosition;
  12068. private _newPosition;
  12069. /** @hidden */
  12070. _localDirection: Vector3;
  12071. /** @hidden */
  12072. _transformedDirection: Vector3;
  12073. /**
  12074. * Instantiates a Free Camera.
  12075. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12076. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12078. * @param name Define the name of the camera in the scene
  12079. * @param position Define the start position of the camera in the scene
  12080. * @param scene Define the scene the camera belongs to
  12081. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12082. */
  12083. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12084. /**
  12085. * Attached controls to the current camera.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Detach the current controls from the camera.
  12092. * The camera will stop reacting to inputs.
  12093. * @param element Defines the element to stop listening the inputs from
  12094. */
  12095. detachControl(element: HTMLElement): void;
  12096. private _collisionMask;
  12097. /**
  12098. * Define a collision mask to limit the list of object the camera can collide with
  12099. */
  12100. collisionMask: number;
  12101. /** @hidden */
  12102. _collideWithWorld(displacement: Vector3): void;
  12103. private _onCollisionPositionChange;
  12104. /** @hidden */
  12105. _checkInputs(): void;
  12106. /** @hidden */
  12107. _decideIfNeedsToMove(): boolean;
  12108. /** @hidden */
  12109. _updatePosition(): void;
  12110. /**
  12111. * Destroy the camera and release the current resources hold by it.
  12112. */
  12113. dispose(): void;
  12114. /**
  12115. * Gets the current object class name.
  12116. * @return the class name
  12117. */
  12118. getClassName(): string;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Represents a gamepad control stick position
  12124. */
  12125. export class StickValues {
  12126. /**
  12127. * The x component of the control stick
  12128. */
  12129. x: number;
  12130. /**
  12131. * The y component of the control stick
  12132. */
  12133. y: number;
  12134. /**
  12135. * Initializes the gamepad x and y control stick values
  12136. * @param x The x component of the gamepad control stick value
  12137. * @param y The y component of the gamepad control stick value
  12138. */
  12139. constructor(
  12140. /**
  12141. * The x component of the control stick
  12142. */
  12143. x: number,
  12144. /**
  12145. * The y component of the control stick
  12146. */
  12147. y: number);
  12148. }
  12149. /**
  12150. * An interface which manages callbacks for gamepad button changes
  12151. */
  12152. export interface GamepadButtonChanges {
  12153. /**
  12154. * Called when a gamepad has been changed
  12155. */
  12156. changed: boolean;
  12157. /**
  12158. * Called when a gamepad press event has been triggered
  12159. */
  12160. pressChanged: boolean;
  12161. /**
  12162. * Called when a touch event has been triggered
  12163. */
  12164. touchChanged: boolean;
  12165. /**
  12166. * Called when a value has changed
  12167. */
  12168. valueChanged: boolean;
  12169. }
  12170. /**
  12171. * Represents a gamepad
  12172. */
  12173. export class Gamepad {
  12174. /**
  12175. * The id of the gamepad
  12176. */
  12177. id: string;
  12178. /**
  12179. * The index of the gamepad
  12180. */
  12181. index: number;
  12182. /**
  12183. * The browser gamepad
  12184. */
  12185. browserGamepad: any;
  12186. /**
  12187. * Specifies what type of gamepad this represents
  12188. */
  12189. type: number;
  12190. private _leftStick;
  12191. private _rightStick;
  12192. /** @hidden */
  12193. _isConnected: boolean;
  12194. private _leftStickAxisX;
  12195. private _leftStickAxisY;
  12196. private _rightStickAxisX;
  12197. private _rightStickAxisY;
  12198. /**
  12199. * Triggered when the left control stick has been changed
  12200. */
  12201. private _onleftstickchanged;
  12202. /**
  12203. * Triggered when the right control stick has been changed
  12204. */
  12205. private _onrightstickchanged;
  12206. /**
  12207. * Represents a gamepad controller
  12208. */
  12209. static GAMEPAD: number;
  12210. /**
  12211. * Represents a generic controller
  12212. */
  12213. static GENERIC: number;
  12214. /**
  12215. * Represents an XBox controller
  12216. */
  12217. static XBOX: number;
  12218. /**
  12219. * Represents a pose-enabled controller
  12220. */
  12221. static POSE_ENABLED: number;
  12222. /**
  12223. * Represents an Dual Shock controller
  12224. */
  12225. static DUALSHOCK: number;
  12226. /**
  12227. * Specifies whether the left control stick should be Y-inverted
  12228. */
  12229. protected _invertLeftStickY: boolean;
  12230. /**
  12231. * Specifies if the gamepad has been connected
  12232. */
  12233. readonly isConnected: boolean;
  12234. /**
  12235. * Initializes the gamepad
  12236. * @param id The id of the gamepad
  12237. * @param index The index of the gamepad
  12238. * @param browserGamepad The browser gamepad
  12239. * @param leftStickX The x component of the left joystick
  12240. * @param leftStickY The y component of the left joystick
  12241. * @param rightStickX The x component of the right joystick
  12242. * @param rightStickY The y component of the right joystick
  12243. */
  12244. constructor(
  12245. /**
  12246. * The id of the gamepad
  12247. */
  12248. id: string,
  12249. /**
  12250. * The index of the gamepad
  12251. */
  12252. index: number,
  12253. /**
  12254. * The browser gamepad
  12255. */
  12256. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12257. /**
  12258. * Callback triggered when the left joystick has changed
  12259. * @param callback
  12260. */
  12261. onleftstickchanged(callback: (values: StickValues) => void): void;
  12262. /**
  12263. * Callback triggered when the right joystick has changed
  12264. * @param callback
  12265. */
  12266. onrightstickchanged(callback: (values: StickValues) => void): void;
  12267. /**
  12268. * Gets the left joystick
  12269. */
  12270. /**
  12271. * Sets the left joystick values
  12272. */
  12273. leftStick: StickValues;
  12274. /**
  12275. * Gets the right joystick
  12276. */
  12277. /**
  12278. * Sets the right joystick value
  12279. */
  12280. rightStick: StickValues;
  12281. /**
  12282. * Updates the gamepad joystick positions
  12283. */
  12284. update(): void;
  12285. /**
  12286. * Disposes the gamepad
  12287. */
  12288. dispose(): void;
  12289. }
  12290. /**
  12291. * Represents a generic gamepad
  12292. */
  12293. export class GenericPad extends Gamepad {
  12294. private _buttons;
  12295. private _onbuttondown;
  12296. private _onbuttonup;
  12297. /**
  12298. * Observable triggered when a button has been pressed
  12299. */
  12300. onButtonDownObservable: Observable<number>;
  12301. /**
  12302. * Observable triggered when a button has been released
  12303. */
  12304. onButtonUpObservable: Observable<number>;
  12305. /**
  12306. * Callback triggered when a button has been pressed
  12307. * @param callback Called when a button has been pressed
  12308. */
  12309. onbuttondown(callback: (buttonPressed: number) => void): void;
  12310. /**
  12311. * Callback triggered when a button has been released
  12312. * @param callback Called when a button has been released
  12313. */
  12314. onbuttonup(callback: (buttonReleased: number) => void): void;
  12315. /**
  12316. * Initializes the generic gamepad
  12317. * @param id The id of the generic gamepad
  12318. * @param index The index of the generic gamepad
  12319. * @param browserGamepad The browser gamepad
  12320. */
  12321. constructor(id: string, index: number, browserGamepad: any);
  12322. private _setButtonValue;
  12323. /**
  12324. * Updates the generic gamepad
  12325. */
  12326. update(): void;
  12327. /**
  12328. * Disposes the generic gamepad
  12329. */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module BABYLON {
  12334. interface Engine {
  12335. /**
  12336. * Creates a raw texture
  12337. * @param data defines the data to store in the texture
  12338. * @param width defines the width of the texture
  12339. * @param height defines the height of the texture
  12340. * @param format defines the format of the data
  12341. * @param generateMipMaps defines if the engine should generate the mip levels
  12342. * @param invertY defines if data must be stored with Y axis inverted
  12343. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12344. * @param compression defines the compression used (null by default)
  12345. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12346. * @returns the raw texture inside an InternalTexture
  12347. */
  12348. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12349. /**
  12350. * Update a raw texture
  12351. * @param texture defines the texture to update
  12352. * @param data defines the data to store in the texture
  12353. * @param format defines the format of the data
  12354. * @param invertY defines if data must be stored with Y axis inverted
  12355. */
  12356. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12357. /**
  12358. * Update a raw texture
  12359. * @param texture defines the texture to update
  12360. * @param data defines the data to store in the texture
  12361. * @param format defines the format of the data
  12362. * @param invertY defines if data must be stored with Y axis inverted
  12363. * @param compression defines the compression used (null by default)
  12364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12365. */
  12366. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12367. /**
  12368. * Creates a new raw cube texture
  12369. * @param data defines the array of data to use to create each face
  12370. * @param size defines the size of the textures
  12371. * @param format defines the format of the data
  12372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12373. * @param generateMipMaps defines if the engine should generate the mip levels
  12374. * @param invertY defines if data must be stored with Y axis inverted
  12375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12376. * @param compression defines the compression used (null by default)
  12377. * @returns the cube texture as an InternalTexture
  12378. */
  12379. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12380. /**
  12381. * Update a raw cube texture
  12382. * @param texture defines the texture to udpdate
  12383. * @param data defines the data to store
  12384. * @param format defines the data format
  12385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12386. * @param invertY defines if data must be stored with Y axis inverted
  12387. */
  12388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12389. /**
  12390. * Update a raw cube texture
  12391. * @param texture defines the texture to udpdate
  12392. * @param data defines the data to store
  12393. * @param format defines the data format
  12394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12395. * @param invertY defines if data must be stored with Y axis inverted
  12396. * @param compression defines the compression used (null by default)
  12397. */
  12398. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12399. /**
  12400. * Update a raw cube texture
  12401. * @param texture defines the texture to udpdate
  12402. * @param data defines the data to store
  12403. * @param format defines the data format
  12404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12405. * @param invertY defines if data must be stored with Y axis inverted
  12406. * @param compression defines the compression used (null by default)
  12407. * @param level defines which level of the texture to update
  12408. */
  12409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12410. /**
  12411. * Creates a new raw cube texture from a specified url
  12412. * @param url defines the url where the data is located
  12413. * @param scene defines the current scene
  12414. * @param size defines the size of the textures
  12415. * @param format defines the format of the data
  12416. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12417. * @param noMipmap defines if the engine should avoid generating the mip levels
  12418. * @param callback defines a callback used to extract texture data from loaded data
  12419. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12420. * @param onLoad defines a callback called when texture is loaded
  12421. * @param onError defines a callback called if there is an error
  12422. * @returns the cube texture as an InternalTexture
  12423. */
  12424. 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;
  12425. /**
  12426. * Creates a new raw cube texture from a specified url
  12427. * @param url defines the url where the data is located
  12428. * @param scene defines the current scene
  12429. * @param size defines the size of the textures
  12430. * @param format defines the format of the data
  12431. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12432. * @param noMipmap defines if the engine should avoid generating the mip levels
  12433. * @param callback defines a callback used to extract texture data from loaded data
  12434. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12435. * @param onLoad defines a callback called when texture is loaded
  12436. * @param onError defines a callback called if there is an error
  12437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @returns the cube texture as an InternalTexture
  12440. */
  12441. 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;
  12442. /**
  12443. * Creates a new raw 3D texture
  12444. * @param data defines the data used to create the texture
  12445. * @param width defines the width of the texture
  12446. * @param height defines the height of the texture
  12447. * @param depth defines the depth of the texture
  12448. * @param format defines the format of the texture
  12449. * @param generateMipMaps defines if the engine must generate mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compressed used (can be null)
  12453. * @param textureType defines the compressed used (can be null)
  12454. * @returns a new raw 3D texture (stored in an InternalTexture)
  12455. */
  12456. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12457. /**
  12458. * Update a raw 3D texture
  12459. * @param texture defines the texture to update
  12460. * @param data defines the data to store
  12461. * @param format defines the data format
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw 3D texture
  12467. * @param texture defines the texture to update
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param invertY defines if data must be stored with Y axis inverted
  12471. * @param compression defines the used compression (can be null)
  12472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12473. */
  12474. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * Raw texture can help creating a texture directly from an array of data.
  12480. * This can be super useful if you either get the data from an uncompressed source or
  12481. * if you wish to create your texture pixel by pixel.
  12482. */
  12483. export class RawTexture extends Texture {
  12484. /**
  12485. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12486. */
  12487. format: number;
  12488. private _engine;
  12489. /**
  12490. * Instantiates a new RawTexture.
  12491. * Raw texture can help creating a texture directly from an array of data.
  12492. * This can be super useful if you either get the data from an uncompressed source or
  12493. * if you wish to create your texture pixel by pixel.
  12494. * @param data define the array of data to use to create the texture
  12495. * @param width define the width of the texture
  12496. * @param height define the height of the texture
  12497. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12498. * @param scene define the scene the texture belongs to
  12499. * @param generateMipMaps define whether mip maps should be generated or not
  12500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12503. */
  12504. constructor(data: ArrayBufferView, width: number, height: number,
  12505. /**
  12506. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12507. */
  12508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12509. /**
  12510. * Updates the texture underlying data.
  12511. * @param data Define the new data of the texture
  12512. */
  12513. update(data: ArrayBufferView): void;
  12514. /**
  12515. * Creates a luminance texture from some data.
  12516. * @param data Define the texture data
  12517. * @param width Define the width of the texture
  12518. * @param height Define the height of the texture
  12519. * @param scene Define the scene the texture belongs to
  12520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12523. * @returns the luminance texture
  12524. */
  12525. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12526. /**
  12527. * Creates a luminance alpha texture from some data.
  12528. * @param data Define the texture data
  12529. * @param width Define the width of the texture
  12530. * @param height Define the height of the texture
  12531. * @param scene Define the scene the texture belongs to
  12532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12535. * @returns the luminance alpha texture
  12536. */
  12537. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12538. /**
  12539. * Creates an alpha texture from some data.
  12540. * @param data Define the texture data
  12541. * @param width Define the width of the texture
  12542. * @param height Define the height of the texture
  12543. * @param scene Define the scene the texture belongs to
  12544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12547. * @returns the alpha texture
  12548. */
  12549. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12550. /**
  12551. * Creates a RGB texture from some data.
  12552. * @param data Define the texture data
  12553. * @param width Define the width of the texture
  12554. * @param height Define the height of the texture
  12555. * @param scene Define the scene the texture belongs to
  12556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12560. * @returns the RGB alpha texture
  12561. */
  12562. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12563. /**
  12564. * Creates a RGBA texture from some data.
  12565. * @param data Define the texture data
  12566. * @param width Define the width of the texture
  12567. * @param height Define the height of the texture
  12568. * @param scene Define the scene the texture belongs to
  12569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12573. * @returns the RGBA texture
  12574. */
  12575. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12576. /**
  12577. * Creates a R texture from some data.
  12578. * @param data Define the texture data
  12579. * @param width Define the width of the texture
  12580. * @param height Define the height of the texture
  12581. * @param scene Define the scene the texture belongs to
  12582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12586. * @returns the R texture
  12587. */
  12588. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. /**
  12593. * Interface for the size containing width and height
  12594. */
  12595. export interface ISize {
  12596. /**
  12597. * Width
  12598. */
  12599. width: number;
  12600. /**
  12601. * Heighht
  12602. */
  12603. height: number;
  12604. }
  12605. /**
  12606. * Size containing widht and height
  12607. */
  12608. export class Size implements ISize {
  12609. /**
  12610. * Width
  12611. */
  12612. width: number;
  12613. /**
  12614. * Height
  12615. */
  12616. height: number;
  12617. /**
  12618. * Creates a Size object from the given width and height (floats).
  12619. * @param width width of the new size
  12620. * @param height height of the new size
  12621. */
  12622. constructor(width: number, height: number);
  12623. /**
  12624. * Returns a string with the Size width and height
  12625. * @returns a string with the Size width and height
  12626. */
  12627. toString(): string;
  12628. /**
  12629. * "Size"
  12630. * @returns the string "Size"
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Returns the Size hash code.
  12635. * @returns a hash code for a unique width and height
  12636. */
  12637. getHashCode(): number;
  12638. /**
  12639. * Updates the current size from the given one.
  12640. * @param src the given size
  12641. */
  12642. copyFrom(src: Size): void;
  12643. /**
  12644. * Updates in place the current Size from the given floats.
  12645. * @param width width of the new size
  12646. * @param height height of the new size
  12647. * @returns the updated Size.
  12648. */
  12649. copyFromFloats(width: number, height: number): Size;
  12650. /**
  12651. * Updates in place the current Size from the given floats.
  12652. * @param width width to set
  12653. * @param height height to set
  12654. * @returns the updated Size.
  12655. */
  12656. set(width: number, height: number): Size;
  12657. /**
  12658. * Multiplies the width and height by numbers
  12659. * @param w factor to multiple the width by
  12660. * @param h factor to multiple the height by
  12661. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12662. */
  12663. multiplyByFloats(w: number, h: number): Size;
  12664. /**
  12665. * Clones the size
  12666. * @returns a new Size copied from the given one.
  12667. */
  12668. clone(): Size;
  12669. /**
  12670. * True if the current Size and the given one width and height are strictly equal.
  12671. * @param other the other size to compare against
  12672. * @returns True if the current Size and the given one width and height are strictly equal.
  12673. */
  12674. equals(other: Size): boolean;
  12675. /**
  12676. * The surface of the Size : width * height (float).
  12677. */
  12678. readonly surface: number;
  12679. /**
  12680. * Create a new size of zero
  12681. * @returns a new Size set to (0.0, 0.0)
  12682. */
  12683. static Zero(): Size;
  12684. /**
  12685. * Sums the width and height of two sizes
  12686. * @param otherSize size to add to this size
  12687. * @returns a new Size set as the addition result of the current Size and the given one.
  12688. */
  12689. add(otherSize: Size): Size;
  12690. /**
  12691. * Subtracts the width and height of two
  12692. * @param otherSize size to subtract to this size
  12693. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12694. */
  12695. subtract(otherSize: Size): Size;
  12696. /**
  12697. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12698. * @param start starting size to lerp between
  12699. * @param end end size to lerp between
  12700. * @param amount amount to lerp between the start and end values
  12701. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12702. */
  12703. static Lerp(start: Size, end: Size, amount: number): Size;
  12704. }
  12705. }
  12706. declare module BABYLON {
  12707. /**
  12708. * Defines a runtime animation
  12709. */
  12710. export class RuntimeAnimation {
  12711. private _events;
  12712. /**
  12713. * The current frame of the runtime animation
  12714. */
  12715. private _currentFrame;
  12716. /**
  12717. * The animation used by the runtime animation
  12718. */
  12719. private _animation;
  12720. /**
  12721. * The target of the runtime animation
  12722. */
  12723. private _target;
  12724. /**
  12725. * The initiating animatable
  12726. */
  12727. private _host;
  12728. /**
  12729. * The original value of the runtime animation
  12730. */
  12731. private _originalValue;
  12732. /**
  12733. * The original blend value of the runtime animation
  12734. */
  12735. private _originalBlendValue;
  12736. /**
  12737. * The offsets cache of the runtime animation
  12738. */
  12739. private _offsetsCache;
  12740. /**
  12741. * The high limits cache of the runtime animation
  12742. */
  12743. private _highLimitsCache;
  12744. /**
  12745. * Specifies if the runtime animation has been stopped
  12746. */
  12747. private _stopped;
  12748. /**
  12749. * The blending factor of the runtime animation
  12750. */
  12751. private _blendingFactor;
  12752. /**
  12753. * The BabylonJS scene
  12754. */
  12755. private _scene;
  12756. /**
  12757. * The current value of the runtime animation
  12758. */
  12759. private _currentValue;
  12760. /** @hidden */
  12761. _animationState: _IAnimationState;
  12762. /**
  12763. * The active target of the runtime animation
  12764. */
  12765. private _activeTargets;
  12766. private _currentActiveTarget;
  12767. private _directTarget;
  12768. /**
  12769. * The target path of the runtime animation
  12770. */
  12771. private _targetPath;
  12772. /**
  12773. * The weight of the runtime animation
  12774. */
  12775. private _weight;
  12776. /**
  12777. * The ratio offset of the runtime animation
  12778. */
  12779. private _ratioOffset;
  12780. /**
  12781. * The previous delay of the runtime animation
  12782. */
  12783. private _previousDelay;
  12784. /**
  12785. * The previous ratio of the runtime animation
  12786. */
  12787. private _previousRatio;
  12788. private _enableBlending;
  12789. private _keys;
  12790. private _minFrame;
  12791. private _maxFrame;
  12792. private _minValue;
  12793. private _maxValue;
  12794. private _targetIsArray;
  12795. /**
  12796. * Gets the current frame of the runtime animation
  12797. */
  12798. readonly currentFrame: number;
  12799. /**
  12800. * Gets the weight of the runtime animation
  12801. */
  12802. readonly weight: number;
  12803. /**
  12804. * Gets the current value of the runtime animation
  12805. */
  12806. readonly currentValue: any;
  12807. /**
  12808. * Gets the target path of the runtime animation
  12809. */
  12810. readonly targetPath: string;
  12811. /**
  12812. * Gets the actual target of the runtime animation
  12813. */
  12814. readonly target: any;
  12815. /** @hidden */
  12816. _onLoop: () => void;
  12817. /**
  12818. * Create a new RuntimeAnimation object
  12819. * @param target defines the target of the animation
  12820. * @param animation defines the source animation object
  12821. * @param scene defines the hosting scene
  12822. * @param host defines the initiating Animatable
  12823. */
  12824. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12825. private _preparePath;
  12826. /**
  12827. * Gets the animation from the runtime animation
  12828. */
  12829. readonly animation: Animation;
  12830. /**
  12831. * Resets the runtime animation to the beginning
  12832. * @param restoreOriginal defines whether to restore the target property to the original value
  12833. */
  12834. reset(restoreOriginal?: boolean): void;
  12835. /**
  12836. * Specifies if the runtime animation is stopped
  12837. * @returns Boolean specifying if the runtime animation is stopped
  12838. */
  12839. isStopped(): boolean;
  12840. /**
  12841. * Disposes of the runtime animation
  12842. */
  12843. dispose(): void;
  12844. /**
  12845. * Apply the interpolated value to the target
  12846. * @param currentValue defines the value computed by the animation
  12847. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12848. */
  12849. setValue(currentValue: any, weight: number): void;
  12850. private _getOriginalValues;
  12851. private _setValue;
  12852. /**
  12853. * Gets the loop pmode of the runtime animation
  12854. * @returns Loop Mode
  12855. */
  12856. private _getCorrectLoopMode;
  12857. /**
  12858. * Move the current animation to a given frame
  12859. * @param frame defines the frame to move to
  12860. */
  12861. goToFrame(frame: number): void;
  12862. /**
  12863. * @hidden Internal use only
  12864. */
  12865. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12866. /**
  12867. * Execute the current animation
  12868. * @param delay defines the delay to add to the current frame
  12869. * @param from defines the lower bound of the animation range
  12870. * @param to defines the upper bound of the animation range
  12871. * @param loop defines if the current animation must loop
  12872. * @param speedRatio defines the current speed ratio
  12873. * @param weight defines the weight of the animation (default is -1 so no weight)
  12874. * @param onLoop optional callback called when animation loops
  12875. * @returns a boolean indicating if the animation is running
  12876. */
  12877. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Class used to store an actual running animation
  12883. */
  12884. export class Animatable {
  12885. /** defines the target object */
  12886. target: any;
  12887. /** defines the starting frame number (default is 0) */
  12888. fromFrame: number;
  12889. /** defines the ending frame number (default is 100) */
  12890. toFrame: number;
  12891. /** defines if the animation must loop (default is false) */
  12892. loopAnimation: boolean;
  12893. /** defines a callback to call when animation ends if it is not looping */
  12894. onAnimationEnd?: (() => void) | null | undefined;
  12895. /** defines a callback to call when animation loops */
  12896. onAnimationLoop?: (() => void) | null | undefined;
  12897. private _localDelayOffset;
  12898. private _pausedDelay;
  12899. private _runtimeAnimations;
  12900. private _paused;
  12901. private _scene;
  12902. private _speedRatio;
  12903. private _weight;
  12904. private _syncRoot;
  12905. /**
  12906. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12907. * This will only apply for non looping animation (default is true)
  12908. */
  12909. disposeOnEnd: boolean;
  12910. /**
  12911. * Gets a boolean indicating if the animation has started
  12912. */
  12913. animationStarted: boolean;
  12914. /**
  12915. * Observer raised when the animation ends
  12916. */
  12917. onAnimationEndObservable: Observable<Animatable>;
  12918. /**
  12919. * Observer raised when the animation loops
  12920. */
  12921. onAnimationLoopObservable: Observable<Animatable>;
  12922. /**
  12923. * Gets the root Animatable used to synchronize and normalize animations
  12924. */
  12925. readonly syncRoot: Nullable<Animatable>;
  12926. /**
  12927. * Gets the current frame of the first RuntimeAnimation
  12928. * Used to synchronize Animatables
  12929. */
  12930. readonly masterFrame: number;
  12931. /**
  12932. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12933. */
  12934. weight: number;
  12935. /**
  12936. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12937. */
  12938. speedRatio: number;
  12939. /**
  12940. * Creates a new Animatable
  12941. * @param scene defines the hosting scene
  12942. * @param target defines the target object
  12943. * @param fromFrame defines the starting frame number (default is 0)
  12944. * @param toFrame defines the ending frame number (default is 100)
  12945. * @param loopAnimation defines if the animation must loop (default is false)
  12946. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12947. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12948. * @param animations defines a group of animation to add to the new Animatable
  12949. * @param onAnimationLoop defines a callback to call when animation loops
  12950. */
  12951. constructor(scene: Scene,
  12952. /** defines the target object */
  12953. target: any,
  12954. /** defines the starting frame number (default is 0) */
  12955. fromFrame?: number,
  12956. /** defines the ending frame number (default is 100) */
  12957. toFrame?: number,
  12958. /** defines if the animation must loop (default is false) */
  12959. loopAnimation?: boolean, speedRatio?: number,
  12960. /** defines a callback to call when animation ends if it is not looping */
  12961. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12962. /** defines a callback to call when animation loops */
  12963. onAnimationLoop?: (() => void) | null | undefined);
  12964. /**
  12965. * Synchronize and normalize current Animatable with a source Animatable
  12966. * This is useful when using animation weights and when animations are not of the same length
  12967. * @param root defines the root Animatable to synchronize with
  12968. * @returns the current Animatable
  12969. */
  12970. syncWith(root: Animatable): Animatable;
  12971. /**
  12972. * Gets the list of runtime animations
  12973. * @returns an array of RuntimeAnimation
  12974. */
  12975. getAnimations(): RuntimeAnimation[];
  12976. /**
  12977. * Adds more animations to the current animatable
  12978. * @param target defines the target of the animations
  12979. * @param animations defines the new animations to add
  12980. */
  12981. appendAnimations(target: any, animations: Animation[]): void;
  12982. /**
  12983. * Gets the source animation for a specific property
  12984. * @param property defines the propertyu to look for
  12985. * @returns null or the source animation for the given property
  12986. */
  12987. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12988. /**
  12989. * Gets the runtime animation for a specific property
  12990. * @param property defines the propertyu to look for
  12991. * @returns null or the runtime animation for the given property
  12992. */
  12993. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12994. /**
  12995. * Resets the animatable to its original state
  12996. */
  12997. reset(): void;
  12998. /**
  12999. * Allows the animatable to blend with current running animations
  13000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13001. * @param blendingSpeed defines the blending speed to use
  13002. */
  13003. enableBlending(blendingSpeed: number): void;
  13004. /**
  13005. * Disable animation blending
  13006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13007. */
  13008. disableBlending(): void;
  13009. /**
  13010. * Jump directly to a given frame
  13011. * @param frame defines the frame to jump to
  13012. */
  13013. goToFrame(frame: number): void;
  13014. /**
  13015. * Pause the animation
  13016. */
  13017. pause(): void;
  13018. /**
  13019. * Restart the animation
  13020. */
  13021. restart(): void;
  13022. private _raiseOnAnimationEnd;
  13023. /**
  13024. * Stop and delete the current animation
  13025. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13026. * @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)
  13027. */
  13028. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13029. /**
  13030. * Wait asynchronously for the animation to end
  13031. * @returns a promise which will be fullfilled when the animation ends
  13032. */
  13033. waitAsync(): Promise<Animatable>;
  13034. /** @hidden */
  13035. _animate(delay: number): boolean;
  13036. }
  13037. interface Scene {
  13038. /** @hidden */
  13039. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13040. /** @hidden */
  13041. _processLateAnimationBindingsForMatrices(holder: {
  13042. totalWeight: number;
  13043. animations: RuntimeAnimation[];
  13044. originalValue: Matrix;
  13045. }): any;
  13046. /** @hidden */
  13047. _processLateAnimationBindingsForQuaternions(holder: {
  13048. totalWeight: number;
  13049. animations: RuntimeAnimation[];
  13050. originalValue: Quaternion;
  13051. }, refQuaternion: Quaternion): Quaternion;
  13052. /** @hidden */
  13053. _processLateAnimationBindings(): void;
  13054. /**
  13055. * Will start the animation sequence of a given target
  13056. * @param target defines the target
  13057. * @param from defines from which frame should animation start
  13058. * @param to defines until which frame should animation run.
  13059. * @param weight defines the weight to apply to the animation (1.0 by default)
  13060. * @param loop defines if the animation loops
  13061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13062. * @param onAnimationEnd defines the function to be executed when the animation ends
  13063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13064. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13065. * @param onAnimationLoop defines the callback to call when an animation loops
  13066. * @returns the animatable object created for this animation
  13067. */
  13068. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13069. /**
  13070. * Will start the animation sequence of a given target
  13071. * @param target defines the target
  13072. * @param from defines from which frame should animation start
  13073. * @param to defines until which frame should animation run.
  13074. * @param loop defines if the animation loops
  13075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13076. * @param onAnimationEnd defines the function to be executed when the animation ends
  13077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13079. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13080. * @param onAnimationLoop defines the callback to call when an animation loops
  13081. * @returns the animatable object created for this animation
  13082. */
  13083. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13084. /**
  13085. * Will start the animation sequence of a given target and its hierarchy
  13086. * @param target defines the target
  13087. * @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.
  13088. * @param from defines from which frame should animation start
  13089. * @param to defines until which frame should animation run.
  13090. * @param loop defines if the animation loops
  13091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13092. * @param onAnimationEnd defines the function to be executed when the animation ends
  13093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13095. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13096. * @param onAnimationLoop defines the callback to call when an animation loops
  13097. * @returns the list of created animatables
  13098. */
  13099. 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[];
  13100. /**
  13101. * Begin a new animation on a given node
  13102. * @param target defines the target where the animation will take place
  13103. * @param animations defines the list of animations to start
  13104. * @param from defines the initial value
  13105. * @param to defines the final value
  13106. * @param loop defines if you want animation to loop (off by default)
  13107. * @param speedRatio defines the speed ratio to apply to all animations
  13108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13109. * @param onAnimationLoop defines the callback to call when an animation loops
  13110. * @returns the list of created animatables
  13111. */
  13112. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13113. /**
  13114. * Begin a new animation on a given node and its hierarchy
  13115. * @param target defines the root node where the animation will take place
  13116. * @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.
  13117. * @param animations defines the list of animations to start
  13118. * @param from defines the initial value
  13119. * @param to defines the final value
  13120. * @param loop defines if you want animation to loop (off by default)
  13121. * @param speedRatio defines the speed ratio to apply to all animations
  13122. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13123. * @param onAnimationLoop defines the callback to call when an animation loops
  13124. * @returns the list of animatables created for all nodes
  13125. */
  13126. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13127. /**
  13128. * Gets the animatable associated with a specific target
  13129. * @param target defines the target of the animatable
  13130. * @returns the required animatable if found
  13131. */
  13132. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13133. /**
  13134. * Gets all animatables associated with a given target
  13135. * @param target defines the target to look animatables for
  13136. * @returns an array of Animatables
  13137. */
  13138. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13139. /**
  13140. * Stops and removes all animations that have been applied to the scene
  13141. */
  13142. stopAllAnimations(): void;
  13143. /**
  13144. * Gets the current delta time used by animation engine
  13145. */
  13146. deltaTime: number;
  13147. }
  13148. interface Bone {
  13149. /**
  13150. * Copy an animation range from another bone
  13151. * @param source defines the source bone
  13152. * @param rangeName defines the range name to copy
  13153. * @param frameOffset defines the frame offset
  13154. * @param rescaleAsRequired defines if rescaling must be applied if required
  13155. * @param skelDimensionsRatio defines the scaling ratio
  13156. * @returns true if operation was successful
  13157. */
  13158. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13159. }
  13160. }
  13161. declare module BABYLON {
  13162. /**
  13163. * Class used to override all child animations of a given target
  13164. */
  13165. export class AnimationPropertiesOverride {
  13166. /**
  13167. * Gets or sets a value indicating if animation blending must be used
  13168. */
  13169. enableBlending: boolean;
  13170. /**
  13171. * Gets or sets the blending speed to use when enableBlending is true
  13172. */
  13173. blendingSpeed: number;
  13174. /**
  13175. * Gets or sets the default loop mode to use
  13176. */
  13177. loopMode: number;
  13178. }
  13179. }
  13180. declare module BABYLON {
  13181. /**
  13182. * Class used to handle skinning animations
  13183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13184. */
  13185. export class Skeleton implements IAnimatable {
  13186. /** defines the skeleton name */
  13187. name: string;
  13188. /** defines the skeleton Id */
  13189. id: string;
  13190. /**
  13191. * Defines the list of child bones
  13192. */
  13193. bones: Bone[];
  13194. /**
  13195. * Defines an estimate of the dimension of the skeleton at rest
  13196. */
  13197. dimensionsAtRest: Vector3;
  13198. /**
  13199. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13200. */
  13201. needInitialSkinMatrix: boolean;
  13202. /**
  13203. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13204. */
  13205. overrideMesh: Nullable<AbstractMesh>;
  13206. /**
  13207. * Gets the list of animations attached to this skeleton
  13208. */
  13209. animations: Array<Animation>;
  13210. private _scene;
  13211. private _isDirty;
  13212. private _transformMatrices;
  13213. private _transformMatrixTexture;
  13214. private _meshesWithPoseMatrix;
  13215. private _animatables;
  13216. private _identity;
  13217. private _synchronizedWithMesh;
  13218. private _ranges;
  13219. private _lastAbsoluteTransformsUpdateId;
  13220. private _canUseTextureForBones;
  13221. private _uniqueId;
  13222. /** @hidden */
  13223. _numBonesWithLinkedTransformNode: number;
  13224. /** @hidden */
  13225. _hasWaitingData: Nullable<boolean>;
  13226. /**
  13227. * Specifies if the skeleton should be serialized
  13228. */
  13229. doNotSerialize: boolean;
  13230. private _useTextureToStoreBoneMatrices;
  13231. /**
  13232. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13233. * Please note that this option is not available if the hardware does not support it
  13234. */
  13235. useTextureToStoreBoneMatrices: boolean;
  13236. private _animationPropertiesOverride;
  13237. /**
  13238. * Gets or sets the animation properties override
  13239. */
  13240. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13241. /**
  13242. * List of inspectable custom properties (used by the Inspector)
  13243. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13244. */
  13245. inspectableCustomProperties: IInspectable[];
  13246. /**
  13247. * An observable triggered before computing the skeleton's matrices
  13248. */
  13249. onBeforeComputeObservable: Observable<Skeleton>;
  13250. /**
  13251. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13252. */
  13253. readonly isUsingTextureForMatrices: boolean;
  13254. /**
  13255. * Gets the unique ID of this skeleton
  13256. */
  13257. readonly uniqueId: number;
  13258. /**
  13259. * Creates a new skeleton
  13260. * @param name defines the skeleton name
  13261. * @param id defines the skeleton Id
  13262. * @param scene defines the hosting scene
  13263. */
  13264. constructor(
  13265. /** defines the skeleton name */
  13266. name: string,
  13267. /** defines the skeleton Id */
  13268. id: string, scene: Scene);
  13269. /**
  13270. * Gets the current object class name.
  13271. * @return the class name
  13272. */
  13273. getClassName(): string;
  13274. /**
  13275. * Returns an array containing the root bones
  13276. * @returns an array containing the root bones
  13277. */
  13278. getChildren(): Array<Bone>;
  13279. /**
  13280. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13281. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13282. * @returns a Float32Array containing matrices data
  13283. */
  13284. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13285. /**
  13286. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13287. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13288. * @returns a raw texture containing the data
  13289. */
  13290. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13291. /**
  13292. * Gets the current hosting scene
  13293. * @returns a scene object
  13294. */
  13295. getScene(): Scene;
  13296. /**
  13297. * Gets a string representing the current skeleton data
  13298. * @param fullDetails defines a boolean indicating if we want a verbose version
  13299. * @returns a string representing the current skeleton data
  13300. */
  13301. toString(fullDetails?: boolean): string;
  13302. /**
  13303. * Get bone's index searching by name
  13304. * @param name defines bone's name to search for
  13305. * @return the indice of the bone. Returns -1 if not found
  13306. */
  13307. getBoneIndexByName(name: string): number;
  13308. /**
  13309. * Creater a new animation range
  13310. * @param name defines the name of the range
  13311. * @param from defines the start key
  13312. * @param to defines the end key
  13313. */
  13314. createAnimationRange(name: string, from: number, to: number): void;
  13315. /**
  13316. * Delete a specific animation range
  13317. * @param name defines the name of the range
  13318. * @param deleteFrames defines if frames must be removed as well
  13319. */
  13320. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13321. /**
  13322. * Gets a specific animation range
  13323. * @param name defines the name of the range to look for
  13324. * @returns the requested animation range or null if not found
  13325. */
  13326. getAnimationRange(name: string): Nullable<AnimationRange>;
  13327. /**
  13328. * Gets the list of all animation ranges defined on this skeleton
  13329. * @returns an array
  13330. */
  13331. getAnimationRanges(): Nullable<AnimationRange>[];
  13332. /**
  13333. * Copy animation range from a source skeleton.
  13334. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13335. * @param source defines the source skeleton
  13336. * @param name defines the name of the range to copy
  13337. * @param rescaleAsRequired defines if rescaling must be applied if required
  13338. * @returns true if operation was successful
  13339. */
  13340. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13341. /**
  13342. * Forces the skeleton to go to rest pose
  13343. */
  13344. returnToRest(): void;
  13345. private _getHighestAnimationFrame;
  13346. /**
  13347. * Begin a specific animation range
  13348. * @param name defines the name of the range to start
  13349. * @param loop defines if looping must be turned on (false by default)
  13350. * @param speedRatio defines the speed ratio to apply (1 by default)
  13351. * @param onAnimationEnd defines a callback which will be called when animation will end
  13352. * @returns a new animatable
  13353. */
  13354. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13355. /** @hidden */
  13356. _markAsDirty(): void;
  13357. /** @hidden */
  13358. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13359. /** @hidden */
  13360. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13361. private _computeTransformMatrices;
  13362. /**
  13363. * Build all resources required to render a skeleton
  13364. */
  13365. prepare(): void;
  13366. /**
  13367. * Gets the list of animatables currently running for this skeleton
  13368. * @returns an array of animatables
  13369. */
  13370. getAnimatables(): IAnimatable[];
  13371. /**
  13372. * Clone the current skeleton
  13373. * @param name defines the name of the new skeleton
  13374. * @param id defines the id of the new skeleton
  13375. * @returns the new skeleton
  13376. */
  13377. clone(name: string, id: string): Skeleton;
  13378. /**
  13379. * Enable animation blending for this skeleton
  13380. * @param blendingSpeed defines the blending speed to apply
  13381. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13382. */
  13383. enableBlending(blendingSpeed?: number): void;
  13384. /**
  13385. * Releases all resources associated with the current skeleton
  13386. */
  13387. dispose(): void;
  13388. /**
  13389. * Serialize the skeleton in a JSON object
  13390. * @returns a JSON object
  13391. */
  13392. serialize(): any;
  13393. /**
  13394. * Creates a new skeleton from serialized data
  13395. * @param parsedSkeleton defines the serialized data
  13396. * @param scene defines the hosting scene
  13397. * @returns a new skeleton
  13398. */
  13399. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13400. /**
  13401. * Compute all node absolute transforms
  13402. * @param forceUpdate defines if computation must be done even if cache is up to date
  13403. */
  13404. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13405. /**
  13406. * Gets the root pose matrix
  13407. * @returns a matrix
  13408. */
  13409. getPoseMatrix(): Nullable<Matrix>;
  13410. /**
  13411. * Sorts bones per internal index
  13412. */
  13413. sortBones(): void;
  13414. private _sortBones;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * Class used to store bone information
  13420. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13421. */
  13422. export class Bone extends Node {
  13423. /**
  13424. * defines the bone name
  13425. */
  13426. name: string;
  13427. private static _tmpVecs;
  13428. private static _tmpQuat;
  13429. private static _tmpMats;
  13430. /**
  13431. * Gets the list of child bones
  13432. */
  13433. children: Bone[];
  13434. /** Gets the animations associated with this bone */
  13435. animations: Animation[];
  13436. /**
  13437. * Gets or sets bone length
  13438. */
  13439. length: number;
  13440. /**
  13441. * @hidden Internal only
  13442. * Set this value to map this bone to a different index in the transform matrices
  13443. * Set this value to -1 to exclude the bone from the transform matrices
  13444. */
  13445. _index: Nullable<number>;
  13446. private _skeleton;
  13447. private _localMatrix;
  13448. private _restPose;
  13449. private _baseMatrix;
  13450. private _absoluteTransform;
  13451. private _invertedAbsoluteTransform;
  13452. private _parent;
  13453. private _scalingDeterminant;
  13454. private _worldTransform;
  13455. private _localScaling;
  13456. private _localRotation;
  13457. private _localPosition;
  13458. private _needToDecompose;
  13459. private _needToCompose;
  13460. /** @hidden */
  13461. _linkedTransformNode: Nullable<TransformNode>;
  13462. /** @hidden */
  13463. _waitingTransformNodeId: Nullable<string>;
  13464. /** @hidden */
  13465. /** @hidden */
  13466. _matrix: Matrix;
  13467. /**
  13468. * Create a new bone
  13469. * @param name defines the bone name
  13470. * @param skeleton defines the parent skeleton
  13471. * @param parentBone defines the parent (can be null if the bone is the root)
  13472. * @param localMatrix defines the local matrix
  13473. * @param restPose defines the rest pose matrix
  13474. * @param baseMatrix defines the base matrix
  13475. * @param index defines index of the bone in the hiearchy
  13476. */
  13477. constructor(
  13478. /**
  13479. * defines the bone name
  13480. */
  13481. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13482. /**
  13483. * Gets the current object class name.
  13484. * @return the class name
  13485. */
  13486. getClassName(): string;
  13487. /**
  13488. * Gets the parent skeleton
  13489. * @returns a skeleton
  13490. */
  13491. getSkeleton(): Skeleton;
  13492. /**
  13493. * Gets parent bone
  13494. * @returns a bone or null if the bone is the root of the bone hierarchy
  13495. */
  13496. getParent(): Nullable<Bone>;
  13497. /**
  13498. * Returns an array containing the root bones
  13499. * @returns an array containing the root bones
  13500. */
  13501. getChildren(): Array<Bone>;
  13502. /**
  13503. * Sets the parent bone
  13504. * @param parent defines the parent (can be null if the bone is the root)
  13505. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13506. */
  13507. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13508. /**
  13509. * Gets the local matrix
  13510. * @returns a matrix
  13511. */
  13512. getLocalMatrix(): Matrix;
  13513. /**
  13514. * Gets the base matrix (initial matrix which remains unchanged)
  13515. * @returns a matrix
  13516. */
  13517. getBaseMatrix(): Matrix;
  13518. /**
  13519. * Gets the rest pose matrix
  13520. * @returns a matrix
  13521. */
  13522. getRestPose(): Matrix;
  13523. /**
  13524. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13525. */
  13526. getWorldMatrix(): Matrix;
  13527. /**
  13528. * Sets the local matrix to rest pose matrix
  13529. */
  13530. returnToRest(): void;
  13531. /**
  13532. * Gets the inverse of the absolute transform matrix.
  13533. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13534. * @returns a matrix
  13535. */
  13536. getInvertedAbsoluteTransform(): Matrix;
  13537. /**
  13538. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13539. * @returns a matrix
  13540. */
  13541. getAbsoluteTransform(): Matrix;
  13542. /**
  13543. * Links with the given transform node.
  13544. * The local matrix of this bone is copied from the transform node every frame.
  13545. * @param transformNode defines the transform node to link to
  13546. */
  13547. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13548. /**
  13549. * Gets the node used to drive the bone's transformation
  13550. * @returns a transform node or null
  13551. */
  13552. getTransformNode(): Nullable<TransformNode>;
  13553. /** Gets or sets current position (in local space) */
  13554. position: Vector3;
  13555. /** Gets or sets current rotation (in local space) */
  13556. rotation: Vector3;
  13557. /** Gets or sets current rotation quaternion (in local space) */
  13558. rotationQuaternion: Quaternion;
  13559. /** Gets or sets current scaling (in local space) */
  13560. scaling: Vector3;
  13561. /**
  13562. * Gets the animation properties override
  13563. */
  13564. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13565. private _decompose;
  13566. private _compose;
  13567. /**
  13568. * Update the base and local matrices
  13569. * @param matrix defines the new base or local matrix
  13570. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13571. * @param updateLocalMatrix defines if the local matrix should be updated
  13572. */
  13573. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13574. /** @hidden */
  13575. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13576. /**
  13577. * Flag the bone as dirty (Forcing it to update everything)
  13578. */
  13579. markAsDirty(): void;
  13580. /** @hidden */
  13581. _markAsDirtyAndCompose(): void;
  13582. private _markAsDirtyAndDecompose;
  13583. /**
  13584. * Translate the bone in local or world space
  13585. * @param vec The amount to translate the bone
  13586. * @param space The space that the translation is in
  13587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13588. */
  13589. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13590. /**
  13591. * Set the postion of the bone in local or world space
  13592. * @param position The position to set the bone
  13593. * @param space The space that the position is in
  13594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13595. */
  13596. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13597. /**
  13598. * Set the absolute position of the bone (world space)
  13599. * @param position The position to set the bone
  13600. * @param mesh The mesh that this bone is attached to
  13601. */
  13602. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13603. /**
  13604. * Scale the bone on the x, y and z axes (in local space)
  13605. * @param x The amount to scale the bone on the x axis
  13606. * @param y The amount to scale the bone on the y axis
  13607. * @param z The amount to scale the bone on the z axis
  13608. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13609. */
  13610. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13611. /**
  13612. * Set the bone scaling in local space
  13613. * @param scale defines the scaling vector
  13614. */
  13615. setScale(scale: Vector3): void;
  13616. /**
  13617. * Gets the current scaling in local space
  13618. * @returns the current scaling vector
  13619. */
  13620. getScale(): Vector3;
  13621. /**
  13622. * Gets the current scaling in local space and stores it in a target vector
  13623. * @param result defines the target vector
  13624. */
  13625. getScaleToRef(result: Vector3): void;
  13626. /**
  13627. * Set the yaw, pitch, and roll of the bone in local or world space
  13628. * @param yaw The rotation of the bone on the y axis
  13629. * @param pitch The rotation of the bone on the x axis
  13630. * @param roll The rotation of the bone on the z axis
  13631. * @param space The space that the axes of rotation are in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. */
  13634. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13635. /**
  13636. * Add a rotation to the bone on an axis in local or world space
  13637. * @param axis The axis to rotate the bone on
  13638. * @param amount The amount to rotate the bone
  13639. * @param space The space that the axis is in
  13640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13641. */
  13642. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13643. /**
  13644. * Set the rotation of the bone to a particular axis angle in local or world space
  13645. * @param axis The axis to rotate the bone on
  13646. * @param angle The angle that the bone should be rotated to
  13647. * @param space The space that the axis is in
  13648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13649. */
  13650. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13651. /**
  13652. * Set the euler rotation of the bone in local of world space
  13653. * @param rotation The euler rotation that the bone should be set to
  13654. * @param space The space that the rotation is in
  13655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13656. */
  13657. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13658. /**
  13659. * Set the quaternion rotation of the bone in local of world space
  13660. * @param quat The quaternion rotation that the bone should be set to
  13661. * @param space The space that the rotation is in
  13662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13663. */
  13664. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13665. /**
  13666. * Set the rotation matrix of the bone in local of world space
  13667. * @param rotMat The rotation matrix that the bone should be set to
  13668. * @param space The space that the rotation is in
  13669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13670. */
  13671. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13672. private _rotateWithMatrix;
  13673. private _getNegativeRotationToRef;
  13674. /**
  13675. * Get the position of the bone in local or world space
  13676. * @param space The space that the returned position is in
  13677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13678. * @returns The position of the bone
  13679. */
  13680. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13681. /**
  13682. * Copy the position of the bone to a vector3 in local or world space
  13683. * @param space The space that the returned position is in
  13684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13685. * @param result The vector3 to copy the position to
  13686. */
  13687. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13688. /**
  13689. * Get the absolute position of the bone (world space)
  13690. * @param mesh The mesh that this bone is attached to
  13691. * @returns The absolute position of the bone
  13692. */
  13693. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13694. /**
  13695. * Copy the absolute position of the bone (world space) to the result param
  13696. * @param mesh The mesh that this bone is attached to
  13697. * @param result The vector3 to copy the absolute position to
  13698. */
  13699. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13700. /**
  13701. * Compute the absolute transforms of this bone and its children
  13702. */
  13703. computeAbsoluteTransforms(): void;
  13704. /**
  13705. * Get the world direction from an axis that is in the local space of the bone
  13706. * @param localAxis The local direction that is used to compute the world direction
  13707. * @param mesh The mesh that this bone is attached to
  13708. * @returns The world direction
  13709. */
  13710. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13711. /**
  13712. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13713. * @param localAxis The local direction that is used to compute the world direction
  13714. * @param mesh The mesh that this bone is attached to
  13715. * @param result The vector3 that the world direction will be copied to
  13716. */
  13717. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13718. /**
  13719. * Get the euler rotation of the bone in local or world space
  13720. * @param space The space that the rotation should be in
  13721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13722. * @returns The euler rotation
  13723. */
  13724. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13725. /**
  13726. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13727. * @param space The space that the rotation should be in
  13728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13729. * @param result The vector3 that the rotation should be copied to
  13730. */
  13731. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13732. /**
  13733. * Get the quaternion rotation of the bone in either local or world space
  13734. * @param space The space that the rotation should be in
  13735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13736. * @returns The quaternion rotation
  13737. */
  13738. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13739. /**
  13740. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13741. * @param space The space that the rotation should be in
  13742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13743. * @param result The quaternion that the rotation should be copied to
  13744. */
  13745. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13746. /**
  13747. * Get the rotation matrix of the bone in local or world space
  13748. * @param space The space that the rotation should be in
  13749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13750. * @returns The rotation matrix
  13751. */
  13752. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13753. /**
  13754. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13755. * @param space The space that the rotation should be in
  13756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13757. * @param result The quaternion that the rotation should be copied to
  13758. */
  13759. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13760. /**
  13761. * Get the world position of a point that is in the local space of the bone
  13762. * @param position The local position
  13763. * @param mesh The mesh that this bone is attached to
  13764. * @returns The world position
  13765. */
  13766. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13767. /**
  13768. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13769. * @param position The local position
  13770. * @param mesh The mesh that this bone is attached to
  13771. * @param result The vector3 that the world position should be copied to
  13772. */
  13773. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13774. /**
  13775. * Get the local position of a point that is in world space
  13776. * @param position The world position
  13777. * @param mesh The mesh that this bone is attached to
  13778. * @returns The local position
  13779. */
  13780. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13781. /**
  13782. * Get the local position of a point that is in world space and copy it to the result param
  13783. * @param position The world position
  13784. * @param mesh The mesh that this bone is attached to
  13785. * @param result The vector3 that the local position should be copied to
  13786. */
  13787. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13788. }
  13789. }
  13790. declare module BABYLON {
  13791. /**
  13792. * 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.
  13793. * @see https://doc.babylonjs.com/how_to/transformnode
  13794. */
  13795. export class TransformNode extends Node {
  13796. /**
  13797. * Object will not rotate to face the camera
  13798. */
  13799. static BILLBOARDMODE_NONE: number;
  13800. /**
  13801. * Object will rotate to face the camera but only on the x axis
  13802. */
  13803. static BILLBOARDMODE_X: number;
  13804. /**
  13805. * Object will rotate to face the camera but only on the y axis
  13806. */
  13807. static BILLBOARDMODE_Y: number;
  13808. /**
  13809. * Object will rotate to face the camera but only on the z axis
  13810. */
  13811. static BILLBOARDMODE_Z: number;
  13812. /**
  13813. * Object will rotate to face the camera
  13814. */
  13815. static BILLBOARDMODE_ALL: number;
  13816. /**
  13817. * Object will rotate to face the camera's position instead of orientation
  13818. */
  13819. static BILLBOARDMODE_USE_POSITION: number;
  13820. private _forward;
  13821. private _forwardInverted;
  13822. private _up;
  13823. private _right;
  13824. private _rightInverted;
  13825. private _position;
  13826. private _rotation;
  13827. private _rotationQuaternion;
  13828. protected _scaling: Vector3;
  13829. protected _isDirty: boolean;
  13830. private _transformToBoneReferal;
  13831. private _isAbsoluteSynced;
  13832. private _billboardMode;
  13833. /**
  13834. * Gets or sets the billboard mode. Default is 0.
  13835. *
  13836. * | Value | Type | Description |
  13837. * | --- | --- | --- |
  13838. * | 0 | BILLBOARDMODE_NONE | |
  13839. * | 1 | BILLBOARDMODE_X | |
  13840. * | 2 | BILLBOARDMODE_Y | |
  13841. * | 4 | BILLBOARDMODE_Z | |
  13842. * | 7 | BILLBOARDMODE_ALL | |
  13843. *
  13844. */
  13845. billboardMode: number;
  13846. private _preserveParentRotationForBillboard;
  13847. /**
  13848. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13849. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13850. */
  13851. preserveParentRotationForBillboard: boolean;
  13852. /**
  13853. * 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
  13854. */
  13855. scalingDeterminant: number;
  13856. private _infiniteDistance;
  13857. /**
  13858. * Gets or sets the distance of the object to max, often used by skybox
  13859. */
  13860. infiniteDistance: boolean;
  13861. /**
  13862. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13863. * By default the system will update normals to compensate
  13864. */
  13865. ignoreNonUniformScaling: boolean;
  13866. /**
  13867. * 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
  13868. */
  13869. reIntegrateRotationIntoRotationQuaternion: boolean;
  13870. /** @hidden */
  13871. _poseMatrix: Nullable<Matrix>;
  13872. /** @hidden */
  13873. _localMatrix: Matrix;
  13874. private _usePivotMatrix;
  13875. private _absolutePosition;
  13876. private _absoluteScaling;
  13877. private _absoluteRotationQuaternion;
  13878. private _pivotMatrix;
  13879. private _pivotMatrixInverse;
  13880. protected _postMultiplyPivotMatrix: boolean;
  13881. protected _isWorldMatrixFrozen: boolean;
  13882. /** @hidden */
  13883. _indexInSceneTransformNodesArray: number;
  13884. /**
  13885. * An event triggered after the world matrix is updated
  13886. */
  13887. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13888. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13889. /**
  13890. * Gets a string identifying the name of the class
  13891. * @returns "TransformNode" string
  13892. */
  13893. getClassName(): string;
  13894. /**
  13895. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13896. */
  13897. position: Vector3;
  13898. /**
  13899. * 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)).
  13900. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13901. */
  13902. rotation: Vector3;
  13903. /**
  13904. * 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)).
  13905. */
  13906. scaling: Vector3;
  13907. /**
  13908. * 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).
  13909. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13910. */
  13911. rotationQuaternion: Nullable<Quaternion>;
  13912. /**
  13913. * The forward direction of that transform in world space.
  13914. */
  13915. readonly forward: Vector3;
  13916. /**
  13917. * The up direction of that transform in world space.
  13918. */
  13919. readonly up: Vector3;
  13920. /**
  13921. * The right direction of that transform in world space.
  13922. */
  13923. readonly right: Vector3;
  13924. /**
  13925. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13926. * @param matrix the matrix to copy the pose from
  13927. * @returns this TransformNode.
  13928. */
  13929. updatePoseMatrix(matrix: Matrix): TransformNode;
  13930. /**
  13931. * Returns the mesh Pose matrix.
  13932. * @returns the pose matrix
  13933. */
  13934. getPoseMatrix(): Matrix;
  13935. /** @hidden */
  13936. _isSynchronized(): boolean;
  13937. /** @hidden */
  13938. _initCache(): void;
  13939. /**
  13940. * Flag the transform node as dirty (Forcing it to update everything)
  13941. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13942. * @returns this transform node
  13943. */
  13944. markAsDirty(property: string): TransformNode;
  13945. /**
  13946. * Returns the current mesh absolute position.
  13947. * Returns a Vector3.
  13948. */
  13949. readonly absolutePosition: Vector3;
  13950. /**
  13951. * Returns the current mesh absolute scaling.
  13952. * Returns a Vector3.
  13953. */
  13954. readonly absoluteScaling: Vector3;
  13955. /**
  13956. * Returns the current mesh absolute rotation.
  13957. * Returns a Quaternion.
  13958. */
  13959. readonly absoluteRotationQuaternion: Quaternion;
  13960. /**
  13961. * Sets a new matrix to apply before all other transformation
  13962. * @param matrix defines the transform matrix
  13963. * @returns the current TransformNode
  13964. */
  13965. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13966. /**
  13967. * Sets a new pivot matrix to the current node
  13968. * @param matrix defines the new pivot matrix to use
  13969. * @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
  13970. * @returns the current TransformNode
  13971. */
  13972. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13973. /**
  13974. * Returns the mesh pivot matrix.
  13975. * Default : Identity.
  13976. * @returns the matrix
  13977. */
  13978. getPivotMatrix(): Matrix;
  13979. /**
  13980. * Instantiate (when possible) or clone that node with its hierarchy
  13981. * @param newParent defines the new parent to use for the instance (or clone)
  13982. * @returns an instance (or a clone) of the current node with its hiearchy
  13983. */
  13984. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13985. /**
  13986. * Prevents the World matrix to be computed any longer
  13987. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13988. * @returns the TransformNode.
  13989. */
  13990. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13991. /**
  13992. * Allows back the World matrix computation.
  13993. * @returns the TransformNode.
  13994. */
  13995. unfreezeWorldMatrix(): this;
  13996. /**
  13997. * True if the World matrix has been frozen.
  13998. */
  13999. readonly isWorldMatrixFrozen: boolean;
  14000. /**
  14001. * Retuns the mesh absolute position in the World.
  14002. * @returns a Vector3.
  14003. */
  14004. getAbsolutePosition(): Vector3;
  14005. /**
  14006. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14007. * @param absolutePosition the absolute position to set
  14008. * @returns the TransformNode.
  14009. */
  14010. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14011. /**
  14012. * Sets the mesh position in its local space.
  14013. * @param vector3 the position to set in localspace
  14014. * @returns the TransformNode.
  14015. */
  14016. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14017. /**
  14018. * Returns the mesh position in the local space from the current World matrix values.
  14019. * @returns a new Vector3.
  14020. */
  14021. getPositionExpressedInLocalSpace(): Vector3;
  14022. /**
  14023. * Translates the mesh along the passed Vector3 in its local space.
  14024. * @param vector3 the distance to translate in localspace
  14025. * @returns the TransformNode.
  14026. */
  14027. locallyTranslate(vector3: Vector3): TransformNode;
  14028. private static _lookAtVectorCache;
  14029. /**
  14030. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14031. * @param targetPoint the position (must be in same space as current mesh) to look at
  14032. * @param yawCor optional yaw (y-axis) correction in radians
  14033. * @param pitchCor optional pitch (x-axis) correction in radians
  14034. * @param rollCor optional roll (z-axis) correction in radians
  14035. * @param space the choosen space of the target
  14036. * @returns the TransformNode.
  14037. */
  14038. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14039. /**
  14040. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14041. * This Vector3 is expressed in the World space.
  14042. * @param localAxis axis to rotate
  14043. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14044. */
  14045. getDirection(localAxis: Vector3): Vector3;
  14046. /**
  14047. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14048. * localAxis is expressed in the mesh local space.
  14049. * result is computed in the Wordl space from the mesh World matrix.
  14050. * @param localAxis axis to rotate
  14051. * @param result the resulting transformnode
  14052. * @returns this TransformNode.
  14053. */
  14054. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14055. /**
  14056. * Sets this transform node rotation to the given local axis.
  14057. * @param localAxis the axis in local space
  14058. * @param yawCor optional yaw (y-axis) correction in radians
  14059. * @param pitchCor optional pitch (x-axis) correction in radians
  14060. * @param rollCor optional roll (z-axis) correction in radians
  14061. * @returns this TransformNode
  14062. */
  14063. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14064. /**
  14065. * Sets a new pivot point to the current node
  14066. * @param point defines the new pivot point to use
  14067. * @param space defines if the point is in world or local space (local by default)
  14068. * @returns the current TransformNode
  14069. */
  14070. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14071. /**
  14072. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14073. * @returns the pivot point
  14074. */
  14075. getPivotPoint(): Vector3;
  14076. /**
  14077. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14078. * @param result the vector3 to store the result
  14079. * @returns this TransformNode.
  14080. */
  14081. getPivotPointToRef(result: Vector3): TransformNode;
  14082. /**
  14083. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14084. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14085. */
  14086. getAbsolutePivotPoint(): Vector3;
  14087. /**
  14088. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14089. * @param result vector3 to store the result
  14090. * @returns this TransformNode.
  14091. */
  14092. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14093. /**
  14094. * Defines the passed node as the parent of the current node.
  14095. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14096. * @see https://doc.babylonjs.com/how_to/parenting
  14097. * @param node the node ot set as the parent
  14098. * @returns this TransformNode.
  14099. */
  14100. setParent(node: Nullable<Node>): TransformNode;
  14101. private _nonUniformScaling;
  14102. /**
  14103. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14104. */
  14105. readonly nonUniformScaling: boolean;
  14106. /** @hidden */
  14107. _updateNonUniformScalingState(value: boolean): boolean;
  14108. /**
  14109. * Attach the current TransformNode to another TransformNode associated with a bone
  14110. * @param bone Bone affecting the TransformNode
  14111. * @param affectedTransformNode TransformNode associated with the bone
  14112. * @returns this object
  14113. */
  14114. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14115. /**
  14116. * Detach the transform node if its associated with a bone
  14117. * @returns this object
  14118. */
  14119. detachFromBone(): TransformNode;
  14120. private static _rotationAxisCache;
  14121. /**
  14122. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14123. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14124. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14125. * The passed axis is also normalized.
  14126. * @param axis the axis to rotate around
  14127. * @param amount the amount to rotate in radians
  14128. * @param space Space to rotate in (Default: local)
  14129. * @returns the TransformNode.
  14130. */
  14131. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14132. /**
  14133. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14134. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14135. * The passed axis is also normalized. .
  14136. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14137. * @param point the point to rotate around
  14138. * @param axis the axis to rotate around
  14139. * @param amount the amount to rotate in radians
  14140. * @returns the TransformNode
  14141. */
  14142. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14143. /**
  14144. * Translates the mesh along the axis vector for the passed distance in the given space.
  14145. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14146. * @param axis the axis to translate in
  14147. * @param distance the distance to translate
  14148. * @param space Space to rotate in (Default: local)
  14149. * @returns the TransformNode.
  14150. */
  14151. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14152. /**
  14153. * Adds a rotation step to the mesh current rotation.
  14154. * x, y, z are Euler angles expressed in radians.
  14155. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14156. * This means this rotation is made in the mesh local space only.
  14157. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14158. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14159. * ```javascript
  14160. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14161. * ```
  14162. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14163. * 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.
  14164. * @param x Rotation to add
  14165. * @param y Rotation to add
  14166. * @param z Rotation to add
  14167. * @returns the TransformNode.
  14168. */
  14169. addRotation(x: number, y: number, z: number): TransformNode;
  14170. /**
  14171. * @hidden
  14172. */
  14173. protected _getEffectiveParent(): Nullable<Node>;
  14174. /**
  14175. * Computes the world matrix of the node
  14176. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14177. * @returns the world matrix
  14178. */
  14179. computeWorldMatrix(force?: boolean): Matrix;
  14180. protected _afterComputeWorldMatrix(): void;
  14181. /**
  14182. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14183. * @param func callback function to add
  14184. *
  14185. * @returns the TransformNode.
  14186. */
  14187. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14188. /**
  14189. * Removes a registered callback function.
  14190. * @param func callback function to remove
  14191. * @returns the TransformNode.
  14192. */
  14193. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14194. /**
  14195. * Gets the position of the current mesh in camera space
  14196. * @param camera defines the camera to use
  14197. * @returns a position
  14198. */
  14199. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14200. /**
  14201. * Returns the distance from the mesh to the active camera
  14202. * @param camera defines the camera to use
  14203. * @returns the distance
  14204. */
  14205. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14206. /**
  14207. * Clone the current transform node
  14208. * @param name Name of the new clone
  14209. * @param newParent New parent for the clone
  14210. * @param doNotCloneChildren Do not clone children hierarchy
  14211. * @returns the new transform node
  14212. */
  14213. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14214. /**
  14215. * Serializes the objects information.
  14216. * @param currentSerializationObject defines the object to serialize in
  14217. * @returns the serialized object
  14218. */
  14219. serialize(currentSerializationObject?: any): any;
  14220. /**
  14221. * Returns a new TransformNode object parsed from the source provided.
  14222. * @param parsedTransformNode is the source.
  14223. * @param scene the scne the object belongs to
  14224. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14225. * @returns a new TransformNode object parsed from the source provided.
  14226. */
  14227. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14228. /**
  14229. * Get all child-transformNodes of this node
  14230. * @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
  14231. * @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
  14232. * @returns an array of TransformNode
  14233. */
  14234. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14235. /**
  14236. * Releases resources associated with this transform node.
  14237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14239. */
  14240. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14241. /**
  14242. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14243. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14244. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14245. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14246. * @returns the current mesh
  14247. */
  14248. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14249. private _syncAbsoluteScalingAndRotation;
  14250. }
  14251. }
  14252. declare module BABYLON {
  14253. /**
  14254. * Defines the types of pose enabled controllers that are supported
  14255. */
  14256. export enum PoseEnabledControllerType {
  14257. /**
  14258. * HTC Vive
  14259. */
  14260. VIVE = 0,
  14261. /**
  14262. * Oculus Rift
  14263. */
  14264. OCULUS = 1,
  14265. /**
  14266. * Windows mixed reality
  14267. */
  14268. WINDOWS = 2,
  14269. /**
  14270. * Samsung gear VR
  14271. */
  14272. GEAR_VR = 3,
  14273. /**
  14274. * Google Daydream
  14275. */
  14276. DAYDREAM = 4,
  14277. /**
  14278. * Generic
  14279. */
  14280. GENERIC = 5
  14281. }
  14282. /**
  14283. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14284. */
  14285. export interface MutableGamepadButton {
  14286. /**
  14287. * Value of the button/trigger
  14288. */
  14289. value: number;
  14290. /**
  14291. * If the button/trigger is currently touched
  14292. */
  14293. touched: boolean;
  14294. /**
  14295. * If the button/trigger is currently pressed
  14296. */
  14297. pressed: boolean;
  14298. }
  14299. /**
  14300. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14301. * @hidden
  14302. */
  14303. export interface ExtendedGamepadButton extends GamepadButton {
  14304. /**
  14305. * If the button/trigger is currently pressed
  14306. */
  14307. readonly pressed: boolean;
  14308. /**
  14309. * If the button/trigger is currently touched
  14310. */
  14311. readonly touched: boolean;
  14312. /**
  14313. * Value of the button/trigger
  14314. */
  14315. readonly value: number;
  14316. }
  14317. /** @hidden */
  14318. export interface _GamePadFactory {
  14319. /**
  14320. * Returns wether or not the current gamepad can be created for this type of controller.
  14321. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14322. * @returns true if it can be created, otherwise false
  14323. */
  14324. canCreate(gamepadInfo: any): boolean;
  14325. /**
  14326. * Creates a new instance of the Gamepad.
  14327. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14328. * @returns the new gamepad instance
  14329. */
  14330. create(gamepadInfo: any): Gamepad;
  14331. }
  14332. /**
  14333. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14334. */
  14335. export class PoseEnabledControllerHelper {
  14336. /** @hidden */
  14337. static _ControllerFactories: _GamePadFactory[];
  14338. /** @hidden */
  14339. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14340. /**
  14341. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14342. * @param vrGamepad the gamepad to initialized
  14343. * @returns a vr controller of the type the gamepad identified as
  14344. */
  14345. static InitiateController(vrGamepad: any): Gamepad;
  14346. }
  14347. /**
  14348. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14349. */
  14350. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14351. /**
  14352. * If the controller is used in a webXR session
  14353. */
  14354. isXR: boolean;
  14355. private _deviceRoomPosition;
  14356. private _deviceRoomRotationQuaternion;
  14357. /**
  14358. * The device position in babylon space
  14359. */
  14360. devicePosition: Vector3;
  14361. /**
  14362. * The device rotation in babylon space
  14363. */
  14364. deviceRotationQuaternion: Quaternion;
  14365. /**
  14366. * The scale factor of the device in babylon space
  14367. */
  14368. deviceScaleFactor: number;
  14369. /**
  14370. * (Likely devicePosition should be used instead) The device position in its room space
  14371. */
  14372. position: Vector3;
  14373. /**
  14374. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14375. */
  14376. rotationQuaternion: Quaternion;
  14377. /**
  14378. * The type of controller (Eg. Windows mixed reality)
  14379. */
  14380. controllerType: PoseEnabledControllerType;
  14381. protected _calculatedPosition: Vector3;
  14382. private _calculatedRotation;
  14383. /**
  14384. * The raw pose from the device
  14385. */
  14386. rawPose: DevicePose;
  14387. private _trackPosition;
  14388. private _maxRotationDistFromHeadset;
  14389. private _draggedRoomRotation;
  14390. /**
  14391. * @hidden
  14392. */
  14393. _disableTrackPosition(fixedPosition: Vector3): void;
  14394. /**
  14395. * Internal, the mesh attached to the controller
  14396. * @hidden
  14397. */
  14398. _mesh: Nullable<AbstractMesh>;
  14399. private _poseControlledCamera;
  14400. private _leftHandSystemQuaternion;
  14401. /**
  14402. * Internal, matrix used to convert room space to babylon space
  14403. * @hidden
  14404. */
  14405. _deviceToWorld: Matrix;
  14406. /**
  14407. * Node to be used when casting a ray from the controller
  14408. * @hidden
  14409. */
  14410. _pointingPoseNode: Nullable<TransformNode>;
  14411. /**
  14412. * Name of the child mesh that can be used to cast a ray from the controller
  14413. */
  14414. static readonly POINTING_POSE: string;
  14415. /**
  14416. * Creates a new PoseEnabledController from a gamepad
  14417. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14418. */
  14419. constructor(browserGamepad: any);
  14420. private _workingMatrix;
  14421. /**
  14422. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14423. */
  14424. update(): void;
  14425. /**
  14426. * Updates only the pose device and mesh without doing any button event checking
  14427. */
  14428. protected _updatePoseAndMesh(): void;
  14429. /**
  14430. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14431. * @param poseData raw pose fromthe device
  14432. */
  14433. updateFromDevice(poseData: DevicePose): void;
  14434. /**
  14435. * @hidden
  14436. */
  14437. _meshAttachedObservable: Observable<AbstractMesh>;
  14438. /**
  14439. * Attaches a mesh to the controller
  14440. * @param mesh the mesh to be attached
  14441. */
  14442. attachToMesh(mesh: AbstractMesh): void;
  14443. /**
  14444. * Attaches the controllers mesh to a camera
  14445. * @param camera the camera the mesh should be attached to
  14446. */
  14447. attachToPoseControlledCamera(camera: TargetCamera): void;
  14448. /**
  14449. * Disposes of the controller
  14450. */
  14451. dispose(): void;
  14452. /**
  14453. * The mesh that is attached to the controller
  14454. */
  14455. readonly mesh: Nullable<AbstractMesh>;
  14456. /**
  14457. * Gets the ray of the controller in the direction the controller is pointing
  14458. * @param length the length the resulting ray should be
  14459. * @returns a ray in the direction the controller is pointing
  14460. */
  14461. getForwardRay(length?: number): Ray;
  14462. }
  14463. }
  14464. declare module BABYLON {
  14465. /**
  14466. * Defines the WebVRController object that represents controllers tracked in 3D space
  14467. */
  14468. export abstract class WebVRController extends PoseEnabledController {
  14469. /**
  14470. * Internal, the default controller model for the controller
  14471. */
  14472. protected _defaultModel: Nullable<AbstractMesh>;
  14473. /**
  14474. * Fired when the trigger state has changed
  14475. */
  14476. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14477. /**
  14478. * Fired when the main button state has changed
  14479. */
  14480. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14481. /**
  14482. * Fired when the secondary button state has changed
  14483. */
  14484. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14485. /**
  14486. * Fired when the pad state has changed
  14487. */
  14488. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14489. /**
  14490. * Fired when controllers stick values have changed
  14491. */
  14492. onPadValuesChangedObservable: Observable<StickValues>;
  14493. /**
  14494. * Array of button availible on the controller
  14495. */
  14496. protected _buttons: Array<MutableGamepadButton>;
  14497. private _onButtonStateChange;
  14498. /**
  14499. * Fired when a controller button's state has changed
  14500. * @param callback the callback containing the button that was modified
  14501. */
  14502. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14503. /**
  14504. * X and Y axis corresponding to the controllers joystick
  14505. */
  14506. pad: StickValues;
  14507. /**
  14508. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14509. */
  14510. hand: string;
  14511. /**
  14512. * The default controller model for the controller
  14513. */
  14514. readonly defaultModel: Nullable<AbstractMesh>;
  14515. /**
  14516. * Creates a new WebVRController from a gamepad
  14517. * @param vrGamepad the gamepad that the WebVRController should be created from
  14518. */
  14519. constructor(vrGamepad: any);
  14520. /**
  14521. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14522. */
  14523. update(): void;
  14524. /**
  14525. * Function to be called when a button is modified
  14526. */
  14527. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14528. /**
  14529. * Loads a mesh and attaches it to the controller
  14530. * @param scene the scene the mesh should be added to
  14531. * @param meshLoaded callback for when the mesh has been loaded
  14532. */
  14533. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14534. private _setButtonValue;
  14535. private _changes;
  14536. private _checkChanges;
  14537. /**
  14538. * Disposes of th webVRCOntroller
  14539. */
  14540. dispose(): void;
  14541. }
  14542. }
  14543. declare module BABYLON {
  14544. /**
  14545. * The HemisphericLight simulates the ambient environment light,
  14546. * so the passed direction is the light reflection direction, not the incoming direction.
  14547. */
  14548. export class HemisphericLight extends Light {
  14549. /**
  14550. * The groundColor is the light in the opposite direction to the one specified during creation.
  14551. * 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.
  14552. */
  14553. groundColor: Color3;
  14554. /**
  14555. * The light reflection direction, not the incoming direction.
  14556. */
  14557. direction: Vector3;
  14558. /**
  14559. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14560. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14561. * The HemisphericLight can't cast shadows.
  14562. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14563. * @param name The friendly name of the light
  14564. * @param direction The direction of the light reflection
  14565. * @param scene The scene the light belongs to
  14566. */
  14567. constructor(name: string, direction: Vector3, scene: Scene);
  14568. protected _buildUniformLayout(): void;
  14569. /**
  14570. * Returns the string "HemisphericLight".
  14571. * @return The class name
  14572. */
  14573. getClassName(): string;
  14574. /**
  14575. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14576. * Returns the updated direction.
  14577. * @param target The target the direction should point to
  14578. * @return The computed direction
  14579. */
  14580. setDirectionToTarget(target: Vector3): Vector3;
  14581. /**
  14582. * Returns the shadow generator associated to the light.
  14583. * @returns Always null for hemispheric lights because it does not support shadows.
  14584. */
  14585. getShadowGenerator(): Nullable<IShadowGenerator>;
  14586. /**
  14587. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14588. * @param effect The effect to update
  14589. * @param lightIndex The index of the light in the effect to update
  14590. * @returns The hemispheric light
  14591. */
  14592. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14593. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14594. /**
  14595. * Computes the world matrix of the node
  14596. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14597. * @param useWasUpdatedFlag defines a reserved property
  14598. * @returns the world matrix
  14599. */
  14600. computeWorldMatrix(): Matrix;
  14601. /**
  14602. * Returns the integer 3.
  14603. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14604. */
  14605. getTypeID(): number;
  14606. /**
  14607. * Prepares the list of defines specific to the light type.
  14608. * @param defines the list of defines
  14609. * @param lightIndex defines the index of the light for the effect
  14610. */
  14611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14612. }
  14613. }
  14614. declare module BABYLON {
  14615. /** @hidden */
  14616. export var vrMultiviewToSingleviewPixelShader: {
  14617. name: string;
  14618. shader: string;
  14619. };
  14620. }
  14621. declare module BABYLON {
  14622. /**
  14623. * Renders to multiple views with a single draw call
  14624. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14625. */
  14626. export class MultiviewRenderTarget extends RenderTargetTexture {
  14627. /**
  14628. * Creates a multiview render target
  14629. * @param scene scene used with the render target
  14630. * @param size the size of the render target (used for each view)
  14631. */
  14632. constructor(scene: Scene, size?: number | {
  14633. width: number;
  14634. height: number;
  14635. } | {
  14636. ratio: number;
  14637. });
  14638. /**
  14639. * @hidden
  14640. * @param faceIndex the face index, if its a cube texture
  14641. */
  14642. _bindFrameBuffer(faceIndex?: number): void;
  14643. /**
  14644. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14645. * @returns the view count
  14646. */
  14647. getViewCount(): number;
  14648. }
  14649. }
  14650. declare module BABYLON {
  14651. /**
  14652. * Represents a camera frustum
  14653. */
  14654. export class Frustum {
  14655. /**
  14656. * Gets the planes representing the frustum
  14657. * @param transform matrix to be applied to the returned planes
  14658. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14659. */
  14660. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14661. /**
  14662. * Gets the near frustum plane transformed by the transform matrix
  14663. * @param transform transformation matrix to be applied to the resulting frustum plane
  14664. * @param frustumPlane the resuling frustum plane
  14665. */
  14666. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14667. /**
  14668. * Gets the far frustum plane transformed by the transform matrix
  14669. * @param transform transformation matrix to be applied to the resulting frustum plane
  14670. * @param frustumPlane the resuling frustum plane
  14671. */
  14672. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14673. /**
  14674. * Gets the left frustum plane transformed by the transform matrix
  14675. * @param transform transformation matrix to be applied to the resulting frustum plane
  14676. * @param frustumPlane the resuling frustum plane
  14677. */
  14678. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14679. /**
  14680. * Gets the right frustum plane transformed by the transform matrix
  14681. * @param transform transformation matrix to be applied to the resulting frustum plane
  14682. * @param frustumPlane the resuling frustum plane
  14683. */
  14684. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14685. /**
  14686. * Gets the top frustum plane transformed by the transform matrix
  14687. * @param transform transformation matrix to be applied to the resulting frustum plane
  14688. * @param frustumPlane the resuling frustum plane
  14689. */
  14690. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14691. /**
  14692. * Gets the bottom frustum plane transformed by the transform matrix
  14693. * @param transform transformation matrix to be applied to the resulting frustum plane
  14694. * @param frustumPlane the resuling frustum plane
  14695. */
  14696. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14697. /**
  14698. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14699. * @param transform transformation matrix to be applied to the resulting frustum planes
  14700. * @param frustumPlanes the resuling frustum planes
  14701. */
  14702. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14703. }
  14704. }
  14705. declare module BABYLON {
  14706. interface Engine {
  14707. /**
  14708. * Creates a new multiview render target
  14709. * @param width defines the width of the texture
  14710. * @param height defines the height of the texture
  14711. * @returns the created multiview texture
  14712. */
  14713. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14714. /**
  14715. * Binds a multiview framebuffer to be drawn to
  14716. * @param multiviewTexture texture to bind
  14717. */
  14718. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14719. }
  14720. interface Camera {
  14721. /**
  14722. * @hidden
  14723. * 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)
  14724. */
  14725. _useMultiviewToSingleView: boolean;
  14726. /**
  14727. * @hidden
  14728. * 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)
  14729. */
  14730. _multiviewTexture: Nullable<RenderTargetTexture>;
  14731. /**
  14732. * @hidden
  14733. * ensures the multiview texture of the camera exists and has the specified width/height
  14734. * @param width height to set on the multiview texture
  14735. * @param height width to set on the multiview texture
  14736. */
  14737. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14738. }
  14739. interface Scene {
  14740. /** @hidden */
  14741. _transformMatrixR: Matrix;
  14742. /** @hidden */
  14743. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14744. /** @hidden */
  14745. _createMultiviewUbo(): void;
  14746. /** @hidden */
  14747. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14748. /** @hidden */
  14749. _renderMultiviewToSingleView(camera: Camera): void;
  14750. }
  14751. }
  14752. declare module BABYLON {
  14753. /**
  14754. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14755. * This will not be used for webXR as it supports displaying texture arrays directly
  14756. */
  14757. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14758. /**
  14759. * Initializes a VRMultiviewToSingleview
  14760. * @param name name of the post process
  14761. * @param camera camera to be applied to
  14762. * @param scaleFactor scaling factor to the size of the output texture
  14763. */
  14764. constructor(name: string, camera: Camera, scaleFactor: number);
  14765. }
  14766. }
  14767. declare module BABYLON {
  14768. interface Engine {
  14769. /** @hidden */
  14770. _vrDisplay: any;
  14771. /** @hidden */
  14772. _vrSupported: boolean;
  14773. /** @hidden */
  14774. _oldSize: Size;
  14775. /** @hidden */
  14776. _oldHardwareScaleFactor: number;
  14777. /** @hidden */
  14778. _vrExclusivePointerMode: boolean;
  14779. /** @hidden */
  14780. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14781. /** @hidden */
  14782. _onVRDisplayPointerRestricted: () => void;
  14783. /** @hidden */
  14784. _onVRDisplayPointerUnrestricted: () => void;
  14785. /** @hidden */
  14786. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14787. /** @hidden */
  14788. _onVrDisplayDisconnect: Nullable<() => void>;
  14789. /** @hidden */
  14790. _onVrDisplayPresentChange: Nullable<() => void>;
  14791. /**
  14792. * Observable signaled when VR display mode changes
  14793. */
  14794. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14795. /**
  14796. * Observable signaled when VR request present is complete
  14797. */
  14798. onVRRequestPresentComplete: Observable<boolean>;
  14799. /**
  14800. * Observable signaled when VR request present starts
  14801. */
  14802. onVRRequestPresentStart: Observable<Engine>;
  14803. /**
  14804. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14805. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14806. */
  14807. isInVRExclusivePointerMode: boolean;
  14808. /**
  14809. * Gets a boolean indicating if a webVR device was detected
  14810. * @returns true if a webVR device was detected
  14811. */
  14812. isVRDevicePresent(): boolean;
  14813. /**
  14814. * Gets the current webVR device
  14815. * @returns the current webVR device (or null)
  14816. */
  14817. getVRDevice(): any;
  14818. /**
  14819. * Initializes a webVR display and starts listening to display change events
  14820. * The onVRDisplayChangedObservable will be notified upon these changes
  14821. * @returns A promise containing a VRDisplay and if vr is supported
  14822. */
  14823. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14824. /** @hidden */
  14825. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14826. /**
  14827. * Call this function to switch to webVR mode
  14828. * Will do nothing if webVR is not supported or if there is no webVR device
  14829. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14830. */
  14831. enableVR(): void;
  14832. /** @hidden */
  14833. _onVRFullScreenTriggered(): void;
  14834. }
  14835. }
  14836. declare module BABYLON {
  14837. /**
  14838. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14839. * IMPORTANT!! The data is right-hand data.
  14840. * @export
  14841. * @interface DevicePose
  14842. */
  14843. export interface DevicePose {
  14844. /**
  14845. * The position of the device, values in array are [x,y,z].
  14846. */
  14847. readonly position: Nullable<Float32Array>;
  14848. /**
  14849. * The linearVelocity of the device, values in array are [x,y,z].
  14850. */
  14851. readonly linearVelocity: Nullable<Float32Array>;
  14852. /**
  14853. * The linearAcceleration of the device, values in array are [x,y,z].
  14854. */
  14855. readonly linearAcceleration: Nullable<Float32Array>;
  14856. /**
  14857. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14858. */
  14859. readonly orientation: Nullable<Float32Array>;
  14860. /**
  14861. * The angularVelocity of the device, values in array are [x,y,z].
  14862. */
  14863. readonly angularVelocity: Nullable<Float32Array>;
  14864. /**
  14865. * The angularAcceleration of the device, values in array are [x,y,z].
  14866. */
  14867. readonly angularAcceleration: Nullable<Float32Array>;
  14868. }
  14869. /**
  14870. * Interface representing a pose controlled object in Babylon.
  14871. * A pose controlled object has both regular pose values as well as pose values
  14872. * from an external device such as a VR head mounted display
  14873. */
  14874. export interface PoseControlled {
  14875. /**
  14876. * The position of the object in babylon space.
  14877. */
  14878. position: Vector3;
  14879. /**
  14880. * The rotation quaternion of the object in babylon space.
  14881. */
  14882. rotationQuaternion: Quaternion;
  14883. /**
  14884. * The position of the device in babylon space.
  14885. */
  14886. devicePosition?: Vector3;
  14887. /**
  14888. * The rotation quaternion of the device in babylon space.
  14889. */
  14890. deviceRotationQuaternion: Quaternion;
  14891. /**
  14892. * The raw pose coming from the device.
  14893. */
  14894. rawPose: Nullable<DevicePose>;
  14895. /**
  14896. * The scale of the device to be used when translating from device space to babylon space.
  14897. */
  14898. deviceScaleFactor: number;
  14899. /**
  14900. * Updates the poseControlled values based on the input device pose.
  14901. * @param poseData the pose data to update the object with
  14902. */
  14903. updateFromDevice(poseData: DevicePose): void;
  14904. }
  14905. /**
  14906. * Set of options to customize the webVRCamera
  14907. */
  14908. export interface WebVROptions {
  14909. /**
  14910. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14911. */
  14912. trackPosition?: boolean;
  14913. /**
  14914. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14915. */
  14916. positionScale?: number;
  14917. /**
  14918. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14919. */
  14920. displayName?: string;
  14921. /**
  14922. * Should the native controller meshes be initialized. (default: true)
  14923. */
  14924. controllerMeshes?: boolean;
  14925. /**
  14926. * Creating a default HemiLight only on controllers. (default: true)
  14927. */
  14928. defaultLightingOnControllers?: boolean;
  14929. /**
  14930. * If you don't want to use the default VR button of the helper. (default: false)
  14931. */
  14932. useCustomVRButton?: boolean;
  14933. /**
  14934. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14935. */
  14936. customVRButton?: HTMLButtonElement;
  14937. /**
  14938. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14939. */
  14940. rayLength?: number;
  14941. /**
  14942. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14943. */
  14944. defaultHeight?: number;
  14945. /**
  14946. * If multiview should be used if availible (default: false)
  14947. */
  14948. useMultiview?: boolean;
  14949. }
  14950. /**
  14951. * This represents a WebVR camera.
  14952. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14953. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14954. */
  14955. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14956. private webVROptions;
  14957. /**
  14958. * @hidden
  14959. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14960. */
  14961. _vrDevice: any;
  14962. /**
  14963. * The rawPose of the vrDevice.
  14964. */
  14965. rawPose: Nullable<DevicePose>;
  14966. private _onVREnabled;
  14967. private _specsVersion;
  14968. private _attached;
  14969. private _frameData;
  14970. protected _descendants: Array<Node>;
  14971. private _deviceRoomPosition;
  14972. /** @hidden */
  14973. _deviceRoomRotationQuaternion: Quaternion;
  14974. private _standingMatrix;
  14975. /**
  14976. * Represents device position in babylon space.
  14977. */
  14978. devicePosition: Vector3;
  14979. /**
  14980. * Represents device rotation in babylon space.
  14981. */
  14982. deviceRotationQuaternion: Quaternion;
  14983. /**
  14984. * The scale of the device to be used when translating from device space to babylon space.
  14985. */
  14986. deviceScaleFactor: number;
  14987. private _deviceToWorld;
  14988. private _worldToDevice;
  14989. /**
  14990. * References to the webVR controllers for the vrDevice.
  14991. */
  14992. controllers: Array<WebVRController>;
  14993. /**
  14994. * Emits an event when a controller is attached.
  14995. */
  14996. onControllersAttachedObservable: Observable<WebVRController[]>;
  14997. /**
  14998. * Emits an event when a controller's mesh has been loaded;
  14999. */
  15000. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15001. /**
  15002. * Emits an event when the HMD's pose has been updated.
  15003. */
  15004. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15005. private _poseSet;
  15006. /**
  15007. * If the rig cameras be used as parent instead of this camera.
  15008. */
  15009. rigParenting: boolean;
  15010. private _lightOnControllers;
  15011. private _defaultHeight?;
  15012. /**
  15013. * Instantiates a WebVRFreeCamera.
  15014. * @param name The name of the WebVRFreeCamera
  15015. * @param position The starting anchor position for the camera
  15016. * @param scene The scene the camera belongs to
  15017. * @param webVROptions a set of customizable options for the webVRCamera
  15018. */
  15019. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15020. /**
  15021. * Gets the device distance from the ground in meters.
  15022. * @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.
  15023. */
  15024. deviceDistanceToRoomGround(): number;
  15025. /**
  15026. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15027. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15028. */
  15029. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15030. /**
  15031. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15032. * @returns A promise with a boolean set to if the standing matrix is supported.
  15033. */
  15034. useStandingMatrixAsync(): Promise<boolean>;
  15035. /**
  15036. * Disposes the camera
  15037. */
  15038. dispose(): void;
  15039. /**
  15040. * Gets a vrController by name.
  15041. * @param name The name of the controller to retreive
  15042. * @returns the controller matching the name specified or null if not found
  15043. */
  15044. getControllerByName(name: string): Nullable<WebVRController>;
  15045. private _leftController;
  15046. /**
  15047. * The controller corresponding to the users left hand.
  15048. */
  15049. readonly leftController: Nullable<WebVRController>;
  15050. private _rightController;
  15051. /**
  15052. * The controller corresponding to the users right hand.
  15053. */
  15054. readonly rightController: Nullable<WebVRController>;
  15055. /**
  15056. * Casts a ray forward from the vrCamera's gaze.
  15057. * @param length Length of the ray (default: 100)
  15058. * @returns the ray corresponding to the gaze
  15059. */
  15060. getForwardRay(length?: number): Ray;
  15061. /**
  15062. * @hidden
  15063. * Updates the camera based on device's frame data
  15064. */
  15065. _checkInputs(): void;
  15066. /**
  15067. * Updates the poseControlled values based on the input device pose.
  15068. * @param poseData Pose coming from the device
  15069. */
  15070. updateFromDevice(poseData: DevicePose): void;
  15071. private _htmlElementAttached;
  15072. private _detachIfAttached;
  15073. /**
  15074. * WebVR's attach control will start broadcasting frames to the device.
  15075. * Note that in certain browsers (chrome for example) this function must be called
  15076. * within a user-interaction callback. Example:
  15077. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15078. *
  15079. * @param element html element to attach the vrDevice to
  15080. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15081. */
  15082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15083. /**
  15084. * Detaches the camera from the html element and disables VR
  15085. *
  15086. * @param element html element to detach from
  15087. */
  15088. detachControl(element: HTMLElement): void;
  15089. /**
  15090. * @returns the name of this class
  15091. */
  15092. getClassName(): string;
  15093. /**
  15094. * Calls resetPose on the vrDisplay
  15095. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15096. */
  15097. resetToCurrentRotation(): void;
  15098. /**
  15099. * @hidden
  15100. * Updates the rig cameras (left and right eye)
  15101. */
  15102. _updateRigCameras(): void;
  15103. private _workingVector;
  15104. private _oneVector;
  15105. private _workingMatrix;
  15106. private updateCacheCalled;
  15107. private _correctPositionIfNotTrackPosition;
  15108. /**
  15109. * @hidden
  15110. * Updates the cached values of the camera
  15111. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15112. */
  15113. _updateCache(ignoreParentClass?: boolean): void;
  15114. /**
  15115. * @hidden
  15116. * Get current device position in babylon world
  15117. */
  15118. _computeDevicePosition(): void;
  15119. /**
  15120. * Updates the current device position and rotation in the babylon world
  15121. */
  15122. update(): void;
  15123. /**
  15124. * @hidden
  15125. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15126. * @returns an identity matrix
  15127. */
  15128. _getViewMatrix(): Matrix;
  15129. private _tmpMatrix;
  15130. /**
  15131. * This function is called by the two RIG cameras.
  15132. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15133. * @hidden
  15134. */
  15135. _getWebVRViewMatrix(): Matrix;
  15136. /** @hidden */
  15137. _getWebVRProjectionMatrix(): Matrix;
  15138. private _onGamepadConnectedObserver;
  15139. private _onGamepadDisconnectedObserver;
  15140. private _updateCacheWhenTrackingDisabledObserver;
  15141. /**
  15142. * Initializes the controllers and their meshes
  15143. */
  15144. initControllers(): void;
  15145. }
  15146. }
  15147. declare module BABYLON {
  15148. /**
  15149. * Size options for a post process
  15150. */
  15151. export type PostProcessOptions = {
  15152. width: number;
  15153. height: number;
  15154. };
  15155. /**
  15156. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15157. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15158. */
  15159. export class PostProcess {
  15160. /** Name of the PostProcess. */
  15161. name: string;
  15162. /**
  15163. * Gets or sets the unique id of the post process
  15164. */
  15165. uniqueId: number;
  15166. /**
  15167. * Width of the texture to apply the post process on
  15168. */
  15169. width: number;
  15170. /**
  15171. * Height of the texture to apply the post process on
  15172. */
  15173. height: number;
  15174. /**
  15175. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15176. * @hidden
  15177. */
  15178. _outputTexture: Nullable<InternalTexture>;
  15179. /**
  15180. * Sampling mode used by the shader
  15181. * See https://doc.babylonjs.com/classes/3.1/texture
  15182. */
  15183. renderTargetSamplingMode: number;
  15184. /**
  15185. * Clear color to use when screen clearing
  15186. */
  15187. clearColor: Color4;
  15188. /**
  15189. * If the buffer needs to be cleared before applying the post process. (default: true)
  15190. * Should be set to false if shader will overwrite all previous pixels.
  15191. */
  15192. autoClear: boolean;
  15193. /**
  15194. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15195. */
  15196. alphaMode: number;
  15197. /**
  15198. * Sets the setAlphaBlendConstants of the babylon engine
  15199. */
  15200. alphaConstants: Color4;
  15201. /**
  15202. * Animations to be used for the post processing
  15203. */
  15204. animations: Animation[];
  15205. /**
  15206. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15207. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15208. */
  15209. enablePixelPerfectMode: boolean;
  15210. /**
  15211. * Force the postprocess to be applied without taking in account viewport
  15212. */
  15213. forceFullscreenViewport: boolean;
  15214. /**
  15215. * List of inspectable custom properties (used by the Inspector)
  15216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15217. */
  15218. inspectableCustomProperties: IInspectable[];
  15219. /**
  15220. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15221. *
  15222. * | Value | Type | Description |
  15223. * | ----- | ----------------------------------- | ----------- |
  15224. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15225. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15226. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15227. *
  15228. */
  15229. scaleMode: number;
  15230. /**
  15231. * Force textures to be a power of two (default: false)
  15232. */
  15233. alwaysForcePOT: boolean;
  15234. private _samples;
  15235. /**
  15236. * Number of sample textures (default: 1)
  15237. */
  15238. samples: number;
  15239. /**
  15240. * Modify the scale of the post process to be the same as the viewport (default: false)
  15241. */
  15242. adaptScaleToCurrentViewport: boolean;
  15243. private _camera;
  15244. private _scene;
  15245. private _engine;
  15246. private _options;
  15247. private _reusable;
  15248. private _textureType;
  15249. /**
  15250. * Smart array of input and output textures for the post process.
  15251. * @hidden
  15252. */
  15253. _textures: SmartArray<InternalTexture>;
  15254. /**
  15255. * The index in _textures that corresponds to the output texture.
  15256. * @hidden
  15257. */
  15258. _currentRenderTextureInd: number;
  15259. private _effect;
  15260. private _samplers;
  15261. private _fragmentUrl;
  15262. private _vertexUrl;
  15263. private _parameters;
  15264. private _scaleRatio;
  15265. protected _indexParameters: any;
  15266. private _shareOutputWithPostProcess;
  15267. private _texelSize;
  15268. private _forcedOutputTexture;
  15269. /**
  15270. * Returns the fragment url or shader name used in the post process.
  15271. * @returns the fragment url or name in the shader store.
  15272. */
  15273. getEffectName(): string;
  15274. /**
  15275. * An event triggered when the postprocess is activated.
  15276. */
  15277. onActivateObservable: Observable<Camera>;
  15278. private _onActivateObserver;
  15279. /**
  15280. * A function that is added to the onActivateObservable
  15281. */
  15282. onActivate: Nullable<(camera: Camera) => void>;
  15283. /**
  15284. * An event triggered when the postprocess changes its size.
  15285. */
  15286. onSizeChangedObservable: Observable<PostProcess>;
  15287. private _onSizeChangedObserver;
  15288. /**
  15289. * A function that is added to the onSizeChangedObservable
  15290. */
  15291. onSizeChanged: (postProcess: PostProcess) => void;
  15292. /**
  15293. * An event triggered when the postprocess applies its effect.
  15294. */
  15295. onApplyObservable: Observable<Effect>;
  15296. private _onApplyObserver;
  15297. /**
  15298. * A function that is added to the onApplyObservable
  15299. */
  15300. onApply: (effect: Effect) => void;
  15301. /**
  15302. * An event triggered before rendering the postprocess
  15303. */
  15304. onBeforeRenderObservable: Observable<Effect>;
  15305. private _onBeforeRenderObserver;
  15306. /**
  15307. * A function that is added to the onBeforeRenderObservable
  15308. */
  15309. onBeforeRender: (effect: Effect) => void;
  15310. /**
  15311. * An event triggered after rendering the postprocess
  15312. */
  15313. onAfterRenderObservable: Observable<Effect>;
  15314. private _onAfterRenderObserver;
  15315. /**
  15316. * A function that is added to the onAfterRenderObservable
  15317. */
  15318. onAfterRender: (efect: Effect) => void;
  15319. /**
  15320. * 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
  15321. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15322. */
  15323. inputTexture: InternalTexture;
  15324. /**
  15325. * Gets the camera which post process is applied to.
  15326. * @returns The camera the post process is applied to.
  15327. */
  15328. getCamera(): Camera;
  15329. /**
  15330. * Gets the texel size of the postprocess.
  15331. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15332. */
  15333. readonly texelSize: Vector2;
  15334. /**
  15335. * Creates a new instance PostProcess
  15336. * @param name The name of the PostProcess.
  15337. * @param fragmentUrl The url of the fragment shader to be used.
  15338. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15339. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15340. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15341. * @param camera The camera to apply the render pass to.
  15342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15343. * @param engine The engine which the post process will be applied. (default: current engine)
  15344. * @param reusable If the post process can be reused on the same frame. (default: false)
  15345. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15346. * @param textureType Type of textures used when performing the post process. (default: 0)
  15347. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15348. * @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
  15349. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15350. */
  15351. constructor(
  15352. /** Name of the PostProcess. */
  15353. 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);
  15354. /**
  15355. * Gets a string idenfifying the name of the class
  15356. * @returns "PostProcess" string
  15357. */
  15358. getClassName(): string;
  15359. /**
  15360. * Gets the engine which this post process belongs to.
  15361. * @returns The engine the post process was enabled with.
  15362. */
  15363. getEngine(): Engine;
  15364. /**
  15365. * The effect that is created when initializing the post process.
  15366. * @returns The created effect corresponding the the postprocess.
  15367. */
  15368. getEffect(): Effect;
  15369. /**
  15370. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15371. * @param postProcess The post process to share the output with.
  15372. * @returns This post process.
  15373. */
  15374. shareOutputWith(postProcess: PostProcess): PostProcess;
  15375. /**
  15376. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15377. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15378. */
  15379. useOwnOutput(): void;
  15380. /**
  15381. * Updates the effect with the current post process compile time values and recompiles the shader.
  15382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15385. * @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
  15386. * @param onCompiled Called when the shader has been compiled.
  15387. * @param onError Called if there is an error when compiling a shader.
  15388. */
  15389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15390. /**
  15391. * The post process is reusable if it can be used multiple times within one frame.
  15392. * @returns If the post process is reusable
  15393. */
  15394. isReusable(): boolean;
  15395. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15396. markTextureDirty(): void;
  15397. /**
  15398. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15399. * 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.
  15400. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15401. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15402. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15403. * @returns The target texture that was bound to be written to.
  15404. */
  15405. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15406. /**
  15407. * If the post process is supported.
  15408. */
  15409. readonly isSupported: boolean;
  15410. /**
  15411. * The aspect ratio of the output texture.
  15412. */
  15413. readonly aspectRatio: number;
  15414. /**
  15415. * Get a value indicating if the post-process is ready to be used
  15416. * @returns true if the post-process is ready (shader is compiled)
  15417. */
  15418. isReady(): boolean;
  15419. /**
  15420. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15421. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15422. */
  15423. apply(): Nullable<Effect>;
  15424. private _disposeTextures;
  15425. /**
  15426. * Disposes the post process.
  15427. * @param camera The camera to dispose the post process on.
  15428. */
  15429. dispose(camera?: Camera): void;
  15430. }
  15431. }
  15432. declare module BABYLON {
  15433. /** @hidden */
  15434. export var kernelBlurVaryingDeclaration: {
  15435. name: string;
  15436. shader: string;
  15437. };
  15438. }
  15439. declare module BABYLON {
  15440. /** @hidden */
  15441. export var kernelBlurFragment: {
  15442. name: string;
  15443. shader: string;
  15444. };
  15445. }
  15446. declare module BABYLON {
  15447. /** @hidden */
  15448. export var kernelBlurFragment2: {
  15449. name: string;
  15450. shader: string;
  15451. };
  15452. }
  15453. declare module BABYLON {
  15454. /** @hidden */
  15455. export var kernelBlurPixelShader: {
  15456. name: string;
  15457. shader: string;
  15458. };
  15459. }
  15460. declare module BABYLON {
  15461. /** @hidden */
  15462. export var kernelBlurVertex: {
  15463. name: string;
  15464. shader: string;
  15465. };
  15466. }
  15467. declare module BABYLON {
  15468. /** @hidden */
  15469. export var kernelBlurVertexShader: {
  15470. name: string;
  15471. shader: string;
  15472. };
  15473. }
  15474. declare module BABYLON {
  15475. /**
  15476. * The Blur Post Process which blurs an image based on a kernel and direction.
  15477. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15478. */
  15479. export class BlurPostProcess extends PostProcess {
  15480. /** The direction in which to blur the image. */
  15481. direction: Vector2;
  15482. private blockCompilation;
  15483. protected _kernel: number;
  15484. protected _idealKernel: number;
  15485. protected _packedFloat: boolean;
  15486. private _staticDefines;
  15487. /**
  15488. * Sets the length in pixels of the blur sample region
  15489. */
  15490. /**
  15491. * Gets the length in pixels of the blur sample region
  15492. */
  15493. kernel: number;
  15494. /**
  15495. * Sets wether or not the blur needs to unpack/repack floats
  15496. */
  15497. /**
  15498. * Gets wether or not the blur is unpacking/repacking floats
  15499. */
  15500. packedFloat: boolean;
  15501. /**
  15502. * Creates a new instance BlurPostProcess
  15503. * @param name The name of the effect.
  15504. * @param direction The direction in which to blur the image.
  15505. * @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.
  15506. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15507. * @param camera The camera to apply the render pass to.
  15508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15509. * @param engine The engine which the post process will be applied. (default: current engine)
  15510. * @param reusable If the post process can be reused on the same frame. (default: false)
  15511. * @param textureType Type of textures used when performing the post process. (default: 0)
  15512. * @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)
  15513. */
  15514. constructor(name: string,
  15515. /** The direction in which to blur the image. */
  15516. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15517. /**
  15518. * Updates the effect with the current post process compile time values and recompiles the shader.
  15519. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15520. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15521. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15522. * @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
  15523. * @param onCompiled Called when the shader has been compiled.
  15524. * @param onError Called if there is an error when compiling a shader.
  15525. */
  15526. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15527. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15528. /**
  15529. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15530. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15531. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15532. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15533. * The gaps between physical kernels are compensated for in the weighting of the samples
  15534. * @param idealKernel Ideal blur kernel.
  15535. * @return Nearest best kernel.
  15536. */
  15537. protected _nearestBestKernel(idealKernel: number): number;
  15538. /**
  15539. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15540. * @param x The point on the Gaussian distribution to sample.
  15541. * @return the value of the Gaussian function at x.
  15542. */
  15543. protected _gaussianWeight(x: number): number;
  15544. /**
  15545. * Generates a string that can be used as a floating point number in GLSL.
  15546. * @param x Value to print.
  15547. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15548. * @return GLSL float string.
  15549. */
  15550. protected _glslFloat(x: number, decimalFigures?: number): string;
  15551. }
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15556. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15557. * You can then easily use it as a reflectionTexture on a flat surface.
  15558. * In case the surface is not a plane, please consider relying on reflection probes.
  15559. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15560. */
  15561. export class MirrorTexture extends RenderTargetTexture {
  15562. private scene;
  15563. /**
  15564. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15565. * 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.
  15566. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15567. */
  15568. mirrorPlane: Plane;
  15569. /**
  15570. * Define the blur ratio used to blur the reflection if needed.
  15571. */
  15572. blurRatio: number;
  15573. /**
  15574. * Define the adaptive blur kernel used to blur the reflection if needed.
  15575. * This will autocompute the closest best match for the `blurKernel`
  15576. */
  15577. adaptiveBlurKernel: number;
  15578. /**
  15579. * Define the blur kernel used to blur the reflection if needed.
  15580. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15581. */
  15582. blurKernel: number;
  15583. /**
  15584. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15585. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15586. */
  15587. blurKernelX: number;
  15588. /**
  15589. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15590. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15591. */
  15592. blurKernelY: number;
  15593. private _autoComputeBlurKernel;
  15594. protected _onRatioRescale(): void;
  15595. private _updateGammaSpace;
  15596. private _imageProcessingConfigChangeObserver;
  15597. private _transformMatrix;
  15598. private _mirrorMatrix;
  15599. private _savedViewMatrix;
  15600. private _blurX;
  15601. private _blurY;
  15602. private _adaptiveBlurKernel;
  15603. private _blurKernelX;
  15604. private _blurKernelY;
  15605. private _blurRatio;
  15606. /**
  15607. * Instantiates a Mirror Texture.
  15608. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15609. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15610. * You can then easily use it as a reflectionTexture on a flat surface.
  15611. * In case the surface is not a plane, please consider relying on reflection probes.
  15612. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15613. * @param name
  15614. * @param size
  15615. * @param scene
  15616. * @param generateMipMaps
  15617. * @param type
  15618. * @param samplingMode
  15619. * @param generateDepthBuffer
  15620. */
  15621. constructor(name: string, size: number | {
  15622. width: number;
  15623. height: number;
  15624. } | {
  15625. ratio: number;
  15626. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15627. private _preparePostProcesses;
  15628. /**
  15629. * Clone the mirror texture.
  15630. * @returns the cloned texture
  15631. */
  15632. clone(): MirrorTexture;
  15633. /**
  15634. * Serialize the texture to a JSON representation you could use in Parse later on
  15635. * @returns the serialized JSON representation
  15636. */
  15637. serialize(): any;
  15638. /**
  15639. * Dispose the texture and release its associated resources.
  15640. */
  15641. dispose(): void;
  15642. }
  15643. }
  15644. declare module BABYLON {
  15645. /**
  15646. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15647. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15648. */
  15649. export class Texture extends BaseTexture {
  15650. /**
  15651. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15652. */
  15653. static SerializeBuffers: boolean;
  15654. /** @hidden */
  15655. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15656. /** @hidden */
  15657. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15658. /** @hidden */
  15659. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15660. /** nearest is mag = nearest and min = nearest and mip = linear */
  15661. static readonly NEAREST_SAMPLINGMODE: number;
  15662. /** nearest is mag = nearest and min = nearest and mip = linear */
  15663. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15664. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15665. static readonly BILINEAR_SAMPLINGMODE: number;
  15666. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15667. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15668. /** Trilinear is mag = linear and min = linear and mip = linear */
  15669. static readonly TRILINEAR_SAMPLINGMODE: number;
  15670. /** Trilinear is mag = linear and min = linear and mip = linear */
  15671. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15672. /** mag = nearest and min = nearest and mip = nearest */
  15673. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15674. /** mag = nearest and min = linear and mip = nearest */
  15675. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15676. /** mag = nearest and min = linear and mip = linear */
  15677. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15678. /** mag = nearest and min = linear and mip = none */
  15679. static readonly NEAREST_LINEAR: number;
  15680. /** mag = nearest and min = nearest and mip = none */
  15681. static readonly NEAREST_NEAREST: number;
  15682. /** mag = linear and min = nearest and mip = nearest */
  15683. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15684. /** mag = linear and min = nearest and mip = linear */
  15685. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15686. /** mag = linear and min = linear and mip = none */
  15687. static readonly LINEAR_LINEAR: number;
  15688. /** mag = linear and min = nearest and mip = none */
  15689. static readonly LINEAR_NEAREST: number;
  15690. /** Explicit coordinates mode */
  15691. static readonly EXPLICIT_MODE: number;
  15692. /** Spherical coordinates mode */
  15693. static readonly SPHERICAL_MODE: number;
  15694. /** Planar coordinates mode */
  15695. static readonly PLANAR_MODE: number;
  15696. /** Cubic coordinates mode */
  15697. static readonly CUBIC_MODE: number;
  15698. /** Projection coordinates mode */
  15699. static readonly PROJECTION_MODE: number;
  15700. /** Inverse Cubic coordinates mode */
  15701. static readonly SKYBOX_MODE: number;
  15702. /** Inverse Cubic coordinates mode */
  15703. static readonly INVCUBIC_MODE: number;
  15704. /** Equirectangular coordinates mode */
  15705. static readonly EQUIRECTANGULAR_MODE: number;
  15706. /** Equirectangular Fixed coordinates mode */
  15707. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15708. /** Equirectangular Fixed Mirrored coordinates mode */
  15709. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15710. /** Texture is not repeating outside of 0..1 UVs */
  15711. static readonly CLAMP_ADDRESSMODE: number;
  15712. /** Texture is repeating outside of 0..1 UVs */
  15713. static readonly WRAP_ADDRESSMODE: number;
  15714. /** Texture is repeating and mirrored */
  15715. static readonly MIRROR_ADDRESSMODE: number;
  15716. /**
  15717. * 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
  15718. */
  15719. static UseSerializedUrlIfAny: boolean;
  15720. /**
  15721. * Define the url of the texture.
  15722. */
  15723. url: Nullable<string>;
  15724. /**
  15725. * Define an offset on the texture to offset the u coordinates of the UVs
  15726. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15727. */
  15728. uOffset: number;
  15729. /**
  15730. * Define an offset on the texture to offset the v coordinates of the UVs
  15731. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15732. */
  15733. vOffset: number;
  15734. /**
  15735. * Define an offset on the texture to scale the u coordinates of the UVs
  15736. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15737. */
  15738. uScale: number;
  15739. /**
  15740. * Define an offset on the texture to scale the v coordinates of the UVs
  15741. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15742. */
  15743. vScale: number;
  15744. /**
  15745. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15746. * @see http://doc.babylonjs.com/how_to/more_materials
  15747. */
  15748. uAng: number;
  15749. /**
  15750. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15751. * @see http://doc.babylonjs.com/how_to/more_materials
  15752. */
  15753. vAng: number;
  15754. /**
  15755. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15756. * @see http://doc.babylonjs.com/how_to/more_materials
  15757. */
  15758. wAng: number;
  15759. /**
  15760. * Defines the center of rotation (U)
  15761. */
  15762. uRotationCenter: number;
  15763. /**
  15764. * Defines the center of rotation (V)
  15765. */
  15766. vRotationCenter: number;
  15767. /**
  15768. * Defines the center of rotation (W)
  15769. */
  15770. wRotationCenter: number;
  15771. /**
  15772. * Are mip maps generated for this texture or not.
  15773. */
  15774. readonly noMipmap: boolean;
  15775. /**
  15776. * List of inspectable custom properties (used by the Inspector)
  15777. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15778. */
  15779. inspectableCustomProperties: Nullable<IInspectable[]>;
  15780. private _noMipmap;
  15781. /** @hidden */
  15782. _invertY: boolean;
  15783. private _rowGenerationMatrix;
  15784. private _cachedTextureMatrix;
  15785. private _projectionModeMatrix;
  15786. private _t0;
  15787. private _t1;
  15788. private _t2;
  15789. private _cachedUOffset;
  15790. private _cachedVOffset;
  15791. private _cachedUScale;
  15792. private _cachedVScale;
  15793. private _cachedUAng;
  15794. private _cachedVAng;
  15795. private _cachedWAng;
  15796. private _cachedProjectionMatrixId;
  15797. private _cachedCoordinatesMode;
  15798. /** @hidden */
  15799. protected _initialSamplingMode: number;
  15800. /** @hidden */
  15801. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15802. private _deleteBuffer;
  15803. protected _format: Nullable<number>;
  15804. private _delayedOnLoad;
  15805. private _delayedOnError;
  15806. private _mimeType?;
  15807. /**
  15808. * Observable triggered once the texture has been loaded.
  15809. */
  15810. onLoadObservable: Observable<Texture>;
  15811. protected _isBlocking: boolean;
  15812. /**
  15813. * Is the texture preventing material to render while loading.
  15814. * If false, a default texture will be used instead of the loading one during the preparation step.
  15815. */
  15816. isBlocking: boolean;
  15817. /**
  15818. * Get the current sampling mode associated with the texture.
  15819. */
  15820. readonly samplingMode: number;
  15821. /**
  15822. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15823. */
  15824. readonly invertY: boolean;
  15825. /**
  15826. * Instantiates a new texture.
  15827. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15828. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15829. * @param url defines the url of the picture to load as a texture
  15830. * @param scene defines the scene or engine the texture will belong to
  15831. * @param noMipmap defines if the texture will require mip maps or not
  15832. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15833. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15834. * @param onLoad defines a callback triggered when the texture has been loaded
  15835. * @param onError defines a callback triggered when an error occurred during the loading session
  15836. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15837. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15838. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15839. * @param mimeType defines an optional mime type information
  15840. */
  15841. 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);
  15842. /**
  15843. * Update the url (and optional buffer) of this texture if url was null during construction.
  15844. * @param url the url of the texture
  15845. * @param buffer the buffer of the texture (defaults to null)
  15846. * @param onLoad callback called when the texture is loaded (defaults to null)
  15847. */
  15848. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15849. /**
  15850. * Finish the loading sequence of a texture flagged as delayed load.
  15851. * @hidden
  15852. */
  15853. delayLoad(): void;
  15854. private _prepareRowForTextureGeneration;
  15855. /**
  15856. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15857. * @returns the transform matrix of the texture.
  15858. */
  15859. getTextureMatrix(): Matrix;
  15860. /**
  15861. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15862. * @returns The reflection texture transform
  15863. */
  15864. getReflectionTextureMatrix(): Matrix;
  15865. /**
  15866. * Clones the texture.
  15867. * @returns the cloned texture
  15868. */
  15869. clone(): Texture;
  15870. /**
  15871. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15872. * @returns The JSON representation of the texture
  15873. */
  15874. serialize(): any;
  15875. /**
  15876. * Get the current class name of the texture useful for serialization or dynamic coding.
  15877. * @returns "Texture"
  15878. */
  15879. getClassName(): string;
  15880. /**
  15881. * Dispose the texture and release its associated resources.
  15882. */
  15883. dispose(): void;
  15884. /**
  15885. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15886. * @param parsedTexture Define the JSON representation of the texture
  15887. * @param scene Define the scene the parsed texture should be instantiated in
  15888. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15889. * @returns The parsed texture if successful
  15890. */
  15891. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15892. /**
  15893. * Creates a texture from its base 64 representation.
  15894. * @param data Define the base64 payload without the data: prefix
  15895. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15896. * @param scene Define the scene the texture should belong to
  15897. * @param noMipmap Forces the texture to not create mip map information if true
  15898. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15899. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15900. * @param onLoad define a callback triggered when the texture has been loaded
  15901. * @param onError define a callback triggered when an error occurred during the loading session
  15902. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15903. * @returns the created texture
  15904. */
  15905. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15906. /**
  15907. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15908. * @param data Define the base64 payload without the data: prefix
  15909. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15910. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15911. * @param scene Define the scene the texture should belong to
  15912. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15913. * @param noMipmap Forces the texture to not create mip map information if true
  15914. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15915. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15916. * @param onLoad define a callback triggered when the texture has been loaded
  15917. * @param onError define a callback triggered when an error occurred during the loading session
  15918. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15919. * @returns the created texture
  15920. */
  15921. 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;
  15922. }
  15923. }
  15924. declare module BABYLON {
  15925. /**
  15926. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15927. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15928. */
  15929. export class PostProcessManager {
  15930. private _scene;
  15931. private _indexBuffer;
  15932. private _vertexBuffers;
  15933. /**
  15934. * Creates a new instance PostProcess
  15935. * @param scene The scene that the post process is associated with.
  15936. */
  15937. constructor(scene: Scene);
  15938. private _prepareBuffers;
  15939. private _buildIndexBuffer;
  15940. /**
  15941. * Rebuilds the vertex buffers of the manager.
  15942. * @hidden
  15943. */
  15944. _rebuild(): void;
  15945. /**
  15946. * Prepares a frame to be run through a post process.
  15947. * @param sourceTexture The input texture to the post procesess. (default: null)
  15948. * @param postProcesses An array of post processes to be run. (default: null)
  15949. * @returns True if the post processes were able to be run.
  15950. * @hidden
  15951. */
  15952. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15953. /**
  15954. * Manually render a set of post processes to a texture.
  15955. * @param postProcesses An array of post processes to be run.
  15956. * @param targetTexture The target texture to render to.
  15957. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15958. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15959. * @param lodLevel defines which lod of the texture to render to
  15960. */
  15961. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15962. /**
  15963. * Finalize the result of the output of the postprocesses.
  15964. * @param doNotPresent If true the result will not be displayed to the screen.
  15965. * @param targetTexture The target texture to render to.
  15966. * @param faceIndex The index of the face to bind the target texture to.
  15967. * @param postProcesses The array of post processes to render.
  15968. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15969. * @hidden
  15970. */
  15971. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15972. /**
  15973. * Disposes of the post process manager.
  15974. */
  15975. dispose(): void;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /** Interface used by value gradients (color, factor, ...) */
  15980. export interface IValueGradient {
  15981. /**
  15982. * Gets or sets the gradient value (between 0 and 1)
  15983. */
  15984. gradient: number;
  15985. }
  15986. /** Class used to store color4 gradient */
  15987. export class ColorGradient implements IValueGradient {
  15988. /**
  15989. * Gets or sets the gradient value (between 0 and 1)
  15990. */
  15991. gradient: number;
  15992. /**
  15993. * Gets or sets first associated color
  15994. */
  15995. color1: Color4;
  15996. /**
  15997. * Gets or sets second associated color
  15998. */
  15999. color2?: Color4;
  16000. /**
  16001. * Will get a color picked randomly between color1 and color2.
  16002. * If color2 is undefined then color1 will be used
  16003. * @param result defines the target Color4 to store the result in
  16004. */
  16005. getColorToRef(result: Color4): void;
  16006. }
  16007. /** Class used to store color 3 gradient */
  16008. export class Color3Gradient implements IValueGradient {
  16009. /**
  16010. * Gets or sets the gradient value (between 0 and 1)
  16011. */
  16012. gradient: number;
  16013. /**
  16014. * Gets or sets the associated color
  16015. */
  16016. color: Color3;
  16017. }
  16018. /** Class used to store factor gradient */
  16019. export class FactorGradient implements IValueGradient {
  16020. /**
  16021. * Gets or sets the gradient value (between 0 and 1)
  16022. */
  16023. gradient: number;
  16024. /**
  16025. * Gets or sets first associated factor
  16026. */
  16027. factor1: number;
  16028. /**
  16029. * Gets or sets second associated factor
  16030. */
  16031. factor2?: number;
  16032. /**
  16033. * Will get a number picked randomly between factor1 and factor2.
  16034. * If factor2 is undefined then factor1 will be used
  16035. * @returns the picked number
  16036. */
  16037. getFactor(): number;
  16038. }
  16039. /**
  16040. * Helper used to simplify some generic gradient tasks
  16041. */
  16042. export class GradientHelper {
  16043. /**
  16044. * Gets the current gradient from an array of IValueGradient
  16045. * @param ratio defines the current ratio to get
  16046. * @param gradients defines the array of IValueGradient
  16047. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16048. */
  16049. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16050. }
  16051. }
  16052. declare module BABYLON {
  16053. interface ThinEngine {
  16054. /**
  16055. * Creates a dynamic texture
  16056. * @param width defines the width of the texture
  16057. * @param height defines the height of the texture
  16058. * @param generateMipMaps defines if the engine should generate the mip levels
  16059. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16060. * @returns the dynamic texture inside an InternalTexture
  16061. */
  16062. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16063. /**
  16064. * Update the content of a dynamic texture
  16065. * @param texture defines the texture to update
  16066. * @param canvas defines the canvas containing the source
  16067. * @param invertY defines if data must be stored with Y axis inverted
  16068. * @param premulAlpha defines if alpha is stored as premultiplied
  16069. * @param format defines the format of the data
  16070. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16071. */
  16072. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16073. }
  16074. }
  16075. declare module BABYLON {
  16076. /**
  16077. * Helper class used to generate a canvas to manipulate images
  16078. */
  16079. export class CanvasGenerator {
  16080. /**
  16081. * Create a new canvas (or offscreen canvas depending on the context)
  16082. * @param width defines the expected width
  16083. * @param height defines the expected height
  16084. * @return a new canvas or offscreen canvas
  16085. */
  16086. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16087. }
  16088. }
  16089. declare module BABYLON {
  16090. /**
  16091. * A class extending Texture allowing drawing on a texture
  16092. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16093. */
  16094. export class DynamicTexture extends Texture {
  16095. private _generateMipMaps;
  16096. private _canvas;
  16097. private _context;
  16098. private _engine;
  16099. /**
  16100. * Creates a DynamicTexture
  16101. * @param name defines the name of the texture
  16102. * @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
  16103. * @param scene defines the scene where you want the texture
  16104. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16105. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16106. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16107. */
  16108. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16109. /**
  16110. * Get the current class name of the texture useful for serialization or dynamic coding.
  16111. * @returns "DynamicTexture"
  16112. */
  16113. getClassName(): string;
  16114. /**
  16115. * Gets the current state of canRescale
  16116. */
  16117. readonly canRescale: boolean;
  16118. private _recreate;
  16119. /**
  16120. * Scales the texture
  16121. * @param ratio the scale factor to apply to both width and height
  16122. */
  16123. scale(ratio: number): void;
  16124. /**
  16125. * Resizes the texture
  16126. * @param width the new width
  16127. * @param height the new height
  16128. */
  16129. scaleTo(width: number, height: number): void;
  16130. /**
  16131. * Gets the context of the canvas used by the texture
  16132. * @returns the canvas context of the dynamic texture
  16133. */
  16134. getContext(): CanvasRenderingContext2D;
  16135. /**
  16136. * Clears the texture
  16137. */
  16138. clear(): void;
  16139. /**
  16140. * Updates the texture
  16141. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16142. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16143. */
  16144. update(invertY?: boolean, premulAlpha?: boolean): void;
  16145. /**
  16146. * Draws text onto the texture
  16147. * @param text defines the text to be drawn
  16148. * @param x defines the placement of the text from the left
  16149. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16150. * @param font defines the font to be used with font-style, font-size, font-name
  16151. * @param color defines the color used for the text
  16152. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16153. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16154. * @param update defines whether texture is immediately update (default is true)
  16155. */
  16156. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16157. /**
  16158. * Clones the texture
  16159. * @returns the clone of the texture.
  16160. */
  16161. clone(): DynamicTexture;
  16162. /**
  16163. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16164. * @returns a serialized dynamic texture object
  16165. */
  16166. serialize(): any;
  16167. /** @hidden */
  16168. _rebuild(): void;
  16169. }
  16170. }
  16171. declare module BABYLON {
  16172. interface AbstractScene {
  16173. /**
  16174. * The list of procedural textures added to the scene
  16175. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16176. */
  16177. proceduralTextures: Array<ProceduralTexture>;
  16178. }
  16179. /**
  16180. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16181. * in a given scene.
  16182. */
  16183. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16184. /**
  16185. * The component name helpfull to identify the component in the list of scene components.
  16186. */
  16187. readonly name: string;
  16188. /**
  16189. * The scene the component belongs to.
  16190. */
  16191. scene: Scene;
  16192. /**
  16193. * Creates a new instance of the component for the given scene
  16194. * @param scene Defines the scene to register the component in
  16195. */
  16196. constructor(scene: Scene);
  16197. /**
  16198. * Registers the component in a given scene
  16199. */
  16200. register(): void;
  16201. /**
  16202. * Rebuilds the elements related to this component in case of
  16203. * context lost for instance.
  16204. */
  16205. rebuild(): void;
  16206. /**
  16207. * Disposes the component and the associated ressources.
  16208. */
  16209. dispose(): void;
  16210. private _beforeClear;
  16211. }
  16212. }
  16213. declare module BABYLON {
  16214. interface ThinEngine {
  16215. /**
  16216. * Creates a new render target cube texture
  16217. * @param size defines the size of the texture
  16218. * @param options defines the options used to create the texture
  16219. * @returns a new render target cube texture stored in an InternalTexture
  16220. */
  16221. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16222. }
  16223. }
  16224. declare module BABYLON {
  16225. /** @hidden */
  16226. export var proceduralVertexShader: {
  16227. name: string;
  16228. shader: string;
  16229. };
  16230. }
  16231. declare module BABYLON {
  16232. /**
  16233. * 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.
  16234. * This is the base class of any Procedural texture and contains most of the shareable code.
  16235. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16236. */
  16237. export class ProceduralTexture extends Texture {
  16238. isCube: boolean;
  16239. /**
  16240. * Define if the texture is enabled or not (disabled texture will not render)
  16241. */
  16242. isEnabled: boolean;
  16243. /**
  16244. * Define if the texture must be cleared before rendering (default is true)
  16245. */
  16246. autoClear: boolean;
  16247. /**
  16248. * Callback called when the texture is generated
  16249. */
  16250. onGenerated: () => void;
  16251. /**
  16252. * Event raised when the texture is generated
  16253. */
  16254. onGeneratedObservable: Observable<ProceduralTexture>;
  16255. /** @hidden */
  16256. _generateMipMaps: boolean;
  16257. /** @hidden **/
  16258. _effect: Effect;
  16259. /** @hidden */
  16260. _textures: {
  16261. [key: string]: Texture;
  16262. };
  16263. private _size;
  16264. private _currentRefreshId;
  16265. private _refreshRate;
  16266. private _vertexBuffers;
  16267. private _indexBuffer;
  16268. private _uniforms;
  16269. private _samplers;
  16270. private _fragment;
  16271. private _floats;
  16272. private _ints;
  16273. private _floatsArrays;
  16274. private _colors3;
  16275. private _colors4;
  16276. private _vectors2;
  16277. private _vectors3;
  16278. private _matrices;
  16279. private _fallbackTexture;
  16280. private _fallbackTextureUsed;
  16281. private _engine;
  16282. private _cachedDefines;
  16283. private _contentUpdateId;
  16284. private _contentData;
  16285. /**
  16286. * Instantiates a new procedural texture.
  16287. * 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.
  16288. * This is the base class of any Procedural texture and contains most of the shareable code.
  16289. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16290. * @param name Define the name of the texture
  16291. * @param size Define the size of the texture to create
  16292. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16293. * @param scene Define the scene the texture belongs to
  16294. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16295. * @param generateMipMaps Define if the texture should creates mip maps or not
  16296. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16297. */
  16298. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16299. /**
  16300. * The effect that is created when initializing the post process.
  16301. * @returns The created effect corresponding the the postprocess.
  16302. */
  16303. getEffect(): Effect;
  16304. /**
  16305. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16306. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16307. */
  16308. getContent(): Nullable<ArrayBufferView>;
  16309. private _createIndexBuffer;
  16310. /** @hidden */
  16311. _rebuild(): void;
  16312. /**
  16313. * Resets the texture in order to recreate its associated resources.
  16314. * This can be called in case of context loss
  16315. */
  16316. reset(): void;
  16317. protected _getDefines(): string;
  16318. /**
  16319. * Is the texture ready to be used ? (rendered at least once)
  16320. * @returns true if ready, otherwise, false.
  16321. */
  16322. isReady(): boolean;
  16323. /**
  16324. * Resets the refresh counter of the texture and start bak from scratch.
  16325. * Could be useful to regenerate the texture if it is setup to render only once.
  16326. */
  16327. resetRefreshCounter(): void;
  16328. /**
  16329. * Set the fragment shader to use in order to render the texture.
  16330. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16331. */
  16332. setFragment(fragment: any): void;
  16333. /**
  16334. * Define the refresh rate of the texture or the rendering frequency.
  16335. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16336. */
  16337. refreshRate: number;
  16338. /** @hidden */
  16339. _shouldRender(): boolean;
  16340. /**
  16341. * Get the size the texture is rendering at.
  16342. * @returns the size (texture is always squared)
  16343. */
  16344. getRenderSize(): number;
  16345. /**
  16346. * Resize the texture to new value.
  16347. * @param size Define the new size the texture should have
  16348. * @param generateMipMaps Define whether the new texture should create mip maps
  16349. */
  16350. resize(size: number, generateMipMaps: boolean): void;
  16351. private _checkUniform;
  16352. /**
  16353. * Set a texture in the shader program used to render.
  16354. * @param name Define the name of the uniform samplers as defined in the shader
  16355. * @param texture Define the texture to bind to this sampler
  16356. * @return the texture itself allowing "fluent" like uniform updates
  16357. */
  16358. setTexture(name: string, texture: Texture): ProceduralTexture;
  16359. /**
  16360. * Set a float in the shader.
  16361. * @param name Define the name of the uniform as defined in the shader
  16362. * @param value Define the value to give to the uniform
  16363. * @return the texture itself allowing "fluent" like uniform updates
  16364. */
  16365. setFloat(name: string, value: number): ProceduralTexture;
  16366. /**
  16367. * Set a int in the shader.
  16368. * @param name Define the name of the uniform as defined in the shader
  16369. * @param value Define the value to give to the uniform
  16370. * @return the texture itself allowing "fluent" like uniform updates
  16371. */
  16372. setInt(name: string, value: number): ProceduralTexture;
  16373. /**
  16374. * Set an array of floats in the shader.
  16375. * @param name Define the name of the uniform as defined in the shader
  16376. * @param value Define the value to give to the uniform
  16377. * @return the texture itself allowing "fluent" like uniform updates
  16378. */
  16379. setFloats(name: string, value: number[]): ProceduralTexture;
  16380. /**
  16381. * Set a vec3 in the shader from a Color3.
  16382. * @param name Define the name of the uniform as defined in the shader
  16383. * @param value Define the value to give to the uniform
  16384. * @return the texture itself allowing "fluent" like uniform updates
  16385. */
  16386. setColor3(name: string, value: Color3): ProceduralTexture;
  16387. /**
  16388. * Set a vec4 in the shader from a Color4.
  16389. * @param name Define the name of the uniform as defined in the shader
  16390. * @param value Define the value to give to the uniform
  16391. * @return the texture itself allowing "fluent" like uniform updates
  16392. */
  16393. setColor4(name: string, value: Color4): ProceduralTexture;
  16394. /**
  16395. * Set a vec2 in the shader from a Vector2.
  16396. * @param name Define the name of the uniform as defined in the shader
  16397. * @param value Define the value to give to the uniform
  16398. * @return the texture itself allowing "fluent" like uniform updates
  16399. */
  16400. setVector2(name: string, value: Vector2): ProceduralTexture;
  16401. /**
  16402. * Set a vec3 in the shader from a Vector3.
  16403. * @param name Define the name of the uniform as defined in the shader
  16404. * @param value Define the value to give to the uniform
  16405. * @return the texture itself allowing "fluent" like uniform updates
  16406. */
  16407. setVector3(name: string, value: Vector3): ProceduralTexture;
  16408. /**
  16409. * Set a mat4 in the shader from a MAtrix.
  16410. * @param name Define the name of the uniform as defined in the shader
  16411. * @param value Define the value to give to the uniform
  16412. * @return the texture itself allowing "fluent" like uniform updates
  16413. */
  16414. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16415. /**
  16416. * Render the texture to its associated render target.
  16417. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16418. */
  16419. render(useCameraPostProcess?: boolean): void;
  16420. /**
  16421. * Clone the texture.
  16422. * @returns the cloned texture
  16423. */
  16424. clone(): ProceduralTexture;
  16425. /**
  16426. * Dispose the texture and release its asoociated resources.
  16427. */
  16428. dispose(): void;
  16429. }
  16430. }
  16431. declare module BABYLON {
  16432. /**
  16433. * This represents the base class for particle system in Babylon.
  16434. * 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.
  16435. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16436. * @example https://doc.babylonjs.com/babylon101/particles
  16437. */
  16438. export class BaseParticleSystem {
  16439. /**
  16440. * Source color is added to the destination color without alpha affecting the result
  16441. */
  16442. static BLENDMODE_ONEONE: number;
  16443. /**
  16444. * Blend current color and particle color using particle’s alpha
  16445. */
  16446. static BLENDMODE_STANDARD: number;
  16447. /**
  16448. * Add current color and particle color multiplied by particle’s alpha
  16449. */
  16450. static BLENDMODE_ADD: number;
  16451. /**
  16452. * Multiply current color with particle color
  16453. */
  16454. static BLENDMODE_MULTIPLY: number;
  16455. /**
  16456. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16457. */
  16458. static BLENDMODE_MULTIPLYADD: number;
  16459. /**
  16460. * List of animations used by the particle system.
  16461. */
  16462. animations: Animation[];
  16463. /**
  16464. * The id of the Particle system.
  16465. */
  16466. id: string;
  16467. /**
  16468. * The friendly name of the Particle system.
  16469. */
  16470. name: string;
  16471. /**
  16472. * The rendering group used by the Particle system to chose when to render.
  16473. */
  16474. renderingGroupId: number;
  16475. /**
  16476. * The emitter represents the Mesh or position we are attaching the particle system to.
  16477. */
  16478. emitter: Nullable<AbstractMesh | Vector3>;
  16479. /**
  16480. * The maximum number of particles to emit per frame
  16481. */
  16482. emitRate: number;
  16483. /**
  16484. * If you want to launch only a few particles at once, that can be done, as well.
  16485. */
  16486. manualEmitCount: number;
  16487. /**
  16488. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16489. */
  16490. updateSpeed: number;
  16491. /**
  16492. * The amount of time the particle system is running (depends of the overall update speed).
  16493. */
  16494. targetStopDuration: number;
  16495. /**
  16496. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16497. */
  16498. disposeOnStop: boolean;
  16499. /**
  16500. * Minimum power of emitting particles.
  16501. */
  16502. minEmitPower: number;
  16503. /**
  16504. * Maximum power of emitting particles.
  16505. */
  16506. maxEmitPower: number;
  16507. /**
  16508. * Minimum life time of emitting particles.
  16509. */
  16510. minLifeTime: number;
  16511. /**
  16512. * Maximum life time of emitting particles.
  16513. */
  16514. maxLifeTime: number;
  16515. /**
  16516. * Minimum Size of emitting particles.
  16517. */
  16518. minSize: number;
  16519. /**
  16520. * Maximum Size of emitting particles.
  16521. */
  16522. maxSize: number;
  16523. /**
  16524. * Minimum scale of emitting particles on X axis.
  16525. */
  16526. minScaleX: number;
  16527. /**
  16528. * Maximum scale of emitting particles on X axis.
  16529. */
  16530. maxScaleX: number;
  16531. /**
  16532. * Minimum scale of emitting particles on Y axis.
  16533. */
  16534. minScaleY: number;
  16535. /**
  16536. * Maximum scale of emitting particles on Y axis.
  16537. */
  16538. maxScaleY: number;
  16539. /**
  16540. * Gets or sets the minimal initial rotation in radians.
  16541. */
  16542. minInitialRotation: number;
  16543. /**
  16544. * Gets or sets the maximal initial rotation in radians.
  16545. */
  16546. maxInitialRotation: number;
  16547. /**
  16548. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16549. */
  16550. minAngularSpeed: number;
  16551. /**
  16552. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16553. */
  16554. maxAngularSpeed: number;
  16555. /**
  16556. * The texture used to render each particle. (this can be a spritesheet)
  16557. */
  16558. particleTexture: Nullable<Texture>;
  16559. /**
  16560. * The layer mask we are rendering the particles through.
  16561. */
  16562. layerMask: number;
  16563. /**
  16564. * This can help using your own shader to render the particle system.
  16565. * The according effect will be created
  16566. */
  16567. customShader: any;
  16568. /**
  16569. * By default particle system starts as soon as they are created. This prevents the
  16570. * automatic start to happen and let you decide when to start emitting particles.
  16571. */
  16572. preventAutoStart: boolean;
  16573. private _noiseTexture;
  16574. /**
  16575. * Gets or sets a texture used to add random noise to particle positions
  16576. */
  16577. noiseTexture: Nullable<ProceduralTexture>;
  16578. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16579. noiseStrength: Vector3;
  16580. /**
  16581. * Callback triggered when the particle animation is ending.
  16582. */
  16583. onAnimationEnd: Nullable<() => void>;
  16584. /**
  16585. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16586. */
  16587. blendMode: number;
  16588. /**
  16589. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16590. * to override the particles.
  16591. */
  16592. forceDepthWrite: boolean;
  16593. /** 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 */
  16594. preWarmCycles: number;
  16595. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16596. preWarmStepOffset: number;
  16597. /**
  16598. * 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)
  16599. */
  16600. spriteCellChangeSpeed: number;
  16601. /**
  16602. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16603. */
  16604. startSpriteCellID: number;
  16605. /**
  16606. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16607. */
  16608. endSpriteCellID: number;
  16609. /**
  16610. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16611. */
  16612. spriteCellWidth: number;
  16613. /**
  16614. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16615. */
  16616. spriteCellHeight: number;
  16617. /**
  16618. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16619. */
  16620. spriteRandomStartCell: boolean;
  16621. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16622. translationPivot: Vector2;
  16623. /** @hidden */
  16624. protected _isAnimationSheetEnabled: boolean;
  16625. /**
  16626. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16627. */
  16628. beginAnimationOnStart: boolean;
  16629. /**
  16630. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16631. */
  16632. beginAnimationFrom: number;
  16633. /**
  16634. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16635. */
  16636. beginAnimationTo: number;
  16637. /**
  16638. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16639. */
  16640. beginAnimationLoop: boolean;
  16641. /**
  16642. * Gets or sets a world offset applied to all particles
  16643. */
  16644. worldOffset: Vector3;
  16645. /**
  16646. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16647. */
  16648. isAnimationSheetEnabled: boolean;
  16649. /**
  16650. * Get hosting scene
  16651. * @returns the scene
  16652. */
  16653. getScene(): Scene;
  16654. /**
  16655. * You can use gravity if you want to give an orientation to your particles.
  16656. */
  16657. gravity: Vector3;
  16658. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16659. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16660. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16661. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16662. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16663. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16664. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16665. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16666. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16667. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16668. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16669. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16670. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16671. /**
  16672. * Defines the delay in milliseconds before starting the system (0 by default)
  16673. */
  16674. startDelay: number;
  16675. /**
  16676. * Gets the current list of drag gradients.
  16677. * You must use addDragGradient and removeDragGradient to udpate this list
  16678. * @returns the list of drag gradients
  16679. */
  16680. getDragGradients(): Nullable<Array<FactorGradient>>;
  16681. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16682. limitVelocityDamping: number;
  16683. /**
  16684. * Gets the current list of limit velocity gradients.
  16685. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16686. * @returns the list of limit velocity gradients
  16687. */
  16688. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16689. /**
  16690. * Gets the current list of color gradients.
  16691. * You must use addColorGradient and removeColorGradient to udpate this list
  16692. * @returns the list of color gradients
  16693. */
  16694. getColorGradients(): Nullable<Array<ColorGradient>>;
  16695. /**
  16696. * Gets the current list of size gradients.
  16697. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16698. * @returns the list of size gradients
  16699. */
  16700. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16701. /**
  16702. * Gets the current list of color remap gradients.
  16703. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16704. * @returns the list of color remap gradients
  16705. */
  16706. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16707. /**
  16708. * Gets the current list of alpha remap gradients.
  16709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16710. * @returns the list of alpha remap gradients
  16711. */
  16712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16713. /**
  16714. * Gets the current list of life time gradients.
  16715. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16716. * @returns the list of life time gradients
  16717. */
  16718. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16719. /**
  16720. * Gets the current list of angular speed gradients.
  16721. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16722. * @returns the list of angular speed gradients
  16723. */
  16724. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16725. /**
  16726. * Gets the current list of velocity gradients.
  16727. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16728. * @returns the list of velocity gradients
  16729. */
  16730. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16731. /**
  16732. * Gets the current list of start size gradients.
  16733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16734. * @returns the list of start size gradients
  16735. */
  16736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16737. /**
  16738. * Gets the current list of emit rate gradients.
  16739. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16740. * @returns the list of emit rate gradients
  16741. */
  16742. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16743. /**
  16744. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16745. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16746. */
  16747. direction1: Vector3;
  16748. /**
  16749. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16750. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16751. */
  16752. direction2: Vector3;
  16753. /**
  16754. * 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.
  16755. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16756. */
  16757. minEmitBox: Vector3;
  16758. /**
  16759. * 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.
  16760. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16761. */
  16762. maxEmitBox: Vector3;
  16763. /**
  16764. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16765. */
  16766. color1: Color4;
  16767. /**
  16768. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16769. */
  16770. color2: Color4;
  16771. /**
  16772. * Color the particle will have at the end of its lifetime
  16773. */
  16774. colorDead: Color4;
  16775. /**
  16776. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16777. */
  16778. textureMask: Color4;
  16779. /**
  16780. * The particle emitter type defines the emitter used by the particle system.
  16781. * It can be for example box, sphere, or cone...
  16782. */
  16783. particleEmitterType: IParticleEmitterType;
  16784. /** @hidden */
  16785. _isSubEmitter: boolean;
  16786. /**
  16787. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16788. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16789. */
  16790. billboardMode: number;
  16791. protected _isBillboardBased: boolean;
  16792. /**
  16793. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16794. */
  16795. isBillboardBased: boolean;
  16796. /**
  16797. * The scene the particle system belongs to.
  16798. */
  16799. protected _scene: Scene;
  16800. /**
  16801. * Local cache of defines for image processing.
  16802. */
  16803. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16804. /**
  16805. * Default configuration related to image processing available in the standard Material.
  16806. */
  16807. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16808. /**
  16809. * Gets the image processing configuration used either in this material.
  16810. */
  16811. /**
  16812. * Sets the Default image processing configuration used either in the this material.
  16813. *
  16814. * If sets to null, the scene one is in use.
  16815. */
  16816. imageProcessingConfiguration: ImageProcessingConfiguration;
  16817. /**
  16818. * Attaches a new image processing configuration to the Standard Material.
  16819. * @param configuration
  16820. */
  16821. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16822. /** @hidden */
  16823. protected _reset(): void;
  16824. /** @hidden */
  16825. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16826. /**
  16827. * Instantiates a particle system.
  16828. * 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.
  16829. * @param name The name of the particle system
  16830. */
  16831. constructor(name: string);
  16832. /**
  16833. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16836. * @returns the emitter
  16837. */
  16838. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16839. /**
  16840. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16841. * @param radius The radius of the hemisphere to emit from
  16842. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16843. * @returns the emitter
  16844. */
  16845. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16846. /**
  16847. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16848. * @param radius The radius of the sphere to emit from
  16849. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16850. * @returns the emitter
  16851. */
  16852. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16853. /**
  16854. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16855. * @param radius The radius of the sphere to emit from
  16856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16858. * @returns the emitter
  16859. */
  16860. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16861. /**
  16862. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16863. * @param radius The radius of the emission cylinder
  16864. * @param height The height of the emission cylinder
  16865. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16866. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16867. * @returns the emitter
  16868. */
  16869. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16870. /**
  16871. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16872. * @param radius The radius of the cylinder to emit from
  16873. * @param height The height of the emission cylinder
  16874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16877. * @returns the emitter
  16878. */
  16879. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16880. /**
  16881. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16882. * @param radius The radius of the cone to emit from
  16883. * @param angle The base angle of the cone
  16884. * @returns the emitter
  16885. */
  16886. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16887. /**
  16888. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16889. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16890. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16891. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16892. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16893. * @returns the emitter
  16894. */
  16895. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16896. }
  16897. }
  16898. declare module BABYLON {
  16899. /**
  16900. * Type of sub emitter
  16901. */
  16902. export enum SubEmitterType {
  16903. /**
  16904. * Attached to the particle over it's lifetime
  16905. */
  16906. ATTACHED = 0,
  16907. /**
  16908. * Created when the particle dies
  16909. */
  16910. END = 1
  16911. }
  16912. /**
  16913. * Sub emitter class used to emit particles from an existing particle
  16914. */
  16915. export class SubEmitter {
  16916. /**
  16917. * the particle system to be used by the sub emitter
  16918. */
  16919. particleSystem: ParticleSystem;
  16920. /**
  16921. * Type of the submitter (Default: END)
  16922. */
  16923. type: SubEmitterType;
  16924. /**
  16925. * 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)
  16926. * Note: This only is supported when using an emitter of type Mesh
  16927. */
  16928. inheritDirection: boolean;
  16929. /**
  16930. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16931. */
  16932. inheritedVelocityAmount: number;
  16933. /**
  16934. * Creates a sub emitter
  16935. * @param particleSystem the particle system to be used by the sub emitter
  16936. */
  16937. constructor(
  16938. /**
  16939. * the particle system to be used by the sub emitter
  16940. */
  16941. particleSystem: ParticleSystem);
  16942. /**
  16943. * Clones the sub emitter
  16944. * @returns the cloned sub emitter
  16945. */
  16946. clone(): SubEmitter;
  16947. /**
  16948. * Serialize current object to a JSON object
  16949. * @returns the serialized object
  16950. */
  16951. serialize(): any;
  16952. /** @hidden */
  16953. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16954. /**
  16955. * Creates a new SubEmitter from a serialized JSON version
  16956. * @param serializationObject defines the JSON object to read from
  16957. * @param scene defines the hosting scene
  16958. * @param rootUrl defines the rootUrl for data loading
  16959. * @returns a new SubEmitter
  16960. */
  16961. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16962. /** Release associated resources */
  16963. dispose(): void;
  16964. }
  16965. }
  16966. declare module BABYLON {
  16967. /** @hidden */
  16968. export var clipPlaneFragmentDeclaration: {
  16969. name: string;
  16970. shader: string;
  16971. };
  16972. }
  16973. declare module BABYLON {
  16974. /** @hidden */
  16975. export var imageProcessingDeclaration: {
  16976. name: string;
  16977. shader: string;
  16978. };
  16979. }
  16980. declare module BABYLON {
  16981. /** @hidden */
  16982. export var imageProcessingFunctions: {
  16983. name: string;
  16984. shader: string;
  16985. };
  16986. }
  16987. declare module BABYLON {
  16988. /** @hidden */
  16989. export var clipPlaneFragment: {
  16990. name: string;
  16991. shader: string;
  16992. };
  16993. }
  16994. declare module BABYLON {
  16995. /** @hidden */
  16996. export var particlesPixelShader: {
  16997. name: string;
  16998. shader: string;
  16999. };
  17000. }
  17001. declare module BABYLON {
  17002. /** @hidden */
  17003. export var clipPlaneVertexDeclaration: {
  17004. name: string;
  17005. shader: string;
  17006. };
  17007. }
  17008. declare module BABYLON {
  17009. /** @hidden */
  17010. export var clipPlaneVertex: {
  17011. name: string;
  17012. shader: string;
  17013. };
  17014. }
  17015. declare module BABYLON {
  17016. /** @hidden */
  17017. export var particlesVertexShader: {
  17018. name: string;
  17019. shader: string;
  17020. };
  17021. }
  17022. declare module BABYLON {
  17023. /**
  17024. * This represents a particle system in Babylon.
  17025. * 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.
  17026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17027. * @example https://doc.babylonjs.com/babylon101/particles
  17028. */
  17029. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17030. /**
  17031. * Billboard mode will only apply to Y axis
  17032. */
  17033. static readonly BILLBOARDMODE_Y: number;
  17034. /**
  17035. * Billboard mode will apply to all axes
  17036. */
  17037. static readonly BILLBOARDMODE_ALL: number;
  17038. /**
  17039. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17040. */
  17041. static readonly BILLBOARDMODE_STRETCHED: number;
  17042. /**
  17043. * This function can be defined to provide custom update for active particles.
  17044. * This function will be called instead of regular update (age, position, color, etc.).
  17045. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17046. */
  17047. updateFunction: (particles: Particle[]) => void;
  17048. private _emitterWorldMatrix;
  17049. /**
  17050. * This function can be defined to specify initial direction for every new particle.
  17051. * It by default use the emitterType defined function
  17052. */
  17053. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17054. /**
  17055. * This function can be defined to specify initial position for every new particle.
  17056. * It by default use the emitterType defined function
  17057. */
  17058. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17059. /**
  17060. * @hidden
  17061. */
  17062. _inheritedVelocityOffset: Vector3;
  17063. /**
  17064. * An event triggered when the system is disposed
  17065. */
  17066. onDisposeObservable: Observable<ParticleSystem>;
  17067. private _onDisposeObserver;
  17068. /**
  17069. * Sets a callback that will be triggered when the system is disposed
  17070. */
  17071. onDispose: () => void;
  17072. private _particles;
  17073. private _epsilon;
  17074. private _capacity;
  17075. private _stockParticles;
  17076. private _newPartsExcess;
  17077. private _vertexData;
  17078. private _vertexBuffer;
  17079. private _vertexBuffers;
  17080. private _spriteBuffer;
  17081. private _indexBuffer;
  17082. private _effect;
  17083. private _customEffect;
  17084. private _cachedDefines;
  17085. private _scaledColorStep;
  17086. private _colorDiff;
  17087. private _scaledDirection;
  17088. private _scaledGravity;
  17089. private _currentRenderId;
  17090. private _alive;
  17091. private _useInstancing;
  17092. private _started;
  17093. private _stopped;
  17094. private _actualFrame;
  17095. private _scaledUpdateSpeed;
  17096. private _vertexBufferSize;
  17097. /** @hidden */
  17098. _currentEmitRateGradient: Nullable<FactorGradient>;
  17099. /** @hidden */
  17100. _currentEmitRate1: number;
  17101. /** @hidden */
  17102. _currentEmitRate2: number;
  17103. /** @hidden */
  17104. _currentStartSizeGradient: Nullable<FactorGradient>;
  17105. /** @hidden */
  17106. _currentStartSize1: number;
  17107. /** @hidden */
  17108. _currentStartSize2: number;
  17109. private readonly _rawTextureWidth;
  17110. private _rampGradientsTexture;
  17111. private _useRampGradients;
  17112. /** Gets or sets a boolean indicating that ramp gradients must be used
  17113. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17114. */
  17115. useRampGradients: boolean;
  17116. /**
  17117. * 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.
  17118. * 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: [])
  17119. */
  17120. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17121. private _subEmitters;
  17122. /**
  17123. * @hidden
  17124. * If the particle systems emitter should be disposed when the particle system is disposed
  17125. */
  17126. _disposeEmitterOnDispose: boolean;
  17127. /**
  17128. * The current active Sub-systems, this property is used by the root particle system only.
  17129. */
  17130. activeSubSystems: Array<ParticleSystem>;
  17131. private _rootParticleSystem;
  17132. /**
  17133. * Gets the current list of active particles
  17134. */
  17135. readonly particles: Particle[];
  17136. /**
  17137. * Returns the string "ParticleSystem"
  17138. * @returns a string containing the class name
  17139. */
  17140. getClassName(): string;
  17141. /**
  17142. * Instantiates a particle system.
  17143. * 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.
  17144. * @param name The name of the particle system
  17145. * @param capacity The max number of particles alive at the same time
  17146. * @param scene The scene the particle system belongs to
  17147. * @param customEffect a custom effect used to change the way particles are rendered by default
  17148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17149. * @param epsilon Offset used to render the particles
  17150. */
  17151. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17152. private _addFactorGradient;
  17153. private _removeFactorGradient;
  17154. /**
  17155. * Adds a new life time gradient
  17156. * @param gradient defines the gradient to use (between 0 and 1)
  17157. * @param factor defines the life time factor to affect to the specified gradient
  17158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17159. * @returns the current particle system
  17160. */
  17161. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17162. /**
  17163. * Remove a specific life time gradient
  17164. * @param gradient defines the gradient to remove
  17165. * @returns the current particle system
  17166. */
  17167. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17168. /**
  17169. * Adds a new size gradient
  17170. * @param gradient defines the gradient to use (between 0 and 1)
  17171. * @param factor defines the size factor to affect to the specified gradient
  17172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17173. * @returns the current particle system
  17174. */
  17175. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17176. /**
  17177. * Remove a specific size gradient
  17178. * @param gradient defines the gradient to remove
  17179. * @returns the current particle system
  17180. */
  17181. removeSizeGradient(gradient: number): IParticleSystem;
  17182. /**
  17183. * Adds a new color remap gradient
  17184. * @param gradient defines the gradient to use (between 0 and 1)
  17185. * @param min defines the color remap minimal range
  17186. * @param max defines the color remap maximal range
  17187. * @returns the current particle system
  17188. */
  17189. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17190. /**
  17191. * Remove a specific color remap gradient
  17192. * @param gradient defines the gradient to remove
  17193. * @returns the current particle system
  17194. */
  17195. removeColorRemapGradient(gradient: number): IParticleSystem;
  17196. /**
  17197. * Adds a new alpha remap gradient
  17198. * @param gradient defines the gradient to use (between 0 and 1)
  17199. * @param min defines the alpha remap minimal range
  17200. * @param max defines the alpha remap maximal range
  17201. * @returns the current particle system
  17202. */
  17203. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17204. /**
  17205. * Remove a specific alpha remap gradient
  17206. * @param gradient defines the gradient to remove
  17207. * @returns the current particle system
  17208. */
  17209. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17210. /**
  17211. * Adds a new angular speed gradient
  17212. * @param gradient defines the gradient to use (between 0 and 1)
  17213. * @param factor defines the angular speed to affect to the specified gradient
  17214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17215. * @returns the current particle system
  17216. */
  17217. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17218. /**
  17219. * Remove a specific angular speed gradient
  17220. * @param gradient defines the gradient to remove
  17221. * @returns the current particle system
  17222. */
  17223. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17224. /**
  17225. * Adds a new velocity gradient
  17226. * @param gradient defines the gradient to use (between 0 and 1)
  17227. * @param factor defines the velocity to affect to the specified gradient
  17228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17229. * @returns the current particle system
  17230. */
  17231. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17232. /**
  17233. * Remove a specific velocity gradient
  17234. * @param gradient defines the gradient to remove
  17235. * @returns the current particle system
  17236. */
  17237. removeVelocityGradient(gradient: number): IParticleSystem;
  17238. /**
  17239. * Adds a new limit velocity gradient
  17240. * @param gradient defines the gradient to use (between 0 and 1)
  17241. * @param factor defines the limit velocity value to affect to the specified gradient
  17242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17243. * @returns the current particle system
  17244. */
  17245. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17246. /**
  17247. * Remove a specific limit velocity gradient
  17248. * @param gradient defines the gradient to remove
  17249. * @returns the current particle system
  17250. */
  17251. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17252. /**
  17253. * Adds a new drag gradient
  17254. * @param gradient defines the gradient to use (between 0 and 1)
  17255. * @param factor defines the drag value to affect to the specified gradient
  17256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17257. * @returns the current particle system
  17258. */
  17259. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17260. /**
  17261. * Remove a specific drag gradient
  17262. * @param gradient defines the gradient to remove
  17263. * @returns the current particle system
  17264. */
  17265. removeDragGradient(gradient: number): IParticleSystem;
  17266. /**
  17267. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17268. * @param gradient defines the gradient to use (between 0 and 1)
  17269. * @param factor defines the emit rate value to affect to the specified gradient
  17270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17271. * @returns the current particle system
  17272. */
  17273. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17274. /**
  17275. * Remove a specific emit rate gradient
  17276. * @param gradient defines the gradient to remove
  17277. * @returns the current particle system
  17278. */
  17279. removeEmitRateGradient(gradient: number): IParticleSystem;
  17280. /**
  17281. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17282. * @param gradient defines the gradient to use (between 0 and 1)
  17283. * @param factor defines the start size value to affect to the specified gradient
  17284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17285. * @returns the current particle system
  17286. */
  17287. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17288. /**
  17289. * Remove a specific start size gradient
  17290. * @param gradient defines the gradient to remove
  17291. * @returns the current particle system
  17292. */
  17293. removeStartSizeGradient(gradient: number): IParticleSystem;
  17294. private _createRampGradientTexture;
  17295. /**
  17296. * Gets the current list of ramp gradients.
  17297. * You must use addRampGradient and removeRampGradient to udpate this list
  17298. * @returns the list of ramp gradients
  17299. */
  17300. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17301. /**
  17302. * Adds a new ramp gradient used to remap particle colors
  17303. * @param gradient defines the gradient to use (between 0 and 1)
  17304. * @param color defines the color to affect to the specified gradient
  17305. * @returns the current particle system
  17306. */
  17307. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17308. /**
  17309. * Remove a specific ramp gradient
  17310. * @param gradient defines the gradient to remove
  17311. * @returns the current particle system
  17312. */
  17313. removeRampGradient(gradient: number): ParticleSystem;
  17314. /**
  17315. * Adds a new color gradient
  17316. * @param gradient defines the gradient to use (between 0 and 1)
  17317. * @param color1 defines the color to affect to the specified gradient
  17318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17319. * @returns this particle system
  17320. */
  17321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17322. /**
  17323. * Remove a specific color gradient
  17324. * @param gradient defines the gradient to remove
  17325. * @returns this particle system
  17326. */
  17327. removeColorGradient(gradient: number): IParticleSystem;
  17328. private _fetchR;
  17329. protected _reset(): void;
  17330. private _resetEffect;
  17331. private _createVertexBuffers;
  17332. private _createIndexBuffer;
  17333. /**
  17334. * Gets the maximum number of particles active at the same time.
  17335. * @returns The max number of active particles.
  17336. */
  17337. getCapacity(): number;
  17338. /**
  17339. * Gets whether there are still active particles in the system.
  17340. * @returns True if it is alive, otherwise false.
  17341. */
  17342. isAlive(): boolean;
  17343. /**
  17344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17345. * @returns True if it has been started, otherwise false.
  17346. */
  17347. isStarted(): boolean;
  17348. private _prepareSubEmitterInternalArray;
  17349. /**
  17350. * Starts the particle system and begins to emit
  17351. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17352. */
  17353. start(delay?: number): void;
  17354. /**
  17355. * Stops the particle system.
  17356. * @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.
  17357. */
  17358. stop(stopSubEmitters?: boolean): void;
  17359. /**
  17360. * Remove all active particles
  17361. */
  17362. reset(): void;
  17363. /**
  17364. * @hidden (for internal use only)
  17365. */
  17366. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17367. /**
  17368. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17369. * Its lifetime will start back at 0.
  17370. */
  17371. recycleParticle: (particle: Particle) => void;
  17372. private _stopSubEmitters;
  17373. private _createParticle;
  17374. private _removeFromRoot;
  17375. private _emitFromParticle;
  17376. private _update;
  17377. /** @hidden */
  17378. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17379. /** @hidden */
  17380. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17381. /** @hidden */
  17382. private _getEffect;
  17383. /**
  17384. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17385. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17386. */
  17387. animate(preWarmOnly?: boolean): void;
  17388. private _appendParticleVertices;
  17389. /**
  17390. * Rebuilds the particle system.
  17391. */
  17392. rebuild(): void;
  17393. /**
  17394. * Is this system ready to be used/rendered
  17395. * @return true if the system is ready
  17396. */
  17397. isReady(): boolean;
  17398. private _render;
  17399. /**
  17400. * Renders the particle system in its current state.
  17401. * @returns the current number of particles
  17402. */
  17403. render(): number;
  17404. /**
  17405. * Disposes the particle system and free the associated resources
  17406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17407. */
  17408. dispose(disposeTexture?: boolean): void;
  17409. /**
  17410. * Clones the particle system.
  17411. * @param name The name of the cloned object
  17412. * @param newEmitter The new emitter to use
  17413. * @returns the cloned particle system
  17414. */
  17415. clone(name: string, newEmitter: any): ParticleSystem;
  17416. /**
  17417. * Serializes the particle system to a JSON object.
  17418. * @returns the JSON object
  17419. */
  17420. serialize(): any;
  17421. /** @hidden */
  17422. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17423. /** @hidden */
  17424. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17425. /**
  17426. * Parses a JSON object to create a particle system.
  17427. * @param parsedParticleSystem The JSON object to parse
  17428. * @param scene The scene to create the particle system in
  17429. * @param rootUrl The root url to use to load external dependencies like texture
  17430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17431. * @returns the Parsed particle system
  17432. */
  17433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17434. }
  17435. }
  17436. declare module BABYLON {
  17437. /**
  17438. * A particle represents one of the element emitted by a particle system.
  17439. * This is mainly define by its coordinates, direction, velocity and age.
  17440. */
  17441. export class Particle {
  17442. /**
  17443. * The particle system the particle belongs to.
  17444. */
  17445. particleSystem: ParticleSystem;
  17446. private static _Count;
  17447. /**
  17448. * Unique ID of the particle
  17449. */
  17450. id: number;
  17451. /**
  17452. * The world position of the particle in the scene.
  17453. */
  17454. position: Vector3;
  17455. /**
  17456. * The world direction of the particle in the scene.
  17457. */
  17458. direction: Vector3;
  17459. /**
  17460. * The color of the particle.
  17461. */
  17462. color: Color4;
  17463. /**
  17464. * The color change of the particle per step.
  17465. */
  17466. colorStep: Color4;
  17467. /**
  17468. * Defines how long will the life of the particle be.
  17469. */
  17470. lifeTime: number;
  17471. /**
  17472. * The current age of the particle.
  17473. */
  17474. age: number;
  17475. /**
  17476. * The current size of the particle.
  17477. */
  17478. size: number;
  17479. /**
  17480. * The current scale of the particle.
  17481. */
  17482. scale: Vector2;
  17483. /**
  17484. * The current angle of the particle.
  17485. */
  17486. angle: number;
  17487. /**
  17488. * Defines how fast is the angle changing.
  17489. */
  17490. angularSpeed: number;
  17491. /**
  17492. * Defines the cell index used by the particle to be rendered from a sprite.
  17493. */
  17494. cellIndex: number;
  17495. /**
  17496. * The information required to support color remapping
  17497. */
  17498. remapData: Vector4;
  17499. /** @hidden */
  17500. _randomCellOffset?: number;
  17501. /** @hidden */
  17502. _initialDirection: Nullable<Vector3>;
  17503. /** @hidden */
  17504. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17505. /** @hidden */
  17506. _initialStartSpriteCellID: number;
  17507. /** @hidden */
  17508. _initialEndSpriteCellID: number;
  17509. /** @hidden */
  17510. _currentColorGradient: Nullable<ColorGradient>;
  17511. /** @hidden */
  17512. _currentColor1: Color4;
  17513. /** @hidden */
  17514. _currentColor2: Color4;
  17515. /** @hidden */
  17516. _currentSizeGradient: Nullable<FactorGradient>;
  17517. /** @hidden */
  17518. _currentSize1: number;
  17519. /** @hidden */
  17520. _currentSize2: number;
  17521. /** @hidden */
  17522. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17523. /** @hidden */
  17524. _currentAngularSpeed1: number;
  17525. /** @hidden */
  17526. _currentAngularSpeed2: number;
  17527. /** @hidden */
  17528. _currentVelocityGradient: Nullable<FactorGradient>;
  17529. /** @hidden */
  17530. _currentVelocity1: number;
  17531. /** @hidden */
  17532. _currentVelocity2: number;
  17533. /** @hidden */
  17534. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17535. /** @hidden */
  17536. _currentLimitVelocity1: number;
  17537. /** @hidden */
  17538. _currentLimitVelocity2: number;
  17539. /** @hidden */
  17540. _currentDragGradient: Nullable<FactorGradient>;
  17541. /** @hidden */
  17542. _currentDrag1: number;
  17543. /** @hidden */
  17544. _currentDrag2: number;
  17545. /** @hidden */
  17546. _randomNoiseCoordinates1: Vector3;
  17547. /** @hidden */
  17548. _randomNoiseCoordinates2: Vector3;
  17549. /**
  17550. * Creates a new instance Particle
  17551. * @param particleSystem the particle system the particle belongs to
  17552. */
  17553. constructor(
  17554. /**
  17555. * The particle system the particle belongs to.
  17556. */
  17557. particleSystem: ParticleSystem);
  17558. private updateCellInfoFromSystem;
  17559. /**
  17560. * Defines how the sprite cell index is updated for the particle
  17561. */
  17562. updateCellIndex(): void;
  17563. /** @hidden */
  17564. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17565. /** @hidden */
  17566. _inheritParticleInfoToSubEmitters(): void;
  17567. /** @hidden */
  17568. _reset(): void;
  17569. /**
  17570. * Copy the properties of particle to another one.
  17571. * @param other the particle to copy the information to.
  17572. */
  17573. copyTo(other: Particle): void;
  17574. }
  17575. }
  17576. declare module BABYLON {
  17577. /**
  17578. * Particle emitter represents a volume emitting particles.
  17579. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17580. */
  17581. export interface IParticleEmitterType {
  17582. /**
  17583. * Called by the particle System when the direction is computed for the created particle.
  17584. * @param worldMatrix is the world matrix of the particle system
  17585. * @param directionToUpdate is the direction vector to update with the result
  17586. * @param particle is the particle we are computed the direction for
  17587. */
  17588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17589. /**
  17590. * Called by the particle System when the position is computed for the created particle.
  17591. * @param worldMatrix is the world matrix of the particle system
  17592. * @param positionToUpdate is the position vector to update with the result
  17593. * @param particle is the particle we are computed the position for
  17594. */
  17595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17596. /**
  17597. * Clones the current emitter and returns a copy of it
  17598. * @returns the new emitter
  17599. */
  17600. clone(): IParticleEmitterType;
  17601. /**
  17602. * Called by the GPUParticleSystem to setup the update shader
  17603. * @param effect defines the update shader
  17604. */
  17605. applyToShader(effect: Effect): void;
  17606. /**
  17607. * Returns a string to use to update the GPU particles update shader
  17608. * @returns the effect defines string
  17609. */
  17610. getEffectDefines(): string;
  17611. /**
  17612. * Returns a string representing the class name
  17613. * @returns a string containing the class name
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Serializes the particle system to a JSON object.
  17618. * @returns the JSON object
  17619. */
  17620. serialize(): any;
  17621. /**
  17622. * Parse properties from a JSON object
  17623. * @param serializationObject defines the JSON object
  17624. */
  17625. parse(serializationObject: any): void;
  17626. }
  17627. }
  17628. declare module BABYLON {
  17629. /**
  17630. * Particle emitter emitting particles from the inside of a box.
  17631. * It emits the particles randomly between 2 given directions.
  17632. */
  17633. export class BoxParticleEmitter implements IParticleEmitterType {
  17634. /**
  17635. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17636. */
  17637. direction1: Vector3;
  17638. /**
  17639. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17640. */
  17641. direction2: Vector3;
  17642. /**
  17643. * 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.
  17644. */
  17645. minEmitBox: Vector3;
  17646. /**
  17647. * 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.
  17648. */
  17649. maxEmitBox: Vector3;
  17650. /**
  17651. * Creates a new instance BoxParticleEmitter
  17652. */
  17653. constructor();
  17654. /**
  17655. * Called by the particle System when the direction is computed for the created particle.
  17656. * @param worldMatrix is the world matrix of the particle system
  17657. * @param directionToUpdate is the direction vector to update with the result
  17658. * @param particle is the particle we are computed the direction for
  17659. */
  17660. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17661. /**
  17662. * Called by the particle System when the position is computed for the created particle.
  17663. * @param worldMatrix is the world matrix of the particle system
  17664. * @param positionToUpdate is the position vector to update with the result
  17665. * @param particle is the particle we are computed the position for
  17666. */
  17667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17668. /**
  17669. * Clones the current emitter and returns a copy of it
  17670. * @returns the new emitter
  17671. */
  17672. clone(): BoxParticleEmitter;
  17673. /**
  17674. * Called by the GPUParticleSystem to setup the update shader
  17675. * @param effect defines the update shader
  17676. */
  17677. applyToShader(effect: Effect): void;
  17678. /**
  17679. * Returns a string to use to update the GPU particles update shader
  17680. * @returns a string containng the defines string
  17681. */
  17682. getEffectDefines(): string;
  17683. /**
  17684. * Returns the string "BoxParticleEmitter"
  17685. * @returns a string containing the class name
  17686. */
  17687. getClassName(): string;
  17688. /**
  17689. * Serializes the particle system to a JSON object.
  17690. * @returns the JSON object
  17691. */
  17692. serialize(): any;
  17693. /**
  17694. * Parse properties from a JSON object
  17695. * @param serializationObject defines the JSON object
  17696. */
  17697. parse(serializationObject: any): void;
  17698. }
  17699. }
  17700. declare module BABYLON {
  17701. /**
  17702. * Particle emitter emitting particles from the inside of a cone.
  17703. * It emits the particles alongside the cone volume from the base to the particle.
  17704. * The emission direction might be randomized.
  17705. */
  17706. export class ConeParticleEmitter implements IParticleEmitterType {
  17707. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17708. directionRandomizer: number;
  17709. private _radius;
  17710. private _angle;
  17711. private _height;
  17712. /**
  17713. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17714. */
  17715. radiusRange: number;
  17716. /**
  17717. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17718. */
  17719. heightRange: number;
  17720. /**
  17721. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17722. */
  17723. emitFromSpawnPointOnly: boolean;
  17724. /**
  17725. * Gets or sets the radius of the emission cone
  17726. */
  17727. radius: number;
  17728. /**
  17729. * Gets or sets the angle of the emission cone
  17730. */
  17731. angle: number;
  17732. private _buildHeight;
  17733. /**
  17734. * Creates a new instance ConeParticleEmitter
  17735. * @param radius the radius of the emission cone (1 by default)
  17736. * @param angle the cone base angle (PI by default)
  17737. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17738. */
  17739. constructor(radius?: number, angle?: number,
  17740. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17741. directionRandomizer?: number);
  17742. /**
  17743. * Called by the particle System when the direction is computed for the created particle.
  17744. * @param worldMatrix is the world matrix of the particle system
  17745. * @param directionToUpdate is the direction vector to update with the result
  17746. * @param particle is the particle we are computed the direction for
  17747. */
  17748. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17749. /**
  17750. * Called by the particle System when the position is computed for the created particle.
  17751. * @param worldMatrix is the world matrix of the particle system
  17752. * @param positionToUpdate is the position vector to update with the result
  17753. * @param particle is the particle we are computed the position for
  17754. */
  17755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17756. /**
  17757. * Clones the current emitter and returns a copy of it
  17758. * @returns the new emitter
  17759. */
  17760. clone(): ConeParticleEmitter;
  17761. /**
  17762. * Called by the GPUParticleSystem to setup the update shader
  17763. * @param effect defines the update shader
  17764. */
  17765. applyToShader(effect: Effect): void;
  17766. /**
  17767. * Returns a string to use to update the GPU particles update shader
  17768. * @returns a string containng the defines string
  17769. */
  17770. getEffectDefines(): string;
  17771. /**
  17772. * Returns the string "ConeParticleEmitter"
  17773. * @returns a string containing the class name
  17774. */
  17775. getClassName(): string;
  17776. /**
  17777. * Serializes the particle system to a JSON object.
  17778. * @returns the JSON object
  17779. */
  17780. serialize(): any;
  17781. /**
  17782. * Parse properties from a JSON object
  17783. * @param serializationObject defines the JSON object
  17784. */
  17785. parse(serializationObject: any): void;
  17786. }
  17787. }
  17788. declare module BABYLON {
  17789. /**
  17790. * Particle emitter emitting particles from the inside of a cylinder.
  17791. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17792. */
  17793. export class CylinderParticleEmitter implements IParticleEmitterType {
  17794. /**
  17795. * The radius of the emission cylinder.
  17796. */
  17797. radius: number;
  17798. /**
  17799. * The height of the emission cylinder.
  17800. */
  17801. height: number;
  17802. /**
  17803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17804. */
  17805. radiusRange: number;
  17806. /**
  17807. * How much to randomize the particle direction [0-1].
  17808. */
  17809. directionRandomizer: number;
  17810. /**
  17811. * Creates a new instance CylinderParticleEmitter
  17812. * @param radius the radius of the emission cylinder (1 by default)
  17813. * @param height the height of the emission cylinder (1 by default)
  17814. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17815. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17816. */
  17817. constructor(
  17818. /**
  17819. * The radius of the emission cylinder.
  17820. */
  17821. radius?: number,
  17822. /**
  17823. * The height of the emission cylinder.
  17824. */
  17825. height?: number,
  17826. /**
  17827. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17828. */
  17829. radiusRange?: number,
  17830. /**
  17831. * How much to randomize the particle direction [0-1].
  17832. */
  17833. directionRandomizer?: number);
  17834. /**
  17835. * Called by the particle System when the direction is computed for the created particle.
  17836. * @param worldMatrix is the world matrix of the particle system
  17837. * @param directionToUpdate is the direction vector to update with the result
  17838. * @param particle is the particle we are computed the direction for
  17839. */
  17840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17841. /**
  17842. * Called by the particle System when the position is computed for the created particle.
  17843. * @param worldMatrix is the world matrix of the particle system
  17844. * @param positionToUpdate is the position vector to update with the result
  17845. * @param particle is the particle we are computed the position for
  17846. */
  17847. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17848. /**
  17849. * Clones the current emitter and returns a copy of it
  17850. * @returns the new emitter
  17851. */
  17852. clone(): CylinderParticleEmitter;
  17853. /**
  17854. * Called by the GPUParticleSystem to setup the update shader
  17855. * @param effect defines the update shader
  17856. */
  17857. applyToShader(effect: Effect): void;
  17858. /**
  17859. * Returns a string to use to update the GPU particles update shader
  17860. * @returns a string containng the defines string
  17861. */
  17862. getEffectDefines(): string;
  17863. /**
  17864. * Returns the string "CylinderParticleEmitter"
  17865. * @returns a string containing the class name
  17866. */
  17867. getClassName(): string;
  17868. /**
  17869. * Serializes the particle system to a JSON object.
  17870. * @returns the JSON object
  17871. */
  17872. serialize(): any;
  17873. /**
  17874. * Parse properties from a JSON object
  17875. * @param serializationObject defines the JSON object
  17876. */
  17877. parse(serializationObject: any): void;
  17878. }
  17879. /**
  17880. * Particle emitter emitting particles from the inside of a cylinder.
  17881. * It emits the particles randomly between two vectors.
  17882. */
  17883. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17884. /**
  17885. * The min limit of the emission direction.
  17886. */
  17887. direction1: Vector3;
  17888. /**
  17889. * The max limit of the emission direction.
  17890. */
  17891. direction2: Vector3;
  17892. /**
  17893. * Creates a new instance CylinderDirectedParticleEmitter
  17894. * @param radius the radius of the emission cylinder (1 by default)
  17895. * @param height the height of the emission cylinder (1 by default)
  17896. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17897. * @param direction1 the min limit of the emission direction (up vector by default)
  17898. * @param direction2 the max limit of the emission direction (up vector by default)
  17899. */
  17900. constructor(radius?: number, height?: number, radiusRange?: number,
  17901. /**
  17902. * The min limit of the emission direction.
  17903. */
  17904. direction1?: Vector3,
  17905. /**
  17906. * The max limit of the emission direction.
  17907. */
  17908. direction2?: Vector3);
  17909. /**
  17910. * Called by the particle System when the direction is computed for the created particle.
  17911. * @param worldMatrix is the world matrix of the particle system
  17912. * @param directionToUpdate is the direction vector to update with the result
  17913. * @param particle is the particle we are computed the direction for
  17914. */
  17915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17916. /**
  17917. * Clones the current emitter and returns a copy of it
  17918. * @returns the new emitter
  17919. */
  17920. clone(): CylinderDirectedParticleEmitter;
  17921. /**
  17922. * Called by the GPUParticleSystem to setup the update shader
  17923. * @param effect defines the update shader
  17924. */
  17925. applyToShader(effect: Effect): void;
  17926. /**
  17927. * Returns a string to use to update the GPU particles update shader
  17928. * @returns a string containng the defines string
  17929. */
  17930. getEffectDefines(): string;
  17931. /**
  17932. * Returns the string "CylinderDirectedParticleEmitter"
  17933. * @returns a string containing the class name
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Serializes the particle system to a JSON object.
  17938. * @returns the JSON object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Parse properties from a JSON object
  17943. * @param serializationObject defines the JSON object
  17944. */
  17945. parse(serializationObject: any): void;
  17946. }
  17947. }
  17948. declare module BABYLON {
  17949. /**
  17950. * Particle emitter emitting particles from the inside of a hemisphere.
  17951. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17952. */
  17953. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17954. /**
  17955. * The radius of the emission hemisphere.
  17956. */
  17957. radius: number;
  17958. /**
  17959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17960. */
  17961. radiusRange: number;
  17962. /**
  17963. * How much to randomize the particle direction [0-1].
  17964. */
  17965. directionRandomizer: number;
  17966. /**
  17967. * Creates a new instance HemisphericParticleEmitter
  17968. * @param radius the radius of the emission hemisphere (1 by default)
  17969. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17970. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17971. */
  17972. constructor(
  17973. /**
  17974. * The radius of the emission hemisphere.
  17975. */
  17976. radius?: number,
  17977. /**
  17978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17979. */
  17980. radiusRange?: number,
  17981. /**
  17982. * How much to randomize the particle direction [0-1].
  17983. */
  17984. directionRandomizer?: number);
  17985. /**
  17986. * Called by the particle System when the direction is computed for the created particle.
  17987. * @param worldMatrix is the world matrix of the particle system
  17988. * @param directionToUpdate is the direction vector to update with the result
  17989. * @param particle is the particle we are computed the direction for
  17990. */
  17991. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17992. /**
  17993. * Called by the particle System when the position is computed for the created particle.
  17994. * @param worldMatrix is the world matrix of the particle system
  17995. * @param positionToUpdate is the position vector to update with the result
  17996. * @param particle is the particle we are computed the position for
  17997. */
  17998. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17999. /**
  18000. * Clones the current emitter and returns a copy of it
  18001. * @returns the new emitter
  18002. */
  18003. clone(): HemisphericParticleEmitter;
  18004. /**
  18005. * Called by the GPUParticleSystem to setup the update shader
  18006. * @param effect defines the update shader
  18007. */
  18008. applyToShader(effect: Effect): void;
  18009. /**
  18010. * Returns a string to use to update the GPU particles update shader
  18011. * @returns a string containng the defines string
  18012. */
  18013. getEffectDefines(): string;
  18014. /**
  18015. * Returns the string "HemisphericParticleEmitter"
  18016. * @returns a string containing the class name
  18017. */
  18018. getClassName(): string;
  18019. /**
  18020. * Serializes the particle system to a JSON object.
  18021. * @returns the JSON object
  18022. */
  18023. serialize(): any;
  18024. /**
  18025. * Parse properties from a JSON object
  18026. * @param serializationObject defines the JSON object
  18027. */
  18028. parse(serializationObject: any): void;
  18029. }
  18030. }
  18031. declare module BABYLON {
  18032. /**
  18033. * Particle emitter emitting particles from a point.
  18034. * It emits the particles randomly between 2 given directions.
  18035. */
  18036. export class PointParticleEmitter implements IParticleEmitterType {
  18037. /**
  18038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18039. */
  18040. direction1: Vector3;
  18041. /**
  18042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18043. */
  18044. direction2: Vector3;
  18045. /**
  18046. * Creates a new instance PointParticleEmitter
  18047. */
  18048. constructor();
  18049. /**
  18050. * Called by the particle System when the direction is computed for the created particle.
  18051. * @param worldMatrix is the world matrix of the particle system
  18052. * @param directionToUpdate is the direction vector to update with the result
  18053. * @param particle is the particle we are computed the direction for
  18054. */
  18055. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18056. /**
  18057. * Called by the particle System when the position is computed for the created particle.
  18058. * @param worldMatrix is the world matrix of the particle system
  18059. * @param positionToUpdate is the position vector to update with the result
  18060. * @param particle is the particle we are computed the position for
  18061. */
  18062. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18063. /**
  18064. * Clones the current emitter and returns a copy of it
  18065. * @returns the new emitter
  18066. */
  18067. clone(): PointParticleEmitter;
  18068. /**
  18069. * Called by the GPUParticleSystem to setup the update shader
  18070. * @param effect defines the update shader
  18071. */
  18072. applyToShader(effect: Effect): void;
  18073. /**
  18074. * Returns a string to use to update the GPU particles update shader
  18075. * @returns a string containng the defines string
  18076. */
  18077. getEffectDefines(): string;
  18078. /**
  18079. * Returns the string "PointParticleEmitter"
  18080. * @returns a string containing the class name
  18081. */
  18082. getClassName(): string;
  18083. /**
  18084. * Serializes the particle system to a JSON object.
  18085. * @returns the JSON object
  18086. */
  18087. serialize(): any;
  18088. /**
  18089. * Parse properties from a JSON object
  18090. * @param serializationObject defines the JSON object
  18091. */
  18092. parse(serializationObject: any): void;
  18093. }
  18094. }
  18095. declare module BABYLON {
  18096. /**
  18097. * Particle emitter emitting particles from the inside of a sphere.
  18098. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18099. */
  18100. export class SphereParticleEmitter implements IParticleEmitterType {
  18101. /**
  18102. * The radius of the emission sphere.
  18103. */
  18104. radius: number;
  18105. /**
  18106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18107. */
  18108. radiusRange: number;
  18109. /**
  18110. * How much to randomize the particle direction [0-1].
  18111. */
  18112. directionRandomizer: number;
  18113. /**
  18114. * Creates a new instance SphereParticleEmitter
  18115. * @param radius the radius of the emission sphere (1 by default)
  18116. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18117. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18118. */
  18119. constructor(
  18120. /**
  18121. * The radius of the emission sphere.
  18122. */
  18123. radius?: number,
  18124. /**
  18125. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18126. */
  18127. radiusRange?: number,
  18128. /**
  18129. * How much to randomize the particle direction [0-1].
  18130. */
  18131. directionRandomizer?: number);
  18132. /**
  18133. * Called by the particle System when the direction is computed for the created particle.
  18134. * @param worldMatrix is the world matrix of the particle system
  18135. * @param directionToUpdate is the direction vector to update with the result
  18136. * @param particle is the particle we are computed the direction for
  18137. */
  18138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18139. /**
  18140. * Called by the particle System when the position is computed for the created particle.
  18141. * @param worldMatrix is the world matrix of the particle system
  18142. * @param positionToUpdate is the position vector to update with the result
  18143. * @param particle is the particle we are computed the position for
  18144. */
  18145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18146. /**
  18147. * Clones the current emitter and returns a copy of it
  18148. * @returns the new emitter
  18149. */
  18150. clone(): SphereParticleEmitter;
  18151. /**
  18152. * Called by the GPUParticleSystem to setup the update shader
  18153. * @param effect defines the update shader
  18154. */
  18155. applyToShader(effect: Effect): void;
  18156. /**
  18157. * Returns a string to use to update the GPU particles update shader
  18158. * @returns a string containng the defines string
  18159. */
  18160. getEffectDefines(): string;
  18161. /**
  18162. * Returns the string "SphereParticleEmitter"
  18163. * @returns a string containing the class name
  18164. */
  18165. getClassName(): string;
  18166. /**
  18167. * Serializes the particle system to a JSON object.
  18168. * @returns the JSON object
  18169. */
  18170. serialize(): any;
  18171. /**
  18172. * Parse properties from a JSON object
  18173. * @param serializationObject defines the JSON object
  18174. */
  18175. parse(serializationObject: any): void;
  18176. }
  18177. /**
  18178. * Particle emitter emitting particles from the inside of a sphere.
  18179. * It emits the particles randomly between two vectors.
  18180. */
  18181. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18182. /**
  18183. * The min limit of the emission direction.
  18184. */
  18185. direction1: Vector3;
  18186. /**
  18187. * The max limit of the emission direction.
  18188. */
  18189. direction2: Vector3;
  18190. /**
  18191. * Creates a new instance SphereDirectedParticleEmitter
  18192. * @param radius the radius of the emission sphere (1 by default)
  18193. * @param direction1 the min limit of the emission direction (up vector by default)
  18194. * @param direction2 the max limit of the emission direction (up vector by default)
  18195. */
  18196. constructor(radius?: number,
  18197. /**
  18198. * The min limit of the emission direction.
  18199. */
  18200. direction1?: Vector3,
  18201. /**
  18202. * The max limit of the emission direction.
  18203. */
  18204. direction2?: Vector3);
  18205. /**
  18206. * Called by the particle System when the direction is computed for the created particle.
  18207. * @param worldMatrix is the world matrix of the particle system
  18208. * @param directionToUpdate is the direction vector to update with the result
  18209. * @param particle is the particle we are computed the direction for
  18210. */
  18211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18212. /**
  18213. * Clones the current emitter and returns a copy of it
  18214. * @returns the new emitter
  18215. */
  18216. clone(): SphereDirectedParticleEmitter;
  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 "SphereDirectedParticleEmitter"
  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. * Interface representing a particle system in Babylon.js.
  18247. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18248. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18249. */
  18250. export interface IParticleSystem {
  18251. /**
  18252. * List of animations used by the particle system.
  18253. */
  18254. animations: Animation[];
  18255. /**
  18256. * The id of the Particle system.
  18257. */
  18258. id: string;
  18259. /**
  18260. * The name of the Particle system.
  18261. */
  18262. name: string;
  18263. /**
  18264. * The emitter represents the Mesh or position we are attaching the particle system to.
  18265. */
  18266. emitter: Nullable<AbstractMesh | Vector3>;
  18267. /**
  18268. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18269. */
  18270. isBillboardBased: boolean;
  18271. /**
  18272. * The rendering group used by the Particle system to chose when to render.
  18273. */
  18274. renderingGroupId: number;
  18275. /**
  18276. * The layer mask we are rendering the particles through.
  18277. */
  18278. layerMask: number;
  18279. /**
  18280. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18281. */
  18282. updateSpeed: number;
  18283. /**
  18284. * The amount of time the particle system is running (depends of the overall update speed).
  18285. */
  18286. targetStopDuration: number;
  18287. /**
  18288. * The texture used to render each particle. (this can be a spritesheet)
  18289. */
  18290. particleTexture: Nullable<Texture>;
  18291. /**
  18292. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18293. */
  18294. blendMode: number;
  18295. /**
  18296. * Minimum life time of emitting particles.
  18297. */
  18298. minLifeTime: number;
  18299. /**
  18300. * Maximum life time of emitting particles.
  18301. */
  18302. maxLifeTime: number;
  18303. /**
  18304. * Minimum Size of emitting particles.
  18305. */
  18306. minSize: number;
  18307. /**
  18308. * Maximum Size of emitting particles.
  18309. */
  18310. maxSize: number;
  18311. /**
  18312. * Minimum scale of emitting particles on X axis.
  18313. */
  18314. minScaleX: number;
  18315. /**
  18316. * Maximum scale of emitting particles on X axis.
  18317. */
  18318. maxScaleX: number;
  18319. /**
  18320. * Minimum scale of emitting particles on Y axis.
  18321. */
  18322. minScaleY: number;
  18323. /**
  18324. * Maximum scale of emitting particles on Y axis.
  18325. */
  18326. maxScaleY: number;
  18327. /**
  18328. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18329. */
  18330. color1: Color4;
  18331. /**
  18332. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18333. */
  18334. color2: Color4;
  18335. /**
  18336. * Color the particle will have at the end of its lifetime.
  18337. */
  18338. colorDead: Color4;
  18339. /**
  18340. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18341. */
  18342. emitRate: number;
  18343. /**
  18344. * You can use gravity if you want to give an orientation to your particles.
  18345. */
  18346. gravity: Vector3;
  18347. /**
  18348. * Minimum power of emitting particles.
  18349. */
  18350. minEmitPower: number;
  18351. /**
  18352. * Maximum power of emitting particles.
  18353. */
  18354. maxEmitPower: number;
  18355. /**
  18356. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18357. */
  18358. minAngularSpeed: number;
  18359. /**
  18360. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18361. */
  18362. maxAngularSpeed: number;
  18363. /**
  18364. * Gets or sets the minimal initial rotation in radians.
  18365. */
  18366. minInitialRotation: number;
  18367. /**
  18368. * Gets or sets the maximal initial rotation in radians.
  18369. */
  18370. maxInitialRotation: number;
  18371. /**
  18372. * The particle emitter type defines the emitter used by the particle system.
  18373. * It can be for example box, sphere, or cone...
  18374. */
  18375. particleEmitterType: Nullable<IParticleEmitterType>;
  18376. /**
  18377. * Defines the delay in milliseconds before starting the system (0 by default)
  18378. */
  18379. startDelay: number;
  18380. /**
  18381. * 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
  18382. */
  18383. preWarmCycles: number;
  18384. /**
  18385. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18386. */
  18387. preWarmStepOffset: number;
  18388. /**
  18389. * 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)
  18390. */
  18391. spriteCellChangeSpeed: number;
  18392. /**
  18393. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18394. */
  18395. startSpriteCellID: number;
  18396. /**
  18397. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18398. */
  18399. endSpriteCellID: number;
  18400. /**
  18401. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18402. */
  18403. spriteCellWidth: number;
  18404. /**
  18405. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18406. */
  18407. spriteCellHeight: number;
  18408. /**
  18409. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18410. */
  18411. spriteRandomStartCell: boolean;
  18412. /**
  18413. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18414. */
  18415. isAnimationSheetEnabled: boolean;
  18416. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18417. translationPivot: Vector2;
  18418. /**
  18419. * Gets or sets a texture used to add random noise to particle positions
  18420. */
  18421. noiseTexture: Nullable<BaseTexture>;
  18422. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18423. noiseStrength: Vector3;
  18424. /**
  18425. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18426. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18427. */
  18428. billboardMode: number;
  18429. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18430. limitVelocityDamping: number;
  18431. /**
  18432. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18433. */
  18434. beginAnimationOnStart: boolean;
  18435. /**
  18436. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18437. */
  18438. beginAnimationFrom: number;
  18439. /**
  18440. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18441. */
  18442. beginAnimationTo: number;
  18443. /**
  18444. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18445. */
  18446. beginAnimationLoop: boolean;
  18447. /**
  18448. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18449. */
  18450. disposeOnStop: boolean;
  18451. /**
  18452. * Gets the maximum number of particles active at the same time.
  18453. * @returns The max number of active particles.
  18454. */
  18455. getCapacity(): number;
  18456. /**
  18457. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18458. * @returns True if it has been started, otherwise false.
  18459. */
  18460. isStarted(): boolean;
  18461. /**
  18462. * Animates the particle system for this frame.
  18463. */
  18464. animate(): void;
  18465. /**
  18466. * Renders the particle system in its current state.
  18467. * @returns the current number of particles
  18468. */
  18469. render(): number;
  18470. /**
  18471. * Dispose the particle system and frees its associated resources.
  18472. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18473. */
  18474. dispose(disposeTexture?: boolean): void;
  18475. /**
  18476. * Clones the particle system.
  18477. * @param name The name of the cloned object
  18478. * @param newEmitter The new emitter to use
  18479. * @returns the cloned particle system
  18480. */
  18481. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Rebuild the particle system
  18489. */
  18490. rebuild(): void;
  18491. /**
  18492. * Starts the particle system and begins to emit
  18493. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18494. */
  18495. start(delay?: number): void;
  18496. /**
  18497. * Stops the particle system.
  18498. */
  18499. stop(): void;
  18500. /**
  18501. * Remove all active particles
  18502. */
  18503. reset(): void;
  18504. /**
  18505. * Is this system ready to be used/rendered
  18506. * @return true if the system is ready
  18507. */
  18508. isReady(): boolean;
  18509. /**
  18510. * Adds a new color gradient
  18511. * @param gradient defines the gradient to use (between 0 and 1)
  18512. * @param color1 defines the color to affect to the specified gradient
  18513. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18514. * @returns the current particle system
  18515. */
  18516. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18517. /**
  18518. * Remove a specific color gradient
  18519. * @param gradient defines the gradient to remove
  18520. * @returns the current particle system
  18521. */
  18522. removeColorGradient(gradient: number): IParticleSystem;
  18523. /**
  18524. * Adds a new size gradient
  18525. * @param gradient defines the gradient to use (between 0 and 1)
  18526. * @param factor defines the size factor to affect to the specified gradient
  18527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18528. * @returns the current particle system
  18529. */
  18530. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18531. /**
  18532. * Remove a specific size gradient
  18533. * @param gradient defines the gradient to remove
  18534. * @returns the current particle system
  18535. */
  18536. removeSizeGradient(gradient: number): IParticleSystem;
  18537. /**
  18538. * Gets the current list of color gradients.
  18539. * You must use addColorGradient and removeColorGradient to udpate this list
  18540. * @returns the list of color gradients
  18541. */
  18542. getColorGradients(): Nullable<Array<ColorGradient>>;
  18543. /**
  18544. * Gets the current list of size gradients.
  18545. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18546. * @returns the list of size gradients
  18547. */
  18548. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18549. /**
  18550. * Gets the current list of angular speed gradients.
  18551. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18552. * @returns the list of angular speed gradients
  18553. */
  18554. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18555. /**
  18556. * Adds a new angular speed gradient
  18557. * @param gradient defines the gradient to use (between 0 and 1)
  18558. * @param factor defines the angular speed to affect to the specified gradient
  18559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18560. * @returns the current particle system
  18561. */
  18562. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18563. /**
  18564. * Remove a specific angular speed gradient
  18565. * @param gradient defines the gradient to remove
  18566. * @returns the current particle system
  18567. */
  18568. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18569. /**
  18570. * Gets the current list of velocity gradients.
  18571. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18572. * @returns the list of velocity gradients
  18573. */
  18574. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18575. /**
  18576. * Adds a new velocity gradient
  18577. * @param gradient defines the gradient to use (between 0 and 1)
  18578. * @param factor defines the velocity to affect to the specified gradient
  18579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18580. * @returns the current particle system
  18581. */
  18582. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18583. /**
  18584. * Remove a specific velocity gradient
  18585. * @param gradient defines the gradient to remove
  18586. * @returns the current particle system
  18587. */
  18588. removeVelocityGradient(gradient: number): IParticleSystem;
  18589. /**
  18590. * Gets the current list of limit velocity gradients.
  18591. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18592. * @returns the list of limit velocity gradients
  18593. */
  18594. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18595. /**
  18596. * Adds a new limit velocity gradient
  18597. * @param gradient defines the gradient to use (between 0 and 1)
  18598. * @param factor defines the limit velocity to affect to the specified gradient
  18599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18600. * @returns the current particle system
  18601. */
  18602. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18603. /**
  18604. * Remove a specific limit velocity gradient
  18605. * @param gradient defines the gradient to remove
  18606. * @returns the current particle system
  18607. */
  18608. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18609. /**
  18610. * Adds a new drag gradient
  18611. * @param gradient defines the gradient to use (between 0 and 1)
  18612. * @param factor defines the drag to affect to the specified gradient
  18613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18614. * @returns the current particle system
  18615. */
  18616. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18617. /**
  18618. * Remove a specific drag gradient
  18619. * @param gradient defines the gradient to remove
  18620. * @returns the current particle system
  18621. */
  18622. removeDragGradient(gradient: number): IParticleSystem;
  18623. /**
  18624. * Gets the current list of drag gradients.
  18625. * You must use addDragGradient and removeDragGradient to udpate this list
  18626. * @returns the list of drag gradients
  18627. */
  18628. getDragGradients(): Nullable<Array<FactorGradient>>;
  18629. /**
  18630. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18631. * @param gradient defines the gradient to use (between 0 and 1)
  18632. * @param factor defines the emit rate to affect to the specified gradient
  18633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18634. * @returns the current particle system
  18635. */
  18636. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18637. /**
  18638. * Remove a specific emit rate gradient
  18639. * @param gradient defines the gradient to remove
  18640. * @returns the current particle system
  18641. */
  18642. removeEmitRateGradient(gradient: number): IParticleSystem;
  18643. /**
  18644. * Gets the current list of emit rate gradients.
  18645. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18646. * @returns the list of emit rate gradients
  18647. */
  18648. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18649. /**
  18650. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18651. * @param gradient defines the gradient to use (between 0 and 1)
  18652. * @param factor defines the start size to affect to the specified gradient
  18653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18654. * @returns the current particle system
  18655. */
  18656. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18657. /**
  18658. * Remove a specific start size gradient
  18659. * @param gradient defines the gradient to remove
  18660. * @returns the current particle system
  18661. */
  18662. removeStartSizeGradient(gradient: number): IParticleSystem;
  18663. /**
  18664. * Gets the current list of start size gradients.
  18665. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18666. * @returns the list of start size gradients
  18667. */
  18668. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18669. /**
  18670. * Adds a new life time gradient
  18671. * @param gradient defines the gradient to use (between 0 and 1)
  18672. * @param factor defines the life time factor to affect to the specified gradient
  18673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18674. * @returns the current particle system
  18675. */
  18676. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18677. /**
  18678. * Remove a specific life time gradient
  18679. * @param gradient defines the gradient to remove
  18680. * @returns the current particle system
  18681. */
  18682. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18683. /**
  18684. * Gets the current list of life time gradients.
  18685. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18686. * @returns the list of life time gradients
  18687. */
  18688. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18689. /**
  18690. * Gets the current list of color gradients.
  18691. * You must use addColorGradient and removeColorGradient to udpate this list
  18692. * @returns the list of color gradients
  18693. */
  18694. getColorGradients(): Nullable<Array<ColorGradient>>;
  18695. /**
  18696. * Adds a new ramp gradient used to remap particle colors
  18697. * @param gradient defines the gradient to use (between 0 and 1)
  18698. * @param color defines the color to affect to the specified gradient
  18699. * @returns the current particle system
  18700. */
  18701. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18702. /**
  18703. * Gets the current list of ramp gradients.
  18704. * You must use addRampGradient and removeRampGradient to udpate this list
  18705. * @returns the list of ramp gradients
  18706. */
  18707. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18708. /** Gets or sets a boolean indicating that ramp gradients must be used
  18709. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18710. */
  18711. useRampGradients: boolean;
  18712. /**
  18713. * Adds a new color remap gradient
  18714. * @param gradient defines the gradient to use (between 0 and 1)
  18715. * @param min defines the color remap minimal range
  18716. * @param max defines the color remap maximal range
  18717. * @returns the current particle system
  18718. */
  18719. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18720. /**
  18721. * Gets the current list of color remap gradients.
  18722. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18723. * @returns the list of color remap gradients
  18724. */
  18725. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18726. /**
  18727. * Adds a new alpha remap gradient
  18728. * @param gradient defines the gradient to use (between 0 and 1)
  18729. * @param min defines the alpha remap minimal range
  18730. * @param max defines the alpha remap maximal range
  18731. * @returns the current particle system
  18732. */
  18733. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18734. /**
  18735. * Gets the current list of alpha remap gradients.
  18736. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18737. * @returns the list of alpha remap gradients
  18738. */
  18739. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18740. /**
  18741. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18744. * @returns the emitter
  18745. */
  18746. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18747. /**
  18748. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18749. * @param radius The radius of the hemisphere to emit from
  18750. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18751. * @returns the emitter
  18752. */
  18753. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18754. /**
  18755. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18756. * @param radius The radius of the sphere to emit from
  18757. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18758. * @returns the emitter
  18759. */
  18760. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18761. /**
  18762. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18763. * @param radius The radius of the sphere to emit from
  18764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18766. * @returns the emitter
  18767. */
  18768. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18769. /**
  18770. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18771. * @param radius The radius of the emission cylinder
  18772. * @param height The height of the emission cylinder
  18773. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18774. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18775. * @returns the emitter
  18776. */
  18777. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18778. /**
  18779. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18780. * @param radius The radius of the cylinder to emit from
  18781. * @param height The height of the emission cylinder
  18782. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18783. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18784. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18785. * @returns the emitter
  18786. */
  18787. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18788. /**
  18789. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18790. * @param radius The radius of the cone to emit from
  18791. * @param angle The base angle of the cone
  18792. * @returns the emitter
  18793. */
  18794. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18795. /**
  18796. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18797. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18798. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18799. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18800. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18801. * @returns the emitter
  18802. */
  18803. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18804. /**
  18805. * Get hosting scene
  18806. * @returns the scene
  18807. */
  18808. getScene(): Scene;
  18809. }
  18810. }
  18811. declare module BABYLON {
  18812. /**
  18813. * Creates an instance based on a source mesh.
  18814. */
  18815. export class InstancedMesh extends AbstractMesh {
  18816. private _sourceMesh;
  18817. private _currentLOD;
  18818. /** @hidden */
  18819. _indexInSourceMeshInstanceArray: number;
  18820. constructor(name: string, source: Mesh);
  18821. /**
  18822. * Returns the string "InstancedMesh".
  18823. */
  18824. getClassName(): string;
  18825. /** Gets the list of lights affecting that mesh */
  18826. readonly lightSources: Light[];
  18827. _resyncLightSources(): void;
  18828. _resyncLighSource(light: Light): void;
  18829. _removeLightSource(light: Light, dispose: boolean): void;
  18830. /**
  18831. * If the source mesh receives shadows
  18832. */
  18833. readonly receiveShadows: boolean;
  18834. /**
  18835. * The material of the source mesh
  18836. */
  18837. readonly material: Nullable<Material>;
  18838. /**
  18839. * Visibility of the source mesh
  18840. */
  18841. readonly visibility: number;
  18842. /**
  18843. * Skeleton of the source mesh
  18844. */
  18845. readonly skeleton: Nullable<Skeleton>;
  18846. /**
  18847. * Rendering ground id of the source mesh
  18848. */
  18849. renderingGroupId: number;
  18850. /**
  18851. * Returns the total number of vertices (integer).
  18852. */
  18853. getTotalVertices(): number;
  18854. /**
  18855. * Returns a positive integer : the total number of indices in this mesh geometry.
  18856. * @returns the numner of indices or zero if the mesh has no geometry.
  18857. */
  18858. getTotalIndices(): number;
  18859. /**
  18860. * The source mesh of the instance
  18861. */
  18862. readonly sourceMesh: Mesh;
  18863. /**
  18864. * Is this node ready to be used/rendered
  18865. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18866. * @return {boolean} is it ready
  18867. */
  18868. isReady(completeCheck?: boolean): boolean;
  18869. /**
  18870. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18871. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18872. * @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.
  18873. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18874. */
  18875. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18876. /**
  18877. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18878. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18879. * The `data` are either a numeric array either a Float32Array.
  18880. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18881. * 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).
  18882. * Note that a new underlying VertexBuffer object is created each call.
  18883. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18884. *
  18885. * Possible `kind` values :
  18886. * - VertexBuffer.PositionKind
  18887. * - VertexBuffer.UVKind
  18888. * - VertexBuffer.UV2Kind
  18889. * - VertexBuffer.UV3Kind
  18890. * - VertexBuffer.UV4Kind
  18891. * - VertexBuffer.UV5Kind
  18892. * - VertexBuffer.UV6Kind
  18893. * - VertexBuffer.ColorKind
  18894. * - VertexBuffer.MatricesIndicesKind
  18895. * - VertexBuffer.MatricesIndicesExtraKind
  18896. * - VertexBuffer.MatricesWeightsKind
  18897. * - VertexBuffer.MatricesWeightsExtraKind
  18898. *
  18899. * Returns the Mesh.
  18900. */
  18901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18902. /**
  18903. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18904. * If the mesh has no geometry, it is simply returned as it is.
  18905. * The `data` are either a numeric array either a Float32Array.
  18906. * No new underlying VertexBuffer object is created.
  18907. * 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.
  18908. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18909. *
  18910. * Possible `kind` values :
  18911. * - VertexBuffer.PositionKind
  18912. * - VertexBuffer.UVKind
  18913. * - VertexBuffer.UV2Kind
  18914. * - VertexBuffer.UV3Kind
  18915. * - VertexBuffer.UV4Kind
  18916. * - VertexBuffer.UV5Kind
  18917. * - VertexBuffer.UV6Kind
  18918. * - VertexBuffer.ColorKind
  18919. * - VertexBuffer.MatricesIndicesKind
  18920. * - VertexBuffer.MatricesIndicesExtraKind
  18921. * - VertexBuffer.MatricesWeightsKind
  18922. * - VertexBuffer.MatricesWeightsExtraKind
  18923. *
  18924. * Returns the Mesh.
  18925. */
  18926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18927. /**
  18928. * Sets the mesh indices.
  18929. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18930. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18931. * This method creates a new index buffer each call.
  18932. * Returns the Mesh.
  18933. */
  18934. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18935. /**
  18936. * Boolean : True if the mesh owns the requested kind of data.
  18937. */
  18938. isVerticesDataPresent(kind: string): boolean;
  18939. /**
  18940. * Returns an array of indices (IndicesArray).
  18941. */
  18942. getIndices(): Nullable<IndicesArray>;
  18943. readonly _positions: Nullable<Vector3[]>;
  18944. /**
  18945. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18946. * This means the mesh underlying bounding box and sphere are recomputed.
  18947. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18948. * @returns the current mesh
  18949. */
  18950. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18951. /** @hidden */
  18952. _preActivate(): InstancedMesh;
  18953. /** @hidden */
  18954. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18955. /** @hidden */
  18956. _postActivate(): void;
  18957. getWorldMatrix(): Matrix;
  18958. readonly isAnInstance: boolean;
  18959. /**
  18960. * Returns the current associated LOD AbstractMesh.
  18961. */
  18962. getLOD(camera: Camera): AbstractMesh;
  18963. /** @hidden */
  18964. _syncSubMeshes(): InstancedMesh;
  18965. /** @hidden */
  18966. _generatePointsArray(): boolean;
  18967. /**
  18968. * Creates a new InstancedMesh from the current mesh.
  18969. * - name (string) : the cloned mesh name
  18970. * - newParent (optional Node) : the optional Node to parent the clone to.
  18971. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18972. *
  18973. * Returns the clone.
  18974. */
  18975. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18976. /**
  18977. * Disposes the InstancedMesh.
  18978. * Returns nothing.
  18979. */
  18980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18981. }
  18982. interface Mesh {
  18983. /**
  18984. * Register a custom buffer that will be instanced
  18985. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18986. * @param kind defines the buffer kind
  18987. * @param stride defines the stride in floats
  18988. */
  18989. registerInstancedBuffer(kind: string, stride: number): void;
  18990. /** @hidden */
  18991. _userInstancedBuffersStorage: {
  18992. data: {
  18993. [key: string]: Float32Array;
  18994. };
  18995. sizes: {
  18996. [key: string]: number;
  18997. };
  18998. vertexBuffers: {
  18999. [key: string]: Nullable<VertexBuffer>;
  19000. };
  19001. strides: {
  19002. [key: string]: number;
  19003. };
  19004. };
  19005. }
  19006. interface AbstractMesh {
  19007. /**
  19008. * Object used to store instanced buffers defined by user
  19009. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19010. */
  19011. instancedBuffers: {
  19012. [key: string]: any;
  19013. };
  19014. }
  19015. }
  19016. declare module BABYLON {
  19017. /**
  19018. * Defines the options associated with the creation of a shader material.
  19019. */
  19020. export interface IShaderMaterialOptions {
  19021. /**
  19022. * Does the material work in alpha blend mode
  19023. */
  19024. needAlphaBlending: boolean;
  19025. /**
  19026. * Does the material work in alpha test mode
  19027. */
  19028. needAlphaTesting: boolean;
  19029. /**
  19030. * The list of attribute names used in the shader
  19031. */
  19032. attributes: string[];
  19033. /**
  19034. * The list of unifrom names used in the shader
  19035. */
  19036. uniforms: string[];
  19037. /**
  19038. * The list of UBO names used in the shader
  19039. */
  19040. uniformBuffers: string[];
  19041. /**
  19042. * The list of sampler names used in the shader
  19043. */
  19044. samplers: string[];
  19045. /**
  19046. * The list of defines used in the shader
  19047. */
  19048. defines: string[];
  19049. }
  19050. /**
  19051. * 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.
  19052. *
  19053. * This returned material effects how the mesh will look based on the code in the shaders.
  19054. *
  19055. * @see http://doc.babylonjs.com/how_to/shader_material
  19056. */
  19057. export class ShaderMaterial extends Material {
  19058. private _shaderPath;
  19059. private _options;
  19060. private _textures;
  19061. private _textureArrays;
  19062. private _floats;
  19063. private _ints;
  19064. private _floatsArrays;
  19065. private _colors3;
  19066. private _colors3Arrays;
  19067. private _colors4;
  19068. private _colors4Arrays;
  19069. private _vectors2;
  19070. private _vectors3;
  19071. private _vectors4;
  19072. private _matrices;
  19073. private _matrices3x3;
  19074. private _matrices2x2;
  19075. private _vectors2Arrays;
  19076. private _vectors3Arrays;
  19077. private _vectors4Arrays;
  19078. private _cachedWorldViewMatrix;
  19079. private _cachedWorldViewProjectionMatrix;
  19080. private _renderId;
  19081. /**
  19082. * Instantiate a new shader material.
  19083. * 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.
  19084. * This returned material effects how the mesh will look based on the code in the shaders.
  19085. * @see http://doc.babylonjs.com/how_to/shader_material
  19086. * @param name Define the name of the material in the scene
  19087. * @param scene Define the scene the material belongs to
  19088. * @param shaderPath Defines the route to the shader code in one of three ways:
  19089. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19090. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19091. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19092. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19093. * @param options Define the options used to create the shader
  19094. */
  19095. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19096. /**
  19097. * Gets the options used to compile the shader.
  19098. * They can be modified to trigger a new compilation
  19099. */
  19100. readonly options: IShaderMaterialOptions;
  19101. /**
  19102. * Gets the current class name of the material e.g. "ShaderMaterial"
  19103. * Mainly use in serialization.
  19104. * @returns the class name
  19105. */
  19106. getClassName(): string;
  19107. /**
  19108. * Specifies if the material will require alpha blending
  19109. * @returns a boolean specifying if alpha blending is needed
  19110. */
  19111. needAlphaBlending(): boolean;
  19112. /**
  19113. * Specifies if this material should be rendered in alpha test mode
  19114. * @returns a boolean specifying if an alpha test is needed.
  19115. */
  19116. needAlphaTesting(): boolean;
  19117. private _checkUniform;
  19118. /**
  19119. * Set a texture in the shader.
  19120. * @param name Define the name of the uniform samplers as defined in the shader
  19121. * @param texture Define the texture to bind to this sampler
  19122. * @return the material itself allowing "fluent" like uniform updates
  19123. */
  19124. setTexture(name: string, texture: Texture): ShaderMaterial;
  19125. /**
  19126. * Set a texture array in the shader.
  19127. * @param name Define the name of the uniform sampler array as defined in the shader
  19128. * @param textures Define the list of textures to bind to this sampler
  19129. * @return the material itself allowing "fluent" like uniform updates
  19130. */
  19131. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19132. /**
  19133. * Set a float in the shader.
  19134. * @param name Define the name of the uniform as defined in the shader
  19135. * @param value Define the value to give to the uniform
  19136. * @return the material itself allowing "fluent" like uniform updates
  19137. */
  19138. setFloat(name: string, value: number): ShaderMaterial;
  19139. /**
  19140. * Set a int in the shader.
  19141. * @param name Define the name of the uniform as defined in the shader
  19142. * @param value Define the value to give to the uniform
  19143. * @return the material itself allowing "fluent" like uniform updates
  19144. */
  19145. setInt(name: string, value: number): ShaderMaterial;
  19146. /**
  19147. * Set an array of floats in the shader.
  19148. * @param name Define the name of the uniform as defined in the shader
  19149. * @param value Define the value to give to the uniform
  19150. * @return the material itself allowing "fluent" like uniform updates
  19151. */
  19152. setFloats(name: string, value: number[]): ShaderMaterial;
  19153. /**
  19154. * Set a vec3 in the shader from a Color3.
  19155. * @param name Define the name of the uniform as defined in the shader
  19156. * @param value Define the value to give to the uniform
  19157. * @return the material itself allowing "fluent" like uniform updates
  19158. */
  19159. setColor3(name: string, value: Color3): ShaderMaterial;
  19160. /**
  19161. * Set a vec3 array in the shader from a Color3 array.
  19162. * @param name Define the name of the uniform as defined in the shader
  19163. * @param value Define the value to give to the uniform
  19164. * @return the material itself allowing "fluent" like uniform updates
  19165. */
  19166. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19167. /**
  19168. * Set a vec4 in the shader from a Color4.
  19169. * @param name Define the name of the uniform as defined in the shader
  19170. * @param value Define the value to give to the uniform
  19171. * @return the material itself allowing "fluent" like uniform updates
  19172. */
  19173. setColor4(name: string, value: Color4): ShaderMaterial;
  19174. /**
  19175. * Set a vec4 array in the shader from a Color4 array.
  19176. * @param name Define the name of the uniform as defined in the shader
  19177. * @param value Define the value to give to the uniform
  19178. * @return the material itself allowing "fluent" like uniform updates
  19179. */
  19180. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19181. /**
  19182. * Set a vec2 in the shader from a Vector2.
  19183. * @param name Define the name of the uniform as defined in the shader
  19184. * @param value Define the value to give to the uniform
  19185. * @return the material itself allowing "fluent" like uniform updates
  19186. */
  19187. setVector2(name: string, value: Vector2): ShaderMaterial;
  19188. /**
  19189. * Set a vec3 in the shader from a Vector3.
  19190. * @param name Define the name of the uniform as defined in the shader
  19191. * @param value Define the value to give to the uniform
  19192. * @return the material itself allowing "fluent" like uniform updates
  19193. */
  19194. setVector3(name: string, value: Vector3): ShaderMaterial;
  19195. /**
  19196. * Set a vec4 in the shader from a Vector4.
  19197. * @param name Define the name of the uniform as defined in the shader
  19198. * @param value Define the value to give to the uniform
  19199. * @return the material itself allowing "fluent" like uniform updates
  19200. */
  19201. setVector4(name: string, value: Vector4): ShaderMaterial;
  19202. /**
  19203. * Set a mat4 in the shader from a Matrix.
  19204. * @param name Define the name of the uniform as defined in the shader
  19205. * @param value Define the value to give to the uniform
  19206. * @return the material itself allowing "fluent" like uniform updates
  19207. */
  19208. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19209. /**
  19210. * Set a mat3 in the shader from a Float32Array.
  19211. * @param name Define the name of the uniform as defined in the shader
  19212. * @param value Define the value to give to the uniform
  19213. * @return the material itself allowing "fluent" like uniform updates
  19214. */
  19215. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19216. /**
  19217. * Set a mat2 in the shader from a Float32Array.
  19218. * @param name Define the name of the uniform as defined in the shader
  19219. * @param value Define the value to give to the uniform
  19220. * @return the material itself allowing "fluent" like uniform updates
  19221. */
  19222. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19223. /**
  19224. * Set a vec2 array in the shader from a number array.
  19225. * @param name Define the name of the uniform as defined in the shader
  19226. * @param value Define the value to give to the uniform
  19227. * @return the material itself allowing "fluent" like uniform updates
  19228. */
  19229. setArray2(name: string, value: number[]): ShaderMaterial;
  19230. /**
  19231. * Set a vec3 array in the shader from a number array.
  19232. * @param name Define the name of the uniform as defined in the shader
  19233. * @param value Define the value to give to the uniform
  19234. * @return the material itself allowing "fluent" like uniform updates
  19235. */
  19236. setArray3(name: string, value: number[]): ShaderMaterial;
  19237. /**
  19238. * Set a vec4 array in the shader from a number array.
  19239. * @param name Define the name of the uniform as defined in the shader
  19240. * @param value Define the value to give to the uniform
  19241. * @return the material itself allowing "fluent" like uniform updates
  19242. */
  19243. setArray4(name: string, value: number[]): ShaderMaterial;
  19244. private _checkCache;
  19245. /**
  19246. * Specifies that the submesh is ready to be used
  19247. * @param mesh defines the mesh to check
  19248. * @param subMesh defines which submesh to check
  19249. * @param useInstances specifies that instances should be used
  19250. * @returns a boolean indicating that the submesh is ready or not
  19251. */
  19252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19253. /**
  19254. * Checks if the material is ready to render the requested mesh
  19255. * @param mesh Define the mesh to render
  19256. * @param useInstances Define whether or not the material is used with instances
  19257. * @returns true if ready, otherwise false
  19258. */
  19259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19260. /**
  19261. * Binds the world matrix to the material
  19262. * @param world defines the world transformation matrix
  19263. */
  19264. bindOnlyWorldMatrix(world: Matrix): void;
  19265. /**
  19266. * Binds the material to the mesh
  19267. * @param world defines the world transformation matrix
  19268. * @param mesh defines the mesh to bind the material to
  19269. */
  19270. bind(world: Matrix, mesh?: Mesh): void;
  19271. /**
  19272. * Gets the active textures from the material
  19273. * @returns an array of textures
  19274. */
  19275. getActiveTextures(): BaseTexture[];
  19276. /**
  19277. * Specifies if the material uses a texture
  19278. * @param texture defines the texture to check against the material
  19279. * @returns a boolean specifying if the material uses the texture
  19280. */
  19281. hasTexture(texture: BaseTexture): boolean;
  19282. /**
  19283. * Makes a duplicate of the material, and gives it a new name
  19284. * @param name defines the new name for the duplicated material
  19285. * @returns the cloned material
  19286. */
  19287. clone(name: string): ShaderMaterial;
  19288. /**
  19289. * Disposes the material
  19290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19292. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19293. */
  19294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19295. /**
  19296. * Serializes this material in a JSON representation
  19297. * @returns the serialized material object
  19298. */
  19299. serialize(): any;
  19300. /**
  19301. * Creates a shader material from parsed shader material data
  19302. * @param source defines the JSON represnetation of the material
  19303. * @param scene defines the hosting scene
  19304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19305. * @returns a new material
  19306. */
  19307. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19308. }
  19309. }
  19310. declare module BABYLON {
  19311. /** @hidden */
  19312. export var colorPixelShader: {
  19313. name: string;
  19314. shader: string;
  19315. };
  19316. }
  19317. declare module BABYLON {
  19318. /** @hidden */
  19319. export var colorVertexShader: {
  19320. name: string;
  19321. shader: string;
  19322. };
  19323. }
  19324. declare module BABYLON {
  19325. /**
  19326. * Line mesh
  19327. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19328. */
  19329. export class LinesMesh extends Mesh {
  19330. /**
  19331. * If vertex color should be applied to the mesh
  19332. */
  19333. readonly useVertexColor?: boolean | undefined;
  19334. /**
  19335. * If vertex alpha should be applied to the mesh
  19336. */
  19337. readonly useVertexAlpha?: boolean | undefined;
  19338. /**
  19339. * Color of the line (Default: White)
  19340. */
  19341. color: Color3;
  19342. /**
  19343. * Alpha of the line (Default: 1)
  19344. */
  19345. alpha: number;
  19346. /**
  19347. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19348. * This margin is expressed in world space coordinates, so its value may vary.
  19349. * Default value is 0.1
  19350. */
  19351. intersectionThreshold: number;
  19352. private _colorShader;
  19353. private color4;
  19354. /**
  19355. * Creates a new LinesMesh
  19356. * @param name defines the name
  19357. * @param scene defines the hosting scene
  19358. * @param parent defines the parent mesh if any
  19359. * @param source defines the optional source LinesMesh used to clone data from
  19360. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19361. * When false, achieved by calling a clone(), also passing False.
  19362. * This will make creation of children, recursive.
  19363. * @param useVertexColor defines if this LinesMesh supports vertex color
  19364. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19365. */
  19366. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19367. /**
  19368. * If vertex color should be applied to the mesh
  19369. */
  19370. useVertexColor?: boolean | undefined,
  19371. /**
  19372. * If vertex alpha should be applied to the mesh
  19373. */
  19374. useVertexAlpha?: boolean | undefined);
  19375. private _addClipPlaneDefine;
  19376. private _removeClipPlaneDefine;
  19377. isReady(): boolean;
  19378. /**
  19379. * Returns the string "LineMesh"
  19380. */
  19381. getClassName(): string;
  19382. /**
  19383. * @hidden
  19384. */
  19385. /**
  19386. * @hidden
  19387. */
  19388. material: Material;
  19389. /**
  19390. * @hidden
  19391. */
  19392. readonly checkCollisions: boolean;
  19393. /** @hidden */
  19394. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19395. /** @hidden */
  19396. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19397. /**
  19398. * Disposes of the line mesh
  19399. * @param doNotRecurse If children should be disposed
  19400. */
  19401. dispose(doNotRecurse?: boolean): void;
  19402. /**
  19403. * Returns a new LineMesh object cloned from the current one.
  19404. */
  19405. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19406. /**
  19407. * Creates a new InstancedLinesMesh object from the mesh model.
  19408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19409. * @param name defines the name of the new instance
  19410. * @returns a new InstancedLinesMesh
  19411. */
  19412. createInstance(name: string): InstancedLinesMesh;
  19413. }
  19414. /**
  19415. * Creates an instance based on a source LinesMesh
  19416. */
  19417. export class InstancedLinesMesh extends InstancedMesh {
  19418. /**
  19419. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19420. * This margin is expressed in world space coordinates, so its value may vary.
  19421. * Initilized with the intersectionThreshold value of the source LinesMesh
  19422. */
  19423. intersectionThreshold: number;
  19424. constructor(name: string, source: LinesMesh);
  19425. /**
  19426. * Returns the string "InstancedLinesMesh".
  19427. */
  19428. getClassName(): string;
  19429. }
  19430. }
  19431. declare module BABYLON {
  19432. /** @hidden */
  19433. export var linePixelShader: {
  19434. name: string;
  19435. shader: string;
  19436. };
  19437. }
  19438. declare module BABYLON {
  19439. /** @hidden */
  19440. export var lineVertexShader: {
  19441. name: string;
  19442. shader: string;
  19443. };
  19444. }
  19445. declare module BABYLON {
  19446. interface AbstractMesh {
  19447. /**
  19448. * Gets the edgesRenderer associated with the mesh
  19449. */
  19450. edgesRenderer: Nullable<EdgesRenderer>;
  19451. }
  19452. interface LinesMesh {
  19453. /**
  19454. * Enables the edge rendering mode on the mesh.
  19455. * This mode makes the mesh edges visible
  19456. * @param epsilon defines the maximal distance between two angles to detect a face
  19457. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19458. * @returns the currentAbstractMesh
  19459. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19460. */
  19461. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19462. }
  19463. interface InstancedLinesMesh {
  19464. /**
  19465. * Enables the edge rendering mode on the mesh.
  19466. * This mode makes the mesh edges visible
  19467. * @param epsilon defines the maximal distance between two angles to detect a face
  19468. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19469. * @returns the current InstancedLinesMesh
  19470. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19471. */
  19472. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19473. }
  19474. /**
  19475. * Defines the minimum contract an Edges renderer should follow.
  19476. */
  19477. export interface IEdgesRenderer extends IDisposable {
  19478. /**
  19479. * Gets or sets a boolean indicating if the edgesRenderer is active
  19480. */
  19481. isEnabled: boolean;
  19482. /**
  19483. * Renders the edges of the attached mesh,
  19484. */
  19485. render(): void;
  19486. /**
  19487. * Checks wether or not the edges renderer is ready to render.
  19488. * @return true if ready, otherwise false.
  19489. */
  19490. isReady(): boolean;
  19491. }
  19492. /**
  19493. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19494. */
  19495. export class EdgesRenderer implements IEdgesRenderer {
  19496. /**
  19497. * Define the size of the edges with an orthographic camera
  19498. */
  19499. edgesWidthScalerForOrthographic: number;
  19500. /**
  19501. * Define the size of the edges with a perspective camera
  19502. */
  19503. edgesWidthScalerForPerspective: number;
  19504. protected _source: AbstractMesh;
  19505. protected _linesPositions: number[];
  19506. protected _linesNormals: number[];
  19507. protected _linesIndices: number[];
  19508. protected _epsilon: number;
  19509. protected _indicesCount: number;
  19510. protected _lineShader: ShaderMaterial;
  19511. protected _ib: DataBuffer;
  19512. protected _buffers: {
  19513. [key: string]: Nullable<VertexBuffer>;
  19514. };
  19515. protected _checkVerticesInsteadOfIndices: boolean;
  19516. private _meshRebuildObserver;
  19517. private _meshDisposeObserver;
  19518. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19519. isEnabled: boolean;
  19520. /**
  19521. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19522. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19523. * @param source Mesh used to create edges
  19524. * @param epsilon sum of angles in adjacency to check for edge
  19525. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19526. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19527. */
  19528. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19529. protected _prepareRessources(): void;
  19530. /** @hidden */
  19531. _rebuild(): void;
  19532. /**
  19533. * Releases the required resources for the edges renderer
  19534. */
  19535. dispose(): void;
  19536. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19537. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19538. /**
  19539. * Checks if the pair of p0 and p1 is en edge
  19540. * @param faceIndex
  19541. * @param edge
  19542. * @param faceNormals
  19543. * @param p0
  19544. * @param p1
  19545. * @private
  19546. */
  19547. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19548. /**
  19549. * push line into the position, normal and index buffer
  19550. * @protected
  19551. */
  19552. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19553. /**
  19554. * Generates lines edges from adjacencjes
  19555. * @private
  19556. */
  19557. _generateEdgesLines(): void;
  19558. /**
  19559. * Checks wether or not the edges renderer is ready to render.
  19560. * @return true if ready, otherwise false.
  19561. */
  19562. isReady(): boolean;
  19563. /**
  19564. * Renders the edges of the attached mesh,
  19565. */
  19566. render(): void;
  19567. }
  19568. /**
  19569. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19570. */
  19571. export class LineEdgesRenderer extends EdgesRenderer {
  19572. /**
  19573. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19574. * @param source LineMesh used to generate edges
  19575. * @param epsilon not important (specified angle for edge detection)
  19576. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19577. */
  19578. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19579. /**
  19580. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19581. */
  19582. _generateEdgesLines(): void;
  19583. }
  19584. }
  19585. declare module BABYLON {
  19586. /**
  19587. * This represents the object necessary to create a rendering group.
  19588. * This is exclusively used and created by the rendering manager.
  19589. * To modify the behavior, you use the available helpers in your scene or meshes.
  19590. * @hidden
  19591. */
  19592. export class RenderingGroup {
  19593. index: number;
  19594. private static _zeroVector;
  19595. private _scene;
  19596. private _opaqueSubMeshes;
  19597. private _transparentSubMeshes;
  19598. private _alphaTestSubMeshes;
  19599. private _depthOnlySubMeshes;
  19600. private _particleSystems;
  19601. private _spriteManagers;
  19602. private _opaqueSortCompareFn;
  19603. private _alphaTestSortCompareFn;
  19604. private _transparentSortCompareFn;
  19605. private _renderOpaque;
  19606. private _renderAlphaTest;
  19607. private _renderTransparent;
  19608. /** @hidden */
  19609. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19610. onBeforeTransparentRendering: () => void;
  19611. /**
  19612. * Set the opaque sort comparison function.
  19613. * If null the sub meshes will be render in the order they were created
  19614. */
  19615. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19616. /**
  19617. * Set the alpha test sort comparison function.
  19618. * If null the sub meshes will be render in the order they were created
  19619. */
  19620. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19621. /**
  19622. * Set the transparent sort comparison function.
  19623. * If null the sub meshes will be render in the order they were created
  19624. */
  19625. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19626. /**
  19627. * Creates a new rendering group.
  19628. * @param index The rendering group index
  19629. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19630. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19631. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19632. */
  19633. 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>);
  19634. /**
  19635. * Render all the sub meshes contained in the group.
  19636. * @param customRenderFunction Used to override the default render behaviour of the group.
  19637. * @returns true if rendered some submeshes.
  19638. */
  19639. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19640. /**
  19641. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19642. * @param subMeshes The submeshes to render
  19643. */
  19644. private renderOpaqueSorted;
  19645. /**
  19646. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19647. * @param subMeshes The submeshes to render
  19648. */
  19649. private renderAlphaTestSorted;
  19650. /**
  19651. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19652. * @param subMeshes The submeshes to render
  19653. */
  19654. private renderTransparentSorted;
  19655. /**
  19656. * Renders the submeshes in a specified order.
  19657. * @param subMeshes The submeshes to sort before render
  19658. * @param sortCompareFn The comparison function use to sort
  19659. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19660. * @param transparent Specifies to activate blending if true
  19661. */
  19662. private static renderSorted;
  19663. /**
  19664. * Renders the submeshes in the order they were dispatched (no sort applied).
  19665. * @param subMeshes The submeshes to render
  19666. */
  19667. private static renderUnsorted;
  19668. /**
  19669. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19670. * are rendered back to front if in the same alpha index.
  19671. *
  19672. * @param a The first submesh
  19673. * @param b The second submesh
  19674. * @returns The result of the comparison
  19675. */
  19676. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19677. /**
  19678. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19679. * are rendered back to front.
  19680. *
  19681. * @param a The first submesh
  19682. * @param b The second submesh
  19683. * @returns The result of the comparison
  19684. */
  19685. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19686. /**
  19687. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19688. * are rendered front to back (prevent overdraw).
  19689. *
  19690. * @param a The first submesh
  19691. * @param b The second submesh
  19692. * @returns The result of the comparison
  19693. */
  19694. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19695. /**
  19696. * Resets the different lists of submeshes to prepare a new frame.
  19697. */
  19698. prepare(): void;
  19699. dispose(): void;
  19700. /**
  19701. * Inserts the submesh in its correct queue depending on its material.
  19702. * @param subMesh The submesh to dispatch
  19703. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19704. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19705. */
  19706. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19707. dispatchSprites(spriteManager: ISpriteManager): void;
  19708. dispatchParticles(particleSystem: IParticleSystem): void;
  19709. private _renderParticles;
  19710. private _renderSprites;
  19711. }
  19712. }
  19713. declare module BABYLON {
  19714. /**
  19715. * Interface describing the different options available in the rendering manager
  19716. * regarding Auto Clear between groups.
  19717. */
  19718. export interface IRenderingManagerAutoClearSetup {
  19719. /**
  19720. * Defines whether or not autoclear is enable.
  19721. */
  19722. autoClear: boolean;
  19723. /**
  19724. * Defines whether or not to autoclear the depth buffer.
  19725. */
  19726. depth: boolean;
  19727. /**
  19728. * Defines whether or not to autoclear the stencil buffer.
  19729. */
  19730. stencil: boolean;
  19731. }
  19732. /**
  19733. * This class is used by the onRenderingGroupObservable
  19734. */
  19735. export class RenderingGroupInfo {
  19736. /**
  19737. * The Scene that being rendered
  19738. */
  19739. scene: Scene;
  19740. /**
  19741. * The camera currently used for the rendering pass
  19742. */
  19743. camera: Nullable<Camera>;
  19744. /**
  19745. * The ID of the renderingGroup being processed
  19746. */
  19747. renderingGroupId: number;
  19748. }
  19749. /**
  19750. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19751. * It is enable to manage the different groups as well as the different necessary sort functions.
  19752. * This should not be used directly aside of the few static configurations
  19753. */
  19754. export class RenderingManager {
  19755. /**
  19756. * The max id used for rendering groups (not included)
  19757. */
  19758. static MAX_RENDERINGGROUPS: number;
  19759. /**
  19760. * The min id used for rendering groups (included)
  19761. */
  19762. static MIN_RENDERINGGROUPS: number;
  19763. /**
  19764. * Used to globally prevent autoclearing scenes.
  19765. */
  19766. static AUTOCLEAR: boolean;
  19767. /**
  19768. * @hidden
  19769. */
  19770. _useSceneAutoClearSetup: boolean;
  19771. private _scene;
  19772. private _renderingGroups;
  19773. private _depthStencilBufferAlreadyCleaned;
  19774. private _autoClearDepthStencil;
  19775. private _customOpaqueSortCompareFn;
  19776. private _customAlphaTestSortCompareFn;
  19777. private _customTransparentSortCompareFn;
  19778. private _renderingGroupInfo;
  19779. /**
  19780. * Instantiates a new rendering group for a particular scene
  19781. * @param scene Defines the scene the groups belongs to
  19782. */
  19783. constructor(scene: Scene);
  19784. private _clearDepthStencilBuffer;
  19785. /**
  19786. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19787. * @hidden
  19788. */
  19789. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19790. /**
  19791. * Resets the different information of the group to prepare a new frame
  19792. * @hidden
  19793. */
  19794. reset(): void;
  19795. /**
  19796. * Dispose and release the group and its associated resources.
  19797. * @hidden
  19798. */
  19799. dispose(): void;
  19800. /**
  19801. * Clear the info related to rendering groups preventing retention points during dispose.
  19802. */
  19803. freeRenderingGroups(): void;
  19804. private _prepareRenderingGroup;
  19805. /**
  19806. * Add a sprite manager to the rendering manager in order to render it this frame.
  19807. * @param spriteManager Define the sprite manager to render
  19808. */
  19809. dispatchSprites(spriteManager: ISpriteManager): void;
  19810. /**
  19811. * Add a particle system to the rendering manager in order to render it this frame.
  19812. * @param particleSystem Define the particle system to render
  19813. */
  19814. dispatchParticles(particleSystem: IParticleSystem): void;
  19815. /**
  19816. * Add a submesh to the manager in order to render it this frame
  19817. * @param subMesh The submesh to dispatch
  19818. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19819. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19820. */
  19821. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19822. /**
  19823. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19824. * This allowed control for front to back rendering or reversly depending of the special needs.
  19825. *
  19826. * @param renderingGroupId The rendering group id corresponding to its index
  19827. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19828. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19829. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19830. */
  19831. 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;
  19832. /**
  19833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19834. *
  19835. * @param renderingGroupId The rendering group id corresponding to its index
  19836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19837. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19838. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19839. */
  19840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19841. /**
  19842. * Gets the current auto clear configuration for one rendering group of the rendering
  19843. * manager.
  19844. * @param index the rendering group index to get the information for
  19845. * @returns The auto clear setup for the requested rendering group
  19846. */
  19847. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19848. }
  19849. }
  19850. declare module BABYLON {
  19851. /**
  19852. * This Helps creating a texture that will be created from a camera in your scene.
  19853. * It is basically a dynamic texture that could be used to create special effects for instance.
  19854. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19855. */
  19856. export class RenderTargetTexture extends Texture {
  19857. isCube: boolean;
  19858. /**
  19859. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19860. */
  19861. static readonly REFRESHRATE_RENDER_ONCE: number;
  19862. /**
  19863. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19864. */
  19865. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19866. /**
  19867. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19868. * the central point of your effect and can save a lot of performances.
  19869. */
  19870. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19871. /**
  19872. * Use this predicate to dynamically define the list of mesh you want to render.
  19873. * If set, the renderList property will be overwritten.
  19874. */
  19875. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19876. private _renderList;
  19877. /**
  19878. * Use this list to define the list of mesh you want to render.
  19879. */
  19880. renderList: Nullable<Array<AbstractMesh>>;
  19881. private _hookArray;
  19882. /**
  19883. * Define if particles should be rendered in your texture.
  19884. */
  19885. renderParticles: boolean;
  19886. /**
  19887. * Define if sprites should be rendered in your texture.
  19888. */
  19889. renderSprites: boolean;
  19890. /**
  19891. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19892. */
  19893. coordinatesMode: number;
  19894. /**
  19895. * Define the camera used to render the texture.
  19896. */
  19897. activeCamera: Nullable<Camera>;
  19898. /**
  19899. * Override the render function of the texture with your own one.
  19900. */
  19901. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19902. /**
  19903. * Define if camera post processes should be use while rendering the texture.
  19904. */
  19905. useCameraPostProcesses: boolean;
  19906. /**
  19907. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19908. */
  19909. ignoreCameraViewport: boolean;
  19910. private _postProcessManager;
  19911. private _postProcesses;
  19912. private _resizeObserver;
  19913. /**
  19914. * An event triggered when the texture is unbind.
  19915. */
  19916. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19917. /**
  19918. * An event triggered when the texture is unbind.
  19919. */
  19920. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19921. private _onAfterUnbindObserver;
  19922. /**
  19923. * Set a after unbind callback in the texture.
  19924. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19925. */
  19926. onAfterUnbind: () => void;
  19927. /**
  19928. * An event triggered before rendering the texture
  19929. */
  19930. onBeforeRenderObservable: Observable<number>;
  19931. private _onBeforeRenderObserver;
  19932. /**
  19933. * Set a before render callback in the texture.
  19934. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19935. */
  19936. onBeforeRender: (faceIndex: number) => void;
  19937. /**
  19938. * An event triggered after rendering the texture
  19939. */
  19940. onAfterRenderObservable: Observable<number>;
  19941. private _onAfterRenderObserver;
  19942. /**
  19943. * Set a after render callback in the texture.
  19944. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19945. */
  19946. onAfterRender: (faceIndex: number) => void;
  19947. /**
  19948. * An event triggered after the texture clear
  19949. */
  19950. onClearObservable: Observable<Engine>;
  19951. private _onClearObserver;
  19952. /**
  19953. * Set a clear callback in the texture.
  19954. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19955. */
  19956. onClear: (Engine: Engine) => void;
  19957. /**
  19958. * An event triggered when the texture is resized.
  19959. */
  19960. onResizeObservable: Observable<RenderTargetTexture>;
  19961. /**
  19962. * Define the clear color of the Render Target if it should be different from the scene.
  19963. */
  19964. clearColor: Color4;
  19965. protected _size: number | {
  19966. width: number;
  19967. height: number;
  19968. };
  19969. protected _initialSizeParameter: number | {
  19970. width: number;
  19971. height: number;
  19972. } | {
  19973. ratio: number;
  19974. };
  19975. protected _sizeRatio: Nullable<number>;
  19976. /** @hidden */
  19977. _generateMipMaps: boolean;
  19978. protected _renderingManager: RenderingManager;
  19979. /** @hidden */
  19980. _waitingRenderList: string[];
  19981. protected _doNotChangeAspectRatio: boolean;
  19982. protected _currentRefreshId: number;
  19983. protected _refreshRate: number;
  19984. protected _textureMatrix: Matrix;
  19985. protected _samples: number;
  19986. protected _renderTargetOptions: RenderTargetCreationOptions;
  19987. /**
  19988. * Gets render target creation options that were used.
  19989. */
  19990. readonly renderTargetOptions: RenderTargetCreationOptions;
  19991. protected _engine: Engine;
  19992. protected _onRatioRescale(): void;
  19993. /**
  19994. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19995. * It must define where the camera used to render the texture is set
  19996. */
  19997. boundingBoxPosition: Vector3;
  19998. private _boundingBoxSize;
  19999. /**
  20000. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20001. * When defined, the cubemap will switch to local mode
  20002. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20003. * @example https://www.babylonjs-playground.com/#RNASML
  20004. */
  20005. boundingBoxSize: Vector3;
  20006. /**
  20007. * In case the RTT has been created with a depth texture, get the associated
  20008. * depth texture.
  20009. * Otherwise, return null.
  20010. */
  20011. depthStencilTexture: Nullable<InternalTexture>;
  20012. /**
  20013. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20014. * or used a shadow, depth texture...
  20015. * @param name The friendly name of the texture
  20016. * @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)
  20017. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20018. * @param generateMipMaps True if mip maps need to be generated after render.
  20019. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20020. * @param type The type of the buffer in the RTT (int, half float, float...)
  20021. * @param isCube True if a cube texture needs to be created
  20022. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20023. * @param generateDepthBuffer True to generate a depth buffer
  20024. * @param generateStencilBuffer True to generate a stencil buffer
  20025. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20026. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20027. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20028. */
  20029. constructor(name: string, size: number | {
  20030. width: number;
  20031. height: number;
  20032. } | {
  20033. ratio: number;
  20034. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20035. /**
  20036. * Creates a depth stencil texture.
  20037. * This is only available in WebGL 2 or with the depth texture extension available.
  20038. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20039. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20040. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20041. */
  20042. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20043. private _processSizeParameter;
  20044. /**
  20045. * Define the number of samples to use in case of MSAA.
  20046. * It defaults to one meaning no MSAA has been enabled.
  20047. */
  20048. samples: number;
  20049. /**
  20050. * Resets the refresh counter of the texture and start bak from scratch.
  20051. * Could be useful to regenerate the texture if it is setup to render only once.
  20052. */
  20053. resetRefreshCounter(): void;
  20054. /**
  20055. * Define the refresh rate of the texture or the rendering frequency.
  20056. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20057. */
  20058. refreshRate: number;
  20059. /**
  20060. * Adds a post process to the render target rendering passes.
  20061. * @param postProcess define the post process to add
  20062. */
  20063. addPostProcess(postProcess: PostProcess): void;
  20064. /**
  20065. * Clear all the post processes attached to the render target
  20066. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20067. */
  20068. clearPostProcesses(dispose?: boolean): void;
  20069. /**
  20070. * Remove one of the post process from the list of attached post processes to the texture
  20071. * @param postProcess define the post process to remove from the list
  20072. */
  20073. removePostProcess(postProcess: PostProcess): void;
  20074. /** @hidden */
  20075. _shouldRender(): boolean;
  20076. /**
  20077. * Gets the actual render size of the texture.
  20078. * @returns the width of the render size
  20079. */
  20080. getRenderSize(): number;
  20081. /**
  20082. * Gets the actual render width of the texture.
  20083. * @returns the width of the render size
  20084. */
  20085. getRenderWidth(): number;
  20086. /**
  20087. * Gets the actual render height of the texture.
  20088. * @returns the height of the render size
  20089. */
  20090. getRenderHeight(): number;
  20091. /**
  20092. * Get if the texture can be rescaled or not.
  20093. */
  20094. readonly canRescale: boolean;
  20095. /**
  20096. * Resize the texture using a ratio.
  20097. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20098. */
  20099. scale(ratio: number): void;
  20100. /**
  20101. * Get the texture reflection matrix used to rotate/transform the reflection.
  20102. * @returns the reflection matrix
  20103. */
  20104. getReflectionTextureMatrix(): Matrix;
  20105. /**
  20106. * Resize the texture to a new desired size.
  20107. * Be carrefull as it will recreate all the data in the new texture.
  20108. * @param size Define the new size. It can be:
  20109. * - a number for squared texture,
  20110. * - an object containing { width: number, height: number }
  20111. * - or an object containing a ratio { ratio: number }
  20112. */
  20113. resize(size: number | {
  20114. width: number;
  20115. height: number;
  20116. } | {
  20117. ratio: number;
  20118. }): void;
  20119. /**
  20120. * Renders all the objects from the render list into the texture.
  20121. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20122. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20123. */
  20124. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20125. private _bestReflectionRenderTargetDimension;
  20126. /**
  20127. * @hidden
  20128. * @param faceIndex face index to bind to if this is a cubetexture
  20129. */
  20130. _bindFrameBuffer(faceIndex?: number): void;
  20131. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20132. private renderToTarget;
  20133. /**
  20134. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20135. * This allowed control for front to back rendering or reversly depending of the special needs.
  20136. *
  20137. * @param renderingGroupId The rendering group id corresponding to its index
  20138. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20139. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20140. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20141. */
  20142. 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;
  20143. /**
  20144. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20145. *
  20146. * @param renderingGroupId The rendering group id corresponding to its index
  20147. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20148. */
  20149. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20150. /**
  20151. * Clones the texture.
  20152. * @returns the cloned texture
  20153. */
  20154. clone(): RenderTargetTexture;
  20155. /**
  20156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20157. * @returns The JSON representation of the texture
  20158. */
  20159. serialize(): any;
  20160. /**
  20161. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20162. */
  20163. disposeFramebufferObjects(): void;
  20164. /**
  20165. * Dispose the texture and release its associated resources.
  20166. */
  20167. dispose(): void;
  20168. /** @hidden */
  20169. _rebuild(): void;
  20170. /**
  20171. * Clear the info related to rendering groups preventing retention point in material dispose.
  20172. */
  20173. freeRenderingGroups(): void;
  20174. /**
  20175. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20176. * @returns the view count
  20177. */
  20178. getViewCount(): number;
  20179. }
  20180. }
  20181. declare module BABYLON {
  20182. /**
  20183. * Options for compiling materials.
  20184. */
  20185. export interface IMaterialCompilationOptions {
  20186. /**
  20187. * Defines whether clip planes are enabled.
  20188. */
  20189. clipPlane: boolean;
  20190. /**
  20191. * Defines whether instances are enabled.
  20192. */
  20193. useInstances: boolean;
  20194. }
  20195. /**
  20196. * Base class for the main features of a material in Babylon.js
  20197. */
  20198. export class Material implements IAnimatable {
  20199. /**
  20200. * Returns the triangle fill mode
  20201. */
  20202. static readonly TriangleFillMode: number;
  20203. /**
  20204. * Returns the wireframe mode
  20205. */
  20206. static readonly WireFrameFillMode: number;
  20207. /**
  20208. * Returns the point fill mode
  20209. */
  20210. static readonly PointFillMode: number;
  20211. /**
  20212. * Returns the point list draw mode
  20213. */
  20214. static readonly PointListDrawMode: number;
  20215. /**
  20216. * Returns the line list draw mode
  20217. */
  20218. static readonly LineListDrawMode: number;
  20219. /**
  20220. * Returns the line loop draw mode
  20221. */
  20222. static readonly LineLoopDrawMode: number;
  20223. /**
  20224. * Returns the line strip draw mode
  20225. */
  20226. static readonly LineStripDrawMode: number;
  20227. /**
  20228. * Returns the triangle strip draw mode
  20229. */
  20230. static readonly TriangleStripDrawMode: number;
  20231. /**
  20232. * Returns the triangle fan draw mode
  20233. */
  20234. static readonly TriangleFanDrawMode: number;
  20235. /**
  20236. * Stores the clock-wise side orientation
  20237. */
  20238. static readonly ClockWiseSideOrientation: number;
  20239. /**
  20240. * Stores the counter clock-wise side orientation
  20241. */
  20242. static readonly CounterClockWiseSideOrientation: number;
  20243. /**
  20244. * The dirty texture flag value
  20245. */
  20246. static readonly TextureDirtyFlag: number;
  20247. /**
  20248. * The dirty light flag value
  20249. */
  20250. static readonly LightDirtyFlag: number;
  20251. /**
  20252. * The dirty fresnel flag value
  20253. */
  20254. static readonly FresnelDirtyFlag: number;
  20255. /**
  20256. * The dirty attribute flag value
  20257. */
  20258. static readonly AttributesDirtyFlag: number;
  20259. /**
  20260. * The dirty misc flag value
  20261. */
  20262. static readonly MiscDirtyFlag: number;
  20263. /**
  20264. * The all dirty flag value
  20265. */
  20266. static readonly AllDirtyFlag: number;
  20267. /**
  20268. * The ID of the material
  20269. */
  20270. id: string;
  20271. /**
  20272. * Gets or sets the unique id of the material
  20273. */
  20274. uniqueId: number;
  20275. /**
  20276. * The name of the material
  20277. */
  20278. name: string;
  20279. /**
  20280. * Gets or sets user defined metadata
  20281. */
  20282. metadata: any;
  20283. /**
  20284. * For internal use only. Please do not use.
  20285. */
  20286. reservedDataStore: any;
  20287. /**
  20288. * Specifies if the ready state should be checked on each call
  20289. */
  20290. checkReadyOnEveryCall: boolean;
  20291. /**
  20292. * Specifies if the ready state should be checked once
  20293. */
  20294. checkReadyOnlyOnce: boolean;
  20295. /**
  20296. * The state of the material
  20297. */
  20298. state: string;
  20299. /**
  20300. * The alpha value of the material
  20301. */
  20302. protected _alpha: number;
  20303. /**
  20304. * List of inspectable custom properties (used by the Inspector)
  20305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20306. */
  20307. inspectableCustomProperties: IInspectable[];
  20308. /**
  20309. * Sets the alpha value of the material
  20310. */
  20311. /**
  20312. * Gets the alpha value of the material
  20313. */
  20314. alpha: number;
  20315. /**
  20316. * Specifies if back face culling is enabled
  20317. */
  20318. protected _backFaceCulling: boolean;
  20319. /**
  20320. * Sets the back-face culling state
  20321. */
  20322. /**
  20323. * Gets the back-face culling state
  20324. */
  20325. backFaceCulling: boolean;
  20326. /**
  20327. * Stores the value for side orientation
  20328. */
  20329. sideOrientation: number;
  20330. /**
  20331. * Callback triggered when the material is compiled
  20332. */
  20333. onCompiled: Nullable<(effect: Effect) => void>;
  20334. /**
  20335. * Callback triggered when an error occurs
  20336. */
  20337. onError: Nullable<(effect: Effect, errors: string) => void>;
  20338. /**
  20339. * Callback triggered to get the render target textures
  20340. */
  20341. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20342. /**
  20343. * Gets a boolean indicating that current material needs to register RTT
  20344. */
  20345. readonly hasRenderTargetTextures: boolean;
  20346. /**
  20347. * Specifies if the material should be serialized
  20348. */
  20349. doNotSerialize: boolean;
  20350. /**
  20351. * @hidden
  20352. */
  20353. _storeEffectOnSubMeshes: boolean;
  20354. /**
  20355. * Stores the animations for the material
  20356. */
  20357. animations: Nullable<Array<Animation>>;
  20358. /**
  20359. * An event triggered when the material is disposed
  20360. */
  20361. onDisposeObservable: Observable<Material>;
  20362. /**
  20363. * An observer which watches for dispose events
  20364. */
  20365. private _onDisposeObserver;
  20366. private _onUnBindObservable;
  20367. /**
  20368. * Called during a dispose event
  20369. */
  20370. onDispose: () => void;
  20371. private _onBindObservable;
  20372. /**
  20373. * An event triggered when the material is bound
  20374. */
  20375. readonly onBindObservable: Observable<AbstractMesh>;
  20376. /**
  20377. * An observer which watches for bind events
  20378. */
  20379. private _onBindObserver;
  20380. /**
  20381. * Called during a bind event
  20382. */
  20383. onBind: (Mesh: AbstractMesh) => void;
  20384. /**
  20385. * An event triggered when the material is unbound
  20386. */
  20387. readonly onUnBindObservable: Observable<Material>;
  20388. /**
  20389. * Stores the value of the alpha mode
  20390. */
  20391. private _alphaMode;
  20392. /**
  20393. * Sets the value of the alpha mode.
  20394. *
  20395. * | Value | Type | Description |
  20396. * | --- | --- | --- |
  20397. * | 0 | ALPHA_DISABLE | |
  20398. * | 1 | ALPHA_ADD | |
  20399. * | 2 | ALPHA_COMBINE | |
  20400. * | 3 | ALPHA_SUBTRACT | |
  20401. * | 4 | ALPHA_MULTIPLY | |
  20402. * | 5 | ALPHA_MAXIMIZED | |
  20403. * | 6 | ALPHA_ONEONE | |
  20404. * | 7 | ALPHA_PREMULTIPLIED | |
  20405. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20406. * | 9 | ALPHA_INTERPOLATE | |
  20407. * | 10 | ALPHA_SCREENMODE | |
  20408. *
  20409. */
  20410. /**
  20411. * Gets the value of the alpha mode
  20412. */
  20413. alphaMode: number;
  20414. /**
  20415. * Stores the state of the need depth pre-pass value
  20416. */
  20417. private _needDepthPrePass;
  20418. /**
  20419. * Sets the need depth pre-pass value
  20420. */
  20421. /**
  20422. * Gets the depth pre-pass value
  20423. */
  20424. needDepthPrePass: boolean;
  20425. /**
  20426. * Specifies if depth writing should be disabled
  20427. */
  20428. disableDepthWrite: boolean;
  20429. /**
  20430. * Specifies if depth writing should be forced
  20431. */
  20432. forceDepthWrite: boolean;
  20433. /**
  20434. * Specifies if there should be a separate pass for culling
  20435. */
  20436. separateCullingPass: boolean;
  20437. /**
  20438. * Stores the state specifing if fog should be enabled
  20439. */
  20440. private _fogEnabled;
  20441. /**
  20442. * Sets the state for enabling fog
  20443. */
  20444. /**
  20445. * Gets the value of the fog enabled state
  20446. */
  20447. fogEnabled: boolean;
  20448. /**
  20449. * Stores the size of points
  20450. */
  20451. pointSize: number;
  20452. /**
  20453. * Stores the z offset value
  20454. */
  20455. zOffset: number;
  20456. /**
  20457. * Gets a value specifying if wireframe mode is enabled
  20458. */
  20459. /**
  20460. * Sets the state of wireframe mode
  20461. */
  20462. wireframe: boolean;
  20463. /**
  20464. * Gets the value specifying if point clouds are enabled
  20465. */
  20466. /**
  20467. * Sets the state of point cloud mode
  20468. */
  20469. pointsCloud: boolean;
  20470. /**
  20471. * Gets the material fill mode
  20472. */
  20473. /**
  20474. * Sets the material fill mode
  20475. */
  20476. fillMode: number;
  20477. /**
  20478. * @hidden
  20479. * Stores the effects for the material
  20480. */
  20481. _effect: Nullable<Effect>;
  20482. /**
  20483. * @hidden
  20484. * Specifies if the material was previously ready
  20485. */
  20486. _wasPreviouslyReady: boolean;
  20487. /**
  20488. * Specifies if uniform buffers should be used
  20489. */
  20490. private _useUBO;
  20491. /**
  20492. * Stores a reference to the scene
  20493. */
  20494. private _scene;
  20495. /**
  20496. * Stores the fill mode state
  20497. */
  20498. private _fillMode;
  20499. /**
  20500. * Specifies if the depth write state should be cached
  20501. */
  20502. private _cachedDepthWriteState;
  20503. /**
  20504. * Stores the uniform buffer
  20505. */
  20506. protected _uniformBuffer: UniformBuffer;
  20507. /** @hidden */
  20508. _indexInSceneMaterialArray: number;
  20509. /** @hidden */
  20510. meshMap: Nullable<{
  20511. [id: string]: AbstractMesh | undefined;
  20512. }>;
  20513. /**
  20514. * Creates a material instance
  20515. * @param name defines the name of the material
  20516. * @param scene defines the scene to reference
  20517. * @param doNotAdd specifies if the material should be added to the scene
  20518. */
  20519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20520. /**
  20521. * Returns a string representation of the current material
  20522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20523. * @returns a string with material information
  20524. */
  20525. toString(fullDetails?: boolean): string;
  20526. /**
  20527. * Gets the class name of the material
  20528. * @returns a string with the class name of the material
  20529. */
  20530. getClassName(): string;
  20531. /**
  20532. * Specifies if updates for the material been locked
  20533. */
  20534. readonly isFrozen: boolean;
  20535. /**
  20536. * Locks updates for the material
  20537. */
  20538. freeze(): void;
  20539. /**
  20540. * Unlocks updates for the material
  20541. */
  20542. unfreeze(): void;
  20543. /**
  20544. * Specifies if the material is ready to be used
  20545. * @param mesh defines the mesh to check
  20546. * @param useInstances specifies if instances should be used
  20547. * @returns a boolean indicating if the material is ready to be used
  20548. */
  20549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20550. /**
  20551. * Specifies that the submesh is ready to be used
  20552. * @param mesh defines the mesh to check
  20553. * @param subMesh defines which submesh to check
  20554. * @param useInstances specifies that instances should be used
  20555. * @returns a boolean indicating that the submesh is ready or not
  20556. */
  20557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20558. /**
  20559. * Returns the material effect
  20560. * @returns the effect associated with the material
  20561. */
  20562. getEffect(): Nullable<Effect>;
  20563. /**
  20564. * Returns the current scene
  20565. * @returns a Scene
  20566. */
  20567. getScene(): Scene;
  20568. /**
  20569. * Specifies if the material will require alpha blending
  20570. * @returns a boolean specifying if alpha blending is needed
  20571. */
  20572. needAlphaBlending(): boolean;
  20573. /**
  20574. * Specifies if the mesh will require alpha blending
  20575. * @param mesh defines the mesh to check
  20576. * @returns a boolean specifying if alpha blending is needed for the mesh
  20577. */
  20578. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20579. /**
  20580. * Specifies if this material should be rendered in alpha test mode
  20581. * @returns a boolean specifying if an alpha test is needed.
  20582. */
  20583. needAlphaTesting(): boolean;
  20584. /**
  20585. * Gets the texture used for the alpha test
  20586. * @returns the texture to use for alpha testing
  20587. */
  20588. getAlphaTestTexture(): Nullable<BaseTexture>;
  20589. /**
  20590. * Marks the material to indicate that it needs to be re-calculated
  20591. */
  20592. markDirty(): void;
  20593. /** @hidden */
  20594. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20595. /**
  20596. * Binds the material to the mesh
  20597. * @param world defines the world transformation matrix
  20598. * @param mesh defines the mesh to bind the material to
  20599. */
  20600. bind(world: Matrix, mesh?: Mesh): void;
  20601. /**
  20602. * Binds the submesh to the material
  20603. * @param world defines the world transformation matrix
  20604. * @param mesh defines the mesh containing the submesh
  20605. * @param subMesh defines the submesh to bind the material to
  20606. */
  20607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20608. /**
  20609. * Binds the world matrix to the material
  20610. * @param world defines the world transformation matrix
  20611. */
  20612. bindOnlyWorldMatrix(world: Matrix): void;
  20613. /**
  20614. * Binds the scene's uniform buffer to the effect.
  20615. * @param effect defines the effect to bind to the scene uniform buffer
  20616. * @param sceneUbo defines the uniform buffer storing scene data
  20617. */
  20618. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20619. /**
  20620. * Binds the view matrix to the effect
  20621. * @param effect defines the effect to bind the view matrix to
  20622. */
  20623. bindView(effect: Effect): void;
  20624. /**
  20625. * Binds the view projection matrix to the effect
  20626. * @param effect defines the effect to bind the view projection matrix to
  20627. */
  20628. bindViewProjection(effect: Effect): void;
  20629. /**
  20630. * Specifies if material alpha testing should be turned on for the mesh
  20631. * @param mesh defines the mesh to check
  20632. */
  20633. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20634. /**
  20635. * Processes to execute after binding the material to a mesh
  20636. * @param mesh defines the rendered mesh
  20637. */
  20638. protected _afterBind(mesh?: Mesh): void;
  20639. /**
  20640. * Unbinds the material from the mesh
  20641. */
  20642. unbind(): void;
  20643. /**
  20644. * Gets the active textures from the material
  20645. * @returns an array of textures
  20646. */
  20647. getActiveTextures(): BaseTexture[];
  20648. /**
  20649. * Specifies if the material uses a texture
  20650. * @param texture defines the texture to check against the material
  20651. * @returns a boolean specifying if the material uses the texture
  20652. */
  20653. hasTexture(texture: BaseTexture): boolean;
  20654. /**
  20655. * Makes a duplicate of the material, and gives it a new name
  20656. * @param name defines the new name for the duplicated material
  20657. * @returns the cloned material
  20658. */
  20659. clone(name: string): Nullable<Material>;
  20660. /**
  20661. * Gets the meshes bound to the material
  20662. * @returns an array of meshes bound to the material
  20663. */
  20664. getBindedMeshes(): AbstractMesh[];
  20665. /**
  20666. * Force shader compilation
  20667. * @param mesh defines the mesh associated with this material
  20668. * @param onCompiled defines a function to execute once the material is compiled
  20669. * @param options defines the options to configure the compilation
  20670. * @param onError defines a function to execute if the material fails compiling
  20671. */
  20672. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20673. /**
  20674. * Force shader compilation
  20675. * @param mesh defines the mesh that will use this material
  20676. * @param options defines additional options for compiling the shaders
  20677. * @returns a promise that resolves when the compilation completes
  20678. */
  20679. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20680. private static readonly _AllDirtyCallBack;
  20681. private static readonly _ImageProcessingDirtyCallBack;
  20682. private static readonly _TextureDirtyCallBack;
  20683. private static readonly _FresnelDirtyCallBack;
  20684. private static readonly _MiscDirtyCallBack;
  20685. private static readonly _LightsDirtyCallBack;
  20686. private static readonly _AttributeDirtyCallBack;
  20687. private static _FresnelAndMiscDirtyCallBack;
  20688. private static _TextureAndMiscDirtyCallBack;
  20689. private static readonly _DirtyCallbackArray;
  20690. private static readonly _RunDirtyCallBacks;
  20691. /**
  20692. * Marks a define in the material to indicate that it needs to be re-computed
  20693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20694. */
  20695. markAsDirty(flag: number): void;
  20696. /**
  20697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20698. * @param func defines a function which checks material defines against the submeshes
  20699. */
  20700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20701. /**
  20702. * Indicates that we need to re-calculated for all submeshes
  20703. */
  20704. protected _markAllSubMeshesAsAllDirty(): void;
  20705. /**
  20706. * Indicates that image processing needs to be re-calculated for all submeshes
  20707. */
  20708. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20709. /**
  20710. * Indicates that textures need to be re-calculated for all submeshes
  20711. */
  20712. protected _markAllSubMeshesAsTexturesDirty(): void;
  20713. /**
  20714. * Indicates that fresnel needs to be re-calculated for all submeshes
  20715. */
  20716. protected _markAllSubMeshesAsFresnelDirty(): void;
  20717. /**
  20718. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20719. */
  20720. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20721. /**
  20722. * Indicates that lights need to be re-calculated for all submeshes
  20723. */
  20724. protected _markAllSubMeshesAsLightsDirty(): void;
  20725. /**
  20726. * Indicates that attributes need to be re-calculated for all submeshes
  20727. */
  20728. protected _markAllSubMeshesAsAttributesDirty(): void;
  20729. /**
  20730. * Indicates that misc needs to be re-calculated for all submeshes
  20731. */
  20732. protected _markAllSubMeshesAsMiscDirty(): void;
  20733. /**
  20734. * Indicates that textures and misc need to be re-calculated for all submeshes
  20735. */
  20736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20737. /**
  20738. * Disposes the material
  20739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20742. */
  20743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20744. /** @hidden */
  20745. private releaseVertexArrayObject;
  20746. /**
  20747. * Serializes this material
  20748. * @returns the serialized material object
  20749. */
  20750. serialize(): any;
  20751. /**
  20752. * Creates a material from parsed material data
  20753. * @param parsedMaterial defines parsed material data
  20754. * @param scene defines the hosting scene
  20755. * @param rootUrl defines the root URL to use to load textures
  20756. * @returns a new material
  20757. */
  20758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20759. }
  20760. }
  20761. declare module BABYLON {
  20762. /**
  20763. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20764. * separate meshes. This can be use to improve performances.
  20765. * @see http://doc.babylonjs.com/how_to/multi_materials
  20766. */
  20767. export class MultiMaterial extends Material {
  20768. private _subMaterials;
  20769. /**
  20770. * Gets or Sets the list of Materials used within the multi material.
  20771. * They need to be ordered according to the submeshes order in the associated mesh
  20772. */
  20773. subMaterials: Nullable<Material>[];
  20774. /**
  20775. * Function used to align with Node.getChildren()
  20776. * @returns the list of Materials used within the multi material
  20777. */
  20778. getChildren(): Nullable<Material>[];
  20779. /**
  20780. * Instantiates a new Multi Material
  20781. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20782. * separate meshes. This can be use to improve performances.
  20783. * @see http://doc.babylonjs.com/how_to/multi_materials
  20784. * @param name Define the name in the scene
  20785. * @param scene Define the scene the material belongs to
  20786. */
  20787. constructor(name: string, scene: Scene);
  20788. private _hookArray;
  20789. /**
  20790. * Get one of the submaterial by its index in the submaterials array
  20791. * @param index The index to look the sub material at
  20792. * @returns The Material if the index has been defined
  20793. */
  20794. getSubMaterial(index: number): Nullable<Material>;
  20795. /**
  20796. * Get the list of active textures for the whole sub materials list.
  20797. * @returns All the textures that will be used during the rendering
  20798. */
  20799. getActiveTextures(): BaseTexture[];
  20800. /**
  20801. * Gets the current class name of the material e.g. "MultiMaterial"
  20802. * Mainly use in serialization.
  20803. * @returns the class name
  20804. */
  20805. getClassName(): string;
  20806. /**
  20807. * Checks if the material is ready to render the requested sub mesh
  20808. * @param mesh Define the mesh the submesh belongs to
  20809. * @param subMesh Define the sub mesh to look readyness for
  20810. * @param useInstances Define whether or not the material is used with instances
  20811. * @returns true if ready, otherwise false
  20812. */
  20813. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20814. /**
  20815. * Clones the current material and its related sub materials
  20816. * @param name Define the name of the newly cloned material
  20817. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20818. * @returns the cloned material
  20819. */
  20820. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20821. /**
  20822. * Serializes the materials into a JSON representation.
  20823. * @returns the JSON representation
  20824. */
  20825. serialize(): any;
  20826. /**
  20827. * Dispose the material and release its associated resources
  20828. * @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)
  20829. * @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)
  20830. * @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)
  20831. */
  20832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20833. /**
  20834. * Creates a MultiMaterial from parsed MultiMaterial data.
  20835. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20836. * @param scene defines the hosting scene
  20837. * @returns a new MultiMaterial
  20838. */
  20839. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20840. }
  20841. }
  20842. declare module BABYLON {
  20843. /**
  20844. * Base class for submeshes
  20845. */
  20846. export class BaseSubMesh {
  20847. /** @hidden */
  20848. _materialDefines: Nullable<MaterialDefines>;
  20849. /** @hidden */
  20850. _materialEffect: Nullable<Effect>;
  20851. /**
  20852. * Gets associated effect
  20853. */
  20854. readonly effect: Nullable<Effect>;
  20855. /**
  20856. * Sets associated effect (effect used to render this submesh)
  20857. * @param effect defines the effect to associate with
  20858. * @param defines defines the set of defines used to compile this effect
  20859. */
  20860. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20861. }
  20862. /**
  20863. * Defines a subdivision inside a mesh
  20864. */
  20865. export class SubMesh extends BaseSubMesh implements ICullable {
  20866. /** the material index to use */
  20867. materialIndex: number;
  20868. /** vertex index start */
  20869. verticesStart: number;
  20870. /** vertices count */
  20871. verticesCount: number;
  20872. /** index start */
  20873. indexStart: number;
  20874. /** indices count */
  20875. indexCount: number;
  20876. /** @hidden */
  20877. _linesIndexCount: number;
  20878. private _mesh;
  20879. private _renderingMesh;
  20880. private _boundingInfo;
  20881. private _linesIndexBuffer;
  20882. /** @hidden */
  20883. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20884. /** @hidden */
  20885. _trianglePlanes: Plane[];
  20886. /** @hidden */
  20887. _lastColliderTransformMatrix: Nullable<Matrix>;
  20888. /** @hidden */
  20889. _renderId: number;
  20890. /** @hidden */
  20891. _alphaIndex: number;
  20892. /** @hidden */
  20893. _distanceToCamera: number;
  20894. /** @hidden */
  20895. _id: number;
  20896. private _currentMaterial;
  20897. /**
  20898. * Add a new submesh to a mesh
  20899. * @param materialIndex defines the material index to use
  20900. * @param verticesStart defines vertex index start
  20901. * @param verticesCount defines vertices count
  20902. * @param indexStart defines index start
  20903. * @param indexCount defines indices count
  20904. * @param mesh defines the parent mesh
  20905. * @param renderingMesh defines an optional rendering mesh
  20906. * @param createBoundingBox defines if bounding box should be created for this submesh
  20907. * @returns the new submesh
  20908. */
  20909. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20910. /**
  20911. * Creates a new submesh
  20912. * @param materialIndex defines the material index to use
  20913. * @param verticesStart defines vertex index start
  20914. * @param verticesCount defines vertices count
  20915. * @param indexStart defines index start
  20916. * @param indexCount defines indices count
  20917. * @param mesh defines the parent mesh
  20918. * @param renderingMesh defines an optional rendering mesh
  20919. * @param createBoundingBox defines if bounding box should be created for this submesh
  20920. */
  20921. constructor(
  20922. /** the material index to use */
  20923. materialIndex: number,
  20924. /** vertex index start */
  20925. verticesStart: number,
  20926. /** vertices count */
  20927. verticesCount: number,
  20928. /** index start */
  20929. indexStart: number,
  20930. /** indices count */
  20931. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20932. /**
  20933. * Returns true if this submesh covers the entire parent mesh
  20934. * @ignorenaming
  20935. */
  20936. readonly IsGlobal: boolean;
  20937. /**
  20938. * Returns the submesh BoudingInfo object
  20939. * @returns current bounding info (or mesh's one if the submesh is global)
  20940. */
  20941. getBoundingInfo(): BoundingInfo;
  20942. /**
  20943. * Sets the submesh BoundingInfo
  20944. * @param boundingInfo defines the new bounding info to use
  20945. * @returns the SubMesh
  20946. */
  20947. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20948. /**
  20949. * Returns the mesh of the current submesh
  20950. * @return the parent mesh
  20951. */
  20952. getMesh(): AbstractMesh;
  20953. /**
  20954. * Returns the rendering mesh of the submesh
  20955. * @returns the rendering mesh (could be different from parent mesh)
  20956. */
  20957. getRenderingMesh(): Mesh;
  20958. /**
  20959. * Returns the submesh material
  20960. * @returns null or the current material
  20961. */
  20962. getMaterial(): Nullable<Material>;
  20963. /**
  20964. * Sets a new updated BoundingInfo object to the submesh
  20965. * @param data defines an optional position array to use to determine the bounding info
  20966. * @returns the SubMesh
  20967. */
  20968. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20969. /** @hidden */
  20970. _checkCollision(collider: Collider): boolean;
  20971. /**
  20972. * Updates the submesh BoundingInfo
  20973. * @param world defines the world matrix to use to update the bounding info
  20974. * @returns the submesh
  20975. */
  20976. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20977. /**
  20978. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20979. * @param frustumPlanes defines the frustum planes
  20980. * @returns true if the submesh is intersecting with the frustum
  20981. */
  20982. isInFrustum(frustumPlanes: Plane[]): boolean;
  20983. /**
  20984. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20985. * @param frustumPlanes defines the frustum planes
  20986. * @returns true if the submesh is inside the frustum
  20987. */
  20988. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20989. /**
  20990. * Renders the submesh
  20991. * @param enableAlphaMode defines if alpha needs to be used
  20992. * @returns the submesh
  20993. */
  20994. render(enableAlphaMode: boolean): SubMesh;
  20995. /**
  20996. * @hidden
  20997. */
  20998. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20999. /**
  21000. * Checks if the submesh intersects with a ray
  21001. * @param ray defines the ray to test
  21002. * @returns true is the passed ray intersects the submesh bounding box
  21003. */
  21004. canIntersects(ray: Ray): boolean;
  21005. /**
  21006. * Intersects current submesh with a ray
  21007. * @param ray defines the ray to test
  21008. * @param positions defines mesh's positions array
  21009. * @param indices defines mesh's indices array
  21010. * @param fastCheck defines if only bounding info should be used
  21011. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21012. * @returns intersection info or null if no intersection
  21013. */
  21014. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21015. /** @hidden */
  21016. private _intersectLines;
  21017. /** @hidden */
  21018. private _intersectUnIndexedLines;
  21019. /** @hidden */
  21020. private _intersectTriangles;
  21021. /** @hidden */
  21022. private _intersectUnIndexedTriangles;
  21023. /** @hidden */
  21024. _rebuild(): void;
  21025. /**
  21026. * Creates a new submesh from the passed mesh
  21027. * @param newMesh defines the new hosting mesh
  21028. * @param newRenderingMesh defines an optional rendering mesh
  21029. * @returns the new submesh
  21030. */
  21031. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21032. /**
  21033. * Release associated resources
  21034. */
  21035. dispose(): void;
  21036. /**
  21037. * Gets the class name
  21038. * @returns the string "SubMesh".
  21039. */
  21040. getClassName(): string;
  21041. /**
  21042. * Creates a new submesh from indices data
  21043. * @param materialIndex the index of the main mesh material
  21044. * @param startIndex the index where to start the copy in the mesh indices array
  21045. * @param indexCount the number of indices to copy then from the startIndex
  21046. * @param mesh the main mesh to create the submesh from
  21047. * @param renderingMesh the optional rendering mesh
  21048. * @returns a new submesh
  21049. */
  21050. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21051. }
  21052. }
  21053. declare module BABYLON {
  21054. /**
  21055. * Class used to represent data loading progression
  21056. */
  21057. export class SceneLoaderFlags {
  21058. private static _ForceFullSceneLoadingForIncremental;
  21059. private static _ShowLoadingScreen;
  21060. private static _CleanBoneMatrixWeights;
  21061. private static _loggingLevel;
  21062. /**
  21063. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21064. */
  21065. static ForceFullSceneLoadingForIncremental: boolean;
  21066. /**
  21067. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21068. */
  21069. static ShowLoadingScreen: boolean;
  21070. /**
  21071. * Defines the current logging level (while loading the scene)
  21072. * @ignorenaming
  21073. */
  21074. static loggingLevel: number;
  21075. /**
  21076. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21077. */
  21078. static CleanBoneMatrixWeights: boolean;
  21079. }
  21080. }
  21081. declare module BABYLON {
  21082. /**
  21083. * Class used to store geometry data (vertex buffers + index buffer)
  21084. */
  21085. export class Geometry implements IGetSetVerticesData {
  21086. /**
  21087. * Gets or sets the ID of the geometry
  21088. */
  21089. id: string;
  21090. /**
  21091. * Gets or sets the unique ID of the geometry
  21092. */
  21093. uniqueId: number;
  21094. /**
  21095. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21096. */
  21097. delayLoadState: number;
  21098. /**
  21099. * Gets the file containing the data to load when running in delay load state
  21100. */
  21101. delayLoadingFile: Nullable<string>;
  21102. /**
  21103. * Callback called when the geometry is updated
  21104. */
  21105. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21106. private _scene;
  21107. private _engine;
  21108. private _meshes;
  21109. private _totalVertices;
  21110. /** @hidden */
  21111. _indices: IndicesArray;
  21112. /** @hidden */
  21113. _vertexBuffers: {
  21114. [key: string]: VertexBuffer;
  21115. };
  21116. private _isDisposed;
  21117. private _extend;
  21118. private _boundingBias;
  21119. /** @hidden */
  21120. _delayInfo: Array<string>;
  21121. private _indexBuffer;
  21122. private _indexBufferIsUpdatable;
  21123. /** @hidden */
  21124. _boundingInfo: Nullable<BoundingInfo>;
  21125. /** @hidden */
  21126. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21127. /** @hidden */
  21128. _softwareSkinningFrameId: number;
  21129. private _vertexArrayObjects;
  21130. private _updatable;
  21131. /** @hidden */
  21132. _positions: Nullable<Vector3[]>;
  21133. /**
  21134. * 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
  21135. */
  21136. /**
  21137. * 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
  21138. */
  21139. boundingBias: Vector2;
  21140. /**
  21141. * Static function used to attach a new empty geometry to a mesh
  21142. * @param mesh defines the mesh to attach the geometry to
  21143. * @returns the new Geometry
  21144. */
  21145. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21146. /**
  21147. * Creates a new geometry
  21148. * @param id defines the unique ID
  21149. * @param scene defines the hosting scene
  21150. * @param vertexData defines the VertexData used to get geometry data
  21151. * @param updatable defines if geometry must be updatable (false by default)
  21152. * @param mesh defines the mesh that will be associated with the geometry
  21153. */
  21154. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21155. /**
  21156. * Gets the current extend of the geometry
  21157. */
  21158. readonly extend: {
  21159. minimum: Vector3;
  21160. maximum: Vector3;
  21161. };
  21162. /**
  21163. * Gets the hosting scene
  21164. * @returns the hosting Scene
  21165. */
  21166. getScene(): Scene;
  21167. /**
  21168. * Gets the hosting engine
  21169. * @returns the hosting Engine
  21170. */
  21171. getEngine(): Engine;
  21172. /**
  21173. * Defines if the geometry is ready to use
  21174. * @returns true if the geometry is ready to be used
  21175. */
  21176. isReady(): boolean;
  21177. /**
  21178. * Gets a value indicating that the geometry should not be serialized
  21179. */
  21180. readonly doNotSerialize: boolean;
  21181. /** @hidden */
  21182. _rebuild(): void;
  21183. /**
  21184. * Affects all geometry data in one call
  21185. * @param vertexData defines the geometry data
  21186. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21187. */
  21188. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21189. /**
  21190. * Set specific vertex data
  21191. * @param kind defines the data kind (Position, normal, etc...)
  21192. * @param data defines the vertex data to use
  21193. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21194. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21195. */
  21196. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21197. /**
  21198. * Removes a specific vertex data
  21199. * @param kind defines the data kind (Position, normal, etc...)
  21200. */
  21201. removeVerticesData(kind: string): void;
  21202. /**
  21203. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21204. * @param buffer defines the vertex buffer to use
  21205. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21206. */
  21207. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21208. /**
  21209. * Update a specific vertex buffer
  21210. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21211. * It will do nothing if the buffer is not updatable
  21212. * @param kind defines the data kind (Position, normal, etc...)
  21213. * @param data defines the data to use
  21214. * @param offset defines the offset in the target buffer where to store the data
  21215. * @param useBytes set to true if the offset is in bytes
  21216. */
  21217. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21218. /**
  21219. * Update a specific vertex buffer
  21220. * This function will create a new buffer if the current one is not updatable
  21221. * @param kind defines the data kind (Position, normal, etc...)
  21222. * @param data defines the data to use
  21223. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21224. */
  21225. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21226. private _updateBoundingInfo;
  21227. /** @hidden */
  21228. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21229. /**
  21230. * Gets total number of vertices
  21231. * @returns the total number of vertices
  21232. */
  21233. getTotalVertices(): number;
  21234. /**
  21235. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21236. * @param kind defines the data kind (Position, normal, etc...)
  21237. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21238. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21239. * @returns a float array containing vertex data
  21240. */
  21241. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21242. /**
  21243. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21244. * @param kind defines the data kind (Position, normal, etc...)
  21245. * @returns true if the vertex buffer with the specified kind is updatable
  21246. */
  21247. isVertexBufferUpdatable(kind: string): boolean;
  21248. /**
  21249. * Gets a specific vertex buffer
  21250. * @param kind defines the data kind (Position, normal, etc...)
  21251. * @returns a VertexBuffer
  21252. */
  21253. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21254. /**
  21255. * Returns all vertex buffers
  21256. * @return an object holding all vertex buffers indexed by kind
  21257. */
  21258. getVertexBuffers(): Nullable<{
  21259. [key: string]: VertexBuffer;
  21260. }>;
  21261. /**
  21262. * Gets a boolean indicating if specific vertex buffer is present
  21263. * @param kind defines the data kind (Position, normal, etc...)
  21264. * @returns true if data is present
  21265. */
  21266. isVerticesDataPresent(kind: string): boolean;
  21267. /**
  21268. * Gets a list of all attached data kinds (Position, normal, etc...)
  21269. * @returns a list of string containing all kinds
  21270. */
  21271. getVerticesDataKinds(): string[];
  21272. /**
  21273. * Update index buffer
  21274. * @param indices defines the indices to store in the index buffer
  21275. * @param offset defines the offset in the target buffer where to store the data
  21276. * @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)
  21277. */
  21278. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21279. /**
  21280. * Creates a new index buffer
  21281. * @param indices defines the indices to store in the index buffer
  21282. * @param totalVertices defines the total number of vertices (could be null)
  21283. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21284. */
  21285. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21286. /**
  21287. * Return the total number of indices
  21288. * @returns the total number of indices
  21289. */
  21290. getTotalIndices(): number;
  21291. /**
  21292. * Gets the index buffer array
  21293. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21295. * @returns the index buffer array
  21296. */
  21297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21298. /**
  21299. * Gets the index buffer
  21300. * @return the index buffer
  21301. */
  21302. getIndexBuffer(): Nullable<DataBuffer>;
  21303. /** @hidden */
  21304. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21305. /**
  21306. * Release the associated resources for a specific mesh
  21307. * @param mesh defines the source mesh
  21308. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21309. */
  21310. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21311. /**
  21312. * Apply current geometry to a given mesh
  21313. * @param mesh defines the mesh to apply geometry to
  21314. */
  21315. applyToMesh(mesh: Mesh): void;
  21316. private _updateExtend;
  21317. private _applyToMesh;
  21318. private notifyUpdate;
  21319. /**
  21320. * Load the geometry if it was flagged as delay loaded
  21321. * @param scene defines the hosting scene
  21322. * @param onLoaded defines a callback called when the geometry is loaded
  21323. */
  21324. load(scene: Scene, onLoaded?: () => void): void;
  21325. private _queueLoad;
  21326. /**
  21327. * Invert the geometry to move from a right handed system to a left handed one.
  21328. */
  21329. toLeftHanded(): void;
  21330. /** @hidden */
  21331. _resetPointsArrayCache(): void;
  21332. /** @hidden */
  21333. _generatePointsArray(): boolean;
  21334. /**
  21335. * Gets a value indicating if the geometry is disposed
  21336. * @returns true if the geometry was disposed
  21337. */
  21338. isDisposed(): boolean;
  21339. private _disposeVertexArrayObjects;
  21340. /**
  21341. * Free all associated resources
  21342. */
  21343. dispose(): void;
  21344. /**
  21345. * Clone the current geometry into a new geometry
  21346. * @param id defines the unique ID of the new geometry
  21347. * @returns a new geometry object
  21348. */
  21349. copy(id: string): Geometry;
  21350. /**
  21351. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21352. * @return a JSON representation of the current geometry data (without the vertices data)
  21353. */
  21354. serialize(): any;
  21355. private toNumberArray;
  21356. /**
  21357. * Serialize all vertices data into a JSON oject
  21358. * @returns a JSON representation of the current geometry data
  21359. */
  21360. serializeVerticeData(): any;
  21361. /**
  21362. * Extracts a clone of a mesh geometry
  21363. * @param mesh defines the source mesh
  21364. * @param id defines the unique ID of the new geometry object
  21365. * @returns the new geometry object
  21366. */
  21367. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21368. /**
  21369. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21370. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21371. * Be aware Math.random() could cause collisions, but:
  21372. * "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"
  21373. * @returns a string containing a new GUID
  21374. */
  21375. static RandomId(): string;
  21376. /** @hidden */
  21377. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21378. private static _CleanMatricesWeights;
  21379. /**
  21380. * Create a new geometry from persisted data (Using .babylon file format)
  21381. * @param parsedVertexData defines the persisted data
  21382. * @param scene defines the hosting scene
  21383. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21384. * @returns the new geometry object
  21385. */
  21386. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21387. }
  21388. }
  21389. declare module BABYLON {
  21390. /**
  21391. * Define an interface for all classes that will get and set the data on vertices
  21392. */
  21393. export interface IGetSetVerticesData {
  21394. /**
  21395. * Gets a boolean indicating if specific vertex data is present
  21396. * @param kind defines the vertex data kind to use
  21397. * @returns true is data kind is present
  21398. */
  21399. isVerticesDataPresent(kind: string): boolean;
  21400. /**
  21401. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21402. * @param kind defines the data kind (Position, normal, etc...)
  21403. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21404. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21405. * @returns a float array containing vertex data
  21406. */
  21407. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21408. /**
  21409. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21410. * @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.
  21411. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21412. * @returns the indices array or an empty array if the mesh has no geometry
  21413. */
  21414. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21415. /**
  21416. * Set specific vertex data
  21417. * @param kind defines the data kind (Position, normal, etc...)
  21418. * @param data defines the vertex data to use
  21419. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21420. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21421. */
  21422. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21423. /**
  21424. * Update a specific associated vertex buffer
  21425. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21426. * - VertexBuffer.PositionKind
  21427. * - VertexBuffer.UVKind
  21428. * - VertexBuffer.UV2Kind
  21429. * - VertexBuffer.UV3Kind
  21430. * - VertexBuffer.UV4Kind
  21431. * - VertexBuffer.UV5Kind
  21432. * - VertexBuffer.UV6Kind
  21433. * - VertexBuffer.ColorKind
  21434. * - VertexBuffer.MatricesIndicesKind
  21435. * - VertexBuffer.MatricesIndicesExtraKind
  21436. * - VertexBuffer.MatricesWeightsKind
  21437. * - VertexBuffer.MatricesWeightsExtraKind
  21438. * @param data defines the data source
  21439. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21440. * @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)
  21441. */
  21442. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21443. /**
  21444. * Creates a new index buffer
  21445. * @param indices defines the indices to store in the index buffer
  21446. * @param totalVertices defines the total number of vertices (could be null)
  21447. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21448. */
  21449. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21450. }
  21451. /**
  21452. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21453. */
  21454. export class VertexData {
  21455. /**
  21456. * Mesh side orientation : usually the external or front surface
  21457. */
  21458. static readonly FRONTSIDE: number;
  21459. /**
  21460. * Mesh side orientation : usually the internal or back surface
  21461. */
  21462. static readonly BACKSIDE: number;
  21463. /**
  21464. * Mesh side orientation : both internal and external or front and back surfaces
  21465. */
  21466. static readonly DOUBLESIDE: number;
  21467. /**
  21468. * Mesh side orientation : by default, `FRONTSIDE`
  21469. */
  21470. static readonly DEFAULTSIDE: number;
  21471. /**
  21472. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21473. */
  21474. positions: Nullable<FloatArray>;
  21475. /**
  21476. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21477. */
  21478. normals: Nullable<FloatArray>;
  21479. /**
  21480. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21481. */
  21482. tangents: Nullable<FloatArray>;
  21483. /**
  21484. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21485. */
  21486. uvs: Nullable<FloatArray>;
  21487. /**
  21488. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21489. */
  21490. uvs2: Nullable<FloatArray>;
  21491. /**
  21492. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21493. */
  21494. uvs3: Nullable<FloatArray>;
  21495. /**
  21496. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21497. */
  21498. uvs4: Nullable<FloatArray>;
  21499. /**
  21500. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21501. */
  21502. uvs5: Nullable<FloatArray>;
  21503. /**
  21504. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21505. */
  21506. uvs6: Nullable<FloatArray>;
  21507. /**
  21508. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21509. */
  21510. colors: Nullable<FloatArray>;
  21511. /**
  21512. * 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).
  21513. */
  21514. matricesIndices: Nullable<FloatArray>;
  21515. /**
  21516. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21517. */
  21518. matricesWeights: Nullable<FloatArray>;
  21519. /**
  21520. * An array extending the number of possible indices
  21521. */
  21522. matricesIndicesExtra: Nullable<FloatArray>;
  21523. /**
  21524. * An array extending the number of possible weights when the number of indices is extended
  21525. */
  21526. matricesWeightsExtra: Nullable<FloatArray>;
  21527. /**
  21528. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21529. */
  21530. indices: Nullable<IndicesArray>;
  21531. /**
  21532. * Uses the passed data array to set the set the values for the specified kind of data
  21533. * @param data a linear array of floating numbers
  21534. * @param kind the type of data that is being set, eg positions, colors etc
  21535. */
  21536. set(data: FloatArray, kind: string): void;
  21537. /**
  21538. * Associates the vertexData to the passed Mesh.
  21539. * Sets it as updatable or not (default `false`)
  21540. * @param mesh the mesh the vertexData is applied to
  21541. * @param updatable when used and having the value true allows new data to update the vertexData
  21542. * @returns the VertexData
  21543. */
  21544. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21545. /**
  21546. * Associates the vertexData to the passed Geometry.
  21547. * Sets it as updatable or not (default `false`)
  21548. * @param geometry the geometry the vertexData is applied to
  21549. * @param updatable when used and having the value true allows new data to update the vertexData
  21550. * @returns VertexData
  21551. */
  21552. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21553. /**
  21554. * Updates the associated mesh
  21555. * @param mesh the mesh to be updated
  21556. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21557. * @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
  21558. * @returns VertexData
  21559. */
  21560. updateMesh(mesh: Mesh): VertexData;
  21561. /**
  21562. * Updates the associated geometry
  21563. * @param geometry the geometry to be updated
  21564. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21565. * @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
  21566. * @returns VertexData.
  21567. */
  21568. updateGeometry(geometry: Geometry): VertexData;
  21569. private _applyTo;
  21570. private _update;
  21571. /**
  21572. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21573. * @param matrix the transforming matrix
  21574. * @returns the VertexData
  21575. */
  21576. transform(matrix: Matrix): VertexData;
  21577. /**
  21578. * Merges the passed VertexData into the current one
  21579. * @param other the VertexData to be merged into the current one
  21580. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21581. * @returns the modified VertexData
  21582. */
  21583. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21584. private _mergeElement;
  21585. private _validate;
  21586. /**
  21587. * Serializes the VertexData
  21588. * @returns a serialized object
  21589. */
  21590. serialize(): any;
  21591. /**
  21592. * Extracts the vertexData from a mesh
  21593. * @param mesh the mesh from which to extract the VertexData
  21594. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21595. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21596. * @returns the object VertexData associated to the passed mesh
  21597. */
  21598. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21599. /**
  21600. * Extracts the vertexData from the geometry
  21601. * @param geometry the geometry from which to extract the VertexData
  21602. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21603. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21604. * @returns the object VertexData associated to the passed mesh
  21605. */
  21606. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21607. private static _ExtractFrom;
  21608. /**
  21609. * Creates the VertexData for a Ribbon
  21610. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21611. * * pathArray array of paths, each of which an array of successive Vector3
  21612. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21613. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21614. * * 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
  21615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21616. * * 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)
  21617. * * 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)
  21618. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21619. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21620. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21621. * @returns the VertexData of the ribbon
  21622. */
  21623. static CreateRibbon(options: {
  21624. pathArray: Vector3[][];
  21625. closeArray?: boolean;
  21626. closePath?: boolean;
  21627. offset?: number;
  21628. sideOrientation?: number;
  21629. frontUVs?: Vector4;
  21630. backUVs?: Vector4;
  21631. invertUV?: boolean;
  21632. uvs?: Vector2[];
  21633. colors?: Color4[];
  21634. }): VertexData;
  21635. /**
  21636. * Creates the VertexData for a box
  21637. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21638. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21639. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21640. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21641. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21642. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21643. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21645. * * 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)
  21646. * * 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)
  21647. * @returns the VertexData of the box
  21648. */
  21649. static CreateBox(options: {
  21650. size?: number;
  21651. width?: number;
  21652. height?: number;
  21653. depth?: number;
  21654. faceUV?: Vector4[];
  21655. faceColors?: Color4[];
  21656. sideOrientation?: number;
  21657. frontUVs?: Vector4;
  21658. backUVs?: Vector4;
  21659. }): VertexData;
  21660. /**
  21661. * Creates the VertexData for a tiled box
  21662. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21663. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21664. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21665. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21666. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21667. * @returns the VertexData of the box
  21668. */
  21669. static CreateTiledBox(options: {
  21670. pattern?: number;
  21671. width?: number;
  21672. height?: number;
  21673. depth?: number;
  21674. tileSize?: number;
  21675. tileWidth?: number;
  21676. tileHeight?: number;
  21677. alignHorizontal?: number;
  21678. alignVertical?: number;
  21679. faceUV?: Vector4[];
  21680. faceColors?: Color4[];
  21681. sideOrientation?: number;
  21682. }): VertexData;
  21683. /**
  21684. * Creates the VertexData for a tiled plane
  21685. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21686. * * pattern a limited pattern arrangement depending on the number
  21687. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21688. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21689. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21691. * * 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)
  21692. * * 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)
  21693. * @returns the VertexData of the tiled plane
  21694. */
  21695. static CreateTiledPlane(options: {
  21696. pattern?: number;
  21697. tileSize?: number;
  21698. tileWidth?: number;
  21699. tileHeight?: number;
  21700. size?: number;
  21701. width?: number;
  21702. height?: number;
  21703. alignHorizontal?: number;
  21704. alignVertical?: number;
  21705. sideOrientation?: number;
  21706. frontUVs?: Vector4;
  21707. backUVs?: Vector4;
  21708. }): VertexData;
  21709. /**
  21710. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21711. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21712. * * segments sets the number of horizontal strips optional, default 32
  21713. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21714. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21715. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21716. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21717. * * 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
  21718. * * 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
  21719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21720. * * 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)
  21721. * * 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)
  21722. * @returns the VertexData of the ellipsoid
  21723. */
  21724. static CreateSphere(options: {
  21725. segments?: number;
  21726. diameter?: number;
  21727. diameterX?: number;
  21728. diameterY?: number;
  21729. diameterZ?: number;
  21730. arc?: number;
  21731. slice?: number;
  21732. sideOrientation?: number;
  21733. frontUVs?: Vector4;
  21734. backUVs?: Vector4;
  21735. }): VertexData;
  21736. /**
  21737. * Creates the VertexData for a cylinder, cone or prism
  21738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21739. * * height sets the height (y direction) of the cylinder, optional, default 2
  21740. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21741. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21742. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21743. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21744. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21745. * * 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
  21746. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21747. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21748. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21749. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21750. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21751. * * 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)
  21752. * * 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)
  21753. * @returns the VertexData of the cylinder, cone or prism
  21754. */
  21755. static CreateCylinder(options: {
  21756. height?: number;
  21757. diameterTop?: number;
  21758. diameterBottom?: number;
  21759. diameter?: number;
  21760. tessellation?: number;
  21761. subdivisions?: number;
  21762. arc?: number;
  21763. faceColors?: Color4[];
  21764. faceUV?: Vector4[];
  21765. hasRings?: boolean;
  21766. enclose?: boolean;
  21767. sideOrientation?: number;
  21768. frontUVs?: Vector4;
  21769. backUVs?: Vector4;
  21770. }): VertexData;
  21771. /**
  21772. * Creates the VertexData for a torus
  21773. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21774. * * diameter the diameter of the torus, optional default 1
  21775. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21776. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21777. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21778. * * 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)
  21779. * * 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)
  21780. * @returns the VertexData of the torus
  21781. */
  21782. static CreateTorus(options: {
  21783. diameter?: number;
  21784. thickness?: number;
  21785. tessellation?: number;
  21786. sideOrientation?: number;
  21787. frontUVs?: Vector4;
  21788. backUVs?: Vector4;
  21789. }): VertexData;
  21790. /**
  21791. * Creates the VertexData of the LineSystem
  21792. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21793. * - lines an array of lines, each line being an array of successive Vector3
  21794. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21795. * @returns the VertexData of the LineSystem
  21796. */
  21797. static CreateLineSystem(options: {
  21798. lines: Vector3[][];
  21799. colors?: Nullable<Color4[][]>;
  21800. }): VertexData;
  21801. /**
  21802. * Create the VertexData for a DashedLines
  21803. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21804. * - points an array successive Vector3
  21805. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21806. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21807. * - dashNb the intended total number of dashes, optional, default 200
  21808. * @returns the VertexData for the DashedLines
  21809. */
  21810. static CreateDashedLines(options: {
  21811. points: Vector3[];
  21812. dashSize?: number;
  21813. gapSize?: number;
  21814. dashNb?: number;
  21815. }): VertexData;
  21816. /**
  21817. * Creates the VertexData for a Ground
  21818. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21819. * - width the width (x direction) of the ground, optional, default 1
  21820. * - height the height (z direction) of the ground, optional, default 1
  21821. * - subdivisions the number of subdivisions per side, optional, default 1
  21822. * @returns the VertexData of the Ground
  21823. */
  21824. static CreateGround(options: {
  21825. width?: number;
  21826. height?: number;
  21827. subdivisions?: number;
  21828. subdivisionsX?: number;
  21829. subdivisionsY?: number;
  21830. }): VertexData;
  21831. /**
  21832. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21833. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21834. * * xmin the ground minimum X coordinate, optional, default -1
  21835. * * zmin the ground minimum Z coordinate, optional, default -1
  21836. * * xmax the ground maximum X coordinate, optional, default 1
  21837. * * zmax the ground maximum Z coordinate, optional, default 1
  21838. * * 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}
  21839. * * 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}
  21840. * @returns the VertexData of the TiledGround
  21841. */
  21842. static CreateTiledGround(options: {
  21843. xmin: number;
  21844. zmin: number;
  21845. xmax: number;
  21846. zmax: number;
  21847. subdivisions?: {
  21848. w: number;
  21849. h: number;
  21850. };
  21851. precision?: {
  21852. w: number;
  21853. h: number;
  21854. };
  21855. }): VertexData;
  21856. /**
  21857. * Creates the VertexData of the Ground designed from a heightmap
  21858. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21859. * * width the width (x direction) of the ground
  21860. * * height the height (z direction) of the ground
  21861. * * subdivisions the number of subdivisions per side
  21862. * * minHeight the minimum altitude on the ground, optional, default 0
  21863. * * maxHeight the maximum altitude on the ground, optional default 1
  21864. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21865. * * buffer the array holding the image color data
  21866. * * bufferWidth the width of image
  21867. * * bufferHeight the height of image
  21868. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21869. * @returns the VertexData of the Ground designed from a heightmap
  21870. */
  21871. static CreateGroundFromHeightMap(options: {
  21872. width: number;
  21873. height: number;
  21874. subdivisions: number;
  21875. minHeight: number;
  21876. maxHeight: number;
  21877. colorFilter: Color3;
  21878. buffer: Uint8Array;
  21879. bufferWidth: number;
  21880. bufferHeight: number;
  21881. alphaFilter: number;
  21882. }): VertexData;
  21883. /**
  21884. * Creates the VertexData for a Plane
  21885. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21886. * * size sets the width and height of the plane to the value of size, optional default 1
  21887. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21888. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21890. * * 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)
  21891. * * 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)
  21892. * @returns the VertexData of the box
  21893. */
  21894. static CreatePlane(options: {
  21895. size?: number;
  21896. width?: number;
  21897. height?: number;
  21898. sideOrientation?: number;
  21899. frontUVs?: Vector4;
  21900. backUVs?: Vector4;
  21901. }): VertexData;
  21902. /**
  21903. * Creates the VertexData of the Disc or regular Polygon
  21904. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21905. * * radius the radius of the disc, optional default 0.5
  21906. * * tessellation the number of polygon sides, optional, default 64
  21907. * * 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
  21908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21909. * * 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)
  21910. * * 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)
  21911. * @returns the VertexData of the box
  21912. */
  21913. static CreateDisc(options: {
  21914. radius?: number;
  21915. tessellation?: number;
  21916. arc?: number;
  21917. sideOrientation?: number;
  21918. frontUVs?: Vector4;
  21919. backUVs?: Vector4;
  21920. }): VertexData;
  21921. /**
  21922. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21923. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21924. * @param polygon a mesh built from polygonTriangulation.build()
  21925. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21926. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21927. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21928. * @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)
  21929. * @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)
  21930. * @returns the VertexData of the Polygon
  21931. */
  21932. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21933. /**
  21934. * Creates the VertexData of the IcoSphere
  21935. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21936. * * radius the radius of the IcoSphere, optional default 1
  21937. * * radiusX allows stretching in the x direction, optional, default radius
  21938. * * radiusY allows stretching in the y direction, optional, default radius
  21939. * * radiusZ allows stretching in the z direction, optional, default radius
  21940. * * flat when true creates a flat shaded mesh, optional, default true
  21941. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21943. * * 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)
  21944. * * 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)
  21945. * @returns the VertexData of the IcoSphere
  21946. */
  21947. static CreateIcoSphere(options: {
  21948. radius?: number;
  21949. radiusX?: number;
  21950. radiusY?: number;
  21951. radiusZ?: number;
  21952. flat?: boolean;
  21953. subdivisions?: number;
  21954. sideOrientation?: number;
  21955. frontUVs?: Vector4;
  21956. backUVs?: Vector4;
  21957. }): VertexData;
  21958. /**
  21959. * Creates the VertexData for a Polyhedron
  21960. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21961. * * type provided types are:
  21962. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21963. * * 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)
  21964. * * size the size of the IcoSphere, optional default 1
  21965. * * sizeX allows stretching in the x direction, optional, default size
  21966. * * sizeY allows stretching in the y direction, optional, default size
  21967. * * sizeZ allows stretching in the z direction, optional, default size
  21968. * * 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
  21969. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21970. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21971. * * flat when true creates a flat shaded mesh, optional, default true
  21972. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21974. * * 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)
  21975. * * 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)
  21976. * @returns the VertexData of the Polyhedron
  21977. */
  21978. static CreatePolyhedron(options: {
  21979. type?: number;
  21980. size?: number;
  21981. sizeX?: number;
  21982. sizeY?: number;
  21983. sizeZ?: number;
  21984. custom?: any;
  21985. faceUV?: Vector4[];
  21986. faceColors?: Color4[];
  21987. flat?: boolean;
  21988. sideOrientation?: number;
  21989. frontUVs?: Vector4;
  21990. backUVs?: Vector4;
  21991. }): VertexData;
  21992. /**
  21993. * Creates the VertexData for a TorusKnot
  21994. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21995. * * radius the radius of the torus knot, optional, default 2
  21996. * * tube the thickness of the tube, optional, default 0.5
  21997. * * radialSegments the number of sides on each tube segments, optional, default 32
  21998. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21999. * * p the number of windings around the z axis, optional, default 2
  22000. * * q the number of windings around the x axis, optional, default 3
  22001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * * 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)
  22003. * * 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)
  22004. * @returns the VertexData of the Torus Knot
  22005. */
  22006. static CreateTorusKnot(options: {
  22007. radius?: number;
  22008. tube?: number;
  22009. radialSegments?: number;
  22010. tubularSegments?: number;
  22011. p?: number;
  22012. q?: number;
  22013. sideOrientation?: number;
  22014. frontUVs?: Vector4;
  22015. backUVs?: Vector4;
  22016. }): VertexData;
  22017. /**
  22018. * Compute normals for given positions and indices
  22019. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22020. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22021. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22022. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22023. * * facetNormals : optional array of facet normals (vector3)
  22024. * * facetPositions : optional array of facet positions (vector3)
  22025. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22026. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22027. * * bInfo : optional bounding info, required for facetPartitioning computation
  22028. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22029. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22030. * * useRightHandedSystem: optional boolean to for right handed system computation
  22031. * * depthSort : optional boolean to enable the facet depth sort computation
  22032. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22033. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22034. */
  22035. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22036. facetNormals?: any;
  22037. facetPositions?: any;
  22038. facetPartitioning?: any;
  22039. ratio?: number;
  22040. bInfo?: any;
  22041. bbSize?: Vector3;
  22042. subDiv?: any;
  22043. useRightHandedSystem?: boolean;
  22044. depthSort?: boolean;
  22045. distanceTo?: Vector3;
  22046. depthSortedFacets?: any;
  22047. }): void;
  22048. /** @hidden */
  22049. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22050. /**
  22051. * Applies VertexData created from the imported parameters to the geometry
  22052. * @param parsedVertexData the parsed data from an imported file
  22053. * @param geometry the geometry to apply the VertexData to
  22054. */
  22055. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22056. }
  22057. }
  22058. declare module BABYLON {
  22059. /**
  22060. * Defines a target to use with MorphTargetManager
  22061. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22062. */
  22063. export class MorphTarget implements IAnimatable {
  22064. /** defines the name of the target */
  22065. name: string;
  22066. /**
  22067. * Gets or sets the list of animations
  22068. */
  22069. animations: Animation[];
  22070. private _scene;
  22071. private _positions;
  22072. private _normals;
  22073. private _tangents;
  22074. private _uvs;
  22075. private _influence;
  22076. /**
  22077. * Observable raised when the influence changes
  22078. */
  22079. onInfluenceChanged: Observable<boolean>;
  22080. /** @hidden */
  22081. _onDataLayoutChanged: Observable<void>;
  22082. /**
  22083. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22084. */
  22085. influence: number;
  22086. /**
  22087. * Gets or sets the id of the morph Target
  22088. */
  22089. id: string;
  22090. private _animationPropertiesOverride;
  22091. /**
  22092. * Gets or sets the animation properties override
  22093. */
  22094. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22095. /**
  22096. * Creates a new MorphTarget
  22097. * @param name defines the name of the target
  22098. * @param influence defines the influence to use
  22099. * @param scene defines the scene the morphtarget belongs to
  22100. */
  22101. constructor(
  22102. /** defines the name of the target */
  22103. name: string, influence?: number, scene?: Nullable<Scene>);
  22104. /**
  22105. * Gets a boolean defining if the target contains position data
  22106. */
  22107. readonly hasPositions: boolean;
  22108. /**
  22109. * Gets a boolean defining if the target contains normal data
  22110. */
  22111. readonly hasNormals: boolean;
  22112. /**
  22113. * Gets a boolean defining if the target contains tangent data
  22114. */
  22115. readonly hasTangents: boolean;
  22116. /**
  22117. * Gets a boolean defining if the target contains texture coordinates data
  22118. */
  22119. readonly hasUVs: boolean;
  22120. /**
  22121. * Affects position data to this target
  22122. * @param data defines the position data to use
  22123. */
  22124. setPositions(data: Nullable<FloatArray>): void;
  22125. /**
  22126. * Gets the position data stored in this target
  22127. * @returns a FloatArray containing the position data (or null if not present)
  22128. */
  22129. getPositions(): Nullable<FloatArray>;
  22130. /**
  22131. * Affects normal data to this target
  22132. * @param data defines the normal data to use
  22133. */
  22134. setNormals(data: Nullable<FloatArray>): void;
  22135. /**
  22136. * Gets the normal data stored in this target
  22137. * @returns a FloatArray containing the normal data (or null if not present)
  22138. */
  22139. getNormals(): Nullable<FloatArray>;
  22140. /**
  22141. * Affects tangent data to this target
  22142. * @param data defines the tangent data to use
  22143. */
  22144. setTangents(data: Nullable<FloatArray>): void;
  22145. /**
  22146. * Gets the tangent data stored in this target
  22147. * @returns a FloatArray containing the tangent data (or null if not present)
  22148. */
  22149. getTangents(): Nullable<FloatArray>;
  22150. /**
  22151. * Affects texture coordinates data to this target
  22152. * @param data defines the texture coordinates data to use
  22153. */
  22154. setUVs(data: Nullable<FloatArray>): void;
  22155. /**
  22156. * Gets the texture coordinates data stored in this target
  22157. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22158. */
  22159. getUVs(): Nullable<FloatArray>;
  22160. /**
  22161. * Serializes the current target into a Serialization object
  22162. * @returns the serialized object
  22163. */
  22164. serialize(): any;
  22165. /**
  22166. * Returns the string "MorphTarget"
  22167. * @returns "MorphTarget"
  22168. */
  22169. getClassName(): string;
  22170. /**
  22171. * Creates a new target from serialized data
  22172. * @param serializationObject defines the serialized data to use
  22173. * @returns a new MorphTarget
  22174. */
  22175. static Parse(serializationObject: any): MorphTarget;
  22176. /**
  22177. * Creates a MorphTarget from mesh data
  22178. * @param mesh defines the source mesh
  22179. * @param name defines the name to use for the new target
  22180. * @param influence defines the influence to attach to the target
  22181. * @returns a new MorphTarget
  22182. */
  22183. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22184. }
  22185. }
  22186. declare module BABYLON {
  22187. /**
  22188. * This class is used to deform meshes using morphing between different targets
  22189. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22190. */
  22191. export class MorphTargetManager {
  22192. private _targets;
  22193. private _targetInfluenceChangedObservers;
  22194. private _targetDataLayoutChangedObservers;
  22195. private _activeTargets;
  22196. private _scene;
  22197. private _influences;
  22198. private _supportsNormals;
  22199. private _supportsTangents;
  22200. private _supportsUVs;
  22201. private _vertexCount;
  22202. private _uniqueId;
  22203. private _tempInfluences;
  22204. /**
  22205. * Gets or sets a boolean indicating if normals must be morphed
  22206. */
  22207. enableNormalMorphing: boolean;
  22208. /**
  22209. * Gets or sets a boolean indicating if tangents must be morphed
  22210. */
  22211. enableTangentMorphing: boolean;
  22212. /**
  22213. * Gets or sets a boolean indicating if UV must be morphed
  22214. */
  22215. enableUVMorphing: boolean;
  22216. /**
  22217. * Creates a new MorphTargetManager
  22218. * @param scene defines the current scene
  22219. */
  22220. constructor(scene?: Nullable<Scene>);
  22221. /**
  22222. * Gets the unique ID of this manager
  22223. */
  22224. readonly uniqueId: number;
  22225. /**
  22226. * Gets the number of vertices handled by this manager
  22227. */
  22228. readonly vertexCount: number;
  22229. /**
  22230. * Gets a boolean indicating if this manager supports morphing of normals
  22231. */
  22232. readonly supportsNormals: boolean;
  22233. /**
  22234. * Gets a boolean indicating if this manager supports morphing of tangents
  22235. */
  22236. readonly supportsTangents: boolean;
  22237. /**
  22238. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22239. */
  22240. readonly supportsUVs: boolean;
  22241. /**
  22242. * Gets the number of targets stored in this manager
  22243. */
  22244. readonly numTargets: number;
  22245. /**
  22246. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22247. */
  22248. readonly numInfluencers: number;
  22249. /**
  22250. * Gets the list of influences (one per target)
  22251. */
  22252. readonly influences: Float32Array;
  22253. /**
  22254. * Gets the active target at specified index. An active target is a target with an influence > 0
  22255. * @param index defines the index to check
  22256. * @returns the requested target
  22257. */
  22258. getActiveTarget(index: number): MorphTarget;
  22259. /**
  22260. * Gets the target at specified index
  22261. * @param index defines the index to check
  22262. * @returns the requested target
  22263. */
  22264. getTarget(index: number): MorphTarget;
  22265. /**
  22266. * Add a new target to this manager
  22267. * @param target defines the target to add
  22268. */
  22269. addTarget(target: MorphTarget): void;
  22270. /**
  22271. * Removes a target from the manager
  22272. * @param target defines the target to remove
  22273. */
  22274. removeTarget(target: MorphTarget): void;
  22275. /**
  22276. * Serializes the current manager into a Serialization object
  22277. * @returns the serialized object
  22278. */
  22279. serialize(): any;
  22280. private _syncActiveTargets;
  22281. /**
  22282. * Syncrhonize the targets with all the meshes using this morph target manager
  22283. */
  22284. synchronize(): void;
  22285. /**
  22286. * Creates a new MorphTargetManager from serialized data
  22287. * @param serializationObject defines the serialized data
  22288. * @param scene defines the hosting scene
  22289. * @returns the new MorphTargetManager
  22290. */
  22291. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22292. }
  22293. }
  22294. declare module BABYLON {
  22295. /**
  22296. * Class used to represent a specific level of detail of a mesh
  22297. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22298. */
  22299. export class MeshLODLevel {
  22300. /** Defines the distance where this level should start being displayed */
  22301. distance: number;
  22302. /** Defines the mesh to use to render this level */
  22303. mesh: Nullable<Mesh>;
  22304. /**
  22305. * Creates a new LOD level
  22306. * @param distance defines the distance where this level should star being displayed
  22307. * @param mesh defines the mesh to use to render this level
  22308. */
  22309. constructor(
  22310. /** Defines the distance where this level should start being displayed */
  22311. distance: number,
  22312. /** Defines the mesh to use to render this level */
  22313. mesh: Nullable<Mesh>);
  22314. }
  22315. }
  22316. declare module BABYLON {
  22317. /**
  22318. * Mesh representing the gorund
  22319. */
  22320. export class GroundMesh extends Mesh {
  22321. /** If octree should be generated */
  22322. generateOctree: boolean;
  22323. private _heightQuads;
  22324. /** @hidden */
  22325. _subdivisionsX: number;
  22326. /** @hidden */
  22327. _subdivisionsY: number;
  22328. /** @hidden */
  22329. _width: number;
  22330. /** @hidden */
  22331. _height: number;
  22332. /** @hidden */
  22333. _minX: number;
  22334. /** @hidden */
  22335. _maxX: number;
  22336. /** @hidden */
  22337. _minZ: number;
  22338. /** @hidden */
  22339. _maxZ: number;
  22340. constructor(name: string, scene: Scene);
  22341. /**
  22342. * "GroundMesh"
  22343. * @returns "GroundMesh"
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * The minimum of x and y subdivisions
  22348. */
  22349. readonly subdivisions: number;
  22350. /**
  22351. * X subdivisions
  22352. */
  22353. readonly subdivisionsX: number;
  22354. /**
  22355. * Y subdivisions
  22356. */
  22357. readonly subdivisionsY: number;
  22358. /**
  22359. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22360. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22361. * @param chunksCount the number of subdivisions for x and y
  22362. * @param octreeBlocksSize (Default: 32)
  22363. */
  22364. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22365. /**
  22366. * Returns a height (y) value in the Worl system :
  22367. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22368. * @param x x coordinate
  22369. * @param z z coordinate
  22370. * @returns the ground y position if (x, z) are outside the ground surface.
  22371. */
  22372. getHeightAtCoordinates(x: number, z: number): number;
  22373. /**
  22374. * Returns a normalized vector (Vector3) orthogonal to the ground
  22375. * at the ground coordinates (x, z) expressed in the World system.
  22376. * @param x x coordinate
  22377. * @param z z coordinate
  22378. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22379. */
  22380. getNormalAtCoordinates(x: number, z: number): Vector3;
  22381. /**
  22382. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22383. * at the ground coordinates (x, z) expressed in the World system.
  22384. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22385. * @param x x coordinate
  22386. * @param z z coordinate
  22387. * @param ref vector to store the result
  22388. * @returns the GroundMesh.
  22389. */
  22390. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22391. /**
  22392. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22393. * if the ground has been updated.
  22394. * This can be used in the render loop.
  22395. * @returns the GroundMesh.
  22396. */
  22397. updateCoordinateHeights(): GroundMesh;
  22398. private _getFacetAt;
  22399. private _initHeightQuads;
  22400. private _computeHeightQuads;
  22401. /**
  22402. * Serializes this ground mesh
  22403. * @param serializationObject object to write serialization to
  22404. */
  22405. serialize(serializationObject: any): void;
  22406. /**
  22407. * Parses a serialized ground mesh
  22408. * @param parsedMesh the serialized mesh
  22409. * @param scene the scene to create the ground mesh in
  22410. * @returns the created ground mesh
  22411. */
  22412. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22413. }
  22414. }
  22415. declare module BABYLON {
  22416. /**
  22417. * Interface for Physics-Joint data
  22418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22419. */
  22420. export interface PhysicsJointData {
  22421. /**
  22422. * The main pivot of the joint
  22423. */
  22424. mainPivot?: Vector3;
  22425. /**
  22426. * The connected pivot of the joint
  22427. */
  22428. connectedPivot?: Vector3;
  22429. /**
  22430. * The main axis of the joint
  22431. */
  22432. mainAxis?: Vector3;
  22433. /**
  22434. * The connected axis of the joint
  22435. */
  22436. connectedAxis?: Vector3;
  22437. /**
  22438. * The collision of the joint
  22439. */
  22440. collision?: boolean;
  22441. /**
  22442. * Native Oimo/Cannon/Energy data
  22443. */
  22444. nativeParams?: any;
  22445. }
  22446. /**
  22447. * This is a holder class for the physics joint created by the physics plugin
  22448. * It holds a set of functions to control the underlying joint
  22449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22450. */
  22451. export class PhysicsJoint {
  22452. /**
  22453. * The type of the physics joint
  22454. */
  22455. type: number;
  22456. /**
  22457. * The data for the physics joint
  22458. */
  22459. jointData: PhysicsJointData;
  22460. private _physicsJoint;
  22461. protected _physicsPlugin: IPhysicsEnginePlugin;
  22462. /**
  22463. * Initializes the physics joint
  22464. * @param type The type of the physics joint
  22465. * @param jointData The data for the physics joint
  22466. */
  22467. constructor(
  22468. /**
  22469. * The type of the physics joint
  22470. */
  22471. type: number,
  22472. /**
  22473. * The data for the physics joint
  22474. */
  22475. jointData: PhysicsJointData);
  22476. /**
  22477. * Gets the physics joint
  22478. */
  22479. /**
  22480. * Sets the physics joint
  22481. */
  22482. physicsJoint: any;
  22483. /**
  22484. * Sets the physics plugin
  22485. */
  22486. physicsPlugin: IPhysicsEnginePlugin;
  22487. /**
  22488. * Execute a function that is physics-plugin specific.
  22489. * @param {Function} func the function that will be executed.
  22490. * It accepts two parameters: the physics world and the physics joint
  22491. */
  22492. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22493. /**
  22494. * Distance-Joint type
  22495. */
  22496. static DistanceJoint: number;
  22497. /**
  22498. * Hinge-Joint type
  22499. */
  22500. static HingeJoint: number;
  22501. /**
  22502. * Ball-and-Socket joint type
  22503. */
  22504. static BallAndSocketJoint: number;
  22505. /**
  22506. * Wheel-Joint type
  22507. */
  22508. static WheelJoint: number;
  22509. /**
  22510. * Slider-Joint type
  22511. */
  22512. static SliderJoint: number;
  22513. /**
  22514. * Prismatic-Joint type
  22515. */
  22516. static PrismaticJoint: number;
  22517. /**
  22518. * Universal-Joint type
  22519. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22520. */
  22521. static UniversalJoint: number;
  22522. /**
  22523. * Hinge-Joint 2 type
  22524. */
  22525. static Hinge2Joint: number;
  22526. /**
  22527. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22528. */
  22529. static PointToPointJoint: number;
  22530. /**
  22531. * Spring-Joint type
  22532. */
  22533. static SpringJoint: number;
  22534. /**
  22535. * Lock-Joint type
  22536. */
  22537. static LockJoint: number;
  22538. }
  22539. /**
  22540. * A class representing a physics distance joint
  22541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22542. */
  22543. export class DistanceJoint extends PhysicsJoint {
  22544. /**
  22545. *
  22546. * @param jointData The data for the Distance-Joint
  22547. */
  22548. constructor(jointData: DistanceJointData);
  22549. /**
  22550. * Update the predefined distance.
  22551. * @param maxDistance The maximum preferred distance
  22552. * @param minDistance The minimum preferred distance
  22553. */
  22554. updateDistance(maxDistance: number, minDistance?: number): void;
  22555. }
  22556. /**
  22557. * Represents a Motor-Enabled Joint
  22558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22559. */
  22560. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22561. /**
  22562. * Initializes the Motor-Enabled Joint
  22563. * @param type The type of the joint
  22564. * @param jointData The physica joint data for the joint
  22565. */
  22566. constructor(type: number, jointData: PhysicsJointData);
  22567. /**
  22568. * Set the motor values.
  22569. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22570. * @param force the force to apply
  22571. * @param maxForce max force for this motor.
  22572. */
  22573. setMotor(force?: number, maxForce?: number): void;
  22574. /**
  22575. * Set the motor's limits.
  22576. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22577. * @param upperLimit The upper limit of the motor
  22578. * @param lowerLimit The lower limit of the motor
  22579. */
  22580. setLimit(upperLimit: number, lowerLimit?: number): void;
  22581. }
  22582. /**
  22583. * This class represents a single physics Hinge-Joint
  22584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22585. */
  22586. export class HingeJoint extends MotorEnabledJoint {
  22587. /**
  22588. * Initializes the Hinge-Joint
  22589. * @param jointData The joint data for the Hinge-Joint
  22590. */
  22591. constructor(jointData: PhysicsJointData);
  22592. /**
  22593. * Set the motor values.
  22594. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22595. * @param {number} force the force to apply
  22596. * @param {number} maxForce max force for this motor.
  22597. */
  22598. setMotor(force?: number, maxForce?: number): void;
  22599. /**
  22600. * Set the motor's limits.
  22601. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22602. * @param upperLimit The upper limit of the motor
  22603. * @param lowerLimit The lower limit of the motor
  22604. */
  22605. setLimit(upperLimit: number, lowerLimit?: number): void;
  22606. }
  22607. /**
  22608. * This class represents a dual hinge physics joint (same as wheel joint)
  22609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22610. */
  22611. export class Hinge2Joint extends MotorEnabledJoint {
  22612. /**
  22613. * Initializes the Hinge2-Joint
  22614. * @param jointData The joint data for the Hinge2-Joint
  22615. */
  22616. constructor(jointData: PhysicsJointData);
  22617. /**
  22618. * Set the motor values.
  22619. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22620. * @param {number} targetSpeed the speed the motor is to reach
  22621. * @param {number} maxForce max force for this motor.
  22622. * @param {motorIndex} the motor's index, 0 or 1.
  22623. */
  22624. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22625. /**
  22626. * Set the motor limits.
  22627. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22628. * @param {number} upperLimit the upper limit
  22629. * @param {number} lowerLimit lower limit
  22630. * @param {motorIndex} the motor's index, 0 or 1.
  22631. */
  22632. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22633. }
  22634. /**
  22635. * Interface for a motor enabled joint
  22636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22637. */
  22638. export interface IMotorEnabledJoint {
  22639. /**
  22640. * Physics joint
  22641. */
  22642. physicsJoint: any;
  22643. /**
  22644. * Sets the motor of the motor-enabled joint
  22645. * @param force The force of the motor
  22646. * @param maxForce The maximum force of the motor
  22647. * @param motorIndex The index of the motor
  22648. */
  22649. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22650. /**
  22651. * Sets the limit of the motor
  22652. * @param upperLimit The upper limit of the motor
  22653. * @param lowerLimit The lower limit of the motor
  22654. * @param motorIndex The index of the motor
  22655. */
  22656. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22657. }
  22658. /**
  22659. * Joint data for a Distance-Joint
  22660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22661. */
  22662. export interface DistanceJointData extends PhysicsJointData {
  22663. /**
  22664. * Max distance the 2 joint objects can be apart
  22665. */
  22666. maxDistance: number;
  22667. }
  22668. /**
  22669. * Joint data from a spring joint
  22670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22671. */
  22672. export interface SpringJointData extends PhysicsJointData {
  22673. /**
  22674. * Length of the spring
  22675. */
  22676. length: number;
  22677. /**
  22678. * Stiffness of the spring
  22679. */
  22680. stiffness: number;
  22681. /**
  22682. * Damping of the spring
  22683. */
  22684. damping: number;
  22685. /** this callback will be called when applying the force to the impostors. */
  22686. forceApplicationCallback: () => void;
  22687. }
  22688. }
  22689. declare module BABYLON {
  22690. /**
  22691. * Holds the data for the raycast result
  22692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22693. */
  22694. export class PhysicsRaycastResult {
  22695. private _hasHit;
  22696. private _hitDistance;
  22697. private _hitNormalWorld;
  22698. private _hitPointWorld;
  22699. private _rayFromWorld;
  22700. private _rayToWorld;
  22701. /**
  22702. * Gets if there was a hit
  22703. */
  22704. readonly hasHit: boolean;
  22705. /**
  22706. * Gets the distance from the hit
  22707. */
  22708. readonly hitDistance: number;
  22709. /**
  22710. * Gets the hit normal/direction in the world
  22711. */
  22712. readonly hitNormalWorld: Vector3;
  22713. /**
  22714. * Gets the hit point in the world
  22715. */
  22716. readonly hitPointWorld: Vector3;
  22717. /**
  22718. * Gets the ray "start point" of the ray in the world
  22719. */
  22720. readonly rayFromWorld: Vector3;
  22721. /**
  22722. * Gets the ray "end point" of the ray in the world
  22723. */
  22724. readonly rayToWorld: Vector3;
  22725. /**
  22726. * Sets the hit data (normal & point in world space)
  22727. * @param hitNormalWorld defines the normal in world space
  22728. * @param hitPointWorld defines the point in world space
  22729. */
  22730. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22731. /**
  22732. * Sets the distance from the start point to the hit point
  22733. * @param distance
  22734. */
  22735. setHitDistance(distance: number): void;
  22736. /**
  22737. * Calculates the distance manually
  22738. */
  22739. calculateHitDistance(): void;
  22740. /**
  22741. * Resets all the values to default
  22742. * @param from The from point on world space
  22743. * @param to The to point on world space
  22744. */
  22745. reset(from?: Vector3, to?: Vector3): void;
  22746. }
  22747. /**
  22748. * Interface for the size containing width and height
  22749. */
  22750. interface IXYZ {
  22751. /**
  22752. * X
  22753. */
  22754. x: number;
  22755. /**
  22756. * Y
  22757. */
  22758. y: number;
  22759. /**
  22760. * Z
  22761. */
  22762. z: number;
  22763. }
  22764. }
  22765. declare module BABYLON {
  22766. /**
  22767. * Interface used to describe a physics joint
  22768. */
  22769. export interface PhysicsImpostorJoint {
  22770. /** Defines the main impostor to which the joint is linked */
  22771. mainImpostor: PhysicsImpostor;
  22772. /** Defines the impostor that is connected to the main impostor using this joint */
  22773. connectedImpostor: PhysicsImpostor;
  22774. /** Defines the joint itself */
  22775. joint: PhysicsJoint;
  22776. }
  22777. /** @hidden */
  22778. export interface IPhysicsEnginePlugin {
  22779. world: any;
  22780. name: string;
  22781. setGravity(gravity: Vector3): void;
  22782. setTimeStep(timeStep: number): void;
  22783. getTimeStep(): number;
  22784. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22785. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22786. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22787. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22788. removePhysicsBody(impostor: PhysicsImpostor): void;
  22789. generateJoint(joint: PhysicsImpostorJoint): void;
  22790. removeJoint(joint: PhysicsImpostorJoint): void;
  22791. isSupported(): boolean;
  22792. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22793. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22794. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22795. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22796. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22797. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22798. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22799. getBodyMass(impostor: PhysicsImpostor): number;
  22800. getBodyFriction(impostor: PhysicsImpostor): number;
  22801. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22802. getBodyRestitution(impostor: PhysicsImpostor): number;
  22803. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22804. getBodyPressure?(impostor: PhysicsImpostor): number;
  22805. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22806. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22807. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22808. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22809. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22810. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22811. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22812. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22813. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22814. sleepBody(impostor: PhysicsImpostor): void;
  22815. wakeUpBody(impostor: PhysicsImpostor): void;
  22816. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22817. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22818. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22819. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22820. getRadius(impostor: PhysicsImpostor): number;
  22821. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22822. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22823. dispose(): void;
  22824. }
  22825. /**
  22826. * Interface used to define a physics engine
  22827. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22828. */
  22829. export interface IPhysicsEngine {
  22830. /**
  22831. * Gets the gravity vector used by the simulation
  22832. */
  22833. gravity: Vector3;
  22834. /**
  22835. * Sets the gravity vector used by the simulation
  22836. * @param gravity defines the gravity vector to use
  22837. */
  22838. setGravity(gravity: Vector3): void;
  22839. /**
  22840. * Set the time step of the physics engine.
  22841. * Default is 1/60.
  22842. * To slow it down, enter 1/600 for example.
  22843. * To speed it up, 1/30
  22844. * @param newTimeStep the new timestep to apply to this world.
  22845. */
  22846. setTimeStep(newTimeStep: number): void;
  22847. /**
  22848. * Get the time step of the physics engine.
  22849. * @returns the current time step
  22850. */
  22851. getTimeStep(): number;
  22852. /**
  22853. * Release all resources
  22854. */
  22855. dispose(): void;
  22856. /**
  22857. * Gets the name of the current physics plugin
  22858. * @returns the name of the plugin
  22859. */
  22860. getPhysicsPluginName(): string;
  22861. /**
  22862. * Adding a new impostor for the impostor tracking.
  22863. * This will be done by the impostor itself.
  22864. * @param impostor the impostor to add
  22865. */
  22866. addImpostor(impostor: PhysicsImpostor): void;
  22867. /**
  22868. * Remove an impostor from the engine.
  22869. * This impostor and its mesh will not longer be updated by the physics engine.
  22870. * @param impostor the impostor to remove
  22871. */
  22872. removeImpostor(impostor: PhysicsImpostor): void;
  22873. /**
  22874. * Add a joint to the physics engine
  22875. * @param mainImpostor defines the main impostor to which the joint is added.
  22876. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22877. * @param joint defines the joint that will connect both impostors.
  22878. */
  22879. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22880. /**
  22881. * Removes a joint from the simulation
  22882. * @param mainImpostor defines the impostor used with the joint
  22883. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22884. * @param joint defines the joint to remove
  22885. */
  22886. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22887. /**
  22888. * Gets the current plugin used to run the simulation
  22889. * @returns current plugin
  22890. */
  22891. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22892. /**
  22893. * Gets the list of physic impostors
  22894. * @returns an array of PhysicsImpostor
  22895. */
  22896. getImpostors(): Array<PhysicsImpostor>;
  22897. /**
  22898. * Gets the impostor for a physics enabled object
  22899. * @param object defines the object impersonated by the impostor
  22900. * @returns the PhysicsImpostor or null if not found
  22901. */
  22902. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22903. /**
  22904. * Gets the impostor for a physics body object
  22905. * @param body defines physics body used by the impostor
  22906. * @returns the PhysicsImpostor or null if not found
  22907. */
  22908. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22909. /**
  22910. * Does a raycast in the physics world
  22911. * @param from when should the ray start?
  22912. * @param to when should the ray end?
  22913. * @returns PhysicsRaycastResult
  22914. */
  22915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22916. /**
  22917. * Called by the scene. No need to call it.
  22918. * @param delta defines the timespam between frames
  22919. */
  22920. _step(delta: number): void;
  22921. }
  22922. }
  22923. declare module BABYLON {
  22924. /**
  22925. * The interface for the physics imposter parameters
  22926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22927. */
  22928. export interface PhysicsImpostorParameters {
  22929. /**
  22930. * The mass of the physics imposter
  22931. */
  22932. mass: number;
  22933. /**
  22934. * The friction of the physics imposter
  22935. */
  22936. friction?: number;
  22937. /**
  22938. * The coefficient of restitution of the physics imposter
  22939. */
  22940. restitution?: number;
  22941. /**
  22942. * The native options of the physics imposter
  22943. */
  22944. nativeOptions?: any;
  22945. /**
  22946. * Specifies if the parent should be ignored
  22947. */
  22948. ignoreParent?: boolean;
  22949. /**
  22950. * Specifies if bi-directional transformations should be disabled
  22951. */
  22952. disableBidirectionalTransformation?: boolean;
  22953. /**
  22954. * The pressure inside the physics imposter, soft object only
  22955. */
  22956. pressure?: number;
  22957. /**
  22958. * The stiffness the physics imposter, soft object only
  22959. */
  22960. stiffness?: number;
  22961. /**
  22962. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22963. */
  22964. velocityIterations?: number;
  22965. /**
  22966. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22967. */
  22968. positionIterations?: number;
  22969. /**
  22970. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22971. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22972. * Add to fix multiple points
  22973. */
  22974. fixedPoints?: number;
  22975. /**
  22976. * The collision margin around a soft object
  22977. */
  22978. margin?: number;
  22979. /**
  22980. * The collision margin around a soft object
  22981. */
  22982. damping?: number;
  22983. /**
  22984. * The path for a rope based on an extrusion
  22985. */
  22986. path?: any;
  22987. /**
  22988. * The shape of an extrusion used for a rope based on an extrusion
  22989. */
  22990. shape?: any;
  22991. }
  22992. /**
  22993. * Interface for a physics-enabled object
  22994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22995. */
  22996. export interface IPhysicsEnabledObject {
  22997. /**
  22998. * The position of the physics-enabled object
  22999. */
  23000. position: Vector3;
  23001. /**
  23002. * The rotation of the physics-enabled object
  23003. */
  23004. rotationQuaternion: Nullable<Quaternion>;
  23005. /**
  23006. * The scale of the physics-enabled object
  23007. */
  23008. scaling: Vector3;
  23009. /**
  23010. * The rotation of the physics-enabled object
  23011. */
  23012. rotation?: Vector3;
  23013. /**
  23014. * The parent of the physics-enabled object
  23015. */
  23016. parent?: any;
  23017. /**
  23018. * The bounding info of the physics-enabled object
  23019. * @returns The bounding info of the physics-enabled object
  23020. */
  23021. getBoundingInfo(): BoundingInfo;
  23022. /**
  23023. * Computes the world matrix
  23024. * @param force Specifies if the world matrix should be computed by force
  23025. * @returns A world matrix
  23026. */
  23027. computeWorldMatrix(force: boolean): Matrix;
  23028. /**
  23029. * Gets the world matrix
  23030. * @returns A world matrix
  23031. */
  23032. getWorldMatrix?(): Matrix;
  23033. /**
  23034. * Gets the child meshes
  23035. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23036. * @returns An array of abstract meshes
  23037. */
  23038. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23039. /**
  23040. * Gets the vertex data
  23041. * @param kind The type of vertex data
  23042. * @returns A nullable array of numbers, or a float32 array
  23043. */
  23044. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23045. /**
  23046. * Gets the indices from the mesh
  23047. * @returns A nullable array of index arrays
  23048. */
  23049. getIndices?(): Nullable<IndicesArray>;
  23050. /**
  23051. * Gets the scene from the mesh
  23052. * @returns the indices array or null
  23053. */
  23054. getScene?(): Scene;
  23055. /**
  23056. * Gets the absolute position from the mesh
  23057. * @returns the absolute position
  23058. */
  23059. getAbsolutePosition(): Vector3;
  23060. /**
  23061. * Gets the absolute pivot point from the mesh
  23062. * @returns the absolute pivot point
  23063. */
  23064. getAbsolutePivotPoint(): Vector3;
  23065. /**
  23066. * Rotates the mesh
  23067. * @param axis The axis of rotation
  23068. * @param amount The amount of rotation
  23069. * @param space The space of the rotation
  23070. * @returns The rotation transform node
  23071. */
  23072. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23073. /**
  23074. * Translates the mesh
  23075. * @param axis The axis of translation
  23076. * @param distance The distance of translation
  23077. * @param space The space of the translation
  23078. * @returns The transform node
  23079. */
  23080. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23081. /**
  23082. * Sets the absolute position of the mesh
  23083. * @param absolutePosition The absolute position of the mesh
  23084. * @returns The transform node
  23085. */
  23086. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23087. /**
  23088. * Gets the class name of the mesh
  23089. * @returns The class name
  23090. */
  23091. getClassName(): string;
  23092. }
  23093. /**
  23094. * Represents a physics imposter
  23095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23096. */
  23097. export class PhysicsImpostor {
  23098. /**
  23099. * The physics-enabled object used as the physics imposter
  23100. */
  23101. object: IPhysicsEnabledObject;
  23102. /**
  23103. * The type of the physics imposter
  23104. */
  23105. type: number;
  23106. private _options;
  23107. private _scene?;
  23108. /**
  23109. * The default object size of the imposter
  23110. */
  23111. static DEFAULT_OBJECT_SIZE: Vector3;
  23112. /**
  23113. * The identity quaternion of the imposter
  23114. */
  23115. static IDENTITY_QUATERNION: Quaternion;
  23116. /** @hidden */
  23117. _pluginData: any;
  23118. private _physicsEngine;
  23119. private _physicsBody;
  23120. private _bodyUpdateRequired;
  23121. private _onBeforePhysicsStepCallbacks;
  23122. private _onAfterPhysicsStepCallbacks;
  23123. /** @hidden */
  23124. _onPhysicsCollideCallbacks: Array<{
  23125. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23126. otherImpostors: Array<PhysicsImpostor>;
  23127. }>;
  23128. private _deltaPosition;
  23129. private _deltaRotation;
  23130. private _deltaRotationConjugated;
  23131. /** @hidden */
  23132. _isFromLine: boolean;
  23133. private _parent;
  23134. private _isDisposed;
  23135. private static _tmpVecs;
  23136. private static _tmpQuat;
  23137. /**
  23138. * Specifies if the physics imposter is disposed
  23139. */
  23140. readonly isDisposed: boolean;
  23141. /**
  23142. * Gets the mass of the physics imposter
  23143. */
  23144. mass: number;
  23145. /**
  23146. * Gets the coefficient of friction
  23147. */
  23148. /**
  23149. * Sets the coefficient of friction
  23150. */
  23151. friction: number;
  23152. /**
  23153. * Gets the coefficient of restitution
  23154. */
  23155. /**
  23156. * Sets the coefficient of restitution
  23157. */
  23158. restitution: number;
  23159. /**
  23160. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23161. */
  23162. /**
  23163. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23164. */
  23165. pressure: number;
  23166. /**
  23167. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23168. */
  23169. /**
  23170. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23171. */
  23172. stiffness: number;
  23173. /**
  23174. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23175. */
  23176. /**
  23177. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23178. */
  23179. velocityIterations: number;
  23180. /**
  23181. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23182. */
  23183. /**
  23184. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23185. */
  23186. positionIterations: number;
  23187. /**
  23188. * The unique id of the physics imposter
  23189. * set by the physics engine when adding this impostor to the array
  23190. */
  23191. uniqueId: number;
  23192. /**
  23193. * @hidden
  23194. */
  23195. soft: boolean;
  23196. /**
  23197. * @hidden
  23198. */
  23199. segments: number;
  23200. private _joints;
  23201. /**
  23202. * Initializes the physics imposter
  23203. * @param object The physics-enabled object used as the physics imposter
  23204. * @param type The type of the physics imposter
  23205. * @param _options The options for the physics imposter
  23206. * @param _scene The Babylon scene
  23207. */
  23208. constructor(
  23209. /**
  23210. * The physics-enabled object used as the physics imposter
  23211. */
  23212. object: IPhysicsEnabledObject,
  23213. /**
  23214. * The type of the physics imposter
  23215. */
  23216. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23217. /**
  23218. * This function will completly initialize this impostor.
  23219. * It will create a new body - but only if this mesh has no parent.
  23220. * If it has, this impostor will not be used other than to define the impostor
  23221. * of the child mesh.
  23222. * @hidden
  23223. */
  23224. _init(): void;
  23225. private _getPhysicsParent;
  23226. /**
  23227. * Should a new body be generated.
  23228. * @returns boolean specifying if body initialization is required
  23229. */
  23230. isBodyInitRequired(): boolean;
  23231. /**
  23232. * Sets the updated scaling
  23233. * @param updated Specifies if the scaling is updated
  23234. */
  23235. setScalingUpdated(): void;
  23236. /**
  23237. * Force a regeneration of this or the parent's impostor's body.
  23238. * Use under cautious - This will remove all joints already implemented.
  23239. */
  23240. forceUpdate(): void;
  23241. /**
  23242. * Gets the body that holds this impostor. Either its own, or its parent.
  23243. */
  23244. /**
  23245. * Set the physics body. Used mainly by the physics engine/plugin
  23246. */
  23247. physicsBody: any;
  23248. /**
  23249. * Get the parent of the physics imposter
  23250. * @returns Physics imposter or null
  23251. */
  23252. /**
  23253. * Sets the parent of the physics imposter
  23254. */
  23255. parent: Nullable<PhysicsImpostor>;
  23256. /**
  23257. * Resets the update flags
  23258. */
  23259. resetUpdateFlags(): void;
  23260. /**
  23261. * Gets the object extend size
  23262. * @returns the object extend size
  23263. */
  23264. getObjectExtendSize(): Vector3;
  23265. /**
  23266. * Gets the object center
  23267. * @returns The object center
  23268. */
  23269. getObjectCenter(): Vector3;
  23270. /**
  23271. * Get a specific parametes from the options parameter
  23272. * @param paramName The object parameter name
  23273. * @returns The object parameter
  23274. */
  23275. getParam(paramName: string): any;
  23276. /**
  23277. * Sets a specific parameter in the options given to the physics plugin
  23278. * @param paramName The parameter name
  23279. * @param value The value of the parameter
  23280. */
  23281. setParam(paramName: string, value: number): void;
  23282. /**
  23283. * Specifically change the body's mass option. Won't recreate the physics body object
  23284. * @param mass The mass of the physics imposter
  23285. */
  23286. setMass(mass: number): void;
  23287. /**
  23288. * Gets the linear velocity
  23289. * @returns linear velocity or null
  23290. */
  23291. getLinearVelocity(): Nullable<Vector3>;
  23292. /**
  23293. * Sets the linear velocity
  23294. * @param velocity linear velocity or null
  23295. */
  23296. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23297. /**
  23298. * Gets the angular velocity
  23299. * @returns angular velocity or null
  23300. */
  23301. getAngularVelocity(): Nullable<Vector3>;
  23302. /**
  23303. * Sets the angular velocity
  23304. * @param velocity The velocity or null
  23305. */
  23306. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23307. /**
  23308. * Execute a function with the physics plugin native code
  23309. * Provide a function the will have two variables - the world object and the physics body object
  23310. * @param func The function to execute with the physics plugin native code
  23311. */
  23312. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23313. /**
  23314. * Register a function that will be executed before the physics world is stepping forward
  23315. * @param func The function to execute before the physics world is stepped forward
  23316. */
  23317. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23318. /**
  23319. * Unregister a function that will be executed before the physics world is stepping forward
  23320. * @param func The function to execute before the physics world is stepped forward
  23321. */
  23322. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23323. /**
  23324. * Register a function that will be executed after the physics step
  23325. * @param func The function to execute after physics step
  23326. */
  23327. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23328. /**
  23329. * Unregisters a function that will be executed after the physics step
  23330. * @param func The function to execute after physics step
  23331. */
  23332. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23333. /**
  23334. * register a function that will be executed when this impostor collides against a different body
  23335. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23336. * @param func Callback that is executed on collision
  23337. */
  23338. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23339. /**
  23340. * Unregisters the physics imposter on contact
  23341. * @param collideAgainst The physics object to collide against
  23342. * @param func Callback to execute on collision
  23343. */
  23344. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23345. private _tmpQuat;
  23346. private _tmpQuat2;
  23347. /**
  23348. * Get the parent rotation
  23349. * @returns The parent rotation
  23350. */
  23351. getParentsRotation(): Quaternion;
  23352. /**
  23353. * this function is executed by the physics engine.
  23354. */
  23355. beforeStep: () => void;
  23356. /**
  23357. * this function is executed by the physics engine
  23358. */
  23359. afterStep: () => void;
  23360. /**
  23361. * Legacy collision detection event support
  23362. */
  23363. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23364. /**
  23365. * event and body object due to cannon's event-based architecture.
  23366. */
  23367. onCollide: (e: {
  23368. body: any;
  23369. }) => void;
  23370. /**
  23371. * Apply a force
  23372. * @param force The force to apply
  23373. * @param contactPoint The contact point for the force
  23374. * @returns The physics imposter
  23375. */
  23376. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23377. /**
  23378. * Apply an impulse
  23379. * @param force The impulse force
  23380. * @param contactPoint The contact point for the impulse force
  23381. * @returns The physics imposter
  23382. */
  23383. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23384. /**
  23385. * A help function to create a joint
  23386. * @param otherImpostor A physics imposter used to create a joint
  23387. * @param jointType The type of joint
  23388. * @param jointData The data for the joint
  23389. * @returns The physics imposter
  23390. */
  23391. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23392. /**
  23393. * Add a joint to this impostor with a different impostor
  23394. * @param otherImpostor A physics imposter used to add a joint
  23395. * @param joint The joint to add
  23396. * @returns The physics imposter
  23397. */
  23398. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23399. /**
  23400. * Add an anchor to a cloth impostor
  23401. * @param otherImpostor rigid impostor to anchor to
  23402. * @param width ratio across width from 0 to 1
  23403. * @param height ratio up height from 0 to 1
  23404. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23405. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23406. * @returns impostor the soft imposter
  23407. */
  23408. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23409. /**
  23410. * Add a hook to a rope impostor
  23411. * @param otherImpostor rigid impostor to anchor to
  23412. * @param length ratio across rope from 0 to 1
  23413. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23414. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23415. * @returns impostor the rope imposter
  23416. */
  23417. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23418. /**
  23419. * Will keep this body still, in a sleep mode.
  23420. * @returns the physics imposter
  23421. */
  23422. sleep(): PhysicsImpostor;
  23423. /**
  23424. * Wake the body up.
  23425. * @returns The physics imposter
  23426. */
  23427. wakeUp(): PhysicsImpostor;
  23428. /**
  23429. * Clones the physics imposter
  23430. * @param newObject The physics imposter clones to this physics-enabled object
  23431. * @returns A nullable physics imposter
  23432. */
  23433. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23434. /**
  23435. * Disposes the physics imposter
  23436. */
  23437. dispose(): void;
  23438. /**
  23439. * Sets the delta position
  23440. * @param position The delta position amount
  23441. */
  23442. setDeltaPosition(position: Vector3): void;
  23443. /**
  23444. * Sets the delta rotation
  23445. * @param rotation The delta rotation amount
  23446. */
  23447. setDeltaRotation(rotation: Quaternion): void;
  23448. /**
  23449. * Gets the box size of the physics imposter and stores the result in the input parameter
  23450. * @param result Stores the box size
  23451. * @returns The physics imposter
  23452. */
  23453. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23454. /**
  23455. * Gets the radius of the physics imposter
  23456. * @returns Radius of the physics imposter
  23457. */
  23458. getRadius(): number;
  23459. /**
  23460. * Sync a bone with this impostor
  23461. * @param bone The bone to sync to the impostor.
  23462. * @param boneMesh The mesh that the bone is influencing.
  23463. * @param jointPivot The pivot of the joint / bone in local space.
  23464. * @param distToJoint Optional distance from the impostor to the joint.
  23465. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23466. */
  23467. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23468. /**
  23469. * Sync impostor to a bone
  23470. * @param bone The bone that the impostor will be synced to.
  23471. * @param boneMesh The mesh that the bone is influencing.
  23472. * @param jointPivot The pivot of the joint / bone in local space.
  23473. * @param distToJoint Optional distance from the impostor to the joint.
  23474. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23475. * @param boneAxis Optional vector3 axis the bone is aligned with
  23476. */
  23477. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23478. /**
  23479. * No-Imposter type
  23480. */
  23481. static NoImpostor: number;
  23482. /**
  23483. * Sphere-Imposter type
  23484. */
  23485. static SphereImpostor: number;
  23486. /**
  23487. * Box-Imposter type
  23488. */
  23489. static BoxImpostor: number;
  23490. /**
  23491. * Plane-Imposter type
  23492. */
  23493. static PlaneImpostor: number;
  23494. /**
  23495. * Mesh-imposter type
  23496. */
  23497. static MeshImpostor: number;
  23498. /**
  23499. * Capsule-Impostor type (Ammo.js plugin only)
  23500. */
  23501. static CapsuleImpostor: number;
  23502. /**
  23503. * Cylinder-Imposter type
  23504. */
  23505. static CylinderImpostor: number;
  23506. /**
  23507. * Particle-Imposter type
  23508. */
  23509. static ParticleImpostor: number;
  23510. /**
  23511. * Heightmap-Imposter type
  23512. */
  23513. static HeightmapImpostor: number;
  23514. /**
  23515. * ConvexHull-Impostor type (Ammo.js plugin only)
  23516. */
  23517. static ConvexHullImpostor: number;
  23518. /**
  23519. * Rope-Imposter type
  23520. */
  23521. static RopeImpostor: number;
  23522. /**
  23523. * Cloth-Imposter type
  23524. */
  23525. static ClothImpostor: number;
  23526. /**
  23527. * Softbody-Imposter type
  23528. */
  23529. static SoftbodyImpostor: number;
  23530. }
  23531. }
  23532. declare module BABYLON {
  23533. /**
  23534. * @hidden
  23535. **/
  23536. export class _CreationDataStorage {
  23537. closePath?: boolean;
  23538. closeArray?: boolean;
  23539. idx: number[];
  23540. dashSize: number;
  23541. gapSize: number;
  23542. path3D: Path3D;
  23543. pathArray: Vector3[][];
  23544. arc: number;
  23545. radius: number;
  23546. cap: number;
  23547. tessellation: number;
  23548. }
  23549. /**
  23550. * @hidden
  23551. **/
  23552. class _InstanceDataStorage {
  23553. visibleInstances: any;
  23554. batchCache: _InstancesBatch;
  23555. instancesBufferSize: number;
  23556. instancesBuffer: Nullable<Buffer>;
  23557. instancesData: Float32Array;
  23558. overridenInstanceCount: number;
  23559. isFrozen: boolean;
  23560. previousBatch: Nullable<_InstancesBatch>;
  23561. hardwareInstancedRendering: boolean;
  23562. sideOrientation: number;
  23563. }
  23564. /**
  23565. * @hidden
  23566. **/
  23567. export class _InstancesBatch {
  23568. mustReturn: boolean;
  23569. visibleInstances: Nullable<InstancedMesh[]>[];
  23570. renderSelf: boolean[];
  23571. hardwareInstancedRendering: boolean[];
  23572. }
  23573. /**
  23574. * Class used to represent renderable models
  23575. */
  23576. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23577. /**
  23578. * Mesh side orientation : usually the external or front surface
  23579. */
  23580. static readonly FRONTSIDE: number;
  23581. /**
  23582. * Mesh side orientation : usually the internal or back surface
  23583. */
  23584. static readonly BACKSIDE: number;
  23585. /**
  23586. * Mesh side orientation : both internal and external or front and back surfaces
  23587. */
  23588. static readonly DOUBLESIDE: number;
  23589. /**
  23590. * Mesh side orientation : by default, `FRONTSIDE`
  23591. */
  23592. static readonly DEFAULTSIDE: number;
  23593. /**
  23594. * Mesh cap setting : no cap
  23595. */
  23596. static readonly NO_CAP: number;
  23597. /**
  23598. * Mesh cap setting : one cap at the beginning of the mesh
  23599. */
  23600. static readonly CAP_START: number;
  23601. /**
  23602. * Mesh cap setting : one cap at the end of the mesh
  23603. */
  23604. static readonly CAP_END: number;
  23605. /**
  23606. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23607. */
  23608. static readonly CAP_ALL: number;
  23609. /**
  23610. * Mesh pattern setting : no flip or rotate
  23611. */
  23612. static readonly NO_FLIP: number;
  23613. /**
  23614. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23615. */
  23616. static readonly FLIP_TILE: number;
  23617. /**
  23618. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23619. */
  23620. static readonly ROTATE_TILE: number;
  23621. /**
  23622. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23623. */
  23624. static readonly FLIP_ROW: number;
  23625. /**
  23626. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23627. */
  23628. static readonly ROTATE_ROW: number;
  23629. /**
  23630. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23631. */
  23632. static readonly FLIP_N_ROTATE_TILE: number;
  23633. /**
  23634. * Mesh pattern setting : rotate pattern and rotate
  23635. */
  23636. static readonly FLIP_N_ROTATE_ROW: number;
  23637. /**
  23638. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23639. */
  23640. static readonly CENTER: number;
  23641. /**
  23642. * Mesh tile positioning : part tiles on left
  23643. */
  23644. static readonly LEFT: number;
  23645. /**
  23646. * Mesh tile positioning : part tiles on right
  23647. */
  23648. static readonly RIGHT: number;
  23649. /**
  23650. * Mesh tile positioning : part tiles on top
  23651. */
  23652. static readonly TOP: number;
  23653. /**
  23654. * Mesh tile positioning : part tiles on bottom
  23655. */
  23656. static readonly BOTTOM: number;
  23657. /**
  23658. * Gets the default side orientation.
  23659. * @param orientation the orientation to value to attempt to get
  23660. * @returns the default orientation
  23661. * @hidden
  23662. */
  23663. static _GetDefaultSideOrientation(orientation?: number): number;
  23664. private _internalMeshDataInfo;
  23665. /**
  23666. * An event triggered before rendering the mesh
  23667. */
  23668. readonly onBeforeRenderObservable: Observable<Mesh>;
  23669. /**
  23670. * An event triggered before binding the mesh
  23671. */
  23672. readonly onBeforeBindObservable: Observable<Mesh>;
  23673. /**
  23674. * An event triggered after rendering the mesh
  23675. */
  23676. readonly onAfterRenderObservable: Observable<Mesh>;
  23677. /**
  23678. * An event triggered before drawing the mesh
  23679. */
  23680. readonly onBeforeDrawObservable: Observable<Mesh>;
  23681. private _onBeforeDrawObserver;
  23682. /**
  23683. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23684. */
  23685. onBeforeDraw: () => void;
  23686. readonly hasInstances: boolean;
  23687. /**
  23688. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23689. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23690. */
  23691. delayLoadState: number;
  23692. /**
  23693. * Gets the list of instances created from this mesh
  23694. * it is not supposed to be modified manually.
  23695. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23697. */
  23698. instances: InstancedMesh[];
  23699. /**
  23700. * Gets the file containing delay loading data for this mesh
  23701. */
  23702. delayLoadingFile: string;
  23703. /** @hidden */
  23704. _binaryInfo: any;
  23705. /**
  23706. * User defined function used to change how LOD level selection is done
  23707. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23708. */
  23709. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23710. /**
  23711. * Gets or sets the morph target manager
  23712. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23713. */
  23714. morphTargetManager: Nullable<MorphTargetManager>;
  23715. /** @hidden */
  23716. _creationDataStorage: Nullable<_CreationDataStorage>;
  23717. /** @hidden */
  23718. _geometry: Nullable<Geometry>;
  23719. /** @hidden */
  23720. _delayInfo: Array<string>;
  23721. /** @hidden */
  23722. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23723. /** @hidden */
  23724. _instanceDataStorage: _InstanceDataStorage;
  23725. private _effectiveMaterial;
  23726. /** @hidden */
  23727. _shouldGenerateFlatShading: boolean;
  23728. /** @hidden */
  23729. _originalBuilderSideOrientation: number;
  23730. /**
  23731. * Use this property to change the original side orientation defined at construction time
  23732. */
  23733. overrideMaterialSideOrientation: Nullable<number>;
  23734. /**
  23735. * Gets the source mesh (the one used to clone this one from)
  23736. */
  23737. readonly source: Nullable<Mesh>;
  23738. /**
  23739. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23740. */
  23741. isUnIndexed: boolean;
  23742. /**
  23743. * @constructor
  23744. * @param name The value used by scene.getMeshByName() to do a lookup.
  23745. * @param scene The scene to add this mesh to.
  23746. * @param parent The parent of this mesh, if it has one
  23747. * @param source An optional Mesh from which geometry is shared, cloned.
  23748. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23749. * When false, achieved by calling a clone(), also passing False.
  23750. * This will make creation of children, recursive.
  23751. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23752. */
  23753. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23754. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23755. /**
  23756. * Gets the class name
  23757. * @returns the string "Mesh".
  23758. */
  23759. getClassName(): string;
  23760. /** @hidden */
  23761. readonly _isMesh: boolean;
  23762. /**
  23763. * Returns a description of this mesh
  23764. * @param fullDetails define if full details about this mesh must be used
  23765. * @returns a descriptive string representing this mesh
  23766. */
  23767. toString(fullDetails?: boolean): string;
  23768. /** @hidden */
  23769. _unBindEffect(): void;
  23770. /**
  23771. * Gets a boolean indicating if this mesh has LOD
  23772. */
  23773. readonly hasLODLevels: boolean;
  23774. /**
  23775. * Gets the list of MeshLODLevel associated with the current mesh
  23776. * @returns an array of MeshLODLevel
  23777. */
  23778. getLODLevels(): MeshLODLevel[];
  23779. private _sortLODLevels;
  23780. /**
  23781. * Add a mesh as LOD level triggered at the given distance.
  23782. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23783. * @param distance The distance from the center of the object to show this level
  23784. * @param mesh The mesh to be added as LOD level (can be null)
  23785. * @return This mesh (for chaining)
  23786. */
  23787. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23788. /**
  23789. * Returns the LOD level mesh at the passed distance or null if not found.
  23790. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23791. * @param distance The distance from the center of the object to show this level
  23792. * @returns a Mesh or `null`
  23793. */
  23794. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23795. /**
  23796. * Remove a mesh from the LOD array
  23797. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23798. * @param mesh defines the mesh to be removed
  23799. * @return This mesh (for chaining)
  23800. */
  23801. removeLODLevel(mesh: Mesh): Mesh;
  23802. /**
  23803. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23804. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23805. * @param camera defines the camera to use to compute distance
  23806. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23807. * @return This mesh (for chaining)
  23808. */
  23809. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23810. /**
  23811. * Gets the mesh internal Geometry object
  23812. */
  23813. readonly geometry: Nullable<Geometry>;
  23814. /**
  23815. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23816. * @returns the total number of vertices
  23817. */
  23818. getTotalVertices(): number;
  23819. /**
  23820. * Returns the content of an associated vertex buffer
  23821. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23822. * - VertexBuffer.PositionKind
  23823. * - VertexBuffer.UVKind
  23824. * - VertexBuffer.UV2Kind
  23825. * - VertexBuffer.UV3Kind
  23826. * - VertexBuffer.UV4Kind
  23827. * - VertexBuffer.UV5Kind
  23828. * - VertexBuffer.UV6Kind
  23829. * - VertexBuffer.ColorKind
  23830. * - VertexBuffer.MatricesIndicesKind
  23831. * - VertexBuffer.MatricesIndicesExtraKind
  23832. * - VertexBuffer.MatricesWeightsKind
  23833. * - VertexBuffer.MatricesWeightsExtraKind
  23834. * @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
  23835. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23836. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23837. */
  23838. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23839. /**
  23840. * Returns the mesh VertexBuffer object from the requested `kind`
  23841. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23842. * - VertexBuffer.PositionKind
  23843. * - VertexBuffer.NormalKind
  23844. * - VertexBuffer.UVKind
  23845. * - VertexBuffer.UV2Kind
  23846. * - VertexBuffer.UV3Kind
  23847. * - VertexBuffer.UV4Kind
  23848. * - VertexBuffer.UV5Kind
  23849. * - VertexBuffer.UV6Kind
  23850. * - VertexBuffer.ColorKind
  23851. * - VertexBuffer.MatricesIndicesKind
  23852. * - VertexBuffer.MatricesIndicesExtraKind
  23853. * - VertexBuffer.MatricesWeightsKind
  23854. * - VertexBuffer.MatricesWeightsExtraKind
  23855. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23856. */
  23857. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23858. /**
  23859. * Tests if a specific vertex buffer is associated with this mesh
  23860. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23861. * - VertexBuffer.PositionKind
  23862. * - VertexBuffer.NormalKind
  23863. * - VertexBuffer.UVKind
  23864. * - VertexBuffer.UV2Kind
  23865. * - VertexBuffer.UV3Kind
  23866. * - VertexBuffer.UV4Kind
  23867. * - VertexBuffer.UV5Kind
  23868. * - VertexBuffer.UV6Kind
  23869. * - VertexBuffer.ColorKind
  23870. * - VertexBuffer.MatricesIndicesKind
  23871. * - VertexBuffer.MatricesIndicesExtraKind
  23872. * - VertexBuffer.MatricesWeightsKind
  23873. * - VertexBuffer.MatricesWeightsExtraKind
  23874. * @returns a boolean
  23875. */
  23876. isVerticesDataPresent(kind: string): boolean;
  23877. /**
  23878. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23879. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23880. * - VertexBuffer.PositionKind
  23881. * - VertexBuffer.UVKind
  23882. * - VertexBuffer.UV2Kind
  23883. * - VertexBuffer.UV3Kind
  23884. * - VertexBuffer.UV4Kind
  23885. * - VertexBuffer.UV5Kind
  23886. * - VertexBuffer.UV6Kind
  23887. * - VertexBuffer.ColorKind
  23888. * - VertexBuffer.MatricesIndicesKind
  23889. * - VertexBuffer.MatricesIndicesExtraKind
  23890. * - VertexBuffer.MatricesWeightsKind
  23891. * - VertexBuffer.MatricesWeightsExtraKind
  23892. * @returns a boolean
  23893. */
  23894. isVertexBufferUpdatable(kind: string): boolean;
  23895. /**
  23896. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23897. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23898. * - VertexBuffer.PositionKind
  23899. * - VertexBuffer.NormalKind
  23900. * - VertexBuffer.UVKind
  23901. * - VertexBuffer.UV2Kind
  23902. * - VertexBuffer.UV3Kind
  23903. * - VertexBuffer.UV4Kind
  23904. * - VertexBuffer.UV5Kind
  23905. * - VertexBuffer.UV6Kind
  23906. * - VertexBuffer.ColorKind
  23907. * - VertexBuffer.MatricesIndicesKind
  23908. * - VertexBuffer.MatricesIndicesExtraKind
  23909. * - VertexBuffer.MatricesWeightsKind
  23910. * - VertexBuffer.MatricesWeightsExtraKind
  23911. * @returns an array of strings
  23912. */
  23913. getVerticesDataKinds(): string[];
  23914. /**
  23915. * Returns a positive integer : the total number of indices in this mesh geometry.
  23916. * @returns the numner of indices or zero if the mesh has no geometry.
  23917. */
  23918. getTotalIndices(): number;
  23919. /**
  23920. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23921. * @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.
  23922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23923. * @returns the indices array or an empty array if the mesh has no geometry
  23924. */
  23925. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23926. readonly isBlocked: boolean;
  23927. /**
  23928. * Determine if the current mesh is ready to be rendered
  23929. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23930. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23931. * @returns true if all associated assets are ready (material, textures, shaders)
  23932. */
  23933. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23934. /**
  23935. * 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.
  23936. */
  23937. readonly areNormalsFrozen: boolean;
  23938. /**
  23939. * 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.
  23940. * @returns the current mesh
  23941. */
  23942. freezeNormals(): Mesh;
  23943. /**
  23944. * 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
  23945. * @returns the current mesh
  23946. */
  23947. unfreezeNormals(): Mesh;
  23948. /**
  23949. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23950. */
  23951. overridenInstanceCount: number;
  23952. /** @hidden */
  23953. _preActivate(): Mesh;
  23954. /** @hidden */
  23955. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23956. /** @hidden */
  23957. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23958. /**
  23959. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23960. * This means the mesh underlying bounding box and sphere are recomputed.
  23961. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23962. * @returns the current mesh
  23963. */
  23964. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23965. /** @hidden */
  23966. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23967. /**
  23968. * This function will subdivide the mesh into multiple submeshes
  23969. * @param count defines the expected number of submeshes
  23970. */
  23971. subdivide(count: number): void;
  23972. /**
  23973. * Copy a FloatArray into a specific associated vertex buffer
  23974. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23975. * - VertexBuffer.PositionKind
  23976. * - VertexBuffer.UVKind
  23977. * - VertexBuffer.UV2Kind
  23978. * - VertexBuffer.UV3Kind
  23979. * - VertexBuffer.UV4Kind
  23980. * - VertexBuffer.UV5Kind
  23981. * - VertexBuffer.UV6Kind
  23982. * - VertexBuffer.ColorKind
  23983. * - VertexBuffer.MatricesIndicesKind
  23984. * - VertexBuffer.MatricesIndicesExtraKind
  23985. * - VertexBuffer.MatricesWeightsKind
  23986. * - VertexBuffer.MatricesWeightsExtraKind
  23987. * @param data defines the data source
  23988. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23989. * @param stride defines the data stride size (can be null)
  23990. * @returns the current mesh
  23991. */
  23992. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23993. /**
  23994. * Delete a vertex buffer associated with this mesh
  23995. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23996. * - VertexBuffer.PositionKind
  23997. * - VertexBuffer.UVKind
  23998. * - VertexBuffer.UV2Kind
  23999. * - VertexBuffer.UV3Kind
  24000. * - VertexBuffer.UV4Kind
  24001. * - VertexBuffer.UV5Kind
  24002. * - VertexBuffer.UV6Kind
  24003. * - VertexBuffer.ColorKind
  24004. * - VertexBuffer.MatricesIndicesKind
  24005. * - VertexBuffer.MatricesIndicesExtraKind
  24006. * - VertexBuffer.MatricesWeightsKind
  24007. * - VertexBuffer.MatricesWeightsExtraKind
  24008. */
  24009. removeVerticesData(kind: string): void;
  24010. /**
  24011. * Flags an associated vertex buffer as updatable
  24012. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24013. * - VertexBuffer.PositionKind
  24014. * - VertexBuffer.UVKind
  24015. * - VertexBuffer.UV2Kind
  24016. * - VertexBuffer.UV3Kind
  24017. * - VertexBuffer.UV4Kind
  24018. * - VertexBuffer.UV5Kind
  24019. * - VertexBuffer.UV6Kind
  24020. * - VertexBuffer.ColorKind
  24021. * - VertexBuffer.MatricesIndicesKind
  24022. * - VertexBuffer.MatricesIndicesExtraKind
  24023. * - VertexBuffer.MatricesWeightsKind
  24024. * - VertexBuffer.MatricesWeightsExtraKind
  24025. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24026. */
  24027. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24028. /**
  24029. * Sets the mesh global Vertex Buffer
  24030. * @param buffer defines the buffer to use
  24031. * @returns the current mesh
  24032. */
  24033. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24034. /**
  24035. * Update a specific associated vertex buffer
  24036. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24037. * - VertexBuffer.PositionKind
  24038. * - VertexBuffer.UVKind
  24039. * - VertexBuffer.UV2Kind
  24040. * - VertexBuffer.UV3Kind
  24041. * - VertexBuffer.UV4Kind
  24042. * - VertexBuffer.UV5Kind
  24043. * - VertexBuffer.UV6Kind
  24044. * - VertexBuffer.ColorKind
  24045. * - VertexBuffer.MatricesIndicesKind
  24046. * - VertexBuffer.MatricesIndicesExtraKind
  24047. * - VertexBuffer.MatricesWeightsKind
  24048. * - VertexBuffer.MatricesWeightsExtraKind
  24049. * @param data defines the data source
  24050. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24051. * @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)
  24052. * @returns the current mesh
  24053. */
  24054. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24055. /**
  24056. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24057. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24058. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24059. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24060. * @returns the current mesh
  24061. */
  24062. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24063. /**
  24064. * Creates a un-shared specific occurence of the geometry for the mesh.
  24065. * @returns the current mesh
  24066. */
  24067. makeGeometryUnique(): Mesh;
  24068. /**
  24069. * Set the index buffer of this mesh
  24070. * @param indices defines the source data
  24071. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24072. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24073. * @returns the current mesh
  24074. */
  24075. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24076. /**
  24077. * Update the current index buffer
  24078. * @param indices defines the source data
  24079. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24080. * @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)
  24081. * @returns the current mesh
  24082. */
  24083. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24084. /**
  24085. * Invert the geometry to move from a right handed system to a left handed one.
  24086. * @returns the current mesh
  24087. */
  24088. toLeftHanded(): Mesh;
  24089. /** @hidden */
  24090. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24091. /** @hidden */
  24092. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24093. /**
  24094. * Registers for this mesh a javascript function called just before the rendering process
  24095. * @param func defines the function to call before rendering this mesh
  24096. * @returns the current mesh
  24097. */
  24098. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24099. /**
  24100. * Disposes a previously registered javascript function called before the rendering
  24101. * @param func defines the function to remove
  24102. * @returns the current mesh
  24103. */
  24104. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24105. /**
  24106. * Registers for this mesh a javascript function called just after the rendering is complete
  24107. * @param func defines the function to call after rendering this mesh
  24108. * @returns the current mesh
  24109. */
  24110. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24111. /**
  24112. * Disposes a previously registered javascript function called after the rendering.
  24113. * @param func defines the function to remove
  24114. * @returns the current mesh
  24115. */
  24116. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24117. /** @hidden */
  24118. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24119. /** @hidden */
  24120. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24121. /** @hidden */
  24122. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24123. /** @hidden */
  24124. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24125. /** @hidden */
  24126. _rebuild(): void;
  24127. /** @hidden */
  24128. _freeze(): void;
  24129. /** @hidden */
  24130. _unFreeze(): void;
  24131. /**
  24132. * 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
  24133. * @param subMesh defines the subMesh to render
  24134. * @param enableAlphaMode defines if alpha mode can be changed
  24135. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24136. * @returns the current mesh
  24137. */
  24138. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24139. private _onBeforeDraw;
  24140. /**
  24141. * Renormalize the mesh and patch it up if there are no weights
  24142. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24143. * However in the case of zero weights then we set just a single influence to 1.
  24144. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24145. */
  24146. cleanMatrixWeights(): void;
  24147. private normalizeSkinFourWeights;
  24148. private normalizeSkinWeightsAndExtra;
  24149. /**
  24150. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24151. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24152. * the user know there was an issue with importing the mesh
  24153. * @returns a validation object with skinned, valid and report string
  24154. */
  24155. validateSkinning(): {
  24156. skinned: boolean;
  24157. valid: boolean;
  24158. report: string;
  24159. };
  24160. /** @hidden */
  24161. _checkDelayState(): Mesh;
  24162. private _queueLoad;
  24163. /**
  24164. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24165. * A mesh is in the frustum if its bounding box intersects the frustum
  24166. * @param frustumPlanes defines the frustum to test
  24167. * @returns true if the mesh is in the frustum planes
  24168. */
  24169. isInFrustum(frustumPlanes: Plane[]): boolean;
  24170. /**
  24171. * Sets the mesh material by the material or multiMaterial `id` property
  24172. * @param id is a string identifying the material or the multiMaterial
  24173. * @returns the current mesh
  24174. */
  24175. setMaterialByID(id: string): Mesh;
  24176. /**
  24177. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24178. * @returns an array of IAnimatable
  24179. */
  24180. getAnimatables(): IAnimatable[];
  24181. /**
  24182. * Modifies the mesh geometry according to the passed transformation matrix.
  24183. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24184. * The mesh normals are modified using the same transformation.
  24185. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24186. * @param transform defines the transform matrix to use
  24187. * @see http://doc.babylonjs.com/resources/baking_transformations
  24188. * @returns the current mesh
  24189. */
  24190. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24191. /**
  24192. * Modifies the mesh geometry according to its own current World Matrix.
  24193. * The mesh World Matrix is then reset.
  24194. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24195. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24196. * @see http://doc.babylonjs.com/resources/baking_transformations
  24197. * @returns the current mesh
  24198. */
  24199. bakeCurrentTransformIntoVertices(): Mesh;
  24200. /** @hidden */
  24201. readonly _positions: Nullable<Vector3[]>;
  24202. /** @hidden */
  24203. _resetPointsArrayCache(): Mesh;
  24204. /** @hidden */
  24205. _generatePointsArray(): boolean;
  24206. /**
  24207. * Returns a new Mesh object generated from the current mesh properties.
  24208. * This method must not get confused with createInstance()
  24209. * @param name is a string, the name given to the new mesh
  24210. * @param newParent can be any Node object (default `null`)
  24211. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24212. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24213. * @returns a new mesh
  24214. */
  24215. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24216. /**
  24217. * Releases resources associated with this mesh.
  24218. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24219. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24220. */
  24221. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24222. /** @hidden */
  24223. _disposeInstanceSpecificData(): void;
  24224. /**
  24225. * Modifies the mesh geometry according to a displacement map.
  24226. * 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.
  24227. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24228. * @param url is a string, the URL from the image file is to be downloaded.
  24229. * @param minHeight is the lower limit of the displacement.
  24230. * @param maxHeight is the upper limit of the displacement.
  24231. * @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.
  24232. * @param uvOffset is an optional vector2 used to offset UV.
  24233. * @param uvScale is an optional vector2 used to scale UV.
  24234. * @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.
  24235. * @returns the Mesh.
  24236. */
  24237. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24238. /**
  24239. * Modifies the mesh geometry according to a displacementMap buffer.
  24240. * 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.
  24241. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24242. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24243. * @param heightMapWidth is the width of the buffer image.
  24244. * @param heightMapHeight is the height of the buffer image.
  24245. * @param minHeight is the lower limit of the displacement.
  24246. * @param maxHeight is the upper limit of the displacement.
  24247. * @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.
  24248. * @param uvOffset is an optional vector2 used to offset UV.
  24249. * @param uvScale is an optional vector2 used to scale UV.
  24250. * @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.
  24251. * @returns the Mesh.
  24252. */
  24253. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24254. /**
  24255. * Modify the mesh to get a flat shading rendering.
  24256. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24257. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24258. * @returns current mesh
  24259. */
  24260. convertToFlatShadedMesh(): Mesh;
  24261. /**
  24262. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24263. * In other words, more vertices, no more indices and a single bigger VBO.
  24264. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24265. * @returns current mesh
  24266. */
  24267. convertToUnIndexedMesh(): Mesh;
  24268. /**
  24269. * Inverses facet orientations.
  24270. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24271. * @param flipNormals will also inverts the normals
  24272. * @returns current mesh
  24273. */
  24274. flipFaces(flipNormals?: boolean): Mesh;
  24275. /**
  24276. * Increase the number of facets and hence vertices in a mesh
  24277. * Vertex normals are interpolated from existing vertex normals
  24278. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24279. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24280. */
  24281. increaseVertices(numberPerEdge: number): void;
  24282. /**
  24283. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24284. * This will undo any application of covertToFlatShadedMesh
  24285. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24286. */
  24287. forceSharedVertices(): void;
  24288. /** @hidden */
  24289. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24290. /** @hidden */
  24291. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24292. /**
  24293. * Creates a new InstancedMesh object from the mesh model.
  24294. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24295. * @param name defines the name of the new instance
  24296. * @returns a new InstancedMesh
  24297. */
  24298. createInstance(name: string): InstancedMesh;
  24299. /**
  24300. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24301. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24302. * @returns the current mesh
  24303. */
  24304. synchronizeInstances(): Mesh;
  24305. /**
  24306. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24307. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24308. * This should be used together with the simplification to avoid disappearing triangles.
  24309. * @param successCallback an optional success callback to be called after the optimization finished.
  24310. * @returns the current mesh
  24311. */
  24312. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24313. /**
  24314. * Serialize current mesh
  24315. * @param serializationObject defines the object which will receive the serialization data
  24316. */
  24317. serialize(serializationObject: any): void;
  24318. /** @hidden */
  24319. _syncGeometryWithMorphTargetManager(): void;
  24320. /** @hidden */
  24321. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24322. /**
  24323. * Returns a new Mesh object parsed from the source provided.
  24324. * @param parsedMesh is the source
  24325. * @param scene defines the hosting scene
  24326. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24327. * @returns a new Mesh
  24328. */
  24329. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24330. /**
  24331. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24332. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24333. * @param name defines the name of the mesh to create
  24334. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24335. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24336. * @param closePath creates a seam between the first and the last points of each path of the path array
  24337. * @param offset is taken in account only if the `pathArray` is containing a single path
  24338. * @param scene defines the hosting scene
  24339. * @param updatable defines if the mesh must be flagged as updatable
  24340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24341. * @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)
  24342. * @returns a new Mesh
  24343. */
  24344. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24345. /**
  24346. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24347. * @param name defines the name of the mesh to create
  24348. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24349. * @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
  24350. * @param scene defines the hosting scene
  24351. * @param updatable defines if the mesh must be flagged as updatable
  24352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24353. * @returns a new Mesh
  24354. */
  24355. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24356. /**
  24357. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24358. * @param name defines the name of the mesh to create
  24359. * @param size sets the size (float) of each box side (default 1)
  24360. * @param scene defines the hosting scene
  24361. * @param updatable defines if the mesh must be flagged as updatable
  24362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24363. * @returns a new Mesh
  24364. */
  24365. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24366. /**
  24367. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24368. * @param name defines the name of the mesh to create
  24369. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24370. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24371. * @param scene defines the hosting scene
  24372. * @param updatable defines if the mesh must be flagged as updatable
  24373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24374. * @returns a new Mesh
  24375. */
  24376. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24377. /**
  24378. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24379. * @param name defines the name of the mesh to create
  24380. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24381. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24382. * @param scene defines the hosting scene
  24383. * @returns a new Mesh
  24384. */
  24385. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24386. /**
  24387. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24388. * @param name defines the name of the mesh to create
  24389. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24390. * @param diameterTop set the top cap diameter (floats, default 1)
  24391. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24392. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24393. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24394. * @param scene defines the hosting scene
  24395. * @param updatable defines if the mesh must be flagged as updatable
  24396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24397. * @returns a new Mesh
  24398. */
  24399. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24400. /**
  24401. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24402. * @param name defines the name of the mesh to create
  24403. * @param diameter sets the diameter size (float) of the torus (default 1)
  24404. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24405. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24406. * @param scene defines the hosting scene
  24407. * @param updatable defines if the mesh must be flagged as updatable
  24408. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24409. * @returns a new Mesh
  24410. */
  24411. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24412. /**
  24413. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24414. * @param name defines the name of the mesh to create
  24415. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24416. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24417. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24418. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24419. * @param p the number of windings on X axis (positive integers, default 2)
  24420. * @param q the number of windings on Y axis (positive integers, default 3)
  24421. * @param scene defines the hosting scene
  24422. * @param updatable defines if the mesh must be flagged as updatable
  24423. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24424. * @returns a new Mesh
  24425. */
  24426. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24427. /**
  24428. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24429. * @param name defines the name of the mesh to create
  24430. * @param points is an array successive Vector3
  24431. * @param scene defines the hosting scene
  24432. * @param updatable defines if the mesh must be flagged as updatable
  24433. * @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).
  24434. * @returns a new Mesh
  24435. */
  24436. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24437. /**
  24438. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24439. * @param name defines the name of the mesh to create
  24440. * @param points is an array successive Vector3
  24441. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24442. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24443. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24444. * @param scene defines the hosting scene
  24445. * @param updatable defines if the mesh must be flagged as updatable
  24446. * @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)
  24447. * @returns a new Mesh
  24448. */
  24449. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24450. /**
  24451. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24452. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24453. * 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.
  24454. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24455. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24456. * Remember you can only change the shape positions, not their number when updating a polygon.
  24457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24458. * @param name defines the name of the mesh to create
  24459. * @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
  24460. * @param scene defines the hosting scene
  24461. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24462. * @param updatable defines if the mesh must be flagged as updatable
  24463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24464. * @param earcutInjection can be used to inject your own earcut reference
  24465. * @returns a new Mesh
  24466. */
  24467. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24468. /**
  24469. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24470. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24471. * @param name defines the name of the mesh to create
  24472. * @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
  24473. * @param depth defines the height of extrusion
  24474. * @param scene defines the hosting scene
  24475. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24476. * @param updatable defines if the mesh must be flagged as updatable
  24477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24478. * @param earcutInjection can be used to inject your own earcut reference
  24479. * @returns a new Mesh
  24480. */
  24481. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24482. /**
  24483. * Creates an extruded shape mesh.
  24484. * 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
  24485. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24486. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24487. * @param name defines the name of the mesh to create
  24488. * @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
  24489. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24490. * @param scale is the value to scale the shape
  24491. * @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
  24492. * @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
  24493. * @param scene defines the hosting scene
  24494. * @param updatable defines if the mesh must be flagged as updatable
  24495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24496. * @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)
  24497. * @returns a new Mesh
  24498. */
  24499. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24500. /**
  24501. * Creates an custom extruded shape mesh.
  24502. * The custom extrusion is a parametric shape.
  24503. * It has no predefined shape. Its final shape will depend on the input parameters.
  24504. * Please consider using the same method from the MeshBuilder class instead
  24505. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24506. * @param name defines the name of the mesh to create
  24507. * @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
  24508. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24509. * @param scaleFunction is a custom Javascript function called on each path point
  24510. * @param rotationFunction is a custom Javascript function called on each path point
  24511. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24512. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24513. * @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
  24514. * @param scene defines the hosting scene
  24515. * @param updatable defines if the mesh must be flagged as updatable
  24516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24517. * @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)
  24518. * @returns a new Mesh
  24519. */
  24520. 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;
  24521. /**
  24522. * Creates lathe mesh.
  24523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24524. * Please consider using the same method from the MeshBuilder class instead
  24525. * @param name defines the name of the mesh to create
  24526. * @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
  24527. * @param radius is the radius value of the lathe
  24528. * @param tessellation is the side number of the lathe.
  24529. * @param scene defines the hosting scene
  24530. * @param updatable defines if the mesh must be flagged as updatable
  24531. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24532. * @returns a new Mesh
  24533. */
  24534. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24535. /**
  24536. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24537. * @param name defines the name of the mesh to create
  24538. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24539. * @param scene defines the hosting scene
  24540. * @param updatable defines if the mesh must be flagged as updatable
  24541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24542. * @returns a new Mesh
  24543. */
  24544. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24545. /**
  24546. * Creates a ground mesh.
  24547. * Please consider using the same method from the MeshBuilder class instead
  24548. * @param name defines the name of the mesh to create
  24549. * @param width set the width of the ground
  24550. * @param height set the height of the ground
  24551. * @param subdivisions sets the number of subdivisions per side
  24552. * @param scene defines the hosting scene
  24553. * @param updatable defines if the mesh must be flagged as updatable
  24554. * @returns a new Mesh
  24555. */
  24556. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24557. /**
  24558. * Creates a tiled ground mesh.
  24559. * Please consider using the same method from the MeshBuilder class instead
  24560. * @param name defines the name of the mesh to create
  24561. * @param xmin set the ground minimum X coordinate
  24562. * @param zmin set the ground minimum Y coordinate
  24563. * @param xmax set the ground maximum X coordinate
  24564. * @param zmax set the ground maximum Z coordinate
  24565. * @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
  24566. * @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
  24567. * @param scene defines the hosting scene
  24568. * @param updatable defines if the mesh must be flagged as updatable
  24569. * @returns a new Mesh
  24570. */
  24571. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24572. w: number;
  24573. h: number;
  24574. }, precision: {
  24575. w: number;
  24576. h: number;
  24577. }, scene: Scene, updatable?: boolean): Mesh;
  24578. /**
  24579. * Creates a ground mesh from a height map.
  24580. * Please consider using the same method from the MeshBuilder class instead
  24581. * @see http://doc.babylonjs.com/babylon101/height_map
  24582. * @param name defines the name of the mesh to create
  24583. * @param url sets the URL of the height map image resource
  24584. * @param width set the ground width size
  24585. * @param height set the ground height size
  24586. * @param subdivisions sets the number of subdivision per side
  24587. * @param minHeight is the minimum altitude on the ground
  24588. * @param maxHeight is the maximum altitude on the ground
  24589. * @param scene defines the hosting scene
  24590. * @param updatable defines if the mesh must be flagged as updatable
  24591. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24592. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24593. * @returns a new Mesh
  24594. */
  24595. 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;
  24596. /**
  24597. * Creates a tube mesh.
  24598. * The tube is a parametric shape.
  24599. * It has no predefined shape. Its final shape will depend on the input parameters.
  24600. * Please consider using the same method from the MeshBuilder class instead
  24601. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24602. * @param name defines the name of the mesh to create
  24603. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24604. * @param radius sets the tube radius size
  24605. * @param tessellation is the number of sides on the tubular surface
  24606. * @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
  24607. * @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
  24608. * @param scene defines the hosting scene
  24609. * @param updatable defines if the mesh must be flagged as updatable
  24610. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24611. * @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)
  24612. * @returns a new Mesh
  24613. */
  24614. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24615. (i: number, distance: number): number;
  24616. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24617. /**
  24618. * Creates a polyhedron mesh.
  24619. * Please consider using the same method from the MeshBuilder class instead.
  24620. * * 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
  24621. * * The parameter `size` (positive float, default 1) sets the polygon size
  24622. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24623. * * 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`
  24624. * * 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
  24625. * * 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)`)
  24626. * * 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
  24627. * * 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
  24628. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24629. * * 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
  24630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24631. * @param name defines the name of the mesh to create
  24632. * @param options defines the options used to create the mesh
  24633. * @param scene defines the hosting scene
  24634. * @returns a new Mesh
  24635. */
  24636. static CreatePolyhedron(name: string, options: {
  24637. type?: number;
  24638. size?: number;
  24639. sizeX?: number;
  24640. sizeY?: number;
  24641. sizeZ?: number;
  24642. custom?: any;
  24643. faceUV?: Vector4[];
  24644. faceColors?: Color4[];
  24645. updatable?: boolean;
  24646. sideOrientation?: number;
  24647. }, scene: Scene): Mesh;
  24648. /**
  24649. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24650. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24651. * * 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`)
  24652. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24653. * * 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
  24654. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24655. * * 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
  24656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24657. * @param name defines the name of the mesh
  24658. * @param options defines the options used to create the mesh
  24659. * @param scene defines the hosting scene
  24660. * @returns a new Mesh
  24661. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24662. */
  24663. static CreateIcoSphere(name: string, options: {
  24664. radius?: number;
  24665. flat?: boolean;
  24666. subdivisions?: number;
  24667. sideOrientation?: number;
  24668. updatable?: boolean;
  24669. }, scene: Scene): Mesh;
  24670. /**
  24671. * Creates a decal mesh.
  24672. * Please consider using the same method from the MeshBuilder class instead.
  24673. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24674. * @param name defines the name of the mesh
  24675. * @param sourceMesh defines the mesh receiving the decal
  24676. * @param position sets the position of the decal in world coordinates
  24677. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24678. * @param size sets the decal scaling
  24679. * @param angle sets the angle to rotate the decal
  24680. * @returns a new Mesh
  24681. */
  24682. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24683. /**
  24684. * Prepare internal position array for software CPU skinning
  24685. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24686. */
  24687. setPositionsForCPUSkinning(): Float32Array;
  24688. /**
  24689. * Prepare internal normal array for software CPU skinning
  24690. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24691. */
  24692. setNormalsForCPUSkinning(): Float32Array;
  24693. /**
  24694. * Updates the vertex buffer by applying transformation from the bones
  24695. * @param skeleton defines the skeleton to apply to current mesh
  24696. * @returns the current mesh
  24697. */
  24698. applySkeleton(skeleton: Skeleton): Mesh;
  24699. /**
  24700. * 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
  24701. * @param meshes defines the list of meshes to scan
  24702. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24703. */
  24704. static MinMax(meshes: AbstractMesh[]): {
  24705. min: Vector3;
  24706. max: Vector3;
  24707. };
  24708. /**
  24709. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24710. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24711. * @returns a vector3
  24712. */
  24713. static Center(meshesOrMinMaxVector: {
  24714. min: Vector3;
  24715. max: Vector3;
  24716. } | AbstractMesh[]): Vector3;
  24717. /**
  24718. * Merge the array of meshes into a single mesh for performance reasons.
  24719. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24720. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24721. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24722. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24723. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24724. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24725. * @returns a new mesh
  24726. */
  24727. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24728. /** @hidden */
  24729. addInstance(instance: InstancedMesh): void;
  24730. /** @hidden */
  24731. removeInstance(instance: InstancedMesh): void;
  24732. }
  24733. }
  24734. declare module BABYLON {
  24735. /**
  24736. * This is the base class of all the camera used in the application.
  24737. * @see http://doc.babylonjs.com/features/cameras
  24738. */
  24739. export class Camera extends Node {
  24740. /** @hidden */
  24741. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24742. /**
  24743. * This is the default projection mode used by the cameras.
  24744. * It helps recreating a feeling of perspective and better appreciate depth.
  24745. * This is the best way to simulate real life cameras.
  24746. */
  24747. static readonly PERSPECTIVE_CAMERA: number;
  24748. /**
  24749. * This helps creating camera with an orthographic mode.
  24750. * 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.
  24751. */
  24752. static readonly ORTHOGRAPHIC_CAMERA: number;
  24753. /**
  24754. * This is the default FOV mode for perspective cameras.
  24755. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24756. */
  24757. static readonly FOVMODE_VERTICAL_FIXED: number;
  24758. /**
  24759. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24760. */
  24761. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24762. /**
  24763. * This specifies ther is no need for a camera rig.
  24764. * Basically only one eye is rendered corresponding to the camera.
  24765. */
  24766. static readonly RIG_MODE_NONE: number;
  24767. /**
  24768. * Simulates a camera Rig with one blue eye and one red eye.
  24769. * This can be use with 3d blue and red glasses.
  24770. */
  24771. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24772. /**
  24773. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24774. */
  24775. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24776. /**
  24777. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24778. */
  24779. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24780. /**
  24781. * Defines that both eyes of the camera will be rendered over under each other.
  24782. */
  24783. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24784. /**
  24785. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24786. */
  24787. static readonly RIG_MODE_VR: number;
  24788. /**
  24789. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24790. */
  24791. static readonly RIG_MODE_WEBVR: number;
  24792. /**
  24793. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24794. */
  24795. static readonly RIG_MODE_CUSTOM: number;
  24796. /**
  24797. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24798. */
  24799. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24800. /**
  24801. * Define the input manager associated with the camera.
  24802. */
  24803. inputs: CameraInputsManager<Camera>;
  24804. /** @hidden */
  24805. _position: Vector3;
  24806. /**
  24807. * Define the current local position of the camera in the scene
  24808. */
  24809. position: Vector3;
  24810. /**
  24811. * The vector the camera should consider as up.
  24812. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24813. */
  24814. upVector: Vector3;
  24815. /**
  24816. * Define the current limit on the left side for an orthographic camera
  24817. * In scene unit
  24818. */
  24819. orthoLeft: Nullable<number>;
  24820. /**
  24821. * Define the current limit on the right side for an orthographic camera
  24822. * In scene unit
  24823. */
  24824. orthoRight: Nullable<number>;
  24825. /**
  24826. * Define the current limit on the bottom side for an orthographic camera
  24827. * In scene unit
  24828. */
  24829. orthoBottom: Nullable<number>;
  24830. /**
  24831. * Define the current limit on the top side for an orthographic camera
  24832. * In scene unit
  24833. */
  24834. orthoTop: Nullable<number>;
  24835. /**
  24836. * Field Of View is set in Radians. (default is 0.8)
  24837. */
  24838. fov: number;
  24839. /**
  24840. * Define the minimum distance the camera can see from.
  24841. * This is important to note that the depth buffer are not infinite and the closer it starts
  24842. * the more your scene might encounter depth fighting issue.
  24843. */
  24844. minZ: number;
  24845. /**
  24846. * Define the maximum distance the camera can see to.
  24847. * This is important to note that the depth buffer are not infinite and the further it end
  24848. * the more your scene might encounter depth fighting issue.
  24849. */
  24850. maxZ: number;
  24851. /**
  24852. * Define the default inertia of the camera.
  24853. * This helps giving a smooth feeling to the camera movement.
  24854. */
  24855. inertia: number;
  24856. /**
  24857. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24858. */
  24859. mode: number;
  24860. /**
  24861. * Define wether the camera is intermediate.
  24862. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24863. */
  24864. isIntermediate: boolean;
  24865. /**
  24866. * Define the viewport of the camera.
  24867. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24868. */
  24869. viewport: Viewport;
  24870. /**
  24871. * Restricts the camera to viewing objects with the same layerMask.
  24872. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24873. */
  24874. layerMask: number;
  24875. /**
  24876. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24877. */
  24878. fovMode: number;
  24879. /**
  24880. * Rig mode of the camera.
  24881. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24882. * This is normally controlled byt the camera themselves as internal use.
  24883. */
  24884. cameraRigMode: number;
  24885. /**
  24886. * Defines the distance between both "eyes" in case of a RIG
  24887. */
  24888. interaxialDistance: number;
  24889. /**
  24890. * Defines if stereoscopic rendering is done side by side or over under.
  24891. */
  24892. isStereoscopicSideBySide: boolean;
  24893. /**
  24894. * 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
  24895. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24896. * else in the scene. (Eg. security camera)
  24897. *
  24898. * 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)
  24899. */
  24900. customRenderTargets: RenderTargetTexture[];
  24901. /**
  24902. * When set, the camera will render to this render target instead of the default canvas
  24903. *
  24904. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24905. */
  24906. outputRenderTarget: Nullable<RenderTargetTexture>;
  24907. /**
  24908. * Observable triggered when the camera view matrix has changed.
  24909. */
  24910. onViewMatrixChangedObservable: Observable<Camera>;
  24911. /**
  24912. * Observable triggered when the camera Projection matrix has changed.
  24913. */
  24914. onProjectionMatrixChangedObservable: Observable<Camera>;
  24915. /**
  24916. * Observable triggered when the inputs have been processed.
  24917. */
  24918. onAfterCheckInputsObservable: Observable<Camera>;
  24919. /**
  24920. * Observable triggered when reset has been called and applied to the camera.
  24921. */
  24922. onRestoreStateObservable: Observable<Camera>;
  24923. /** @hidden */
  24924. _cameraRigParams: any;
  24925. /** @hidden */
  24926. _rigCameras: Camera[];
  24927. /** @hidden */
  24928. _rigPostProcess: Nullable<PostProcess>;
  24929. protected _webvrViewMatrix: Matrix;
  24930. /** @hidden */
  24931. _skipRendering: boolean;
  24932. /** @hidden */
  24933. _projectionMatrix: Matrix;
  24934. /** @hidden */
  24935. _postProcesses: Nullable<PostProcess>[];
  24936. /** @hidden */
  24937. _activeMeshes: SmartArray<AbstractMesh>;
  24938. protected _globalPosition: Vector3;
  24939. /** @hidden */
  24940. _computedViewMatrix: Matrix;
  24941. private _doNotComputeProjectionMatrix;
  24942. private _transformMatrix;
  24943. private _frustumPlanes;
  24944. private _refreshFrustumPlanes;
  24945. private _storedFov;
  24946. private _stateStored;
  24947. /**
  24948. * Instantiates a new camera object.
  24949. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24950. * @see http://doc.babylonjs.com/features/cameras
  24951. * @param name Defines the name of the camera in the scene
  24952. * @param position Defines the position of the camera
  24953. * @param scene Defines the scene the camera belongs too
  24954. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24955. */
  24956. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24957. /**
  24958. * Store current camera state (fov, position, etc..)
  24959. * @returns the camera
  24960. */
  24961. storeState(): Camera;
  24962. /**
  24963. * Restores the camera state values if it has been stored. You must call storeState() first
  24964. */
  24965. protected _restoreStateValues(): boolean;
  24966. /**
  24967. * Restored camera state. You must call storeState() first.
  24968. * @returns true if restored and false otherwise
  24969. */
  24970. restoreState(): boolean;
  24971. /**
  24972. * Gets the class name of the camera.
  24973. * @returns the class name
  24974. */
  24975. getClassName(): string;
  24976. /** @hidden */
  24977. readonly _isCamera: boolean;
  24978. /**
  24979. * Gets a string representation of the camera useful for debug purpose.
  24980. * @param fullDetails Defines that a more verboe level of logging is required
  24981. * @returns the string representation
  24982. */
  24983. toString(fullDetails?: boolean): string;
  24984. /**
  24985. * Gets the current world space position of the camera.
  24986. */
  24987. readonly globalPosition: Vector3;
  24988. /**
  24989. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24990. * @returns the active meshe list
  24991. */
  24992. getActiveMeshes(): SmartArray<AbstractMesh>;
  24993. /**
  24994. * Check wether a mesh is part of the current active mesh list of the camera
  24995. * @param mesh Defines the mesh to check
  24996. * @returns true if active, false otherwise
  24997. */
  24998. isActiveMesh(mesh: Mesh): boolean;
  24999. /**
  25000. * Is this camera ready to be used/rendered
  25001. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25002. * @return true if the camera is ready
  25003. */
  25004. isReady(completeCheck?: boolean): boolean;
  25005. /** @hidden */
  25006. _initCache(): void;
  25007. /** @hidden */
  25008. _updateCache(ignoreParentClass?: boolean): void;
  25009. /** @hidden */
  25010. _isSynchronized(): boolean;
  25011. /** @hidden */
  25012. _isSynchronizedViewMatrix(): boolean;
  25013. /** @hidden */
  25014. _isSynchronizedProjectionMatrix(): boolean;
  25015. /**
  25016. * Attach the input controls to a specific dom element to get the input from.
  25017. * @param element Defines the element the controls should be listened from
  25018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25019. */
  25020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25021. /**
  25022. * Detach the current controls from the specified dom element.
  25023. * @param element Defines the element to stop listening the inputs from
  25024. */
  25025. detachControl(element: HTMLElement): void;
  25026. /**
  25027. * Update the camera state according to the different inputs gathered during the frame.
  25028. */
  25029. update(): void;
  25030. /** @hidden */
  25031. _checkInputs(): void;
  25032. /** @hidden */
  25033. readonly rigCameras: Camera[];
  25034. /**
  25035. * Gets the post process used by the rig cameras
  25036. */
  25037. readonly rigPostProcess: Nullable<PostProcess>;
  25038. /**
  25039. * Internal, gets the first post proces.
  25040. * @returns the first post process to be run on this camera.
  25041. */
  25042. _getFirstPostProcess(): Nullable<PostProcess>;
  25043. private _cascadePostProcessesToRigCams;
  25044. /**
  25045. * Attach a post process to the camera.
  25046. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25047. * @param postProcess The post process to attach to the camera
  25048. * @param insertAt The position of the post process in case several of them are in use in the scene
  25049. * @returns the position the post process has been inserted at
  25050. */
  25051. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25052. /**
  25053. * Detach a post process to the camera.
  25054. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25055. * @param postProcess The post process to detach from the camera
  25056. */
  25057. detachPostProcess(postProcess: PostProcess): void;
  25058. /**
  25059. * Gets the current world matrix of the camera
  25060. */
  25061. getWorldMatrix(): Matrix;
  25062. /** @hidden */
  25063. _getViewMatrix(): Matrix;
  25064. /**
  25065. * Gets the current view matrix of the camera.
  25066. * @param force forces the camera to recompute the matrix without looking at the cached state
  25067. * @returns the view matrix
  25068. */
  25069. getViewMatrix(force?: boolean): Matrix;
  25070. /**
  25071. * Freeze the projection matrix.
  25072. * It will prevent the cache check of the camera projection compute and can speed up perf
  25073. * if no parameter of the camera are meant to change
  25074. * @param projection Defines manually a projection if necessary
  25075. */
  25076. freezeProjectionMatrix(projection?: Matrix): void;
  25077. /**
  25078. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25079. */
  25080. unfreezeProjectionMatrix(): void;
  25081. /**
  25082. * Gets the current projection matrix of the camera.
  25083. * @param force forces the camera to recompute the matrix without looking at the cached state
  25084. * @returns the projection matrix
  25085. */
  25086. getProjectionMatrix(force?: boolean): Matrix;
  25087. /**
  25088. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25089. * @returns a Matrix
  25090. */
  25091. getTransformationMatrix(): Matrix;
  25092. private _updateFrustumPlanes;
  25093. /**
  25094. * Checks if a cullable object (mesh...) is in the camera frustum
  25095. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25096. * @param target The object to check
  25097. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25098. * @returns true if the object is in frustum otherwise false
  25099. */
  25100. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25101. /**
  25102. * Checks if a cullable object (mesh...) is in the camera frustum
  25103. * Unlike isInFrustum this cheks the full bounding box
  25104. * @param target The object to check
  25105. * @returns true if the object is in frustum otherwise false
  25106. */
  25107. isCompletelyInFrustum(target: ICullable): boolean;
  25108. /**
  25109. * Gets a ray in the forward direction from the camera.
  25110. * @param length Defines the length of the ray to create
  25111. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25112. * @param origin Defines the start point of the ray which defaults to the camera position
  25113. * @returns the forward ray
  25114. */
  25115. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25116. /**
  25117. * Releases resources associated with this node.
  25118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25120. */
  25121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25122. /** @hidden */
  25123. _isLeftCamera: boolean;
  25124. /**
  25125. * Gets the left camera of a rig setup in case of Rigged Camera
  25126. */
  25127. readonly isLeftCamera: boolean;
  25128. /** @hidden */
  25129. _isRightCamera: boolean;
  25130. /**
  25131. * Gets the right camera of a rig setup in case of Rigged Camera
  25132. */
  25133. readonly isRightCamera: boolean;
  25134. /**
  25135. * Gets the left camera of a rig setup in case of Rigged Camera
  25136. */
  25137. readonly leftCamera: Nullable<FreeCamera>;
  25138. /**
  25139. * Gets the right camera of a rig setup in case of Rigged Camera
  25140. */
  25141. readonly rightCamera: Nullable<FreeCamera>;
  25142. /**
  25143. * Gets the left camera target of a rig setup in case of Rigged Camera
  25144. * @returns the target position
  25145. */
  25146. getLeftTarget(): Nullable<Vector3>;
  25147. /**
  25148. * Gets the right camera target of a rig setup in case of Rigged Camera
  25149. * @returns the target position
  25150. */
  25151. getRightTarget(): Nullable<Vector3>;
  25152. /**
  25153. * @hidden
  25154. */
  25155. setCameraRigMode(mode: number, rigParams: any): void;
  25156. /** @hidden */
  25157. static _setStereoscopicRigMode(camera: Camera): void;
  25158. /** @hidden */
  25159. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25160. /** @hidden */
  25161. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25162. /** @hidden */
  25163. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25164. /** @hidden */
  25165. _getVRProjectionMatrix(): Matrix;
  25166. protected _updateCameraRotationMatrix(): void;
  25167. protected _updateWebVRCameraRotationMatrix(): void;
  25168. /**
  25169. * This function MUST be overwritten by the different WebVR cameras available.
  25170. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25171. * @hidden
  25172. */
  25173. _getWebVRProjectionMatrix(): Matrix;
  25174. /**
  25175. * This function MUST be overwritten by the different WebVR cameras available.
  25176. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25177. * @hidden
  25178. */
  25179. _getWebVRViewMatrix(): Matrix;
  25180. /** @hidden */
  25181. setCameraRigParameter(name: string, value: any): void;
  25182. /**
  25183. * needs to be overridden by children so sub has required properties to be copied
  25184. * @hidden
  25185. */
  25186. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25187. /**
  25188. * May need to be overridden by children
  25189. * @hidden
  25190. */
  25191. _updateRigCameras(): void;
  25192. /** @hidden */
  25193. _setupInputs(): void;
  25194. /**
  25195. * Serialiaze the camera setup to a json represention
  25196. * @returns the JSON representation
  25197. */
  25198. serialize(): any;
  25199. /**
  25200. * Clones the current camera.
  25201. * @param name The cloned camera name
  25202. * @returns the cloned camera
  25203. */
  25204. clone(name: string): Camera;
  25205. /**
  25206. * Gets the direction of the camera relative to a given local axis.
  25207. * @param localAxis Defines the reference axis to provide a relative direction.
  25208. * @return the direction
  25209. */
  25210. getDirection(localAxis: Vector3): Vector3;
  25211. /**
  25212. * Returns the current camera absolute rotation
  25213. */
  25214. readonly absoluteRotation: Quaternion;
  25215. /**
  25216. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25217. * @param localAxis Defines the reference axis to provide a relative direction.
  25218. * @param result Defines the vector to store the result in
  25219. */
  25220. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25221. /**
  25222. * Gets a camera constructor for a given camera type
  25223. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25224. * @param name The name of the camera the result will be able to instantiate
  25225. * @param scene The scene the result will construct the camera in
  25226. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25227. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25228. * @returns a factory method to construc the camera
  25229. */
  25230. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25231. /**
  25232. * Compute the world matrix of the camera.
  25233. * @returns the camera world matrix
  25234. */
  25235. computeWorldMatrix(): Matrix;
  25236. /**
  25237. * Parse a JSON and creates the camera from the parsed information
  25238. * @param parsedCamera The JSON to parse
  25239. * @param scene The scene to instantiate the camera in
  25240. * @returns the newly constructed camera
  25241. */
  25242. static Parse(parsedCamera: any, scene: Scene): Camera;
  25243. }
  25244. }
  25245. declare module BABYLON {
  25246. /**
  25247. * Class containing static functions to help procedurally build meshes
  25248. */
  25249. export class DiscBuilder {
  25250. /**
  25251. * Creates a plane polygonal mesh. By default, this is a disc
  25252. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25253. * * 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
  25254. * * 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
  25255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25256. * * 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
  25257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25258. * @param name defines the name of the mesh
  25259. * @param options defines the options used to create the mesh
  25260. * @param scene defines the hosting scene
  25261. * @returns the plane polygonal mesh
  25262. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25263. */
  25264. static CreateDisc(name: string, options: {
  25265. radius?: number;
  25266. tessellation?: number;
  25267. arc?: number;
  25268. updatable?: boolean;
  25269. sideOrientation?: number;
  25270. frontUVs?: Vector4;
  25271. backUVs?: Vector4;
  25272. }, scene?: Nullable<Scene>): Mesh;
  25273. }
  25274. }
  25275. declare module BABYLON {
  25276. /**
  25277. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25278. *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.
  25279. * The SPS is also a particle system. It provides some methods to manage the particles.
  25280. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25281. *
  25282. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25283. */
  25284. export class SolidParticleSystem implements IDisposable {
  25285. /**
  25286. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25287. * Example : var p = SPS.particles[i];
  25288. */
  25289. particles: SolidParticle[];
  25290. /**
  25291. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25292. */
  25293. nbParticles: number;
  25294. /**
  25295. * If the particles must ever face the camera (default false). Useful for planar particles.
  25296. */
  25297. billboard: boolean;
  25298. /**
  25299. * Recompute normals when adding a shape
  25300. */
  25301. recomputeNormals: boolean;
  25302. /**
  25303. * This a counter ofr your own usage. It's not set by any SPS functions.
  25304. */
  25305. counter: number;
  25306. /**
  25307. * The SPS name. This name is also given to the underlying mesh.
  25308. */
  25309. name: string;
  25310. /**
  25311. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25312. */
  25313. mesh: Mesh;
  25314. /**
  25315. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25316. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25317. */
  25318. vars: any;
  25319. /**
  25320. * This array is populated when the SPS is set as 'pickable'.
  25321. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25322. * Each element of this array is an object `{idx: int, faceId: int}`.
  25323. * `idx` is the picked particle index in the `SPS.particles` array
  25324. * `faceId` is the picked face index counted within this particle.
  25325. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25326. */
  25327. pickedParticles: {
  25328. idx: number;
  25329. faceId: number;
  25330. }[];
  25331. /**
  25332. * This array is populated when `enableDepthSort` is set to true.
  25333. * Each element of this array is an instance of the class DepthSortedParticle.
  25334. */
  25335. depthSortedParticles: DepthSortedParticle[];
  25336. /**
  25337. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25338. * @hidden
  25339. */
  25340. _bSphereOnly: boolean;
  25341. /**
  25342. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25343. * @hidden
  25344. */
  25345. _bSphereRadiusFactor: number;
  25346. private _scene;
  25347. private _positions;
  25348. private _indices;
  25349. private _normals;
  25350. private _colors;
  25351. private _uvs;
  25352. private _indices32;
  25353. private _positions32;
  25354. private _normals32;
  25355. private _fixedNormal32;
  25356. private _colors32;
  25357. private _uvs32;
  25358. private _index;
  25359. private _updatable;
  25360. private _pickable;
  25361. private _isVisibilityBoxLocked;
  25362. private _alwaysVisible;
  25363. private _depthSort;
  25364. private _expandable;
  25365. private _shapeCounter;
  25366. private _copy;
  25367. private _color;
  25368. private _computeParticleColor;
  25369. private _computeParticleTexture;
  25370. private _computeParticleRotation;
  25371. private _computeParticleVertex;
  25372. private _computeBoundingBox;
  25373. private _depthSortParticles;
  25374. private _camera;
  25375. private _mustUnrotateFixedNormals;
  25376. private _particlesIntersect;
  25377. private _needs32Bits;
  25378. private _isNotBuilt;
  25379. /**
  25380. * Creates a SPS (Solid Particle System) object.
  25381. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25382. * @param scene (Scene) is the scene in which the SPS is added.
  25383. * @param options defines the options of the sps e.g.
  25384. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25385. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25386. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25387. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25388. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25389. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25390. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25391. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25392. */
  25393. constructor(name: string, scene: Scene, options?: {
  25394. updatable?: boolean;
  25395. isPickable?: boolean;
  25396. enableDepthSort?: boolean;
  25397. particleIntersection?: boolean;
  25398. boundingSphereOnly?: boolean;
  25399. bSphereRadiusFactor?: number;
  25400. expandable?: boolean;
  25401. });
  25402. /**
  25403. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25404. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25405. * @returns the created mesh
  25406. */
  25407. buildMesh(): Mesh;
  25408. /**
  25409. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25410. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25411. * Thus the particles generated from `digest()` have their property `position` set yet.
  25412. * @param mesh ( Mesh ) is the mesh to be digested
  25413. * @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
  25414. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25415. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25416. * @returns the current SPS
  25417. */
  25418. digest(mesh: Mesh, options?: {
  25419. facetNb?: number;
  25420. number?: number;
  25421. delta?: number;
  25422. }): SolidParticleSystem;
  25423. private _unrotateFixedNormals;
  25424. private _resetCopy;
  25425. private _meshBuilder;
  25426. private _posToShape;
  25427. private _uvsToShapeUV;
  25428. private _addParticle;
  25429. /**
  25430. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25431. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25432. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25433. * @param nb (positive integer) the number of particles to be created from this model
  25434. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25435. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25436. * @returns the number of shapes in the system
  25437. */
  25438. addShape(mesh: Mesh, nb: number, options?: {
  25439. positionFunction?: any;
  25440. vertexFunction?: any;
  25441. }): number;
  25442. private _rebuildParticle;
  25443. /**
  25444. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25445. * @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.
  25446. * @returns the SPS.
  25447. */
  25448. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25449. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25450. * Returns an array with the removed particles.
  25451. * 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.
  25452. * The SPS can't be empty so at least one particle needs to remain in place.
  25453. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25454. * @param start index of the first particle to remove
  25455. * @param end index of the last particle to remove (included)
  25456. * @returns an array populated with the removed particles
  25457. */
  25458. removeParticles(start: number, end: number): SolidParticle[];
  25459. /**
  25460. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25461. * This method calls `updateParticle()` for each particle of the SPS.
  25462. * For an animated SPS, it is usually called within the render loop.
  25463. * 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.
  25464. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25465. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25466. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25467. * @returns the SPS.
  25468. */
  25469. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25470. /**
  25471. * Disposes the SPS.
  25472. */
  25473. dispose(): void;
  25474. /**
  25475. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25476. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25477. * @returns the SPS.
  25478. */
  25479. refreshVisibleSize(): SolidParticleSystem;
  25480. /**
  25481. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25482. * @param size the size (float) of the visibility box
  25483. * note : this doesn't lock the SPS mesh bounding box.
  25484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25485. */
  25486. setVisibilityBox(size: number): void;
  25487. /**
  25488. * Gets whether the SPS as always visible or not
  25489. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25490. */
  25491. /**
  25492. * Sets the SPS as always visible or not
  25493. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25494. */
  25495. isAlwaysVisible: boolean;
  25496. /**
  25497. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25498. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25499. */
  25500. /**
  25501. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25502. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25503. */
  25504. isVisibilityBoxLocked: boolean;
  25505. /**
  25506. * Tells to `setParticles()` to compute the particle rotations or not.
  25507. * Default value : true. The SPS is faster when it's set to false.
  25508. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25509. */
  25510. /**
  25511. * Gets if `setParticles()` computes the particle rotations or not.
  25512. * Default value : true. The SPS is faster when it's set to false.
  25513. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25514. */
  25515. computeParticleRotation: boolean;
  25516. /**
  25517. * Tells to `setParticles()` to compute the particle colors or not.
  25518. * Default value : true. The SPS is faster when it's set to false.
  25519. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25520. */
  25521. /**
  25522. * Gets if `setParticles()` computes the particle colors or not.
  25523. * Default value : true. The SPS is faster when it's set to false.
  25524. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25525. */
  25526. computeParticleColor: boolean;
  25527. /**
  25528. * Gets if `setParticles()` computes the particle textures or not.
  25529. * Default value : true. The SPS is faster when it's set to false.
  25530. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25531. */
  25532. computeParticleTexture: boolean;
  25533. /**
  25534. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25535. * Default value : false. The SPS is faster when it's set to false.
  25536. * Note : the particle custom vertex positions aren't stored values.
  25537. */
  25538. /**
  25539. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25540. * Default value : false. The SPS is faster when it's set to false.
  25541. * Note : the particle custom vertex positions aren't stored values.
  25542. */
  25543. computeParticleVertex: boolean;
  25544. /**
  25545. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25546. */
  25547. /**
  25548. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25549. */
  25550. computeBoundingBox: boolean;
  25551. /**
  25552. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25553. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25554. * Default : `true`
  25555. */
  25556. /**
  25557. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25558. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25559. * Default : `true`
  25560. */
  25561. depthSortParticles: boolean;
  25562. /**
  25563. * Gets if the SPS is created as expandable at construction time.
  25564. * Default : `false`
  25565. */
  25566. readonly expandable: boolean;
  25567. /**
  25568. * This function does nothing. It may be overwritten to set all the particle first values.
  25569. * The SPS doesn't call this function, you may have to call it by your own.
  25570. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25571. */
  25572. initParticles(): void;
  25573. /**
  25574. * This function does nothing. It may be overwritten to recycle a particle.
  25575. * The SPS doesn't call this function, you may have to call it by your own.
  25576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25577. * @param particle The particle to recycle
  25578. * @returns the recycled particle
  25579. */
  25580. recycleParticle(particle: SolidParticle): SolidParticle;
  25581. /**
  25582. * Updates a particle : this function should be overwritten by the user.
  25583. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25585. * @example : just set a particle position or velocity and recycle conditions
  25586. * @param particle The particle to update
  25587. * @returns the updated particle
  25588. */
  25589. updateParticle(particle: SolidParticle): SolidParticle;
  25590. /**
  25591. * Updates a vertex of a particle : it can be overwritten by the user.
  25592. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25593. * @param particle the current particle
  25594. * @param vertex the current index of the current particle
  25595. * @param pt the index of the current vertex in the particle shape
  25596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25597. * @example : just set a vertex particle position
  25598. * @returns the updated vertex
  25599. */
  25600. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25601. /**
  25602. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25603. * This does nothing and may be overwritten by the user.
  25604. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25605. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25606. * @param update the boolean update value actually passed to setParticles()
  25607. */
  25608. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25609. /**
  25610. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25611. * This will be passed three parameters.
  25612. * This does nothing and may be overwritten by the user.
  25613. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25614. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25615. * @param update the boolean update value actually passed to setParticles()
  25616. */
  25617. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25618. }
  25619. }
  25620. declare module BABYLON {
  25621. /**
  25622. * Represents one particle of a solid particle system.
  25623. */
  25624. export class SolidParticle {
  25625. /**
  25626. * particle global index
  25627. */
  25628. idx: number;
  25629. /**
  25630. * The color of the particle
  25631. */
  25632. color: Nullable<Color4>;
  25633. /**
  25634. * The world space position of the particle.
  25635. */
  25636. position: Vector3;
  25637. /**
  25638. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25639. */
  25640. rotation: Vector3;
  25641. /**
  25642. * The world space rotation quaternion of the particle.
  25643. */
  25644. rotationQuaternion: Nullable<Quaternion>;
  25645. /**
  25646. * The scaling of the particle.
  25647. */
  25648. scaling: Vector3;
  25649. /**
  25650. * The uvs of the particle.
  25651. */
  25652. uvs: Vector4;
  25653. /**
  25654. * The current speed of the particle.
  25655. */
  25656. velocity: Vector3;
  25657. /**
  25658. * The pivot point in the particle local space.
  25659. */
  25660. pivot: Vector3;
  25661. /**
  25662. * Must the particle be translated from its pivot point in its local space ?
  25663. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25664. * Default : false
  25665. */
  25666. translateFromPivot: boolean;
  25667. /**
  25668. * Is the particle active or not ?
  25669. */
  25670. alive: boolean;
  25671. /**
  25672. * Is the particle visible or not ?
  25673. */
  25674. isVisible: boolean;
  25675. /**
  25676. * Index of this particle in the global "positions" array (Internal use)
  25677. * @hidden
  25678. */
  25679. _pos: number;
  25680. /**
  25681. * @hidden Index of this particle in the global "indices" array (Internal use)
  25682. */
  25683. _ind: number;
  25684. /**
  25685. * @hidden ModelShape of this particle (Internal use)
  25686. */
  25687. _model: ModelShape;
  25688. /**
  25689. * ModelShape id of this particle
  25690. */
  25691. shapeId: number;
  25692. /**
  25693. * Index of the particle in its shape id
  25694. */
  25695. idxInShape: number;
  25696. /**
  25697. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25698. */
  25699. _modelBoundingInfo: BoundingInfo;
  25700. /**
  25701. * @hidden Particle BoundingInfo object (Internal use)
  25702. */
  25703. _boundingInfo: BoundingInfo;
  25704. /**
  25705. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25706. */
  25707. _sps: SolidParticleSystem;
  25708. /**
  25709. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25710. */
  25711. _stillInvisible: boolean;
  25712. /**
  25713. * @hidden Last computed particle rotation matrix
  25714. */
  25715. _rotationMatrix: number[];
  25716. /**
  25717. * Parent particle Id, if any.
  25718. * Default null.
  25719. */
  25720. parentId: Nullable<number>;
  25721. /**
  25722. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25723. * The possible values are :
  25724. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25725. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25727. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25728. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25729. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25730. * */
  25731. cullingStrategy: number;
  25732. /**
  25733. * @hidden Internal global position in the SPS.
  25734. */
  25735. _globalPosition: Vector3;
  25736. /**
  25737. * Creates a Solid Particle object.
  25738. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25739. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25740. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25741. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25742. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25743. * @param shapeId (integer) is the model shape identifier in the SPS.
  25744. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25745. * @param sps defines the sps it is associated to
  25746. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25747. */
  25748. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25749. /**
  25750. * Legacy support, changed scale to scaling
  25751. */
  25752. /**
  25753. * Legacy support, changed scale to scaling
  25754. */
  25755. scale: Vector3;
  25756. /**
  25757. * Legacy support, changed quaternion to rotationQuaternion
  25758. */
  25759. /**
  25760. * Legacy support, changed quaternion to rotationQuaternion
  25761. */
  25762. quaternion: Nullable<Quaternion>;
  25763. /**
  25764. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25765. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25766. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25767. * @returns true if it intersects
  25768. */
  25769. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25770. /**
  25771. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25772. * A particle is in the frustum if its bounding box intersects the frustum
  25773. * @param frustumPlanes defines the frustum to test
  25774. * @returns true if the particle is in the frustum planes
  25775. */
  25776. isInFrustum(frustumPlanes: Plane[]): boolean;
  25777. /**
  25778. * get the rotation matrix of the particle
  25779. * @hidden
  25780. */
  25781. getRotationMatrix(m: Matrix): void;
  25782. }
  25783. /**
  25784. * Represents the shape of the model used by one particle of a solid particle system.
  25785. * SPS internal tool, don't use it manually.
  25786. */
  25787. export class ModelShape {
  25788. /**
  25789. * The shape id
  25790. * @hidden
  25791. */
  25792. shapeID: number;
  25793. /**
  25794. * flat array of model positions (internal use)
  25795. * @hidden
  25796. */
  25797. _shape: Vector3[];
  25798. /**
  25799. * flat array of model UVs (internal use)
  25800. * @hidden
  25801. */
  25802. _shapeUV: number[];
  25803. /**
  25804. * color array of the model
  25805. * @hidden
  25806. */
  25807. _shapeColors: number[];
  25808. /**
  25809. * indices array of the model
  25810. * @hidden
  25811. */
  25812. _indices: number[];
  25813. /**
  25814. * normals array of the model
  25815. * @hidden
  25816. */
  25817. _normals: number[];
  25818. /**
  25819. * length of the shape in the model indices array (internal use)
  25820. * @hidden
  25821. */
  25822. _indicesLength: number;
  25823. /**
  25824. * Custom position function (internal use)
  25825. * @hidden
  25826. */
  25827. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25828. /**
  25829. * Custom vertex function (internal use)
  25830. * @hidden
  25831. */
  25832. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25833. /**
  25834. * 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.
  25835. * SPS internal tool, don't use it manually.
  25836. * @hidden
  25837. */
  25838. 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>);
  25839. }
  25840. /**
  25841. * Represents a Depth Sorted Particle in the solid particle system.
  25842. */
  25843. export class DepthSortedParticle {
  25844. /**
  25845. * Index of the particle in the "indices" array
  25846. */
  25847. ind: number;
  25848. /**
  25849. * Length of the particle shape in the "indices" array
  25850. */
  25851. indicesLength: number;
  25852. /**
  25853. * Squared distance from the particle to the camera
  25854. */
  25855. sqDistance: number;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * @hidden
  25861. */
  25862. export class _MeshCollisionData {
  25863. _checkCollisions: boolean;
  25864. _collisionMask: number;
  25865. _collisionGroup: number;
  25866. _collider: Nullable<Collider>;
  25867. _oldPositionForCollisions: Vector3;
  25868. _diffPositionForCollisions: Vector3;
  25869. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25870. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25871. }
  25872. }
  25873. declare module BABYLON {
  25874. /** @hidden */
  25875. class _FacetDataStorage {
  25876. facetPositions: Vector3[];
  25877. facetNormals: Vector3[];
  25878. facetPartitioning: number[][];
  25879. facetNb: number;
  25880. partitioningSubdivisions: number;
  25881. partitioningBBoxRatio: number;
  25882. facetDataEnabled: boolean;
  25883. facetParameters: any;
  25884. bbSize: Vector3;
  25885. subDiv: {
  25886. max: number;
  25887. X: number;
  25888. Y: number;
  25889. Z: number;
  25890. };
  25891. facetDepthSort: boolean;
  25892. facetDepthSortEnabled: boolean;
  25893. depthSortedIndices: IndicesArray;
  25894. depthSortedFacets: {
  25895. ind: number;
  25896. sqDistance: number;
  25897. }[];
  25898. facetDepthSortFunction: (f1: {
  25899. ind: number;
  25900. sqDistance: number;
  25901. }, f2: {
  25902. ind: number;
  25903. sqDistance: number;
  25904. }) => number;
  25905. facetDepthSortFrom: Vector3;
  25906. facetDepthSortOrigin: Vector3;
  25907. invertedMatrix: Matrix;
  25908. }
  25909. /**
  25910. * @hidden
  25911. **/
  25912. class _InternalAbstractMeshDataInfo {
  25913. _hasVertexAlpha: boolean;
  25914. _useVertexColors: boolean;
  25915. _numBoneInfluencers: number;
  25916. _applyFog: boolean;
  25917. _receiveShadows: boolean;
  25918. _facetData: _FacetDataStorage;
  25919. _visibility: number;
  25920. _skeleton: Nullable<Skeleton>;
  25921. _layerMask: number;
  25922. _computeBonesUsingShaders: boolean;
  25923. _isActive: boolean;
  25924. _onlyForInstances: boolean;
  25925. _isActiveIntermediate: boolean;
  25926. _onlyForInstancesIntermediate: boolean;
  25927. _actAsRegularMesh: boolean;
  25928. }
  25929. /**
  25930. * Class used to store all common mesh properties
  25931. */
  25932. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25933. /** No occlusion */
  25934. static OCCLUSION_TYPE_NONE: number;
  25935. /** Occlusion set to optimisitic */
  25936. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25937. /** Occlusion set to strict */
  25938. static OCCLUSION_TYPE_STRICT: number;
  25939. /** Use an accurante occlusion algorithm */
  25940. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25941. /** Use a conservative occlusion algorithm */
  25942. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25943. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25944. * Test order :
  25945. * Is the bounding sphere outside the frustum ?
  25946. * If not, are the bounding box vertices outside the frustum ?
  25947. * It not, then the cullable object is in the frustum.
  25948. */
  25949. static readonly CULLINGSTRATEGY_STANDARD: number;
  25950. /** Culling strategy : Bounding Sphere Only.
  25951. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25952. * It's also less accurate than the standard because some not visible objects can still be selected.
  25953. * Test : is the bounding sphere outside the frustum ?
  25954. * If not, then the cullable object is in the frustum.
  25955. */
  25956. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25957. /** Culling strategy : Optimistic Inclusion.
  25958. * This in an inclusion test first, then the standard exclusion test.
  25959. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25960. * 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.
  25961. * Anyway, it's as accurate as the standard strategy.
  25962. * Test :
  25963. * Is the cullable object bounding sphere center in the frustum ?
  25964. * If not, apply the default culling strategy.
  25965. */
  25966. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25967. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25968. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25969. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25970. * 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.
  25971. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25972. * Test :
  25973. * Is the cullable object bounding sphere center in the frustum ?
  25974. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25975. */
  25976. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25977. /**
  25978. * No billboard
  25979. */
  25980. static readonly BILLBOARDMODE_NONE: number;
  25981. /** Billboard on X axis */
  25982. static readonly BILLBOARDMODE_X: number;
  25983. /** Billboard on Y axis */
  25984. static readonly BILLBOARDMODE_Y: number;
  25985. /** Billboard on Z axis */
  25986. static readonly BILLBOARDMODE_Z: number;
  25987. /** Billboard on all axes */
  25988. static readonly BILLBOARDMODE_ALL: number;
  25989. /** Billboard on using position instead of orientation */
  25990. static readonly BILLBOARDMODE_USE_POSITION: number;
  25991. /** @hidden */
  25992. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25993. /**
  25994. * The culling strategy to use to check whether the mesh must be rendered or not.
  25995. * This value can be changed at any time and will be used on the next render mesh selection.
  25996. * The possible values are :
  25997. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25998. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25999. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26000. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26001. * Please read each static variable documentation to get details about the culling process.
  26002. * */
  26003. cullingStrategy: number;
  26004. /**
  26005. * Gets the number of facets in the mesh
  26006. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26007. */
  26008. readonly facetNb: number;
  26009. /**
  26010. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26011. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26012. */
  26013. partitioningSubdivisions: number;
  26014. /**
  26015. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26016. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26018. */
  26019. partitioningBBoxRatio: number;
  26020. /**
  26021. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26022. * Works only for updatable meshes.
  26023. * Doesn't work with multi-materials
  26024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26025. */
  26026. mustDepthSortFacets: boolean;
  26027. /**
  26028. * The location (Vector3) where the facet depth sort must be computed from.
  26029. * By default, the active camera position.
  26030. * Used only when facet depth sort is enabled
  26031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26032. */
  26033. facetDepthSortFrom: Vector3;
  26034. /**
  26035. * gets a boolean indicating if facetData is enabled
  26036. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26037. */
  26038. readonly isFacetDataEnabled: boolean;
  26039. /** @hidden */
  26040. _updateNonUniformScalingState(value: boolean): boolean;
  26041. /**
  26042. * An event triggered when this mesh collides with another one
  26043. */
  26044. onCollideObservable: Observable<AbstractMesh>;
  26045. /** Set a function to call when this mesh collides with another one */
  26046. onCollide: () => void;
  26047. /**
  26048. * An event triggered when the collision's position changes
  26049. */
  26050. onCollisionPositionChangeObservable: Observable<Vector3>;
  26051. /** Set a function to call when the collision's position changes */
  26052. onCollisionPositionChange: () => void;
  26053. /**
  26054. * An event triggered when material is changed
  26055. */
  26056. onMaterialChangedObservable: Observable<AbstractMesh>;
  26057. /**
  26058. * Gets or sets the orientation for POV movement & rotation
  26059. */
  26060. definedFacingForward: boolean;
  26061. /** @hidden */
  26062. _occlusionQuery: Nullable<WebGLQuery>;
  26063. /** @hidden */
  26064. _renderingGroup: Nullable<RenderingGroup>;
  26065. /**
  26066. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26067. */
  26068. /**
  26069. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26070. */
  26071. visibility: number;
  26072. /** Gets or sets the alpha index used to sort transparent meshes
  26073. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26074. */
  26075. alphaIndex: number;
  26076. /**
  26077. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26078. */
  26079. isVisible: boolean;
  26080. /**
  26081. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26082. */
  26083. isPickable: boolean;
  26084. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26085. showSubMeshesBoundingBox: boolean;
  26086. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26087. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26088. */
  26089. isBlocker: boolean;
  26090. /**
  26091. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26092. */
  26093. enablePointerMoveEvents: boolean;
  26094. /**
  26095. * Specifies the rendering group id for this mesh (0 by default)
  26096. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26097. */
  26098. renderingGroupId: number;
  26099. private _material;
  26100. /** Gets or sets current material */
  26101. material: Nullable<Material>;
  26102. /**
  26103. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26104. * @see http://doc.babylonjs.com/babylon101/shadows
  26105. */
  26106. receiveShadows: boolean;
  26107. /** Defines color to use when rendering outline */
  26108. outlineColor: Color3;
  26109. /** Define width to use when rendering outline */
  26110. outlineWidth: number;
  26111. /** Defines color to use when rendering overlay */
  26112. overlayColor: Color3;
  26113. /** Defines alpha to use when rendering overlay */
  26114. overlayAlpha: number;
  26115. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26116. hasVertexAlpha: boolean;
  26117. /** 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) */
  26118. useVertexColors: boolean;
  26119. /**
  26120. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26121. */
  26122. computeBonesUsingShaders: boolean;
  26123. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26124. numBoneInfluencers: number;
  26125. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26126. applyFog: boolean;
  26127. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26128. useOctreeForRenderingSelection: boolean;
  26129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26130. useOctreeForPicking: boolean;
  26131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26132. useOctreeForCollisions: boolean;
  26133. /**
  26134. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26135. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26136. */
  26137. layerMask: number;
  26138. /**
  26139. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26140. */
  26141. alwaysSelectAsActiveMesh: boolean;
  26142. /**
  26143. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26144. */
  26145. doNotSyncBoundingInfo: boolean;
  26146. /**
  26147. * Gets or sets the current action manager
  26148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26149. */
  26150. actionManager: Nullable<AbstractActionManager>;
  26151. private _meshCollisionData;
  26152. /**
  26153. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26154. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26155. */
  26156. ellipsoid: Vector3;
  26157. /**
  26158. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26160. */
  26161. ellipsoidOffset: Vector3;
  26162. /**
  26163. * Gets or sets a collision mask used to mask collisions (default is -1).
  26164. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26165. */
  26166. collisionMask: number;
  26167. /**
  26168. * Gets or sets the current collision group mask (-1 by default).
  26169. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26170. */
  26171. collisionGroup: number;
  26172. /**
  26173. * Defines edge width used when edgesRenderer is enabled
  26174. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26175. */
  26176. edgesWidth: number;
  26177. /**
  26178. * Defines edge color used when edgesRenderer is enabled
  26179. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26180. */
  26181. edgesColor: Color4;
  26182. /** @hidden */
  26183. _edgesRenderer: Nullable<IEdgesRenderer>;
  26184. /** @hidden */
  26185. _masterMesh: Nullable<AbstractMesh>;
  26186. /** @hidden */
  26187. _boundingInfo: Nullable<BoundingInfo>;
  26188. /** @hidden */
  26189. _renderId: number;
  26190. /**
  26191. * Gets or sets the list of subMeshes
  26192. * @see http://doc.babylonjs.com/how_to/multi_materials
  26193. */
  26194. subMeshes: SubMesh[];
  26195. /** @hidden */
  26196. _intersectionsInProgress: AbstractMesh[];
  26197. /** @hidden */
  26198. _unIndexed: boolean;
  26199. /** @hidden */
  26200. _lightSources: Light[];
  26201. /** Gets the list of lights affecting that mesh */
  26202. readonly lightSources: Light[];
  26203. /** @hidden */
  26204. readonly _positions: Nullable<Vector3[]>;
  26205. /** @hidden */
  26206. _waitingData: {
  26207. lods: Nullable<any>;
  26208. actions: Nullable<any>;
  26209. freezeWorldMatrix: Nullable<boolean>;
  26210. };
  26211. /** @hidden */
  26212. _bonesTransformMatrices: Nullable<Float32Array>;
  26213. /** @hidden */
  26214. _transformMatrixTexture: Nullable<RawTexture>;
  26215. /**
  26216. * Gets or sets a skeleton to apply skining transformations
  26217. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26218. */
  26219. skeleton: Nullable<Skeleton>;
  26220. /**
  26221. * An event triggered when the mesh is rebuilt.
  26222. */
  26223. onRebuildObservable: Observable<AbstractMesh>;
  26224. /**
  26225. * Creates a new AbstractMesh
  26226. * @param name defines the name of the mesh
  26227. * @param scene defines the hosting scene
  26228. */
  26229. constructor(name: string, scene?: Nullable<Scene>);
  26230. /**
  26231. * Returns the string "AbstractMesh"
  26232. * @returns "AbstractMesh"
  26233. */
  26234. getClassName(): string;
  26235. /**
  26236. * Gets a string representation of the current mesh
  26237. * @param fullDetails defines a boolean indicating if full details must be included
  26238. * @returns a string representation of the current mesh
  26239. */
  26240. toString(fullDetails?: boolean): string;
  26241. /**
  26242. * @hidden
  26243. */
  26244. protected _getEffectiveParent(): Nullable<Node>;
  26245. /** @hidden */
  26246. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26247. /** @hidden */
  26248. _rebuild(): void;
  26249. /** @hidden */
  26250. _resyncLightSources(): void;
  26251. /** @hidden */
  26252. _resyncLighSource(light: Light): void;
  26253. /** @hidden */
  26254. _unBindEffect(): void;
  26255. /** @hidden */
  26256. _removeLightSource(light: Light, dispose: boolean): void;
  26257. private _markSubMeshesAsDirty;
  26258. /** @hidden */
  26259. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26260. /** @hidden */
  26261. _markSubMeshesAsAttributesDirty(): void;
  26262. /** @hidden */
  26263. _markSubMeshesAsMiscDirty(): void;
  26264. /**
  26265. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26266. */
  26267. scaling: Vector3;
  26268. /**
  26269. * Returns true if the mesh is blocked. Implemented by child classes
  26270. */
  26271. readonly isBlocked: boolean;
  26272. /**
  26273. * Returns the mesh itself by default. Implemented by child classes
  26274. * @param camera defines the camera to use to pick the right LOD level
  26275. * @returns the currentAbstractMesh
  26276. */
  26277. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26278. /**
  26279. * Returns 0 by default. Implemented by child classes
  26280. * @returns an integer
  26281. */
  26282. getTotalVertices(): number;
  26283. /**
  26284. * Returns a positive integer : the total number of indices in this mesh geometry.
  26285. * @returns the numner of indices or zero if the mesh has no geometry.
  26286. */
  26287. getTotalIndices(): number;
  26288. /**
  26289. * Returns null by default. Implemented by child classes
  26290. * @returns null
  26291. */
  26292. getIndices(): Nullable<IndicesArray>;
  26293. /**
  26294. * Returns the array of the requested vertex data kind. Implemented by child classes
  26295. * @param kind defines the vertex data kind to use
  26296. * @returns null
  26297. */
  26298. getVerticesData(kind: string): Nullable<FloatArray>;
  26299. /**
  26300. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26301. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26302. * Note that a new underlying VertexBuffer object is created each call.
  26303. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26304. * @param kind defines vertex data kind:
  26305. * * VertexBuffer.PositionKind
  26306. * * VertexBuffer.UVKind
  26307. * * VertexBuffer.UV2Kind
  26308. * * VertexBuffer.UV3Kind
  26309. * * VertexBuffer.UV4Kind
  26310. * * VertexBuffer.UV5Kind
  26311. * * VertexBuffer.UV6Kind
  26312. * * VertexBuffer.ColorKind
  26313. * * VertexBuffer.MatricesIndicesKind
  26314. * * VertexBuffer.MatricesIndicesExtraKind
  26315. * * VertexBuffer.MatricesWeightsKind
  26316. * * VertexBuffer.MatricesWeightsExtraKind
  26317. * @param data defines the data source
  26318. * @param updatable defines if the data must be flagged as updatable (or static)
  26319. * @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
  26320. * @returns the current mesh
  26321. */
  26322. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26323. /**
  26324. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26325. * If the mesh has no geometry, it is simply returned as it is.
  26326. * @param kind defines vertex data kind:
  26327. * * VertexBuffer.PositionKind
  26328. * * VertexBuffer.UVKind
  26329. * * VertexBuffer.UV2Kind
  26330. * * VertexBuffer.UV3Kind
  26331. * * VertexBuffer.UV4Kind
  26332. * * VertexBuffer.UV5Kind
  26333. * * VertexBuffer.UV6Kind
  26334. * * VertexBuffer.ColorKind
  26335. * * VertexBuffer.MatricesIndicesKind
  26336. * * VertexBuffer.MatricesIndicesExtraKind
  26337. * * VertexBuffer.MatricesWeightsKind
  26338. * * VertexBuffer.MatricesWeightsExtraKind
  26339. * @param data defines the data source
  26340. * @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
  26341. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26342. * @returns the current mesh
  26343. */
  26344. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26345. /**
  26346. * Sets the mesh indices,
  26347. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26348. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26349. * @param totalVertices Defines the total number of vertices
  26350. * @returns the current mesh
  26351. */
  26352. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26353. /**
  26354. * Gets a boolean indicating if specific vertex data is present
  26355. * @param kind defines the vertex data kind to use
  26356. * @returns true is data kind is present
  26357. */
  26358. isVerticesDataPresent(kind: string): boolean;
  26359. /**
  26360. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26361. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26362. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26363. * @returns a BoundingInfo
  26364. */
  26365. getBoundingInfo(): BoundingInfo;
  26366. /**
  26367. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26368. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26369. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26370. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26371. * @returns the current mesh
  26372. */
  26373. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26374. /**
  26375. * Overwrite the current bounding info
  26376. * @param boundingInfo defines the new bounding info
  26377. * @returns the current mesh
  26378. */
  26379. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26380. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26381. readonly useBones: boolean;
  26382. /** @hidden */
  26383. _preActivate(): void;
  26384. /** @hidden */
  26385. _preActivateForIntermediateRendering(renderId: number): void;
  26386. /** @hidden */
  26387. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26388. /** @hidden */
  26389. _postActivate(): void;
  26390. /** @hidden */
  26391. _freeze(): void;
  26392. /** @hidden */
  26393. _unFreeze(): void;
  26394. /**
  26395. * Gets the current world matrix
  26396. * @returns a Matrix
  26397. */
  26398. getWorldMatrix(): Matrix;
  26399. /** @hidden */
  26400. _getWorldMatrixDeterminant(): number;
  26401. /**
  26402. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26403. */
  26404. readonly isAnInstance: boolean;
  26405. /**
  26406. * Gets a boolean indicating if this mesh has instances
  26407. */
  26408. readonly hasInstances: boolean;
  26409. /**
  26410. * Perform relative position change from the point of view of behind the front of the mesh.
  26411. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26412. * Supports definition of mesh facing forward or backward
  26413. * @param amountRight defines the distance on the right axis
  26414. * @param amountUp defines the distance on the up axis
  26415. * @param amountForward defines the distance on the forward axis
  26416. * @returns the current mesh
  26417. */
  26418. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26419. /**
  26420. * Calculate relative position change from the point of view of behind the front of the mesh.
  26421. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26422. * Supports definition of mesh facing forward or backward
  26423. * @param amountRight defines the distance on the right axis
  26424. * @param amountUp defines the distance on the up axis
  26425. * @param amountForward defines the distance on the forward axis
  26426. * @returns the new displacement vector
  26427. */
  26428. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26429. /**
  26430. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26431. * Supports definition of mesh facing forward or backward
  26432. * @param flipBack defines the flip
  26433. * @param twirlClockwise defines the twirl
  26434. * @param tiltRight defines the tilt
  26435. * @returns the current mesh
  26436. */
  26437. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26438. /**
  26439. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26440. * Supports definition of mesh facing forward or backward.
  26441. * @param flipBack defines the flip
  26442. * @param twirlClockwise defines the twirl
  26443. * @param tiltRight defines the tilt
  26444. * @returns the new rotation vector
  26445. */
  26446. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26447. /**
  26448. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26449. * This means the mesh underlying bounding box and sphere are recomputed.
  26450. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26451. * @returns the current mesh
  26452. */
  26453. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26454. /** @hidden */
  26455. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26456. /** @hidden */
  26457. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26458. /** @hidden */
  26459. _updateBoundingInfo(): AbstractMesh;
  26460. /** @hidden */
  26461. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26462. /** @hidden */
  26463. protected _afterComputeWorldMatrix(): void;
  26464. /** @hidden */
  26465. readonly _effectiveMesh: AbstractMesh;
  26466. /**
  26467. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26468. * A mesh is in the frustum if its bounding box intersects the frustum
  26469. * @param frustumPlanes defines the frustum to test
  26470. * @returns true if the mesh is in the frustum planes
  26471. */
  26472. isInFrustum(frustumPlanes: Plane[]): boolean;
  26473. /**
  26474. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26475. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26476. * @param frustumPlanes defines the frustum to test
  26477. * @returns true if the mesh is completely in the frustum planes
  26478. */
  26479. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26480. /**
  26481. * True if the mesh intersects another mesh or a SolidParticle object
  26482. * @param mesh defines a target mesh or SolidParticle to test
  26483. * @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)
  26484. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26485. * @returns true if there is an intersection
  26486. */
  26487. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26488. /**
  26489. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26490. * @param point defines the point to test
  26491. * @returns true if there is an intersection
  26492. */
  26493. intersectsPoint(point: Vector3): boolean;
  26494. /**
  26495. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26497. */
  26498. checkCollisions: boolean;
  26499. /**
  26500. * Gets Collider object used to compute collisions (not physics)
  26501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26502. */
  26503. readonly collider: Nullable<Collider>;
  26504. /**
  26505. * Move the mesh using collision engine
  26506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26507. * @param displacement defines the requested displacement vector
  26508. * @returns the current mesh
  26509. */
  26510. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26511. private _onCollisionPositionChange;
  26512. /** @hidden */
  26513. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26514. /** @hidden */
  26515. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26516. /** @hidden */
  26517. _checkCollision(collider: Collider): AbstractMesh;
  26518. /** @hidden */
  26519. _generatePointsArray(): boolean;
  26520. /**
  26521. * Checks if the passed Ray intersects with the mesh
  26522. * @param ray defines the ray to use
  26523. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26525. * @returns the picking info
  26526. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26527. */
  26528. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26529. /**
  26530. * Clones the current mesh
  26531. * @param name defines the mesh name
  26532. * @param newParent defines the new mesh parent
  26533. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26534. * @returns the new mesh
  26535. */
  26536. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26537. /**
  26538. * Disposes all the submeshes of the current meshnp
  26539. * @returns the current mesh
  26540. */
  26541. releaseSubMeshes(): AbstractMesh;
  26542. /**
  26543. * Releases resources associated with this abstract mesh.
  26544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26546. */
  26547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26548. /**
  26549. * Adds the passed mesh as a child to the current mesh
  26550. * @param mesh defines the child mesh
  26551. * @returns the current mesh
  26552. */
  26553. addChild(mesh: AbstractMesh): AbstractMesh;
  26554. /**
  26555. * Removes the passed mesh from the current mesh children list
  26556. * @param mesh defines the child mesh
  26557. * @returns the current mesh
  26558. */
  26559. removeChild(mesh: AbstractMesh): AbstractMesh;
  26560. /** @hidden */
  26561. private _initFacetData;
  26562. /**
  26563. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26564. * This method can be called within the render loop.
  26565. * 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
  26566. * @returns the current mesh
  26567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26568. */
  26569. updateFacetData(): AbstractMesh;
  26570. /**
  26571. * Returns the facetLocalNormals array.
  26572. * The normals are expressed in the mesh local spac
  26573. * @returns an array of Vector3
  26574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26575. */
  26576. getFacetLocalNormals(): Vector3[];
  26577. /**
  26578. * Returns the facetLocalPositions array.
  26579. * The facet positions are expressed in the mesh local space
  26580. * @returns an array of Vector3
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26582. */
  26583. getFacetLocalPositions(): Vector3[];
  26584. /**
  26585. * Returns the facetLocalPartioning array
  26586. * @returns an array of array of numbers
  26587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26588. */
  26589. getFacetLocalPartitioning(): number[][];
  26590. /**
  26591. * Returns the i-th facet position in the world system.
  26592. * This method allocates a new Vector3 per call
  26593. * @param i defines the facet index
  26594. * @returns a new Vector3
  26595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26596. */
  26597. getFacetPosition(i: number): Vector3;
  26598. /**
  26599. * Sets the reference Vector3 with the i-th facet position in the world system
  26600. * @param i defines the facet index
  26601. * @param ref defines the target vector
  26602. * @returns the current mesh
  26603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26604. */
  26605. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26606. /**
  26607. * Returns the i-th facet normal in the world system.
  26608. * This method allocates a new Vector3 per call
  26609. * @param i defines the facet index
  26610. * @returns a new Vector3
  26611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26612. */
  26613. getFacetNormal(i: number): Vector3;
  26614. /**
  26615. * Sets the reference Vector3 with the i-th facet normal in the world system
  26616. * @param i defines the facet index
  26617. * @param ref defines the target vector
  26618. * @returns the current mesh
  26619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26620. */
  26621. getFacetNormalToRef(i: number, ref: Vector3): this;
  26622. /**
  26623. * 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)
  26624. * @param x defines x coordinate
  26625. * @param y defines y coordinate
  26626. * @param z defines z coordinate
  26627. * @returns the array of facet indexes
  26628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26629. */
  26630. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26631. /**
  26632. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26633. * @param projected sets as the (x,y,z) world projection on the facet
  26634. * @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
  26635. * @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
  26636. * @param x defines x coordinate
  26637. * @param y defines y coordinate
  26638. * @param z defines z coordinate
  26639. * @returns the face index if found (or null instead)
  26640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26641. */
  26642. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26643. /**
  26644. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26645. * @param projected sets as the (x,y,z) local projection on the facet
  26646. * @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
  26647. * @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
  26648. * @param x defines x coordinate
  26649. * @param y defines y coordinate
  26650. * @param z defines z coordinate
  26651. * @returns the face index if found (or null instead)
  26652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26653. */
  26654. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26655. /**
  26656. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26657. * @returns the parameters
  26658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26659. */
  26660. getFacetDataParameters(): any;
  26661. /**
  26662. * Disables the feature FacetData and frees the related memory
  26663. * @returns the current mesh
  26664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26665. */
  26666. disableFacetData(): AbstractMesh;
  26667. /**
  26668. * Updates the AbstractMesh indices array
  26669. * @param indices defines the data source
  26670. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26671. * @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)
  26672. * @returns the current mesh
  26673. */
  26674. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26675. /**
  26676. * Creates new normals data for the mesh
  26677. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26678. * @returns the current mesh
  26679. */
  26680. createNormals(updatable: boolean): AbstractMesh;
  26681. /**
  26682. * Align the mesh with a normal
  26683. * @param normal defines the normal to use
  26684. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26685. * @returns the current mesh
  26686. */
  26687. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26688. /** @hidden */
  26689. _checkOcclusionQuery(): boolean;
  26690. /**
  26691. * Disables the mesh edge rendering mode
  26692. * @returns the currentAbstractMesh
  26693. */
  26694. disableEdgesRendering(): AbstractMesh;
  26695. /**
  26696. * Enables the edge rendering mode on the mesh.
  26697. * This mode makes the mesh edges visible
  26698. * @param epsilon defines the maximal distance between two angles to detect a face
  26699. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26700. * @returns the currentAbstractMesh
  26701. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26702. */
  26703. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26704. }
  26705. }
  26706. declare module BABYLON {
  26707. /**
  26708. * Interface used to define ActionEvent
  26709. */
  26710. export interface IActionEvent {
  26711. /** The mesh or sprite that triggered the action */
  26712. source: any;
  26713. /** The X mouse cursor position at the time of the event */
  26714. pointerX: number;
  26715. /** The Y mouse cursor position at the time of the event */
  26716. pointerY: number;
  26717. /** The mesh that is currently pointed at (can be null) */
  26718. meshUnderPointer: Nullable<AbstractMesh>;
  26719. /** the original (browser) event that triggered the ActionEvent */
  26720. sourceEvent?: any;
  26721. /** additional data for the event */
  26722. additionalData?: any;
  26723. }
  26724. /**
  26725. * ActionEvent is the event being sent when an action is triggered.
  26726. */
  26727. export class ActionEvent implements IActionEvent {
  26728. /** The mesh or sprite that triggered the action */
  26729. source: any;
  26730. /** The X mouse cursor position at the time of the event */
  26731. pointerX: number;
  26732. /** The Y mouse cursor position at the time of the event */
  26733. pointerY: number;
  26734. /** The mesh that is currently pointed at (can be null) */
  26735. meshUnderPointer: Nullable<AbstractMesh>;
  26736. /** the original (browser) event that triggered the ActionEvent */
  26737. sourceEvent?: any;
  26738. /** additional data for the event */
  26739. additionalData?: any;
  26740. /**
  26741. * Creates a new ActionEvent
  26742. * @param source The mesh or sprite that triggered the action
  26743. * @param pointerX The X mouse cursor position at the time of the event
  26744. * @param pointerY The Y mouse cursor position at the time of the event
  26745. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26746. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26747. * @param additionalData additional data for the event
  26748. */
  26749. constructor(
  26750. /** The mesh or sprite that triggered the action */
  26751. source: any,
  26752. /** The X mouse cursor position at the time of the event */
  26753. pointerX: number,
  26754. /** The Y mouse cursor position at the time of the event */
  26755. pointerY: number,
  26756. /** The mesh that is currently pointed at (can be null) */
  26757. meshUnderPointer: Nullable<AbstractMesh>,
  26758. /** the original (browser) event that triggered the ActionEvent */
  26759. sourceEvent?: any,
  26760. /** additional data for the event */
  26761. additionalData?: any);
  26762. /**
  26763. * Helper function to auto-create an ActionEvent from a source mesh.
  26764. * @param source The source mesh that triggered the event
  26765. * @param evt The original (browser) event
  26766. * @param additionalData additional data for the event
  26767. * @returns the new ActionEvent
  26768. */
  26769. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26770. /**
  26771. * Helper function to auto-create an ActionEvent from a source sprite
  26772. * @param source The source sprite that triggered the event
  26773. * @param scene Scene associated with the sprite
  26774. * @param evt The original (browser) event
  26775. * @param additionalData additional data for the event
  26776. * @returns the new ActionEvent
  26777. */
  26778. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26779. /**
  26780. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26781. * @param scene the scene where the event occurred
  26782. * @param evt The original (browser) event
  26783. * @returns the new ActionEvent
  26784. */
  26785. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26786. /**
  26787. * Helper function to auto-create an ActionEvent from a primitive
  26788. * @param prim defines the target primitive
  26789. * @param pointerPos defines the pointer position
  26790. * @param evt The original (browser) event
  26791. * @param additionalData additional data for the event
  26792. * @returns the new ActionEvent
  26793. */
  26794. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26795. }
  26796. }
  26797. declare module BABYLON {
  26798. /**
  26799. * Abstract class used to decouple action Manager from scene and meshes.
  26800. * Do not instantiate.
  26801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26802. */
  26803. export abstract class AbstractActionManager implements IDisposable {
  26804. /** Gets the list of active triggers */
  26805. static Triggers: {
  26806. [key: string]: number;
  26807. };
  26808. /** Gets the cursor to use when hovering items */
  26809. hoverCursor: string;
  26810. /** Gets the list of actions */
  26811. actions: IAction[];
  26812. /**
  26813. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26814. */
  26815. isRecursive: boolean;
  26816. /**
  26817. * Releases all associated resources
  26818. */
  26819. abstract dispose(): void;
  26820. /**
  26821. * Does this action manager has pointer triggers
  26822. */
  26823. abstract readonly hasPointerTriggers: boolean;
  26824. /**
  26825. * Does this action manager has pick triggers
  26826. */
  26827. abstract readonly hasPickTriggers: boolean;
  26828. /**
  26829. * Process a specific trigger
  26830. * @param trigger defines the trigger to process
  26831. * @param evt defines the event details to be processed
  26832. */
  26833. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26834. /**
  26835. * Does this action manager handles actions of any of the given triggers
  26836. * @param triggers defines the triggers to be tested
  26837. * @return a boolean indicating whether one (or more) of the triggers is handled
  26838. */
  26839. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26840. /**
  26841. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26842. * speed.
  26843. * @param triggerA defines the trigger to be tested
  26844. * @param triggerB defines the trigger to be tested
  26845. * @return a boolean indicating whether one (or more) of the triggers is handled
  26846. */
  26847. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26848. /**
  26849. * Does this action manager handles actions of a given trigger
  26850. * @param trigger defines the trigger to be tested
  26851. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26852. * @return whether the trigger is handled
  26853. */
  26854. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26855. /**
  26856. * Serialize this manager to a JSON object
  26857. * @param name defines the property name to store this manager
  26858. * @returns a JSON representation of this manager
  26859. */
  26860. abstract serialize(name: string): any;
  26861. /**
  26862. * Registers an action to this action manager
  26863. * @param action defines the action to be registered
  26864. * @return the action amended (prepared) after registration
  26865. */
  26866. abstract registerAction(action: IAction): Nullable<IAction>;
  26867. /**
  26868. * Unregisters an action to this action manager
  26869. * @param action defines the action to be unregistered
  26870. * @return a boolean indicating whether the action has been unregistered
  26871. */
  26872. abstract unregisterAction(action: IAction): Boolean;
  26873. /**
  26874. * Does exist one action manager with at least one trigger
  26875. **/
  26876. static readonly HasTriggers: boolean;
  26877. /**
  26878. * Does exist one action manager with at least one pick trigger
  26879. **/
  26880. static readonly HasPickTriggers: boolean;
  26881. /**
  26882. * Does exist one action manager that handles actions of a given trigger
  26883. * @param trigger defines the trigger to be tested
  26884. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26885. **/
  26886. static HasSpecificTrigger(trigger: number): boolean;
  26887. }
  26888. }
  26889. declare module BABYLON {
  26890. /**
  26891. * Defines how a node can be built from a string name.
  26892. */
  26893. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26894. /**
  26895. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26896. */
  26897. export class Node implements IBehaviorAware<Node> {
  26898. /** @hidden */
  26899. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26900. private static _NodeConstructors;
  26901. /**
  26902. * Add a new node constructor
  26903. * @param type defines the type name of the node to construct
  26904. * @param constructorFunc defines the constructor function
  26905. */
  26906. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26907. /**
  26908. * Returns a node constructor based on type name
  26909. * @param type defines the type name
  26910. * @param name defines the new node name
  26911. * @param scene defines the hosting scene
  26912. * @param options defines optional options to transmit to constructors
  26913. * @returns the new constructor or null
  26914. */
  26915. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26916. /**
  26917. * Gets or sets the name of the node
  26918. */
  26919. name: string;
  26920. /**
  26921. * Gets or sets the id of the node
  26922. */
  26923. id: string;
  26924. /**
  26925. * Gets or sets the unique id of the node
  26926. */
  26927. uniqueId: number;
  26928. /**
  26929. * Gets or sets a string used to store user defined state for the node
  26930. */
  26931. state: string;
  26932. /**
  26933. * Gets or sets an object used to store user defined information for the node
  26934. */
  26935. metadata: any;
  26936. /**
  26937. * For internal use only. Please do not use.
  26938. */
  26939. reservedDataStore: any;
  26940. /**
  26941. * List of inspectable custom properties (used by the Inspector)
  26942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26943. */
  26944. inspectableCustomProperties: IInspectable[];
  26945. private _doNotSerialize;
  26946. /**
  26947. * Gets or sets a boolean used to define if the node must be serialized
  26948. */
  26949. doNotSerialize: boolean;
  26950. /** @hidden */
  26951. _isDisposed: boolean;
  26952. /**
  26953. * Gets a list of Animations associated with the node
  26954. */
  26955. animations: Animation[];
  26956. protected _ranges: {
  26957. [name: string]: Nullable<AnimationRange>;
  26958. };
  26959. /**
  26960. * Callback raised when the node is ready to be used
  26961. */
  26962. onReady: Nullable<(node: Node) => void>;
  26963. private _isEnabled;
  26964. private _isParentEnabled;
  26965. private _isReady;
  26966. /** @hidden */
  26967. _currentRenderId: number;
  26968. private _parentUpdateId;
  26969. /** @hidden */
  26970. _childUpdateId: number;
  26971. /** @hidden */
  26972. _waitingParentId: Nullable<string>;
  26973. /** @hidden */
  26974. _scene: Scene;
  26975. /** @hidden */
  26976. _cache: any;
  26977. private _parentNode;
  26978. private _children;
  26979. /** @hidden */
  26980. _worldMatrix: Matrix;
  26981. /** @hidden */
  26982. _worldMatrixDeterminant: number;
  26983. /** @hidden */
  26984. _worldMatrixDeterminantIsDirty: boolean;
  26985. /** @hidden */
  26986. private _sceneRootNodesIndex;
  26987. /**
  26988. * Gets a boolean indicating if the node has been disposed
  26989. * @returns true if the node was disposed
  26990. */
  26991. isDisposed(): boolean;
  26992. /**
  26993. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26994. * @see https://doc.babylonjs.com/how_to/parenting
  26995. */
  26996. parent: Nullable<Node>;
  26997. private addToSceneRootNodes;
  26998. private removeFromSceneRootNodes;
  26999. private _animationPropertiesOverride;
  27000. /**
  27001. * Gets or sets the animation properties override
  27002. */
  27003. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27004. /**
  27005. * Gets a string idenfifying the name of the class
  27006. * @returns "Node" string
  27007. */
  27008. getClassName(): string;
  27009. /** @hidden */
  27010. readonly _isNode: boolean;
  27011. /**
  27012. * An event triggered when the mesh is disposed
  27013. */
  27014. onDisposeObservable: Observable<Node>;
  27015. private _onDisposeObserver;
  27016. /**
  27017. * Sets a callback that will be raised when the node will be disposed
  27018. */
  27019. onDispose: () => void;
  27020. /**
  27021. * Creates a new Node
  27022. * @param name the name and id to be given to this node
  27023. * @param scene the scene this node will be added to
  27024. * @param addToRootNodes the node will be added to scene.rootNodes
  27025. */
  27026. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27027. /**
  27028. * Gets the scene of the node
  27029. * @returns a scene
  27030. */
  27031. getScene(): Scene;
  27032. /**
  27033. * Gets the engine of the node
  27034. * @returns a Engine
  27035. */
  27036. getEngine(): Engine;
  27037. private _behaviors;
  27038. /**
  27039. * Attach a behavior to the node
  27040. * @see http://doc.babylonjs.com/features/behaviour
  27041. * @param behavior defines the behavior to attach
  27042. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27043. * @returns the current Node
  27044. */
  27045. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27046. /**
  27047. * Remove an attached behavior
  27048. * @see http://doc.babylonjs.com/features/behaviour
  27049. * @param behavior defines the behavior to attach
  27050. * @returns the current Node
  27051. */
  27052. removeBehavior(behavior: Behavior<Node>): Node;
  27053. /**
  27054. * Gets the list of attached behaviors
  27055. * @see http://doc.babylonjs.com/features/behaviour
  27056. */
  27057. readonly behaviors: Behavior<Node>[];
  27058. /**
  27059. * Gets an attached behavior by name
  27060. * @param name defines the name of the behavior to look for
  27061. * @see http://doc.babylonjs.com/features/behaviour
  27062. * @returns null if behavior was not found else the requested behavior
  27063. */
  27064. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27065. /**
  27066. * Returns the latest update of the World matrix
  27067. * @returns a Matrix
  27068. */
  27069. getWorldMatrix(): Matrix;
  27070. /** @hidden */
  27071. _getWorldMatrixDeterminant(): number;
  27072. /**
  27073. * Returns directly the latest state of the mesh World matrix.
  27074. * A Matrix is returned.
  27075. */
  27076. readonly worldMatrixFromCache: Matrix;
  27077. /** @hidden */
  27078. _initCache(): void;
  27079. /** @hidden */
  27080. updateCache(force?: boolean): void;
  27081. /** @hidden */
  27082. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27083. /** @hidden */
  27084. _updateCache(ignoreParentClass?: boolean): void;
  27085. /** @hidden */
  27086. _isSynchronized(): boolean;
  27087. /** @hidden */
  27088. _markSyncedWithParent(): void;
  27089. /** @hidden */
  27090. isSynchronizedWithParent(): boolean;
  27091. /** @hidden */
  27092. isSynchronized(): boolean;
  27093. /**
  27094. * Is this node ready to be used/rendered
  27095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27096. * @return true if the node is ready
  27097. */
  27098. isReady(completeCheck?: boolean): boolean;
  27099. /**
  27100. * Is this node enabled?
  27101. * 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
  27102. * @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
  27103. * @return whether this node (and its parent) is enabled
  27104. */
  27105. isEnabled(checkAncestors?: boolean): boolean;
  27106. /** @hidden */
  27107. protected _syncParentEnabledState(): void;
  27108. /**
  27109. * Set the enabled state of this node
  27110. * @param value defines the new enabled state
  27111. */
  27112. setEnabled(value: boolean): void;
  27113. /**
  27114. * Is this node a descendant of the given node?
  27115. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27116. * @param ancestor defines the parent node to inspect
  27117. * @returns a boolean indicating if this node is a descendant of the given node
  27118. */
  27119. isDescendantOf(ancestor: Node): boolean;
  27120. /** @hidden */
  27121. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27122. /**
  27123. * Will return all nodes that have this node as ascendant
  27124. * @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
  27125. * @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
  27126. * @return all children nodes of all types
  27127. */
  27128. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27129. /**
  27130. * Get all child-meshes of this node
  27131. * @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)
  27132. * @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
  27133. * @returns an array of AbstractMesh
  27134. */
  27135. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27136. /**
  27137. * Get all direct children of this node
  27138. * @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
  27139. * @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)
  27140. * @returns an array of Node
  27141. */
  27142. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27143. /** @hidden */
  27144. _setReady(state: boolean): void;
  27145. /**
  27146. * Get an animation by name
  27147. * @param name defines the name of the animation to look for
  27148. * @returns null if not found else the requested animation
  27149. */
  27150. getAnimationByName(name: string): Nullable<Animation>;
  27151. /**
  27152. * Creates an animation range for this node
  27153. * @param name defines the name of the range
  27154. * @param from defines the starting key
  27155. * @param to defines the end key
  27156. */
  27157. createAnimationRange(name: string, from: number, to: number): void;
  27158. /**
  27159. * Delete a specific animation range
  27160. * @param name defines the name of the range to delete
  27161. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27162. */
  27163. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27164. /**
  27165. * Get an animation range by name
  27166. * @param name defines the name of the animation range to look for
  27167. * @returns null if not found else the requested animation range
  27168. */
  27169. getAnimationRange(name: string): Nullable<AnimationRange>;
  27170. /**
  27171. * Gets the list of all animation ranges defined on this node
  27172. * @returns an array
  27173. */
  27174. getAnimationRanges(): Nullable<AnimationRange>[];
  27175. /**
  27176. * Will start the animation sequence
  27177. * @param name defines the range frames for animation sequence
  27178. * @param loop defines if the animation should loop (false by default)
  27179. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27180. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27181. * @returns the object created for this animation. If range does not exist, it will return null
  27182. */
  27183. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27184. /**
  27185. * Serialize animation ranges into a JSON compatible object
  27186. * @returns serialization object
  27187. */
  27188. serializeAnimationRanges(): any;
  27189. /**
  27190. * Computes the world matrix of the node
  27191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27192. * @returns the world matrix
  27193. */
  27194. computeWorldMatrix(force?: boolean): Matrix;
  27195. /**
  27196. * Releases resources associated with this node.
  27197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27199. */
  27200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27201. /**
  27202. * Parse animation range data from a serialization object and store them into a given node
  27203. * @param node defines where to store the animation ranges
  27204. * @param parsedNode defines the serialization object to read data from
  27205. * @param scene defines the hosting scene
  27206. */
  27207. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27208. /**
  27209. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27210. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27211. * @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
  27212. * @returns the new bounding vectors
  27213. */
  27214. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27215. min: Vector3;
  27216. max: Vector3;
  27217. };
  27218. }
  27219. }
  27220. declare module BABYLON {
  27221. /**
  27222. * @hidden
  27223. */
  27224. export class _IAnimationState {
  27225. key: number;
  27226. repeatCount: number;
  27227. workValue?: any;
  27228. loopMode?: number;
  27229. offsetValue?: any;
  27230. highLimitValue?: any;
  27231. }
  27232. /**
  27233. * Class used to store any kind of animation
  27234. */
  27235. export class Animation {
  27236. /**Name of the animation */
  27237. name: string;
  27238. /**Property to animate */
  27239. targetProperty: string;
  27240. /**The frames per second of the animation */
  27241. framePerSecond: number;
  27242. /**The data type of the animation */
  27243. dataType: number;
  27244. /**The loop mode of the animation */
  27245. loopMode?: number | undefined;
  27246. /**Specifies if blending should be enabled */
  27247. enableBlending?: boolean | undefined;
  27248. /**
  27249. * Use matrix interpolation instead of using direct key value when animating matrices
  27250. */
  27251. static AllowMatricesInterpolation: boolean;
  27252. /**
  27253. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27254. */
  27255. static AllowMatrixDecomposeForInterpolation: boolean;
  27256. /**
  27257. * Stores the key frames of the animation
  27258. */
  27259. private _keys;
  27260. /**
  27261. * Stores the easing function of the animation
  27262. */
  27263. private _easingFunction;
  27264. /**
  27265. * @hidden Internal use only
  27266. */
  27267. _runtimeAnimations: RuntimeAnimation[];
  27268. /**
  27269. * The set of event that will be linked to this animation
  27270. */
  27271. private _events;
  27272. /**
  27273. * Stores an array of target property paths
  27274. */
  27275. targetPropertyPath: string[];
  27276. /**
  27277. * Stores the blending speed of the animation
  27278. */
  27279. blendingSpeed: number;
  27280. /**
  27281. * Stores the animation ranges for the animation
  27282. */
  27283. private _ranges;
  27284. /**
  27285. * @hidden Internal use
  27286. */
  27287. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27288. /**
  27289. * Sets up an animation
  27290. * @param property The property to animate
  27291. * @param animationType The animation type to apply
  27292. * @param framePerSecond The frames per second of the animation
  27293. * @param easingFunction The easing function used in the animation
  27294. * @returns The created animation
  27295. */
  27296. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27297. /**
  27298. * Create and start an animation on a node
  27299. * @param name defines the name of the global animation that will be run on all nodes
  27300. * @param node defines the root node where the animation will take place
  27301. * @param targetProperty defines property to animate
  27302. * @param framePerSecond defines the number of frame per second yo use
  27303. * @param totalFrame defines the number of frames in total
  27304. * @param from defines the initial value
  27305. * @param to defines the final value
  27306. * @param loopMode defines which loop mode you want to use (off by default)
  27307. * @param easingFunction defines the easing function to use (linear by default)
  27308. * @param onAnimationEnd defines the callback to call when animation end
  27309. * @returns the animatable created for this animation
  27310. */
  27311. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27312. /**
  27313. * Create and start an animation on a node and its descendants
  27314. * @param name defines the name of the global animation that will be run on all nodes
  27315. * @param node defines the root node where the animation will take place
  27316. * @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
  27317. * @param targetProperty defines property to animate
  27318. * @param framePerSecond defines the number of frame per second to use
  27319. * @param totalFrame defines the number of frames in total
  27320. * @param from defines the initial value
  27321. * @param to defines the final value
  27322. * @param loopMode defines which loop mode you want to use (off by default)
  27323. * @param easingFunction defines the easing function to use (linear by default)
  27324. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27325. * @returns the list of animatables created for all nodes
  27326. * @example https://www.babylonjs-playground.com/#MH0VLI
  27327. */
  27328. 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[]>;
  27329. /**
  27330. * Creates a new animation, merges it with the existing animations and starts it
  27331. * @param name Name of the animation
  27332. * @param node Node which contains the scene that begins the animations
  27333. * @param targetProperty Specifies which property to animate
  27334. * @param framePerSecond The frames per second of the animation
  27335. * @param totalFrame The total number of frames
  27336. * @param from The frame at the beginning of the animation
  27337. * @param to The frame at the end of the animation
  27338. * @param loopMode Specifies the loop mode of the animation
  27339. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27340. * @param onAnimationEnd Callback to run once the animation is complete
  27341. * @returns Nullable animation
  27342. */
  27343. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27344. /**
  27345. * Transition property of an host to the target Value
  27346. * @param property The property to transition
  27347. * @param targetValue The target Value of the property
  27348. * @param host The object where the property to animate belongs
  27349. * @param scene Scene used to run the animation
  27350. * @param frameRate Framerate (in frame/s) to use
  27351. * @param transition The transition type we want to use
  27352. * @param duration The duration of the animation, in milliseconds
  27353. * @param onAnimationEnd Callback trigger at the end of the animation
  27354. * @returns Nullable animation
  27355. */
  27356. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27357. /**
  27358. * Return the array of runtime animations currently using this animation
  27359. */
  27360. readonly runtimeAnimations: RuntimeAnimation[];
  27361. /**
  27362. * Specifies if any of the runtime animations are currently running
  27363. */
  27364. readonly hasRunningRuntimeAnimations: boolean;
  27365. /**
  27366. * Initializes the animation
  27367. * @param name Name of the animation
  27368. * @param targetProperty Property to animate
  27369. * @param framePerSecond The frames per second of the animation
  27370. * @param dataType The data type of the animation
  27371. * @param loopMode The loop mode of the animation
  27372. * @param enableBlending Specifies if blending should be enabled
  27373. */
  27374. constructor(
  27375. /**Name of the animation */
  27376. name: string,
  27377. /**Property to animate */
  27378. targetProperty: string,
  27379. /**The frames per second of the animation */
  27380. framePerSecond: number,
  27381. /**The data type of the animation */
  27382. dataType: number,
  27383. /**The loop mode of the animation */
  27384. loopMode?: number | undefined,
  27385. /**Specifies if blending should be enabled */
  27386. enableBlending?: boolean | undefined);
  27387. /**
  27388. * Converts the animation to a string
  27389. * @param fullDetails support for multiple levels of logging within scene loading
  27390. * @returns String form of the animation
  27391. */
  27392. toString(fullDetails?: boolean): string;
  27393. /**
  27394. * Add an event to this animation
  27395. * @param event Event to add
  27396. */
  27397. addEvent(event: AnimationEvent): void;
  27398. /**
  27399. * Remove all events found at the given frame
  27400. * @param frame The frame to remove events from
  27401. */
  27402. removeEvents(frame: number): void;
  27403. /**
  27404. * Retrieves all the events from the animation
  27405. * @returns Events from the animation
  27406. */
  27407. getEvents(): AnimationEvent[];
  27408. /**
  27409. * Creates an animation range
  27410. * @param name Name of the animation range
  27411. * @param from Starting frame of the animation range
  27412. * @param to Ending frame of the animation
  27413. */
  27414. createRange(name: string, from: number, to: number): void;
  27415. /**
  27416. * Deletes an animation range by name
  27417. * @param name Name of the animation range to delete
  27418. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27419. */
  27420. deleteRange(name: string, deleteFrames?: boolean): void;
  27421. /**
  27422. * Gets the animation range by name, or null if not defined
  27423. * @param name Name of the animation range
  27424. * @returns Nullable animation range
  27425. */
  27426. getRange(name: string): Nullable<AnimationRange>;
  27427. /**
  27428. * Gets the key frames from the animation
  27429. * @returns The key frames of the animation
  27430. */
  27431. getKeys(): Array<IAnimationKey>;
  27432. /**
  27433. * Gets the highest frame rate of the animation
  27434. * @returns Highest frame rate of the animation
  27435. */
  27436. getHighestFrame(): number;
  27437. /**
  27438. * Gets the easing function of the animation
  27439. * @returns Easing function of the animation
  27440. */
  27441. getEasingFunction(): IEasingFunction;
  27442. /**
  27443. * Sets the easing function of the animation
  27444. * @param easingFunction A custom mathematical formula for animation
  27445. */
  27446. setEasingFunction(easingFunction: EasingFunction): void;
  27447. /**
  27448. * Interpolates a scalar linearly
  27449. * @param startValue Start value of the animation curve
  27450. * @param endValue End value of the animation curve
  27451. * @param gradient Scalar amount to interpolate
  27452. * @returns Interpolated scalar value
  27453. */
  27454. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27455. /**
  27456. * Interpolates a scalar cubically
  27457. * @param startValue Start value of the animation curve
  27458. * @param outTangent End tangent of the animation
  27459. * @param endValue End value of the animation curve
  27460. * @param inTangent Start tangent of the animation curve
  27461. * @param gradient Scalar amount to interpolate
  27462. * @returns Interpolated scalar value
  27463. */
  27464. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27465. /**
  27466. * Interpolates a quaternion using a spherical linear interpolation
  27467. * @param startValue Start value of the animation curve
  27468. * @param endValue End value of the animation curve
  27469. * @param gradient Scalar amount to interpolate
  27470. * @returns Interpolated quaternion value
  27471. */
  27472. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27473. /**
  27474. * Interpolates a quaternion cubically
  27475. * @param startValue Start value of the animation curve
  27476. * @param outTangent End tangent of the animation curve
  27477. * @param endValue End value of the animation curve
  27478. * @param inTangent Start tangent of the animation curve
  27479. * @param gradient Scalar amount to interpolate
  27480. * @returns Interpolated quaternion value
  27481. */
  27482. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27483. /**
  27484. * Interpolates a Vector3 linearl
  27485. * @param startValue Start value of the animation curve
  27486. * @param endValue End value of the animation curve
  27487. * @param gradient Scalar amount to interpolate
  27488. * @returns Interpolated scalar value
  27489. */
  27490. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27491. /**
  27492. * Interpolates a Vector3 cubically
  27493. * @param startValue Start value of the animation curve
  27494. * @param outTangent End tangent of the animation
  27495. * @param endValue End value of the animation curve
  27496. * @param inTangent Start tangent of the animation curve
  27497. * @param gradient Scalar amount to interpolate
  27498. * @returns InterpolatedVector3 value
  27499. */
  27500. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27501. /**
  27502. * Interpolates a Vector2 linearly
  27503. * @param startValue Start value of the animation curve
  27504. * @param endValue End value of the animation curve
  27505. * @param gradient Scalar amount to interpolate
  27506. * @returns Interpolated Vector2 value
  27507. */
  27508. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27509. /**
  27510. * Interpolates a Vector2 cubically
  27511. * @param startValue Start value of the animation curve
  27512. * @param outTangent End tangent of the animation
  27513. * @param endValue End value of the animation curve
  27514. * @param inTangent Start tangent of the animation curve
  27515. * @param gradient Scalar amount to interpolate
  27516. * @returns Interpolated Vector2 value
  27517. */
  27518. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27519. /**
  27520. * Interpolates a size linearly
  27521. * @param startValue Start value of the animation curve
  27522. * @param endValue End value of the animation curve
  27523. * @param gradient Scalar amount to interpolate
  27524. * @returns Interpolated Size value
  27525. */
  27526. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27527. /**
  27528. * Interpolates a Color3 linearly
  27529. * @param startValue Start value of the animation curve
  27530. * @param endValue End value of the animation curve
  27531. * @param gradient Scalar amount to interpolate
  27532. * @returns Interpolated Color3 value
  27533. */
  27534. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27535. /**
  27536. * Interpolates a Color4 linearly
  27537. * @param startValue Start value of the animation curve
  27538. * @param endValue End value of the animation curve
  27539. * @param gradient Scalar amount to interpolate
  27540. * @returns Interpolated Color3 value
  27541. */
  27542. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27543. /**
  27544. * @hidden Internal use only
  27545. */
  27546. _getKeyValue(value: any): any;
  27547. /**
  27548. * @hidden Internal use only
  27549. */
  27550. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27551. /**
  27552. * Defines the function to use to interpolate matrices
  27553. * @param startValue defines the start matrix
  27554. * @param endValue defines the end matrix
  27555. * @param gradient defines the gradient between both matrices
  27556. * @param result defines an optional target matrix where to store the interpolation
  27557. * @returns the interpolated matrix
  27558. */
  27559. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27560. /**
  27561. * Makes a copy of the animation
  27562. * @returns Cloned animation
  27563. */
  27564. clone(): Animation;
  27565. /**
  27566. * Sets the key frames of the animation
  27567. * @param values The animation key frames to set
  27568. */
  27569. setKeys(values: Array<IAnimationKey>): void;
  27570. /**
  27571. * Serializes the animation to an object
  27572. * @returns Serialized object
  27573. */
  27574. serialize(): any;
  27575. /**
  27576. * Float animation type
  27577. */
  27578. static readonly ANIMATIONTYPE_FLOAT: number;
  27579. /**
  27580. * Vector3 animation type
  27581. */
  27582. static readonly ANIMATIONTYPE_VECTOR3: number;
  27583. /**
  27584. * Quaternion animation type
  27585. */
  27586. static readonly ANIMATIONTYPE_QUATERNION: number;
  27587. /**
  27588. * Matrix animation type
  27589. */
  27590. static readonly ANIMATIONTYPE_MATRIX: number;
  27591. /**
  27592. * Color3 animation type
  27593. */
  27594. static readonly ANIMATIONTYPE_COLOR3: number;
  27595. /**
  27596. * Color3 animation type
  27597. */
  27598. static readonly ANIMATIONTYPE_COLOR4: number;
  27599. /**
  27600. * Vector2 animation type
  27601. */
  27602. static readonly ANIMATIONTYPE_VECTOR2: number;
  27603. /**
  27604. * Size animation type
  27605. */
  27606. static readonly ANIMATIONTYPE_SIZE: number;
  27607. /**
  27608. * Relative Loop Mode
  27609. */
  27610. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27611. /**
  27612. * Cycle Loop Mode
  27613. */
  27614. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27615. /**
  27616. * Constant Loop Mode
  27617. */
  27618. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27619. /** @hidden */
  27620. static _UniversalLerp(left: any, right: any, amount: number): any;
  27621. /**
  27622. * Parses an animation object and creates an animation
  27623. * @param parsedAnimation Parsed animation object
  27624. * @returns Animation object
  27625. */
  27626. static Parse(parsedAnimation: any): Animation;
  27627. /**
  27628. * Appends the serialized animations from the source animations
  27629. * @param source Source containing the animations
  27630. * @param destination Target to store the animations
  27631. */
  27632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27633. }
  27634. }
  27635. declare module BABYLON {
  27636. /**
  27637. * Interface containing an array of animations
  27638. */
  27639. export interface IAnimatable {
  27640. /**
  27641. * Array of animations
  27642. */
  27643. animations: Nullable<Array<Animation>>;
  27644. }
  27645. }
  27646. declare module BABYLON {
  27647. /**
  27648. * This represents all the required information to add a fresnel effect on a material:
  27649. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27650. */
  27651. export class FresnelParameters {
  27652. private _isEnabled;
  27653. /**
  27654. * Define if the fresnel effect is enable or not.
  27655. */
  27656. isEnabled: boolean;
  27657. /**
  27658. * Define the color used on edges (grazing angle)
  27659. */
  27660. leftColor: Color3;
  27661. /**
  27662. * Define the color used on center
  27663. */
  27664. rightColor: Color3;
  27665. /**
  27666. * Define bias applied to computed fresnel term
  27667. */
  27668. bias: number;
  27669. /**
  27670. * Defined the power exponent applied to fresnel term
  27671. */
  27672. power: number;
  27673. /**
  27674. * Clones the current fresnel and its valuues
  27675. * @returns a clone fresnel configuration
  27676. */
  27677. clone(): FresnelParameters;
  27678. /**
  27679. * Serializes the current fresnel parameters to a JSON representation.
  27680. * @return the JSON serialization
  27681. */
  27682. serialize(): any;
  27683. /**
  27684. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27685. * @param parsedFresnelParameters Define the JSON representation
  27686. * @returns the parsed parameters
  27687. */
  27688. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27689. }
  27690. }
  27691. declare module BABYLON {
  27692. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27693. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27694. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27695. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27696. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27697. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27698. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27699. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27700. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27701. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27702. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27703. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27704. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27705. /**
  27706. * Decorator used to define property that can be serialized as reference to a camera
  27707. * @param sourceName defines the name of the property to decorate
  27708. */
  27709. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27710. /**
  27711. * Class used to help serialization objects
  27712. */
  27713. export class SerializationHelper {
  27714. /** @hidden */
  27715. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27716. /** @hidden */
  27717. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27718. /** @hidden */
  27719. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27720. /** @hidden */
  27721. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27722. /**
  27723. * Appends the serialized animations from the source animations
  27724. * @param source Source containing the animations
  27725. * @param destination Target to store the animations
  27726. */
  27727. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27728. /**
  27729. * Static function used to serialized a specific entity
  27730. * @param entity defines the entity to serialize
  27731. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27732. * @returns a JSON compatible object representing the serialization of the entity
  27733. */
  27734. static Serialize<T>(entity: T, serializationObject?: any): any;
  27735. /**
  27736. * Creates a new entity from a serialization data object
  27737. * @param creationFunction defines a function used to instanciated the new entity
  27738. * @param source defines the source serialization data
  27739. * @param scene defines the hosting scene
  27740. * @param rootUrl defines the root url for resources
  27741. * @returns a new entity
  27742. */
  27743. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27744. /**
  27745. * Clones an object
  27746. * @param creationFunction defines the function used to instanciate the new object
  27747. * @param source defines the source object
  27748. * @returns the cloned object
  27749. */
  27750. static Clone<T>(creationFunction: () => T, source: T): T;
  27751. /**
  27752. * Instanciates a new object based on a source one (some data will be shared between both object)
  27753. * @param creationFunction defines the function used to instanciate the new object
  27754. * @param source defines the source object
  27755. * @returns the new object
  27756. */
  27757. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27758. }
  27759. }
  27760. declare module BABYLON {
  27761. /**
  27762. * Class used to manipulate GUIDs
  27763. */
  27764. export class GUID {
  27765. /**
  27766. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27767. * Be aware Math.random() could cause collisions, but:
  27768. * "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"
  27769. * @returns a pseudo random id
  27770. */
  27771. static RandomId(): string;
  27772. }
  27773. }
  27774. declare module BABYLON {
  27775. /**
  27776. * Base class of all the textures in babylon.
  27777. * It groups all the common properties the materials, post process, lights... might need
  27778. * in order to make a correct use of the texture.
  27779. */
  27780. export class BaseTexture implements IAnimatable {
  27781. /**
  27782. * Default anisotropic filtering level for the application.
  27783. * It is set to 4 as a good tradeoff between perf and quality.
  27784. */
  27785. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27786. /**
  27787. * Gets or sets the unique id of the texture
  27788. */
  27789. uniqueId: number;
  27790. /**
  27791. * Define the name of the texture.
  27792. */
  27793. name: string;
  27794. /**
  27795. * Gets or sets an object used to store user defined information.
  27796. */
  27797. metadata: any;
  27798. /**
  27799. * For internal use only. Please do not use.
  27800. */
  27801. reservedDataStore: any;
  27802. private _hasAlpha;
  27803. /**
  27804. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27805. */
  27806. hasAlpha: boolean;
  27807. /**
  27808. * Defines if the alpha value should be determined via the rgb values.
  27809. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27810. */
  27811. getAlphaFromRGB: boolean;
  27812. /**
  27813. * Intensity or strength of the texture.
  27814. * It is commonly used by materials to fine tune the intensity of the texture
  27815. */
  27816. level: number;
  27817. /**
  27818. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27819. * This is part of the texture as textures usually maps to one uv set.
  27820. */
  27821. coordinatesIndex: number;
  27822. private _coordinatesMode;
  27823. /**
  27824. * How a texture is mapped.
  27825. *
  27826. * | Value | Type | Description |
  27827. * | ----- | ----------------------------------- | ----------- |
  27828. * | 0 | EXPLICIT_MODE | |
  27829. * | 1 | SPHERICAL_MODE | |
  27830. * | 2 | PLANAR_MODE | |
  27831. * | 3 | CUBIC_MODE | |
  27832. * | 4 | PROJECTION_MODE | |
  27833. * | 5 | SKYBOX_MODE | |
  27834. * | 6 | INVCUBIC_MODE | |
  27835. * | 7 | EQUIRECTANGULAR_MODE | |
  27836. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27837. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27838. */
  27839. coordinatesMode: number;
  27840. /**
  27841. * | Value | Type | Description |
  27842. * | ----- | ------------------ | ----------- |
  27843. * | 0 | CLAMP_ADDRESSMODE | |
  27844. * | 1 | WRAP_ADDRESSMODE | |
  27845. * | 2 | MIRROR_ADDRESSMODE | |
  27846. */
  27847. wrapU: number;
  27848. /**
  27849. * | Value | Type | Description |
  27850. * | ----- | ------------------ | ----------- |
  27851. * | 0 | CLAMP_ADDRESSMODE | |
  27852. * | 1 | WRAP_ADDRESSMODE | |
  27853. * | 2 | MIRROR_ADDRESSMODE | |
  27854. */
  27855. wrapV: number;
  27856. /**
  27857. * | Value | Type | Description |
  27858. * | ----- | ------------------ | ----------- |
  27859. * | 0 | CLAMP_ADDRESSMODE | |
  27860. * | 1 | WRAP_ADDRESSMODE | |
  27861. * | 2 | MIRROR_ADDRESSMODE | |
  27862. */
  27863. wrapR: number;
  27864. /**
  27865. * With compliant hardware and browser (supporting anisotropic filtering)
  27866. * this defines the level of anisotropic filtering in the texture.
  27867. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27868. */
  27869. anisotropicFilteringLevel: number;
  27870. /**
  27871. * Define if the texture is a cube texture or if false a 2d texture.
  27872. */
  27873. isCube: boolean;
  27874. /**
  27875. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27876. */
  27877. is3D: boolean;
  27878. /**
  27879. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27880. * HDR texture are usually stored in linear space.
  27881. * This only impacts the PBR and Background materials
  27882. */
  27883. gammaSpace: boolean;
  27884. /**
  27885. * Gets or sets whether or not the texture contains RGBD data.
  27886. */
  27887. isRGBD: boolean;
  27888. /**
  27889. * Is Z inverted in the texture (useful in a cube texture).
  27890. */
  27891. invertZ: boolean;
  27892. /**
  27893. * Are mip maps generated for this texture or not.
  27894. */
  27895. readonly noMipmap: boolean;
  27896. /**
  27897. * @hidden
  27898. */
  27899. lodLevelInAlpha: boolean;
  27900. /**
  27901. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27902. */
  27903. lodGenerationOffset: number;
  27904. /**
  27905. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27906. */
  27907. lodGenerationScale: number;
  27908. /**
  27909. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27910. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27911. * average roughness values.
  27912. */
  27913. linearSpecularLOD: boolean;
  27914. /**
  27915. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27916. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27917. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27918. */
  27919. irradianceTexture: Nullable<BaseTexture>;
  27920. /**
  27921. * Define if the texture is a render target.
  27922. */
  27923. isRenderTarget: boolean;
  27924. /**
  27925. * Define the unique id of the texture in the scene.
  27926. */
  27927. readonly uid: string;
  27928. /**
  27929. * Return a string representation of the texture.
  27930. * @returns the texture as a string
  27931. */
  27932. toString(): string;
  27933. /**
  27934. * Get the class name of the texture.
  27935. * @returns "BaseTexture"
  27936. */
  27937. getClassName(): string;
  27938. /**
  27939. * Define the list of animation attached to the texture.
  27940. */
  27941. animations: Animation[];
  27942. /**
  27943. * An event triggered when the texture is disposed.
  27944. */
  27945. onDisposeObservable: Observable<BaseTexture>;
  27946. private _onDisposeObserver;
  27947. /**
  27948. * Callback triggered when the texture has been disposed.
  27949. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27950. */
  27951. onDispose: () => void;
  27952. /**
  27953. * Define the current state of the loading sequence when in delayed load mode.
  27954. */
  27955. delayLoadState: number;
  27956. private _scene;
  27957. /** @hidden */
  27958. _texture: Nullable<InternalTexture>;
  27959. private _uid;
  27960. /**
  27961. * Define if the texture is preventinga material to render or not.
  27962. * If not and the texture is not ready, the engine will use a default black texture instead.
  27963. */
  27964. readonly isBlocking: boolean;
  27965. /**
  27966. * Instantiates a new BaseTexture.
  27967. * Base class of all the textures in babylon.
  27968. * It groups all the common properties the materials, post process, lights... might need
  27969. * in order to make a correct use of the texture.
  27970. * @param scene Define the scene the texture blongs to
  27971. */
  27972. constructor(scene: Nullable<Scene>);
  27973. /**
  27974. * Get the scene the texture belongs to.
  27975. * @returns the scene or null if undefined
  27976. */
  27977. getScene(): Nullable<Scene>;
  27978. /**
  27979. * Get the texture transform matrix used to offset tile the texture for istance.
  27980. * @returns the transformation matrix
  27981. */
  27982. getTextureMatrix(): Matrix;
  27983. /**
  27984. * Get the texture reflection matrix used to rotate/transform the reflection.
  27985. * @returns the reflection matrix
  27986. */
  27987. getReflectionTextureMatrix(): Matrix;
  27988. /**
  27989. * Get the underlying lower level texture from Babylon.
  27990. * @returns the insternal texture
  27991. */
  27992. getInternalTexture(): Nullable<InternalTexture>;
  27993. /**
  27994. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27995. * @returns true if ready or not blocking
  27996. */
  27997. isReadyOrNotBlocking(): boolean;
  27998. /**
  27999. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28000. * @returns true if fully ready
  28001. */
  28002. isReady(): boolean;
  28003. private _cachedSize;
  28004. /**
  28005. * Get the size of the texture.
  28006. * @returns the texture size.
  28007. */
  28008. getSize(): ISize;
  28009. /**
  28010. * Get the base size of the texture.
  28011. * It can be different from the size if the texture has been resized for POT for instance
  28012. * @returns the base size
  28013. */
  28014. getBaseSize(): ISize;
  28015. /**
  28016. * Update the sampling mode of the texture.
  28017. * Default is Trilinear mode.
  28018. *
  28019. * | Value | Type | Description |
  28020. * | ----- | ------------------ | ----------- |
  28021. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28022. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28023. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28024. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28025. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28026. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28027. * | 7 | NEAREST_LINEAR | |
  28028. * | 8 | NEAREST_NEAREST | |
  28029. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28030. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28031. * | 11 | LINEAR_LINEAR | |
  28032. * | 12 | LINEAR_NEAREST | |
  28033. *
  28034. * > _mag_: magnification filter (close to the viewer)
  28035. * > _min_: minification filter (far from the viewer)
  28036. * > _mip_: filter used between mip map levels
  28037. *@param samplingMode Define the new sampling mode of the texture
  28038. */
  28039. updateSamplingMode(samplingMode: number): void;
  28040. /**
  28041. * Scales the texture if is `canRescale()`
  28042. * @param ratio the resize factor we want to use to rescale
  28043. */
  28044. scale(ratio: number): void;
  28045. /**
  28046. * Get if the texture can rescale.
  28047. */
  28048. readonly canRescale: boolean;
  28049. /** @hidden */
  28050. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28051. /** @hidden */
  28052. _rebuild(): void;
  28053. /**
  28054. * Triggers the load sequence in delayed load mode.
  28055. */
  28056. delayLoad(): void;
  28057. /**
  28058. * Clones the texture.
  28059. * @returns the cloned texture
  28060. */
  28061. clone(): Nullable<BaseTexture>;
  28062. /**
  28063. * Get the texture underlying type (INT, FLOAT...)
  28064. */
  28065. readonly textureType: number;
  28066. /**
  28067. * Get the texture underlying format (RGB, RGBA...)
  28068. */
  28069. readonly textureFormat: number;
  28070. /**
  28071. * Indicates that textures need to be re-calculated for all materials
  28072. */
  28073. protected _markAllSubMeshesAsTexturesDirty(): void;
  28074. /**
  28075. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28076. * This will returns an RGBA array buffer containing either in values (0-255) or
  28077. * float values (0-1) depending of the underlying buffer type.
  28078. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28079. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28080. * @param buffer defines a user defined buffer to fill with data (can be null)
  28081. * @returns The Array buffer containing the pixels data.
  28082. */
  28083. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28084. /**
  28085. * Release and destroy the underlying lower level texture aka internalTexture.
  28086. */
  28087. releaseInternalTexture(): void;
  28088. /** @hidden */
  28089. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28090. /** @hidden */
  28091. readonly _lodTextureMid: Nullable<BaseTexture>;
  28092. /** @hidden */
  28093. readonly _lodTextureLow: Nullable<BaseTexture>;
  28094. /**
  28095. * Dispose the texture and release its associated resources.
  28096. */
  28097. dispose(): void;
  28098. /**
  28099. * Serialize the texture into a JSON representation that can be parsed later on.
  28100. * @returns the JSON representation of the texture
  28101. */
  28102. serialize(): any;
  28103. /**
  28104. * Helper function to be called back once a list of texture contains only ready textures.
  28105. * @param textures Define the list of textures to wait for
  28106. * @param callback Define the callback triggered once the entire list will be ready
  28107. */
  28108. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28109. }
  28110. }
  28111. declare module BABYLON {
  28112. /**
  28113. * Options to be used when creating an effect.
  28114. */
  28115. export interface IEffectCreationOptions {
  28116. /**
  28117. * Atrributes that will be used in the shader.
  28118. */
  28119. attributes: string[];
  28120. /**
  28121. * Uniform varible names that will be set in the shader.
  28122. */
  28123. uniformsNames: string[];
  28124. /**
  28125. * Uniform buffer varible names that will be set in the shader.
  28126. */
  28127. uniformBuffersNames: string[];
  28128. /**
  28129. * Sampler texture variable names that will be set in the shader.
  28130. */
  28131. samplers: string[];
  28132. /**
  28133. * Define statements that will be set in the shader.
  28134. */
  28135. defines: any;
  28136. /**
  28137. * Possible fallbacks for this effect to improve performance when needed.
  28138. */
  28139. fallbacks: Nullable<IEffectFallbacks>;
  28140. /**
  28141. * Callback that will be called when the shader is compiled.
  28142. */
  28143. onCompiled: Nullable<(effect: Effect) => void>;
  28144. /**
  28145. * Callback that will be called if an error occurs during shader compilation.
  28146. */
  28147. onError: Nullable<(effect: Effect, errors: string) => void>;
  28148. /**
  28149. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28150. */
  28151. indexParameters?: any;
  28152. /**
  28153. * Max number of lights that can be used in the shader.
  28154. */
  28155. maxSimultaneousLights?: number;
  28156. /**
  28157. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28158. */
  28159. transformFeedbackVaryings?: Nullable<string[]>;
  28160. }
  28161. /**
  28162. * Effect containing vertex and fragment shader that can be executed on an object.
  28163. */
  28164. export class Effect implements IDisposable {
  28165. /**
  28166. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28167. */
  28168. static ShadersRepository: string;
  28169. /**
  28170. * Name of the effect.
  28171. */
  28172. name: any;
  28173. /**
  28174. * String container all the define statements that should be set on the shader.
  28175. */
  28176. defines: string;
  28177. /**
  28178. * Callback that will be called when the shader is compiled.
  28179. */
  28180. onCompiled: Nullable<(effect: Effect) => void>;
  28181. /**
  28182. * Callback that will be called if an error occurs during shader compilation.
  28183. */
  28184. onError: Nullable<(effect: Effect, errors: string) => void>;
  28185. /**
  28186. * Callback that will be called when effect is bound.
  28187. */
  28188. onBind: Nullable<(effect: Effect) => void>;
  28189. /**
  28190. * Unique ID of the effect.
  28191. */
  28192. uniqueId: number;
  28193. /**
  28194. * Observable that will be called when the shader is compiled.
  28195. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28196. */
  28197. onCompileObservable: Observable<Effect>;
  28198. /**
  28199. * Observable that will be called if an error occurs during shader compilation.
  28200. */
  28201. onErrorObservable: Observable<Effect>;
  28202. /** @hidden */
  28203. _onBindObservable: Nullable<Observable<Effect>>;
  28204. /**
  28205. * Observable that will be called when effect is bound.
  28206. */
  28207. readonly onBindObservable: Observable<Effect>;
  28208. /** @hidden */
  28209. _bonesComputationForcedToCPU: boolean;
  28210. private static _uniqueIdSeed;
  28211. private _engine;
  28212. private _uniformBuffersNames;
  28213. private _uniformsNames;
  28214. private _samplerList;
  28215. private _samplers;
  28216. private _isReady;
  28217. private _compilationError;
  28218. private _allFallbacksProcessed;
  28219. private _attributesNames;
  28220. private _attributes;
  28221. private _uniforms;
  28222. /**
  28223. * Key for the effect.
  28224. * @hidden
  28225. */
  28226. _key: string;
  28227. private _indexParameters;
  28228. private _fallbacks;
  28229. private _vertexSourceCode;
  28230. private _fragmentSourceCode;
  28231. private _vertexSourceCodeOverride;
  28232. private _fragmentSourceCodeOverride;
  28233. private _transformFeedbackVaryings;
  28234. /**
  28235. * Compiled shader to webGL program.
  28236. * @hidden
  28237. */
  28238. _pipelineContext: Nullable<IPipelineContext>;
  28239. private _valueCache;
  28240. private static _baseCache;
  28241. /**
  28242. * Instantiates an effect.
  28243. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28244. * @param baseName Name of the effect.
  28245. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28246. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28247. * @param samplers List of sampler variables that will be passed to the shader.
  28248. * @param engine Engine to be used to render the effect
  28249. * @param defines Define statements to be added to the shader.
  28250. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28251. * @param onCompiled Callback that will be called when the shader is compiled.
  28252. * @param onError Callback that will be called if an error occurs during shader compilation.
  28253. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28254. */
  28255. 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);
  28256. private _useFinalCode;
  28257. /**
  28258. * Unique key for this effect
  28259. */
  28260. readonly key: string;
  28261. /**
  28262. * If the effect has been compiled and prepared.
  28263. * @returns if the effect is compiled and prepared.
  28264. */
  28265. isReady(): boolean;
  28266. private _isReadyInternal;
  28267. /**
  28268. * The engine the effect was initialized with.
  28269. * @returns the engine.
  28270. */
  28271. getEngine(): Engine;
  28272. /**
  28273. * The pipeline context for this effect
  28274. * @returns the associated pipeline context
  28275. */
  28276. getPipelineContext(): Nullable<IPipelineContext>;
  28277. /**
  28278. * The set of names of attribute variables for the shader.
  28279. * @returns An array of attribute names.
  28280. */
  28281. getAttributesNames(): string[];
  28282. /**
  28283. * Returns the attribute at the given index.
  28284. * @param index The index of the attribute.
  28285. * @returns The location of the attribute.
  28286. */
  28287. getAttributeLocation(index: number): number;
  28288. /**
  28289. * Returns the attribute based on the name of the variable.
  28290. * @param name of the attribute to look up.
  28291. * @returns the attribute location.
  28292. */
  28293. getAttributeLocationByName(name: string): number;
  28294. /**
  28295. * The number of attributes.
  28296. * @returns the numnber of attributes.
  28297. */
  28298. getAttributesCount(): number;
  28299. /**
  28300. * Gets the index of a uniform variable.
  28301. * @param uniformName of the uniform to look up.
  28302. * @returns the index.
  28303. */
  28304. getUniformIndex(uniformName: string): number;
  28305. /**
  28306. * Returns the attribute based on the name of the variable.
  28307. * @param uniformName of the uniform to look up.
  28308. * @returns the location of the uniform.
  28309. */
  28310. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28311. /**
  28312. * Returns an array of sampler variable names
  28313. * @returns The array of sampler variable neames.
  28314. */
  28315. getSamplers(): string[];
  28316. /**
  28317. * The error from the last compilation.
  28318. * @returns the error string.
  28319. */
  28320. getCompilationError(): string;
  28321. /**
  28322. * Gets a boolean indicating that all fallbacks were used during compilation
  28323. * @returns true if all fallbacks were used
  28324. */
  28325. allFallbacksProcessed(): boolean;
  28326. /**
  28327. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28328. * @param func The callback to be used.
  28329. */
  28330. executeWhenCompiled(func: (effect: Effect) => void): void;
  28331. private _checkIsReady;
  28332. private _loadShader;
  28333. /**
  28334. * Recompiles the webGL program
  28335. * @param vertexSourceCode The source code for the vertex shader.
  28336. * @param fragmentSourceCode The source code for the fragment shader.
  28337. * @param onCompiled Callback called when completed.
  28338. * @param onError Callback called on error.
  28339. * @hidden
  28340. */
  28341. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28342. /**
  28343. * Prepares the effect
  28344. * @hidden
  28345. */
  28346. _prepareEffect(): void;
  28347. private _processCompilationErrors;
  28348. /**
  28349. * Checks if the effect is supported. (Must be called after compilation)
  28350. */
  28351. readonly isSupported: boolean;
  28352. /**
  28353. * Binds a texture to the engine to be used as output of the shader.
  28354. * @param channel Name of the output variable.
  28355. * @param texture Texture to bind.
  28356. * @hidden
  28357. */
  28358. _bindTexture(channel: string, texture: InternalTexture): void;
  28359. /**
  28360. * Sets a texture on the engine to be used in the shader.
  28361. * @param channel Name of the sampler variable.
  28362. * @param texture Texture to set.
  28363. */
  28364. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28365. /**
  28366. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28367. * @param channel Name of the sampler variable.
  28368. * @param texture Texture to set.
  28369. */
  28370. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28371. /**
  28372. * Sets an array of textures on the engine to be used in the shader.
  28373. * @param channel Name of the variable.
  28374. * @param textures Textures to set.
  28375. */
  28376. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28377. /**
  28378. * 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)
  28379. * @param channel Name of the sampler variable.
  28380. * @param postProcess Post process to get the input texture from.
  28381. */
  28382. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28383. /**
  28384. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28385. * 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)
  28386. * @param channel Name of the sampler variable.
  28387. * @param postProcess Post process to get the output texture from.
  28388. */
  28389. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28390. /** @hidden */
  28391. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28392. /** @hidden */
  28393. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28394. /** @hidden */
  28395. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28396. /** @hidden */
  28397. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28398. /**
  28399. * Binds a buffer to a uniform.
  28400. * @param buffer Buffer to bind.
  28401. * @param name Name of the uniform variable to bind to.
  28402. */
  28403. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28404. /**
  28405. * Binds block to a uniform.
  28406. * @param blockName Name of the block to bind.
  28407. * @param index Index to bind.
  28408. */
  28409. bindUniformBlock(blockName: string, index: number): void;
  28410. /**
  28411. * Sets an interger value on a uniform variable.
  28412. * @param uniformName Name of the variable.
  28413. * @param value Value to be set.
  28414. * @returns this effect.
  28415. */
  28416. setInt(uniformName: string, value: number): Effect;
  28417. /**
  28418. * Sets an int array on a uniform variable.
  28419. * @param uniformName Name of the variable.
  28420. * @param array array to be set.
  28421. * @returns this effect.
  28422. */
  28423. setIntArray(uniformName: string, array: Int32Array): Effect;
  28424. /**
  28425. * 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)
  28426. * @param uniformName Name of the variable.
  28427. * @param array array to be set.
  28428. * @returns this effect.
  28429. */
  28430. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28431. /**
  28432. * 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)
  28433. * @param uniformName Name of the variable.
  28434. * @param array array to be set.
  28435. * @returns this effect.
  28436. */
  28437. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28438. /**
  28439. * 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)
  28440. * @param uniformName Name of the variable.
  28441. * @param array array to be set.
  28442. * @returns this effect.
  28443. */
  28444. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28445. /**
  28446. * Sets an float array on a uniform variable.
  28447. * @param uniformName Name of the variable.
  28448. * @param array array to be set.
  28449. * @returns this effect.
  28450. */
  28451. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28452. /**
  28453. * 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)
  28454. * @param uniformName Name of the variable.
  28455. * @param array array to be set.
  28456. * @returns this effect.
  28457. */
  28458. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28459. /**
  28460. * 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)
  28461. * @param uniformName Name of the variable.
  28462. * @param array array to be set.
  28463. * @returns this effect.
  28464. */
  28465. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28466. /**
  28467. * 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)
  28468. * @param uniformName Name of the variable.
  28469. * @param array array to be set.
  28470. * @returns this effect.
  28471. */
  28472. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28473. /**
  28474. * Sets an array on a uniform variable.
  28475. * @param uniformName Name of the variable.
  28476. * @param array array to be set.
  28477. * @returns this effect.
  28478. */
  28479. setArray(uniformName: string, array: number[]): Effect;
  28480. /**
  28481. * 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)
  28482. * @param uniformName Name of the variable.
  28483. * @param array array to be set.
  28484. * @returns this effect.
  28485. */
  28486. setArray2(uniformName: string, array: number[]): Effect;
  28487. /**
  28488. * 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)
  28489. * @param uniformName Name of the variable.
  28490. * @param array array to be set.
  28491. * @returns this effect.
  28492. */
  28493. setArray3(uniformName: string, array: number[]): Effect;
  28494. /**
  28495. * 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)
  28496. * @param uniformName Name of the variable.
  28497. * @param array array to be set.
  28498. * @returns this effect.
  28499. */
  28500. setArray4(uniformName: string, array: number[]): Effect;
  28501. /**
  28502. * Sets matrices on a uniform variable.
  28503. * @param uniformName Name of the variable.
  28504. * @param matrices matrices to be set.
  28505. * @returns this effect.
  28506. */
  28507. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28508. /**
  28509. * Sets matrix on a uniform variable.
  28510. * @param uniformName Name of the variable.
  28511. * @param matrix matrix to be set.
  28512. * @returns this effect.
  28513. */
  28514. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28515. /**
  28516. * 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)
  28517. * @param uniformName Name of the variable.
  28518. * @param matrix matrix to be set.
  28519. * @returns this effect.
  28520. */
  28521. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28522. /**
  28523. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28524. * @param uniformName Name of the variable.
  28525. * @param matrix matrix to be set.
  28526. * @returns this effect.
  28527. */
  28528. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28529. /**
  28530. * Sets a float on a uniform variable.
  28531. * @param uniformName Name of the variable.
  28532. * @param value value to be set.
  28533. * @returns this effect.
  28534. */
  28535. setFloat(uniformName: string, value: number): Effect;
  28536. /**
  28537. * Sets a boolean on a uniform variable.
  28538. * @param uniformName Name of the variable.
  28539. * @param bool value to be set.
  28540. * @returns this effect.
  28541. */
  28542. setBool(uniformName: string, bool: boolean): Effect;
  28543. /**
  28544. * Sets a Vector2 on a uniform variable.
  28545. * @param uniformName Name of the variable.
  28546. * @param vector2 vector2 to be set.
  28547. * @returns this effect.
  28548. */
  28549. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28550. /**
  28551. * Sets a float2 on a uniform variable.
  28552. * @param uniformName Name of the variable.
  28553. * @param x First float in float2.
  28554. * @param y Second float in float2.
  28555. * @returns this effect.
  28556. */
  28557. setFloat2(uniformName: string, x: number, y: number): Effect;
  28558. /**
  28559. * Sets a Vector3 on a uniform variable.
  28560. * @param uniformName Name of the variable.
  28561. * @param vector3 Value to be set.
  28562. * @returns this effect.
  28563. */
  28564. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28565. /**
  28566. * Sets a float3 on a uniform variable.
  28567. * @param uniformName Name of the variable.
  28568. * @param x First float in float3.
  28569. * @param y Second float in float3.
  28570. * @param z Third float in float3.
  28571. * @returns this effect.
  28572. */
  28573. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28574. /**
  28575. * Sets a Vector4 on a uniform variable.
  28576. * @param uniformName Name of the variable.
  28577. * @param vector4 Value to be set.
  28578. * @returns this effect.
  28579. */
  28580. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28581. /**
  28582. * Sets a float4 on a uniform variable.
  28583. * @param uniformName Name of the variable.
  28584. * @param x First float in float4.
  28585. * @param y Second float in float4.
  28586. * @param z Third float in float4.
  28587. * @param w Fourth float in float4.
  28588. * @returns this effect.
  28589. */
  28590. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28591. /**
  28592. * Sets a Color3 on a uniform variable.
  28593. * @param uniformName Name of the variable.
  28594. * @param color3 Value to be set.
  28595. * @returns this effect.
  28596. */
  28597. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28598. /**
  28599. * Sets a Color4 on a uniform variable.
  28600. * @param uniformName Name of the variable.
  28601. * @param color3 Value to be set.
  28602. * @param alpha Alpha value to be set.
  28603. * @returns this effect.
  28604. */
  28605. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28606. /**
  28607. * Sets a Color4 on a uniform variable
  28608. * @param uniformName defines the name of the variable
  28609. * @param color4 defines the value to be set
  28610. * @returns this effect.
  28611. */
  28612. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28613. /** Release all associated resources */
  28614. dispose(): void;
  28615. /**
  28616. * This function will add a new shader to the shader store
  28617. * @param name the name of the shader
  28618. * @param pixelShader optional pixel shader content
  28619. * @param vertexShader optional vertex shader content
  28620. */
  28621. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28622. /**
  28623. * Store of each shader (The can be looked up using effect.key)
  28624. */
  28625. static ShadersStore: {
  28626. [key: string]: string;
  28627. };
  28628. /**
  28629. * Store of each included file for a shader (The can be looked up using effect.key)
  28630. */
  28631. static IncludesShadersStore: {
  28632. [key: string]: string;
  28633. };
  28634. /**
  28635. * Resets the cache of effects.
  28636. */
  28637. static ResetCache(): void;
  28638. }
  28639. }
  28640. declare module BABYLON {
  28641. /**
  28642. * Interface used to describe the capabilities of the engine relatively to the current browser
  28643. */
  28644. export interface EngineCapabilities {
  28645. /** Maximum textures units per fragment shader */
  28646. maxTexturesImageUnits: number;
  28647. /** Maximum texture units per vertex shader */
  28648. maxVertexTextureImageUnits: number;
  28649. /** Maximum textures units in the entire pipeline */
  28650. maxCombinedTexturesImageUnits: number;
  28651. /** Maximum texture size */
  28652. maxTextureSize: number;
  28653. /** Maximum cube texture size */
  28654. maxCubemapTextureSize: number;
  28655. /** Maximum render texture size */
  28656. maxRenderTextureSize: number;
  28657. /** Maximum number of vertex attributes */
  28658. maxVertexAttribs: number;
  28659. /** Maximum number of varyings */
  28660. maxVaryingVectors: number;
  28661. /** Maximum number of uniforms per vertex shader */
  28662. maxVertexUniformVectors: number;
  28663. /** Maximum number of uniforms per fragment shader */
  28664. maxFragmentUniformVectors: number;
  28665. /** Defines if standard derivates (dx/dy) are supported */
  28666. standardDerivatives: boolean;
  28667. /** Defines if s3tc texture compression is supported */
  28668. s3tc?: WEBGL_compressed_texture_s3tc;
  28669. /** Defines if pvrtc texture compression is supported */
  28670. pvrtc: any;
  28671. /** Defines if etc1 texture compression is supported */
  28672. etc1: any;
  28673. /** Defines if etc2 texture compression is supported */
  28674. etc2: any;
  28675. /** Defines if astc texture compression is supported */
  28676. astc: any;
  28677. /** Defines if float textures are supported */
  28678. textureFloat: boolean;
  28679. /** Defines if vertex array objects are supported */
  28680. vertexArrayObject: boolean;
  28681. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28682. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28683. /** Gets the maximum level of anisotropy supported */
  28684. maxAnisotropy: number;
  28685. /** Defines if instancing is supported */
  28686. instancedArrays: boolean;
  28687. /** Defines if 32 bits indices are supported */
  28688. uintIndices: boolean;
  28689. /** Defines if high precision shaders are supported */
  28690. highPrecisionShaderSupported: boolean;
  28691. /** Defines if depth reading in the fragment shader is supported */
  28692. fragmentDepthSupported: boolean;
  28693. /** Defines if float texture linear filtering is supported*/
  28694. textureFloatLinearFiltering: boolean;
  28695. /** Defines if rendering to float textures is supported */
  28696. textureFloatRender: boolean;
  28697. /** Defines if half float textures are supported*/
  28698. textureHalfFloat: boolean;
  28699. /** Defines if half float texture linear filtering is supported*/
  28700. textureHalfFloatLinearFiltering: boolean;
  28701. /** Defines if rendering to half float textures is supported */
  28702. textureHalfFloatRender: boolean;
  28703. /** Defines if textureLOD shader command is supported */
  28704. textureLOD: boolean;
  28705. /** Defines if draw buffers extension is supported */
  28706. drawBuffersExtension: boolean;
  28707. /** Defines if depth textures are supported */
  28708. depthTextureExtension: boolean;
  28709. /** Defines if float color buffer are supported */
  28710. colorBufferFloat: boolean;
  28711. /** Gets disjoint timer query extension (null if not supported) */
  28712. timerQuery?: EXT_disjoint_timer_query;
  28713. /** Defines if timestamp can be used with timer query */
  28714. canUseTimestampForTimerQuery: boolean;
  28715. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28716. multiview?: any;
  28717. /** Function used to let the system compiles shaders in background */
  28718. parallelShaderCompile?: {
  28719. COMPLETION_STATUS_KHR: number;
  28720. };
  28721. /** Max number of texture samples for MSAA */
  28722. maxMSAASamples: number;
  28723. /** Defines if the blend min max extension is supported */
  28724. blendMinMax: boolean;
  28725. }
  28726. }
  28727. declare module BABYLON {
  28728. /**
  28729. * @hidden
  28730. **/
  28731. export class DepthCullingState {
  28732. private _isDepthTestDirty;
  28733. private _isDepthMaskDirty;
  28734. private _isDepthFuncDirty;
  28735. private _isCullFaceDirty;
  28736. private _isCullDirty;
  28737. private _isZOffsetDirty;
  28738. private _isFrontFaceDirty;
  28739. private _depthTest;
  28740. private _depthMask;
  28741. private _depthFunc;
  28742. private _cull;
  28743. private _cullFace;
  28744. private _zOffset;
  28745. private _frontFace;
  28746. /**
  28747. * Initializes the state.
  28748. */
  28749. constructor();
  28750. readonly isDirty: boolean;
  28751. zOffset: number;
  28752. cullFace: Nullable<number>;
  28753. cull: Nullable<boolean>;
  28754. depthFunc: Nullable<number>;
  28755. depthMask: boolean;
  28756. depthTest: boolean;
  28757. frontFace: Nullable<number>;
  28758. reset(): void;
  28759. apply(gl: WebGLRenderingContext): void;
  28760. }
  28761. }
  28762. declare module BABYLON {
  28763. /**
  28764. * @hidden
  28765. **/
  28766. export class StencilState {
  28767. /** 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 */
  28768. static readonly ALWAYS: number;
  28769. /** Passed to stencilOperation to specify that stencil value must be kept */
  28770. static readonly KEEP: number;
  28771. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28772. static readonly REPLACE: number;
  28773. private _isStencilTestDirty;
  28774. private _isStencilMaskDirty;
  28775. private _isStencilFuncDirty;
  28776. private _isStencilOpDirty;
  28777. private _stencilTest;
  28778. private _stencilMask;
  28779. private _stencilFunc;
  28780. private _stencilFuncRef;
  28781. private _stencilFuncMask;
  28782. private _stencilOpStencilFail;
  28783. private _stencilOpDepthFail;
  28784. private _stencilOpStencilDepthPass;
  28785. readonly isDirty: boolean;
  28786. stencilFunc: number;
  28787. stencilFuncRef: number;
  28788. stencilFuncMask: number;
  28789. stencilOpStencilFail: number;
  28790. stencilOpDepthFail: number;
  28791. stencilOpStencilDepthPass: number;
  28792. stencilMask: number;
  28793. stencilTest: boolean;
  28794. constructor();
  28795. reset(): void;
  28796. apply(gl: WebGLRenderingContext): void;
  28797. }
  28798. }
  28799. declare module BABYLON {
  28800. /**
  28801. * @hidden
  28802. **/
  28803. export class AlphaState {
  28804. private _isAlphaBlendDirty;
  28805. private _isBlendFunctionParametersDirty;
  28806. private _isBlendEquationParametersDirty;
  28807. private _isBlendConstantsDirty;
  28808. private _alphaBlend;
  28809. private _blendFunctionParameters;
  28810. private _blendEquationParameters;
  28811. private _blendConstants;
  28812. /**
  28813. * Initializes the state.
  28814. */
  28815. constructor();
  28816. readonly isDirty: boolean;
  28817. alphaBlend: boolean;
  28818. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28819. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28820. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28821. reset(): void;
  28822. apply(gl: WebGLRenderingContext): void;
  28823. }
  28824. }
  28825. declare module BABYLON {
  28826. /** @hidden */
  28827. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28828. attributeProcessor(attribute: string): string;
  28829. varyingProcessor(varying: string, isFragment: boolean): string;
  28830. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28831. }
  28832. }
  28833. declare module BABYLON {
  28834. /**
  28835. * Interface for attribute information associated with buffer instanciation
  28836. */
  28837. export class InstancingAttributeInfo {
  28838. /**
  28839. * Index/offset of the attribute in the vertex shader
  28840. */
  28841. index: number;
  28842. /**
  28843. * size of the attribute, 1, 2, 3 or 4
  28844. */
  28845. attributeSize: number;
  28846. /**
  28847. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28848. * default is FLOAT
  28849. */
  28850. attributeType: number;
  28851. /**
  28852. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28853. */
  28854. normalized: boolean;
  28855. /**
  28856. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28857. */
  28858. offset: number;
  28859. /**
  28860. * Name of the GLSL attribute, for debugging purpose only
  28861. */
  28862. attributeName: string;
  28863. }
  28864. }
  28865. declare module BABYLON {
  28866. interface ThinEngine {
  28867. /**
  28868. * Update a video texture
  28869. * @param texture defines the texture to update
  28870. * @param video defines the video element to use
  28871. * @param invertY defines if data must be stored with Y axis inverted
  28872. */
  28873. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28874. }
  28875. }
  28876. declare module BABYLON {
  28877. /**
  28878. * Settings for finer control over video usage
  28879. */
  28880. export interface VideoTextureSettings {
  28881. /**
  28882. * Applies `autoplay` to video, if specified
  28883. */
  28884. autoPlay?: boolean;
  28885. /**
  28886. * Applies `loop` to video, if specified
  28887. */
  28888. loop?: boolean;
  28889. /**
  28890. * Automatically updates internal texture from video at every frame in the render loop
  28891. */
  28892. autoUpdateTexture: boolean;
  28893. /**
  28894. * Image src displayed during the video loading or until the user interacts with the video.
  28895. */
  28896. poster?: string;
  28897. }
  28898. /**
  28899. * If you want to display a video in your scene, this is the special texture for that.
  28900. * This special texture works similar to other textures, with the exception of a few parameters.
  28901. * @see https://doc.babylonjs.com/how_to/video_texture
  28902. */
  28903. export class VideoTexture extends Texture {
  28904. /**
  28905. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28906. */
  28907. readonly autoUpdateTexture: boolean;
  28908. /**
  28909. * The video instance used by the texture internally
  28910. */
  28911. readonly video: HTMLVideoElement;
  28912. private _onUserActionRequestedObservable;
  28913. /**
  28914. * Event triggerd when a dom action is required by the user to play the video.
  28915. * This happens due to recent changes in browser policies preventing video to auto start.
  28916. */
  28917. readonly onUserActionRequestedObservable: Observable<Texture>;
  28918. private _generateMipMaps;
  28919. private _engine;
  28920. private _stillImageCaptured;
  28921. private _displayingPosterTexture;
  28922. private _settings;
  28923. private _createInternalTextureOnEvent;
  28924. private _frameId;
  28925. /**
  28926. * Creates a video texture.
  28927. * If you want to display a video in your scene, this is the special texture for that.
  28928. * This special texture works similar to other textures, with the exception of a few parameters.
  28929. * @see https://doc.babylonjs.com/how_to/video_texture
  28930. * @param name optional name, will detect from video source, if not defined
  28931. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28932. * @param scene is obviously the current scene.
  28933. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28934. * @param invertY is false by default but can be used to invert video on Y axis
  28935. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28936. * @param settings allows finer control over video usage
  28937. */
  28938. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28939. private _getName;
  28940. private _getVideo;
  28941. private _createInternalTexture;
  28942. private reset;
  28943. /**
  28944. * @hidden Internal method to initiate `update`.
  28945. */
  28946. _rebuild(): void;
  28947. /**
  28948. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28949. */
  28950. update(): void;
  28951. /**
  28952. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28953. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28954. */
  28955. updateTexture(isVisible: boolean): void;
  28956. protected _updateInternalTexture: () => void;
  28957. /**
  28958. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28959. * @param url New url.
  28960. */
  28961. updateURL(url: string): void;
  28962. /**
  28963. * Dispose the texture and release its associated resources.
  28964. */
  28965. dispose(): void;
  28966. /**
  28967. * Creates a video texture straight from a stream.
  28968. * @param scene Define the scene the texture should be created in
  28969. * @param stream Define the stream the texture should be created from
  28970. * @returns The created video texture as a promise
  28971. */
  28972. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28973. /**
  28974. * Creates a video texture straight from your WebCam video feed.
  28975. * @param scene Define the scene the texture should be created in
  28976. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28977. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28978. * @returns The created video texture as a promise
  28979. */
  28980. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28981. minWidth: number;
  28982. maxWidth: number;
  28983. minHeight: number;
  28984. maxHeight: number;
  28985. deviceId: string;
  28986. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28987. /**
  28988. * Creates a video texture straight from your WebCam video feed.
  28989. * @param scene Define the scene the texture should be created in
  28990. * @param onReady Define a callback to triggered once the texture will be ready
  28991. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28992. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28993. */
  28994. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28995. minWidth: number;
  28996. maxWidth: number;
  28997. minHeight: number;
  28998. maxHeight: number;
  28999. deviceId: string;
  29000. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29001. }
  29002. }
  29003. declare module BABYLON {
  29004. /**
  29005. * Defines the interface used by objects working like Scene
  29006. * @hidden
  29007. */
  29008. interface ISceneLike {
  29009. _addPendingData(data: any): void;
  29010. _removePendingData(data: any): void;
  29011. offlineProvider: IOfflineProvider;
  29012. }
  29013. /** Interface defining initialization parameters for Engine class */
  29014. export interface EngineOptions extends WebGLContextAttributes {
  29015. /**
  29016. * Defines if the engine should no exceed a specified device ratio
  29017. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29018. */
  29019. limitDeviceRatio?: number;
  29020. /**
  29021. * Defines if webvr should be enabled automatically
  29022. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29023. */
  29024. autoEnableWebVR?: boolean;
  29025. /**
  29026. * Defines if webgl2 should be turned off even if supported
  29027. * @see http://doc.babylonjs.com/features/webgl2
  29028. */
  29029. disableWebGL2Support?: boolean;
  29030. /**
  29031. * Defines if webaudio should be initialized as well
  29032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29033. */
  29034. audioEngine?: boolean;
  29035. /**
  29036. * Defines if animations should run using a deterministic lock step
  29037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29038. */
  29039. deterministicLockstep?: boolean;
  29040. /** Defines the maximum steps to use with deterministic lock step mode */
  29041. lockstepMaxSteps?: number;
  29042. /**
  29043. * Defines that engine should ignore context lost events
  29044. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29045. */
  29046. doNotHandleContextLost?: boolean;
  29047. /**
  29048. * Defines that engine should ignore modifying touch action attribute and style
  29049. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29050. */
  29051. doNotHandleTouchAction?: boolean;
  29052. /**
  29053. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29054. */
  29055. useHighPrecisionFloats?: boolean;
  29056. }
  29057. /**
  29058. * The base engine class (root of all engines)
  29059. */
  29060. export class ThinEngine {
  29061. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29062. static ExceptionList: ({
  29063. key: string;
  29064. capture: string;
  29065. captureConstraint: number;
  29066. targets: string[];
  29067. } | {
  29068. key: string;
  29069. capture: null;
  29070. captureConstraint: null;
  29071. targets: string[];
  29072. })[];
  29073. /** @hidden */
  29074. static _TextureLoaders: IInternalTextureLoader[];
  29075. /**
  29076. * Returns the current npm package of the sdk
  29077. */
  29078. static readonly NpmPackage: string;
  29079. /**
  29080. * Returns the current version of the framework
  29081. */
  29082. static readonly Version: string;
  29083. /**
  29084. * Returns a string describing the current engine
  29085. */
  29086. readonly description: string;
  29087. /**
  29088. * Gets or sets the epsilon value used by collision engine
  29089. */
  29090. static CollisionsEpsilon: number;
  29091. /**
  29092. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29093. */
  29094. static ShadersRepository: string;
  29095. /** @hidden */
  29096. _shaderProcessor: IShaderProcessor;
  29097. /**
  29098. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29099. */
  29100. forcePOTTextures: boolean;
  29101. /**
  29102. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29103. */
  29104. isFullscreen: boolean;
  29105. /**
  29106. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29107. */
  29108. cullBackFaces: boolean;
  29109. /**
  29110. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29111. */
  29112. renderEvenInBackground: boolean;
  29113. /**
  29114. * Gets or sets a boolean indicating that cache can be kept between frames
  29115. */
  29116. preventCacheWipeBetweenFrames: boolean;
  29117. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29118. validateShaderPrograms: boolean;
  29119. /**
  29120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29121. */
  29122. disableUniformBuffers: boolean;
  29123. /** @hidden */
  29124. _uniformBuffers: UniformBuffer[];
  29125. /**
  29126. * Gets a boolean indicating that the engine supports uniform buffers
  29127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29128. */
  29129. readonly supportsUniformBuffers: boolean;
  29130. /** @hidden */
  29131. _gl: WebGLRenderingContext;
  29132. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29133. protected _windowIsBackground: boolean;
  29134. protected _webGLVersion: number;
  29135. protected _highPrecisionShadersAllowed: boolean;
  29136. /** @hidden */
  29137. readonly _shouldUseHighPrecisionShader: boolean;
  29138. /**
  29139. * Gets a boolean indicating that only power of 2 textures are supported
  29140. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29141. */
  29142. readonly needPOTTextures: boolean;
  29143. /** @hidden */
  29144. _badOS: boolean;
  29145. /** @hidden */
  29146. _badDesktopOS: boolean;
  29147. private _hardwareScalingLevel;
  29148. /** @hidden */
  29149. _caps: EngineCapabilities;
  29150. private _isStencilEnable;
  29151. protected _colorWrite: boolean;
  29152. private _glVersion;
  29153. private _glRenderer;
  29154. private _glVendor;
  29155. /** @hidden */
  29156. _videoTextureSupported: boolean;
  29157. protected _renderingQueueLaunched: boolean;
  29158. protected _activeRenderLoops: (() => void)[];
  29159. /**
  29160. * Observable signaled when a context lost event is raised
  29161. */
  29162. onContextLostObservable: Observable<ThinEngine>;
  29163. /**
  29164. * Observable signaled when a context restored event is raised
  29165. */
  29166. onContextRestoredObservable: Observable<ThinEngine>;
  29167. private _onContextLost;
  29168. private _onContextRestored;
  29169. protected _contextWasLost: boolean;
  29170. /** @hidden */
  29171. _doNotHandleContextLost: boolean;
  29172. /**
  29173. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29175. */
  29176. doNotHandleContextLost: boolean;
  29177. /**
  29178. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29179. */
  29180. disableVertexArrayObjects: boolean;
  29181. /** @hidden */
  29182. protected _depthCullingState: DepthCullingState;
  29183. /** @hidden */
  29184. protected _stencilState: StencilState;
  29185. /** @hidden */
  29186. protected _alphaState: AlphaState;
  29187. /** @hidden */
  29188. _internalTexturesCache: InternalTexture[];
  29189. /** @hidden */
  29190. protected _activeChannel: number;
  29191. private _currentTextureChannel;
  29192. /** @hidden */
  29193. protected _boundTexturesCache: {
  29194. [key: string]: Nullable<InternalTexture>;
  29195. };
  29196. /** @hidden */
  29197. protected _currentEffect: Nullable<Effect>;
  29198. /** @hidden */
  29199. protected _currentProgram: Nullable<WebGLProgram>;
  29200. private _compiledEffects;
  29201. private _vertexAttribArraysEnabled;
  29202. /** @hidden */
  29203. protected _cachedViewport: Nullable<IViewportLike>;
  29204. private _cachedVertexArrayObject;
  29205. /** @hidden */
  29206. protected _cachedVertexBuffers: any;
  29207. /** @hidden */
  29208. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29209. /** @hidden */
  29210. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29211. /** @hidden */
  29212. _currentRenderTarget: Nullable<InternalTexture>;
  29213. private _uintIndicesCurrentlySet;
  29214. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29215. /** @hidden */
  29216. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29217. private _currentBufferPointers;
  29218. private _currentInstanceLocations;
  29219. private _currentInstanceBuffers;
  29220. private _textureUnits;
  29221. /** @hidden */
  29222. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29223. /** @hidden */
  29224. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29225. /** @hidden */
  29226. _bindedRenderFunction: any;
  29227. private _vaoRecordInProgress;
  29228. private _mustWipeVertexAttributes;
  29229. private _emptyTexture;
  29230. private _emptyCubeTexture;
  29231. private _emptyTexture3D;
  29232. /** @hidden */
  29233. _frameHandler: number;
  29234. private _nextFreeTextureSlots;
  29235. private _maxSimultaneousTextures;
  29236. private _activeRequests;
  29237. protected _texturesSupported: string[];
  29238. /** @hidden */
  29239. _textureFormatInUse: Nullable<string>;
  29240. protected readonly _supportsHardwareTextureRescaling: boolean;
  29241. /**
  29242. * Gets the list of texture formats supported
  29243. */
  29244. readonly texturesSupported: Array<string>;
  29245. /**
  29246. * Gets the list of texture formats in use
  29247. */
  29248. readonly textureFormatInUse: Nullable<string>;
  29249. /**
  29250. * Gets the current viewport
  29251. */
  29252. readonly currentViewport: Nullable<IViewportLike>;
  29253. /**
  29254. * Gets the default empty texture
  29255. */
  29256. readonly emptyTexture: InternalTexture;
  29257. /**
  29258. * Gets the default empty 3D texture
  29259. */
  29260. readonly emptyTexture3D: InternalTexture;
  29261. /**
  29262. * Gets the default empty cube texture
  29263. */
  29264. readonly emptyCubeTexture: InternalTexture;
  29265. /**
  29266. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29267. */
  29268. readonly premultipliedAlpha: boolean;
  29269. /**
  29270. * Observable event triggered before each texture is initialized
  29271. */
  29272. onBeforeTextureInitObservable: Observable<Texture>;
  29273. /**
  29274. * Creates a new engine
  29275. * @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
  29276. * @param antialias defines enable antialiasing (default: false)
  29277. * @param options defines further options to be sent to the getContext() function
  29278. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29279. */
  29280. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29281. private _rebuildInternalTextures;
  29282. private _rebuildEffects;
  29283. /**
  29284. * Gets a boolean indicating if all created effects are ready
  29285. * @returns true if all effects are ready
  29286. */
  29287. areAllEffectsReady(): boolean;
  29288. protected _rebuildBuffers(): void;
  29289. private _initGLContext;
  29290. /**
  29291. * Gets version of the current webGL context
  29292. */
  29293. readonly webGLVersion: number;
  29294. /**
  29295. * Gets a string idenfifying the name of the class
  29296. * @returns "Engine" string
  29297. */
  29298. getClassName(): string;
  29299. /**
  29300. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29301. */
  29302. readonly isStencilEnable: boolean;
  29303. /** @hidden */
  29304. _prepareWorkingCanvas(): void;
  29305. /**
  29306. * Reset the texture cache to empty state
  29307. */
  29308. resetTextureCache(): void;
  29309. /**
  29310. * Gets an object containing information about the current webGL context
  29311. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29312. */
  29313. getGlInfo(): {
  29314. vendor: string;
  29315. renderer: string;
  29316. version: string;
  29317. };
  29318. /**
  29319. * Defines the hardware scaling level.
  29320. * By default the hardware scaling level is computed from the window device ratio.
  29321. * 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.
  29322. * @param level defines the level to use
  29323. */
  29324. setHardwareScalingLevel(level: number): void;
  29325. /**
  29326. * Gets the current hardware scaling level.
  29327. * By default the hardware scaling level is computed from the window device ratio.
  29328. * 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.
  29329. * @returns a number indicating the current hardware scaling level
  29330. */
  29331. getHardwareScalingLevel(): number;
  29332. /**
  29333. * Gets the list of loaded textures
  29334. * @returns an array containing all loaded textures
  29335. */
  29336. getLoadedTexturesCache(): InternalTexture[];
  29337. /**
  29338. * Gets the object containing all engine capabilities
  29339. * @returns the EngineCapabilities object
  29340. */
  29341. getCaps(): EngineCapabilities;
  29342. /**
  29343. * stop executing a render loop function and remove it from the execution array
  29344. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29345. */
  29346. stopRenderLoop(renderFunction?: () => void): void;
  29347. /** @hidden */
  29348. _renderLoop(): void;
  29349. /**
  29350. * Gets the HTML canvas attached with the current webGL context
  29351. * @returns a HTML canvas
  29352. */
  29353. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29354. /**
  29355. * Gets host window
  29356. * @returns the host window object
  29357. */
  29358. getHostWindow(): Nullable<Window>;
  29359. /**
  29360. * Gets the current render width
  29361. * @param useScreen defines if screen size must be used (or the current render target if any)
  29362. * @returns a number defining the current render width
  29363. */
  29364. getRenderWidth(useScreen?: boolean): number;
  29365. /**
  29366. * Gets the current render height
  29367. * @param useScreen defines if screen size must be used (or the current render target if any)
  29368. * @returns a number defining the current render height
  29369. */
  29370. getRenderHeight(useScreen?: boolean): number;
  29371. /**
  29372. * Can be used to override the current requestAnimationFrame requester.
  29373. * @hidden
  29374. */
  29375. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29376. /**
  29377. * Register and execute a render loop. The engine can have more than one render function
  29378. * @param renderFunction defines the function to continuously execute
  29379. */
  29380. runRenderLoop(renderFunction: () => void): void;
  29381. /**
  29382. * Clear the current render buffer or the current render target (if any is set up)
  29383. * @param color defines the color to use
  29384. * @param backBuffer defines if the back buffer must be cleared
  29385. * @param depth defines if the depth buffer must be cleared
  29386. * @param stencil defines if the stencil buffer must be cleared
  29387. */
  29388. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29389. private _viewportCached;
  29390. /** @hidden */
  29391. _viewport(x: number, y: number, width: number, height: number): void;
  29392. /**
  29393. * Set the WebGL's viewport
  29394. * @param viewport defines the viewport element to be used
  29395. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29396. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29397. */
  29398. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29399. /**
  29400. * Begin a new frame
  29401. */
  29402. beginFrame(): void;
  29403. /**
  29404. * Enf the current frame
  29405. */
  29406. endFrame(): void;
  29407. /**
  29408. * Resize the view according to the canvas' size
  29409. */
  29410. resize(): void;
  29411. /**
  29412. * Force a specific size of the canvas
  29413. * @param width defines the new canvas' width
  29414. * @param height defines the new canvas' height
  29415. */
  29416. setSize(width: number, height: number): void;
  29417. /**
  29418. * Binds the frame buffer to the specified texture.
  29419. * @param texture The texture to render to or null for the default canvas
  29420. * @param faceIndex The face of the texture to render to in case of cube texture
  29421. * @param requiredWidth The width of the target to render to
  29422. * @param requiredHeight The height of the target to render to
  29423. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29424. * @param depthStencilTexture The depth stencil texture to use to render
  29425. * @param lodLevel defines le lod level to bind to the frame buffer
  29426. */
  29427. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29428. /** @hidden */
  29429. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29430. /**
  29431. * Unbind the current render target texture from the webGL context
  29432. * @param texture defines the render target texture to unbind
  29433. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29434. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29435. */
  29436. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29437. /**
  29438. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29439. */
  29440. flushFramebuffer(): void;
  29441. /**
  29442. * Unbind the current render target and bind the default framebuffer
  29443. */
  29444. restoreDefaultFramebuffer(): void;
  29445. /** @hidden */
  29446. protected _resetVertexBufferBinding(): void;
  29447. /**
  29448. * Creates a vertex buffer
  29449. * @param data the data for the vertex buffer
  29450. * @returns the new WebGL static buffer
  29451. */
  29452. createVertexBuffer(data: DataArray): DataBuffer;
  29453. private _createVertexBuffer;
  29454. /**
  29455. * Creates a dynamic vertex buffer
  29456. * @param data the data for the dynamic vertex buffer
  29457. * @returns the new WebGL dynamic buffer
  29458. */
  29459. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29460. protected _resetIndexBufferBinding(): void;
  29461. /**
  29462. * Creates a new index buffer
  29463. * @param indices defines the content of the index buffer
  29464. * @param updatable defines if the index buffer must be updatable
  29465. * @returns a new webGL buffer
  29466. */
  29467. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29468. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29469. /**
  29470. * Bind a webGL buffer to the webGL context
  29471. * @param buffer defines the buffer to bind
  29472. */
  29473. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29474. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29475. private bindBuffer;
  29476. /**
  29477. * update the bound buffer with the given data
  29478. * @param data defines the data to update
  29479. */
  29480. updateArrayBuffer(data: Float32Array): void;
  29481. private _vertexAttribPointer;
  29482. private _bindIndexBufferWithCache;
  29483. private _bindVertexBuffersAttributes;
  29484. /**
  29485. * Records a vertex array object
  29486. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29487. * @param vertexBuffers defines the list of vertex buffers to store
  29488. * @param indexBuffer defines the index buffer to store
  29489. * @param effect defines the effect to store
  29490. * @returns the new vertex array object
  29491. */
  29492. recordVertexArrayObject(vertexBuffers: {
  29493. [key: string]: VertexBuffer;
  29494. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29495. /**
  29496. * Bind a specific vertex array object
  29497. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29498. * @param vertexArrayObject defines the vertex array object to bind
  29499. * @param indexBuffer defines the index buffer to bind
  29500. */
  29501. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29502. /**
  29503. * Bind webGl buffers directly to the webGL context
  29504. * @param vertexBuffer defines the vertex buffer to bind
  29505. * @param indexBuffer defines the index buffer to bind
  29506. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29507. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29508. * @param effect defines the effect associated with the vertex buffer
  29509. */
  29510. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29511. private _unbindVertexArrayObject;
  29512. /**
  29513. * Bind a list of vertex buffers to the webGL context
  29514. * @param vertexBuffers defines the list of vertex buffers to bind
  29515. * @param indexBuffer defines the index buffer to bind
  29516. * @param effect defines the effect associated with the vertex buffers
  29517. */
  29518. bindBuffers(vertexBuffers: {
  29519. [key: string]: Nullable<VertexBuffer>;
  29520. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29521. /**
  29522. * Unbind all instance attributes
  29523. */
  29524. unbindInstanceAttributes(): void;
  29525. /**
  29526. * Release and free the memory of a vertex array object
  29527. * @param vao defines the vertex array object to delete
  29528. */
  29529. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29530. /** @hidden */
  29531. _releaseBuffer(buffer: DataBuffer): boolean;
  29532. protected _deleteBuffer(buffer: DataBuffer): void;
  29533. /**
  29534. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29535. * @param instancesBuffer defines the webGL buffer to update and bind
  29536. * @param data defines the data to store in the buffer
  29537. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29538. */
  29539. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29540. /**
  29541. * Apply all cached states (depth, culling, stencil and alpha)
  29542. */
  29543. applyStates(): void;
  29544. /**
  29545. * Send a draw order
  29546. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29547. * @param indexStart defines the starting index
  29548. * @param indexCount defines the number of index to draw
  29549. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29550. */
  29551. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29552. /**
  29553. * Draw a list of points
  29554. * @param verticesStart defines the index of first vertex to draw
  29555. * @param verticesCount defines the count of vertices to draw
  29556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29557. */
  29558. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29559. /**
  29560. * Draw a list of unindexed primitives
  29561. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29562. * @param verticesStart defines the index of first vertex to draw
  29563. * @param verticesCount defines the count of vertices to draw
  29564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29565. */
  29566. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29567. /**
  29568. * Draw a list of indexed primitives
  29569. * @param fillMode defines the primitive to use
  29570. * @param indexStart defines the starting index
  29571. * @param indexCount defines the number of index to draw
  29572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29573. */
  29574. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29575. /**
  29576. * Draw a list of unindexed primitives
  29577. * @param fillMode defines the primitive to use
  29578. * @param verticesStart defines the index of first vertex to draw
  29579. * @param verticesCount defines the count of vertices to draw
  29580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29581. */
  29582. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29583. private _drawMode;
  29584. /** @hidden */
  29585. protected _reportDrawCall(): void;
  29586. /** @hidden */
  29587. _releaseEffect(effect: Effect): void;
  29588. /** @hidden */
  29589. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29590. /**
  29591. * Create a new effect (used to store vertex/fragment shaders)
  29592. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29593. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29594. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29595. * @param samplers defines an array of string used to represent textures
  29596. * @param defines defines the string containing the defines to use to compile the shaders
  29597. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29598. * @param onCompiled defines a function to call when the effect creation is successful
  29599. * @param onError defines a function to call when the effect creation has failed
  29600. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29601. * @returns the new Effect
  29602. */
  29603. 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;
  29604. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29605. private _compileShader;
  29606. private _compileRawShader;
  29607. /**
  29608. * Directly creates a webGL program
  29609. * @param pipelineContext defines the pipeline context to attach to
  29610. * @param vertexCode defines the vertex shader code to use
  29611. * @param fragmentCode defines the fragment shader code to use
  29612. * @param context defines the webGL context to use (if not set, the current one will be used)
  29613. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29614. * @returns the new webGL program
  29615. */
  29616. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29617. /**
  29618. * Creates a webGL program
  29619. * @param pipelineContext defines the pipeline context to attach to
  29620. * @param vertexCode defines the vertex shader code to use
  29621. * @param fragmentCode defines the fragment shader code to use
  29622. * @param defines defines the string containing the defines to use to compile the shaders
  29623. * @param context defines the webGL context to use (if not set, the current one will be used)
  29624. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29625. * @returns the new webGL program
  29626. */
  29627. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29628. /**
  29629. * Creates a new pipeline context
  29630. * @returns the new pipeline
  29631. */
  29632. createPipelineContext(): IPipelineContext;
  29633. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29634. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29635. /** @hidden */
  29636. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29637. /** @hidden */
  29638. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29639. /** @hidden */
  29640. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29641. /**
  29642. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29643. * @param pipelineContext defines the pipeline context to use
  29644. * @param uniformsNames defines the list of uniform names
  29645. * @returns an array of webGL uniform locations
  29646. */
  29647. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29648. /**
  29649. * Gets the lsit of active attributes for a given webGL program
  29650. * @param pipelineContext defines the pipeline context to use
  29651. * @param attributesNames defines the list of attribute names to get
  29652. * @returns an array of indices indicating the offset of each attribute
  29653. */
  29654. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29655. /**
  29656. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29657. * @param effect defines the effect to activate
  29658. */
  29659. enableEffect(effect: Nullable<Effect>): void;
  29660. /**
  29661. * Set the value of an uniform to an array of int32
  29662. * @param uniform defines the webGL uniform location where to store the value
  29663. * @param array defines the array of int32 to store
  29664. */
  29665. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29666. /**
  29667. * Set the value of an uniform to an array of int32 (stored as vec2)
  29668. * @param uniform defines the webGL uniform location where to store the value
  29669. * @param array defines the array of int32 to store
  29670. */
  29671. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29672. /**
  29673. * Set the value of an uniform to an array of int32 (stored as vec3)
  29674. * @param uniform defines the webGL uniform location where to store the value
  29675. * @param array defines the array of int32 to store
  29676. */
  29677. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29678. /**
  29679. * Set the value of an uniform to an array of int32 (stored as vec4)
  29680. * @param uniform defines the webGL uniform location where to store the value
  29681. * @param array defines the array of int32 to store
  29682. */
  29683. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29684. /**
  29685. * Set the value of an uniform to an array of float32
  29686. * @param uniform defines the webGL uniform location where to store the value
  29687. * @param array defines the array of float32 to store
  29688. */
  29689. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29690. /**
  29691. * Set the value of an uniform to an array of float32 (stored as vec2)
  29692. * @param uniform defines the webGL uniform location where to store the value
  29693. * @param array defines the array of float32 to store
  29694. */
  29695. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29696. /**
  29697. * Set the value of an uniform to an array of float32 (stored as vec3)
  29698. * @param uniform defines the webGL uniform location where to store the value
  29699. * @param array defines the array of float32 to store
  29700. */
  29701. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29702. /**
  29703. * Set the value of an uniform to an array of float32 (stored as vec4)
  29704. * @param uniform defines the webGL uniform location where to store the value
  29705. * @param array defines the array of float32 to store
  29706. */
  29707. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29708. /**
  29709. * Set the value of an uniform to an array of number
  29710. * @param uniform defines the webGL uniform location where to store the value
  29711. * @param array defines the array of number to store
  29712. */
  29713. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29714. /**
  29715. * Set the value of an uniform to an array of number (stored as vec2)
  29716. * @param uniform defines the webGL uniform location where to store the value
  29717. * @param array defines the array of number to store
  29718. */
  29719. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29720. /**
  29721. * Set the value of an uniform to an array of number (stored as vec3)
  29722. * @param uniform defines the webGL uniform location where to store the value
  29723. * @param array defines the array of number to store
  29724. */
  29725. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29726. /**
  29727. * Set the value of an uniform to an array of number (stored as vec4)
  29728. * @param uniform defines the webGL uniform location where to store the value
  29729. * @param array defines the array of number to store
  29730. */
  29731. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29732. /**
  29733. * Set the value of an uniform to an array of float32 (stored as matrices)
  29734. * @param uniform defines the webGL uniform location where to store the value
  29735. * @param matrices defines the array of float32 to store
  29736. */
  29737. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29738. /**
  29739. * Set the value of an uniform to a matrix (3x3)
  29740. * @param uniform defines the webGL uniform location where to store the value
  29741. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29742. */
  29743. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29744. /**
  29745. * Set the value of an uniform to a matrix (2x2)
  29746. * @param uniform defines the webGL uniform location where to store the value
  29747. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29748. */
  29749. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29750. /**
  29751. * Set the value of an uniform to a number (int)
  29752. * @param uniform defines the webGL uniform location where to store the value
  29753. * @param value defines the int number to store
  29754. */
  29755. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29756. /**
  29757. * Set the value of an uniform to a number (float)
  29758. * @param uniform defines the webGL uniform location where to store the value
  29759. * @param value defines the float number to store
  29760. */
  29761. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29762. /**
  29763. * Set the value of an uniform to a vec2
  29764. * @param uniform defines the webGL uniform location where to store the value
  29765. * @param x defines the 1st component of the value
  29766. * @param y defines the 2nd component of the value
  29767. */
  29768. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29769. /**
  29770. * Set the value of an uniform to a vec3
  29771. * @param uniform defines the webGL uniform location where to store the value
  29772. * @param x defines the 1st component of the value
  29773. * @param y defines the 2nd component of the value
  29774. * @param z defines the 3rd component of the value
  29775. */
  29776. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29777. /**
  29778. * Set the value of an uniform to a boolean
  29779. * @param uniform defines the webGL uniform location where to store the value
  29780. * @param bool defines the boolean to store
  29781. */
  29782. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29783. /**
  29784. * Set the value of an uniform to a vec4
  29785. * @param uniform defines the webGL uniform location where to store the value
  29786. * @param x defines the 1st component of the value
  29787. * @param y defines the 2nd component of the value
  29788. * @param z defines the 3rd component of the value
  29789. * @param w defines the 4th component of the value
  29790. */
  29791. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29792. /**
  29793. * Sets a Color4 on a uniform variable
  29794. * @param uniform defines the uniform location
  29795. * @param color4 defines the value to be set
  29796. */
  29797. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29798. /**
  29799. * Gets the depth culling state manager
  29800. */
  29801. readonly depthCullingState: DepthCullingState;
  29802. /**
  29803. * Gets the alpha state manager
  29804. */
  29805. readonly alphaState: AlphaState;
  29806. /**
  29807. * Gets the stencil state manager
  29808. */
  29809. readonly stencilState: StencilState;
  29810. /**
  29811. * Clears the list of texture accessible through engine.
  29812. * This can help preventing texture load conflict due to name collision.
  29813. */
  29814. clearInternalTexturesCache(): void;
  29815. /**
  29816. * Force the entire cache to be cleared
  29817. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29818. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29819. */
  29820. wipeCaches(bruteForce?: boolean): void;
  29821. /** @hidden */
  29822. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29823. min: number;
  29824. mag: number;
  29825. };
  29826. /** @hidden */
  29827. _createTexture(): WebGLTexture;
  29828. /**
  29829. * Usually called from Texture.ts.
  29830. * Passed information to create a WebGLTexture
  29831. * @param urlArg defines a value which contains one of the following:
  29832. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29833. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29834. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29835. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29836. * @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)
  29837. * @param scene needed for loading to the correct scene
  29838. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29839. * @param onLoad optional callback to be called upon successful completion
  29840. * @param onError optional callback to be called upon failure
  29841. * @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
  29842. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29843. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29844. * @param forcedExtension defines the extension to use to pick the right loader
  29845. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29846. * @param mimeType defines an optional mime type
  29847. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29848. */
  29849. 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;
  29850. /**
  29851. * @hidden
  29852. */
  29853. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29854. /**
  29855. * Creates a raw texture
  29856. * @param data defines the data to store in the texture
  29857. * @param width defines the width of the texture
  29858. * @param height defines the height of the texture
  29859. * @param format defines the format of the data
  29860. * @param generateMipMaps defines if the engine should generate the mip levels
  29861. * @param invertY defines if data must be stored with Y axis inverted
  29862. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29863. * @param compression defines the compression used (null by default)
  29864. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29865. * @returns the raw texture inside an InternalTexture
  29866. */
  29867. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29868. /**
  29869. * Creates a new raw cube texture
  29870. * @param data defines the array of data to use to create each face
  29871. * @param size defines the size of the textures
  29872. * @param format defines the format of the data
  29873. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29874. * @param generateMipMaps defines if the engine should generate the mip levels
  29875. * @param invertY defines if data must be stored with Y axis inverted
  29876. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29877. * @param compression defines the compression used (null by default)
  29878. * @returns the cube texture as an InternalTexture
  29879. */
  29880. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29881. /**
  29882. * Creates a new raw 3D texture
  29883. * @param data defines the data used to create the texture
  29884. * @param width defines the width of the texture
  29885. * @param height defines the height of the texture
  29886. * @param depth defines the depth of the texture
  29887. * @param format defines the format of the texture
  29888. * @param generateMipMaps defines if the engine must generate mip levels
  29889. * @param invertY defines if data must be stored with Y axis inverted
  29890. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29891. * @param compression defines the compressed used (can be null)
  29892. * @param textureType defines the compressed used (can be null)
  29893. * @returns a new raw 3D texture (stored in an InternalTexture)
  29894. */
  29895. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29896. private _unpackFlipYCached;
  29897. /**
  29898. * In case you are sharing the context with other applications, it might
  29899. * be interested to not cache the unpack flip y state to ensure a consistent
  29900. * value would be set.
  29901. */
  29902. enableUnpackFlipYCached: boolean;
  29903. /** @hidden */
  29904. _unpackFlipY(value: boolean): void;
  29905. /** @hidden */
  29906. _getUnpackAlignement(): number;
  29907. /**
  29908. * Update the sampling mode of a given texture
  29909. * @param samplingMode defines the required sampling mode
  29910. * @param texture defines the texture to update
  29911. */
  29912. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29913. /**
  29914. * Updates a depth texture Comparison Mode and Function.
  29915. * If the comparison Function is equal to 0, the mode will be set to none.
  29916. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29917. * @param texture The texture to set the comparison function for
  29918. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29919. */
  29920. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29921. /** @hidden */
  29922. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29923. width: number;
  29924. height: number;
  29925. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29926. /** @hidden */
  29927. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29928. /** @hidden */
  29929. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29930. /** @hidden */
  29931. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29932. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29933. private _prepareWebGLTexture;
  29934. /** @hidden */
  29935. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29936. /** @hidden */
  29937. _releaseFramebufferObjects(texture: InternalTexture): void;
  29938. /** @hidden */
  29939. _releaseTexture(texture: InternalTexture): void;
  29940. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29941. protected _setProgram(program: WebGLProgram): void;
  29942. protected _boundUniforms: {
  29943. [key: number]: WebGLUniformLocation;
  29944. };
  29945. /**
  29946. * Binds an effect to the webGL context
  29947. * @param effect defines the effect to bind
  29948. */
  29949. bindSamplers(effect: Effect): void;
  29950. private _activateCurrentTexture;
  29951. /** @hidden */
  29952. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29953. /** @hidden */
  29954. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29955. /**
  29956. * Unbind all textures from the webGL context
  29957. */
  29958. unbindAllTextures(): void;
  29959. /**
  29960. * Sets a texture to the according uniform.
  29961. * @param channel The texture channel
  29962. * @param uniform The uniform to set
  29963. * @param texture The texture to apply
  29964. */
  29965. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29966. private _bindSamplerUniformToChannel;
  29967. private _getTextureWrapMode;
  29968. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29969. /**
  29970. * Sets an array of texture to the webGL context
  29971. * @param channel defines the channel where the texture array must be set
  29972. * @param uniform defines the associated uniform location
  29973. * @param textures defines the array of textures to bind
  29974. */
  29975. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29976. /** @hidden */
  29977. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29978. private _setTextureParameterFloat;
  29979. private _setTextureParameterInteger;
  29980. /**
  29981. * Unbind all vertex attributes from the webGL context
  29982. */
  29983. unbindAllAttributes(): void;
  29984. /**
  29985. * 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
  29986. */
  29987. releaseEffects(): void;
  29988. /**
  29989. * Dispose and release all associated resources
  29990. */
  29991. dispose(): void;
  29992. /**
  29993. * Attach a new callback raised when context lost event is fired
  29994. * @param callback defines the callback to call
  29995. */
  29996. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29997. /**
  29998. * Attach a new callback raised when context restored event is fired
  29999. * @param callback defines the callback to call
  30000. */
  30001. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30002. /**
  30003. * Get the current error code of the webGL context
  30004. * @returns the error code
  30005. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30006. */
  30007. getError(): number;
  30008. private _canRenderToFloatFramebuffer;
  30009. private _canRenderToHalfFloatFramebuffer;
  30010. private _canRenderToFramebuffer;
  30011. /** @hidden */
  30012. _getWebGLTextureType(type: number): number;
  30013. /** @hidden */
  30014. _getInternalFormat(format: number): number;
  30015. /** @hidden */
  30016. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30017. /** @hidden */
  30018. _getRGBAMultiSampleBufferFormat(type: number): number;
  30019. /** @hidden */
  30020. _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;
  30021. /**
  30022. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30023. * @returns true if the engine can be created
  30024. * @ignorenaming
  30025. */
  30026. static isSupported(): boolean;
  30027. /**
  30028. * Find the next highest power of two.
  30029. * @param x Number to start search from.
  30030. * @return Next highest power of two.
  30031. */
  30032. static CeilingPOT(x: number): number;
  30033. /**
  30034. * Find the next lowest power of two.
  30035. * @param x Number to start search from.
  30036. * @return Next lowest power of two.
  30037. */
  30038. static FloorPOT(x: number): number;
  30039. /**
  30040. * Find the nearest power of two.
  30041. * @param x Number to start search from.
  30042. * @return Next nearest power of two.
  30043. */
  30044. static NearestPOT(x: number): number;
  30045. /**
  30046. * Get the closest exponent of two
  30047. * @param value defines the value to approximate
  30048. * @param max defines the maximum value to return
  30049. * @param mode defines how to define the closest value
  30050. * @returns closest exponent of two of the given value
  30051. */
  30052. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30053. /**
  30054. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30055. * @param func - the function to be called
  30056. * @param requester - the object that will request the next frame. Falls back to window.
  30057. * @returns frame number
  30058. */
  30059. static QueueNewFrame(func: () => void, requester?: any): number;
  30060. }
  30061. }
  30062. declare module BABYLON {
  30063. /**
  30064. * Class representing spherical harmonics coefficients to the 3rd degree
  30065. */
  30066. export class SphericalHarmonics {
  30067. /**
  30068. * Defines whether or not the harmonics have been prescaled for rendering.
  30069. */
  30070. preScaled: boolean;
  30071. /**
  30072. * The l0,0 coefficients of the spherical harmonics
  30073. */
  30074. l00: Vector3;
  30075. /**
  30076. * The l1,-1 coefficients of the spherical harmonics
  30077. */
  30078. l1_1: Vector3;
  30079. /**
  30080. * The l1,0 coefficients of the spherical harmonics
  30081. */
  30082. l10: Vector3;
  30083. /**
  30084. * The l1,1 coefficients of the spherical harmonics
  30085. */
  30086. l11: Vector3;
  30087. /**
  30088. * The l2,-2 coefficients of the spherical harmonics
  30089. */
  30090. l2_2: Vector3;
  30091. /**
  30092. * The l2,-1 coefficients of the spherical harmonics
  30093. */
  30094. l2_1: Vector3;
  30095. /**
  30096. * The l2,0 coefficients of the spherical harmonics
  30097. */
  30098. l20: Vector3;
  30099. /**
  30100. * The l2,1 coefficients of the spherical harmonics
  30101. */
  30102. l21: Vector3;
  30103. /**
  30104. * The l2,2 coefficients of the spherical harmonics
  30105. */
  30106. l22: Vector3;
  30107. /**
  30108. * Adds a light to the spherical harmonics
  30109. * @param direction the direction of the light
  30110. * @param color the color of the light
  30111. * @param deltaSolidAngle the delta solid angle of the light
  30112. */
  30113. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30114. /**
  30115. * Scales the spherical harmonics by the given amount
  30116. * @param scale the amount to scale
  30117. */
  30118. scaleInPlace(scale: number): void;
  30119. /**
  30120. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30121. *
  30122. * ```
  30123. * E_lm = A_l * L_lm
  30124. * ```
  30125. *
  30126. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30127. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30128. * the scaling factors are given in equation 9.
  30129. */
  30130. convertIncidentRadianceToIrradiance(): void;
  30131. /**
  30132. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30133. *
  30134. * ```
  30135. * L = (1/pi) * E * rho
  30136. * ```
  30137. *
  30138. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30139. */
  30140. convertIrradianceToLambertianRadiance(): void;
  30141. /**
  30142. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30143. * required operations at run time.
  30144. *
  30145. * This is simply done by scaling back the SH with Ylm constants parameter.
  30146. * The trigonometric part being applied by the shader at run time.
  30147. */
  30148. preScaleForRendering(): void;
  30149. /**
  30150. * Constructs a spherical harmonics from an array.
  30151. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30152. * @returns the spherical harmonics
  30153. */
  30154. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30155. /**
  30156. * Gets the spherical harmonics from polynomial
  30157. * @param polynomial the spherical polynomial
  30158. * @returns the spherical harmonics
  30159. */
  30160. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30161. }
  30162. /**
  30163. * Class representing spherical polynomial coefficients to the 3rd degree
  30164. */
  30165. export class SphericalPolynomial {
  30166. private _harmonics;
  30167. /**
  30168. * The spherical harmonics used to create the polynomials.
  30169. */
  30170. readonly preScaledHarmonics: SphericalHarmonics;
  30171. /**
  30172. * The x coefficients of the spherical polynomial
  30173. */
  30174. x: Vector3;
  30175. /**
  30176. * The y coefficients of the spherical polynomial
  30177. */
  30178. y: Vector3;
  30179. /**
  30180. * The z coefficients of the spherical polynomial
  30181. */
  30182. z: Vector3;
  30183. /**
  30184. * The xx coefficients of the spherical polynomial
  30185. */
  30186. xx: Vector3;
  30187. /**
  30188. * The yy coefficients of the spherical polynomial
  30189. */
  30190. yy: Vector3;
  30191. /**
  30192. * The zz coefficients of the spherical polynomial
  30193. */
  30194. zz: Vector3;
  30195. /**
  30196. * The xy coefficients of the spherical polynomial
  30197. */
  30198. xy: Vector3;
  30199. /**
  30200. * The yz coefficients of the spherical polynomial
  30201. */
  30202. yz: Vector3;
  30203. /**
  30204. * The zx coefficients of the spherical polynomial
  30205. */
  30206. zx: Vector3;
  30207. /**
  30208. * Adds an ambient color to the spherical polynomial
  30209. * @param color the color to add
  30210. */
  30211. addAmbient(color: Color3): void;
  30212. /**
  30213. * Scales the spherical polynomial by the given amount
  30214. * @param scale the amount to scale
  30215. */
  30216. scaleInPlace(scale: number): void;
  30217. /**
  30218. * Gets the spherical polynomial from harmonics
  30219. * @param harmonics the spherical harmonics
  30220. * @returns the spherical polynomial
  30221. */
  30222. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30223. /**
  30224. * Constructs a spherical polynomial from an array.
  30225. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30226. * @returns the spherical polynomial
  30227. */
  30228. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30229. }
  30230. }
  30231. declare module BABYLON {
  30232. /**
  30233. * Defines the source of the internal texture
  30234. */
  30235. export enum InternalTextureSource {
  30236. /**
  30237. * The source of the texture data is unknown
  30238. */
  30239. Unknown = 0,
  30240. /**
  30241. * Texture data comes from an URL
  30242. */
  30243. Url = 1,
  30244. /**
  30245. * Texture data is only used for temporary storage
  30246. */
  30247. Temp = 2,
  30248. /**
  30249. * Texture data comes from raw data (ArrayBuffer)
  30250. */
  30251. Raw = 3,
  30252. /**
  30253. * Texture content is dynamic (video or dynamic texture)
  30254. */
  30255. Dynamic = 4,
  30256. /**
  30257. * Texture content is generated by rendering to it
  30258. */
  30259. RenderTarget = 5,
  30260. /**
  30261. * Texture content is part of a multi render target process
  30262. */
  30263. MultiRenderTarget = 6,
  30264. /**
  30265. * Texture data comes from a cube data file
  30266. */
  30267. Cube = 7,
  30268. /**
  30269. * Texture data comes from a raw cube data
  30270. */
  30271. CubeRaw = 8,
  30272. /**
  30273. * Texture data come from a prefiltered cube data file
  30274. */
  30275. CubePrefiltered = 9,
  30276. /**
  30277. * Texture content is raw 3D data
  30278. */
  30279. Raw3D = 10,
  30280. /**
  30281. * Texture content is a depth texture
  30282. */
  30283. Depth = 11,
  30284. /**
  30285. * Texture data comes from a raw cube data encoded with RGBD
  30286. */
  30287. CubeRawRGBD = 12
  30288. }
  30289. /**
  30290. * Class used to store data associated with WebGL texture data for the engine
  30291. * This class should not be used directly
  30292. */
  30293. export class InternalTexture {
  30294. /** @hidden */
  30295. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30296. /**
  30297. * Defines if the texture is ready
  30298. */
  30299. isReady: boolean;
  30300. /**
  30301. * Defines if the texture is a cube texture
  30302. */
  30303. isCube: boolean;
  30304. /**
  30305. * Defines if the texture contains 3D data
  30306. */
  30307. is3D: boolean;
  30308. /**
  30309. * Defines if the texture contains multiview data
  30310. */
  30311. isMultiview: boolean;
  30312. /**
  30313. * Gets the URL used to load this texture
  30314. */
  30315. url: string;
  30316. /**
  30317. * Gets the sampling mode of the texture
  30318. */
  30319. samplingMode: number;
  30320. /**
  30321. * Gets a boolean indicating if the texture needs mipmaps generation
  30322. */
  30323. generateMipMaps: boolean;
  30324. /**
  30325. * Gets the number of samples used by the texture (WebGL2+ only)
  30326. */
  30327. samples: number;
  30328. /**
  30329. * Gets the type of the texture (int, float...)
  30330. */
  30331. type: number;
  30332. /**
  30333. * Gets the format of the texture (RGB, RGBA...)
  30334. */
  30335. format: number;
  30336. /**
  30337. * Observable called when the texture is loaded
  30338. */
  30339. onLoadedObservable: Observable<InternalTexture>;
  30340. /**
  30341. * Gets the width of the texture
  30342. */
  30343. width: number;
  30344. /**
  30345. * Gets the height of the texture
  30346. */
  30347. height: number;
  30348. /**
  30349. * Gets the depth of the texture
  30350. */
  30351. depth: number;
  30352. /**
  30353. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30354. */
  30355. baseWidth: number;
  30356. /**
  30357. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30358. */
  30359. baseHeight: number;
  30360. /**
  30361. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30362. */
  30363. baseDepth: number;
  30364. /**
  30365. * Gets a boolean indicating if the texture is inverted on Y axis
  30366. */
  30367. invertY: boolean;
  30368. /** @hidden */
  30369. _invertVScale: boolean;
  30370. /** @hidden */
  30371. _associatedChannel: number;
  30372. /** @hidden */
  30373. _source: InternalTextureSource;
  30374. /** @hidden */
  30375. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30376. /** @hidden */
  30377. _bufferView: Nullable<ArrayBufferView>;
  30378. /** @hidden */
  30379. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30380. /** @hidden */
  30381. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30382. /** @hidden */
  30383. _size: number;
  30384. /** @hidden */
  30385. _extension: string;
  30386. /** @hidden */
  30387. _files: Nullable<string[]>;
  30388. /** @hidden */
  30389. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30390. /** @hidden */
  30391. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30392. /** @hidden */
  30393. _framebuffer: Nullable<WebGLFramebuffer>;
  30394. /** @hidden */
  30395. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30396. /** @hidden */
  30397. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30398. /** @hidden */
  30399. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30400. /** @hidden */
  30401. _attachments: Nullable<number[]>;
  30402. /** @hidden */
  30403. _cachedCoordinatesMode: Nullable<number>;
  30404. /** @hidden */
  30405. _cachedWrapU: Nullable<number>;
  30406. /** @hidden */
  30407. _cachedWrapV: Nullable<number>;
  30408. /** @hidden */
  30409. _cachedWrapR: Nullable<number>;
  30410. /** @hidden */
  30411. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30412. /** @hidden */
  30413. _isDisabled: boolean;
  30414. /** @hidden */
  30415. _compression: Nullable<string>;
  30416. /** @hidden */
  30417. _generateStencilBuffer: boolean;
  30418. /** @hidden */
  30419. _generateDepthBuffer: boolean;
  30420. /** @hidden */
  30421. _comparisonFunction: number;
  30422. /** @hidden */
  30423. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30424. /** @hidden */
  30425. _lodGenerationScale: number;
  30426. /** @hidden */
  30427. _lodGenerationOffset: number;
  30428. /** @hidden */
  30429. _colorTextureArray: Nullable<WebGLTexture>;
  30430. /** @hidden */
  30431. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30432. /** @hidden */
  30433. _lodTextureHigh: Nullable<BaseTexture>;
  30434. /** @hidden */
  30435. _lodTextureMid: Nullable<BaseTexture>;
  30436. /** @hidden */
  30437. _lodTextureLow: Nullable<BaseTexture>;
  30438. /** @hidden */
  30439. _isRGBD: boolean;
  30440. /** @hidden */
  30441. _linearSpecularLOD: boolean;
  30442. /** @hidden */
  30443. _irradianceTexture: Nullable<BaseTexture>;
  30444. /** @hidden */
  30445. _webGLTexture: Nullable<WebGLTexture>;
  30446. /** @hidden */
  30447. _references: number;
  30448. private _engine;
  30449. /**
  30450. * Gets the Engine the texture belongs to.
  30451. * @returns The babylon engine
  30452. */
  30453. getEngine(): ThinEngine;
  30454. /**
  30455. * Gets the data source type of the texture
  30456. */
  30457. readonly source: InternalTextureSource;
  30458. /**
  30459. * Creates a new InternalTexture
  30460. * @param engine defines the engine to use
  30461. * @param source defines the type of data that will be used
  30462. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30463. */
  30464. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30465. /**
  30466. * Increments the number of references (ie. the number of Texture that point to it)
  30467. */
  30468. incrementReferences(): void;
  30469. /**
  30470. * Change the size of the texture (not the size of the content)
  30471. * @param width defines the new width
  30472. * @param height defines the new height
  30473. * @param depth defines the new depth (1 by default)
  30474. */
  30475. updateSize(width: int, height: int, depth?: int): void;
  30476. /** @hidden */
  30477. _rebuild(): void;
  30478. /** @hidden */
  30479. _swapAndDie(target: InternalTexture): void;
  30480. /**
  30481. * Dispose the current allocated resources
  30482. */
  30483. dispose(): void;
  30484. }
  30485. }
  30486. declare module BABYLON {
  30487. /**
  30488. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30490. */
  30491. export class Analyser {
  30492. /**
  30493. * Gets or sets the smoothing
  30494. * @ignorenaming
  30495. */
  30496. SMOOTHING: number;
  30497. /**
  30498. * Gets or sets the FFT table size
  30499. * @ignorenaming
  30500. */
  30501. FFT_SIZE: number;
  30502. /**
  30503. * Gets or sets the bar graph amplitude
  30504. * @ignorenaming
  30505. */
  30506. BARGRAPHAMPLITUDE: number;
  30507. /**
  30508. * Gets or sets the position of the debug canvas
  30509. * @ignorenaming
  30510. */
  30511. DEBUGCANVASPOS: {
  30512. x: number;
  30513. y: number;
  30514. };
  30515. /**
  30516. * Gets or sets the debug canvas size
  30517. * @ignorenaming
  30518. */
  30519. DEBUGCANVASSIZE: {
  30520. width: number;
  30521. height: number;
  30522. };
  30523. private _byteFreqs;
  30524. private _byteTime;
  30525. private _floatFreqs;
  30526. private _webAudioAnalyser;
  30527. private _debugCanvas;
  30528. private _debugCanvasContext;
  30529. private _scene;
  30530. private _registerFunc;
  30531. private _audioEngine;
  30532. /**
  30533. * Creates a new analyser
  30534. * @param scene defines hosting scene
  30535. */
  30536. constructor(scene: Scene);
  30537. /**
  30538. * Get the number of data values you will have to play with for the visualization
  30539. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30540. * @returns a number
  30541. */
  30542. getFrequencyBinCount(): number;
  30543. /**
  30544. * Gets the current frequency data as a byte array
  30545. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30546. * @returns a Uint8Array
  30547. */
  30548. getByteFrequencyData(): Uint8Array;
  30549. /**
  30550. * Gets the current waveform as a byte array
  30551. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30552. * @returns a Uint8Array
  30553. */
  30554. getByteTimeDomainData(): Uint8Array;
  30555. /**
  30556. * Gets the current frequency data as a float array
  30557. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30558. * @returns a Float32Array
  30559. */
  30560. getFloatFrequencyData(): Float32Array;
  30561. /**
  30562. * Renders the debug canvas
  30563. */
  30564. drawDebugCanvas(): void;
  30565. /**
  30566. * Stops rendering the debug canvas and removes it
  30567. */
  30568. stopDebugCanvas(): void;
  30569. /**
  30570. * Connects two audio nodes
  30571. * @param inputAudioNode defines first node to connect
  30572. * @param outputAudioNode defines second node to connect
  30573. */
  30574. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30575. /**
  30576. * Releases all associated resources
  30577. */
  30578. dispose(): void;
  30579. }
  30580. }
  30581. declare module BABYLON {
  30582. /**
  30583. * This represents an audio engine and it is responsible
  30584. * to play, synchronize and analyse sounds throughout the application.
  30585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30586. */
  30587. export interface IAudioEngine extends IDisposable {
  30588. /**
  30589. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30590. */
  30591. readonly canUseWebAudio: boolean;
  30592. /**
  30593. * Gets the current AudioContext if available.
  30594. */
  30595. readonly audioContext: Nullable<AudioContext>;
  30596. /**
  30597. * The master gain node defines the global audio volume of your audio engine.
  30598. */
  30599. readonly masterGain: GainNode;
  30600. /**
  30601. * Gets whether or not mp3 are supported by your browser.
  30602. */
  30603. readonly isMP3supported: boolean;
  30604. /**
  30605. * Gets whether or not ogg are supported by your browser.
  30606. */
  30607. readonly isOGGsupported: boolean;
  30608. /**
  30609. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30610. * @ignoreNaming
  30611. */
  30612. WarnedWebAudioUnsupported: boolean;
  30613. /**
  30614. * Defines if the audio engine relies on a custom unlocked button.
  30615. * In this case, the embedded button will not be displayed.
  30616. */
  30617. useCustomUnlockedButton: boolean;
  30618. /**
  30619. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30620. */
  30621. readonly unlocked: boolean;
  30622. /**
  30623. * Event raised when audio has been unlocked on the browser.
  30624. */
  30625. onAudioUnlockedObservable: Observable<AudioEngine>;
  30626. /**
  30627. * Event raised when audio has been locked on the browser.
  30628. */
  30629. onAudioLockedObservable: Observable<AudioEngine>;
  30630. /**
  30631. * Flags the audio engine in Locked state.
  30632. * This happens due to new browser policies preventing audio to autoplay.
  30633. */
  30634. lock(): void;
  30635. /**
  30636. * Unlocks the audio engine once a user action has been done on the dom.
  30637. * This is helpful to resume play once browser policies have been satisfied.
  30638. */
  30639. unlock(): void;
  30640. }
  30641. /**
  30642. * This represents the default audio engine used in babylon.
  30643. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30645. */
  30646. export class AudioEngine implements IAudioEngine {
  30647. private _audioContext;
  30648. private _audioContextInitialized;
  30649. private _muteButton;
  30650. private _hostElement;
  30651. /**
  30652. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30653. */
  30654. canUseWebAudio: boolean;
  30655. /**
  30656. * The master gain node defines the global audio volume of your audio engine.
  30657. */
  30658. masterGain: GainNode;
  30659. /**
  30660. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30661. * @ignoreNaming
  30662. */
  30663. WarnedWebAudioUnsupported: boolean;
  30664. /**
  30665. * Gets whether or not mp3 are supported by your browser.
  30666. */
  30667. isMP3supported: boolean;
  30668. /**
  30669. * Gets whether or not ogg are supported by your browser.
  30670. */
  30671. isOGGsupported: boolean;
  30672. /**
  30673. * Gets whether audio has been unlocked on the device.
  30674. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30675. * a user interaction has happened.
  30676. */
  30677. unlocked: boolean;
  30678. /**
  30679. * Defines if the audio engine relies on a custom unlocked button.
  30680. * In this case, the embedded button will not be displayed.
  30681. */
  30682. useCustomUnlockedButton: boolean;
  30683. /**
  30684. * Event raised when audio has been unlocked on the browser.
  30685. */
  30686. onAudioUnlockedObservable: Observable<AudioEngine>;
  30687. /**
  30688. * Event raised when audio has been locked on the browser.
  30689. */
  30690. onAudioLockedObservable: Observable<AudioEngine>;
  30691. /**
  30692. * Gets the current AudioContext if available.
  30693. */
  30694. readonly audioContext: Nullable<AudioContext>;
  30695. private _connectedAnalyser;
  30696. /**
  30697. * Instantiates a new audio engine.
  30698. *
  30699. * There should be only one per page as some browsers restrict the number
  30700. * of audio contexts you can create.
  30701. * @param hostElement defines the host element where to display the mute icon if necessary
  30702. */
  30703. constructor(hostElement?: Nullable<HTMLElement>);
  30704. /**
  30705. * Flags the audio engine in Locked state.
  30706. * This happens due to new browser policies preventing audio to autoplay.
  30707. */
  30708. lock(): void;
  30709. /**
  30710. * Unlocks the audio engine once a user action has been done on the dom.
  30711. * This is helpful to resume play once browser policies have been satisfied.
  30712. */
  30713. unlock(): void;
  30714. private _resumeAudioContext;
  30715. private _initializeAudioContext;
  30716. private _tryToRun;
  30717. private _triggerRunningState;
  30718. private _triggerSuspendedState;
  30719. private _displayMuteButton;
  30720. private _moveButtonToTopLeft;
  30721. private _onResize;
  30722. private _hideMuteButton;
  30723. /**
  30724. * Destroy and release the resources associated with the audio ccontext.
  30725. */
  30726. dispose(): void;
  30727. /**
  30728. * Gets the global volume sets on the master gain.
  30729. * @returns the global volume if set or -1 otherwise
  30730. */
  30731. getGlobalVolume(): number;
  30732. /**
  30733. * Sets the global volume of your experience (sets on the master gain).
  30734. * @param newVolume Defines the new global volume of the application
  30735. */
  30736. setGlobalVolume(newVolume: number): void;
  30737. /**
  30738. * Connect the audio engine to an audio analyser allowing some amazing
  30739. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30741. * @param analyser The analyser to connect to the engine
  30742. */
  30743. connectToAnalyser(analyser: Analyser): void;
  30744. }
  30745. }
  30746. declare module BABYLON {
  30747. /**
  30748. * Interface used to present a loading screen while loading a scene
  30749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30750. */
  30751. export interface ILoadingScreen {
  30752. /**
  30753. * Function called to display the loading screen
  30754. */
  30755. displayLoadingUI: () => void;
  30756. /**
  30757. * Function called to hide the loading screen
  30758. */
  30759. hideLoadingUI: () => void;
  30760. /**
  30761. * Gets or sets the color to use for the background
  30762. */
  30763. loadingUIBackgroundColor: string;
  30764. /**
  30765. * Gets or sets the text to display while loading
  30766. */
  30767. loadingUIText: string;
  30768. }
  30769. /**
  30770. * Class used for the default loading screen
  30771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30772. */
  30773. export class DefaultLoadingScreen implements ILoadingScreen {
  30774. private _renderingCanvas;
  30775. private _loadingText;
  30776. private _loadingDivBackgroundColor;
  30777. private _loadingDiv;
  30778. private _loadingTextDiv;
  30779. /** Gets or sets the logo url to use for the default loading screen */
  30780. static DefaultLogoUrl: string;
  30781. /** Gets or sets the spinner url to use for the default loading screen */
  30782. static DefaultSpinnerUrl: string;
  30783. /**
  30784. * Creates a new default loading screen
  30785. * @param _renderingCanvas defines the canvas used to render the scene
  30786. * @param _loadingText defines the default text to display
  30787. * @param _loadingDivBackgroundColor defines the default background color
  30788. */
  30789. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30790. /**
  30791. * Function called to display the loading screen
  30792. */
  30793. displayLoadingUI(): void;
  30794. /**
  30795. * Function called to hide the loading screen
  30796. */
  30797. hideLoadingUI(): void;
  30798. /**
  30799. * Gets or sets the text to display while loading
  30800. */
  30801. loadingUIText: string;
  30802. /**
  30803. * Gets or sets the color to use for the background
  30804. */
  30805. loadingUIBackgroundColor: string;
  30806. private _resizeLoadingUI;
  30807. }
  30808. }
  30809. declare module BABYLON {
  30810. /**
  30811. * Interface for any object that can request an animation frame
  30812. */
  30813. export interface ICustomAnimationFrameRequester {
  30814. /**
  30815. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30816. */
  30817. renderFunction?: Function;
  30818. /**
  30819. * Called to request the next frame to render to
  30820. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30821. */
  30822. requestAnimationFrame: Function;
  30823. /**
  30824. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30825. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30826. */
  30827. requestID?: number;
  30828. }
  30829. }
  30830. declare module BABYLON {
  30831. /**
  30832. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30833. */
  30834. export class PerformanceMonitor {
  30835. private _enabled;
  30836. private _rollingFrameTime;
  30837. private _lastFrameTimeMs;
  30838. /**
  30839. * constructor
  30840. * @param frameSampleSize The number of samples required to saturate the sliding window
  30841. */
  30842. constructor(frameSampleSize?: number);
  30843. /**
  30844. * Samples current frame
  30845. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30846. */
  30847. sampleFrame(timeMs?: number): void;
  30848. /**
  30849. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30850. */
  30851. readonly averageFrameTime: number;
  30852. /**
  30853. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30854. */
  30855. readonly averageFrameTimeVariance: number;
  30856. /**
  30857. * Returns the frame time of the most recent frame
  30858. */
  30859. readonly instantaneousFrameTime: number;
  30860. /**
  30861. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30862. */
  30863. readonly averageFPS: number;
  30864. /**
  30865. * Returns the average framerate in frames per second using the most recent frame time
  30866. */
  30867. readonly instantaneousFPS: number;
  30868. /**
  30869. * Returns true if enough samples have been taken to completely fill the sliding window
  30870. */
  30871. readonly isSaturated: boolean;
  30872. /**
  30873. * Enables contributions to the sliding window sample set
  30874. */
  30875. enable(): void;
  30876. /**
  30877. * Disables contributions to the sliding window sample set
  30878. * Samples will not be interpolated over the disabled period
  30879. */
  30880. disable(): void;
  30881. /**
  30882. * Returns true if sampling is enabled
  30883. */
  30884. readonly isEnabled: boolean;
  30885. /**
  30886. * Resets performance monitor
  30887. */
  30888. reset(): void;
  30889. }
  30890. /**
  30891. * RollingAverage
  30892. *
  30893. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30894. */
  30895. export class RollingAverage {
  30896. /**
  30897. * Current average
  30898. */
  30899. average: number;
  30900. /**
  30901. * Current variance
  30902. */
  30903. variance: number;
  30904. protected _samples: Array<number>;
  30905. protected _sampleCount: number;
  30906. protected _pos: number;
  30907. protected _m2: number;
  30908. /**
  30909. * constructor
  30910. * @param length The number of samples required to saturate the sliding window
  30911. */
  30912. constructor(length: number);
  30913. /**
  30914. * Adds a sample to the sample set
  30915. * @param v The sample value
  30916. */
  30917. add(v: number): void;
  30918. /**
  30919. * Returns previously added values or null if outside of history or outside the sliding window domain
  30920. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30921. * @return Value previously recorded with add() or null if outside of range
  30922. */
  30923. history(i: number): number;
  30924. /**
  30925. * Returns true if enough samples have been taken to completely fill the sliding window
  30926. * @return true if sample-set saturated
  30927. */
  30928. isSaturated(): boolean;
  30929. /**
  30930. * Resets the rolling average (equivalent to 0 samples taken so far)
  30931. */
  30932. reset(): void;
  30933. /**
  30934. * Wraps a value around the sample range boundaries
  30935. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30936. * @return Wrapped position in sample range
  30937. */
  30938. protected _wrapPosition(i: number): number;
  30939. }
  30940. }
  30941. declare module BABYLON {
  30942. /**
  30943. * This class is used to track a performance counter which is number based.
  30944. * The user has access to many properties which give statistics of different nature.
  30945. *
  30946. * The implementer can track two kinds of Performance Counter: time and count.
  30947. * 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.
  30948. * 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.
  30949. */
  30950. export class PerfCounter {
  30951. /**
  30952. * Gets or sets a global boolean to turn on and off all the counters
  30953. */
  30954. static Enabled: boolean;
  30955. /**
  30956. * Returns the smallest value ever
  30957. */
  30958. readonly min: number;
  30959. /**
  30960. * Returns the biggest value ever
  30961. */
  30962. readonly max: number;
  30963. /**
  30964. * Returns the average value since the performance counter is running
  30965. */
  30966. readonly average: number;
  30967. /**
  30968. * Returns the average value of the last second the counter was monitored
  30969. */
  30970. readonly lastSecAverage: number;
  30971. /**
  30972. * Returns the current value
  30973. */
  30974. readonly current: number;
  30975. /**
  30976. * Gets the accumulated total
  30977. */
  30978. readonly total: number;
  30979. /**
  30980. * Gets the total value count
  30981. */
  30982. readonly count: number;
  30983. /**
  30984. * Creates a new counter
  30985. */
  30986. constructor();
  30987. /**
  30988. * Call this method to start monitoring a new frame.
  30989. * 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.
  30990. */
  30991. fetchNewFrame(): void;
  30992. /**
  30993. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30994. * @param newCount the count value to add to the monitored count
  30995. * @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.
  30996. */
  30997. addCount(newCount: number, fetchResult: boolean): void;
  30998. /**
  30999. * Start monitoring this performance counter
  31000. */
  31001. beginMonitoring(): void;
  31002. /**
  31003. * Compute the time lapsed since the previous beginMonitoring() call.
  31004. * @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
  31005. */
  31006. endMonitoring(newFrame?: boolean): void;
  31007. private _fetchResult;
  31008. private _startMonitoringTime;
  31009. private _min;
  31010. private _max;
  31011. private _average;
  31012. private _current;
  31013. private _totalValueCount;
  31014. private _totalAccumulated;
  31015. private _lastSecAverage;
  31016. private _lastSecAccumulated;
  31017. private _lastSecTime;
  31018. private _lastSecValueCount;
  31019. }
  31020. }
  31021. declare module BABYLON {
  31022. /**
  31023. * Defines the interface used by display changed events
  31024. */
  31025. export interface IDisplayChangedEventArgs {
  31026. /** Gets the vrDisplay object (if any) */
  31027. vrDisplay: Nullable<any>;
  31028. /** Gets a boolean indicating if webVR is supported */
  31029. vrSupported: boolean;
  31030. }
  31031. /**
  31032. * Defines the interface used by objects containing a viewport (like a camera)
  31033. */
  31034. interface IViewportOwnerLike {
  31035. /**
  31036. * Gets or sets the viewport
  31037. */
  31038. viewport: IViewportLike;
  31039. }
  31040. /**
  31041. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31042. */
  31043. export class Engine extends ThinEngine {
  31044. /** Defines that alpha blending is disabled */
  31045. static readonly ALPHA_DISABLE: number;
  31046. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31047. static readonly ALPHA_ADD: number;
  31048. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31049. static readonly ALPHA_COMBINE: number;
  31050. /** Defines that alpha blending to DEST - SRC * DEST */
  31051. static readonly ALPHA_SUBTRACT: number;
  31052. /** Defines that alpha blending to SRC * DEST */
  31053. static readonly ALPHA_MULTIPLY: number;
  31054. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31055. static readonly ALPHA_MAXIMIZED: number;
  31056. /** Defines that alpha blending to SRC + DEST */
  31057. static readonly ALPHA_ONEONE: number;
  31058. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31059. static readonly ALPHA_PREMULTIPLIED: number;
  31060. /**
  31061. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31062. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31063. */
  31064. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31065. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31066. static readonly ALPHA_INTERPOLATE: number;
  31067. /**
  31068. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31069. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31070. */
  31071. static readonly ALPHA_SCREENMODE: number;
  31072. /** Defines that the ressource is not delayed*/
  31073. static readonly DELAYLOADSTATE_NONE: number;
  31074. /** Defines that the ressource was successfully delay loaded */
  31075. static readonly DELAYLOADSTATE_LOADED: number;
  31076. /** Defines that the ressource is currently delay loading */
  31077. static readonly DELAYLOADSTATE_LOADING: number;
  31078. /** Defines that the ressource is delayed and has not started loading */
  31079. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31081. static readonly NEVER: number;
  31082. /** 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 */
  31083. static readonly ALWAYS: number;
  31084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31085. static readonly LESS: number;
  31086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31087. static readonly EQUAL: number;
  31088. /** 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 */
  31089. static readonly LEQUAL: number;
  31090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31091. static readonly GREATER: number;
  31092. /** 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 */
  31093. static readonly GEQUAL: number;
  31094. /** 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 */
  31095. static readonly NOTEQUAL: number;
  31096. /** Passed to stencilOperation to specify that stencil value must be kept */
  31097. static readonly KEEP: number;
  31098. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31099. static readonly REPLACE: number;
  31100. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31101. static readonly INCR: number;
  31102. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31103. static readonly DECR: number;
  31104. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31105. static readonly INVERT: number;
  31106. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31107. static readonly INCR_WRAP: number;
  31108. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31109. static readonly DECR_WRAP: number;
  31110. /** Texture is not repeating outside of 0..1 UVs */
  31111. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31112. /** Texture is repeating outside of 0..1 UVs */
  31113. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31114. /** Texture is repeating and mirrored */
  31115. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31116. /** ALPHA */
  31117. static readonly TEXTUREFORMAT_ALPHA: number;
  31118. /** LUMINANCE */
  31119. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31120. /** LUMINANCE_ALPHA */
  31121. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31122. /** RGB */
  31123. static readonly TEXTUREFORMAT_RGB: number;
  31124. /** RGBA */
  31125. static readonly TEXTUREFORMAT_RGBA: number;
  31126. /** RED */
  31127. static readonly TEXTUREFORMAT_RED: number;
  31128. /** RED (2nd reference) */
  31129. static readonly TEXTUREFORMAT_R: number;
  31130. /** RG */
  31131. static readonly TEXTUREFORMAT_RG: number;
  31132. /** RED_INTEGER */
  31133. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31134. /** RED_INTEGER (2nd reference) */
  31135. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31136. /** RG_INTEGER */
  31137. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31138. /** RGB_INTEGER */
  31139. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31140. /** RGBA_INTEGER */
  31141. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31142. /** UNSIGNED_BYTE */
  31143. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31144. /** UNSIGNED_BYTE (2nd reference) */
  31145. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31146. /** FLOAT */
  31147. static readonly TEXTURETYPE_FLOAT: number;
  31148. /** HALF_FLOAT */
  31149. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31150. /** BYTE */
  31151. static readonly TEXTURETYPE_BYTE: number;
  31152. /** SHORT */
  31153. static readonly TEXTURETYPE_SHORT: number;
  31154. /** UNSIGNED_SHORT */
  31155. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31156. /** INT */
  31157. static readonly TEXTURETYPE_INT: number;
  31158. /** UNSIGNED_INT */
  31159. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31160. /** UNSIGNED_SHORT_4_4_4_4 */
  31161. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31162. /** UNSIGNED_SHORT_5_5_5_1 */
  31163. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31164. /** UNSIGNED_SHORT_5_6_5 */
  31165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31166. /** UNSIGNED_INT_2_10_10_10_REV */
  31167. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31168. /** UNSIGNED_INT_24_8 */
  31169. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31170. /** UNSIGNED_INT_10F_11F_11F_REV */
  31171. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31172. /** UNSIGNED_INT_5_9_9_9_REV */
  31173. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31174. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31175. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31176. /** nearest is mag = nearest and min = nearest and mip = linear */
  31177. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31178. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31179. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31180. /** Trilinear is mag = linear and min = linear and mip = linear */
  31181. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31182. /** nearest is mag = nearest and min = nearest and mip = linear */
  31183. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31185. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31186. /** Trilinear is mag = linear and min = linear and mip = linear */
  31187. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31188. /** mag = nearest and min = nearest and mip = nearest */
  31189. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31190. /** mag = nearest and min = linear and mip = nearest */
  31191. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31192. /** mag = nearest and min = linear and mip = linear */
  31193. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31194. /** mag = nearest and min = linear and mip = none */
  31195. static readonly TEXTURE_NEAREST_LINEAR: number;
  31196. /** mag = nearest and min = nearest and mip = none */
  31197. static readonly TEXTURE_NEAREST_NEAREST: number;
  31198. /** mag = linear and min = nearest and mip = nearest */
  31199. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31200. /** mag = linear and min = nearest and mip = linear */
  31201. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31202. /** mag = linear and min = linear and mip = none */
  31203. static readonly TEXTURE_LINEAR_LINEAR: number;
  31204. /** mag = linear and min = nearest and mip = none */
  31205. static readonly TEXTURE_LINEAR_NEAREST: number;
  31206. /** Explicit coordinates mode */
  31207. static readonly TEXTURE_EXPLICIT_MODE: number;
  31208. /** Spherical coordinates mode */
  31209. static readonly TEXTURE_SPHERICAL_MODE: number;
  31210. /** Planar coordinates mode */
  31211. static readonly TEXTURE_PLANAR_MODE: number;
  31212. /** Cubic coordinates mode */
  31213. static readonly TEXTURE_CUBIC_MODE: number;
  31214. /** Projection coordinates mode */
  31215. static readonly TEXTURE_PROJECTION_MODE: number;
  31216. /** Skybox coordinates mode */
  31217. static readonly TEXTURE_SKYBOX_MODE: number;
  31218. /** Inverse Cubic coordinates mode */
  31219. static readonly TEXTURE_INVCUBIC_MODE: number;
  31220. /** Equirectangular coordinates mode */
  31221. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31222. /** Equirectangular Fixed coordinates mode */
  31223. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31224. /** Equirectangular Fixed Mirrored coordinates mode */
  31225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31226. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31227. static readonly SCALEMODE_FLOOR: number;
  31228. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31229. static readonly SCALEMODE_NEAREST: number;
  31230. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31231. static readonly SCALEMODE_CEILING: number;
  31232. /**
  31233. * Returns the current npm package of the sdk
  31234. */
  31235. static readonly NpmPackage: string;
  31236. /**
  31237. * Returns the current version of the framework
  31238. */
  31239. static readonly Version: string;
  31240. /** Gets the list of created engines */
  31241. static readonly Instances: Engine[];
  31242. /**
  31243. * Gets the latest created engine
  31244. */
  31245. static readonly LastCreatedEngine: Nullable<Engine>;
  31246. /**
  31247. * Gets the latest created scene
  31248. */
  31249. static readonly LastCreatedScene: Nullable<Scene>;
  31250. /**
  31251. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31252. * @param flag defines which part of the materials must be marked as dirty
  31253. * @param predicate defines a predicate used to filter which materials should be affected
  31254. */
  31255. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31256. /**
  31257. * Method called to create the default loading screen.
  31258. * This can be overriden in your own app.
  31259. * @param canvas The rendering canvas element
  31260. * @returns The loading screen
  31261. */
  31262. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31263. /**
  31264. * Method called to create the default rescale post process on each engine.
  31265. */
  31266. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31267. /**
  31268. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31269. **/
  31270. enableOfflineSupport: boolean;
  31271. /**
  31272. * 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)
  31273. **/
  31274. disableManifestCheck: boolean;
  31275. /**
  31276. * Gets the list of created scenes
  31277. */
  31278. scenes: Scene[];
  31279. /**
  31280. * Event raised when a new scene is created
  31281. */
  31282. onNewSceneAddedObservable: Observable<Scene>;
  31283. /**
  31284. * Gets the list of created postprocesses
  31285. */
  31286. postProcesses: PostProcess[];
  31287. /**
  31288. * Gets a boolean indicating if the pointer is currently locked
  31289. */
  31290. isPointerLock: boolean;
  31291. /**
  31292. * Observable event triggered each time the rendering canvas is resized
  31293. */
  31294. onResizeObservable: Observable<Engine>;
  31295. /**
  31296. * Observable event triggered each time the canvas loses focus
  31297. */
  31298. onCanvasBlurObservable: Observable<Engine>;
  31299. /**
  31300. * Observable event triggered each time the canvas gains focus
  31301. */
  31302. onCanvasFocusObservable: Observable<Engine>;
  31303. /**
  31304. * Observable event triggered each time the canvas receives pointerout event
  31305. */
  31306. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31307. /**
  31308. * Observable raised when the engine begins a new frame
  31309. */
  31310. onBeginFrameObservable: Observable<Engine>;
  31311. /**
  31312. * If set, will be used to request the next animation frame for the render loop
  31313. */
  31314. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31315. /**
  31316. * Observable raised when the engine ends the current frame
  31317. */
  31318. onEndFrameObservable: Observable<Engine>;
  31319. /**
  31320. * Observable raised when the engine is about to compile a shader
  31321. */
  31322. onBeforeShaderCompilationObservable: Observable<Engine>;
  31323. /**
  31324. * Observable raised when the engine has jsut compiled a shader
  31325. */
  31326. onAfterShaderCompilationObservable: Observable<Engine>;
  31327. /**
  31328. * Gets the audio engine
  31329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31330. * @ignorenaming
  31331. */
  31332. static audioEngine: IAudioEngine;
  31333. /**
  31334. * Default AudioEngine factory responsible of creating the Audio Engine.
  31335. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31336. */
  31337. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31338. /**
  31339. * Default offline support factory responsible of creating a tool used to store data locally.
  31340. * By default, this will create a Database object if the workload has been embedded.
  31341. */
  31342. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31343. private _loadingScreen;
  31344. private _pointerLockRequested;
  31345. private _dummyFramebuffer;
  31346. private _rescalePostProcess;
  31347. /** @hidden */
  31348. protected _alphaMode: number;
  31349. /** @hidden */
  31350. protected _alphaEquation: number;
  31351. private _deterministicLockstep;
  31352. private _lockstepMaxSteps;
  31353. protected readonly _supportsHardwareTextureRescaling: boolean;
  31354. private _fps;
  31355. private _deltaTime;
  31356. /** @hidden */
  31357. _drawCalls: PerfCounter;
  31358. /**
  31359. * Turn this value on if you want to pause FPS computation when in background
  31360. */
  31361. disablePerformanceMonitorInBackground: boolean;
  31362. private _performanceMonitor;
  31363. /**
  31364. * Gets the performance monitor attached to this engine
  31365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31366. */
  31367. readonly performanceMonitor: PerformanceMonitor;
  31368. private _onFocus;
  31369. private _onBlur;
  31370. private _onCanvasPointerOut;
  31371. private _onCanvasBlur;
  31372. private _onCanvasFocus;
  31373. private _onFullscreenChange;
  31374. private _onPointerLockChange;
  31375. /**
  31376. * Creates a new engine
  31377. * @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
  31378. * @param antialias defines enable antialiasing (default: false)
  31379. * @param options defines further options to be sent to the getContext() function
  31380. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31381. */
  31382. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31383. /**
  31384. * Gets current aspect ratio
  31385. * @param viewportOwner defines the camera to use to get the aspect ratio
  31386. * @param useScreen defines if screen size must be used (or the current render target if any)
  31387. * @returns a number defining the aspect ratio
  31388. */
  31389. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31390. /**
  31391. * Gets current screen aspect ratio
  31392. * @returns a number defining the aspect ratio
  31393. */
  31394. getScreenAspectRatio(): number;
  31395. /**
  31396. * Gets host document
  31397. * @returns the host document object
  31398. */
  31399. getHostDocument(): Document;
  31400. /**
  31401. * Gets the client rect of the HTML canvas attached with the current webGL context
  31402. * @returns a client rectanglee
  31403. */
  31404. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31405. /**
  31406. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31407. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31408. * @returns true if engine is in deterministic lock step mode
  31409. */
  31410. isDeterministicLockStep(): boolean;
  31411. /**
  31412. * Gets the max steps when engine is running in deterministic lock step
  31413. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31414. * @returns the max steps
  31415. */
  31416. getLockstepMaxSteps(): number;
  31417. /**
  31418. * Force the mipmap generation for the given render target texture
  31419. * @param texture defines the render target texture to use
  31420. */
  31421. generateMipMapsForCubemap(texture: InternalTexture): void;
  31422. /** States */
  31423. /**
  31424. * Set various states to the webGL context
  31425. * @param culling defines backface culling state
  31426. * @param zOffset defines the value to apply to zOffset (0 by default)
  31427. * @param force defines if states must be applied even if cache is up to date
  31428. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31429. */
  31430. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31431. /**
  31432. * Set the z offset to apply to current rendering
  31433. * @param value defines the offset to apply
  31434. */
  31435. setZOffset(value: number): void;
  31436. /**
  31437. * Gets the current value of the zOffset
  31438. * @returns the current zOffset state
  31439. */
  31440. getZOffset(): number;
  31441. /**
  31442. * Enable or disable depth buffering
  31443. * @param enable defines the state to set
  31444. */
  31445. setDepthBuffer(enable: boolean): void;
  31446. /**
  31447. * Gets a boolean indicating if depth writing is enabled
  31448. * @returns the current depth writing state
  31449. */
  31450. getDepthWrite(): boolean;
  31451. /**
  31452. * Enable or disable depth writing
  31453. * @param enable defines the state to set
  31454. */
  31455. setDepthWrite(enable: boolean): void;
  31456. /**
  31457. * Enable or disable color writing
  31458. * @param enable defines the state to set
  31459. */
  31460. setColorWrite(enable: boolean): void;
  31461. /**
  31462. * Gets a boolean indicating if color writing is enabled
  31463. * @returns the current color writing state
  31464. */
  31465. getColorWrite(): boolean;
  31466. /**
  31467. * Sets alpha constants used by some alpha blending modes
  31468. * @param r defines the red component
  31469. * @param g defines the green component
  31470. * @param b defines the blue component
  31471. * @param a defines the alpha component
  31472. */
  31473. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31474. /**
  31475. * Sets the current alpha mode
  31476. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31477. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31479. */
  31480. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31481. /**
  31482. * Gets the current alpha mode
  31483. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31484. * @returns the current alpha mode
  31485. */
  31486. getAlphaMode(): number;
  31487. /**
  31488. * Sets the current alpha equation
  31489. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31490. */
  31491. setAlphaEquation(equation: number): void;
  31492. /**
  31493. * Gets the current alpha equation.
  31494. * @returns the current alpha equation
  31495. */
  31496. getAlphaEquation(): number;
  31497. /**
  31498. * Gets a boolean indicating if stencil buffer is enabled
  31499. * @returns the current stencil buffer state
  31500. */
  31501. getStencilBuffer(): boolean;
  31502. /**
  31503. * Enable or disable the stencil buffer
  31504. * @param enable defines if the stencil buffer must be enabled or disabled
  31505. */
  31506. setStencilBuffer(enable: boolean): void;
  31507. /**
  31508. * Gets the current stencil mask
  31509. * @returns a number defining the new stencil mask to use
  31510. */
  31511. getStencilMask(): number;
  31512. /**
  31513. * Sets the current stencil mask
  31514. * @param mask defines the new stencil mask to use
  31515. */
  31516. setStencilMask(mask: number): void;
  31517. /**
  31518. * Gets the current stencil function
  31519. * @returns a number defining the stencil function to use
  31520. */
  31521. getStencilFunction(): number;
  31522. /**
  31523. * Gets the current stencil reference value
  31524. * @returns a number defining the stencil reference value to use
  31525. */
  31526. getStencilFunctionReference(): number;
  31527. /**
  31528. * Gets the current stencil mask
  31529. * @returns a number defining the stencil mask to use
  31530. */
  31531. getStencilFunctionMask(): number;
  31532. /**
  31533. * Sets the current stencil function
  31534. * @param stencilFunc defines the new stencil function to use
  31535. */
  31536. setStencilFunction(stencilFunc: number): void;
  31537. /**
  31538. * Sets the current stencil reference
  31539. * @param reference defines the new stencil reference to use
  31540. */
  31541. setStencilFunctionReference(reference: number): void;
  31542. /**
  31543. * Sets the current stencil mask
  31544. * @param mask defines the new stencil mask to use
  31545. */
  31546. setStencilFunctionMask(mask: number): void;
  31547. /**
  31548. * Gets the current stencil operation when stencil fails
  31549. * @returns a number defining stencil operation to use when stencil fails
  31550. */
  31551. getStencilOperationFail(): number;
  31552. /**
  31553. * Gets the current stencil operation when depth fails
  31554. * @returns a number defining stencil operation to use when depth fails
  31555. */
  31556. getStencilOperationDepthFail(): number;
  31557. /**
  31558. * Gets the current stencil operation when stencil passes
  31559. * @returns a number defining stencil operation to use when stencil passes
  31560. */
  31561. getStencilOperationPass(): number;
  31562. /**
  31563. * Sets the stencil operation to use when stencil fails
  31564. * @param operation defines the stencil operation to use when stencil fails
  31565. */
  31566. setStencilOperationFail(operation: number): void;
  31567. /**
  31568. * Sets the stencil operation to use when depth fails
  31569. * @param operation defines the stencil operation to use when depth fails
  31570. */
  31571. setStencilOperationDepthFail(operation: number): void;
  31572. /**
  31573. * Sets the stencil operation to use when stencil passes
  31574. * @param operation defines the stencil operation to use when stencil passes
  31575. */
  31576. setStencilOperationPass(operation: number): void;
  31577. /**
  31578. * Sets a boolean indicating if the dithering state is enabled or disabled
  31579. * @param value defines the dithering state
  31580. */
  31581. setDitheringState(value: boolean): void;
  31582. /**
  31583. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31584. * @param value defines the rasterizer state
  31585. */
  31586. setRasterizerState(value: boolean): void;
  31587. /**
  31588. * Gets the current depth function
  31589. * @returns a number defining the depth function
  31590. */
  31591. getDepthFunction(): Nullable<number>;
  31592. /**
  31593. * Sets the current depth function
  31594. * @param depthFunc defines the function to use
  31595. */
  31596. setDepthFunction(depthFunc: number): void;
  31597. /**
  31598. * Sets the current depth function to GREATER
  31599. */
  31600. setDepthFunctionToGreater(): void;
  31601. /**
  31602. * Sets the current depth function to GEQUAL
  31603. */
  31604. setDepthFunctionToGreaterOrEqual(): void;
  31605. /**
  31606. * Sets the current depth function to LESS
  31607. */
  31608. setDepthFunctionToLess(): void;
  31609. /**
  31610. * Sets the current depth function to LEQUAL
  31611. */
  31612. setDepthFunctionToLessOrEqual(): void;
  31613. private _cachedStencilBuffer;
  31614. private _cachedStencilFunction;
  31615. private _cachedStencilMask;
  31616. private _cachedStencilOperationPass;
  31617. private _cachedStencilOperationFail;
  31618. private _cachedStencilOperationDepthFail;
  31619. private _cachedStencilReference;
  31620. /**
  31621. * Caches the the state of the stencil buffer
  31622. */
  31623. cacheStencilState(): void;
  31624. /**
  31625. * Restores the state of the stencil buffer
  31626. */
  31627. restoreStencilState(): void;
  31628. /**
  31629. * Directly set the WebGL Viewport
  31630. * @param x defines the x coordinate of the viewport (in screen space)
  31631. * @param y defines the y coordinate of the viewport (in screen space)
  31632. * @param width defines the width of the viewport (in screen space)
  31633. * @param height defines the height of the viewport (in screen space)
  31634. * @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
  31635. */
  31636. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31637. /**
  31638. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31639. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31640. * @param y defines the y-coordinate of the corner of the clear rectangle
  31641. * @param width defines the width of the clear rectangle
  31642. * @param height defines the height of the clear rectangle
  31643. * @param clearColor defines the clear color
  31644. */
  31645. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31646. /**
  31647. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31648. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31649. * @param y defines the y-coordinate of the corner of the clear rectangle
  31650. * @param width defines the width of the clear rectangle
  31651. * @param height defines the height of the clear rectangle
  31652. */
  31653. enableScissor(x: number, y: number, width: number, height: number): void;
  31654. /**
  31655. * Disable previously set scissor test rectangle
  31656. */
  31657. disableScissor(): void;
  31658. protected _reportDrawCall(): void;
  31659. /**
  31660. * Initializes a webVR display and starts listening to display change events
  31661. * The onVRDisplayChangedObservable will be notified upon these changes
  31662. * @returns The onVRDisplayChangedObservable
  31663. */
  31664. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31665. /** @hidden */
  31666. _prepareVRComponent(): void;
  31667. /** @hidden */
  31668. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31669. /** @hidden */
  31670. _submitVRFrame(): void;
  31671. /**
  31672. * Call this function to leave webVR mode
  31673. * Will do nothing if webVR is not supported or if there is no webVR device
  31674. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31675. */
  31676. disableVR(): void;
  31677. /**
  31678. * Gets a boolean indicating that the system is in VR mode and is presenting
  31679. * @returns true if VR mode is engaged
  31680. */
  31681. isVRPresenting(): boolean;
  31682. /** @hidden */
  31683. _requestVRFrame(): void;
  31684. /** @hidden */
  31685. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31686. /**
  31687. * Gets the source code of the vertex shader associated with a specific webGL program
  31688. * @param program defines the program to use
  31689. * @returns a string containing the source code of the vertex shader associated with the program
  31690. */
  31691. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31692. /**
  31693. * Gets the source code of the fragment shader associated with a specific webGL program
  31694. * @param program defines the program to use
  31695. * @returns a string containing the source code of the fragment shader associated with the program
  31696. */
  31697. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31698. /**
  31699. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31700. * @param x defines the x coordinate of the rectangle where pixels must be read
  31701. * @param y defines the y coordinate of the rectangle where pixels must be read
  31702. * @param width defines the width of the rectangle where pixels must be read
  31703. * @param height defines the height of the rectangle where pixels must be read
  31704. * @returns a Uint8Array containing RGBA colors
  31705. */
  31706. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31707. /**
  31708. * Sets a depth stencil texture from a render target to the according uniform.
  31709. * @param channel The texture channel
  31710. * @param uniform The uniform to set
  31711. * @param texture The render target texture containing the depth stencil texture to apply
  31712. */
  31713. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31714. /**
  31715. * Sets a texture to the webGL context from a postprocess
  31716. * @param channel defines the channel to use
  31717. * @param postProcess defines the source postprocess
  31718. */
  31719. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31720. /**
  31721. * Binds the output of the passed in post process to the texture channel specified
  31722. * @param channel The channel the texture should be bound to
  31723. * @param postProcess The post process which's output should be bound
  31724. */
  31725. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31726. /** @hidden */
  31727. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31728. protected _rebuildBuffers(): void;
  31729. _renderLoop(): void;
  31730. /**
  31731. * Toggle full screen mode
  31732. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31733. */
  31734. switchFullscreen(requestPointerLock: boolean): void;
  31735. /**
  31736. * Enters full screen mode
  31737. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31738. */
  31739. enterFullscreen(requestPointerLock: boolean): void;
  31740. /**
  31741. * Exits full screen mode
  31742. */
  31743. exitFullscreen(): void;
  31744. /**
  31745. * Enters Pointerlock mode
  31746. */
  31747. enterPointerlock(): void;
  31748. /**
  31749. * Exits Pointerlock mode
  31750. */
  31751. exitPointerlock(): void;
  31752. /**
  31753. * Begin a new frame
  31754. */
  31755. beginFrame(): void;
  31756. /**
  31757. * Enf the current frame
  31758. */
  31759. endFrame(): void;
  31760. resize(): void;
  31761. /**
  31762. * Set the compressed texture format to use, based on the formats you have, and the formats
  31763. * supported by the hardware / browser.
  31764. *
  31765. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31766. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31767. * to API arguments needed to compressed textures. This puts the burden on the container
  31768. * generator to house the arcane code for determining these for current & future formats.
  31769. *
  31770. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31771. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31772. *
  31773. * Note: The result of this call is not taken into account when a texture is base64.
  31774. *
  31775. * @param formatsAvailable defines the list of those format families you have created
  31776. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31777. *
  31778. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31779. * @returns The extension selected.
  31780. */
  31781. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31782. /**
  31783. * Force a specific size of the canvas
  31784. * @param width defines the new canvas' width
  31785. * @param height defines the new canvas' height
  31786. */
  31787. setSize(width: number, height: number): void;
  31788. /**
  31789. * Updates a dynamic vertex buffer.
  31790. * @param vertexBuffer the vertex buffer to update
  31791. * @param data the data used to update the vertex buffer
  31792. * @param byteOffset the byte offset of the data
  31793. * @param byteLength the byte length of the data
  31794. */
  31795. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31796. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31797. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31798. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31799. _releaseTexture(texture: InternalTexture): void;
  31800. /**
  31801. * @hidden
  31802. * Rescales a texture
  31803. * @param source input texutre
  31804. * @param destination destination texture
  31805. * @param scene scene to use to render the resize
  31806. * @param internalFormat format to use when resizing
  31807. * @param onComplete callback to be called when resize has completed
  31808. */
  31809. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31810. /**
  31811. * Gets the current framerate
  31812. * @returns a number representing the framerate
  31813. */
  31814. getFps(): number;
  31815. /**
  31816. * Gets the time spent between current and previous frame
  31817. * @returns a number representing the delta time in ms
  31818. */
  31819. getDeltaTime(): number;
  31820. private _measureFps;
  31821. /** @hidden */
  31822. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  31823. /**
  31824. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31825. * @param renderTarget The render target to set the frame buffer for
  31826. */
  31827. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31828. /**
  31829. * Update a dynamic index buffer
  31830. * @param indexBuffer defines the target index buffer
  31831. * @param indices defines the data to update
  31832. * @param offset defines the offset in the target index buffer where update should start
  31833. */
  31834. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31835. /**
  31836. * Updates the sample count of a render target texture
  31837. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31838. * @param texture defines the texture to update
  31839. * @param samples defines the sample count to set
  31840. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31841. */
  31842. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31843. /**
  31844. * Creates a webGL buffer to use with instanciation
  31845. * @param capacity defines the size of the buffer
  31846. * @returns the webGL buffer
  31847. */
  31848. createInstancesBuffer(capacity: number): DataBuffer;
  31849. /**
  31850. * Delete a webGL buffer used with instanciation
  31851. * @param buffer defines the webGL buffer to delete
  31852. */
  31853. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31854. /** @hidden */
  31855. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31856. dispose(): void;
  31857. private _disableTouchAction;
  31858. /**
  31859. * Display the loading screen
  31860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31861. */
  31862. displayLoadingUI(): void;
  31863. /**
  31864. * Hide the loading screen
  31865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31866. */
  31867. hideLoadingUI(): void;
  31868. /**
  31869. * Gets the current loading screen object
  31870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31871. */
  31872. /**
  31873. * Sets the current loading screen object
  31874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31875. */
  31876. loadingScreen: ILoadingScreen;
  31877. /**
  31878. * Sets the current loading screen text
  31879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31880. */
  31881. loadingUIText: string;
  31882. /**
  31883. * Sets the current loading screen background color
  31884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31885. */
  31886. loadingUIBackgroundColor: string;
  31887. /** Pointerlock and fullscreen */
  31888. /**
  31889. * Ask the browser to promote the current element to pointerlock mode
  31890. * @param element defines the DOM element to promote
  31891. */
  31892. static _RequestPointerlock(element: HTMLElement): void;
  31893. /**
  31894. * Asks the browser to exit pointerlock mode
  31895. */
  31896. static _ExitPointerlock(): void;
  31897. /**
  31898. * Ask the browser to promote the current element to fullscreen rendering mode
  31899. * @param element defines the DOM element to promote
  31900. */
  31901. static _RequestFullscreen(element: HTMLElement): void;
  31902. /**
  31903. * Asks the browser to exit fullscreen mode
  31904. */
  31905. static _ExitFullscreen(): void;
  31906. }
  31907. }
  31908. declare module BABYLON {
  31909. /**
  31910. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31911. * during the life time of the application.
  31912. */
  31913. export class EngineStore {
  31914. /** Gets the list of created engines */
  31915. static Instances: Engine[];
  31916. /** @hidden */
  31917. static _LastCreatedScene: Nullable<Scene>;
  31918. /**
  31919. * Gets the latest created engine
  31920. */
  31921. static readonly LastCreatedEngine: Nullable<Engine>;
  31922. /**
  31923. * Gets the latest created scene
  31924. */
  31925. static readonly LastCreatedScene: Nullable<Scene>;
  31926. /**
  31927. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31928. * @ignorenaming
  31929. */
  31930. static UseFallbackTexture: boolean;
  31931. /**
  31932. * Texture content used if a texture cannot loaded
  31933. * @ignorenaming
  31934. */
  31935. static FallbackTexture: string;
  31936. }
  31937. }
  31938. declare module BABYLON {
  31939. /**
  31940. * Helper class that provides a small promise polyfill
  31941. */
  31942. export class PromisePolyfill {
  31943. /**
  31944. * Static function used to check if the polyfill is required
  31945. * If this is the case then the function will inject the polyfill to window.Promise
  31946. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31947. */
  31948. static Apply(force?: boolean): void;
  31949. }
  31950. }
  31951. declare module BABYLON {
  31952. /**
  31953. * Interface for screenshot methods with describe argument called `size` as object with options
  31954. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31955. */
  31956. export interface IScreenshotSize {
  31957. /**
  31958. * number in pixels for canvas height
  31959. */
  31960. height?: number;
  31961. /**
  31962. * multiplier allowing render at a higher or lower resolution
  31963. * If value is defined then height and width will be ignored and taken from camera
  31964. */
  31965. precision?: number;
  31966. /**
  31967. * number in pixels for canvas width
  31968. */
  31969. width?: number;
  31970. }
  31971. }
  31972. declare module BABYLON {
  31973. interface IColor4Like {
  31974. r: float;
  31975. g: float;
  31976. b: float;
  31977. a: float;
  31978. }
  31979. /**
  31980. * Class containing a set of static utilities functions
  31981. */
  31982. export class Tools {
  31983. /**
  31984. * Gets or sets the base URL to use to load assets
  31985. */
  31986. static BaseUrl: string;
  31987. /**
  31988. * Enable/Disable Custom HTTP Request Headers globally.
  31989. * default = false
  31990. * @see CustomRequestHeaders
  31991. */
  31992. static UseCustomRequestHeaders: boolean;
  31993. /**
  31994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31995. * i.e. when loading files, where the server/service expects an Authorization header
  31996. */
  31997. static CustomRequestHeaders: {
  31998. [key: string]: string;
  31999. };
  32000. /**
  32001. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32002. */
  32003. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32004. /**
  32005. * Default behaviour for cors in the application.
  32006. * It can be a string if the expected behavior is identical in the entire app.
  32007. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32008. */
  32009. static CorsBehavior: string | ((url: string | string[]) => string);
  32010. /**
  32011. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32012. * @ignorenaming
  32013. */
  32014. static UseFallbackTexture: boolean;
  32015. /**
  32016. * Use this object to register external classes like custom textures or material
  32017. * to allow the laoders to instantiate them
  32018. */
  32019. static RegisteredExternalClasses: {
  32020. [key: string]: Object;
  32021. };
  32022. /**
  32023. * Texture content used if a texture cannot loaded
  32024. * @ignorenaming
  32025. */
  32026. static fallbackTexture: string;
  32027. /**
  32028. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32029. * @param u defines the coordinate on X axis
  32030. * @param v defines the coordinate on Y axis
  32031. * @param width defines the width of the source data
  32032. * @param height defines the height of the source data
  32033. * @param pixels defines the source byte array
  32034. * @param color defines the output color
  32035. */
  32036. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32037. /**
  32038. * Interpolates between a and b via alpha
  32039. * @param a The lower value (returned when alpha = 0)
  32040. * @param b The upper value (returned when alpha = 1)
  32041. * @param alpha The interpolation-factor
  32042. * @return The mixed value
  32043. */
  32044. static Mix(a: number, b: number, alpha: number): number;
  32045. /**
  32046. * Tries to instantiate a new object from a given class name
  32047. * @param className defines the class name to instantiate
  32048. * @returns the new object or null if the system was not able to do the instantiation
  32049. */
  32050. static Instantiate(className: string): any;
  32051. /**
  32052. * Provides a slice function that will work even on IE
  32053. * @param data defines the array to slice
  32054. * @param start defines the start of the data (optional)
  32055. * @param end defines the end of the data (optional)
  32056. * @returns the new sliced array
  32057. */
  32058. static Slice<T>(data: T, start?: number, end?: number): T;
  32059. /**
  32060. * Polyfill for setImmediate
  32061. * @param action defines the action to execute after the current execution block
  32062. */
  32063. static SetImmediate(action: () => void): void;
  32064. /**
  32065. * Function indicating if a number is an exponent of 2
  32066. * @param value defines the value to test
  32067. * @returns true if the value is an exponent of 2
  32068. */
  32069. static IsExponentOfTwo(value: number): boolean;
  32070. private static _tmpFloatArray;
  32071. /**
  32072. * Returns the nearest 32-bit single precision float representation of a Number
  32073. * @param value A Number. If the parameter is of a different type, it will get converted
  32074. * to a number or to NaN if it cannot be converted
  32075. * @returns number
  32076. */
  32077. static FloatRound(value: number): number;
  32078. /**
  32079. * Extracts the filename from a path
  32080. * @param path defines the path to use
  32081. * @returns the filename
  32082. */
  32083. static GetFilename(path: string): string;
  32084. /**
  32085. * Extracts the "folder" part of a path (everything before the filename).
  32086. * @param uri The URI to extract the info from
  32087. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32088. * @returns The "folder" part of the path
  32089. */
  32090. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32091. /**
  32092. * Extracts text content from a DOM element hierarchy
  32093. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32094. */
  32095. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32096. /**
  32097. * Convert an angle in radians to degrees
  32098. * @param angle defines the angle to convert
  32099. * @returns the angle in degrees
  32100. */
  32101. static ToDegrees(angle: number): number;
  32102. /**
  32103. * Convert an angle in degrees to radians
  32104. * @param angle defines the angle to convert
  32105. * @returns the angle in radians
  32106. */
  32107. static ToRadians(angle: number): number;
  32108. /**
  32109. * Returns an array if obj is not an array
  32110. * @param obj defines the object to evaluate as an array
  32111. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32112. * @returns either obj directly if obj is an array or a new array containing obj
  32113. */
  32114. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32115. /**
  32116. * Gets the pointer prefix to use
  32117. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32118. */
  32119. static GetPointerPrefix(): string;
  32120. /**
  32121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32122. * @param url define the url we are trying
  32123. * @param element define the dom element where to configure the cors policy
  32124. */
  32125. static SetCorsBehavior(url: string | string[], element: {
  32126. crossOrigin: string | null;
  32127. }): void;
  32128. /**
  32129. * Removes unwanted characters from an url
  32130. * @param url defines the url to clean
  32131. * @returns the cleaned url
  32132. */
  32133. static CleanUrl(url: string): string;
  32134. /**
  32135. * Gets or sets a function used to pre-process url before using them to load assets
  32136. */
  32137. static PreprocessUrl: (url: string) => string;
  32138. /**
  32139. * Loads an image as an HTMLImageElement.
  32140. * @param input url string, ArrayBuffer, or Blob to load
  32141. * @param onLoad callback called when the image successfully loads
  32142. * @param onError callback called when the image fails to load
  32143. * @param offlineProvider offline provider for caching
  32144. * @param mimeType optional mime type
  32145. * @returns the HTMLImageElement of the loaded image
  32146. */
  32147. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32148. /**
  32149. * Loads a file from a url
  32150. * @param url url string, ArrayBuffer, or Blob to load
  32151. * @param onSuccess callback called when the file successfully loads
  32152. * @param onProgress callback called while file is loading (if the server supports this mode)
  32153. * @param offlineProvider defines the offline provider for caching
  32154. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32155. * @param onError callback called when the file fails to load
  32156. * @returns a file request object
  32157. */
  32158. 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;
  32159. /**
  32160. * Loads a file from a url
  32161. * @param url the file url to load
  32162. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32163. */
  32164. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32165. /**
  32166. * Load a script (identified by an url). When the url returns, the
  32167. * content of this file is added into a new script element, attached to the DOM (body element)
  32168. * @param scriptUrl defines the url of the script to laod
  32169. * @param onSuccess defines the callback called when the script is loaded
  32170. * @param onError defines the callback to call if an error occurs
  32171. * @param scriptId defines the id of the script element
  32172. */
  32173. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32174. /**
  32175. * Load an asynchronous script (identified by an url). When the url returns, the
  32176. * content of this file is added into a new script element, attached to the DOM (body element)
  32177. * @param scriptUrl defines the url of the script to laod
  32178. * @param scriptId defines the id of the script element
  32179. * @returns a promise request object
  32180. */
  32181. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32182. /**
  32183. * Loads a file from a blob
  32184. * @param fileToLoad defines the blob to use
  32185. * @param callback defines the callback to call when data is loaded
  32186. * @param progressCallback defines the callback to call during loading process
  32187. * @returns a file request object
  32188. */
  32189. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32190. /**
  32191. * Reads a file from a File object
  32192. * @param file defines the file to load
  32193. * @param onSuccess defines the callback to call when data is loaded
  32194. * @param onProgress defines the callback to call during loading process
  32195. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32196. * @param onError defines the callback to call when an error occurs
  32197. * @returns a file request object
  32198. */
  32199. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32200. /**
  32201. * Creates a data url from a given string content
  32202. * @param content defines the content to convert
  32203. * @returns the new data url link
  32204. */
  32205. static FileAsURL(content: string): string;
  32206. /**
  32207. * Format the given number to a specific decimal format
  32208. * @param value defines the number to format
  32209. * @param decimals defines the number of decimals to use
  32210. * @returns the formatted string
  32211. */
  32212. static Format(value: number, decimals?: number): string;
  32213. /**
  32214. * Tries to copy an object by duplicating every property
  32215. * @param source defines the source object
  32216. * @param destination defines the target object
  32217. * @param doNotCopyList defines a list of properties to avoid
  32218. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32219. */
  32220. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32221. /**
  32222. * Gets a boolean indicating if the given object has no own property
  32223. * @param obj defines the object to test
  32224. * @returns true if object has no own property
  32225. */
  32226. static IsEmpty(obj: any): boolean;
  32227. /**
  32228. * Function used to register events at window level
  32229. * @param windowElement defines the Window object to use
  32230. * @param events defines the events to register
  32231. */
  32232. static RegisterTopRootEvents(windowElement: Window, events: {
  32233. name: string;
  32234. handler: Nullable<(e: FocusEvent) => any>;
  32235. }[]): void;
  32236. /**
  32237. * Function used to unregister events from window level
  32238. * @param windowElement defines the Window object to use
  32239. * @param events defines the events to unregister
  32240. */
  32241. static UnregisterTopRootEvents(windowElement: Window, events: {
  32242. name: string;
  32243. handler: Nullable<(e: FocusEvent) => any>;
  32244. }[]): void;
  32245. /**
  32246. * @ignore
  32247. */
  32248. static _ScreenshotCanvas: HTMLCanvasElement;
  32249. /**
  32250. * Dumps the current bound framebuffer
  32251. * @param width defines the rendering width
  32252. * @param height defines the rendering height
  32253. * @param engine defines the hosting engine
  32254. * @param successCallback defines the callback triggered once the data are available
  32255. * @param mimeType defines the mime type of the result
  32256. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32257. */
  32258. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32259. /**
  32260. * Converts the canvas data to blob.
  32261. * This acts as a polyfill for browsers not supporting the to blob function.
  32262. * @param canvas Defines the canvas to extract the data from
  32263. * @param successCallback Defines the callback triggered once the data are available
  32264. * @param mimeType Defines the mime type of the result
  32265. */
  32266. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32267. /**
  32268. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32269. * @param successCallback defines the callback triggered once the data are available
  32270. * @param mimeType defines the mime type of the result
  32271. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32272. */
  32273. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32274. /**
  32275. * Downloads a blob in the browser
  32276. * @param blob defines the blob to download
  32277. * @param fileName defines the name of the downloaded file
  32278. */
  32279. static Download(blob: Blob, fileName: string): void;
  32280. /**
  32281. * Captures a screenshot of the current rendering
  32282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32283. * @param engine defines the rendering engine
  32284. * @param camera defines the source camera
  32285. * @param size This parameter can be set to a single number or to an object with the
  32286. * following (optional) properties: precision, width, height. If a single number is passed,
  32287. * it will be used for both width and height. If an object is passed, the screenshot size
  32288. * will be derived from the parameters. The precision property is a multiplier allowing
  32289. * rendering at a higher or lower resolution
  32290. * @param successCallback defines the callback receives a single parameter which contains the
  32291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32292. * src parameter of an <img> to display it
  32293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32294. * Check your browser for supported MIME types
  32295. */
  32296. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32297. /**
  32298. * Captures a screenshot of the current rendering
  32299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32300. * @param engine defines the rendering engine
  32301. * @param camera defines the source camera
  32302. * @param size This parameter can be set to a single number or to an object with the
  32303. * following (optional) properties: precision, width, height. If a single number is passed,
  32304. * it will be used for both width and height. If an object is passed, the screenshot size
  32305. * will be derived from the parameters. The precision property is a multiplier allowing
  32306. * rendering at a higher or lower resolution
  32307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32308. * Check your browser for supported MIME types
  32309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32310. * to the src parameter of an <img> to display it
  32311. */
  32312. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32313. /**
  32314. * Generates an image screenshot from the specified camera.
  32315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32316. * @param engine The engine to use for rendering
  32317. * @param camera The camera to use for rendering
  32318. * @param size This parameter can be set to a single number or to an object with the
  32319. * following (optional) properties: precision, width, height. If a single number is passed,
  32320. * it will be used for both width and height. If an object is passed, the screenshot size
  32321. * will be derived from the parameters. The precision property is a multiplier allowing
  32322. * rendering at a higher or lower resolution
  32323. * @param successCallback The callback receives a single parameter which contains the
  32324. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32325. * src parameter of an <img> to display it
  32326. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32327. * Check your browser for supported MIME types
  32328. * @param samples Texture samples (default: 1)
  32329. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32330. * @param fileName A name for for the downloaded file.
  32331. */
  32332. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32333. /**
  32334. * Generates an image screenshot from the specified camera.
  32335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32336. * @param engine The engine to use for rendering
  32337. * @param camera The camera to use for rendering
  32338. * @param size This parameter can be set to a single number or to an object with the
  32339. * following (optional) properties: precision, width, height. If a single number is passed,
  32340. * it will be used for both width and height. If an object is passed, the screenshot size
  32341. * will be derived from the parameters. The precision property is a multiplier allowing
  32342. * rendering at a higher or lower resolution
  32343. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32344. * Check your browser for supported MIME types
  32345. * @param samples Texture samples (default: 1)
  32346. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32347. * @param fileName A name for for the downloaded file.
  32348. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32349. * to the src parameter of an <img> to display it
  32350. */
  32351. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32352. /**
  32353. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32354. * Be aware Math.random() could cause collisions, but:
  32355. * "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"
  32356. * @returns a pseudo random id
  32357. */
  32358. static RandomId(): string;
  32359. /**
  32360. * Test if the given uri is a base64 string
  32361. * @param uri The uri to test
  32362. * @return True if the uri is a base64 string or false otherwise
  32363. */
  32364. static IsBase64(uri: string): boolean;
  32365. /**
  32366. * Decode the given base64 uri.
  32367. * @param uri The uri to decode
  32368. * @return The decoded base64 data.
  32369. */
  32370. static DecodeBase64(uri: string): ArrayBuffer;
  32371. /**
  32372. * Gets the absolute url.
  32373. * @param url the input url
  32374. * @return the absolute url
  32375. */
  32376. static GetAbsoluteUrl(url: string): string;
  32377. /**
  32378. * No log
  32379. */
  32380. static readonly NoneLogLevel: number;
  32381. /**
  32382. * Only message logs
  32383. */
  32384. static readonly MessageLogLevel: number;
  32385. /**
  32386. * Only warning logs
  32387. */
  32388. static readonly WarningLogLevel: number;
  32389. /**
  32390. * Only error logs
  32391. */
  32392. static readonly ErrorLogLevel: number;
  32393. /**
  32394. * All logs
  32395. */
  32396. static readonly AllLogLevel: number;
  32397. /**
  32398. * Gets a value indicating the number of loading errors
  32399. * @ignorenaming
  32400. */
  32401. static readonly errorsCount: number;
  32402. /**
  32403. * Callback called when a new log is added
  32404. */
  32405. static OnNewCacheEntry: (entry: string) => void;
  32406. /**
  32407. * Log a message to the console
  32408. * @param message defines the message to log
  32409. */
  32410. static Log(message: string): void;
  32411. /**
  32412. * Write a warning message to the console
  32413. * @param message defines the message to log
  32414. */
  32415. static Warn(message: string): void;
  32416. /**
  32417. * Write an error message to the console
  32418. * @param message defines the message to log
  32419. */
  32420. static Error(message: string): void;
  32421. /**
  32422. * Gets current log cache (list of logs)
  32423. */
  32424. static readonly LogCache: string;
  32425. /**
  32426. * Clears the log cache
  32427. */
  32428. static ClearLogCache(): void;
  32429. /**
  32430. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32431. */
  32432. static LogLevels: number;
  32433. /**
  32434. * Checks if the window object exists
  32435. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32436. */
  32437. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32438. /**
  32439. * No performance log
  32440. */
  32441. static readonly PerformanceNoneLogLevel: number;
  32442. /**
  32443. * Use user marks to log performance
  32444. */
  32445. static readonly PerformanceUserMarkLogLevel: number;
  32446. /**
  32447. * Log performance to the console
  32448. */
  32449. static readonly PerformanceConsoleLogLevel: number;
  32450. private static _performance;
  32451. /**
  32452. * Sets the current performance log level
  32453. */
  32454. static PerformanceLogLevel: number;
  32455. private static _StartPerformanceCounterDisabled;
  32456. private static _EndPerformanceCounterDisabled;
  32457. private static _StartUserMark;
  32458. private static _EndUserMark;
  32459. private static _StartPerformanceConsole;
  32460. private static _EndPerformanceConsole;
  32461. /**
  32462. * Starts a performance counter
  32463. */
  32464. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32465. /**
  32466. * Ends a specific performance coutner
  32467. */
  32468. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32469. /**
  32470. * Gets either window.performance.now() if supported or Date.now() else
  32471. */
  32472. static readonly Now: number;
  32473. /**
  32474. * This method will return the name of the class used to create the instance of the given object.
  32475. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32476. * @param object the object to get the class name from
  32477. * @param isType defines if the object is actually a type
  32478. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32479. */
  32480. static GetClassName(object: any, isType?: boolean): string;
  32481. /**
  32482. * Gets the first element of an array satisfying a given predicate
  32483. * @param array defines the array to browse
  32484. * @param predicate defines the predicate to use
  32485. * @returns null if not found or the element
  32486. */
  32487. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32488. /**
  32489. * This method will return the name of the full name of the class, including its owning module (if any).
  32490. * 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).
  32491. * @param object the object to get the class name from
  32492. * @param isType defines if the object is actually a type
  32493. * @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.
  32494. * @ignorenaming
  32495. */
  32496. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32497. /**
  32498. * Returns a promise that resolves after the given amount of time.
  32499. * @param delay Number of milliseconds to delay
  32500. * @returns Promise that resolves after the given amount of time
  32501. */
  32502. static DelayAsync(delay: number): Promise<void>;
  32503. }
  32504. /**
  32505. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32506. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32507. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32508. * @param name The name of the class, case should be preserved
  32509. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32510. */
  32511. export function className(name: string, module?: string): (target: Object) => void;
  32512. /**
  32513. * An implementation of a loop for asynchronous functions.
  32514. */
  32515. export class AsyncLoop {
  32516. /**
  32517. * Defines the number of iterations for the loop
  32518. */
  32519. iterations: number;
  32520. /**
  32521. * Defines the current index of the loop.
  32522. */
  32523. index: number;
  32524. private _done;
  32525. private _fn;
  32526. private _successCallback;
  32527. /**
  32528. * Constructor.
  32529. * @param iterations the number of iterations.
  32530. * @param func the function to run each iteration
  32531. * @param successCallback the callback that will be called upon succesful execution
  32532. * @param offset starting offset.
  32533. */
  32534. constructor(
  32535. /**
  32536. * Defines the number of iterations for the loop
  32537. */
  32538. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32539. /**
  32540. * Execute the next iteration. Must be called after the last iteration was finished.
  32541. */
  32542. executeNext(): void;
  32543. /**
  32544. * Break the loop and run the success callback.
  32545. */
  32546. breakLoop(): void;
  32547. /**
  32548. * Create and run an async loop.
  32549. * @param iterations the number of iterations.
  32550. * @param fn the function to run each iteration
  32551. * @param successCallback the callback that will be called upon succesful execution
  32552. * @param offset starting offset.
  32553. * @returns the created async loop object
  32554. */
  32555. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32556. /**
  32557. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32558. * @param iterations total number of iterations
  32559. * @param syncedIterations number of synchronous iterations in each async iteration.
  32560. * @param fn the function to call each iteration.
  32561. * @param callback a success call back that will be called when iterating stops.
  32562. * @param breakFunction a break condition (optional)
  32563. * @param timeout timeout settings for the setTimeout function. default - 0.
  32564. * @returns the created async loop object
  32565. */
  32566. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32567. }
  32568. }
  32569. declare module BABYLON {
  32570. /**
  32571. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32572. * The underlying implementation relies on an associative array to ensure the best performances.
  32573. * The value can be anything including 'null' but except 'undefined'
  32574. */
  32575. export class StringDictionary<T> {
  32576. /**
  32577. * This will clear this dictionary and copy the content from the 'source' one.
  32578. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32579. * @param source the dictionary to take the content from and copy to this dictionary
  32580. */
  32581. copyFrom(source: StringDictionary<T>): void;
  32582. /**
  32583. * Get a value based from its key
  32584. * @param key the given key to get the matching value from
  32585. * @return the value if found, otherwise undefined is returned
  32586. */
  32587. get(key: string): T | undefined;
  32588. /**
  32589. * Get a value from its key or add it if it doesn't exist.
  32590. * This method will ensure you that a given key/data will be present in the dictionary.
  32591. * @param key the given key to get the matching value from
  32592. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32593. * The factory will only be invoked if there's no data for the given key.
  32594. * @return the value corresponding to the key.
  32595. */
  32596. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32597. /**
  32598. * Get a value from its key if present in the dictionary otherwise add it
  32599. * @param key the key to get the value from
  32600. * @param val if there's no such key/value pair in the dictionary add it with this value
  32601. * @return the value corresponding to the key
  32602. */
  32603. getOrAdd(key: string, val: T): T;
  32604. /**
  32605. * Check if there's a given key in the dictionary
  32606. * @param key the key to check for
  32607. * @return true if the key is present, false otherwise
  32608. */
  32609. contains(key: string): boolean;
  32610. /**
  32611. * Add a new key and its corresponding value
  32612. * @param key the key to add
  32613. * @param value the value corresponding to the key
  32614. * @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
  32615. */
  32616. add(key: string, value: T): boolean;
  32617. /**
  32618. * Update a specific value associated to a key
  32619. * @param key defines the key to use
  32620. * @param value defines the value to store
  32621. * @returns true if the value was updated (or false if the key was not found)
  32622. */
  32623. set(key: string, value: T): boolean;
  32624. /**
  32625. * Get the element of the given key and remove it from the dictionary
  32626. * @param key defines the key to search
  32627. * @returns the value associated with the key or null if not found
  32628. */
  32629. getAndRemove(key: string): Nullable<T>;
  32630. /**
  32631. * Remove a key/value from the dictionary.
  32632. * @param key the key to remove
  32633. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32634. */
  32635. remove(key: string): boolean;
  32636. /**
  32637. * Clear the whole content of the dictionary
  32638. */
  32639. clear(): void;
  32640. /**
  32641. * Gets the current count
  32642. */
  32643. readonly count: number;
  32644. /**
  32645. * Execute a callback on each key/val of the dictionary.
  32646. * Note that you can remove any element in this dictionary in the callback implementation
  32647. * @param callback the callback to execute on a given key/value pair
  32648. */
  32649. forEach(callback: (key: string, val: T) => void): void;
  32650. /**
  32651. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32652. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32653. * Note that you can remove any element in this dictionary in the callback implementation
  32654. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32655. * @returns the first item
  32656. */
  32657. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32658. private _count;
  32659. private _data;
  32660. }
  32661. }
  32662. declare module BABYLON {
  32663. /** @hidden */
  32664. export interface ICollisionCoordinator {
  32665. createCollider(): Collider;
  32666. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32667. init(scene: Scene): void;
  32668. }
  32669. /** @hidden */
  32670. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32671. private _scene;
  32672. private _scaledPosition;
  32673. private _scaledVelocity;
  32674. private _finalPosition;
  32675. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32676. createCollider(): Collider;
  32677. init(scene: Scene): void;
  32678. private _collideWithWorld;
  32679. }
  32680. }
  32681. declare module BABYLON {
  32682. /**
  32683. * Class used to manage all inputs for the scene.
  32684. */
  32685. export class InputManager {
  32686. /** The distance in pixel that you have to move to prevent some events */
  32687. static DragMovementThreshold: number;
  32688. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32689. static LongPressDelay: number;
  32690. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32691. static DoubleClickDelay: number;
  32692. /** If you need to check double click without raising a single click at first click, enable this flag */
  32693. static ExclusiveDoubleClickMode: boolean;
  32694. private _wheelEventName;
  32695. private _onPointerMove;
  32696. private _onPointerDown;
  32697. private _onPointerUp;
  32698. private _initClickEvent;
  32699. private _initActionManager;
  32700. private _delayedSimpleClick;
  32701. private _delayedSimpleClickTimeout;
  32702. private _previousDelayedSimpleClickTimeout;
  32703. private _meshPickProceed;
  32704. private _previousButtonPressed;
  32705. private _currentPickResult;
  32706. private _previousPickResult;
  32707. private _totalPointersPressed;
  32708. private _doubleClickOccured;
  32709. private _pointerOverMesh;
  32710. private _pickedDownMesh;
  32711. private _pickedUpMesh;
  32712. private _pointerX;
  32713. private _pointerY;
  32714. private _unTranslatedPointerX;
  32715. private _unTranslatedPointerY;
  32716. private _startingPointerPosition;
  32717. private _previousStartingPointerPosition;
  32718. private _startingPointerTime;
  32719. private _previousStartingPointerTime;
  32720. private _pointerCaptures;
  32721. private _onKeyDown;
  32722. private _onKeyUp;
  32723. private _onCanvasFocusObserver;
  32724. private _onCanvasBlurObserver;
  32725. private _scene;
  32726. /**
  32727. * Creates a new InputManager
  32728. * @param scene defines the hosting scene
  32729. */
  32730. constructor(scene: Scene);
  32731. /**
  32732. * Gets the mesh that is currently under the pointer
  32733. */
  32734. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32735. /**
  32736. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32737. */
  32738. readonly unTranslatedPointer: Vector2;
  32739. /**
  32740. * Gets or sets the current on-screen X position of the pointer
  32741. */
  32742. pointerX: number;
  32743. /**
  32744. * Gets or sets the current on-screen Y position of the pointer
  32745. */
  32746. pointerY: number;
  32747. private _updatePointerPosition;
  32748. private _processPointerMove;
  32749. private _setRayOnPointerInfo;
  32750. private _checkPrePointerObservable;
  32751. /**
  32752. * Use this method to simulate a pointer move on a mesh
  32753. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32754. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32755. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32756. */
  32757. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32758. /**
  32759. * Use this method to simulate a pointer down on a mesh
  32760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32763. */
  32764. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32765. private _processPointerDown;
  32766. /** @hidden */
  32767. _isPointerSwiping(): boolean;
  32768. /**
  32769. * Use this method to simulate a pointer up on a mesh
  32770. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32771. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32772. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32773. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32774. */
  32775. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32776. private _processPointerUp;
  32777. /**
  32778. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32779. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32780. * @returns true if the pointer was captured
  32781. */
  32782. isPointerCaptured(pointerId?: number): boolean;
  32783. /**
  32784. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32785. * @param attachUp defines if you want to attach events to pointerup
  32786. * @param attachDown defines if you want to attach events to pointerdown
  32787. * @param attachMove defines if you want to attach events to pointermove
  32788. */
  32789. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32790. /**
  32791. * Detaches all event handlers
  32792. */
  32793. detachControl(): void;
  32794. /**
  32795. * Force the value of meshUnderPointer
  32796. * @param mesh defines the mesh to use
  32797. */
  32798. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32799. /**
  32800. * Gets the mesh under the pointer
  32801. * @returns a Mesh or null if no mesh is under the pointer
  32802. */
  32803. getPointerOverMesh(): Nullable<AbstractMesh>;
  32804. }
  32805. }
  32806. declare module BABYLON {
  32807. /**
  32808. * Helper class used to generate session unique ID
  32809. */
  32810. export class UniqueIdGenerator {
  32811. private static _UniqueIdCounter;
  32812. /**
  32813. * Gets an unique (relatively to the current scene) Id
  32814. */
  32815. static readonly UniqueId: number;
  32816. }
  32817. }
  32818. declare module BABYLON {
  32819. /**
  32820. * This class defines the direct association between an animation and a target
  32821. */
  32822. export class TargetedAnimation {
  32823. /**
  32824. * Animation to perform
  32825. */
  32826. animation: Animation;
  32827. /**
  32828. * Target to animate
  32829. */
  32830. target: any;
  32831. /**
  32832. * Serialize the object
  32833. * @returns the JSON object representing the current entity
  32834. */
  32835. serialize(): any;
  32836. }
  32837. /**
  32838. * Use this class to create coordinated animations on multiple targets
  32839. */
  32840. export class AnimationGroup implements IDisposable {
  32841. /** The name of the animation group */
  32842. name: string;
  32843. private _scene;
  32844. private _targetedAnimations;
  32845. private _animatables;
  32846. private _from;
  32847. private _to;
  32848. private _isStarted;
  32849. private _isPaused;
  32850. private _speedRatio;
  32851. private _loopAnimation;
  32852. /**
  32853. * Gets or sets the unique id of the node
  32854. */
  32855. uniqueId: number;
  32856. /**
  32857. * This observable will notify when one animation have ended
  32858. */
  32859. onAnimationEndObservable: Observable<TargetedAnimation>;
  32860. /**
  32861. * Observer raised when one animation loops
  32862. */
  32863. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32864. /**
  32865. * This observable will notify when all animations have ended.
  32866. */
  32867. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32868. /**
  32869. * This observable will notify when all animations have paused.
  32870. */
  32871. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32872. /**
  32873. * This observable will notify when all animations are playing.
  32874. */
  32875. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32876. /**
  32877. * Gets the first frame
  32878. */
  32879. readonly from: number;
  32880. /**
  32881. * Gets the last frame
  32882. */
  32883. readonly to: number;
  32884. /**
  32885. * Define if the animations are started
  32886. */
  32887. readonly isStarted: boolean;
  32888. /**
  32889. * Gets a value indicating that the current group is playing
  32890. */
  32891. readonly isPlaying: boolean;
  32892. /**
  32893. * Gets or sets the speed ratio to use for all animations
  32894. */
  32895. /**
  32896. * Gets or sets the speed ratio to use for all animations
  32897. */
  32898. speedRatio: number;
  32899. /**
  32900. * Gets or sets if all animations should loop or not
  32901. */
  32902. loopAnimation: boolean;
  32903. /**
  32904. * Gets the targeted animations for this animation group
  32905. */
  32906. readonly targetedAnimations: Array<TargetedAnimation>;
  32907. /**
  32908. * returning the list of animatables controlled by this animation group.
  32909. */
  32910. readonly animatables: Array<Animatable>;
  32911. /**
  32912. * Instantiates a new Animation Group.
  32913. * This helps managing several animations at once.
  32914. * @see http://doc.babylonjs.com/how_to/group
  32915. * @param name Defines the name of the group
  32916. * @param scene Defines the scene the group belongs to
  32917. */
  32918. constructor(
  32919. /** The name of the animation group */
  32920. name: string, scene?: Nullable<Scene>);
  32921. /**
  32922. * Add an animation (with its target) in the group
  32923. * @param animation defines the animation we want to add
  32924. * @param target defines the target of the animation
  32925. * @returns the TargetedAnimation object
  32926. */
  32927. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32928. /**
  32929. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32930. * It can add constant keys at begin or end
  32931. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32932. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32933. * @returns the animation group
  32934. */
  32935. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32936. /**
  32937. * Start all animations on given targets
  32938. * @param loop defines if animations must loop
  32939. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32940. * @param from defines the from key (optional)
  32941. * @param to defines the to key (optional)
  32942. * @returns the current animation group
  32943. */
  32944. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32945. /**
  32946. * Pause all animations
  32947. * @returns the animation group
  32948. */
  32949. pause(): AnimationGroup;
  32950. /**
  32951. * Play all animations to initial state
  32952. * This function will start() the animations if they were not started or will restart() them if they were paused
  32953. * @param loop defines if animations must loop
  32954. * @returns the animation group
  32955. */
  32956. play(loop?: boolean): AnimationGroup;
  32957. /**
  32958. * Reset all animations to initial state
  32959. * @returns the animation group
  32960. */
  32961. reset(): AnimationGroup;
  32962. /**
  32963. * Restart animations from key 0
  32964. * @returns the animation group
  32965. */
  32966. restart(): AnimationGroup;
  32967. /**
  32968. * Stop all animations
  32969. * @returns the animation group
  32970. */
  32971. stop(): AnimationGroup;
  32972. /**
  32973. * Set animation weight for all animatables
  32974. * @param weight defines the weight to use
  32975. * @return the animationGroup
  32976. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32977. */
  32978. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32979. /**
  32980. * Synchronize and normalize all animatables with a source animatable
  32981. * @param root defines the root animatable to synchronize with
  32982. * @return the animationGroup
  32983. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32984. */
  32985. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32986. /**
  32987. * Goes to a specific frame in this animation group
  32988. * @param frame the frame number to go to
  32989. * @return the animationGroup
  32990. */
  32991. goToFrame(frame: number): AnimationGroup;
  32992. /**
  32993. * Dispose all associated resources
  32994. */
  32995. dispose(): void;
  32996. private _checkAnimationGroupEnded;
  32997. /**
  32998. * Clone the current animation group and returns a copy
  32999. * @param newName defines the name of the new group
  33000. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33001. * @returns the new aniamtion group
  33002. */
  33003. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33004. /**
  33005. * Serializes the animationGroup to an object
  33006. * @returns Serialized object
  33007. */
  33008. serialize(): any;
  33009. /**
  33010. * Returns a new AnimationGroup object parsed from the source provided.
  33011. * @param parsedAnimationGroup defines the source
  33012. * @param scene defines the scene that will receive the animationGroup
  33013. * @returns a new AnimationGroup
  33014. */
  33015. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33016. /**
  33017. * Returns the string "AnimationGroup"
  33018. * @returns "AnimationGroup"
  33019. */
  33020. getClassName(): string;
  33021. /**
  33022. * Creates a detailled string about the object
  33023. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33024. * @returns a string representing the object
  33025. */
  33026. toString(fullDetails?: boolean): string;
  33027. }
  33028. }
  33029. declare module BABYLON {
  33030. /**
  33031. * Define an interface for all classes that will hold resources
  33032. */
  33033. export interface IDisposable {
  33034. /**
  33035. * Releases all held resources
  33036. */
  33037. dispose(): void;
  33038. }
  33039. /** Interface defining initialization parameters for Scene class */
  33040. export interface SceneOptions {
  33041. /**
  33042. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33043. * It will improve performance when the number of geometries becomes important.
  33044. */
  33045. useGeometryUniqueIdsMap?: boolean;
  33046. /**
  33047. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33048. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33049. */
  33050. useMaterialMeshMap?: boolean;
  33051. /**
  33052. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33053. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33054. */
  33055. useClonedMeshhMap?: boolean;
  33056. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33057. virtual?: boolean;
  33058. }
  33059. /**
  33060. * Represents a scene to be rendered by the engine.
  33061. * @see http://doc.babylonjs.com/features/scene
  33062. */
  33063. export class Scene extends AbstractScene implements IAnimatable {
  33064. /** The fog is deactivated */
  33065. static readonly FOGMODE_NONE: number;
  33066. /** The fog density is following an exponential function */
  33067. static readonly FOGMODE_EXP: number;
  33068. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33069. static readonly FOGMODE_EXP2: number;
  33070. /** The fog density is following a linear function. */
  33071. static readonly FOGMODE_LINEAR: number;
  33072. /**
  33073. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33075. */
  33076. static MinDeltaTime: number;
  33077. /**
  33078. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33080. */
  33081. static MaxDeltaTime: number;
  33082. /**
  33083. * Factory used to create the default material.
  33084. * @param name The name of the material to create
  33085. * @param scene The scene to create the material for
  33086. * @returns The default material
  33087. */
  33088. static DefaultMaterialFactory(scene: Scene): Material;
  33089. /**
  33090. * Factory used to create the a collision coordinator.
  33091. * @returns The collision coordinator
  33092. */
  33093. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33094. /** @hidden */
  33095. _inputManager: InputManager;
  33096. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33097. cameraToUseForPointers: Nullable<Camera>;
  33098. /** @hidden */
  33099. readonly _isScene: boolean;
  33100. /**
  33101. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33102. */
  33103. autoClear: boolean;
  33104. /**
  33105. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33106. */
  33107. autoClearDepthAndStencil: boolean;
  33108. /**
  33109. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33110. */
  33111. clearColor: Color4;
  33112. /**
  33113. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33114. */
  33115. ambientColor: Color3;
  33116. /**
  33117. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33118. * It should only be one of the following (if not the default embedded one):
  33119. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33120. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33121. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33122. * The material properties need to be setup according to the type of texture in use.
  33123. */
  33124. environmentBRDFTexture: BaseTexture;
  33125. /** @hidden */
  33126. protected _environmentTexture: Nullable<BaseTexture>;
  33127. /**
  33128. * Texture used in all pbr material as the reflection texture.
  33129. * As in the majority of the scene they are the same (exception for multi room and so on),
  33130. * this is easier to reference from here than from all the materials.
  33131. */
  33132. /**
  33133. * Texture used in all pbr material as the reflection texture.
  33134. * As in the majority of the scene they are the same (exception for multi room and so on),
  33135. * this is easier to set here than in all the materials.
  33136. */
  33137. environmentTexture: Nullable<BaseTexture>;
  33138. /** @hidden */
  33139. protected _environmentIntensity: number;
  33140. /**
  33141. * Intensity of the environment in all pbr material.
  33142. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33143. * As in the majority of the scene they are the same (exception for multi room and so on),
  33144. * this is easier to reference from here than from all the materials.
  33145. */
  33146. /**
  33147. * Intensity of the environment in all pbr material.
  33148. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33149. * As in the majority of the scene they are the same (exception for multi room and so on),
  33150. * this is easier to set here than in all the materials.
  33151. */
  33152. environmentIntensity: number;
  33153. /** @hidden */
  33154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33155. /**
  33156. * Default image processing configuration used either in the rendering
  33157. * Forward main pass or through the imageProcessingPostProcess if present.
  33158. * As in the majority of the scene they are the same (exception for multi camera),
  33159. * this is easier to reference from here than from all the materials and post process.
  33160. *
  33161. * No setter as we it is a shared configuration, you can set the values instead.
  33162. */
  33163. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33164. private _forceWireframe;
  33165. /**
  33166. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33167. */
  33168. forceWireframe: boolean;
  33169. private _forcePointsCloud;
  33170. /**
  33171. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33172. */
  33173. forcePointsCloud: boolean;
  33174. /**
  33175. * Gets or sets the active clipplane 1
  33176. */
  33177. clipPlane: Nullable<Plane>;
  33178. /**
  33179. * Gets or sets the active clipplane 2
  33180. */
  33181. clipPlane2: Nullable<Plane>;
  33182. /**
  33183. * Gets or sets the active clipplane 3
  33184. */
  33185. clipPlane3: Nullable<Plane>;
  33186. /**
  33187. * Gets or sets the active clipplane 4
  33188. */
  33189. clipPlane4: Nullable<Plane>;
  33190. /**
  33191. * Gets or sets a boolean indicating if animations are enabled
  33192. */
  33193. animationsEnabled: boolean;
  33194. private _animationPropertiesOverride;
  33195. /**
  33196. * Gets or sets the animation properties override
  33197. */
  33198. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33199. /**
  33200. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33201. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33202. */
  33203. useConstantAnimationDeltaTime: boolean;
  33204. /**
  33205. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33206. * Please note that it requires to run a ray cast through the scene on every frame
  33207. */
  33208. constantlyUpdateMeshUnderPointer: boolean;
  33209. /**
  33210. * Defines the HTML cursor to use when hovering over interactive elements
  33211. */
  33212. hoverCursor: string;
  33213. /**
  33214. * Defines the HTML default cursor to use (empty by default)
  33215. */
  33216. defaultCursor: string;
  33217. /**
  33218. * Defines wether cursors are handled by the scene.
  33219. */
  33220. doNotHandleCursors: boolean;
  33221. /**
  33222. * This is used to call preventDefault() on pointer down
  33223. * in order to block unwanted artifacts like system double clicks
  33224. */
  33225. preventDefaultOnPointerDown: boolean;
  33226. /**
  33227. * This is used to call preventDefault() on pointer up
  33228. * in order to block unwanted artifacts like system double clicks
  33229. */
  33230. preventDefaultOnPointerUp: boolean;
  33231. /**
  33232. * Gets or sets user defined metadata
  33233. */
  33234. metadata: any;
  33235. /**
  33236. * For internal use only. Please do not use.
  33237. */
  33238. reservedDataStore: any;
  33239. /**
  33240. * Gets the name of the plugin used to load this scene (null by default)
  33241. */
  33242. loadingPluginName: string;
  33243. /**
  33244. * Use this array to add regular expressions used to disable offline support for specific urls
  33245. */
  33246. disableOfflineSupportExceptionRules: RegExp[];
  33247. /**
  33248. * An event triggered when the scene is disposed.
  33249. */
  33250. onDisposeObservable: Observable<Scene>;
  33251. private _onDisposeObserver;
  33252. /** Sets a function to be executed when this scene is disposed. */
  33253. onDispose: () => void;
  33254. /**
  33255. * An event triggered before rendering the scene (right after animations and physics)
  33256. */
  33257. onBeforeRenderObservable: Observable<Scene>;
  33258. private _onBeforeRenderObserver;
  33259. /** Sets a function to be executed before rendering this scene */
  33260. beforeRender: Nullable<() => void>;
  33261. /**
  33262. * An event triggered after rendering the scene
  33263. */
  33264. onAfterRenderObservable: Observable<Scene>;
  33265. /**
  33266. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33267. */
  33268. onAfterRenderCameraObservable: Observable<Camera>;
  33269. private _onAfterRenderObserver;
  33270. /** Sets a function to be executed after rendering this scene */
  33271. afterRender: Nullable<() => void>;
  33272. /**
  33273. * An event triggered before animating the scene
  33274. */
  33275. onBeforeAnimationsObservable: Observable<Scene>;
  33276. /**
  33277. * An event triggered after animations processing
  33278. */
  33279. onAfterAnimationsObservable: Observable<Scene>;
  33280. /**
  33281. * An event triggered before draw calls are ready to be sent
  33282. */
  33283. onBeforeDrawPhaseObservable: Observable<Scene>;
  33284. /**
  33285. * An event triggered after draw calls have been sent
  33286. */
  33287. onAfterDrawPhaseObservable: Observable<Scene>;
  33288. /**
  33289. * An event triggered when the scene is ready
  33290. */
  33291. onReadyObservable: Observable<Scene>;
  33292. /**
  33293. * An event triggered before rendering a camera
  33294. */
  33295. onBeforeCameraRenderObservable: Observable<Camera>;
  33296. private _onBeforeCameraRenderObserver;
  33297. /** Sets a function to be executed before rendering a camera*/
  33298. beforeCameraRender: () => void;
  33299. /**
  33300. * An event triggered after rendering a camera
  33301. */
  33302. onAfterCameraRenderObservable: Observable<Camera>;
  33303. private _onAfterCameraRenderObserver;
  33304. /** Sets a function to be executed after rendering a camera*/
  33305. afterCameraRender: () => void;
  33306. /**
  33307. * An event triggered when active meshes evaluation is about to start
  33308. */
  33309. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33310. /**
  33311. * An event triggered when active meshes evaluation is done
  33312. */
  33313. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33314. /**
  33315. * An event triggered when particles rendering is about to start
  33316. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33317. */
  33318. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33319. /**
  33320. * An event triggered when particles rendering is done
  33321. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33322. */
  33323. onAfterParticlesRenderingObservable: Observable<Scene>;
  33324. /**
  33325. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33326. */
  33327. onDataLoadedObservable: Observable<Scene>;
  33328. /**
  33329. * An event triggered when a camera is created
  33330. */
  33331. onNewCameraAddedObservable: Observable<Camera>;
  33332. /**
  33333. * An event triggered when a camera is removed
  33334. */
  33335. onCameraRemovedObservable: Observable<Camera>;
  33336. /**
  33337. * An event triggered when a light is created
  33338. */
  33339. onNewLightAddedObservable: Observable<Light>;
  33340. /**
  33341. * An event triggered when a light is removed
  33342. */
  33343. onLightRemovedObservable: Observable<Light>;
  33344. /**
  33345. * An event triggered when a geometry is created
  33346. */
  33347. onNewGeometryAddedObservable: Observable<Geometry>;
  33348. /**
  33349. * An event triggered when a geometry is removed
  33350. */
  33351. onGeometryRemovedObservable: Observable<Geometry>;
  33352. /**
  33353. * An event triggered when a transform node is created
  33354. */
  33355. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33356. /**
  33357. * An event triggered when a transform node is removed
  33358. */
  33359. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33360. /**
  33361. * An event triggered when a mesh is created
  33362. */
  33363. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33364. /**
  33365. * An event triggered when a mesh is removed
  33366. */
  33367. onMeshRemovedObservable: Observable<AbstractMesh>;
  33368. /**
  33369. * An event triggered when a skeleton is created
  33370. */
  33371. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33372. /**
  33373. * An event triggered when a skeleton is removed
  33374. */
  33375. onSkeletonRemovedObservable: Observable<Skeleton>;
  33376. /**
  33377. * An event triggered when a material is created
  33378. */
  33379. onNewMaterialAddedObservable: Observable<Material>;
  33380. /**
  33381. * An event triggered when a material is removed
  33382. */
  33383. onMaterialRemovedObservable: Observable<Material>;
  33384. /**
  33385. * An event triggered when a texture is created
  33386. */
  33387. onNewTextureAddedObservable: Observable<BaseTexture>;
  33388. /**
  33389. * An event triggered when a texture is removed
  33390. */
  33391. onTextureRemovedObservable: Observable<BaseTexture>;
  33392. /**
  33393. * An event triggered when render targets are about to be rendered
  33394. * Can happen multiple times per frame.
  33395. */
  33396. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33397. /**
  33398. * An event triggered when render targets were rendered.
  33399. * Can happen multiple times per frame.
  33400. */
  33401. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33402. /**
  33403. * An event triggered before calculating deterministic simulation step
  33404. */
  33405. onBeforeStepObservable: Observable<Scene>;
  33406. /**
  33407. * An event triggered after calculating deterministic simulation step
  33408. */
  33409. onAfterStepObservable: Observable<Scene>;
  33410. /**
  33411. * An event triggered when the activeCamera property is updated
  33412. */
  33413. onActiveCameraChanged: Observable<Scene>;
  33414. /**
  33415. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33416. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33417. * 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)
  33418. */
  33419. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33420. /**
  33421. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33422. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33423. * 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)
  33424. */
  33425. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33426. /**
  33427. * This Observable will when a mesh has been imported into the scene.
  33428. */
  33429. onMeshImportedObservable: Observable<AbstractMesh>;
  33430. /**
  33431. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33432. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33433. */
  33434. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33435. /** @hidden */
  33436. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33437. /**
  33438. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33439. */
  33440. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33441. /**
  33442. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33443. */
  33444. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33445. /**
  33446. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33447. */
  33448. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33449. /** Callback called when a pointer move is detected */
  33450. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33451. /** Callback called when a pointer down is detected */
  33452. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33453. /** Callback called when a pointer up is detected */
  33454. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33455. /** Callback called when a pointer pick is detected */
  33456. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33457. /**
  33458. * 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).
  33459. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33460. */
  33461. onPrePointerObservable: Observable<PointerInfoPre>;
  33462. /**
  33463. * Observable event triggered each time an input event is received from the rendering canvas
  33464. */
  33465. onPointerObservable: Observable<PointerInfo>;
  33466. /**
  33467. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33468. */
  33469. readonly unTranslatedPointer: Vector2;
  33470. /**
  33471. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33472. */
  33473. static DragMovementThreshold: number;
  33474. /**
  33475. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33476. */
  33477. static LongPressDelay: number;
  33478. /**
  33479. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33480. */
  33481. static DoubleClickDelay: number;
  33482. /** If you need to check double click without raising a single click at first click, enable this flag */
  33483. static ExclusiveDoubleClickMode: boolean;
  33484. /** @hidden */
  33485. _mirroredCameraPosition: Nullable<Vector3>;
  33486. /**
  33487. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33488. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33489. */
  33490. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33491. /**
  33492. * Observable event triggered each time an keyboard event is received from the hosting window
  33493. */
  33494. onKeyboardObservable: Observable<KeyboardInfo>;
  33495. private _useRightHandedSystem;
  33496. /**
  33497. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33498. */
  33499. useRightHandedSystem: boolean;
  33500. private _timeAccumulator;
  33501. private _currentStepId;
  33502. private _currentInternalStep;
  33503. /**
  33504. * Sets the step Id used by deterministic lock step
  33505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33506. * @param newStepId defines the step Id
  33507. */
  33508. setStepId(newStepId: number): void;
  33509. /**
  33510. * Gets the step Id used by deterministic lock step
  33511. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33512. * @returns the step Id
  33513. */
  33514. getStepId(): number;
  33515. /**
  33516. * Gets the internal step used by deterministic lock step
  33517. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33518. * @returns the internal step
  33519. */
  33520. getInternalStep(): number;
  33521. private _fogEnabled;
  33522. /**
  33523. * Gets or sets a boolean indicating if fog is enabled on this scene
  33524. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33525. * (Default is true)
  33526. */
  33527. fogEnabled: boolean;
  33528. private _fogMode;
  33529. /**
  33530. * Gets or sets the fog mode to use
  33531. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33532. * | mode | value |
  33533. * | --- | --- |
  33534. * | FOGMODE_NONE | 0 |
  33535. * | FOGMODE_EXP | 1 |
  33536. * | FOGMODE_EXP2 | 2 |
  33537. * | FOGMODE_LINEAR | 3 |
  33538. */
  33539. fogMode: number;
  33540. /**
  33541. * Gets or sets the fog color to use
  33542. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33543. * (Default is Color3(0.2, 0.2, 0.3))
  33544. */
  33545. fogColor: Color3;
  33546. /**
  33547. * Gets or sets the fog density to use
  33548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33549. * (Default is 0.1)
  33550. */
  33551. fogDensity: number;
  33552. /**
  33553. * Gets or sets the fog start distance to use
  33554. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33555. * (Default is 0)
  33556. */
  33557. fogStart: number;
  33558. /**
  33559. * Gets or sets the fog end distance to use
  33560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33561. * (Default is 1000)
  33562. */
  33563. fogEnd: number;
  33564. private _shadowsEnabled;
  33565. /**
  33566. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33567. */
  33568. shadowsEnabled: boolean;
  33569. private _lightsEnabled;
  33570. /**
  33571. * Gets or sets a boolean indicating if lights are enabled on this scene
  33572. */
  33573. lightsEnabled: boolean;
  33574. /** All of the active cameras added to this scene. */
  33575. activeCameras: Camera[];
  33576. /** @hidden */
  33577. _activeCamera: Nullable<Camera>;
  33578. /** Gets or sets the current active camera */
  33579. activeCamera: Nullable<Camera>;
  33580. private _defaultMaterial;
  33581. /** The default material used on meshes when no material is affected */
  33582. /** The default material used on meshes when no material is affected */
  33583. defaultMaterial: Material;
  33584. private _texturesEnabled;
  33585. /**
  33586. * Gets or sets a boolean indicating if textures are enabled on this scene
  33587. */
  33588. texturesEnabled: boolean;
  33589. /**
  33590. * Gets or sets a boolean indicating if particles are enabled on this scene
  33591. */
  33592. particlesEnabled: boolean;
  33593. /**
  33594. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33595. */
  33596. spritesEnabled: boolean;
  33597. private _skeletonsEnabled;
  33598. /**
  33599. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33600. */
  33601. skeletonsEnabled: boolean;
  33602. /**
  33603. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33604. */
  33605. lensFlaresEnabled: boolean;
  33606. /**
  33607. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33609. */
  33610. collisionsEnabled: boolean;
  33611. private _collisionCoordinator;
  33612. /** @hidden */
  33613. readonly collisionCoordinator: ICollisionCoordinator;
  33614. /**
  33615. * Defines the gravity applied to this scene (used only for collisions)
  33616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33617. */
  33618. gravity: Vector3;
  33619. /**
  33620. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33621. */
  33622. postProcessesEnabled: boolean;
  33623. /**
  33624. * The list of postprocesses added to the scene
  33625. */
  33626. postProcesses: PostProcess[];
  33627. /**
  33628. * Gets the current postprocess manager
  33629. */
  33630. postProcessManager: PostProcessManager;
  33631. /**
  33632. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33633. */
  33634. renderTargetsEnabled: boolean;
  33635. /**
  33636. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33637. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33638. */
  33639. dumpNextRenderTargets: boolean;
  33640. /**
  33641. * The list of user defined render targets added to the scene
  33642. */
  33643. customRenderTargets: RenderTargetTexture[];
  33644. /**
  33645. * Defines if texture loading must be delayed
  33646. * If true, textures will only be loaded when they need to be rendered
  33647. */
  33648. useDelayedTextureLoading: boolean;
  33649. /**
  33650. * Gets the list of meshes imported to the scene through SceneLoader
  33651. */
  33652. importedMeshesFiles: String[];
  33653. /**
  33654. * Gets or sets a boolean indicating if probes are enabled on this scene
  33655. */
  33656. probesEnabled: boolean;
  33657. /**
  33658. * Gets or sets the current offline provider to use to store scene data
  33659. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33660. */
  33661. offlineProvider: IOfflineProvider;
  33662. /**
  33663. * Gets or sets the action manager associated with the scene
  33664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33665. */
  33666. actionManager: AbstractActionManager;
  33667. private _meshesForIntersections;
  33668. /**
  33669. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33670. */
  33671. proceduralTexturesEnabled: boolean;
  33672. private _engine;
  33673. private _totalVertices;
  33674. /** @hidden */
  33675. _activeIndices: PerfCounter;
  33676. /** @hidden */
  33677. _activeParticles: PerfCounter;
  33678. /** @hidden */
  33679. _activeBones: PerfCounter;
  33680. private _animationRatio;
  33681. /** @hidden */
  33682. _animationTimeLast: number;
  33683. /** @hidden */
  33684. _animationTime: number;
  33685. /**
  33686. * Gets or sets a general scale for animation speed
  33687. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33688. */
  33689. animationTimeScale: number;
  33690. /** @hidden */
  33691. _cachedMaterial: Nullable<Material>;
  33692. /** @hidden */
  33693. _cachedEffect: Nullable<Effect>;
  33694. /** @hidden */
  33695. _cachedVisibility: Nullable<number>;
  33696. private _renderId;
  33697. private _frameId;
  33698. private _executeWhenReadyTimeoutId;
  33699. private _intermediateRendering;
  33700. private _viewUpdateFlag;
  33701. private _projectionUpdateFlag;
  33702. /** @hidden */
  33703. _toBeDisposed: Nullable<IDisposable>[];
  33704. private _activeRequests;
  33705. /** @hidden */
  33706. _pendingData: any[];
  33707. private _isDisposed;
  33708. /**
  33709. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33710. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33711. */
  33712. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33713. private _activeMeshes;
  33714. private _processedMaterials;
  33715. private _renderTargets;
  33716. /** @hidden */
  33717. _activeParticleSystems: SmartArray<IParticleSystem>;
  33718. private _activeSkeletons;
  33719. private _softwareSkinnedMeshes;
  33720. private _renderingManager;
  33721. /** @hidden */
  33722. _activeAnimatables: Animatable[];
  33723. private _transformMatrix;
  33724. private _sceneUbo;
  33725. /** @hidden */
  33726. _viewMatrix: Matrix;
  33727. private _projectionMatrix;
  33728. /** @hidden */
  33729. _forcedViewPosition: Nullable<Vector3>;
  33730. /** @hidden */
  33731. _frustumPlanes: Plane[];
  33732. /**
  33733. * Gets the list of frustum planes (built from the active camera)
  33734. */
  33735. readonly frustumPlanes: Plane[];
  33736. /**
  33737. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33738. * This is useful if there are more lights that the maximum simulteanous authorized
  33739. */
  33740. requireLightSorting: boolean;
  33741. /** @hidden */
  33742. readonly useMaterialMeshMap: boolean;
  33743. /** @hidden */
  33744. readonly useClonedMeshhMap: boolean;
  33745. private _externalData;
  33746. private _uid;
  33747. /**
  33748. * @hidden
  33749. * Backing store of defined scene components.
  33750. */
  33751. _components: ISceneComponent[];
  33752. /**
  33753. * @hidden
  33754. * Backing store of defined scene components.
  33755. */
  33756. _serializableComponents: ISceneSerializableComponent[];
  33757. /**
  33758. * List of components to register on the next registration step.
  33759. */
  33760. private _transientComponents;
  33761. /**
  33762. * Registers the transient components if needed.
  33763. */
  33764. private _registerTransientComponents;
  33765. /**
  33766. * @hidden
  33767. * Add a component to the scene.
  33768. * Note that the ccomponent could be registered on th next frame if this is called after
  33769. * the register component stage.
  33770. * @param component Defines the component to add to the scene
  33771. */
  33772. _addComponent(component: ISceneComponent): void;
  33773. /**
  33774. * @hidden
  33775. * Gets a component from the scene.
  33776. * @param name defines the name of the component to retrieve
  33777. * @returns the component or null if not present
  33778. */
  33779. _getComponent(name: string): Nullable<ISceneComponent>;
  33780. /**
  33781. * @hidden
  33782. * Defines the actions happening before camera updates.
  33783. */
  33784. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33785. /**
  33786. * @hidden
  33787. * Defines the actions happening before clear the canvas.
  33788. */
  33789. _beforeClearStage: Stage<SimpleStageAction>;
  33790. /**
  33791. * @hidden
  33792. * Defines the actions when collecting render targets for the frame.
  33793. */
  33794. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33795. /**
  33796. * @hidden
  33797. * Defines the actions happening for one camera in the frame.
  33798. */
  33799. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33800. /**
  33801. * @hidden
  33802. * Defines the actions happening during the per mesh ready checks.
  33803. */
  33804. _isReadyForMeshStage: Stage<MeshStageAction>;
  33805. /**
  33806. * @hidden
  33807. * Defines the actions happening before evaluate active mesh checks.
  33808. */
  33809. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33810. /**
  33811. * @hidden
  33812. * Defines the actions happening during the evaluate sub mesh checks.
  33813. */
  33814. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33815. /**
  33816. * @hidden
  33817. * Defines the actions happening during the active mesh stage.
  33818. */
  33819. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33820. /**
  33821. * @hidden
  33822. * Defines the actions happening during the per camera render target step.
  33823. */
  33824. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33825. /**
  33826. * @hidden
  33827. * Defines the actions happening just before the active camera is drawing.
  33828. */
  33829. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33830. /**
  33831. * @hidden
  33832. * Defines the actions happening just before a render target is drawing.
  33833. */
  33834. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33835. /**
  33836. * @hidden
  33837. * Defines the actions happening just before a rendering group is drawing.
  33838. */
  33839. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33840. /**
  33841. * @hidden
  33842. * Defines the actions happening just before a mesh is drawing.
  33843. */
  33844. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33845. /**
  33846. * @hidden
  33847. * Defines the actions happening just after a mesh has been drawn.
  33848. */
  33849. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33850. /**
  33851. * @hidden
  33852. * Defines the actions happening just after a rendering group has been drawn.
  33853. */
  33854. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33855. /**
  33856. * @hidden
  33857. * Defines the actions happening just after the active camera has been drawn.
  33858. */
  33859. _afterCameraDrawStage: Stage<CameraStageAction>;
  33860. /**
  33861. * @hidden
  33862. * Defines the actions happening just after a render target has been drawn.
  33863. */
  33864. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33865. /**
  33866. * @hidden
  33867. * Defines the actions happening just after rendering all cameras and computing intersections.
  33868. */
  33869. _afterRenderStage: Stage<SimpleStageAction>;
  33870. /**
  33871. * @hidden
  33872. * Defines the actions happening when a pointer move event happens.
  33873. */
  33874. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33875. /**
  33876. * @hidden
  33877. * Defines the actions happening when a pointer down event happens.
  33878. */
  33879. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33880. /**
  33881. * @hidden
  33882. * Defines the actions happening when a pointer up event happens.
  33883. */
  33884. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33885. /**
  33886. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33887. */
  33888. private geometriesByUniqueId;
  33889. /**
  33890. * Creates a new Scene
  33891. * @param engine defines the engine to use to render this scene
  33892. * @param options defines the scene options
  33893. */
  33894. constructor(engine: Engine, options?: SceneOptions);
  33895. /**
  33896. * Gets a string idenfifying the name of the class
  33897. * @returns "Scene" string
  33898. */
  33899. getClassName(): string;
  33900. private _defaultMeshCandidates;
  33901. /**
  33902. * @hidden
  33903. */
  33904. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33905. private _defaultSubMeshCandidates;
  33906. /**
  33907. * @hidden
  33908. */
  33909. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33910. /**
  33911. * Sets the default candidate providers for the scene.
  33912. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33913. * and getCollidingSubMeshCandidates to their default function
  33914. */
  33915. setDefaultCandidateProviders(): void;
  33916. /**
  33917. * Gets the mesh that is currently under the pointer
  33918. */
  33919. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33920. /**
  33921. * Gets or sets the current on-screen X position of the pointer
  33922. */
  33923. pointerX: number;
  33924. /**
  33925. * Gets or sets the current on-screen Y position of the pointer
  33926. */
  33927. pointerY: number;
  33928. /**
  33929. * Gets the cached material (ie. the latest rendered one)
  33930. * @returns the cached material
  33931. */
  33932. getCachedMaterial(): Nullable<Material>;
  33933. /**
  33934. * Gets the cached effect (ie. the latest rendered one)
  33935. * @returns the cached effect
  33936. */
  33937. getCachedEffect(): Nullable<Effect>;
  33938. /**
  33939. * Gets the cached visibility state (ie. the latest rendered one)
  33940. * @returns the cached visibility state
  33941. */
  33942. getCachedVisibility(): Nullable<number>;
  33943. /**
  33944. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33945. * @param material defines the current material
  33946. * @param effect defines the current effect
  33947. * @param visibility defines the current visibility state
  33948. * @returns true if one parameter is not cached
  33949. */
  33950. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33951. /**
  33952. * Gets the engine associated with the scene
  33953. * @returns an Engine
  33954. */
  33955. getEngine(): Engine;
  33956. /**
  33957. * Gets the total number of vertices rendered per frame
  33958. * @returns the total number of vertices rendered per frame
  33959. */
  33960. getTotalVertices(): number;
  33961. /**
  33962. * Gets the performance counter for total vertices
  33963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33964. */
  33965. readonly totalVerticesPerfCounter: PerfCounter;
  33966. /**
  33967. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33968. * @returns the total number of active indices rendered per frame
  33969. */
  33970. getActiveIndices(): number;
  33971. /**
  33972. * Gets the performance counter for active indices
  33973. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33974. */
  33975. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33976. /**
  33977. * Gets the total number of active particles rendered per frame
  33978. * @returns the total number of active particles rendered per frame
  33979. */
  33980. getActiveParticles(): number;
  33981. /**
  33982. * Gets the performance counter for active particles
  33983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33984. */
  33985. readonly activeParticlesPerfCounter: PerfCounter;
  33986. /**
  33987. * Gets the total number of active bones rendered per frame
  33988. * @returns the total number of active bones rendered per frame
  33989. */
  33990. getActiveBones(): number;
  33991. /**
  33992. * Gets the performance counter for active bones
  33993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33994. */
  33995. readonly activeBonesPerfCounter: PerfCounter;
  33996. /**
  33997. * Gets the array of active meshes
  33998. * @returns an array of AbstractMesh
  33999. */
  34000. getActiveMeshes(): SmartArray<AbstractMesh>;
  34001. /**
  34002. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34003. * @returns a number
  34004. */
  34005. getAnimationRatio(): number;
  34006. /**
  34007. * Gets an unique Id for the current render phase
  34008. * @returns a number
  34009. */
  34010. getRenderId(): number;
  34011. /**
  34012. * Gets an unique Id for the current frame
  34013. * @returns a number
  34014. */
  34015. getFrameId(): number;
  34016. /** Call this function if you want to manually increment the render Id*/
  34017. incrementRenderId(): void;
  34018. private _createUbo;
  34019. /**
  34020. * Use this method to simulate a pointer move on a mesh
  34021. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34022. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34023. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34024. * @returns the current scene
  34025. */
  34026. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34027. /**
  34028. * Use this method to simulate a pointer down on a mesh
  34029. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34030. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34031. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34032. * @returns the current scene
  34033. */
  34034. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34035. /**
  34036. * Use this method to simulate a pointer up on a mesh
  34037. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34038. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34039. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34040. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34041. * @returns the current scene
  34042. */
  34043. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34044. /**
  34045. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34046. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34047. * @returns true if the pointer was captured
  34048. */
  34049. isPointerCaptured(pointerId?: number): boolean;
  34050. /**
  34051. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34052. * @param attachUp defines if you want to attach events to pointerup
  34053. * @param attachDown defines if you want to attach events to pointerdown
  34054. * @param attachMove defines if you want to attach events to pointermove
  34055. */
  34056. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34057. /** Detaches all event handlers*/
  34058. detachControl(): void;
  34059. /**
  34060. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34061. * Delay loaded resources are not taking in account
  34062. * @return true if all required resources are ready
  34063. */
  34064. isReady(): boolean;
  34065. /** Resets all cached information relative to material (including effect and visibility) */
  34066. resetCachedMaterial(): void;
  34067. /**
  34068. * Registers a function to be called before every frame render
  34069. * @param func defines the function to register
  34070. */
  34071. registerBeforeRender(func: () => void): void;
  34072. /**
  34073. * Unregisters a function called before every frame render
  34074. * @param func defines the function to unregister
  34075. */
  34076. unregisterBeforeRender(func: () => void): void;
  34077. /**
  34078. * Registers a function to be called after every frame render
  34079. * @param func defines the function to register
  34080. */
  34081. registerAfterRender(func: () => void): void;
  34082. /**
  34083. * Unregisters a function called after every frame render
  34084. * @param func defines the function to unregister
  34085. */
  34086. unregisterAfterRender(func: () => void): void;
  34087. private _executeOnceBeforeRender;
  34088. /**
  34089. * The provided function will run before render once and will be disposed afterwards.
  34090. * A timeout delay can be provided so that the function will be executed in N ms.
  34091. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34092. * @param func The function to be executed.
  34093. * @param timeout optional delay in ms
  34094. */
  34095. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34096. /** @hidden */
  34097. _addPendingData(data: any): void;
  34098. /** @hidden */
  34099. _removePendingData(data: any): void;
  34100. /**
  34101. * Returns the number of items waiting to be loaded
  34102. * @returns the number of items waiting to be loaded
  34103. */
  34104. getWaitingItemsCount(): number;
  34105. /**
  34106. * Returns a boolean indicating if the scene is still loading data
  34107. */
  34108. readonly isLoading: boolean;
  34109. /**
  34110. * Registers a function to be executed when the scene is ready
  34111. * @param {Function} func - the function to be executed
  34112. */
  34113. executeWhenReady(func: () => void): void;
  34114. /**
  34115. * Returns a promise that resolves when the scene is ready
  34116. * @returns A promise that resolves when the scene is ready
  34117. */
  34118. whenReadyAsync(): Promise<void>;
  34119. /** @hidden */
  34120. _checkIsReady(): void;
  34121. /**
  34122. * Gets all animatable attached to the scene
  34123. */
  34124. readonly animatables: Animatable[];
  34125. /**
  34126. * Resets the last animation time frame.
  34127. * Useful to override when animations start running when loading a scene for the first time.
  34128. */
  34129. resetLastAnimationTimeFrame(): void;
  34130. /**
  34131. * Gets the current view matrix
  34132. * @returns a Matrix
  34133. */
  34134. getViewMatrix(): Matrix;
  34135. /**
  34136. * Gets the current projection matrix
  34137. * @returns a Matrix
  34138. */
  34139. getProjectionMatrix(): Matrix;
  34140. /**
  34141. * Gets the current transform matrix
  34142. * @returns a Matrix made of View * Projection
  34143. */
  34144. getTransformMatrix(): Matrix;
  34145. /**
  34146. * Sets the current transform matrix
  34147. * @param viewL defines the View matrix to use
  34148. * @param projectionL defines the Projection matrix to use
  34149. * @param viewR defines the right View matrix to use (if provided)
  34150. * @param projectionR defines the right Projection matrix to use (if provided)
  34151. */
  34152. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34153. /**
  34154. * Gets the uniform buffer used to store scene data
  34155. * @returns a UniformBuffer
  34156. */
  34157. getSceneUniformBuffer(): UniformBuffer;
  34158. /**
  34159. * Gets an unique (relatively to the current scene) Id
  34160. * @returns an unique number for the scene
  34161. */
  34162. getUniqueId(): number;
  34163. /**
  34164. * Add a mesh to the list of scene's meshes
  34165. * @param newMesh defines the mesh to add
  34166. * @param recursive if all child meshes should also be added to the scene
  34167. */
  34168. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34169. /**
  34170. * Remove a mesh for the list of scene's meshes
  34171. * @param toRemove defines the mesh to remove
  34172. * @param recursive if all child meshes should also be removed from the scene
  34173. * @returns the index where the mesh was in the mesh list
  34174. */
  34175. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34176. /**
  34177. * Add a transform node to the list of scene's transform nodes
  34178. * @param newTransformNode defines the transform node to add
  34179. */
  34180. addTransformNode(newTransformNode: TransformNode): void;
  34181. /**
  34182. * Remove a transform node for the list of scene's transform nodes
  34183. * @param toRemove defines the transform node to remove
  34184. * @returns the index where the transform node was in the transform node list
  34185. */
  34186. removeTransformNode(toRemove: TransformNode): number;
  34187. /**
  34188. * Remove a skeleton for the list of scene's skeletons
  34189. * @param toRemove defines the skeleton to remove
  34190. * @returns the index where the skeleton was in the skeleton list
  34191. */
  34192. removeSkeleton(toRemove: Skeleton): number;
  34193. /**
  34194. * Remove a morph target for the list of scene's morph targets
  34195. * @param toRemove defines the morph target to remove
  34196. * @returns the index where the morph target was in the morph target list
  34197. */
  34198. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34199. /**
  34200. * Remove a light for the list of scene's lights
  34201. * @param toRemove defines the light to remove
  34202. * @returns the index where the light was in the light list
  34203. */
  34204. removeLight(toRemove: Light): number;
  34205. /**
  34206. * Remove a camera for the list of scene's cameras
  34207. * @param toRemove defines the camera to remove
  34208. * @returns the index where the camera was in the camera list
  34209. */
  34210. removeCamera(toRemove: Camera): number;
  34211. /**
  34212. * Remove a particle system for the list of scene's particle systems
  34213. * @param toRemove defines the particle system to remove
  34214. * @returns the index where the particle system was in the particle system list
  34215. */
  34216. removeParticleSystem(toRemove: IParticleSystem): number;
  34217. /**
  34218. * Remove a animation for the list of scene's animations
  34219. * @param toRemove defines the animation to remove
  34220. * @returns the index where the animation was in the animation list
  34221. */
  34222. removeAnimation(toRemove: Animation): number;
  34223. /**
  34224. * Will stop the animation of the given target
  34225. * @param target - the target
  34226. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34227. * @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)
  34228. */
  34229. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34230. /**
  34231. * Removes the given animation group from this scene.
  34232. * @param toRemove The animation group to remove
  34233. * @returns The index of the removed animation group
  34234. */
  34235. removeAnimationGroup(toRemove: AnimationGroup): number;
  34236. /**
  34237. * Removes the given multi-material from this scene.
  34238. * @param toRemove The multi-material to remove
  34239. * @returns The index of the removed multi-material
  34240. */
  34241. removeMultiMaterial(toRemove: MultiMaterial): number;
  34242. /**
  34243. * Removes the given material from this scene.
  34244. * @param toRemove The material to remove
  34245. * @returns The index of the removed material
  34246. */
  34247. removeMaterial(toRemove: Material): number;
  34248. /**
  34249. * Removes the given action manager from this scene.
  34250. * @param toRemove The action manager to remove
  34251. * @returns The index of the removed action manager
  34252. */
  34253. removeActionManager(toRemove: AbstractActionManager): number;
  34254. /**
  34255. * Removes the given texture from this scene.
  34256. * @param toRemove The texture to remove
  34257. * @returns The index of the removed texture
  34258. */
  34259. removeTexture(toRemove: BaseTexture): number;
  34260. /**
  34261. * Adds the given light to this scene
  34262. * @param newLight The light to add
  34263. */
  34264. addLight(newLight: Light): void;
  34265. /**
  34266. * Sorts the list list based on light priorities
  34267. */
  34268. sortLightsByPriority(): void;
  34269. /**
  34270. * Adds the given camera to this scene
  34271. * @param newCamera The camera to add
  34272. */
  34273. addCamera(newCamera: Camera): void;
  34274. /**
  34275. * Adds the given skeleton to this scene
  34276. * @param newSkeleton The skeleton to add
  34277. */
  34278. addSkeleton(newSkeleton: Skeleton): void;
  34279. /**
  34280. * Adds the given particle system to this scene
  34281. * @param newParticleSystem The particle system to add
  34282. */
  34283. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34284. /**
  34285. * Adds the given animation to this scene
  34286. * @param newAnimation The animation to add
  34287. */
  34288. addAnimation(newAnimation: Animation): void;
  34289. /**
  34290. * Adds the given animation group to this scene.
  34291. * @param newAnimationGroup The animation group to add
  34292. */
  34293. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34294. /**
  34295. * Adds the given multi-material to this scene
  34296. * @param newMultiMaterial The multi-material to add
  34297. */
  34298. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34299. /**
  34300. * Adds the given material to this scene
  34301. * @param newMaterial The material to add
  34302. */
  34303. addMaterial(newMaterial: Material): void;
  34304. /**
  34305. * Adds the given morph target to this scene
  34306. * @param newMorphTargetManager The morph target to add
  34307. */
  34308. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34309. /**
  34310. * Adds the given geometry to this scene
  34311. * @param newGeometry The geometry to add
  34312. */
  34313. addGeometry(newGeometry: Geometry): void;
  34314. /**
  34315. * Adds the given action manager to this scene
  34316. * @param newActionManager The action manager to add
  34317. */
  34318. addActionManager(newActionManager: AbstractActionManager): void;
  34319. /**
  34320. * Adds the given texture to this scene.
  34321. * @param newTexture The texture to add
  34322. */
  34323. addTexture(newTexture: BaseTexture): void;
  34324. /**
  34325. * Switch active camera
  34326. * @param newCamera defines the new active camera
  34327. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34328. */
  34329. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34330. /**
  34331. * sets the active camera of the scene using its ID
  34332. * @param id defines the camera's ID
  34333. * @return the new active camera or null if none found.
  34334. */
  34335. setActiveCameraByID(id: string): Nullable<Camera>;
  34336. /**
  34337. * sets the active camera of the scene using its name
  34338. * @param name defines the camera's name
  34339. * @returns the new active camera or null if none found.
  34340. */
  34341. setActiveCameraByName(name: string): Nullable<Camera>;
  34342. /**
  34343. * get an animation group using its name
  34344. * @param name defines the material's name
  34345. * @return the animation group or null if none found.
  34346. */
  34347. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34348. /**
  34349. * Get a material using its unique id
  34350. * @param uniqueId defines the material's unique id
  34351. * @return the material or null if none found.
  34352. */
  34353. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34354. /**
  34355. * get a material using its id
  34356. * @param id defines the material's ID
  34357. * @return the material or null if none found.
  34358. */
  34359. getMaterialByID(id: string): Nullable<Material>;
  34360. /**
  34361. * Gets a the last added material using a given id
  34362. * @param id defines the material's ID
  34363. * @return the last material with the given id or null if none found.
  34364. */
  34365. getLastMaterialByID(id: string): Nullable<Material>;
  34366. /**
  34367. * Gets a material using its name
  34368. * @param name defines the material's name
  34369. * @return the material or null if none found.
  34370. */
  34371. getMaterialByName(name: string): Nullable<Material>;
  34372. /**
  34373. * Get a texture using its unique id
  34374. * @param uniqueId defines the texture's unique id
  34375. * @return the texture or null if none found.
  34376. */
  34377. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34378. /**
  34379. * Gets a camera using its id
  34380. * @param id defines the id to look for
  34381. * @returns the camera or null if not found
  34382. */
  34383. getCameraByID(id: string): Nullable<Camera>;
  34384. /**
  34385. * Gets a camera using its unique id
  34386. * @param uniqueId defines the unique id to look for
  34387. * @returns the camera or null if not found
  34388. */
  34389. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34390. /**
  34391. * Gets a camera using its name
  34392. * @param name defines the camera's name
  34393. * @return the camera or null if none found.
  34394. */
  34395. getCameraByName(name: string): Nullable<Camera>;
  34396. /**
  34397. * Gets a bone using its id
  34398. * @param id defines the bone's id
  34399. * @return the bone or null if not found
  34400. */
  34401. getBoneByID(id: string): Nullable<Bone>;
  34402. /**
  34403. * Gets a bone using its id
  34404. * @param name defines the bone's name
  34405. * @return the bone or null if not found
  34406. */
  34407. getBoneByName(name: string): Nullable<Bone>;
  34408. /**
  34409. * Gets a light node using its name
  34410. * @param name defines the the light's name
  34411. * @return the light or null if none found.
  34412. */
  34413. getLightByName(name: string): Nullable<Light>;
  34414. /**
  34415. * Gets a light node using its id
  34416. * @param id defines the light's id
  34417. * @return the light or null if none found.
  34418. */
  34419. getLightByID(id: string): Nullable<Light>;
  34420. /**
  34421. * Gets a light node using its scene-generated unique ID
  34422. * @param uniqueId defines the light's unique id
  34423. * @return the light or null if none found.
  34424. */
  34425. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34426. /**
  34427. * Gets a particle system by id
  34428. * @param id defines the particle system id
  34429. * @return the corresponding system or null if none found
  34430. */
  34431. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34432. /**
  34433. * Gets a geometry using its ID
  34434. * @param id defines the geometry's id
  34435. * @return the geometry or null if none found.
  34436. */
  34437. getGeometryByID(id: string): Nullable<Geometry>;
  34438. private _getGeometryByUniqueID;
  34439. /**
  34440. * Add a new geometry to this scene
  34441. * @param geometry defines the geometry to be added to the scene.
  34442. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34443. * @return a boolean defining if the geometry was added or not
  34444. */
  34445. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34446. /**
  34447. * Removes an existing geometry
  34448. * @param geometry defines the geometry to be removed from the scene
  34449. * @return a boolean defining if the geometry was removed or not
  34450. */
  34451. removeGeometry(geometry: Geometry): boolean;
  34452. /**
  34453. * Gets the list of geometries attached to the scene
  34454. * @returns an array of Geometry
  34455. */
  34456. getGeometries(): Geometry[];
  34457. /**
  34458. * Gets the first added mesh found of a given ID
  34459. * @param id defines the id to search for
  34460. * @return the mesh found or null if not found at all
  34461. */
  34462. getMeshByID(id: string): Nullable<AbstractMesh>;
  34463. /**
  34464. * Gets a list of meshes using their id
  34465. * @param id defines the id to search for
  34466. * @returns a list of meshes
  34467. */
  34468. getMeshesByID(id: string): Array<AbstractMesh>;
  34469. /**
  34470. * Gets the first added transform node found of a given ID
  34471. * @param id defines the id to search for
  34472. * @return the found transform node or null if not found at all.
  34473. */
  34474. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34475. /**
  34476. * Gets a transform node with its auto-generated unique id
  34477. * @param uniqueId efines the unique id to search for
  34478. * @return the found transform node or null if not found at all.
  34479. */
  34480. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34481. /**
  34482. * Gets a list of transform nodes using their id
  34483. * @param id defines the id to search for
  34484. * @returns a list of transform nodes
  34485. */
  34486. getTransformNodesByID(id: string): Array<TransformNode>;
  34487. /**
  34488. * Gets a mesh with its auto-generated unique id
  34489. * @param uniqueId defines the unique id to search for
  34490. * @return the found mesh or null if not found at all.
  34491. */
  34492. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34493. /**
  34494. * Gets a the last added mesh using a given id
  34495. * @param id defines the id to search for
  34496. * @return the found mesh or null if not found at all.
  34497. */
  34498. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34499. /**
  34500. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34501. * @param id defines the id to search for
  34502. * @return the found node or null if not found at all
  34503. */
  34504. getLastEntryByID(id: string): Nullable<Node>;
  34505. /**
  34506. * Gets a node (Mesh, Camera, Light) using a given id
  34507. * @param id defines the id to search for
  34508. * @return the found node or null if not found at all
  34509. */
  34510. getNodeByID(id: string): Nullable<Node>;
  34511. /**
  34512. * Gets a node (Mesh, Camera, Light) using a given name
  34513. * @param name defines the name to search for
  34514. * @return the found node or null if not found at all.
  34515. */
  34516. getNodeByName(name: string): Nullable<Node>;
  34517. /**
  34518. * Gets a mesh using a given name
  34519. * @param name defines the name to search for
  34520. * @return the found mesh or null if not found at all.
  34521. */
  34522. getMeshByName(name: string): Nullable<AbstractMesh>;
  34523. /**
  34524. * Gets a transform node using a given name
  34525. * @param name defines the name to search for
  34526. * @return the found transform node or null if not found at all.
  34527. */
  34528. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34529. /**
  34530. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34531. * @param id defines the id to search for
  34532. * @return the found skeleton or null if not found at all.
  34533. */
  34534. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34535. /**
  34536. * Gets a skeleton using a given auto generated unique id
  34537. * @param uniqueId defines the unique id to search for
  34538. * @return the found skeleton or null if not found at all.
  34539. */
  34540. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34541. /**
  34542. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34543. * @param id defines the id to search for
  34544. * @return the found skeleton or null if not found at all.
  34545. */
  34546. getSkeletonById(id: string): Nullable<Skeleton>;
  34547. /**
  34548. * Gets a skeleton using a given name
  34549. * @param name defines the name to search for
  34550. * @return the found skeleton or null if not found at all.
  34551. */
  34552. getSkeletonByName(name: string): Nullable<Skeleton>;
  34553. /**
  34554. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34555. * @param id defines the id to search for
  34556. * @return the found morph target manager or null if not found at all.
  34557. */
  34558. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34559. /**
  34560. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34561. * @param id defines the id to search for
  34562. * @return the found morph target or null if not found at all.
  34563. */
  34564. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34565. /**
  34566. * Gets a boolean indicating if the given mesh is active
  34567. * @param mesh defines the mesh to look for
  34568. * @returns true if the mesh is in the active list
  34569. */
  34570. isActiveMesh(mesh: AbstractMesh): boolean;
  34571. /**
  34572. * Return a unique id as a string which can serve as an identifier for the scene
  34573. */
  34574. readonly uid: string;
  34575. /**
  34576. * Add an externaly attached data from its key.
  34577. * This method call will fail and return false, if such key already exists.
  34578. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34579. * @param key the unique key that identifies the data
  34580. * @param data the data object to associate to the key for this Engine instance
  34581. * @return true if no such key were already present and the data was added successfully, false otherwise
  34582. */
  34583. addExternalData<T>(key: string, data: T): boolean;
  34584. /**
  34585. * Get an externaly attached data from its key
  34586. * @param key the unique key that identifies the data
  34587. * @return the associated data, if present (can be null), or undefined if not present
  34588. */
  34589. getExternalData<T>(key: string): Nullable<T>;
  34590. /**
  34591. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34592. * @param key the unique key that identifies the data
  34593. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34594. * @return the associated data, can be null if the factory returned null.
  34595. */
  34596. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34597. /**
  34598. * Remove an externaly attached data from the Engine instance
  34599. * @param key the unique key that identifies the data
  34600. * @return true if the data was successfully removed, false if it doesn't exist
  34601. */
  34602. removeExternalData(key: string): boolean;
  34603. private _evaluateSubMesh;
  34604. /**
  34605. * Clear the processed materials smart array preventing retention point in material dispose.
  34606. */
  34607. freeProcessedMaterials(): void;
  34608. private _preventFreeActiveMeshesAndRenderingGroups;
  34609. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34610. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34611. * when disposing several meshes in a row or a hierarchy of meshes.
  34612. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34613. */
  34614. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34615. /**
  34616. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34617. */
  34618. freeActiveMeshes(): void;
  34619. /**
  34620. * Clear the info related to rendering groups preventing retention points during dispose.
  34621. */
  34622. freeRenderingGroups(): void;
  34623. /** @hidden */
  34624. _isInIntermediateRendering(): boolean;
  34625. /**
  34626. * Lambda returning the list of potentially active meshes.
  34627. */
  34628. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34629. /**
  34630. * Lambda returning the list of potentially active sub meshes.
  34631. */
  34632. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34633. /**
  34634. * Lambda returning the list of potentially intersecting sub meshes.
  34635. */
  34636. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34637. /**
  34638. * Lambda returning the list of potentially colliding sub meshes.
  34639. */
  34640. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34641. private _activeMeshesFrozen;
  34642. /**
  34643. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34644. * @returns the current scene
  34645. */
  34646. freezeActiveMeshes(): Scene;
  34647. /**
  34648. * Use this function to restart evaluating active meshes on every frame
  34649. * @returns the current scene
  34650. */
  34651. unfreezeActiveMeshes(): Scene;
  34652. private _evaluateActiveMeshes;
  34653. private _activeMesh;
  34654. /**
  34655. * Update the transform matrix to update from the current active camera
  34656. * @param force defines a boolean used to force the update even if cache is up to date
  34657. */
  34658. updateTransformMatrix(force?: boolean): void;
  34659. private _bindFrameBuffer;
  34660. /** @hidden */
  34661. _allowPostProcessClearColor: boolean;
  34662. /** @hidden */
  34663. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34664. private _processSubCameras;
  34665. private _checkIntersections;
  34666. /** @hidden */
  34667. _advancePhysicsEngineStep(step: number): void;
  34668. /**
  34669. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34670. */
  34671. getDeterministicFrameTime: () => number;
  34672. /** @hidden */
  34673. _animate(): void;
  34674. /** Execute all animations (for a frame) */
  34675. animate(): void;
  34676. /**
  34677. * Render the scene
  34678. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34679. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34680. */
  34681. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34682. /**
  34683. * Freeze all materials
  34684. * A frozen material will not be updatable but should be faster to render
  34685. */
  34686. freezeMaterials(): void;
  34687. /**
  34688. * Unfreeze all materials
  34689. * A frozen material will not be updatable but should be faster to render
  34690. */
  34691. unfreezeMaterials(): void;
  34692. /**
  34693. * Releases all held ressources
  34694. */
  34695. dispose(): void;
  34696. /**
  34697. * Gets if the scene is already disposed
  34698. */
  34699. readonly isDisposed: boolean;
  34700. /**
  34701. * Call this function to reduce memory footprint of the scene.
  34702. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34703. */
  34704. clearCachedVertexData(): void;
  34705. /**
  34706. * This function will remove the local cached buffer data from texture.
  34707. * It will save memory but will prevent the texture from being rebuilt
  34708. */
  34709. cleanCachedTextureBuffer(): void;
  34710. /**
  34711. * Get the world extend vectors with an optional filter
  34712. *
  34713. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34714. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34715. */
  34716. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34717. min: Vector3;
  34718. max: Vector3;
  34719. };
  34720. /**
  34721. * Creates a ray that can be used to pick in the scene
  34722. * @param x defines the x coordinate of the origin (on-screen)
  34723. * @param y defines the y coordinate of the origin (on-screen)
  34724. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34725. * @param camera defines the camera to use for the picking
  34726. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34727. * @returns a Ray
  34728. */
  34729. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34730. /**
  34731. * Creates a ray that can be used to pick in the scene
  34732. * @param x defines the x coordinate of the origin (on-screen)
  34733. * @param y defines the y coordinate of the origin (on-screen)
  34734. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34735. * @param result defines the ray where to store the picking ray
  34736. * @param camera defines the camera to use for the picking
  34737. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34738. * @returns the current scene
  34739. */
  34740. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34741. /**
  34742. * Creates a ray that can be used to pick in the scene
  34743. * @param x defines the x coordinate of the origin (on-screen)
  34744. * @param y defines the y coordinate of the origin (on-screen)
  34745. * @param camera defines the camera to use for the picking
  34746. * @returns a Ray
  34747. */
  34748. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34749. /**
  34750. * Creates a ray that can be used to pick in the scene
  34751. * @param x defines the x coordinate of the origin (on-screen)
  34752. * @param y defines the y coordinate of the origin (on-screen)
  34753. * @param result defines the ray where to store the picking ray
  34754. * @param camera defines the camera to use for the picking
  34755. * @returns the current scene
  34756. */
  34757. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34758. /** Launch a ray to try to pick a mesh in the scene
  34759. * @param x position on screen
  34760. * @param y position on screen
  34761. * @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
  34762. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34763. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34765. * @returns a PickingInfo
  34766. */
  34767. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34768. /** Use the given ray to pick a mesh in the scene
  34769. * @param ray The ray to use to pick meshes
  34770. * @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
  34771. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34772. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34773. * @returns a PickingInfo
  34774. */
  34775. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34776. /**
  34777. * Launch a ray to try to pick a mesh in the scene
  34778. * @param x X position on screen
  34779. * @param y Y position on screen
  34780. * @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
  34781. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34782. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34783. * @returns an array of PickingInfo
  34784. */
  34785. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34786. /**
  34787. * Launch a ray to try to pick a mesh in the scene
  34788. * @param ray Ray to use
  34789. * @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
  34790. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34791. * @returns an array of PickingInfo
  34792. */
  34793. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34794. /**
  34795. * Force the value of meshUnderPointer
  34796. * @param mesh defines the mesh to use
  34797. */
  34798. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34799. /**
  34800. * Gets the mesh under the pointer
  34801. * @returns a Mesh or null if no mesh is under the pointer
  34802. */
  34803. getPointerOverMesh(): Nullable<AbstractMesh>;
  34804. /** @hidden */
  34805. _rebuildGeometries(): void;
  34806. /** @hidden */
  34807. _rebuildTextures(): void;
  34808. private _getByTags;
  34809. /**
  34810. * Get a list of meshes by tags
  34811. * @param tagsQuery defines the tags query to use
  34812. * @param forEach defines a predicate used to filter results
  34813. * @returns an array of Mesh
  34814. */
  34815. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34816. /**
  34817. * Get a list of cameras by tags
  34818. * @param tagsQuery defines the tags query to use
  34819. * @param forEach defines a predicate used to filter results
  34820. * @returns an array of Camera
  34821. */
  34822. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34823. /**
  34824. * Get a list of lights by tags
  34825. * @param tagsQuery defines the tags query to use
  34826. * @param forEach defines a predicate used to filter results
  34827. * @returns an array of Light
  34828. */
  34829. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34830. /**
  34831. * Get a list of materials by tags
  34832. * @param tagsQuery defines the tags query to use
  34833. * @param forEach defines a predicate used to filter results
  34834. * @returns an array of Material
  34835. */
  34836. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34837. /**
  34838. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34839. * This allowed control for front to back rendering or reversly depending of the special needs.
  34840. *
  34841. * @param renderingGroupId The rendering group id corresponding to its index
  34842. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34843. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34844. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34845. */
  34846. 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;
  34847. /**
  34848. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34849. *
  34850. * @param renderingGroupId The rendering group id corresponding to its index
  34851. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34852. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34853. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34854. */
  34855. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34856. /**
  34857. * Gets the current auto clear configuration for one rendering group of the rendering
  34858. * manager.
  34859. * @param index the rendering group index to get the information for
  34860. * @returns The auto clear setup for the requested rendering group
  34861. */
  34862. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34863. private _blockMaterialDirtyMechanism;
  34864. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34865. blockMaterialDirtyMechanism: boolean;
  34866. /**
  34867. * Will flag all materials as dirty to trigger new shader compilation
  34868. * @param flag defines the flag used to specify which material part must be marked as dirty
  34869. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34870. */
  34871. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34872. /** @hidden */
  34873. _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;
  34874. /** @hidden */
  34875. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34876. /** @hidden */
  34877. _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;
  34878. /** @hidden */
  34879. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34880. /** @hidden */
  34881. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34882. /** @hidden */
  34883. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34884. }
  34885. }
  34886. declare module BABYLON {
  34887. /**
  34888. * Set of assets to keep when moving a scene into an asset container.
  34889. */
  34890. export class KeepAssets extends AbstractScene {
  34891. }
  34892. /**
  34893. * Container with a set of assets that can be added or removed from a scene.
  34894. */
  34895. export class AssetContainer extends AbstractScene {
  34896. /**
  34897. * The scene the AssetContainer belongs to.
  34898. */
  34899. scene: Scene;
  34900. /**
  34901. * Instantiates an AssetContainer.
  34902. * @param scene The scene the AssetContainer belongs to.
  34903. */
  34904. constructor(scene: Scene);
  34905. /**
  34906. * Adds all the assets from the container to the scene.
  34907. */
  34908. addAllToScene(): void;
  34909. /**
  34910. * Removes all the assets in the container from the scene
  34911. */
  34912. removeAllFromScene(): void;
  34913. /**
  34914. * Disposes all the assets in the container
  34915. */
  34916. dispose(): void;
  34917. private _moveAssets;
  34918. /**
  34919. * Removes all the assets contained in the scene and adds them to the container.
  34920. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34921. */
  34922. moveAllFromScene(keepAssets?: KeepAssets): void;
  34923. /**
  34924. * 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.
  34925. * @returns the root mesh
  34926. */
  34927. createRootMesh(): Mesh;
  34928. }
  34929. }
  34930. declare module BABYLON {
  34931. /**
  34932. * Defines how the parser contract is defined.
  34933. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34934. */
  34935. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34936. /**
  34937. * Defines how the individual parser contract is defined.
  34938. * These parser can parse an individual asset
  34939. */
  34940. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34941. /**
  34942. * Base class of the scene acting as a container for the different elements composing a scene.
  34943. * This class is dynamically extended by the different components of the scene increasing
  34944. * flexibility and reducing coupling
  34945. */
  34946. export abstract class AbstractScene {
  34947. /**
  34948. * Stores the list of available parsers in the application.
  34949. */
  34950. private static _BabylonFileParsers;
  34951. /**
  34952. * Stores the list of available individual parsers in the application.
  34953. */
  34954. private static _IndividualBabylonFileParsers;
  34955. /**
  34956. * Adds a parser in the list of available ones
  34957. * @param name Defines the name of the parser
  34958. * @param parser Defines the parser to add
  34959. */
  34960. static AddParser(name: string, parser: BabylonFileParser): void;
  34961. /**
  34962. * Gets a general parser from the list of avaialble ones
  34963. * @param name Defines the name of the parser
  34964. * @returns the requested parser or null
  34965. */
  34966. static GetParser(name: string): Nullable<BabylonFileParser>;
  34967. /**
  34968. * Adds n individual parser in the list of available ones
  34969. * @param name Defines the name of the parser
  34970. * @param parser Defines the parser to add
  34971. */
  34972. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34973. /**
  34974. * Gets an individual parser from the list of avaialble ones
  34975. * @param name Defines the name of the parser
  34976. * @returns the requested parser or null
  34977. */
  34978. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34979. /**
  34980. * Parser json data and populate both a scene and its associated container object
  34981. * @param jsonData Defines the data to parse
  34982. * @param scene Defines the scene to parse the data for
  34983. * @param container Defines the container attached to the parsing sequence
  34984. * @param rootUrl Defines the root url of the data
  34985. */
  34986. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34987. /**
  34988. * Gets the list of root nodes (ie. nodes with no parent)
  34989. */
  34990. rootNodes: Node[];
  34991. /** All of the cameras added to this scene
  34992. * @see http://doc.babylonjs.com/babylon101/cameras
  34993. */
  34994. cameras: Camera[];
  34995. /**
  34996. * All of the lights added to this scene
  34997. * @see http://doc.babylonjs.com/babylon101/lights
  34998. */
  34999. lights: Light[];
  35000. /**
  35001. * All of the (abstract) meshes added to this scene
  35002. */
  35003. meshes: AbstractMesh[];
  35004. /**
  35005. * The list of skeletons added to the scene
  35006. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35007. */
  35008. skeletons: Skeleton[];
  35009. /**
  35010. * All of the particle systems added to this scene
  35011. * @see http://doc.babylonjs.com/babylon101/particles
  35012. */
  35013. particleSystems: IParticleSystem[];
  35014. /**
  35015. * Gets a list of Animations associated with the scene
  35016. */
  35017. animations: Animation[];
  35018. /**
  35019. * All of the animation groups added to this scene
  35020. * @see http://doc.babylonjs.com/how_to/group
  35021. */
  35022. animationGroups: AnimationGroup[];
  35023. /**
  35024. * All of the multi-materials added to this scene
  35025. * @see http://doc.babylonjs.com/how_to/multi_materials
  35026. */
  35027. multiMaterials: MultiMaterial[];
  35028. /**
  35029. * All of the materials added to this scene
  35030. * In the context of a Scene, it is not supposed to be modified manually.
  35031. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35032. * Note also that the order of the Material wihin the array is not significant and might change.
  35033. * @see http://doc.babylonjs.com/babylon101/materials
  35034. */
  35035. materials: Material[];
  35036. /**
  35037. * The list of morph target managers added to the scene
  35038. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35039. */
  35040. morphTargetManagers: MorphTargetManager[];
  35041. /**
  35042. * The list of geometries used in the scene.
  35043. */
  35044. geometries: Geometry[];
  35045. /**
  35046. * All of the tranform nodes added to this scene
  35047. * In the context of a Scene, it is not supposed to be modified manually.
  35048. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35049. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35050. * @see http://doc.babylonjs.com/how_to/transformnode
  35051. */
  35052. transformNodes: TransformNode[];
  35053. /**
  35054. * ActionManagers available on the scene.
  35055. */
  35056. actionManagers: AbstractActionManager[];
  35057. /**
  35058. * Textures to keep.
  35059. */
  35060. textures: BaseTexture[];
  35061. /**
  35062. * Environment texture for the scene
  35063. */
  35064. environmentTexture: Nullable<BaseTexture>;
  35065. }
  35066. }
  35067. declare module BABYLON {
  35068. /**
  35069. * Interface used to define options for Sound class
  35070. */
  35071. export interface ISoundOptions {
  35072. /**
  35073. * Does the sound autoplay once loaded.
  35074. */
  35075. autoplay?: boolean;
  35076. /**
  35077. * Does the sound loop after it finishes playing once.
  35078. */
  35079. loop?: boolean;
  35080. /**
  35081. * Sound's volume
  35082. */
  35083. volume?: number;
  35084. /**
  35085. * Is it a spatial sound?
  35086. */
  35087. spatialSound?: boolean;
  35088. /**
  35089. * Maximum distance to hear that sound
  35090. */
  35091. maxDistance?: number;
  35092. /**
  35093. * Uses user defined attenuation function
  35094. */
  35095. useCustomAttenuation?: boolean;
  35096. /**
  35097. * Define the roll off factor of spatial sounds.
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35099. */
  35100. rolloffFactor?: number;
  35101. /**
  35102. * Define the reference distance the sound should be heard perfectly.
  35103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35104. */
  35105. refDistance?: number;
  35106. /**
  35107. * Define the distance attenuation model the sound will follow.
  35108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35109. */
  35110. distanceModel?: string;
  35111. /**
  35112. * Defines the playback speed (1 by default)
  35113. */
  35114. playbackRate?: number;
  35115. /**
  35116. * Defines if the sound is from a streaming source
  35117. */
  35118. streaming?: boolean;
  35119. /**
  35120. * Defines an optional length (in seconds) inside the sound file
  35121. */
  35122. length?: number;
  35123. /**
  35124. * Defines an optional offset (in seconds) inside the sound file
  35125. */
  35126. offset?: number;
  35127. /**
  35128. * If true, URLs will not be required to state the audio file codec to use.
  35129. */
  35130. skipCodecCheck?: boolean;
  35131. }
  35132. /**
  35133. * Defines a sound that can be played in the application.
  35134. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35136. */
  35137. export class Sound {
  35138. /**
  35139. * The name of the sound in the scene.
  35140. */
  35141. name: string;
  35142. /**
  35143. * Does the sound autoplay once loaded.
  35144. */
  35145. autoplay: boolean;
  35146. /**
  35147. * Does the sound loop after it finishes playing once.
  35148. */
  35149. loop: boolean;
  35150. /**
  35151. * Does the sound use a custom attenuation curve to simulate the falloff
  35152. * happening when the source gets further away from the camera.
  35153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35154. */
  35155. useCustomAttenuation: boolean;
  35156. /**
  35157. * The sound track id this sound belongs to.
  35158. */
  35159. soundTrackId: number;
  35160. /**
  35161. * Is this sound currently played.
  35162. */
  35163. isPlaying: boolean;
  35164. /**
  35165. * Is this sound currently paused.
  35166. */
  35167. isPaused: boolean;
  35168. /**
  35169. * Does this sound enables spatial sound.
  35170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35171. */
  35172. spatialSound: boolean;
  35173. /**
  35174. * Define the reference distance the sound should be heard perfectly.
  35175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35176. */
  35177. refDistance: number;
  35178. /**
  35179. * Define the roll off factor of spatial sounds.
  35180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35181. */
  35182. rolloffFactor: number;
  35183. /**
  35184. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35186. */
  35187. maxDistance: number;
  35188. /**
  35189. * Define the distance attenuation model the sound will follow.
  35190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35191. */
  35192. distanceModel: string;
  35193. /**
  35194. * @hidden
  35195. * Back Compat
  35196. **/
  35197. onended: () => any;
  35198. /**
  35199. * Observable event when the current playing sound finishes.
  35200. */
  35201. onEndedObservable: Observable<Sound>;
  35202. private _panningModel;
  35203. private _playbackRate;
  35204. private _streaming;
  35205. private _startTime;
  35206. private _startOffset;
  35207. private _position;
  35208. /** @hidden */
  35209. _positionInEmitterSpace: boolean;
  35210. private _localDirection;
  35211. private _volume;
  35212. private _isReadyToPlay;
  35213. private _isDirectional;
  35214. private _readyToPlayCallback;
  35215. private _audioBuffer;
  35216. private _soundSource;
  35217. private _streamingSource;
  35218. private _soundPanner;
  35219. private _soundGain;
  35220. private _inputAudioNode;
  35221. private _outputAudioNode;
  35222. private _coneInnerAngle;
  35223. private _coneOuterAngle;
  35224. private _coneOuterGain;
  35225. private _scene;
  35226. private _connectedTransformNode;
  35227. private _customAttenuationFunction;
  35228. private _registerFunc;
  35229. private _isOutputConnected;
  35230. private _htmlAudioElement;
  35231. private _urlType;
  35232. private _length?;
  35233. private _offset?;
  35234. /** @hidden */
  35235. static _SceneComponentInitialization: (scene: Scene) => void;
  35236. /**
  35237. * Create a sound and attach it to a scene
  35238. * @param name Name of your sound
  35239. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35240. * @param scene defines the scene the sound belongs to
  35241. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35242. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35243. */
  35244. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35245. /**
  35246. * Release the sound and its associated resources
  35247. */
  35248. dispose(): void;
  35249. /**
  35250. * Gets if the sounds is ready to be played or not.
  35251. * @returns true if ready, otherwise false
  35252. */
  35253. isReady(): boolean;
  35254. private _soundLoaded;
  35255. /**
  35256. * Sets the data of the sound from an audiobuffer
  35257. * @param audioBuffer The audioBuffer containing the data
  35258. */
  35259. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35260. /**
  35261. * Updates the current sounds options such as maxdistance, loop...
  35262. * @param options A JSON object containing values named as the object properties
  35263. */
  35264. updateOptions(options: ISoundOptions): void;
  35265. private _createSpatialParameters;
  35266. private _updateSpatialParameters;
  35267. /**
  35268. * Switch the panning model to HRTF:
  35269. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35271. */
  35272. switchPanningModelToHRTF(): void;
  35273. /**
  35274. * Switch the panning model to Equal Power:
  35275. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35277. */
  35278. switchPanningModelToEqualPower(): void;
  35279. private _switchPanningModel;
  35280. /**
  35281. * Connect this sound to a sound track audio node like gain...
  35282. * @param soundTrackAudioNode the sound track audio node to connect to
  35283. */
  35284. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35285. /**
  35286. * Transform this sound into a directional source
  35287. * @param coneInnerAngle Size of the inner cone in degree
  35288. * @param coneOuterAngle Size of the outer cone in degree
  35289. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35290. */
  35291. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35292. /**
  35293. * Gets or sets the inner angle for the directional cone.
  35294. */
  35295. /**
  35296. * Gets or sets the inner angle for the directional cone.
  35297. */
  35298. directionalConeInnerAngle: number;
  35299. /**
  35300. * Gets or sets the outer angle for the directional cone.
  35301. */
  35302. /**
  35303. * Gets or sets the outer angle for the directional cone.
  35304. */
  35305. directionalConeOuterAngle: number;
  35306. /**
  35307. * Sets the position of the emitter if spatial sound is enabled
  35308. * @param newPosition Defines the new posisiton
  35309. */
  35310. setPosition(newPosition: Vector3): void;
  35311. /**
  35312. * Sets the local direction of the emitter if spatial sound is enabled
  35313. * @param newLocalDirection Defines the new local direction
  35314. */
  35315. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35316. private _updateDirection;
  35317. /** @hidden */
  35318. updateDistanceFromListener(): void;
  35319. /**
  35320. * Sets a new custom attenuation function for the sound.
  35321. * @param callback Defines the function used for the attenuation
  35322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35323. */
  35324. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35325. /**
  35326. * Play the sound
  35327. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35328. * @param offset (optional) Start the sound at a specific time in seconds
  35329. * @param length (optional) Sound duration (in seconds)
  35330. */
  35331. play(time?: number, offset?: number, length?: number): void;
  35332. private _onended;
  35333. /**
  35334. * Stop the sound
  35335. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35336. */
  35337. stop(time?: number): void;
  35338. /**
  35339. * Put the sound in pause
  35340. */
  35341. pause(): void;
  35342. /**
  35343. * Sets a dedicated volume for this sounds
  35344. * @param newVolume Define the new volume of the sound
  35345. * @param time Define time for gradual change to new volume
  35346. */
  35347. setVolume(newVolume: number, time?: number): void;
  35348. /**
  35349. * Set the sound play back rate
  35350. * @param newPlaybackRate Define the playback rate the sound should be played at
  35351. */
  35352. setPlaybackRate(newPlaybackRate: number): void;
  35353. /**
  35354. * Gets the volume of the sound.
  35355. * @returns the volume of the sound
  35356. */
  35357. getVolume(): number;
  35358. /**
  35359. * Attach the sound to a dedicated mesh
  35360. * @param transformNode The transform node to connect the sound with
  35361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35362. */
  35363. attachToMesh(transformNode: TransformNode): void;
  35364. /**
  35365. * Detach the sound from the previously attached mesh
  35366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35367. */
  35368. detachFromMesh(): void;
  35369. private _onRegisterAfterWorldMatrixUpdate;
  35370. /**
  35371. * Clone the current sound in the scene.
  35372. * @returns the new sound clone
  35373. */
  35374. clone(): Nullable<Sound>;
  35375. /**
  35376. * Gets the current underlying audio buffer containing the data
  35377. * @returns the audio buffer
  35378. */
  35379. getAudioBuffer(): Nullable<AudioBuffer>;
  35380. /**
  35381. * Serializes the Sound in a JSON representation
  35382. * @returns the JSON representation of the sound
  35383. */
  35384. serialize(): any;
  35385. /**
  35386. * Parse a JSON representation of a sound to innstantiate in a given scene
  35387. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35388. * @param scene Define the scene the new parsed sound should be created in
  35389. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35390. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35391. * @returns the newly parsed sound
  35392. */
  35393. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35394. }
  35395. }
  35396. declare module BABYLON {
  35397. /**
  35398. * This defines an action helpful to play a defined sound on a triggered action.
  35399. */
  35400. export class PlaySoundAction extends Action {
  35401. private _sound;
  35402. /**
  35403. * Instantiate the action
  35404. * @param triggerOptions defines the trigger options
  35405. * @param sound defines the sound to play
  35406. * @param condition defines the trigger related conditions
  35407. */
  35408. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35409. /** @hidden */
  35410. _prepare(): void;
  35411. /**
  35412. * Execute the action and play the sound.
  35413. */
  35414. execute(): void;
  35415. /**
  35416. * Serializes the actions and its related information.
  35417. * @param parent defines the object to serialize in
  35418. * @returns the serialized object
  35419. */
  35420. serialize(parent: any): any;
  35421. }
  35422. /**
  35423. * This defines an action helpful to stop a defined sound on a triggered action.
  35424. */
  35425. export class StopSoundAction extends Action {
  35426. private _sound;
  35427. /**
  35428. * Instantiate the action
  35429. * @param triggerOptions defines the trigger options
  35430. * @param sound defines the sound to stop
  35431. * @param condition defines the trigger related conditions
  35432. */
  35433. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35434. /** @hidden */
  35435. _prepare(): void;
  35436. /**
  35437. * Execute the action and stop the sound.
  35438. */
  35439. execute(): void;
  35440. /**
  35441. * Serializes the actions and its related information.
  35442. * @param parent defines the object to serialize in
  35443. * @returns the serialized object
  35444. */
  35445. serialize(parent: any): any;
  35446. }
  35447. }
  35448. declare module BABYLON {
  35449. /**
  35450. * This defines an action responsible to change the value of a property
  35451. * by interpolating between its current value and the newly set one once triggered.
  35452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35453. */
  35454. export class InterpolateValueAction extends Action {
  35455. /**
  35456. * Defines the path of the property where the value should be interpolated
  35457. */
  35458. propertyPath: string;
  35459. /**
  35460. * Defines the target value at the end of the interpolation.
  35461. */
  35462. value: any;
  35463. /**
  35464. * Defines the time it will take for the property to interpolate to the value.
  35465. */
  35466. duration: number;
  35467. /**
  35468. * Defines if the other scene animations should be stopped when the action has been triggered
  35469. */
  35470. stopOtherAnimations?: boolean;
  35471. /**
  35472. * Defines a callback raised once the interpolation animation has been done.
  35473. */
  35474. onInterpolationDone?: () => void;
  35475. /**
  35476. * Observable triggered once the interpolation animation has been done.
  35477. */
  35478. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35479. private _target;
  35480. private _effectiveTarget;
  35481. private _property;
  35482. /**
  35483. * Instantiate the action
  35484. * @param triggerOptions defines the trigger options
  35485. * @param target defines the object containing the value to interpolate
  35486. * @param propertyPath defines the path to the property in the target object
  35487. * @param value defines the target value at the end of the interpolation
  35488. * @param duration deines the time it will take for the property to interpolate to the value.
  35489. * @param condition defines the trigger related conditions
  35490. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35491. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35492. */
  35493. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35494. /** @hidden */
  35495. _prepare(): void;
  35496. /**
  35497. * Execute the action starts the value interpolation.
  35498. */
  35499. execute(): void;
  35500. /**
  35501. * Serializes the actions and its related information.
  35502. * @param parent defines the object to serialize in
  35503. * @returns the serialized object
  35504. */
  35505. serialize(parent: any): any;
  35506. }
  35507. }
  35508. declare module BABYLON {
  35509. /**
  35510. * Options allowed during the creation of a sound track.
  35511. */
  35512. export interface ISoundTrackOptions {
  35513. /**
  35514. * The volume the sound track should take during creation
  35515. */
  35516. volume?: number;
  35517. /**
  35518. * Define if the sound track is the main sound track of the scene
  35519. */
  35520. mainTrack?: boolean;
  35521. }
  35522. /**
  35523. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35524. * It will be also used in a future release to apply effects on a specific track.
  35525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35526. */
  35527. export class SoundTrack {
  35528. /**
  35529. * The unique identifier of the sound track in the scene.
  35530. */
  35531. id: number;
  35532. /**
  35533. * The list of sounds included in the sound track.
  35534. */
  35535. soundCollection: Array<Sound>;
  35536. private _outputAudioNode;
  35537. private _scene;
  35538. private _isMainTrack;
  35539. private _connectedAnalyser;
  35540. private _options;
  35541. private _isInitialized;
  35542. /**
  35543. * Creates a new sound track.
  35544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35545. * @param scene Define the scene the sound track belongs to
  35546. * @param options
  35547. */
  35548. constructor(scene: Scene, options?: ISoundTrackOptions);
  35549. private _initializeSoundTrackAudioGraph;
  35550. /**
  35551. * Release the sound track and its associated resources
  35552. */
  35553. dispose(): void;
  35554. /**
  35555. * Adds a sound to this sound track
  35556. * @param sound define the cound to add
  35557. * @ignoreNaming
  35558. */
  35559. AddSound(sound: Sound): void;
  35560. /**
  35561. * Removes a sound to this sound track
  35562. * @param sound define the cound to remove
  35563. * @ignoreNaming
  35564. */
  35565. RemoveSound(sound: Sound): void;
  35566. /**
  35567. * Set a global volume for the full sound track.
  35568. * @param newVolume Define the new volume of the sound track
  35569. */
  35570. setVolume(newVolume: number): void;
  35571. /**
  35572. * Switch the panning model to HRTF:
  35573. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35575. */
  35576. switchPanningModelToHRTF(): void;
  35577. /**
  35578. * Switch the panning model to Equal Power:
  35579. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35581. */
  35582. switchPanningModelToEqualPower(): void;
  35583. /**
  35584. * Connect the sound track to an audio analyser allowing some amazing
  35585. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35587. * @param analyser The analyser to connect to the engine
  35588. */
  35589. connectToAnalyser(analyser: Analyser): void;
  35590. }
  35591. }
  35592. declare module BABYLON {
  35593. interface AbstractScene {
  35594. /**
  35595. * The list of sounds used in the scene.
  35596. */
  35597. sounds: Nullable<Array<Sound>>;
  35598. }
  35599. interface Scene {
  35600. /**
  35601. * @hidden
  35602. * Backing field
  35603. */
  35604. _mainSoundTrack: SoundTrack;
  35605. /**
  35606. * The main sound track played by the scene.
  35607. * It cotains your primary collection of sounds.
  35608. */
  35609. mainSoundTrack: SoundTrack;
  35610. /**
  35611. * The list of sound tracks added to the scene
  35612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35613. */
  35614. soundTracks: Nullable<Array<SoundTrack>>;
  35615. /**
  35616. * Gets a sound using a given name
  35617. * @param name defines the name to search for
  35618. * @return the found sound or null if not found at all.
  35619. */
  35620. getSoundByName(name: string): Nullable<Sound>;
  35621. /**
  35622. * Gets or sets if audio support is enabled
  35623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35624. */
  35625. audioEnabled: boolean;
  35626. /**
  35627. * Gets or sets if audio will be output to headphones
  35628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35629. */
  35630. headphone: boolean;
  35631. /**
  35632. * Gets or sets custom audio listener position provider
  35633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35634. */
  35635. audioListenerPositionProvider: Nullable<() => Vector3>;
  35636. }
  35637. /**
  35638. * Defines the sound scene component responsible to manage any sounds
  35639. * in a given scene.
  35640. */
  35641. export class AudioSceneComponent implements ISceneSerializableComponent {
  35642. /**
  35643. * The component name helpfull to identify the component in the list of scene components.
  35644. */
  35645. readonly name: string;
  35646. /**
  35647. * The scene the component belongs to.
  35648. */
  35649. scene: Scene;
  35650. private _audioEnabled;
  35651. /**
  35652. * Gets whether audio is enabled or not.
  35653. * Please use related enable/disable method to switch state.
  35654. */
  35655. readonly audioEnabled: boolean;
  35656. private _headphone;
  35657. /**
  35658. * Gets whether audio is outputing to headphone or not.
  35659. * Please use the according Switch methods to change output.
  35660. */
  35661. readonly headphone: boolean;
  35662. private _audioListenerPositionProvider;
  35663. /**
  35664. * Gets the current audio listener position provider
  35665. */
  35666. /**
  35667. * Sets a custom listener position for all sounds in the scene
  35668. * By default, this is the position of the first active camera
  35669. */
  35670. audioListenerPositionProvider: Nullable<() => Vector3>;
  35671. /**
  35672. * Creates a new instance of the component for the given scene
  35673. * @param scene Defines the scene to register the component in
  35674. */
  35675. constructor(scene: Scene);
  35676. /**
  35677. * Registers the component in a given scene
  35678. */
  35679. register(): void;
  35680. /**
  35681. * Rebuilds the elements related to this component in case of
  35682. * context lost for instance.
  35683. */
  35684. rebuild(): void;
  35685. /**
  35686. * Serializes the component data to the specified json object
  35687. * @param serializationObject The object to serialize to
  35688. */
  35689. serialize(serializationObject: any): void;
  35690. /**
  35691. * Adds all the elements from the container to the scene
  35692. * @param container the container holding the elements
  35693. */
  35694. addFromContainer(container: AbstractScene): void;
  35695. /**
  35696. * Removes all the elements in the container from the scene
  35697. * @param container contains the elements to remove
  35698. * @param dispose if the removed element should be disposed (default: false)
  35699. */
  35700. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35701. /**
  35702. * Disposes the component and the associated ressources.
  35703. */
  35704. dispose(): void;
  35705. /**
  35706. * Disables audio in the associated scene.
  35707. */
  35708. disableAudio(): void;
  35709. /**
  35710. * Enables audio in the associated scene.
  35711. */
  35712. enableAudio(): void;
  35713. /**
  35714. * Switch audio to headphone output.
  35715. */
  35716. switchAudioModeForHeadphones(): void;
  35717. /**
  35718. * Switch audio to normal speakers.
  35719. */
  35720. switchAudioModeForNormalSpeakers(): void;
  35721. private _afterRender;
  35722. }
  35723. }
  35724. declare module BABYLON {
  35725. /**
  35726. * Wraps one or more Sound objects and selects one with random weight for playback.
  35727. */
  35728. export class WeightedSound {
  35729. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35730. loop: boolean;
  35731. private _coneInnerAngle;
  35732. private _coneOuterAngle;
  35733. private _volume;
  35734. /** A Sound is currently playing. */
  35735. isPlaying: boolean;
  35736. /** A Sound is currently paused. */
  35737. isPaused: boolean;
  35738. private _sounds;
  35739. private _weights;
  35740. private _currentIndex?;
  35741. /**
  35742. * Creates a new WeightedSound from the list of sounds given.
  35743. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35744. * @param sounds Array of Sounds that will be selected from.
  35745. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35746. */
  35747. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35748. /**
  35749. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35750. */
  35751. /**
  35752. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35753. */
  35754. directionalConeInnerAngle: number;
  35755. /**
  35756. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35757. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35758. */
  35759. /**
  35760. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35761. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35762. */
  35763. directionalConeOuterAngle: number;
  35764. /**
  35765. * Playback volume.
  35766. */
  35767. /**
  35768. * Playback volume.
  35769. */
  35770. volume: number;
  35771. private _onended;
  35772. /**
  35773. * Suspend playback
  35774. */
  35775. pause(): void;
  35776. /**
  35777. * Stop playback
  35778. */
  35779. stop(): void;
  35780. /**
  35781. * Start playback.
  35782. * @param startOffset Position the clip head at a specific time in seconds.
  35783. */
  35784. play(startOffset?: number): void;
  35785. }
  35786. }
  35787. declare module BABYLON {
  35788. /**
  35789. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35791. */
  35792. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35793. /**
  35794. * Gets the name of the behavior.
  35795. */
  35796. readonly name: string;
  35797. /**
  35798. * The easing function used by animations
  35799. */
  35800. static EasingFunction: BackEase;
  35801. /**
  35802. * The easing mode used by animations
  35803. */
  35804. static EasingMode: number;
  35805. /**
  35806. * The duration of the animation, in milliseconds
  35807. */
  35808. transitionDuration: number;
  35809. /**
  35810. * Length of the distance animated by the transition when lower radius is reached
  35811. */
  35812. lowerRadiusTransitionRange: number;
  35813. /**
  35814. * Length of the distance animated by the transition when upper radius is reached
  35815. */
  35816. upperRadiusTransitionRange: number;
  35817. private _autoTransitionRange;
  35818. /**
  35819. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35820. */
  35821. /**
  35822. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35823. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35824. */
  35825. autoTransitionRange: boolean;
  35826. private _attachedCamera;
  35827. private _onAfterCheckInputsObserver;
  35828. private _onMeshTargetChangedObserver;
  35829. /**
  35830. * Initializes the behavior.
  35831. */
  35832. init(): void;
  35833. /**
  35834. * Attaches the behavior to its arc rotate camera.
  35835. * @param camera Defines the camera to attach the behavior to
  35836. */
  35837. attach(camera: ArcRotateCamera): void;
  35838. /**
  35839. * Detaches the behavior from its current arc rotate camera.
  35840. */
  35841. detach(): void;
  35842. private _radiusIsAnimating;
  35843. private _radiusBounceTransition;
  35844. private _animatables;
  35845. private _cachedWheelPrecision;
  35846. /**
  35847. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35848. * @param radiusLimit The limit to check against.
  35849. * @return Bool to indicate if at limit.
  35850. */
  35851. private _isRadiusAtLimit;
  35852. /**
  35853. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35854. * @param radiusDelta The delta by which to animate to. Can be negative.
  35855. */
  35856. private _applyBoundRadiusAnimation;
  35857. /**
  35858. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35859. */
  35860. protected _clearAnimationLocks(): void;
  35861. /**
  35862. * Stops and removes all animations that have been applied to the camera
  35863. */
  35864. stopAllAnimations(): void;
  35865. }
  35866. }
  35867. declare module BABYLON {
  35868. /**
  35869. * 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.
  35870. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35871. */
  35872. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35873. /**
  35874. * Gets the name of the behavior.
  35875. */
  35876. readonly name: string;
  35877. private _mode;
  35878. private _radiusScale;
  35879. private _positionScale;
  35880. private _defaultElevation;
  35881. private _elevationReturnTime;
  35882. private _elevationReturnWaitTime;
  35883. private _zoomStopsAnimation;
  35884. private _framingTime;
  35885. /**
  35886. * The easing function used by animations
  35887. */
  35888. static EasingFunction: ExponentialEase;
  35889. /**
  35890. * The easing mode used by animations
  35891. */
  35892. static EasingMode: number;
  35893. /**
  35894. * Sets the current mode used by the behavior
  35895. */
  35896. /**
  35897. * Gets current mode used by the behavior.
  35898. */
  35899. mode: number;
  35900. /**
  35901. * Sets the scale applied to the radius (1 by default)
  35902. */
  35903. /**
  35904. * Gets the scale applied to the radius
  35905. */
  35906. radiusScale: number;
  35907. /**
  35908. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35909. */
  35910. /**
  35911. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35912. */
  35913. positionScale: number;
  35914. /**
  35915. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35916. * behaviour is triggered, in radians.
  35917. */
  35918. /**
  35919. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35920. * behaviour is triggered, in radians.
  35921. */
  35922. defaultElevation: number;
  35923. /**
  35924. * Sets the time (in milliseconds) taken to return to the default beta position.
  35925. * Negative value indicates camera should not return to default.
  35926. */
  35927. /**
  35928. * Gets the time (in milliseconds) taken to return to the default beta position.
  35929. * Negative value indicates camera should not return to default.
  35930. */
  35931. elevationReturnTime: number;
  35932. /**
  35933. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35934. */
  35935. /**
  35936. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35937. */
  35938. elevationReturnWaitTime: number;
  35939. /**
  35940. * Sets the flag that indicates if user zooming should stop animation.
  35941. */
  35942. /**
  35943. * Gets the flag that indicates if user zooming should stop animation.
  35944. */
  35945. zoomStopsAnimation: boolean;
  35946. /**
  35947. * Sets the transition time when framing the mesh, in milliseconds
  35948. */
  35949. /**
  35950. * Gets the transition time when framing the mesh, in milliseconds
  35951. */
  35952. framingTime: number;
  35953. /**
  35954. * Define if the behavior should automatically change the configured
  35955. * camera limits and sensibilities.
  35956. */
  35957. autoCorrectCameraLimitsAndSensibility: boolean;
  35958. private _onPrePointerObservableObserver;
  35959. private _onAfterCheckInputsObserver;
  35960. private _onMeshTargetChangedObserver;
  35961. private _attachedCamera;
  35962. private _isPointerDown;
  35963. private _lastInteractionTime;
  35964. /**
  35965. * Initializes the behavior.
  35966. */
  35967. init(): void;
  35968. /**
  35969. * Attaches the behavior to its arc rotate camera.
  35970. * @param camera Defines the camera to attach the behavior to
  35971. */
  35972. attach(camera: ArcRotateCamera): void;
  35973. /**
  35974. * Detaches the behavior from its current arc rotate camera.
  35975. */
  35976. detach(): void;
  35977. private _animatables;
  35978. private _betaIsAnimating;
  35979. private _betaTransition;
  35980. private _radiusTransition;
  35981. private _vectorTransition;
  35982. /**
  35983. * Targets the given mesh and updates zoom level accordingly.
  35984. * @param mesh The mesh to target.
  35985. * @param radius Optional. If a cached radius position already exists, overrides default.
  35986. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35987. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35988. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35989. */
  35990. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35991. /**
  35992. * Targets the given mesh with its children and updates zoom level accordingly.
  35993. * @param mesh The mesh to target.
  35994. * @param radius Optional. If a cached radius position already exists, overrides default.
  35995. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35996. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35997. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35998. */
  35999. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36000. /**
  36001. * Targets the given meshes with their children and updates zoom level accordingly.
  36002. * @param meshes The mesh to target.
  36003. * @param radius Optional. If a cached radius position already exists, overrides default.
  36004. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36005. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36006. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36007. */
  36008. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36009. /**
  36010. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36011. * @param minimumWorld Determines the smaller position of the bounding box extend
  36012. * @param maximumWorld Determines the bigger position of the bounding box extend
  36013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36015. */
  36016. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36017. /**
  36018. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36019. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36020. * frustum width.
  36021. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36022. * to fully enclose the mesh in the viewing frustum.
  36023. */
  36024. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36025. /**
  36026. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36027. * is automatically returned to its default position (expected to be above ground plane).
  36028. */
  36029. private _maintainCameraAboveGround;
  36030. /**
  36031. * Returns the frustum slope based on the canvas ratio and camera FOV
  36032. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36033. */
  36034. private _getFrustumSlope;
  36035. /**
  36036. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36037. */
  36038. private _clearAnimationLocks;
  36039. /**
  36040. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36041. */
  36042. private _applyUserInteraction;
  36043. /**
  36044. * Stops and removes all animations that have been applied to the camera
  36045. */
  36046. stopAllAnimations(): void;
  36047. /**
  36048. * Gets a value indicating if the user is moving the camera
  36049. */
  36050. readonly isUserIsMoving: boolean;
  36051. /**
  36052. * The camera can move all the way towards the mesh.
  36053. */
  36054. static IgnoreBoundsSizeMode: number;
  36055. /**
  36056. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36057. */
  36058. static FitFrustumSidesMode: number;
  36059. }
  36060. }
  36061. declare module BABYLON {
  36062. /**
  36063. * Base class for Camera Pointer Inputs.
  36064. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36065. * for example usage.
  36066. */
  36067. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36068. /**
  36069. * Defines the camera the input is attached to.
  36070. */
  36071. abstract camera: Camera;
  36072. /**
  36073. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36074. */
  36075. protected _altKey: boolean;
  36076. protected _ctrlKey: boolean;
  36077. protected _metaKey: boolean;
  36078. protected _shiftKey: boolean;
  36079. /**
  36080. * Which mouse buttons were pressed at time of last mouse event.
  36081. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36082. */
  36083. protected _buttonsPressed: number;
  36084. /**
  36085. * Defines the buttons associated with the input to handle camera move.
  36086. */
  36087. buttons: number[];
  36088. /**
  36089. * Attach the input controls to a specific dom element to get the input from.
  36090. * @param element Defines the element the controls should be listened from
  36091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36092. */
  36093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36094. /**
  36095. * Detach the current controls from the specified dom element.
  36096. * @param element Defines the element to stop listening the inputs from
  36097. */
  36098. detachControl(element: Nullable<HTMLElement>): void;
  36099. /**
  36100. * Gets the class name of the current input.
  36101. * @returns the class name
  36102. */
  36103. getClassName(): string;
  36104. /**
  36105. * Get the friendly name associated with the input class.
  36106. * @returns the input friendly name
  36107. */
  36108. getSimpleName(): string;
  36109. /**
  36110. * Called on pointer POINTERDOUBLETAP event.
  36111. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36112. */
  36113. protected onDoubleTap(type: string): void;
  36114. /**
  36115. * Called on pointer POINTERMOVE event if only a single touch is active.
  36116. * Override this method to provide functionality.
  36117. */
  36118. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36119. /**
  36120. * Called on pointer POINTERMOVE event if multiple touches are active.
  36121. * Override this method to provide functionality.
  36122. */
  36123. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36124. /**
  36125. * Called on JS contextmenu event.
  36126. * Override this method to provide functionality.
  36127. */
  36128. protected onContextMenu(evt: PointerEvent): void;
  36129. /**
  36130. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36131. * press.
  36132. * Override this method to provide functionality.
  36133. */
  36134. protected onButtonDown(evt: PointerEvent): void;
  36135. /**
  36136. * Called each time a new POINTERUP event occurs. Ie, for each button
  36137. * release.
  36138. * Override this method to provide functionality.
  36139. */
  36140. protected onButtonUp(evt: PointerEvent): void;
  36141. /**
  36142. * Called when window becomes inactive.
  36143. * Override this method to provide functionality.
  36144. */
  36145. protected onLostFocus(): void;
  36146. private _pointerInput;
  36147. private _observer;
  36148. private _onLostFocus;
  36149. private pointA;
  36150. private pointB;
  36151. }
  36152. }
  36153. declare module BABYLON {
  36154. /**
  36155. * Manage the pointers inputs to control an arc rotate camera.
  36156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36157. */
  36158. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36159. /**
  36160. * Defines the camera the input is attached to.
  36161. */
  36162. camera: ArcRotateCamera;
  36163. /**
  36164. * Gets the class name of the current input.
  36165. * @returns the class name
  36166. */
  36167. getClassName(): string;
  36168. /**
  36169. * Defines the buttons associated with the input to handle camera move.
  36170. */
  36171. buttons: number[];
  36172. /**
  36173. * Defines the pointer angular sensibility along the X axis or how fast is
  36174. * the camera rotating.
  36175. */
  36176. angularSensibilityX: number;
  36177. /**
  36178. * Defines the pointer angular sensibility along the Y axis or how fast is
  36179. * the camera rotating.
  36180. */
  36181. angularSensibilityY: number;
  36182. /**
  36183. * Defines the pointer pinch precision or how fast is the camera zooming.
  36184. */
  36185. pinchPrecision: number;
  36186. /**
  36187. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36188. * from 0.
  36189. * It defines the percentage of current camera.radius to use as delta when
  36190. * pinch zoom is used.
  36191. */
  36192. pinchDeltaPercentage: number;
  36193. /**
  36194. * Defines the pointer panning sensibility or how fast is the camera moving.
  36195. */
  36196. panningSensibility: number;
  36197. /**
  36198. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36199. */
  36200. multiTouchPanning: boolean;
  36201. /**
  36202. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36203. * zoom (pinch) through multitouch.
  36204. */
  36205. multiTouchPanAndZoom: boolean;
  36206. /**
  36207. * Revers pinch action direction.
  36208. */
  36209. pinchInwards: boolean;
  36210. private _isPanClick;
  36211. private _twoFingerActivityCount;
  36212. private _isPinching;
  36213. /**
  36214. * Called on pointer POINTERMOVE event if only a single touch is active.
  36215. */
  36216. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36217. /**
  36218. * Called on pointer POINTERDOUBLETAP event.
  36219. */
  36220. protected onDoubleTap(type: string): void;
  36221. /**
  36222. * Called on pointer POINTERMOVE event if multiple touches are active.
  36223. */
  36224. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36225. /**
  36226. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36227. * press.
  36228. */
  36229. protected onButtonDown(evt: PointerEvent): void;
  36230. /**
  36231. * Called each time a new POINTERUP event occurs. Ie, for each button
  36232. * release.
  36233. */
  36234. protected onButtonUp(evt: PointerEvent): void;
  36235. /**
  36236. * Called when window becomes inactive.
  36237. */
  36238. protected onLostFocus(): void;
  36239. }
  36240. }
  36241. declare module BABYLON {
  36242. /**
  36243. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36245. */
  36246. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36247. /**
  36248. * Defines the camera the input is attached to.
  36249. */
  36250. camera: ArcRotateCamera;
  36251. /**
  36252. * Defines the list of key codes associated with the up action (increase alpha)
  36253. */
  36254. keysUp: number[];
  36255. /**
  36256. * Defines the list of key codes associated with the down action (decrease alpha)
  36257. */
  36258. keysDown: number[];
  36259. /**
  36260. * Defines the list of key codes associated with the left action (increase beta)
  36261. */
  36262. keysLeft: number[];
  36263. /**
  36264. * Defines the list of key codes associated with the right action (decrease beta)
  36265. */
  36266. keysRight: number[];
  36267. /**
  36268. * Defines the list of key codes associated with the reset action.
  36269. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36270. */
  36271. keysReset: number[];
  36272. /**
  36273. * Defines the panning sensibility of the inputs.
  36274. * (How fast is the camera paning)
  36275. */
  36276. panningSensibility: number;
  36277. /**
  36278. * Defines the zooming sensibility of the inputs.
  36279. * (How fast is the camera zooming)
  36280. */
  36281. zoomingSensibility: number;
  36282. /**
  36283. * Defines wether maintaining the alt key down switch the movement mode from
  36284. * orientation to zoom.
  36285. */
  36286. useAltToZoom: boolean;
  36287. /**
  36288. * Rotation speed of the camera
  36289. */
  36290. angularSpeed: number;
  36291. private _keys;
  36292. private _ctrlPressed;
  36293. private _altPressed;
  36294. private _onCanvasBlurObserver;
  36295. private _onKeyboardObserver;
  36296. private _engine;
  36297. private _scene;
  36298. /**
  36299. * Attach the input controls to a specific dom element to get the input from.
  36300. * @param element Defines the element the controls should be listened from
  36301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36302. */
  36303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36304. /**
  36305. * Detach the current controls from the specified dom element.
  36306. * @param element Defines the element to stop listening the inputs from
  36307. */
  36308. detachControl(element: Nullable<HTMLElement>): void;
  36309. /**
  36310. * Update the current camera state depending on the inputs that have been used this frame.
  36311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36312. */
  36313. checkInputs(): void;
  36314. /**
  36315. * Gets the class name of the current intput.
  36316. * @returns the class name
  36317. */
  36318. getClassName(): string;
  36319. /**
  36320. * Get the friendly name associated with the input class.
  36321. * @returns the input friendly name
  36322. */
  36323. getSimpleName(): string;
  36324. }
  36325. }
  36326. declare module BABYLON {
  36327. /**
  36328. * Manage the mouse wheel inputs to control an arc rotate camera.
  36329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36330. */
  36331. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36332. /**
  36333. * Defines the camera the input is attached to.
  36334. */
  36335. camera: ArcRotateCamera;
  36336. /**
  36337. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36338. */
  36339. wheelPrecision: number;
  36340. /**
  36341. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36342. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36343. */
  36344. wheelDeltaPercentage: number;
  36345. private _wheel;
  36346. private _observer;
  36347. private computeDeltaFromMouseWheelLegacyEvent;
  36348. /**
  36349. * Attach the input controls to a specific dom element to get the input from.
  36350. * @param element Defines the element the controls should be listened from
  36351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36352. */
  36353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36354. /**
  36355. * Detach the current controls from the specified dom element.
  36356. * @param element Defines the element to stop listening the inputs from
  36357. */
  36358. detachControl(element: Nullable<HTMLElement>): void;
  36359. /**
  36360. * Gets the class name of the current intput.
  36361. * @returns the class name
  36362. */
  36363. getClassName(): string;
  36364. /**
  36365. * Get the friendly name associated with the input class.
  36366. * @returns the input friendly name
  36367. */
  36368. getSimpleName(): string;
  36369. }
  36370. }
  36371. declare module BABYLON {
  36372. /**
  36373. * Default Inputs manager for the ArcRotateCamera.
  36374. * It groups all the default supported inputs for ease of use.
  36375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36376. */
  36377. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36378. /**
  36379. * Instantiates a new ArcRotateCameraInputsManager.
  36380. * @param camera Defines the camera the inputs belong to
  36381. */
  36382. constructor(camera: ArcRotateCamera);
  36383. /**
  36384. * Add mouse wheel input support to the input manager.
  36385. * @returns the current input manager
  36386. */
  36387. addMouseWheel(): ArcRotateCameraInputsManager;
  36388. /**
  36389. * Add pointers input support to the input manager.
  36390. * @returns the current input manager
  36391. */
  36392. addPointers(): ArcRotateCameraInputsManager;
  36393. /**
  36394. * Add keyboard input support to the input manager.
  36395. * @returns the current input manager
  36396. */
  36397. addKeyboard(): ArcRotateCameraInputsManager;
  36398. }
  36399. }
  36400. declare module BABYLON {
  36401. /**
  36402. * This represents an orbital type of camera.
  36403. *
  36404. * 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.
  36405. * 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.
  36406. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36407. */
  36408. export class ArcRotateCamera extends TargetCamera {
  36409. /**
  36410. * Defines the rotation angle of the camera along the longitudinal axis.
  36411. */
  36412. alpha: number;
  36413. /**
  36414. * Defines the rotation angle of the camera along the latitudinal axis.
  36415. */
  36416. beta: number;
  36417. /**
  36418. * Defines the radius of the camera from it s target point.
  36419. */
  36420. radius: number;
  36421. protected _target: Vector3;
  36422. protected _targetHost: Nullable<AbstractMesh>;
  36423. /**
  36424. * Defines the target point of the camera.
  36425. * The camera looks towards it form the radius distance.
  36426. */
  36427. target: Vector3;
  36428. /**
  36429. * Define the current local position of the camera in the scene
  36430. */
  36431. position: Vector3;
  36432. protected _upVector: Vector3;
  36433. protected _upToYMatrix: Matrix;
  36434. protected _YToUpMatrix: Matrix;
  36435. /**
  36436. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36437. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36438. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36439. */
  36440. upVector: Vector3;
  36441. /**
  36442. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36443. */
  36444. setMatUp(): void;
  36445. /**
  36446. * Current inertia value on the longitudinal axis.
  36447. * The bigger this number the longer it will take for the camera to stop.
  36448. */
  36449. inertialAlphaOffset: number;
  36450. /**
  36451. * Current inertia value on the latitudinal axis.
  36452. * The bigger this number the longer it will take for the camera to stop.
  36453. */
  36454. inertialBetaOffset: number;
  36455. /**
  36456. * Current inertia value on the radius axis.
  36457. * The bigger this number the longer it will take for the camera to stop.
  36458. */
  36459. inertialRadiusOffset: number;
  36460. /**
  36461. * Minimum allowed angle on the longitudinal axis.
  36462. * This can help limiting how the Camera is able to move in the scene.
  36463. */
  36464. lowerAlphaLimit: Nullable<number>;
  36465. /**
  36466. * Maximum allowed angle on the longitudinal axis.
  36467. * This can help limiting how the Camera is able to move in the scene.
  36468. */
  36469. upperAlphaLimit: Nullable<number>;
  36470. /**
  36471. * Minimum allowed angle on the latitudinal axis.
  36472. * This can help limiting how the Camera is able to move in the scene.
  36473. */
  36474. lowerBetaLimit: number;
  36475. /**
  36476. * Maximum allowed angle on the latitudinal axis.
  36477. * This can help limiting how the Camera is able to move in the scene.
  36478. */
  36479. upperBetaLimit: number;
  36480. /**
  36481. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36482. * This can help limiting how the Camera is able to move in the scene.
  36483. */
  36484. lowerRadiusLimit: Nullable<number>;
  36485. /**
  36486. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36487. * This can help limiting how the Camera is able to move in the scene.
  36488. */
  36489. upperRadiusLimit: Nullable<number>;
  36490. /**
  36491. * Defines the current inertia value used during panning of the camera along the X axis.
  36492. */
  36493. inertialPanningX: number;
  36494. /**
  36495. * Defines the current inertia value used during panning of the camera along the Y axis.
  36496. */
  36497. inertialPanningY: number;
  36498. /**
  36499. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36500. * Basically if your fingers moves away from more than this distance you will be considered
  36501. * in pinch mode.
  36502. */
  36503. pinchToPanMaxDistance: number;
  36504. /**
  36505. * Defines the maximum distance the camera can pan.
  36506. * This could help keeping the cammera always in your scene.
  36507. */
  36508. panningDistanceLimit: Nullable<number>;
  36509. /**
  36510. * Defines the target of the camera before paning.
  36511. */
  36512. panningOriginTarget: Vector3;
  36513. /**
  36514. * Defines the value of the inertia used during panning.
  36515. * 0 would mean stop inertia and one would mean no decelleration at all.
  36516. */
  36517. panningInertia: number;
  36518. /**
  36519. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36520. */
  36521. angularSensibilityX: number;
  36522. /**
  36523. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36524. */
  36525. angularSensibilityY: number;
  36526. /**
  36527. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36528. */
  36529. pinchPrecision: number;
  36530. /**
  36531. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36532. * It will be used instead of pinchDeltaPrecision if different from 0.
  36533. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36534. */
  36535. pinchDeltaPercentage: number;
  36536. /**
  36537. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36538. */
  36539. panningSensibility: number;
  36540. /**
  36541. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36542. */
  36543. keysUp: number[];
  36544. /**
  36545. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36546. */
  36547. keysDown: number[];
  36548. /**
  36549. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36550. */
  36551. keysLeft: number[];
  36552. /**
  36553. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36554. */
  36555. keysRight: number[];
  36556. /**
  36557. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36558. */
  36559. wheelPrecision: number;
  36560. /**
  36561. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36562. * It will be used instead of pinchDeltaPrecision if different from 0.
  36563. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36564. */
  36565. wheelDeltaPercentage: number;
  36566. /**
  36567. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36568. */
  36569. zoomOnFactor: number;
  36570. /**
  36571. * Defines a screen offset for the camera position.
  36572. */
  36573. targetScreenOffset: Vector2;
  36574. /**
  36575. * Allows the camera to be completely reversed.
  36576. * If false the camera can not arrive upside down.
  36577. */
  36578. allowUpsideDown: boolean;
  36579. /**
  36580. * Define if double tap/click is used to restore the previously saved state of the camera.
  36581. */
  36582. useInputToRestoreState: boolean;
  36583. /** @hidden */
  36584. _viewMatrix: Matrix;
  36585. /** @hidden */
  36586. _useCtrlForPanning: boolean;
  36587. /** @hidden */
  36588. _panningMouseButton: number;
  36589. /**
  36590. * Defines the input associated to the camera.
  36591. */
  36592. inputs: ArcRotateCameraInputsManager;
  36593. /** @hidden */
  36594. _reset: () => void;
  36595. /**
  36596. * Defines the allowed panning axis.
  36597. */
  36598. panningAxis: Vector3;
  36599. protected _localDirection: Vector3;
  36600. protected _transformedDirection: Vector3;
  36601. private _bouncingBehavior;
  36602. /**
  36603. * Gets the bouncing behavior of the camera if it has been enabled.
  36604. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36605. */
  36606. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36607. /**
  36608. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36609. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36610. */
  36611. useBouncingBehavior: boolean;
  36612. private _framingBehavior;
  36613. /**
  36614. * Gets the framing behavior of the camera if it has been enabled.
  36615. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36616. */
  36617. readonly framingBehavior: Nullable<FramingBehavior>;
  36618. /**
  36619. * Defines if the framing behavior of the camera is enabled on the camera.
  36620. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36621. */
  36622. useFramingBehavior: boolean;
  36623. private _autoRotationBehavior;
  36624. /**
  36625. * Gets the auto rotation behavior of the camera if it has been enabled.
  36626. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36627. */
  36628. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36629. /**
  36630. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36632. */
  36633. useAutoRotationBehavior: boolean;
  36634. /**
  36635. * Observable triggered when the mesh target has been changed on the camera.
  36636. */
  36637. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36638. /**
  36639. * Event raised when the camera is colliding with a mesh.
  36640. */
  36641. onCollide: (collidedMesh: AbstractMesh) => void;
  36642. /**
  36643. * Defines whether the camera should check collision with the objects oh the scene.
  36644. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36645. */
  36646. checkCollisions: boolean;
  36647. /**
  36648. * Defines the collision radius of the camera.
  36649. * This simulates a sphere around the camera.
  36650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36651. */
  36652. collisionRadius: Vector3;
  36653. protected _collider: Collider;
  36654. protected _previousPosition: Vector3;
  36655. protected _collisionVelocity: Vector3;
  36656. protected _newPosition: Vector3;
  36657. protected _previousAlpha: number;
  36658. protected _previousBeta: number;
  36659. protected _previousRadius: number;
  36660. protected _collisionTriggered: boolean;
  36661. protected _targetBoundingCenter: Nullable<Vector3>;
  36662. private _computationVector;
  36663. /**
  36664. * Instantiates a new ArcRotateCamera in a given scene
  36665. * @param name Defines the name of the camera
  36666. * @param alpha Defines the camera rotation along the logitudinal axis
  36667. * @param beta Defines the camera rotation along the latitudinal axis
  36668. * @param radius Defines the camera distance from its target
  36669. * @param target Defines the camera target
  36670. * @param scene Defines the scene the camera belongs to
  36671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36672. */
  36673. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36674. /** @hidden */
  36675. _initCache(): void;
  36676. /** @hidden */
  36677. _updateCache(ignoreParentClass?: boolean): void;
  36678. protected _getTargetPosition(): Vector3;
  36679. private _storedAlpha;
  36680. private _storedBeta;
  36681. private _storedRadius;
  36682. private _storedTarget;
  36683. private _storedTargetScreenOffset;
  36684. /**
  36685. * Stores the current state of the camera (alpha, beta, radius and target)
  36686. * @returns the camera itself
  36687. */
  36688. storeState(): Camera;
  36689. /**
  36690. * @hidden
  36691. * Restored camera state. You must call storeState() first
  36692. */
  36693. _restoreStateValues(): boolean;
  36694. /** @hidden */
  36695. _isSynchronizedViewMatrix(): boolean;
  36696. /**
  36697. * Attached controls to the current camera.
  36698. * @param element Defines the element the controls should be listened from
  36699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36700. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36701. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36702. */
  36703. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36704. /**
  36705. * Detach the current controls from the camera.
  36706. * The camera will stop reacting to inputs.
  36707. * @param element Defines the element to stop listening the inputs from
  36708. */
  36709. detachControl(element: HTMLElement): void;
  36710. /** @hidden */
  36711. _checkInputs(): void;
  36712. protected _checkLimits(): void;
  36713. /**
  36714. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36715. */
  36716. rebuildAnglesAndRadius(): void;
  36717. /**
  36718. * Use a position to define the current camera related information like alpha, beta and radius
  36719. * @param position Defines the position to set the camera at
  36720. */
  36721. setPosition(position: Vector3): void;
  36722. /**
  36723. * Defines the target the camera should look at.
  36724. * This will automatically adapt alpha beta and radius to fit within the new target.
  36725. * @param target Defines the new target as a Vector or a mesh
  36726. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36727. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36728. */
  36729. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36730. /** @hidden */
  36731. _getViewMatrix(): Matrix;
  36732. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36733. /**
  36734. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36735. * @param meshes Defines the mesh to zoom on
  36736. * @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)
  36737. */
  36738. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36739. /**
  36740. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36741. * The target will be changed but the radius
  36742. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36743. * @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)
  36744. */
  36745. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36746. min: Vector3;
  36747. max: Vector3;
  36748. distance: number;
  36749. }, doNotUpdateMaxZ?: boolean): void;
  36750. /**
  36751. * @override
  36752. * Override Camera.createRigCamera
  36753. */
  36754. createRigCamera(name: string, cameraIndex: number): Camera;
  36755. /**
  36756. * @hidden
  36757. * @override
  36758. * Override Camera._updateRigCameras
  36759. */
  36760. _updateRigCameras(): void;
  36761. /**
  36762. * Destroy the camera and release the current resources hold by it.
  36763. */
  36764. dispose(): void;
  36765. /**
  36766. * Gets the current object class name.
  36767. * @return the class name
  36768. */
  36769. getClassName(): string;
  36770. }
  36771. }
  36772. declare module BABYLON {
  36773. /**
  36774. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36776. */
  36777. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36778. /**
  36779. * Gets the name of the behavior.
  36780. */
  36781. readonly name: string;
  36782. private _zoomStopsAnimation;
  36783. private _idleRotationSpeed;
  36784. private _idleRotationWaitTime;
  36785. private _idleRotationSpinupTime;
  36786. /**
  36787. * Sets the flag that indicates if user zooming should stop animation.
  36788. */
  36789. /**
  36790. * Gets the flag that indicates if user zooming should stop animation.
  36791. */
  36792. zoomStopsAnimation: boolean;
  36793. /**
  36794. * Sets the default speed at which the camera rotates around the model.
  36795. */
  36796. /**
  36797. * Gets the default speed at which the camera rotates around the model.
  36798. */
  36799. idleRotationSpeed: number;
  36800. /**
  36801. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36802. */
  36803. /**
  36804. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36805. */
  36806. idleRotationWaitTime: number;
  36807. /**
  36808. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36809. */
  36810. /**
  36811. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36812. */
  36813. idleRotationSpinupTime: number;
  36814. /**
  36815. * Gets a value indicating if the camera is currently rotating because of this behavior
  36816. */
  36817. readonly rotationInProgress: boolean;
  36818. private _onPrePointerObservableObserver;
  36819. private _onAfterCheckInputsObserver;
  36820. private _attachedCamera;
  36821. private _isPointerDown;
  36822. private _lastFrameTime;
  36823. private _lastInteractionTime;
  36824. private _cameraRotationSpeed;
  36825. /**
  36826. * Initializes the behavior.
  36827. */
  36828. init(): void;
  36829. /**
  36830. * Attaches the behavior to its arc rotate camera.
  36831. * @param camera Defines the camera to attach the behavior to
  36832. */
  36833. attach(camera: ArcRotateCamera): void;
  36834. /**
  36835. * Detaches the behavior from its current arc rotate camera.
  36836. */
  36837. detach(): void;
  36838. /**
  36839. * Returns true if user is scrolling.
  36840. * @return true if user is scrolling.
  36841. */
  36842. private _userIsZooming;
  36843. private _lastFrameRadius;
  36844. private _shouldAnimationStopForInteraction;
  36845. /**
  36846. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36847. */
  36848. private _applyUserInteraction;
  36849. private _userIsMoving;
  36850. }
  36851. }
  36852. declare module BABYLON {
  36853. /**
  36854. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36855. */
  36856. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36857. private ui;
  36858. /**
  36859. * The name of the behavior
  36860. */
  36861. name: string;
  36862. /**
  36863. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36864. */
  36865. distanceAwayFromFace: number;
  36866. /**
  36867. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36868. */
  36869. distanceAwayFromBottomOfFace: number;
  36870. private _faceVectors;
  36871. private _target;
  36872. private _scene;
  36873. private _onRenderObserver;
  36874. private _tmpMatrix;
  36875. private _tmpVector;
  36876. /**
  36877. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36878. * @param ui The transform node that should be attched to the mesh
  36879. */
  36880. constructor(ui: TransformNode);
  36881. /**
  36882. * Initializes the behavior
  36883. */
  36884. init(): void;
  36885. private _closestFace;
  36886. private _zeroVector;
  36887. private _lookAtTmpMatrix;
  36888. private _lookAtToRef;
  36889. /**
  36890. * Attaches the AttachToBoxBehavior to the passed in mesh
  36891. * @param target The mesh that the specified node will be attached to
  36892. */
  36893. attach(target: Mesh): void;
  36894. /**
  36895. * Detaches the behavior from the mesh
  36896. */
  36897. detach(): void;
  36898. }
  36899. }
  36900. declare module BABYLON {
  36901. /**
  36902. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36903. */
  36904. export class FadeInOutBehavior implements Behavior<Mesh> {
  36905. /**
  36906. * Time in milliseconds to delay before fading in (Default: 0)
  36907. */
  36908. delay: number;
  36909. /**
  36910. * Time in milliseconds for the mesh to fade in (Default: 300)
  36911. */
  36912. fadeInTime: number;
  36913. private _millisecondsPerFrame;
  36914. private _hovered;
  36915. private _hoverValue;
  36916. private _ownerNode;
  36917. /**
  36918. * Instatiates the FadeInOutBehavior
  36919. */
  36920. constructor();
  36921. /**
  36922. * The name of the behavior
  36923. */
  36924. readonly name: string;
  36925. /**
  36926. * Initializes the behavior
  36927. */
  36928. init(): void;
  36929. /**
  36930. * Attaches the fade behavior on the passed in mesh
  36931. * @param ownerNode The mesh that will be faded in/out once attached
  36932. */
  36933. attach(ownerNode: Mesh): void;
  36934. /**
  36935. * Detaches the behavior from the mesh
  36936. */
  36937. detach(): void;
  36938. /**
  36939. * Triggers the mesh to begin fading in or out
  36940. * @param value if the object should fade in or out (true to fade in)
  36941. */
  36942. fadeIn(value: boolean): void;
  36943. private _update;
  36944. private _setAllVisibility;
  36945. }
  36946. }
  36947. declare module BABYLON {
  36948. /**
  36949. * Class containing a set of static utilities functions for managing Pivots
  36950. * @hidden
  36951. */
  36952. export class PivotTools {
  36953. private static _PivotCached;
  36954. private static _OldPivotPoint;
  36955. private static _PivotTranslation;
  36956. private static _PivotTmpVector;
  36957. /** @hidden */
  36958. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36959. /** @hidden */
  36960. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36961. }
  36962. }
  36963. declare module BABYLON {
  36964. /**
  36965. * Class containing static functions to help procedurally build meshes
  36966. */
  36967. export class PlaneBuilder {
  36968. /**
  36969. * Creates a plane mesh
  36970. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36971. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36972. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36974. * * 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
  36975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36976. * @param name defines the name of the mesh
  36977. * @param options defines the options used to create the mesh
  36978. * @param scene defines the hosting scene
  36979. * @returns the plane mesh
  36980. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36981. */
  36982. static CreatePlane(name: string, options: {
  36983. size?: number;
  36984. width?: number;
  36985. height?: number;
  36986. sideOrientation?: number;
  36987. frontUVs?: Vector4;
  36988. backUVs?: Vector4;
  36989. updatable?: boolean;
  36990. sourcePlane?: Plane;
  36991. }, scene?: Nullable<Scene>): Mesh;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36997. */
  36998. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36999. private static _AnyMouseID;
  37000. /**
  37001. * Abstract mesh the behavior is set on
  37002. */
  37003. attachedNode: AbstractMesh;
  37004. private _dragPlane;
  37005. private _scene;
  37006. private _pointerObserver;
  37007. private _beforeRenderObserver;
  37008. private static _planeScene;
  37009. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37010. /**
  37011. * 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)
  37012. */
  37013. maxDragAngle: number;
  37014. /**
  37015. * @hidden
  37016. */
  37017. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37018. /**
  37019. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37020. */
  37021. currentDraggingPointerID: number;
  37022. /**
  37023. * The last position where the pointer hit the drag plane in world space
  37024. */
  37025. lastDragPosition: Vector3;
  37026. /**
  37027. * If the behavior is currently in a dragging state
  37028. */
  37029. dragging: boolean;
  37030. /**
  37031. * 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)
  37032. */
  37033. dragDeltaRatio: number;
  37034. /**
  37035. * If the drag plane orientation should be updated during the dragging (Default: true)
  37036. */
  37037. updateDragPlane: boolean;
  37038. private _debugMode;
  37039. private _moving;
  37040. /**
  37041. * Fires each time the attached mesh is dragged with the pointer
  37042. * * delta between last drag position and current drag position in world space
  37043. * * dragDistance along the drag axis
  37044. * * dragPlaneNormal normal of the current drag plane used during the drag
  37045. * * dragPlanePoint in world space where the drag intersects the drag plane
  37046. */
  37047. onDragObservable: Observable<{
  37048. delta: Vector3;
  37049. dragPlanePoint: Vector3;
  37050. dragPlaneNormal: Vector3;
  37051. dragDistance: number;
  37052. pointerId: number;
  37053. }>;
  37054. /**
  37055. * Fires each time a drag begins (eg. mouse down on mesh)
  37056. */
  37057. onDragStartObservable: Observable<{
  37058. dragPlanePoint: Vector3;
  37059. pointerId: number;
  37060. }>;
  37061. /**
  37062. * Fires each time a drag ends (eg. mouse release after drag)
  37063. */
  37064. onDragEndObservable: Observable<{
  37065. dragPlanePoint: Vector3;
  37066. pointerId: number;
  37067. }>;
  37068. /**
  37069. * If the attached mesh should be moved when dragged
  37070. */
  37071. moveAttached: boolean;
  37072. /**
  37073. * If the drag behavior will react to drag events (Default: true)
  37074. */
  37075. enabled: boolean;
  37076. /**
  37077. * If pointer events should start and release the drag (Default: true)
  37078. */
  37079. startAndReleaseDragOnPointerEvents: boolean;
  37080. /**
  37081. * If camera controls should be detached during the drag
  37082. */
  37083. detachCameraControls: boolean;
  37084. /**
  37085. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37086. */
  37087. useObjectOrienationForDragging: boolean;
  37088. private _options;
  37089. /**
  37090. * Creates a pointer drag behavior that can be attached to a mesh
  37091. * @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)
  37092. */
  37093. constructor(options?: {
  37094. dragAxis?: Vector3;
  37095. dragPlaneNormal?: Vector3;
  37096. });
  37097. /**
  37098. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37099. */
  37100. validateDrag: (targetPosition: Vector3) => boolean;
  37101. /**
  37102. * The name of the behavior
  37103. */
  37104. readonly name: string;
  37105. /**
  37106. * Initializes the behavior
  37107. */
  37108. init(): void;
  37109. private _tmpVector;
  37110. private _alternatePickedPoint;
  37111. private _worldDragAxis;
  37112. private _targetPosition;
  37113. private _attachedElement;
  37114. /**
  37115. * Attaches the drag behavior the passed in mesh
  37116. * @param ownerNode The mesh that will be dragged around once attached
  37117. * @param predicate Predicate to use for pick filtering
  37118. */
  37119. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37120. /**
  37121. * Force relase the drag action by code.
  37122. */
  37123. releaseDrag(): void;
  37124. private _startDragRay;
  37125. private _lastPointerRay;
  37126. /**
  37127. * Simulates the start of a pointer drag event on the behavior
  37128. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37129. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37130. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37131. */
  37132. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37133. private _startDrag;
  37134. private _dragDelta;
  37135. private _moveDrag;
  37136. private _pickWithRayOnDragPlane;
  37137. private _pointA;
  37138. private _pointB;
  37139. private _pointC;
  37140. private _lineA;
  37141. private _lineB;
  37142. private _localAxis;
  37143. private _lookAt;
  37144. private _updateDragPlanePosition;
  37145. /**
  37146. * Detaches the behavior from the mesh
  37147. */
  37148. detach(): void;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. /**
  37153. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37154. */
  37155. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37156. private _dragBehaviorA;
  37157. private _dragBehaviorB;
  37158. private _startDistance;
  37159. private _initialScale;
  37160. private _targetScale;
  37161. private _ownerNode;
  37162. private _sceneRenderObserver;
  37163. /**
  37164. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37165. */
  37166. constructor();
  37167. /**
  37168. * The name of the behavior
  37169. */
  37170. readonly name: string;
  37171. /**
  37172. * Initializes the behavior
  37173. */
  37174. init(): void;
  37175. private _getCurrentDistance;
  37176. /**
  37177. * Attaches the scale behavior the passed in mesh
  37178. * @param ownerNode The mesh that will be scaled around once attached
  37179. */
  37180. attach(ownerNode: Mesh): void;
  37181. /**
  37182. * Detaches the behavior from the mesh
  37183. */
  37184. detach(): void;
  37185. }
  37186. }
  37187. declare module BABYLON {
  37188. /**
  37189. * 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
  37190. */
  37191. export class SixDofDragBehavior implements Behavior<Mesh> {
  37192. private static _virtualScene;
  37193. private _ownerNode;
  37194. private _sceneRenderObserver;
  37195. private _scene;
  37196. private _targetPosition;
  37197. private _virtualOriginMesh;
  37198. private _virtualDragMesh;
  37199. private _pointerObserver;
  37200. private _moving;
  37201. private _startingOrientation;
  37202. /**
  37203. * 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)
  37204. */
  37205. private zDragFactor;
  37206. /**
  37207. * If the object should rotate to face the drag origin
  37208. */
  37209. rotateDraggedObject: boolean;
  37210. /**
  37211. * If the behavior is currently in a dragging state
  37212. */
  37213. dragging: boolean;
  37214. /**
  37215. * 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)
  37216. */
  37217. dragDeltaRatio: number;
  37218. /**
  37219. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37220. */
  37221. currentDraggingPointerID: number;
  37222. /**
  37223. * If camera controls should be detached during the drag
  37224. */
  37225. detachCameraControls: boolean;
  37226. /**
  37227. * Fires each time a drag starts
  37228. */
  37229. onDragStartObservable: Observable<{}>;
  37230. /**
  37231. * Fires each time a drag ends (eg. mouse release after drag)
  37232. */
  37233. onDragEndObservable: Observable<{}>;
  37234. /**
  37235. * 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
  37236. */
  37237. constructor();
  37238. /**
  37239. * The name of the behavior
  37240. */
  37241. readonly name: string;
  37242. /**
  37243. * Initializes the behavior
  37244. */
  37245. init(): void;
  37246. /**
  37247. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37248. */
  37249. private readonly _pointerCamera;
  37250. /**
  37251. * Attaches the scale behavior the passed in mesh
  37252. * @param ownerNode The mesh that will be scaled around once attached
  37253. */
  37254. attach(ownerNode: Mesh): void;
  37255. /**
  37256. * Detaches the behavior from the mesh
  37257. */
  37258. detach(): void;
  37259. }
  37260. }
  37261. declare module BABYLON {
  37262. /**
  37263. * Class used to apply inverse kinematics to bones
  37264. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37265. */
  37266. export class BoneIKController {
  37267. private static _tmpVecs;
  37268. private static _tmpQuat;
  37269. private static _tmpMats;
  37270. /**
  37271. * Gets or sets the target mesh
  37272. */
  37273. targetMesh: AbstractMesh;
  37274. /** Gets or sets the mesh used as pole */
  37275. poleTargetMesh: AbstractMesh;
  37276. /**
  37277. * Gets or sets the bone used as pole
  37278. */
  37279. poleTargetBone: Nullable<Bone>;
  37280. /**
  37281. * Gets or sets the target position
  37282. */
  37283. targetPosition: Vector3;
  37284. /**
  37285. * Gets or sets the pole target position
  37286. */
  37287. poleTargetPosition: Vector3;
  37288. /**
  37289. * Gets or sets the pole target local offset
  37290. */
  37291. poleTargetLocalOffset: Vector3;
  37292. /**
  37293. * Gets or sets the pole angle
  37294. */
  37295. poleAngle: number;
  37296. /**
  37297. * Gets or sets the mesh associated with the controller
  37298. */
  37299. mesh: AbstractMesh;
  37300. /**
  37301. * 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)
  37302. */
  37303. slerpAmount: number;
  37304. private _bone1Quat;
  37305. private _bone1Mat;
  37306. private _bone2Ang;
  37307. private _bone1;
  37308. private _bone2;
  37309. private _bone1Length;
  37310. private _bone2Length;
  37311. private _maxAngle;
  37312. private _maxReach;
  37313. private _rightHandedSystem;
  37314. private _bendAxis;
  37315. private _slerping;
  37316. private _adjustRoll;
  37317. /**
  37318. * Gets or sets maximum allowed angle
  37319. */
  37320. maxAngle: number;
  37321. /**
  37322. * Creates a new BoneIKController
  37323. * @param mesh defines the mesh to control
  37324. * @param bone defines the bone to control
  37325. * @param options defines options to set up the controller
  37326. */
  37327. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37328. targetMesh?: AbstractMesh;
  37329. poleTargetMesh?: AbstractMesh;
  37330. poleTargetBone?: Bone;
  37331. poleTargetLocalOffset?: Vector3;
  37332. poleAngle?: number;
  37333. bendAxis?: Vector3;
  37334. maxAngle?: number;
  37335. slerpAmount?: number;
  37336. });
  37337. private _setMaxAngle;
  37338. /**
  37339. * Force the controller to update the bones
  37340. */
  37341. update(): void;
  37342. }
  37343. }
  37344. declare module BABYLON {
  37345. /**
  37346. * Class used to make a bone look toward a point in space
  37347. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37348. */
  37349. export class BoneLookController {
  37350. private static _tmpVecs;
  37351. private static _tmpQuat;
  37352. private static _tmpMats;
  37353. /**
  37354. * The target Vector3 that the bone will look at
  37355. */
  37356. target: Vector3;
  37357. /**
  37358. * The mesh that the bone is attached to
  37359. */
  37360. mesh: AbstractMesh;
  37361. /**
  37362. * The bone that will be looking to the target
  37363. */
  37364. bone: Bone;
  37365. /**
  37366. * The up axis of the coordinate system that is used when the bone is rotated
  37367. */
  37368. upAxis: Vector3;
  37369. /**
  37370. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37371. */
  37372. upAxisSpace: Space;
  37373. /**
  37374. * Used to make an adjustment to the yaw of the bone
  37375. */
  37376. adjustYaw: number;
  37377. /**
  37378. * Used to make an adjustment to the pitch of the bone
  37379. */
  37380. adjustPitch: number;
  37381. /**
  37382. * Used to make an adjustment to the roll of the bone
  37383. */
  37384. adjustRoll: number;
  37385. /**
  37386. * 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)
  37387. */
  37388. slerpAmount: number;
  37389. private _minYaw;
  37390. private _maxYaw;
  37391. private _minPitch;
  37392. private _maxPitch;
  37393. private _minYawSin;
  37394. private _minYawCos;
  37395. private _maxYawSin;
  37396. private _maxYawCos;
  37397. private _midYawConstraint;
  37398. private _minPitchTan;
  37399. private _maxPitchTan;
  37400. private _boneQuat;
  37401. private _slerping;
  37402. private _transformYawPitch;
  37403. private _transformYawPitchInv;
  37404. private _firstFrameSkipped;
  37405. private _yawRange;
  37406. private _fowardAxis;
  37407. /**
  37408. * Gets or sets the minimum yaw angle that the bone can look to
  37409. */
  37410. minYaw: number;
  37411. /**
  37412. * Gets or sets the maximum yaw angle that the bone can look to
  37413. */
  37414. maxYaw: number;
  37415. /**
  37416. * Gets or sets the minimum pitch angle that the bone can look to
  37417. */
  37418. minPitch: number;
  37419. /**
  37420. * Gets or sets the maximum pitch angle that the bone can look to
  37421. */
  37422. maxPitch: number;
  37423. /**
  37424. * Create a BoneLookController
  37425. * @param mesh the mesh that the bone belongs to
  37426. * @param bone the bone that will be looking to the target
  37427. * @param target the target Vector3 to look at
  37428. * @param options optional settings:
  37429. * * maxYaw: the maximum angle the bone will yaw to
  37430. * * minYaw: the minimum angle the bone will yaw to
  37431. * * maxPitch: the maximum angle the bone will pitch to
  37432. * * minPitch: the minimum angle the bone will yaw to
  37433. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37434. * * upAxis: the up axis of the coordinate system
  37435. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37436. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37437. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37438. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37439. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37440. * * adjustRoll: used to make an adjustment to the roll of the bone
  37441. **/
  37442. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37443. maxYaw?: number;
  37444. minYaw?: number;
  37445. maxPitch?: number;
  37446. minPitch?: number;
  37447. slerpAmount?: number;
  37448. upAxis?: Vector3;
  37449. upAxisSpace?: Space;
  37450. yawAxis?: Vector3;
  37451. pitchAxis?: Vector3;
  37452. adjustYaw?: number;
  37453. adjustPitch?: number;
  37454. adjustRoll?: number;
  37455. });
  37456. /**
  37457. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37458. */
  37459. update(): void;
  37460. private _getAngleDiff;
  37461. private _getAngleBetween;
  37462. private _isAngleBetween;
  37463. }
  37464. }
  37465. declare module BABYLON {
  37466. /**
  37467. * Manage the gamepad inputs to control an arc rotate camera.
  37468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37469. */
  37470. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37471. /**
  37472. * Defines the camera the input is attached to.
  37473. */
  37474. camera: ArcRotateCamera;
  37475. /**
  37476. * Defines the gamepad the input is gathering event from.
  37477. */
  37478. gamepad: Nullable<Gamepad>;
  37479. /**
  37480. * Defines the gamepad rotation sensiblity.
  37481. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37482. */
  37483. gamepadRotationSensibility: number;
  37484. /**
  37485. * Defines the gamepad move sensiblity.
  37486. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37487. */
  37488. gamepadMoveSensibility: number;
  37489. private _yAxisScale;
  37490. /**
  37491. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37492. */
  37493. invertYAxis: boolean;
  37494. private _onGamepadConnectedObserver;
  37495. private _onGamepadDisconnectedObserver;
  37496. /**
  37497. * Attach the input controls to a specific dom element to get the input from.
  37498. * @param element Defines the element the controls should be listened from
  37499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37500. */
  37501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37502. /**
  37503. * Detach the current controls from the specified dom element.
  37504. * @param element Defines the element to stop listening the inputs from
  37505. */
  37506. detachControl(element: Nullable<HTMLElement>): void;
  37507. /**
  37508. * Update the current camera state depending on the inputs that have been used this frame.
  37509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37510. */
  37511. checkInputs(): void;
  37512. /**
  37513. * Gets the class name of the current intput.
  37514. * @returns the class name
  37515. */
  37516. getClassName(): string;
  37517. /**
  37518. * Get the friendly name associated with the input class.
  37519. * @returns the input friendly name
  37520. */
  37521. getSimpleName(): string;
  37522. }
  37523. }
  37524. declare module BABYLON {
  37525. interface ArcRotateCameraInputsManager {
  37526. /**
  37527. * Add orientation input support to the input manager.
  37528. * @returns the current input manager
  37529. */
  37530. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37531. }
  37532. /**
  37533. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37535. */
  37536. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37537. /**
  37538. * Defines the camera the input is attached to.
  37539. */
  37540. camera: ArcRotateCamera;
  37541. /**
  37542. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37543. */
  37544. alphaCorrection: number;
  37545. /**
  37546. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37547. */
  37548. gammaCorrection: number;
  37549. private _alpha;
  37550. private _gamma;
  37551. private _dirty;
  37552. private _deviceOrientationHandler;
  37553. /**
  37554. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37555. */
  37556. constructor();
  37557. /**
  37558. * Attach the input controls to a specific dom element to get the input from.
  37559. * @param element Defines the element the controls should be listened from
  37560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37561. */
  37562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37563. /** @hidden */
  37564. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37565. /**
  37566. * Update the current camera state depending on the inputs that have been used this frame.
  37567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37568. */
  37569. checkInputs(): void;
  37570. /**
  37571. * Detach the current controls from the specified dom element.
  37572. * @param element Defines the element to stop listening the inputs from
  37573. */
  37574. detachControl(element: Nullable<HTMLElement>): void;
  37575. /**
  37576. * Gets the class name of the current intput.
  37577. * @returns the class name
  37578. */
  37579. getClassName(): string;
  37580. /**
  37581. * Get the friendly name associated with the input class.
  37582. * @returns the input friendly name
  37583. */
  37584. getSimpleName(): string;
  37585. }
  37586. }
  37587. declare module BABYLON {
  37588. /**
  37589. * Listen to mouse events to control the camera.
  37590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37591. */
  37592. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37593. /**
  37594. * Defines the camera the input is attached to.
  37595. */
  37596. camera: FlyCamera;
  37597. /**
  37598. * Defines if touch is enabled. (Default is true.)
  37599. */
  37600. touchEnabled: boolean;
  37601. /**
  37602. * Defines the buttons associated with the input to handle camera rotation.
  37603. */
  37604. buttons: number[];
  37605. /**
  37606. * Assign buttons for Yaw control.
  37607. */
  37608. buttonsYaw: number[];
  37609. /**
  37610. * Assign buttons for Pitch control.
  37611. */
  37612. buttonsPitch: number[];
  37613. /**
  37614. * Assign buttons for Roll control.
  37615. */
  37616. buttonsRoll: number[];
  37617. /**
  37618. * Detect if any button is being pressed while mouse is moved.
  37619. * -1 = Mouse locked.
  37620. * 0 = Left button.
  37621. * 1 = Middle Button.
  37622. * 2 = Right Button.
  37623. */
  37624. activeButton: number;
  37625. /**
  37626. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37627. * Higher values reduce its sensitivity.
  37628. */
  37629. angularSensibility: number;
  37630. private _mousemoveCallback;
  37631. private _observer;
  37632. private _rollObserver;
  37633. private previousPosition;
  37634. private noPreventDefault;
  37635. private element;
  37636. /**
  37637. * Listen to mouse events to control the camera.
  37638. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37640. */
  37641. constructor(touchEnabled?: boolean);
  37642. /**
  37643. * Attach the mouse control to the HTML DOM element.
  37644. * @param element Defines the element that listens to the input events.
  37645. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37646. */
  37647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37648. /**
  37649. * Detach the current controls from the specified dom element.
  37650. * @param element Defines the element to stop listening the inputs from
  37651. */
  37652. detachControl(element: Nullable<HTMLElement>): void;
  37653. /**
  37654. * Gets the class name of the current input.
  37655. * @returns the class name.
  37656. */
  37657. getClassName(): string;
  37658. /**
  37659. * Get the friendly name associated with the input class.
  37660. * @returns the input's friendly name.
  37661. */
  37662. getSimpleName(): string;
  37663. private _pointerInput;
  37664. private _onMouseMove;
  37665. /**
  37666. * Rotate camera by mouse offset.
  37667. */
  37668. private rotateCamera;
  37669. }
  37670. }
  37671. declare module BABYLON {
  37672. /**
  37673. * Default Inputs manager for the FlyCamera.
  37674. * It groups all the default supported inputs for ease of use.
  37675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37676. */
  37677. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37678. /**
  37679. * Instantiates a new FlyCameraInputsManager.
  37680. * @param camera Defines the camera the inputs belong to.
  37681. */
  37682. constructor(camera: FlyCamera);
  37683. /**
  37684. * Add keyboard input support to the input manager.
  37685. * @returns the new FlyCameraKeyboardMoveInput().
  37686. */
  37687. addKeyboard(): FlyCameraInputsManager;
  37688. /**
  37689. * Add mouse input support to the input manager.
  37690. * @param touchEnabled Enable touch screen support.
  37691. * @returns the new FlyCameraMouseInput().
  37692. */
  37693. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37694. }
  37695. }
  37696. declare module BABYLON {
  37697. /**
  37698. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37699. * such as in a 3D Space Shooter or a Flight Simulator.
  37700. */
  37701. export class FlyCamera extends TargetCamera {
  37702. /**
  37703. * Define the collision ellipsoid of the camera.
  37704. * This is helpful for simulating a camera body, like a player's body.
  37705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37706. */
  37707. ellipsoid: Vector3;
  37708. /**
  37709. * Define an offset for the position of the ellipsoid around the camera.
  37710. * This can be helpful if the camera is attached away from the player's body center,
  37711. * such as at its head.
  37712. */
  37713. ellipsoidOffset: Vector3;
  37714. /**
  37715. * Enable or disable collisions of the camera with the rest of the scene objects.
  37716. */
  37717. checkCollisions: boolean;
  37718. /**
  37719. * Enable or disable gravity on the camera.
  37720. */
  37721. applyGravity: boolean;
  37722. /**
  37723. * Define the current direction the camera is moving to.
  37724. */
  37725. cameraDirection: Vector3;
  37726. /**
  37727. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37728. * This overrides and empties cameraRotation.
  37729. */
  37730. rotationQuaternion: Quaternion;
  37731. /**
  37732. * Track Roll to maintain the wanted Rolling when looking around.
  37733. */
  37734. _trackRoll: number;
  37735. /**
  37736. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37737. */
  37738. rollCorrect: number;
  37739. /**
  37740. * Mimic a banked turn, Rolling the camera when Yawing.
  37741. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37742. */
  37743. bankedTurn: boolean;
  37744. /**
  37745. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37746. */
  37747. bankedTurnLimit: number;
  37748. /**
  37749. * Value of 0 disables the banked Roll.
  37750. * Value of 1 is equal to the Yaw angle in radians.
  37751. */
  37752. bankedTurnMultiplier: number;
  37753. /**
  37754. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37755. */
  37756. inputs: FlyCameraInputsManager;
  37757. /**
  37758. * Gets the input sensibility for mouse input.
  37759. * Higher values reduce sensitivity.
  37760. */
  37761. /**
  37762. * Sets the input sensibility for a mouse input.
  37763. * Higher values reduce sensitivity.
  37764. */
  37765. angularSensibility: number;
  37766. /**
  37767. * Get the keys for camera movement forward.
  37768. */
  37769. /**
  37770. * Set the keys for camera movement forward.
  37771. */
  37772. keysForward: number[];
  37773. /**
  37774. * Get the keys for camera movement backward.
  37775. */
  37776. keysBackward: number[];
  37777. /**
  37778. * Get the keys for camera movement up.
  37779. */
  37780. /**
  37781. * Set the keys for camera movement up.
  37782. */
  37783. keysUp: number[];
  37784. /**
  37785. * Get the keys for camera movement down.
  37786. */
  37787. /**
  37788. * Set the keys for camera movement down.
  37789. */
  37790. keysDown: number[];
  37791. /**
  37792. * Get the keys for camera movement left.
  37793. */
  37794. /**
  37795. * Set the keys for camera movement left.
  37796. */
  37797. keysLeft: number[];
  37798. /**
  37799. * Set the keys for camera movement right.
  37800. */
  37801. /**
  37802. * Set the keys for camera movement right.
  37803. */
  37804. keysRight: number[];
  37805. /**
  37806. * Event raised when the camera collides with a mesh in the scene.
  37807. */
  37808. onCollide: (collidedMesh: AbstractMesh) => void;
  37809. private _collider;
  37810. private _needMoveForGravity;
  37811. private _oldPosition;
  37812. private _diffPosition;
  37813. private _newPosition;
  37814. /** @hidden */
  37815. _localDirection: Vector3;
  37816. /** @hidden */
  37817. _transformedDirection: Vector3;
  37818. /**
  37819. * Instantiates a FlyCamera.
  37820. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37821. * such as in a 3D Space Shooter or a Flight Simulator.
  37822. * @param name Define the name of the camera in the scene.
  37823. * @param position Define the starting position of the camera in the scene.
  37824. * @param scene Define the scene the camera belongs to.
  37825. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37826. */
  37827. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37828. /**
  37829. * Attach a control to the HTML DOM element.
  37830. * @param element Defines the element that listens to the input events.
  37831. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37832. */
  37833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37834. /**
  37835. * Detach a control from the HTML DOM element.
  37836. * The camera will stop reacting to that input.
  37837. * @param element Defines the element that listens to the input events.
  37838. */
  37839. detachControl(element: HTMLElement): void;
  37840. private _collisionMask;
  37841. /**
  37842. * Get the mask that the camera ignores in collision events.
  37843. */
  37844. /**
  37845. * Set the mask that the camera ignores in collision events.
  37846. */
  37847. collisionMask: number;
  37848. /** @hidden */
  37849. _collideWithWorld(displacement: Vector3): void;
  37850. /** @hidden */
  37851. private _onCollisionPositionChange;
  37852. /** @hidden */
  37853. _checkInputs(): void;
  37854. /** @hidden */
  37855. _decideIfNeedsToMove(): boolean;
  37856. /** @hidden */
  37857. _updatePosition(): void;
  37858. /**
  37859. * Restore the Roll to its target value at the rate specified.
  37860. * @param rate - Higher means slower restoring.
  37861. * @hidden
  37862. */
  37863. restoreRoll(rate: number): void;
  37864. /**
  37865. * Destroy the camera and release the current resources held by it.
  37866. */
  37867. dispose(): void;
  37868. /**
  37869. * Get the current object class name.
  37870. * @returns the class name.
  37871. */
  37872. getClassName(): string;
  37873. }
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * Listen to keyboard events to control the camera.
  37878. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37879. */
  37880. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37881. /**
  37882. * Defines the camera the input is attached to.
  37883. */
  37884. camera: FlyCamera;
  37885. /**
  37886. * The list of keyboard keys used to control the forward move of the camera.
  37887. */
  37888. keysForward: number[];
  37889. /**
  37890. * The list of keyboard keys used to control the backward move of the camera.
  37891. */
  37892. keysBackward: number[];
  37893. /**
  37894. * The list of keyboard keys used to control the forward move of the camera.
  37895. */
  37896. keysUp: number[];
  37897. /**
  37898. * The list of keyboard keys used to control the backward move of the camera.
  37899. */
  37900. keysDown: number[];
  37901. /**
  37902. * The list of keyboard keys used to control the right strafe move of the camera.
  37903. */
  37904. keysRight: number[];
  37905. /**
  37906. * The list of keyboard keys used to control the left strafe move of the camera.
  37907. */
  37908. keysLeft: number[];
  37909. private _keys;
  37910. private _onCanvasBlurObserver;
  37911. private _onKeyboardObserver;
  37912. private _engine;
  37913. private _scene;
  37914. /**
  37915. * Attach the input controls to a specific dom element to get the input from.
  37916. * @param element Defines the element the controls should be listened from
  37917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37918. */
  37919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37920. /**
  37921. * Detach the current controls from the specified dom element.
  37922. * @param element Defines the element to stop listening the inputs from
  37923. */
  37924. detachControl(element: Nullable<HTMLElement>): void;
  37925. /**
  37926. * Gets the class name of the current intput.
  37927. * @returns the class name
  37928. */
  37929. getClassName(): string;
  37930. /** @hidden */
  37931. _onLostFocus(e: FocusEvent): void;
  37932. /**
  37933. * Get the friendly name associated with the input class.
  37934. * @returns the input friendly name
  37935. */
  37936. getSimpleName(): string;
  37937. /**
  37938. * Update the current camera state depending on the inputs that have been used this frame.
  37939. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37940. */
  37941. checkInputs(): void;
  37942. }
  37943. }
  37944. declare module BABYLON {
  37945. /**
  37946. * Manage the mouse wheel inputs to control a follow camera.
  37947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37948. */
  37949. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37950. /**
  37951. * Defines the camera the input is attached to.
  37952. */
  37953. camera: FollowCamera;
  37954. /**
  37955. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37956. */
  37957. axisControlRadius: boolean;
  37958. /**
  37959. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37960. */
  37961. axisControlHeight: boolean;
  37962. /**
  37963. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37964. */
  37965. axisControlRotation: boolean;
  37966. /**
  37967. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37968. * relation to mouseWheel events.
  37969. */
  37970. wheelPrecision: number;
  37971. /**
  37972. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37973. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37974. */
  37975. wheelDeltaPercentage: number;
  37976. private _wheel;
  37977. private _observer;
  37978. /**
  37979. * Attach the input controls to a specific dom element to get the input from.
  37980. * @param element Defines the element the controls should be listened from
  37981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37982. */
  37983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37984. /**
  37985. * Detach the current controls from the specified dom element.
  37986. * @param element Defines the element to stop listening the inputs from
  37987. */
  37988. detachControl(element: Nullable<HTMLElement>): void;
  37989. /**
  37990. * Gets the class name of the current intput.
  37991. * @returns the class name
  37992. */
  37993. getClassName(): string;
  37994. /**
  37995. * Get the friendly name associated with the input class.
  37996. * @returns the input friendly name
  37997. */
  37998. getSimpleName(): string;
  37999. }
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * Manage the pointers inputs to control an follow camera.
  38004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38005. */
  38006. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38007. /**
  38008. * Defines the camera the input is attached to.
  38009. */
  38010. camera: FollowCamera;
  38011. /**
  38012. * Gets the class name of the current input.
  38013. * @returns the class name
  38014. */
  38015. getClassName(): string;
  38016. /**
  38017. * Defines the pointer angular sensibility along the X axis or how fast is
  38018. * the camera rotating.
  38019. * A negative number will reverse the axis direction.
  38020. */
  38021. angularSensibilityX: number;
  38022. /**
  38023. * Defines the pointer angular sensibility along the Y axis or how fast is
  38024. * the camera rotating.
  38025. * A negative number will reverse the axis direction.
  38026. */
  38027. angularSensibilityY: number;
  38028. /**
  38029. * Defines the pointer pinch precision or how fast is the camera zooming.
  38030. * A negative number will reverse the axis direction.
  38031. */
  38032. pinchPrecision: number;
  38033. /**
  38034. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38035. * from 0.
  38036. * It defines the percentage of current camera.radius to use as delta when
  38037. * pinch zoom is used.
  38038. */
  38039. pinchDeltaPercentage: number;
  38040. /**
  38041. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38042. */
  38043. axisXControlRadius: boolean;
  38044. /**
  38045. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38046. */
  38047. axisXControlHeight: boolean;
  38048. /**
  38049. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38050. */
  38051. axisXControlRotation: boolean;
  38052. /**
  38053. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38054. */
  38055. axisYControlRadius: boolean;
  38056. /**
  38057. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38058. */
  38059. axisYControlHeight: boolean;
  38060. /**
  38061. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38062. */
  38063. axisYControlRotation: boolean;
  38064. /**
  38065. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38066. */
  38067. axisPinchControlRadius: boolean;
  38068. /**
  38069. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38070. */
  38071. axisPinchControlHeight: boolean;
  38072. /**
  38073. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38074. */
  38075. axisPinchControlRotation: boolean;
  38076. /**
  38077. * Log error messages if basic misconfiguration has occurred.
  38078. */
  38079. warningEnable: boolean;
  38080. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38081. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38082. private _warningCounter;
  38083. private _warning;
  38084. }
  38085. }
  38086. declare module BABYLON {
  38087. /**
  38088. * Default Inputs manager for the FollowCamera.
  38089. * It groups all the default supported inputs for ease of use.
  38090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38091. */
  38092. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38093. /**
  38094. * Instantiates a new FollowCameraInputsManager.
  38095. * @param camera Defines the camera the inputs belong to
  38096. */
  38097. constructor(camera: FollowCamera);
  38098. /**
  38099. * Add keyboard input support to the input manager.
  38100. * @returns the current input manager
  38101. */
  38102. addKeyboard(): FollowCameraInputsManager;
  38103. /**
  38104. * Add mouse wheel input support to the input manager.
  38105. * @returns the current input manager
  38106. */
  38107. addMouseWheel(): FollowCameraInputsManager;
  38108. /**
  38109. * Add pointers input support to the input manager.
  38110. * @returns the current input manager
  38111. */
  38112. addPointers(): FollowCameraInputsManager;
  38113. /**
  38114. * Add orientation input support to the input manager.
  38115. * @returns the current input manager
  38116. */
  38117. addVRDeviceOrientation(): FollowCameraInputsManager;
  38118. }
  38119. }
  38120. declare module BABYLON {
  38121. /**
  38122. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38123. * an arc rotate version arcFollowCamera are available.
  38124. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38125. */
  38126. export class FollowCamera extends TargetCamera {
  38127. /**
  38128. * Distance the follow camera should follow an object at
  38129. */
  38130. radius: number;
  38131. /**
  38132. * Minimum allowed distance of the camera to the axis of rotation
  38133. * (The camera can not get closer).
  38134. * This can help limiting how the Camera is able to move in the scene.
  38135. */
  38136. lowerRadiusLimit: Nullable<number>;
  38137. /**
  38138. * Maximum allowed distance of the camera to the axis of rotation
  38139. * (The camera can not get further).
  38140. * This can help limiting how the Camera is able to move in the scene.
  38141. */
  38142. upperRadiusLimit: Nullable<number>;
  38143. /**
  38144. * Define a rotation offset between the camera and the object it follows
  38145. */
  38146. rotationOffset: number;
  38147. /**
  38148. * Minimum allowed angle to camera position relative to target object.
  38149. * This can help limiting how the Camera is able to move in the scene.
  38150. */
  38151. lowerRotationOffsetLimit: Nullable<number>;
  38152. /**
  38153. * Maximum allowed angle to camera position relative to target object.
  38154. * This can help limiting how the Camera is able to move in the scene.
  38155. */
  38156. upperRotationOffsetLimit: Nullable<number>;
  38157. /**
  38158. * Define a height offset between the camera and the object it follows.
  38159. * It can help following an object from the top (like a car chaing a plane)
  38160. */
  38161. heightOffset: number;
  38162. /**
  38163. * Minimum allowed height of camera position relative to target object.
  38164. * This can help limiting how the Camera is able to move in the scene.
  38165. */
  38166. lowerHeightOffsetLimit: Nullable<number>;
  38167. /**
  38168. * Maximum allowed height of camera position relative to target object.
  38169. * This can help limiting how the Camera is able to move in the scene.
  38170. */
  38171. upperHeightOffsetLimit: Nullable<number>;
  38172. /**
  38173. * Define how fast the camera can accelerate to follow it s target.
  38174. */
  38175. cameraAcceleration: number;
  38176. /**
  38177. * Define the speed limit of the camera following an object.
  38178. */
  38179. maxCameraSpeed: number;
  38180. /**
  38181. * Define the target of the camera.
  38182. */
  38183. lockedTarget: Nullable<AbstractMesh>;
  38184. /**
  38185. * Defines the input associated with the camera.
  38186. */
  38187. inputs: FollowCameraInputsManager;
  38188. /**
  38189. * Instantiates the follow camera.
  38190. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38191. * @param name Define the name of the camera in the scene
  38192. * @param position Define the position of the camera
  38193. * @param scene Define the scene the camera belong to
  38194. * @param lockedTarget Define the target of the camera
  38195. */
  38196. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38197. private _follow;
  38198. /**
  38199. * Attached controls to the current camera.
  38200. * @param element Defines the element the controls should be listened from
  38201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38202. */
  38203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38204. /**
  38205. * Detach the current controls from the camera.
  38206. * The camera will stop reacting to inputs.
  38207. * @param element Defines the element to stop listening the inputs from
  38208. */
  38209. detachControl(element: HTMLElement): void;
  38210. /** @hidden */
  38211. _checkInputs(): void;
  38212. private _checkLimits;
  38213. /**
  38214. * Gets the camera class name.
  38215. * @returns the class name
  38216. */
  38217. getClassName(): string;
  38218. }
  38219. /**
  38220. * Arc Rotate version of the follow camera.
  38221. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38222. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38223. */
  38224. export class ArcFollowCamera extends TargetCamera {
  38225. /** The longitudinal angle of the camera */
  38226. alpha: number;
  38227. /** The latitudinal angle of the camera */
  38228. beta: number;
  38229. /** The radius of the camera from its target */
  38230. radius: number;
  38231. /** Define the camera target (the messh it should follow) */
  38232. target: Nullable<AbstractMesh>;
  38233. private _cartesianCoordinates;
  38234. /**
  38235. * Instantiates a new ArcFollowCamera
  38236. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38237. * @param name Define the name of the camera
  38238. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38239. * @param beta Define the rotation angle of the camera around the elevation axis
  38240. * @param radius Define the radius of the camera from its target point
  38241. * @param target Define the target of the camera
  38242. * @param scene Define the scene the camera belongs to
  38243. */
  38244. constructor(name: string,
  38245. /** The longitudinal angle of the camera */
  38246. alpha: number,
  38247. /** The latitudinal angle of the camera */
  38248. beta: number,
  38249. /** The radius of the camera from its target */
  38250. radius: number,
  38251. /** Define the camera target (the messh it should follow) */
  38252. target: Nullable<AbstractMesh>, scene: Scene);
  38253. private _follow;
  38254. /** @hidden */
  38255. _checkInputs(): void;
  38256. /**
  38257. * Returns the class name of the object.
  38258. * It is mostly used internally for serialization purposes.
  38259. */
  38260. getClassName(): string;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. /**
  38265. * Manage the keyboard inputs to control the movement of a follow camera.
  38266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38267. */
  38268. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38269. /**
  38270. * Defines the camera the input is attached to.
  38271. */
  38272. camera: FollowCamera;
  38273. /**
  38274. * Defines the list of key codes associated with the up action (increase heightOffset)
  38275. */
  38276. keysHeightOffsetIncr: number[];
  38277. /**
  38278. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38279. */
  38280. keysHeightOffsetDecr: number[];
  38281. /**
  38282. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38283. */
  38284. keysHeightOffsetModifierAlt: boolean;
  38285. /**
  38286. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38287. */
  38288. keysHeightOffsetModifierCtrl: boolean;
  38289. /**
  38290. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38291. */
  38292. keysHeightOffsetModifierShift: boolean;
  38293. /**
  38294. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38295. */
  38296. keysRotationOffsetIncr: number[];
  38297. /**
  38298. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38299. */
  38300. keysRotationOffsetDecr: number[];
  38301. /**
  38302. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38303. */
  38304. keysRotationOffsetModifierAlt: boolean;
  38305. /**
  38306. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38307. */
  38308. keysRotationOffsetModifierCtrl: boolean;
  38309. /**
  38310. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38311. */
  38312. keysRotationOffsetModifierShift: boolean;
  38313. /**
  38314. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38315. */
  38316. keysRadiusIncr: number[];
  38317. /**
  38318. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38319. */
  38320. keysRadiusDecr: number[];
  38321. /**
  38322. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38323. */
  38324. keysRadiusModifierAlt: boolean;
  38325. /**
  38326. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38327. */
  38328. keysRadiusModifierCtrl: boolean;
  38329. /**
  38330. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38331. */
  38332. keysRadiusModifierShift: boolean;
  38333. /**
  38334. * Defines the rate of change of heightOffset.
  38335. */
  38336. heightSensibility: number;
  38337. /**
  38338. * Defines the rate of change of rotationOffset.
  38339. */
  38340. rotationSensibility: number;
  38341. /**
  38342. * Defines the rate of change of radius.
  38343. */
  38344. radiusSensibility: number;
  38345. private _keys;
  38346. private _ctrlPressed;
  38347. private _altPressed;
  38348. private _shiftPressed;
  38349. private _onCanvasBlurObserver;
  38350. private _onKeyboardObserver;
  38351. private _engine;
  38352. private _scene;
  38353. /**
  38354. * Attach the input controls to a specific dom element to get the input from.
  38355. * @param element Defines the element the controls should be listened from
  38356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38357. */
  38358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38359. /**
  38360. * Detach the current controls from the specified dom element.
  38361. * @param element Defines the element to stop listening the inputs from
  38362. */
  38363. detachControl(element: Nullable<HTMLElement>): void;
  38364. /**
  38365. * Update the current camera state depending on the inputs that have been used this frame.
  38366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38367. */
  38368. checkInputs(): void;
  38369. /**
  38370. * Gets the class name of the current input.
  38371. * @returns the class name
  38372. */
  38373. getClassName(): string;
  38374. /**
  38375. * Get the friendly name associated with the input class.
  38376. * @returns the input friendly name
  38377. */
  38378. getSimpleName(): string;
  38379. /**
  38380. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38381. * allow modification of the heightOffset value.
  38382. */
  38383. private _modifierHeightOffset;
  38384. /**
  38385. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38386. * allow modification of the rotationOffset value.
  38387. */
  38388. private _modifierRotationOffset;
  38389. /**
  38390. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38391. * allow modification of the radius value.
  38392. */
  38393. private _modifierRadius;
  38394. }
  38395. }
  38396. declare module BABYLON {
  38397. interface FreeCameraInputsManager {
  38398. /**
  38399. * @hidden
  38400. */
  38401. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38402. /**
  38403. * Add orientation input support to the input manager.
  38404. * @returns the current input manager
  38405. */
  38406. addDeviceOrientation(): FreeCameraInputsManager;
  38407. }
  38408. /**
  38409. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38410. * Screen rotation is taken into account.
  38411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38412. */
  38413. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38414. private _camera;
  38415. private _screenOrientationAngle;
  38416. private _constantTranform;
  38417. private _screenQuaternion;
  38418. private _alpha;
  38419. private _beta;
  38420. private _gamma;
  38421. /**
  38422. * Can be used to detect if a device orientation sensor is availible on a device
  38423. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38424. * @returns a promise that will resolve on orientation change
  38425. */
  38426. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38427. /**
  38428. * @hidden
  38429. */
  38430. _onDeviceOrientationChangedObservable: Observable<void>;
  38431. /**
  38432. * Instantiates a new input
  38433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38434. */
  38435. constructor();
  38436. /**
  38437. * Define the camera controlled by the input.
  38438. */
  38439. camera: FreeCamera;
  38440. /**
  38441. * Attach the input controls to a specific dom element to get the input from.
  38442. * @param element Defines the element the controls should be listened from
  38443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38444. */
  38445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38446. private _orientationChanged;
  38447. private _deviceOrientation;
  38448. /**
  38449. * Detach the current controls from the specified dom element.
  38450. * @param element Defines the element to stop listening the inputs from
  38451. */
  38452. detachControl(element: Nullable<HTMLElement>): void;
  38453. /**
  38454. * Update the current camera state depending on the inputs that have been used this frame.
  38455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38456. */
  38457. checkInputs(): void;
  38458. /**
  38459. * Gets the class name of the current intput.
  38460. * @returns the class name
  38461. */
  38462. getClassName(): string;
  38463. /**
  38464. * Get the friendly name associated with the input class.
  38465. * @returns the input friendly name
  38466. */
  38467. getSimpleName(): string;
  38468. }
  38469. }
  38470. declare module BABYLON {
  38471. /**
  38472. * Manage the gamepad inputs to control a free camera.
  38473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38474. */
  38475. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38476. /**
  38477. * Define the camera the input is attached to.
  38478. */
  38479. camera: FreeCamera;
  38480. /**
  38481. * Define the Gamepad controlling the input
  38482. */
  38483. gamepad: Nullable<Gamepad>;
  38484. /**
  38485. * Defines the gamepad rotation sensiblity.
  38486. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38487. */
  38488. gamepadAngularSensibility: number;
  38489. /**
  38490. * Defines the gamepad move sensiblity.
  38491. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38492. */
  38493. gamepadMoveSensibility: number;
  38494. private _yAxisScale;
  38495. /**
  38496. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38497. */
  38498. invertYAxis: boolean;
  38499. private _onGamepadConnectedObserver;
  38500. private _onGamepadDisconnectedObserver;
  38501. private _cameraTransform;
  38502. private _deltaTransform;
  38503. private _vector3;
  38504. private _vector2;
  38505. /**
  38506. * Attach the input controls to a specific dom element to get the input from.
  38507. * @param element Defines the element the controls should be listened from
  38508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38509. */
  38510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38511. /**
  38512. * Detach the current controls from the specified dom element.
  38513. * @param element Defines the element to stop listening the inputs from
  38514. */
  38515. detachControl(element: Nullable<HTMLElement>): void;
  38516. /**
  38517. * Update the current camera state depending on the inputs that have been used this frame.
  38518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38519. */
  38520. checkInputs(): void;
  38521. /**
  38522. * Gets the class name of the current intput.
  38523. * @returns the class name
  38524. */
  38525. getClassName(): string;
  38526. /**
  38527. * Get the friendly name associated with the input class.
  38528. * @returns the input friendly name
  38529. */
  38530. getSimpleName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /**
  38535. * Defines the potential axis of a Joystick
  38536. */
  38537. export enum JoystickAxis {
  38538. /** X axis */
  38539. X = 0,
  38540. /** Y axis */
  38541. Y = 1,
  38542. /** Z axis */
  38543. Z = 2
  38544. }
  38545. /**
  38546. * Class used to define virtual joystick (used in touch mode)
  38547. */
  38548. export class VirtualJoystick {
  38549. /**
  38550. * Gets or sets a boolean indicating that left and right values must be inverted
  38551. */
  38552. reverseLeftRight: boolean;
  38553. /**
  38554. * Gets or sets a boolean indicating that up and down values must be inverted
  38555. */
  38556. reverseUpDown: boolean;
  38557. /**
  38558. * Gets the offset value for the position (ie. the change of the position value)
  38559. */
  38560. deltaPosition: Vector3;
  38561. /**
  38562. * Gets a boolean indicating if the virtual joystick was pressed
  38563. */
  38564. pressed: boolean;
  38565. /**
  38566. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38567. */
  38568. static Canvas: Nullable<HTMLCanvasElement>;
  38569. private static _globalJoystickIndex;
  38570. private static vjCanvasContext;
  38571. private static vjCanvasWidth;
  38572. private static vjCanvasHeight;
  38573. private static halfWidth;
  38574. private _action;
  38575. private _axisTargetedByLeftAndRight;
  38576. private _axisTargetedByUpAndDown;
  38577. private _joystickSensibility;
  38578. private _inversedSensibility;
  38579. private _joystickPointerID;
  38580. private _joystickColor;
  38581. private _joystickPointerPos;
  38582. private _joystickPreviousPointerPos;
  38583. private _joystickPointerStartPos;
  38584. private _deltaJoystickVector;
  38585. private _leftJoystick;
  38586. private _touches;
  38587. private _onPointerDownHandlerRef;
  38588. private _onPointerMoveHandlerRef;
  38589. private _onPointerUpHandlerRef;
  38590. private _onResize;
  38591. /**
  38592. * Creates a new virtual joystick
  38593. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38594. */
  38595. constructor(leftJoystick?: boolean);
  38596. /**
  38597. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38598. * @param newJoystickSensibility defines the new sensibility
  38599. */
  38600. setJoystickSensibility(newJoystickSensibility: number): void;
  38601. private _onPointerDown;
  38602. private _onPointerMove;
  38603. private _onPointerUp;
  38604. /**
  38605. * Change the color of the virtual joystick
  38606. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38607. */
  38608. setJoystickColor(newColor: string): void;
  38609. /**
  38610. * Defines a callback to call when the joystick is touched
  38611. * @param action defines the callback
  38612. */
  38613. setActionOnTouch(action: () => any): void;
  38614. /**
  38615. * Defines which axis you'd like to control for left & right
  38616. * @param axis defines the axis to use
  38617. */
  38618. setAxisForLeftRight(axis: JoystickAxis): void;
  38619. /**
  38620. * Defines which axis you'd like to control for up & down
  38621. * @param axis defines the axis to use
  38622. */
  38623. setAxisForUpDown(axis: JoystickAxis): void;
  38624. private _drawVirtualJoystick;
  38625. /**
  38626. * Release internal HTML canvas
  38627. */
  38628. releaseCanvas(): void;
  38629. }
  38630. }
  38631. declare module BABYLON {
  38632. interface FreeCameraInputsManager {
  38633. /**
  38634. * Add virtual joystick input support to the input manager.
  38635. * @returns the current input manager
  38636. */
  38637. addVirtualJoystick(): FreeCameraInputsManager;
  38638. }
  38639. /**
  38640. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38642. */
  38643. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38644. /**
  38645. * Defines the camera the input is attached to.
  38646. */
  38647. camera: FreeCamera;
  38648. private _leftjoystick;
  38649. private _rightjoystick;
  38650. /**
  38651. * Gets the left stick of the virtual joystick.
  38652. * @returns The virtual Joystick
  38653. */
  38654. getLeftJoystick(): VirtualJoystick;
  38655. /**
  38656. * Gets the right stick of the virtual joystick.
  38657. * @returns The virtual Joystick
  38658. */
  38659. getRightJoystick(): VirtualJoystick;
  38660. /**
  38661. * Update the current camera state depending on the inputs that have been used this frame.
  38662. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38663. */
  38664. checkInputs(): void;
  38665. /**
  38666. * Attach the input controls to a specific dom element to get the input from.
  38667. * @param element Defines the element the controls should be listened from
  38668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38669. */
  38670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38671. /**
  38672. * Detach the current controls from the specified dom element.
  38673. * @param element Defines the element to stop listening the inputs from
  38674. */
  38675. detachControl(element: Nullable<HTMLElement>): void;
  38676. /**
  38677. * Gets the class name of the current intput.
  38678. * @returns the class name
  38679. */
  38680. getClassName(): string;
  38681. /**
  38682. * Get the friendly name associated with the input class.
  38683. * @returns the input friendly name
  38684. */
  38685. getSimpleName(): string;
  38686. }
  38687. }
  38688. declare module BABYLON {
  38689. /**
  38690. * This represents a FPS type of camera controlled by touch.
  38691. * This is like a universal camera minus the Gamepad controls.
  38692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38693. */
  38694. export class TouchCamera extends FreeCamera {
  38695. /**
  38696. * Defines the touch sensibility for rotation.
  38697. * The higher the faster.
  38698. */
  38699. touchAngularSensibility: number;
  38700. /**
  38701. * Defines the touch sensibility for move.
  38702. * The higher the faster.
  38703. */
  38704. touchMoveSensibility: number;
  38705. /**
  38706. * Instantiates a new touch camera.
  38707. * This represents a FPS type of camera controlled by touch.
  38708. * This is like a universal camera minus the Gamepad controls.
  38709. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38710. * @param name Define the name of the camera in the scene
  38711. * @param position Define the start position of the camera in the scene
  38712. * @param scene Define the scene the camera belongs to
  38713. */
  38714. constructor(name: string, position: Vector3, scene: Scene);
  38715. /**
  38716. * Gets the current object class name.
  38717. * @return the class name
  38718. */
  38719. getClassName(): string;
  38720. /** @hidden */
  38721. _setupInputs(): void;
  38722. }
  38723. }
  38724. declare module BABYLON {
  38725. /**
  38726. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38727. * being tilted forward or back and left or right.
  38728. */
  38729. export class DeviceOrientationCamera extends FreeCamera {
  38730. private _initialQuaternion;
  38731. private _quaternionCache;
  38732. private _tmpDragQuaternion;
  38733. private _disablePointerInputWhenUsingDeviceOrientation;
  38734. /**
  38735. * Creates a new device orientation camera
  38736. * @param name The name of the camera
  38737. * @param position The start position camera
  38738. * @param scene The scene the camera belongs to
  38739. */
  38740. constructor(name: string, position: Vector3, scene: Scene);
  38741. /**
  38742. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38743. */
  38744. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38745. private _dragFactor;
  38746. /**
  38747. * Enabled turning on the y axis when the orientation sensor is active
  38748. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38749. */
  38750. enableHorizontalDragging(dragFactor?: number): void;
  38751. /**
  38752. * Gets the current instance class name ("DeviceOrientationCamera").
  38753. * This helps avoiding instanceof at run time.
  38754. * @returns the class name
  38755. */
  38756. getClassName(): string;
  38757. /**
  38758. * @hidden
  38759. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38760. */
  38761. _checkInputs(): void;
  38762. /**
  38763. * Reset the camera to its default orientation on the specified axis only.
  38764. * @param axis The axis to reset
  38765. */
  38766. resetToCurrentRotation(axis?: Axis): void;
  38767. }
  38768. }
  38769. declare module BABYLON {
  38770. /**
  38771. * Defines supported buttons for XBox360 compatible gamepads
  38772. */
  38773. export enum Xbox360Button {
  38774. /** A */
  38775. A = 0,
  38776. /** B */
  38777. B = 1,
  38778. /** X */
  38779. X = 2,
  38780. /** Y */
  38781. Y = 3,
  38782. /** Start */
  38783. Start = 4,
  38784. /** Back */
  38785. Back = 5,
  38786. /** Left button */
  38787. LB = 6,
  38788. /** Right button */
  38789. RB = 7,
  38790. /** Left stick */
  38791. LeftStick = 8,
  38792. /** Right stick */
  38793. RightStick = 9
  38794. }
  38795. /** Defines values for XBox360 DPad */
  38796. export enum Xbox360Dpad {
  38797. /** Up */
  38798. Up = 0,
  38799. /** Down */
  38800. Down = 1,
  38801. /** Left */
  38802. Left = 2,
  38803. /** Right */
  38804. Right = 3
  38805. }
  38806. /**
  38807. * Defines a XBox360 gamepad
  38808. */
  38809. export class Xbox360Pad extends Gamepad {
  38810. private _leftTrigger;
  38811. private _rightTrigger;
  38812. private _onlefttriggerchanged;
  38813. private _onrighttriggerchanged;
  38814. private _onbuttondown;
  38815. private _onbuttonup;
  38816. private _ondpaddown;
  38817. private _ondpadup;
  38818. /** Observable raised when a button is pressed */
  38819. onButtonDownObservable: Observable<Xbox360Button>;
  38820. /** Observable raised when a button is released */
  38821. onButtonUpObservable: Observable<Xbox360Button>;
  38822. /** Observable raised when a pad is pressed */
  38823. onPadDownObservable: Observable<Xbox360Dpad>;
  38824. /** Observable raised when a pad is released */
  38825. onPadUpObservable: Observable<Xbox360Dpad>;
  38826. private _buttonA;
  38827. private _buttonB;
  38828. private _buttonX;
  38829. private _buttonY;
  38830. private _buttonBack;
  38831. private _buttonStart;
  38832. private _buttonLB;
  38833. private _buttonRB;
  38834. private _buttonLeftStick;
  38835. private _buttonRightStick;
  38836. private _dPadUp;
  38837. private _dPadDown;
  38838. private _dPadLeft;
  38839. private _dPadRight;
  38840. private _isXboxOnePad;
  38841. /**
  38842. * Creates a new XBox360 gamepad object
  38843. * @param id defines the id of this gamepad
  38844. * @param index defines its index
  38845. * @param gamepad defines the internal HTML gamepad object
  38846. * @param xboxOne defines if it is a XBox One gamepad
  38847. */
  38848. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38849. /**
  38850. * Defines the callback to call when left trigger is pressed
  38851. * @param callback defines the callback to use
  38852. */
  38853. onlefttriggerchanged(callback: (value: number) => void): void;
  38854. /**
  38855. * Defines the callback to call when right trigger is pressed
  38856. * @param callback defines the callback to use
  38857. */
  38858. onrighttriggerchanged(callback: (value: number) => void): void;
  38859. /**
  38860. * Gets the left trigger value
  38861. */
  38862. /**
  38863. * Sets the left trigger value
  38864. */
  38865. leftTrigger: number;
  38866. /**
  38867. * Gets the right trigger value
  38868. */
  38869. /**
  38870. * Sets the right trigger value
  38871. */
  38872. rightTrigger: number;
  38873. /**
  38874. * Defines the callback to call when a button is pressed
  38875. * @param callback defines the callback to use
  38876. */
  38877. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38878. /**
  38879. * Defines the callback to call when a button is released
  38880. * @param callback defines the callback to use
  38881. */
  38882. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38883. /**
  38884. * Defines the callback to call when a pad is pressed
  38885. * @param callback defines the callback to use
  38886. */
  38887. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38888. /**
  38889. * Defines the callback to call when a pad is released
  38890. * @param callback defines the callback to use
  38891. */
  38892. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38893. private _setButtonValue;
  38894. private _setDPadValue;
  38895. /**
  38896. * Gets the value of the `A` button
  38897. */
  38898. /**
  38899. * Sets the value of the `A` button
  38900. */
  38901. buttonA: number;
  38902. /**
  38903. * Gets the value of the `B` button
  38904. */
  38905. /**
  38906. * Sets the value of the `B` button
  38907. */
  38908. buttonB: number;
  38909. /**
  38910. * Gets the value of the `X` button
  38911. */
  38912. /**
  38913. * Sets the value of the `X` button
  38914. */
  38915. buttonX: number;
  38916. /**
  38917. * Gets the value of the `Y` button
  38918. */
  38919. /**
  38920. * Sets the value of the `Y` button
  38921. */
  38922. buttonY: number;
  38923. /**
  38924. * Gets the value of the `Start` button
  38925. */
  38926. /**
  38927. * Sets the value of the `Start` button
  38928. */
  38929. buttonStart: number;
  38930. /**
  38931. * Gets the value of the `Back` button
  38932. */
  38933. /**
  38934. * Sets the value of the `Back` button
  38935. */
  38936. buttonBack: number;
  38937. /**
  38938. * Gets the value of the `Left` button
  38939. */
  38940. /**
  38941. * Sets the value of the `Left` button
  38942. */
  38943. buttonLB: number;
  38944. /**
  38945. * Gets the value of the `Right` button
  38946. */
  38947. /**
  38948. * Sets the value of the `Right` button
  38949. */
  38950. buttonRB: number;
  38951. /**
  38952. * Gets the value of the Left joystick
  38953. */
  38954. /**
  38955. * Sets the value of the Left joystick
  38956. */
  38957. buttonLeftStick: number;
  38958. /**
  38959. * Gets the value of the Right joystick
  38960. */
  38961. /**
  38962. * Sets the value of the Right joystick
  38963. */
  38964. buttonRightStick: number;
  38965. /**
  38966. * Gets the value of D-pad up
  38967. */
  38968. /**
  38969. * Sets the value of D-pad up
  38970. */
  38971. dPadUp: number;
  38972. /**
  38973. * Gets the value of D-pad down
  38974. */
  38975. /**
  38976. * Sets the value of D-pad down
  38977. */
  38978. dPadDown: number;
  38979. /**
  38980. * Gets the value of D-pad left
  38981. */
  38982. /**
  38983. * Sets the value of D-pad left
  38984. */
  38985. dPadLeft: number;
  38986. /**
  38987. * Gets the value of D-pad right
  38988. */
  38989. /**
  38990. * Sets the value of D-pad right
  38991. */
  38992. dPadRight: number;
  38993. /**
  38994. * Force the gamepad to synchronize with device values
  38995. */
  38996. update(): void;
  38997. /**
  38998. * Disposes the gamepad
  38999. */
  39000. dispose(): void;
  39001. }
  39002. }
  39003. declare module BABYLON {
  39004. /**
  39005. * Defines supported buttons for DualShock compatible gamepads
  39006. */
  39007. export enum DualShockButton {
  39008. /** Cross */
  39009. Cross = 0,
  39010. /** Circle */
  39011. Circle = 1,
  39012. /** Square */
  39013. Square = 2,
  39014. /** Triangle */
  39015. Triangle = 3,
  39016. /** Options */
  39017. Options = 4,
  39018. /** Share */
  39019. Share = 5,
  39020. /** L1 */
  39021. L1 = 6,
  39022. /** R1 */
  39023. R1 = 7,
  39024. /** Left stick */
  39025. LeftStick = 8,
  39026. /** Right stick */
  39027. RightStick = 9
  39028. }
  39029. /** Defines values for DualShock DPad */
  39030. export enum DualShockDpad {
  39031. /** Up */
  39032. Up = 0,
  39033. /** Down */
  39034. Down = 1,
  39035. /** Left */
  39036. Left = 2,
  39037. /** Right */
  39038. Right = 3
  39039. }
  39040. /**
  39041. * Defines a DualShock gamepad
  39042. */
  39043. export class DualShockPad extends Gamepad {
  39044. private _leftTrigger;
  39045. private _rightTrigger;
  39046. private _onlefttriggerchanged;
  39047. private _onrighttriggerchanged;
  39048. private _onbuttondown;
  39049. private _onbuttonup;
  39050. private _ondpaddown;
  39051. private _ondpadup;
  39052. /** Observable raised when a button is pressed */
  39053. onButtonDownObservable: Observable<DualShockButton>;
  39054. /** Observable raised when a button is released */
  39055. onButtonUpObservable: Observable<DualShockButton>;
  39056. /** Observable raised when a pad is pressed */
  39057. onPadDownObservable: Observable<DualShockDpad>;
  39058. /** Observable raised when a pad is released */
  39059. onPadUpObservable: Observable<DualShockDpad>;
  39060. private _buttonCross;
  39061. private _buttonCircle;
  39062. private _buttonSquare;
  39063. private _buttonTriangle;
  39064. private _buttonShare;
  39065. private _buttonOptions;
  39066. private _buttonL1;
  39067. private _buttonR1;
  39068. private _buttonLeftStick;
  39069. private _buttonRightStick;
  39070. private _dPadUp;
  39071. private _dPadDown;
  39072. private _dPadLeft;
  39073. private _dPadRight;
  39074. /**
  39075. * Creates a new DualShock gamepad object
  39076. * @param id defines the id of this gamepad
  39077. * @param index defines its index
  39078. * @param gamepad defines the internal HTML gamepad object
  39079. */
  39080. constructor(id: string, index: number, gamepad: any);
  39081. /**
  39082. * Defines the callback to call when left trigger is pressed
  39083. * @param callback defines the callback to use
  39084. */
  39085. onlefttriggerchanged(callback: (value: number) => void): void;
  39086. /**
  39087. * Defines the callback to call when right trigger is pressed
  39088. * @param callback defines the callback to use
  39089. */
  39090. onrighttriggerchanged(callback: (value: number) => void): void;
  39091. /**
  39092. * Gets the left trigger value
  39093. */
  39094. /**
  39095. * Sets the left trigger value
  39096. */
  39097. leftTrigger: number;
  39098. /**
  39099. * Gets the right trigger value
  39100. */
  39101. /**
  39102. * Sets the right trigger value
  39103. */
  39104. rightTrigger: number;
  39105. /**
  39106. * Defines the callback to call when a button is pressed
  39107. * @param callback defines the callback to use
  39108. */
  39109. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39110. /**
  39111. * Defines the callback to call when a button is released
  39112. * @param callback defines the callback to use
  39113. */
  39114. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39115. /**
  39116. * Defines the callback to call when a pad is pressed
  39117. * @param callback defines the callback to use
  39118. */
  39119. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39120. /**
  39121. * Defines the callback to call when a pad is released
  39122. * @param callback defines the callback to use
  39123. */
  39124. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39125. private _setButtonValue;
  39126. private _setDPadValue;
  39127. /**
  39128. * Gets the value of the `Cross` button
  39129. */
  39130. /**
  39131. * Sets the value of the `Cross` button
  39132. */
  39133. buttonCross: number;
  39134. /**
  39135. * Gets the value of the `Circle` button
  39136. */
  39137. /**
  39138. * Sets the value of the `Circle` button
  39139. */
  39140. buttonCircle: number;
  39141. /**
  39142. * Gets the value of the `Square` button
  39143. */
  39144. /**
  39145. * Sets the value of the `Square` button
  39146. */
  39147. buttonSquare: number;
  39148. /**
  39149. * Gets the value of the `Triangle` button
  39150. */
  39151. /**
  39152. * Sets the value of the `Triangle` button
  39153. */
  39154. buttonTriangle: number;
  39155. /**
  39156. * Gets the value of the `Options` button
  39157. */
  39158. /**
  39159. * Sets the value of the `Options` button
  39160. */
  39161. buttonOptions: number;
  39162. /**
  39163. * Gets the value of the `Share` button
  39164. */
  39165. /**
  39166. * Sets the value of the `Share` button
  39167. */
  39168. buttonShare: number;
  39169. /**
  39170. * Gets the value of the `L1` button
  39171. */
  39172. /**
  39173. * Sets the value of the `L1` button
  39174. */
  39175. buttonL1: number;
  39176. /**
  39177. * Gets the value of the `R1` button
  39178. */
  39179. /**
  39180. * Sets the value of the `R1` button
  39181. */
  39182. buttonR1: number;
  39183. /**
  39184. * Gets the value of the Left joystick
  39185. */
  39186. /**
  39187. * Sets the value of the Left joystick
  39188. */
  39189. buttonLeftStick: number;
  39190. /**
  39191. * Gets the value of the Right joystick
  39192. */
  39193. /**
  39194. * Sets the value of the Right joystick
  39195. */
  39196. buttonRightStick: number;
  39197. /**
  39198. * Gets the value of D-pad up
  39199. */
  39200. /**
  39201. * Sets the value of D-pad up
  39202. */
  39203. dPadUp: number;
  39204. /**
  39205. * Gets the value of D-pad down
  39206. */
  39207. /**
  39208. * Sets the value of D-pad down
  39209. */
  39210. dPadDown: number;
  39211. /**
  39212. * Gets the value of D-pad left
  39213. */
  39214. /**
  39215. * Sets the value of D-pad left
  39216. */
  39217. dPadLeft: number;
  39218. /**
  39219. * Gets the value of D-pad right
  39220. */
  39221. /**
  39222. * Sets the value of D-pad right
  39223. */
  39224. dPadRight: number;
  39225. /**
  39226. * Force the gamepad to synchronize with device values
  39227. */
  39228. update(): void;
  39229. /**
  39230. * Disposes the gamepad
  39231. */
  39232. dispose(): void;
  39233. }
  39234. }
  39235. declare module BABYLON {
  39236. /**
  39237. * Manager for handling gamepads
  39238. */
  39239. export class GamepadManager {
  39240. private _scene?;
  39241. private _babylonGamepads;
  39242. private _oneGamepadConnected;
  39243. /** @hidden */
  39244. _isMonitoring: boolean;
  39245. private _gamepadEventSupported;
  39246. private _gamepadSupport;
  39247. /**
  39248. * observable to be triggered when the gamepad controller has been connected
  39249. */
  39250. onGamepadConnectedObservable: Observable<Gamepad>;
  39251. /**
  39252. * observable to be triggered when the gamepad controller has been disconnected
  39253. */
  39254. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39255. private _onGamepadConnectedEvent;
  39256. private _onGamepadDisconnectedEvent;
  39257. /**
  39258. * Initializes the gamepad manager
  39259. * @param _scene BabylonJS scene
  39260. */
  39261. constructor(_scene?: Scene | undefined);
  39262. /**
  39263. * The gamepads in the game pad manager
  39264. */
  39265. readonly gamepads: Gamepad[];
  39266. /**
  39267. * Get the gamepad controllers based on type
  39268. * @param type The type of gamepad controller
  39269. * @returns Nullable gamepad
  39270. */
  39271. getGamepadByType(type?: number): Nullable<Gamepad>;
  39272. /**
  39273. * Disposes the gamepad manager
  39274. */
  39275. dispose(): void;
  39276. private _addNewGamepad;
  39277. private _startMonitoringGamepads;
  39278. private _stopMonitoringGamepads;
  39279. /** @hidden */
  39280. _checkGamepadsStatus(): void;
  39281. private _updateGamepadObjects;
  39282. }
  39283. }
  39284. declare module BABYLON {
  39285. interface Scene {
  39286. /** @hidden */
  39287. _gamepadManager: Nullable<GamepadManager>;
  39288. /**
  39289. * Gets the gamepad manager associated with the scene
  39290. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39291. */
  39292. gamepadManager: GamepadManager;
  39293. }
  39294. /**
  39295. * Interface representing a free camera inputs manager
  39296. */
  39297. interface FreeCameraInputsManager {
  39298. /**
  39299. * Adds gamepad input support to the FreeCameraInputsManager.
  39300. * @returns the FreeCameraInputsManager
  39301. */
  39302. addGamepad(): FreeCameraInputsManager;
  39303. }
  39304. /**
  39305. * Interface representing an arc rotate camera inputs manager
  39306. */
  39307. interface ArcRotateCameraInputsManager {
  39308. /**
  39309. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39310. * @returns the camera inputs manager
  39311. */
  39312. addGamepad(): ArcRotateCameraInputsManager;
  39313. }
  39314. /**
  39315. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39316. */
  39317. export class GamepadSystemSceneComponent implements ISceneComponent {
  39318. /**
  39319. * The component name helpfull to identify the component in the list of scene components.
  39320. */
  39321. readonly name: string;
  39322. /**
  39323. * The scene the component belongs to.
  39324. */
  39325. scene: Scene;
  39326. /**
  39327. * Creates a new instance of the component for the given scene
  39328. * @param scene Defines the scene to register the component in
  39329. */
  39330. constructor(scene: Scene);
  39331. /**
  39332. * Registers the component in a given scene
  39333. */
  39334. register(): void;
  39335. /**
  39336. * Rebuilds the elements related to this component in case of
  39337. * context lost for instance.
  39338. */
  39339. rebuild(): void;
  39340. /**
  39341. * Disposes the component and the associated ressources
  39342. */
  39343. dispose(): void;
  39344. private _beforeCameraUpdate;
  39345. }
  39346. }
  39347. declare module BABYLON {
  39348. /**
  39349. * 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,
  39350. * which still works and will still be found in many Playgrounds.
  39351. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39352. */
  39353. export class UniversalCamera extends TouchCamera {
  39354. /**
  39355. * Defines the gamepad rotation sensiblity.
  39356. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39357. */
  39358. gamepadAngularSensibility: number;
  39359. /**
  39360. * Defines the gamepad move sensiblity.
  39361. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39362. */
  39363. gamepadMoveSensibility: number;
  39364. /**
  39365. * 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,
  39366. * which still works and will still be found in many Playgrounds.
  39367. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39368. * @param name Define the name of the camera in the scene
  39369. * @param position Define the start position of the camera in the scene
  39370. * @param scene Define the scene the camera belongs to
  39371. */
  39372. constructor(name: string, position: Vector3, scene: Scene);
  39373. /**
  39374. * Gets the current object class name.
  39375. * @return the class name
  39376. */
  39377. getClassName(): string;
  39378. }
  39379. }
  39380. declare module BABYLON {
  39381. /**
  39382. * This represents a FPS type of camera. This is only here for back compat purpose.
  39383. * Please use the UniversalCamera instead as both are identical.
  39384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39385. */
  39386. export class GamepadCamera extends UniversalCamera {
  39387. /**
  39388. * Instantiates a new Gamepad Camera
  39389. * This represents a FPS type of camera. This is only here for back compat purpose.
  39390. * Please use the UniversalCamera instead as both are identical.
  39391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39392. * @param name Define the name of the camera in the scene
  39393. * @param position Define the start position of the camera in the scene
  39394. * @param scene Define the scene the camera belongs to
  39395. */
  39396. constructor(name: string, position: Vector3, scene: Scene);
  39397. /**
  39398. * Gets the current object class name.
  39399. * @return the class name
  39400. */
  39401. getClassName(): string;
  39402. }
  39403. }
  39404. declare module BABYLON {
  39405. /** @hidden */
  39406. export var passPixelShader: {
  39407. name: string;
  39408. shader: string;
  39409. };
  39410. }
  39411. declare module BABYLON {
  39412. /** @hidden */
  39413. export var passCubePixelShader: {
  39414. name: string;
  39415. shader: string;
  39416. };
  39417. }
  39418. declare module BABYLON {
  39419. /**
  39420. * PassPostProcess which produces an output the same as it's input
  39421. */
  39422. export class PassPostProcess extends PostProcess {
  39423. /**
  39424. * Creates the PassPostProcess
  39425. * @param name The name of the effect.
  39426. * @param options The required width/height ratio to downsize to before computing the render pass.
  39427. * @param camera The camera to apply the render pass to.
  39428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39429. * @param engine The engine which the post process will be applied. (default: current engine)
  39430. * @param reusable If the post process can be reused on the same frame. (default: false)
  39431. * @param textureType The type of texture to be used when performing the post processing.
  39432. * @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)
  39433. */
  39434. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39435. }
  39436. /**
  39437. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39438. */
  39439. export class PassCubePostProcess extends PostProcess {
  39440. private _face;
  39441. /**
  39442. * Gets or sets the cube face to display.
  39443. * * 0 is +X
  39444. * * 1 is -X
  39445. * * 2 is +Y
  39446. * * 3 is -Y
  39447. * * 4 is +Z
  39448. * * 5 is -Z
  39449. */
  39450. face: number;
  39451. /**
  39452. * Creates the PassCubePostProcess
  39453. * @param name The name of the effect.
  39454. * @param options The required width/height ratio to downsize to before computing the render pass.
  39455. * @param camera The camera to apply the render pass to.
  39456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39457. * @param engine The engine which the post process will be applied. (default: current engine)
  39458. * @param reusable If the post process can be reused on the same frame. (default: false)
  39459. * @param textureType The type of texture to be used when performing the post processing.
  39460. * @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)
  39461. */
  39462. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39463. }
  39464. }
  39465. declare module BABYLON {
  39466. /** @hidden */
  39467. export var anaglyphPixelShader: {
  39468. name: string;
  39469. shader: string;
  39470. };
  39471. }
  39472. declare module BABYLON {
  39473. /**
  39474. * Postprocess used to generate anaglyphic rendering
  39475. */
  39476. export class AnaglyphPostProcess extends PostProcess {
  39477. private _passedProcess;
  39478. /**
  39479. * Creates a new AnaglyphPostProcess
  39480. * @param name defines postprocess name
  39481. * @param options defines creation options or target ratio scale
  39482. * @param rigCameras defines cameras using this postprocess
  39483. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39484. * @param engine defines hosting engine
  39485. * @param reusable defines if the postprocess will be reused multiple times per frame
  39486. */
  39487. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39488. }
  39489. }
  39490. declare module BABYLON {
  39491. /**
  39492. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39493. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39494. */
  39495. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39496. /**
  39497. * Creates a new AnaglyphArcRotateCamera
  39498. * @param name defines camera name
  39499. * @param alpha defines alpha angle (in radians)
  39500. * @param beta defines beta angle (in radians)
  39501. * @param radius defines radius
  39502. * @param target defines camera target
  39503. * @param interaxialDistance defines distance between each color axis
  39504. * @param scene defines the hosting scene
  39505. */
  39506. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39507. /**
  39508. * Gets camera class name
  39509. * @returns AnaglyphArcRotateCamera
  39510. */
  39511. getClassName(): string;
  39512. }
  39513. }
  39514. declare module BABYLON {
  39515. /**
  39516. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39517. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39518. */
  39519. export class AnaglyphFreeCamera extends FreeCamera {
  39520. /**
  39521. * Creates a new AnaglyphFreeCamera
  39522. * @param name defines camera name
  39523. * @param position defines initial position
  39524. * @param interaxialDistance defines distance between each color axis
  39525. * @param scene defines the hosting scene
  39526. */
  39527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39528. /**
  39529. * Gets camera class name
  39530. * @returns AnaglyphFreeCamera
  39531. */
  39532. getClassName(): string;
  39533. }
  39534. }
  39535. declare module BABYLON {
  39536. /**
  39537. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39538. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39539. */
  39540. export class AnaglyphGamepadCamera extends GamepadCamera {
  39541. /**
  39542. * Creates a new AnaglyphGamepadCamera
  39543. * @param name defines camera name
  39544. * @param position defines initial position
  39545. * @param interaxialDistance defines distance between each color axis
  39546. * @param scene defines the hosting scene
  39547. */
  39548. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39549. /**
  39550. * Gets camera class name
  39551. * @returns AnaglyphGamepadCamera
  39552. */
  39553. getClassName(): string;
  39554. }
  39555. }
  39556. declare module BABYLON {
  39557. /**
  39558. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39559. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39560. */
  39561. export class AnaglyphUniversalCamera extends UniversalCamera {
  39562. /**
  39563. * Creates a new AnaglyphUniversalCamera
  39564. * @param name defines camera name
  39565. * @param position defines initial position
  39566. * @param interaxialDistance defines distance between each color axis
  39567. * @param scene defines the hosting scene
  39568. */
  39569. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39570. /**
  39571. * Gets camera class name
  39572. * @returns AnaglyphUniversalCamera
  39573. */
  39574. getClassName(): string;
  39575. }
  39576. }
  39577. declare module BABYLON {
  39578. /** @hidden */
  39579. export var stereoscopicInterlacePixelShader: {
  39580. name: string;
  39581. shader: string;
  39582. };
  39583. }
  39584. declare module BABYLON {
  39585. /**
  39586. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39587. */
  39588. export class StereoscopicInterlacePostProcess extends PostProcess {
  39589. private _stepSize;
  39590. private _passedProcess;
  39591. /**
  39592. * Initializes a StereoscopicInterlacePostProcess
  39593. * @param name The name of the effect.
  39594. * @param rigCameras The rig cameras to be appled to the post process
  39595. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39597. * @param engine The engine which the post process will be applied. (default: current engine)
  39598. * @param reusable If the post process can be reused on the same frame. (default: false)
  39599. */
  39600. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39601. }
  39602. }
  39603. declare module BABYLON {
  39604. /**
  39605. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39606. * @see http://doc.babylonjs.com/features/cameras
  39607. */
  39608. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39609. /**
  39610. * Creates a new StereoscopicArcRotateCamera
  39611. * @param name defines camera name
  39612. * @param alpha defines alpha angle (in radians)
  39613. * @param beta defines beta angle (in radians)
  39614. * @param radius defines radius
  39615. * @param target defines camera target
  39616. * @param interaxialDistance defines distance between each color axis
  39617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39618. * @param scene defines the hosting scene
  39619. */
  39620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39621. /**
  39622. * Gets camera class name
  39623. * @returns StereoscopicArcRotateCamera
  39624. */
  39625. getClassName(): string;
  39626. }
  39627. }
  39628. declare module BABYLON {
  39629. /**
  39630. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39631. * @see http://doc.babylonjs.com/features/cameras
  39632. */
  39633. export class StereoscopicFreeCamera extends FreeCamera {
  39634. /**
  39635. * Creates a new StereoscopicFreeCamera
  39636. * @param name defines camera name
  39637. * @param position defines initial position
  39638. * @param interaxialDistance defines distance between each color axis
  39639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39640. * @param scene defines the hosting scene
  39641. */
  39642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39643. /**
  39644. * Gets camera class name
  39645. * @returns StereoscopicFreeCamera
  39646. */
  39647. getClassName(): string;
  39648. }
  39649. }
  39650. declare module BABYLON {
  39651. /**
  39652. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39653. * @see http://doc.babylonjs.com/features/cameras
  39654. */
  39655. export class StereoscopicGamepadCamera extends GamepadCamera {
  39656. /**
  39657. * Creates a new StereoscopicGamepadCamera
  39658. * @param name defines camera name
  39659. * @param position defines initial position
  39660. * @param interaxialDistance defines distance between each color axis
  39661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39662. * @param scene defines the hosting scene
  39663. */
  39664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39665. /**
  39666. * Gets camera class name
  39667. * @returns StereoscopicGamepadCamera
  39668. */
  39669. getClassName(): string;
  39670. }
  39671. }
  39672. declare module BABYLON {
  39673. /**
  39674. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39675. * @see http://doc.babylonjs.com/features/cameras
  39676. */
  39677. export class StereoscopicUniversalCamera extends UniversalCamera {
  39678. /**
  39679. * Creates a new StereoscopicUniversalCamera
  39680. * @param name defines camera name
  39681. * @param position defines initial position
  39682. * @param interaxialDistance defines distance between each color axis
  39683. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39684. * @param scene defines the hosting scene
  39685. */
  39686. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39687. /**
  39688. * Gets camera class name
  39689. * @returns StereoscopicUniversalCamera
  39690. */
  39691. getClassName(): string;
  39692. }
  39693. }
  39694. declare module BABYLON {
  39695. /**
  39696. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39697. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39698. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39699. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39700. */
  39701. export class VirtualJoysticksCamera extends FreeCamera {
  39702. /**
  39703. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39704. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39705. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39706. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39707. * @param name Define the name of the camera in the scene
  39708. * @param position Define the start position of the camera in the scene
  39709. * @param scene Define the scene the camera belongs to
  39710. */
  39711. constructor(name: string, position: Vector3, scene: Scene);
  39712. /**
  39713. * Gets the current object class name.
  39714. * @return the class name
  39715. */
  39716. getClassName(): string;
  39717. }
  39718. }
  39719. declare module BABYLON {
  39720. /**
  39721. * This represents all the required metrics to create a VR camera.
  39722. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39723. */
  39724. export class VRCameraMetrics {
  39725. /**
  39726. * Define the horizontal resolution off the screen.
  39727. */
  39728. hResolution: number;
  39729. /**
  39730. * Define the vertical resolution off the screen.
  39731. */
  39732. vResolution: number;
  39733. /**
  39734. * Define the horizontal screen size.
  39735. */
  39736. hScreenSize: number;
  39737. /**
  39738. * Define the vertical screen size.
  39739. */
  39740. vScreenSize: number;
  39741. /**
  39742. * Define the vertical screen center position.
  39743. */
  39744. vScreenCenter: number;
  39745. /**
  39746. * Define the distance of the eyes to the screen.
  39747. */
  39748. eyeToScreenDistance: number;
  39749. /**
  39750. * Define the distance between both lenses
  39751. */
  39752. lensSeparationDistance: number;
  39753. /**
  39754. * Define the distance between both viewer's eyes.
  39755. */
  39756. interpupillaryDistance: number;
  39757. /**
  39758. * Define the distortion factor of the VR postprocess.
  39759. * Please, touch with care.
  39760. */
  39761. distortionK: number[];
  39762. /**
  39763. * Define the chromatic aberration correction factors for the VR post process.
  39764. */
  39765. chromaAbCorrection: number[];
  39766. /**
  39767. * Define the scale factor of the post process.
  39768. * The smaller the better but the slower.
  39769. */
  39770. postProcessScaleFactor: number;
  39771. /**
  39772. * Define an offset for the lens center.
  39773. */
  39774. lensCenterOffset: number;
  39775. /**
  39776. * Define if the current vr camera should compensate the distortion of the lense or not.
  39777. */
  39778. compensateDistortion: boolean;
  39779. /**
  39780. * Defines if multiview should be enabled when rendering (Default: false)
  39781. */
  39782. multiviewEnabled: boolean;
  39783. /**
  39784. * Gets the rendering aspect ratio based on the provided resolutions.
  39785. */
  39786. readonly aspectRatio: number;
  39787. /**
  39788. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39789. */
  39790. readonly aspectRatioFov: number;
  39791. /**
  39792. * @hidden
  39793. */
  39794. readonly leftHMatrix: Matrix;
  39795. /**
  39796. * @hidden
  39797. */
  39798. readonly rightHMatrix: Matrix;
  39799. /**
  39800. * @hidden
  39801. */
  39802. readonly leftPreViewMatrix: Matrix;
  39803. /**
  39804. * @hidden
  39805. */
  39806. readonly rightPreViewMatrix: Matrix;
  39807. /**
  39808. * Get the default VRMetrics based on the most generic setup.
  39809. * @returns the default vr metrics
  39810. */
  39811. static GetDefault(): VRCameraMetrics;
  39812. }
  39813. }
  39814. declare module BABYLON {
  39815. /** @hidden */
  39816. export var vrDistortionCorrectionPixelShader: {
  39817. name: string;
  39818. shader: string;
  39819. };
  39820. }
  39821. declare module BABYLON {
  39822. /**
  39823. * VRDistortionCorrectionPostProcess used for mobile VR
  39824. */
  39825. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39826. private _isRightEye;
  39827. private _distortionFactors;
  39828. private _postProcessScaleFactor;
  39829. private _lensCenterOffset;
  39830. private _scaleIn;
  39831. private _scaleFactor;
  39832. private _lensCenter;
  39833. /**
  39834. * Initializes the VRDistortionCorrectionPostProcess
  39835. * @param name The name of the effect.
  39836. * @param camera The camera to apply the render pass to.
  39837. * @param isRightEye If this is for the right eye distortion
  39838. * @param vrMetrics All the required metrics for the VR camera
  39839. */
  39840. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39841. }
  39842. }
  39843. declare module BABYLON {
  39844. /**
  39845. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39846. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39847. */
  39848. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39849. /**
  39850. * Creates a new VRDeviceOrientationArcRotateCamera
  39851. * @param name defines camera name
  39852. * @param alpha defines the camera rotation along the logitudinal axis
  39853. * @param beta defines the camera rotation along the latitudinal axis
  39854. * @param radius defines the camera distance from its target
  39855. * @param target defines the camera target
  39856. * @param scene defines the scene the camera belongs to
  39857. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39858. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39859. */
  39860. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39861. /**
  39862. * Gets camera class name
  39863. * @returns VRDeviceOrientationArcRotateCamera
  39864. */
  39865. getClassName(): string;
  39866. }
  39867. }
  39868. declare module BABYLON {
  39869. /**
  39870. * Camera used to simulate VR rendering (based on FreeCamera)
  39871. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39872. */
  39873. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39874. /**
  39875. * Creates a new VRDeviceOrientationFreeCamera
  39876. * @param name defines camera name
  39877. * @param position defines the start position of the camera
  39878. * @param scene defines the scene the camera belongs to
  39879. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39880. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39881. */
  39882. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39883. /**
  39884. * Gets camera class name
  39885. * @returns VRDeviceOrientationFreeCamera
  39886. */
  39887. getClassName(): string;
  39888. }
  39889. }
  39890. declare module BABYLON {
  39891. /**
  39892. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39893. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39894. */
  39895. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39896. /**
  39897. * Creates a new VRDeviceOrientationGamepadCamera
  39898. * @param name defines camera name
  39899. * @param position defines the start position of the camera
  39900. * @param scene defines the scene the camera belongs to
  39901. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39902. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39903. */
  39904. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39905. /**
  39906. * Gets camera class name
  39907. * @returns VRDeviceOrientationGamepadCamera
  39908. */
  39909. getClassName(): string;
  39910. }
  39911. }
  39912. declare module BABYLON {
  39913. /**
  39914. * Base class of materials working in push mode in babylon JS
  39915. * @hidden
  39916. */
  39917. export class PushMaterial extends Material {
  39918. protected _activeEffect: Effect;
  39919. protected _normalMatrix: Matrix;
  39920. /**
  39921. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39922. * This means that the material can keep using a previous shader while a new one is being compiled.
  39923. * This is mostly used when shader parallel compilation is supported (true by default)
  39924. */
  39925. allowShaderHotSwapping: boolean;
  39926. constructor(name: string, scene: Scene);
  39927. getEffect(): Effect;
  39928. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39929. /**
  39930. * Binds the given world matrix to the active effect
  39931. *
  39932. * @param world the matrix to bind
  39933. */
  39934. bindOnlyWorldMatrix(world: Matrix): void;
  39935. /**
  39936. * Binds the given normal matrix to the active effect
  39937. *
  39938. * @param normalMatrix the matrix to bind
  39939. */
  39940. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39941. bind(world: Matrix, mesh?: Mesh): void;
  39942. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39943. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39944. }
  39945. }
  39946. declare module BABYLON {
  39947. /**
  39948. * This groups all the flags used to control the materials channel.
  39949. */
  39950. export class MaterialFlags {
  39951. private static _DiffuseTextureEnabled;
  39952. /**
  39953. * Are diffuse textures enabled in the application.
  39954. */
  39955. static DiffuseTextureEnabled: boolean;
  39956. private static _AmbientTextureEnabled;
  39957. /**
  39958. * Are ambient textures enabled in the application.
  39959. */
  39960. static AmbientTextureEnabled: boolean;
  39961. private static _OpacityTextureEnabled;
  39962. /**
  39963. * Are opacity textures enabled in the application.
  39964. */
  39965. static OpacityTextureEnabled: boolean;
  39966. private static _ReflectionTextureEnabled;
  39967. /**
  39968. * Are reflection textures enabled in the application.
  39969. */
  39970. static ReflectionTextureEnabled: boolean;
  39971. private static _EmissiveTextureEnabled;
  39972. /**
  39973. * Are emissive textures enabled in the application.
  39974. */
  39975. static EmissiveTextureEnabled: boolean;
  39976. private static _SpecularTextureEnabled;
  39977. /**
  39978. * Are specular textures enabled in the application.
  39979. */
  39980. static SpecularTextureEnabled: boolean;
  39981. private static _BumpTextureEnabled;
  39982. /**
  39983. * Are bump textures enabled in the application.
  39984. */
  39985. static BumpTextureEnabled: boolean;
  39986. private static _LightmapTextureEnabled;
  39987. /**
  39988. * Are lightmap textures enabled in the application.
  39989. */
  39990. static LightmapTextureEnabled: boolean;
  39991. private static _RefractionTextureEnabled;
  39992. /**
  39993. * Are refraction textures enabled in the application.
  39994. */
  39995. static RefractionTextureEnabled: boolean;
  39996. private static _ColorGradingTextureEnabled;
  39997. /**
  39998. * Are color grading textures enabled in the application.
  39999. */
  40000. static ColorGradingTextureEnabled: boolean;
  40001. private static _FresnelEnabled;
  40002. /**
  40003. * Are fresnels enabled in the application.
  40004. */
  40005. static FresnelEnabled: boolean;
  40006. private static _ClearCoatTextureEnabled;
  40007. /**
  40008. * Are clear coat textures enabled in the application.
  40009. */
  40010. static ClearCoatTextureEnabled: boolean;
  40011. private static _ClearCoatBumpTextureEnabled;
  40012. /**
  40013. * Are clear coat bump textures enabled in the application.
  40014. */
  40015. static ClearCoatBumpTextureEnabled: boolean;
  40016. private static _ClearCoatTintTextureEnabled;
  40017. /**
  40018. * Are clear coat tint textures enabled in the application.
  40019. */
  40020. static ClearCoatTintTextureEnabled: boolean;
  40021. private static _SheenTextureEnabled;
  40022. /**
  40023. * Are sheen textures enabled in the application.
  40024. */
  40025. static SheenTextureEnabled: boolean;
  40026. private static _AnisotropicTextureEnabled;
  40027. /**
  40028. * Are anisotropic textures enabled in the application.
  40029. */
  40030. static AnisotropicTextureEnabled: boolean;
  40031. private static _ThicknessTextureEnabled;
  40032. /**
  40033. * Are thickness textures enabled in the application.
  40034. */
  40035. static ThicknessTextureEnabled: boolean;
  40036. }
  40037. }
  40038. declare module BABYLON {
  40039. /** @hidden */
  40040. export var defaultFragmentDeclaration: {
  40041. name: string;
  40042. shader: string;
  40043. };
  40044. }
  40045. declare module BABYLON {
  40046. /** @hidden */
  40047. export var defaultUboDeclaration: {
  40048. name: string;
  40049. shader: string;
  40050. };
  40051. }
  40052. declare module BABYLON {
  40053. /** @hidden */
  40054. export var lightFragmentDeclaration: {
  40055. name: string;
  40056. shader: string;
  40057. };
  40058. }
  40059. declare module BABYLON {
  40060. /** @hidden */
  40061. export var lightUboDeclaration: {
  40062. name: string;
  40063. shader: string;
  40064. };
  40065. }
  40066. declare module BABYLON {
  40067. /** @hidden */
  40068. export var lightsFragmentFunctions: {
  40069. name: string;
  40070. shader: string;
  40071. };
  40072. }
  40073. declare module BABYLON {
  40074. /** @hidden */
  40075. export var shadowsFragmentFunctions: {
  40076. name: string;
  40077. shader: string;
  40078. };
  40079. }
  40080. declare module BABYLON {
  40081. /** @hidden */
  40082. export var fresnelFunction: {
  40083. name: string;
  40084. shader: string;
  40085. };
  40086. }
  40087. declare module BABYLON {
  40088. /** @hidden */
  40089. export var reflectionFunction: {
  40090. name: string;
  40091. shader: string;
  40092. };
  40093. }
  40094. declare module BABYLON {
  40095. /** @hidden */
  40096. export var bumpFragmentFunctions: {
  40097. name: string;
  40098. shader: string;
  40099. };
  40100. }
  40101. declare module BABYLON {
  40102. /** @hidden */
  40103. export var logDepthDeclaration: {
  40104. name: string;
  40105. shader: string;
  40106. };
  40107. }
  40108. declare module BABYLON {
  40109. /** @hidden */
  40110. export var bumpFragment: {
  40111. name: string;
  40112. shader: string;
  40113. };
  40114. }
  40115. declare module BABYLON {
  40116. /** @hidden */
  40117. export var depthPrePass: {
  40118. name: string;
  40119. shader: string;
  40120. };
  40121. }
  40122. declare module BABYLON {
  40123. /** @hidden */
  40124. export var lightFragment: {
  40125. name: string;
  40126. shader: string;
  40127. };
  40128. }
  40129. declare module BABYLON {
  40130. /** @hidden */
  40131. export var logDepthFragment: {
  40132. name: string;
  40133. shader: string;
  40134. };
  40135. }
  40136. declare module BABYLON {
  40137. /** @hidden */
  40138. export var defaultPixelShader: {
  40139. name: string;
  40140. shader: string;
  40141. };
  40142. }
  40143. declare module BABYLON {
  40144. /** @hidden */
  40145. export var defaultVertexDeclaration: {
  40146. name: string;
  40147. shader: string;
  40148. };
  40149. }
  40150. declare module BABYLON {
  40151. /** @hidden */
  40152. export var bumpVertexDeclaration: {
  40153. name: string;
  40154. shader: string;
  40155. };
  40156. }
  40157. declare module BABYLON {
  40158. /** @hidden */
  40159. export var bumpVertex: {
  40160. name: string;
  40161. shader: string;
  40162. };
  40163. }
  40164. declare module BABYLON {
  40165. /** @hidden */
  40166. export var fogVertex: {
  40167. name: string;
  40168. shader: string;
  40169. };
  40170. }
  40171. declare module BABYLON {
  40172. /** @hidden */
  40173. export var shadowsVertex: {
  40174. name: string;
  40175. shader: string;
  40176. };
  40177. }
  40178. declare module BABYLON {
  40179. /** @hidden */
  40180. export var pointCloudVertex: {
  40181. name: string;
  40182. shader: string;
  40183. };
  40184. }
  40185. declare module BABYLON {
  40186. /** @hidden */
  40187. export var logDepthVertex: {
  40188. name: string;
  40189. shader: string;
  40190. };
  40191. }
  40192. declare module BABYLON {
  40193. /** @hidden */
  40194. export var defaultVertexShader: {
  40195. name: string;
  40196. shader: string;
  40197. };
  40198. }
  40199. declare module BABYLON {
  40200. /** @hidden */
  40201. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40202. MAINUV1: boolean;
  40203. MAINUV2: boolean;
  40204. DIFFUSE: boolean;
  40205. DIFFUSEDIRECTUV: number;
  40206. AMBIENT: boolean;
  40207. AMBIENTDIRECTUV: number;
  40208. OPACITY: boolean;
  40209. OPACITYDIRECTUV: number;
  40210. OPACITYRGB: boolean;
  40211. REFLECTION: boolean;
  40212. EMISSIVE: boolean;
  40213. EMISSIVEDIRECTUV: number;
  40214. SPECULAR: boolean;
  40215. SPECULARDIRECTUV: number;
  40216. BUMP: boolean;
  40217. BUMPDIRECTUV: number;
  40218. PARALLAX: boolean;
  40219. PARALLAXOCCLUSION: boolean;
  40220. SPECULAROVERALPHA: boolean;
  40221. CLIPPLANE: boolean;
  40222. CLIPPLANE2: boolean;
  40223. CLIPPLANE3: boolean;
  40224. CLIPPLANE4: boolean;
  40225. ALPHATEST: boolean;
  40226. DEPTHPREPASS: boolean;
  40227. ALPHAFROMDIFFUSE: boolean;
  40228. POINTSIZE: boolean;
  40229. FOG: boolean;
  40230. SPECULARTERM: boolean;
  40231. DIFFUSEFRESNEL: boolean;
  40232. OPACITYFRESNEL: boolean;
  40233. REFLECTIONFRESNEL: boolean;
  40234. REFRACTIONFRESNEL: boolean;
  40235. EMISSIVEFRESNEL: boolean;
  40236. FRESNEL: boolean;
  40237. NORMAL: boolean;
  40238. UV1: boolean;
  40239. UV2: boolean;
  40240. VERTEXCOLOR: boolean;
  40241. VERTEXALPHA: boolean;
  40242. NUM_BONE_INFLUENCERS: number;
  40243. BonesPerMesh: number;
  40244. BONETEXTURE: boolean;
  40245. INSTANCES: boolean;
  40246. GLOSSINESS: boolean;
  40247. ROUGHNESS: boolean;
  40248. EMISSIVEASILLUMINATION: boolean;
  40249. LINKEMISSIVEWITHDIFFUSE: boolean;
  40250. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40251. LIGHTMAP: boolean;
  40252. LIGHTMAPDIRECTUV: number;
  40253. OBJECTSPACE_NORMALMAP: boolean;
  40254. USELIGHTMAPASSHADOWMAP: boolean;
  40255. REFLECTIONMAP_3D: boolean;
  40256. REFLECTIONMAP_SPHERICAL: boolean;
  40257. REFLECTIONMAP_PLANAR: boolean;
  40258. REFLECTIONMAP_CUBIC: boolean;
  40259. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40260. REFLECTIONMAP_PROJECTION: boolean;
  40261. REFLECTIONMAP_SKYBOX: boolean;
  40262. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40263. REFLECTIONMAP_EXPLICIT: boolean;
  40264. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40265. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40266. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40267. INVERTCUBICMAP: boolean;
  40268. LOGARITHMICDEPTH: boolean;
  40269. REFRACTION: boolean;
  40270. REFRACTIONMAP_3D: boolean;
  40271. REFLECTIONOVERALPHA: boolean;
  40272. TWOSIDEDLIGHTING: boolean;
  40273. SHADOWFLOAT: boolean;
  40274. MORPHTARGETS: boolean;
  40275. MORPHTARGETS_NORMAL: boolean;
  40276. MORPHTARGETS_TANGENT: boolean;
  40277. MORPHTARGETS_UV: boolean;
  40278. NUM_MORPH_INFLUENCERS: number;
  40279. NONUNIFORMSCALING: boolean;
  40280. PREMULTIPLYALPHA: boolean;
  40281. IMAGEPROCESSING: boolean;
  40282. VIGNETTE: boolean;
  40283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40284. VIGNETTEBLENDMODEOPAQUE: boolean;
  40285. TONEMAPPING: boolean;
  40286. TONEMAPPING_ACES: boolean;
  40287. CONTRAST: boolean;
  40288. COLORCURVES: boolean;
  40289. COLORGRADING: boolean;
  40290. COLORGRADING3D: boolean;
  40291. SAMPLER3DGREENDEPTH: boolean;
  40292. SAMPLER3DBGRMAP: boolean;
  40293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40294. MULTIVIEW: boolean;
  40295. /**
  40296. * If the reflection texture on this material is in linear color space
  40297. * @hidden
  40298. */
  40299. IS_REFLECTION_LINEAR: boolean;
  40300. /**
  40301. * If the refraction texture on this material is in linear color space
  40302. * @hidden
  40303. */
  40304. IS_REFRACTION_LINEAR: boolean;
  40305. EXPOSURE: boolean;
  40306. constructor();
  40307. setReflectionMode(modeToEnable: string): void;
  40308. }
  40309. /**
  40310. * This is the default material used in Babylon. It is the best trade off between quality
  40311. * and performances.
  40312. * @see http://doc.babylonjs.com/babylon101/materials
  40313. */
  40314. export class StandardMaterial extends PushMaterial {
  40315. private _diffuseTexture;
  40316. /**
  40317. * The basic texture of the material as viewed under a light.
  40318. */
  40319. diffuseTexture: Nullable<BaseTexture>;
  40320. private _ambientTexture;
  40321. /**
  40322. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40323. */
  40324. ambientTexture: Nullable<BaseTexture>;
  40325. private _opacityTexture;
  40326. /**
  40327. * Define the transparency of the material from a texture.
  40328. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40329. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40330. */
  40331. opacityTexture: Nullable<BaseTexture>;
  40332. private _reflectionTexture;
  40333. /**
  40334. * Define the texture used to display the reflection.
  40335. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40336. */
  40337. reflectionTexture: Nullable<BaseTexture>;
  40338. private _emissiveTexture;
  40339. /**
  40340. * Define texture of the material as if self lit.
  40341. * This will be mixed in the final result even in the absence of light.
  40342. */
  40343. emissiveTexture: Nullable<BaseTexture>;
  40344. private _specularTexture;
  40345. /**
  40346. * Define how the color and intensity of the highlight given by the light in the material.
  40347. */
  40348. specularTexture: Nullable<BaseTexture>;
  40349. private _bumpTexture;
  40350. /**
  40351. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40352. * 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.
  40353. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40354. */
  40355. bumpTexture: Nullable<BaseTexture>;
  40356. private _lightmapTexture;
  40357. /**
  40358. * Complex lighting can be computationally expensive to compute at runtime.
  40359. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40360. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40361. */
  40362. lightmapTexture: Nullable<BaseTexture>;
  40363. private _refractionTexture;
  40364. /**
  40365. * Define the texture used to display the refraction.
  40366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40367. */
  40368. refractionTexture: Nullable<BaseTexture>;
  40369. /**
  40370. * The color of the material lit by the environmental background lighting.
  40371. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40372. */
  40373. ambientColor: Color3;
  40374. /**
  40375. * The basic color of the material as viewed under a light.
  40376. */
  40377. diffuseColor: Color3;
  40378. /**
  40379. * Define how the color and intensity of the highlight given by the light in the material.
  40380. */
  40381. specularColor: Color3;
  40382. /**
  40383. * Define the color of the material as if self lit.
  40384. * This will be mixed in the final result even in the absence of light.
  40385. */
  40386. emissiveColor: Color3;
  40387. /**
  40388. * Defines how sharp are the highlights in the material.
  40389. * The bigger the value the sharper giving a more glossy feeling to the result.
  40390. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40391. */
  40392. specularPower: number;
  40393. private _useAlphaFromDiffuseTexture;
  40394. /**
  40395. * Does the transparency come from the diffuse texture alpha channel.
  40396. */
  40397. useAlphaFromDiffuseTexture: boolean;
  40398. private _useEmissiveAsIllumination;
  40399. /**
  40400. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40401. */
  40402. useEmissiveAsIllumination: boolean;
  40403. private _linkEmissiveWithDiffuse;
  40404. /**
  40405. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40406. * the emissive level when the final color is close to one.
  40407. */
  40408. linkEmissiveWithDiffuse: boolean;
  40409. private _useSpecularOverAlpha;
  40410. /**
  40411. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40412. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40413. */
  40414. useSpecularOverAlpha: boolean;
  40415. private _useReflectionOverAlpha;
  40416. /**
  40417. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40418. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40419. */
  40420. useReflectionOverAlpha: boolean;
  40421. private _disableLighting;
  40422. /**
  40423. * Does lights from the scene impacts this material.
  40424. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40425. */
  40426. disableLighting: boolean;
  40427. private _useObjectSpaceNormalMap;
  40428. /**
  40429. * Allows using an object space normal map (instead of tangent space).
  40430. */
  40431. useObjectSpaceNormalMap: boolean;
  40432. private _useParallax;
  40433. /**
  40434. * Is parallax enabled or not.
  40435. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40436. */
  40437. useParallax: boolean;
  40438. private _useParallaxOcclusion;
  40439. /**
  40440. * Is parallax occlusion enabled or not.
  40441. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40442. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40443. */
  40444. useParallaxOcclusion: boolean;
  40445. /**
  40446. * 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.
  40447. */
  40448. parallaxScaleBias: number;
  40449. private _roughness;
  40450. /**
  40451. * Helps to define how blurry the reflections should appears in the material.
  40452. */
  40453. roughness: number;
  40454. /**
  40455. * In case of refraction, define the value of the index of refraction.
  40456. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40457. */
  40458. indexOfRefraction: number;
  40459. /**
  40460. * Invert the refraction texture alongside the y axis.
  40461. * It can be useful with procedural textures or probe for instance.
  40462. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40463. */
  40464. invertRefractionY: boolean;
  40465. /**
  40466. * Defines the alpha limits in alpha test mode.
  40467. */
  40468. alphaCutOff: number;
  40469. private _useLightmapAsShadowmap;
  40470. /**
  40471. * In case of light mapping, define whether the map contains light or shadow informations.
  40472. */
  40473. useLightmapAsShadowmap: boolean;
  40474. private _diffuseFresnelParameters;
  40475. /**
  40476. * Define the diffuse fresnel parameters of the material.
  40477. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40478. */
  40479. diffuseFresnelParameters: FresnelParameters;
  40480. private _opacityFresnelParameters;
  40481. /**
  40482. * Define the opacity fresnel parameters of the material.
  40483. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40484. */
  40485. opacityFresnelParameters: FresnelParameters;
  40486. private _reflectionFresnelParameters;
  40487. /**
  40488. * Define the reflection fresnel parameters of the material.
  40489. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40490. */
  40491. reflectionFresnelParameters: FresnelParameters;
  40492. private _refractionFresnelParameters;
  40493. /**
  40494. * Define the refraction fresnel parameters of the material.
  40495. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40496. */
  40497. refractionFresnelParameters: FresnelParameters;
  40498. private _emissiveFresnelParameters;
  40499. /**
  40500. * Define the emissive fresnel parameters of the material.
  40501. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40502. */
  40503. emissiveFresnelParameters: FresnelParameters;
  40504. private _useReflectionFresnelFromSpecular;
  40505. /**
  40506. * If true automatically deducts the fresnels values from the material specularity.
  40507. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40508. */
  40509. useReflectionFresnelFromSpecular: boolean;
  40510. private _useGlossinessFromSpecularMapAlpha;
  40511. /**
  40512. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40513. */
  40514. useGlossinessFromSpecularMapAlpha: boolean;
  40515. private _maxSimultaneousLights;
  40516. /**
  40517. * Defines the maximum number of lights that can be used in the material
  40518. */
  40519. maxSimultaneousLights: number;
  40520. private _invertNormalMapX;
  40521. /**
  40522. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40523. */
  40524. invertNormalMapX: boolean;
  40525. private _invertNormalMapY;
  40526. /**
  40527. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40528. */
  40529. invertNormalMapY: boolean;
  40530. private _twoSidedLighting;
  40531. /**
  40532. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40533. */
  40534. twoSidedLighting: boolean;
  40535. /**
  40536. * Default configuration related to image processing available in the standard Material.
  40537. */
  40538. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40539. /**
  40540. * Gets the image processing configuration used either in this material.
  40541. */
  40542. /**
  40543. * Sets the Default image processing configuration used either in the this material.
  40544. *
  40545. * If sets to null, the scene one is in use.
  40546. */
  40547. imageProcessingConfiguration: ImageProcessingConfiguration;
  40548. /**
  40549. * Keep track of the image processing observer to allow dispose and replace.
  40550. */
  40551. private _imageProcessingObserver;
  40552. /**
  40553. * Attaches a new image processing configuration to the Standard Material.
  40554. * @param configuration
  40555. */
  40556. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40557. /**
  40558. * Gets wether the color curves effect is enabled.
  40559. */
  40560. /**
  40561. * Sets wether the color curves effect is enabled.
  40562. */
  40563. cameraColorCurvesEnabled: boolean;
  40564. /**
  40565. * Gets wether the color grading effect is enabled.
  40566. */
  40567. /**
  40568. * Gets wether the color grading effect is enabled.
  40569. */
  40570. cameraColorGradingEnabled: boolean;
  40571. /**
  40572. * Gets wether tonemapping is enabled or not.
  40573. */
  40574. /**
  40575. * Sets wether tonemapping is enabled or not
  40576. */
  40577. cameraToneMappingEnabled: boolean;
  40578. /**
  40579. * The camera exposure used on this material.
  40580. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40581. * This corresponds to a photographic exposure.
  40582. */
  40583. /**
  40584. * The camera exposure used on this material.
  40585. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40586. * This corresponds to a photographic exposure.
  40587. */
  40588. cameraExposure: number;
  40589. /**
  40590. * Gets The camera contrast used on this material.
  40591. */
  40592. /**
  40593. * Sets The camera contrast used on this material.
  40594. */
  40595. cameraContrast: number;
  40596. /**
  40597. * Gets the Color Grading 2D Lookup Texture.
  40598. */
  40599. /**
  40600. * Sets the Color Grading 2D Lookup Texture.
  40601. */
  40602. cameraColorGradingTexture: Nullable<BaseTexture>;
  40603. /**
  40604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40606. * 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;
  40607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40608. */
  40609. /**
  40610. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40611. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40612. * 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;
  40613. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40614. */
  40615. cameraColorCurves: Nullable<ColorCurves>;
  40616. /**
  40617. * Custom callback helping to override the default shader used in the material.
  40618. */
  40619. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40620. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40621. protected _worldViewProjectionMatrix: Matrix;
  40622. protected _globalAmbientColor: Color3;
  40623. protected _useLogarithmicDepth: boolean;
  40624. protected _rebuildInParallel: boolean;
  40625. /**
  40626. * Instantiates a new standard material.
  40627. * This is the default material used in Babylon. It is the best trade off between quality
  40628. * and performances.
  40629. * @see http://doc.babylonjs.com/babylon101/materials
  40630. * @param name Define the name of the material in the scene
  40631. * @param scene Define the scene the material belong to
  40632. */
  40633. constructor(name: string, scene: Scene);
  40634. /**
  40635. * Gets a boolean indicating that current material needs to register RTT
  40636. */
  40637. readonly hasRenderTargetTextures: boolean;
  40638. /**
  40639. * Gets the current class name of the material e.g. "StandardMaterial"
  40640. * Mainly use in serialization.
  40641. * @returns the class name
  40642. */
  40643. getClassName(): string;
  40644. /**
  40645. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40646. * You can try switching to logarithmic depth.
  40647. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40648. */
  40649. useLogarithmicDepth: boolean;
  40650. /**
  40651. * Specifies if the material will require alpha blending
  40652. * @returns a boolean specifying if alpha blending is needed
  40653. */
  40654. needAlphaBlending(): boolean;
  40655. /**
  40656. * Specifies if this material should be rendered in alpha test mode
  40657. * @returns a boolean specifying if an alpha test is needed.
  40658. */
  40659. needAlphaTesting(): boolean;
  40660. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40661. /**
  40662. * Get the texture used for alpha test purpose.
  40663. * @returns the diffuse texture in case of the standard material.
  40664. */
  40665. getAlphaTestTexture(): Nullable<BaseTexture>;
  40666. /**
  40667. * Get if the submesh is ready to be used and all its information available.
  40668. * Child classes can use it to update shaders
  40669. * @param mesh defines the mesh to check
  40670. * @param subMesh defines which submesh to check
  40671. * @param useInstances specifies that instances should be used
  40672. * @returns a boolean indicating that the submesh is ready or not
  40673. */
  40674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40675. /**
  40676. * Builds the material UBO layouts.
  40677. * Used internally during the effect preparation.
  40678. */
  40679. buildUniformLayout(): void;
  40680. /**
  40681. * Unbinds the material from the mesh
  40682. */
  40683. unbind(): void;
  40684. /**
  40685. * Binds the submesh to this material by preparing the effect and shader to draw
  40686. * @param world defines the world transformation matrix
  40687. * @param mesh defines the mesh containing the submesh
  40688. * @param subMesh defines the submesh to bind the material to
  40689. */
  40690. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40691. /**
  40692. * Get the list of animatables in the material.
  40693. * @returns the list of animatables object used in the material
  40694. */
  40695. getAnimatables(): IAnimatable[];
  40696. /**
  40697. * Gets the active textures from the material
  40698. * @returns an array of textures
  40699. */
  40700. getActiveTextures(): BaseTexture[];
  40701. /**
  40702. * Specifies if the material uses a texture
  40703. * @param texture defines the texture to check against the material
  40704. * @returns a boolean specifying if the material uses the texture
  40705. */
  40706. hasTexture(texture: BaseTexture): boolean;
  40707. /**
  40708. * Disposes the material
  40709. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40710. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40711. */
  40712. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40713. /**
  40714. * Makes a duplicate of the material, and gives it a new name
  40715. * @param name defines the new name for the duplicated material
  40716. * @returns the cloned material
  40717. */
  40718. clone(name: string): StandardMaterial;
  40719. /**
  40720. * Serializes this material in a JSON representation
  40721. * @returns the serialized material object
  40722. */
  40723. serialize(): any;
  40724. /**
  40725. * Creates a standard material from parsed material data
  40726. * @param source defines the JSON representation of the material
  40727. * @param scene defines the hosting scene
  40728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40729. * @returns a new standard material
  40730. */
  40731. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40732. /**
  40733. * Are diffuse textures enabled in the application.
  40734. */
  40735. static DiffuseTextureEnabled: boolean;
  40736. /**
  40737. * Are ambient textures enabled in the application.
  40738. */
  40739. static AmbientTextureEnabled: boolean;
  40740. /**
  40741. * Are opacity textures enabled in the application.
  40742. */
  40743. static OpacityTextureEnabled: boolean;
  40744. /**
  40745. * Are reflection textures enabled in the application.
  40746. */
  40747. static ReflectionTextureEnabled: boolean;
  40748. /**
  40749. * Are emissive textures enabled in the application.
  40750. */
  40751. static EmissiveTextureEnabled: boolean;
  40752. /**
  40753. * Are specular textures enabled in the application.
  40754. */
  40755. static SpecularTextureEnabled: boolean;
  40756. /**
  40757. * Are bump textures enabled in the application.
  40758. */
  40759. static BumpTextureEnabled: boolean;
  40760. /**
  40761. * Are lightmap textures enabled in the application.
  40762. */
  40763. static LightmapTextureEnabled: boolean;
  40764. /**
  40765. * Are refraction textures enabled in the application.
  40766. */
  40767. static RefractionTextureEnabled: boolean;
  40768. /**
  40769. * Are color grading textures enabled in the application.
  40770. */
  40771. static ColorGradingTextureEnabled: boolean;
  40772. /**
  40773. * Are fresnels enabled in the application.
  40774. */
  40775. static FresnelEnabled: boolean;
  40776. }
  40777. }
  40778. declare module BABYLON {
  40779. /** @hidden */
  40780. export var imageProcessingPixelShader: {
  40781. name: string;
  40782. shader: string;
  40783. };
  40784. }
  40785. declare module BABYLON {
  40786. /**
  40787. * ImageProcessingPostProcess
  40788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40789. */
  40790. export class ImageProcessingPostProcess extends PostProcess {
  40791. /**
  40792. * Default configuration related to image processing available in the PBR Material.
  40793. */
  40794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40795. /**
  40796. * Gets the image processing configuration used either in this material.
  40797. */
  40798. /**
  40799. * Sets the Default image processing configuration used either in the this material.
  40800. *
  40801. * If sets to null, the scene one is in use.
  40802. */
  40803. imageProcessingConfiguration: ImageProcessingConfiguration;
  40804. /**
  40805. * Keep track of the image processing observer to allow dispose and replace.
  40806. */
  40807. private _imageProcessingObserver;
  40808. /**
  40809. * Attaches a new image processing configuration to the PBR Material.
  40810. * @param configuration
  40811. */
  40812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40813. /**
  40814. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40815. */
  40816. /**
  40817. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40818. */
  40819. colorCurves: Nullable<ColorCurves>;
  40820. /**
  40821. * Gets wether the color curves effect is enabled.
  40822. */
  40823. /**
  40824. * Sets wether the color curves effect is enabled.
  40825. */
  40826. colorCurvesEnabled: boolean;
  40827. /**
  40828. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40829. */
  40830. /**
  40831. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40832. */
  40833. colorGradingTexture: Nullable<BaseTexture>;
  40834. /**
  40835. * Gets wether the color grading effect is enabled.
  40836. */
  40837. /**
  40838. * Gets wether the color grading effect is enabled.
  40839. */
  40840. colorGradingEnabled: boolean;
  40841. /**
  40842. * Gets exposure used in the effect.
  40843. */
  40844. /**
  40845. * Sets exposure used in the effect.
  40846. */
  40847. exposure: number;
  40848. /**
  40849. * Gets wether tonemapping is enabled or not.
  40850. */
  40851. /**
  40852. * Sets wether tonemapping is enabled or not
  40853. */
  40854. toneMappingEnabled: boolean;
  40855. /**
  40856. * Gets the type of tone mapping effect.
  40857. */
  40858. /**
  40859. * Sets the type of tone mapping effect.
  40860. */
  40861. toneMappingType: number;
  40862. /**
  40863. * Gets contrast used in the effect.
  40864. */
  40865. /**
  40866. * Sets contrast used in the effect.
  40867. */
  40868. contrast: number;
  40869. /**
  40870. * Gets Vignette stretch size.
  40871. */
  40872. /**
  40873. * Sets Vignette stretch size.
  40874. */
  40875. vignetteStretch: number;
  40876. /**
  40877. * Gets Vignette centre X Offset.
  40878. */
  40879. /**
  40880. * Sets Vignette centre X Offset.
  40881. */
  40882. vignetteCentreX: number;
  40883. /**
  40884. * Gets Vignette centre Y Offset.
  40885. */
  40886. /**
  40887. * Sets Vignette centre Y Offset.
  40888. */
  40889. vignetteCentreY: number;
  40890. /**
  40891. * Gets Vignette weight or intensity of the vignette effect.
  40892. */
  40893. /**
  40894. * Sets Vignette weight or intensity of the vignette effect.
  40895. */
  40896. vignetteWeight: number;
  40897. /**
  40898. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40899. * if vignetteEnabled is set to true.
  40900. */
  40901. /**
  40902. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40903. * if vignetteEnabled is set to true.
  40904. */
  40905. vignetteColor: Color4;
  40906. /**
  40907. * Gets Camera field of view used by the Vignette effect.
  40908. */
  40909. /**
  40910. * Sets Camera field of view used by the Vignette effect.
  40911. */
  40912. vignetteCameraFov: number;
  40913. /**
  40914. * Gets the vignette blend mode allowing different kind of effect.
  40915. */
  40916. /**
  40917. * Sets the vignette blend mode allowing different kind of effect.
  40918. */
  40919. vignetteBlendMode: number;
  40920. /**
  40921. * Gets wether the vignette effect is enabled.
  40922. */
  40923. /**
  40924. * Sets wether the vignette effect is enabled.
  40925. */
  40926. vignetteEnabled: boolean;
  40927. private _fromLinearSpace;
  40928. /**
  40929. * Gets wether the input of the processing is in Gamma or Linear Space.
  40930. */
  40931. /**
  40932. * Sets wether the input of the processing is in Gamma or Linear Space.
  40933. */
  40934. fromLinearSpace: boolean;
  40935. /**
  40936. * Defines cache preventing GC.
  40937. */
  40938. private _defines;
  40939. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40940. /**
  40941. * "ImageProcessingPostProcess"
  40942. * @returns "ImageProcessingPostProcess"
  40943. */
  40944. getClassName(): string;
  40945. protected _updateParameters(): void;
  40946. dispose(camera?: Camera): void;
  40947. }
  40948. }
  40949. declare module BABYLON {
  40950. /**
  40951. * Class containing static functions to help procedurally build meshes
  40952. */
  40953. export class GroundBuilder {
  40954. /**
  40955. * Creates a ground mesh
  40956. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40957. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40959. * @param name defines the name of the mesh
  40960. * @param options defines the options used to create the mesh
  40961. * @param scene defines the hosting scene
  40962. * @returns the ground mesh
  40963. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40964. */
  40965. static CreateGround(name: string, options: {
  40966. width?: number;
  40967. height?: number;
  40968. subdivisions?: number;
  40969. subdivisionsX?: number;
  40970. subdivisionsY?: number;
  40971. updatable?: boolean;
  40972. }, scene: any): Mesh;
  40973. /**
  40974. * Creates a tiled ground mesh
  40975. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40976. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40977. * * 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
  40978. * * 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
  40979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40980. * @param name defines the name of the mesh
  40981. * @param options defines the options used to create the mesh
  40982. * @param scene defines the hosting scene
  40983. * @returns the tiled ground mesh
  40984. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40985. */
  40986. static CreateTiledGround(name: string, options: {
  40987. xmin: number;
  40988. zmin: number;
  40989. xmax: number;
  40990. zmax: number;
  40991. subdivisions?: {
  40992. w: number;
  40993. h: number;
  40994. };
  40995. precision?: {
  40996. w: number;
  40997. h: number;
  40998. };
  40999. updatable?: boolean;
  41000. }, scene?: Nullable<Scene>): Mesh;
  41001. /**
  41002. * Creates a ground mesh from a height map
  41003. * * The parameter `url` sets the URL of the height map image resource.
  41004. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41005. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41006. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41007. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41008. * * 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.
  41009. * * 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).
  41010. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41012. * @param name defines the name of the mesh
  41013. * @param url defines the url to the height map
  41014. * @param options defines the options used to create the mesh
  41015. * @param scene defines the hosting scene
  41016. * @returns the ground mesh
  41017. * @see https://doc.babylonjs.com/babylon101/height_map
  41018. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41019. */
  41020. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41021. width?: number;
  41022. height?: number;
  41023. subdivisions?: number;
  41024. minHeight?: number;
  41025. maxHeight?: number;
  41026. colorFilter?: Color3;
  41027. alphaFilter?: number;
  41028. updatable?: boolean;
  41029. onReady?: (mesh: GroundMesh) => void;
  41030. }, scene?: Nullable<Scene>): GroundMesh;
  41031. }
  41032. }
  41033. declare module BABYLON {
  41034. /**
  41035. * Class containing static functions to help procedurally build meshes
  41036. */
  41037. export class TorusBuilder {
  41038. /**
  41039. * Creates a torus mesh
  41040. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41041. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41042. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41044. * * 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
  41045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41046. * @param name defines the name of the mesh
  41047. * @param options defines the options used to create the mesh
  41048. * @param scene defines the hosting scene
  41049. * @returns the torus mesh
  41050. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41051. */
  41052. static CreateTorus(name: string, options: {
  41053. diameter?: number;
  41054. thickness?: number;
  41055. tessellation?: number;
  41056. updatable?: boolean;
  41057. sideOrientation?: number;
  41058. frontUVs?: Vector4;
  41059. backUVs?: Vector4;
  41060. }, scene: any): Mesh;
  41061. }
  41062. }
  41063. declare module BABYLON {
  41064. /**
  41065. * Class containing static functions to help procedurally build meshes
  41066. */
  41067. export class CylinderBuilder {
  41068. /**
  41069. * Creates a cylinder or a cone mesh
  41070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41072. * * 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.
  41073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41077. * * 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).
  41078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41079. * * 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).
  41080. * * 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
  41081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41082. * * 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
  41083. * * 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.
  41084. * * If `enclose` is false, a ring surface is one element.
  41085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41086. * * 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
  41087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41088. * * 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
  41089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41090. * @param name defines the name of the mesh
  41091. * @param options defines the options used to create the mesh
  41092. * @param scene defines the hosting scene
  41093. * @returns the cylinder mesh
  41094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41095. */
  41096. static CreateCylinder(name: string, options: {
  41097. height?: number;
  41098. diameterTop?: number;
  41099. diameterBottom?: number;
  41100. diameter?: number;
  41101. tessellation?: number;
  41102. subdivisions?: number;
  41103. arc?: number;
  41104. faceColors?: Color4[];
  41105. faceUV?: Vector4[];
  41106. updatable?: boolean;
  41107. hasRings?: boolean;
  41108. enclose?: boolean;
  41109. cap?: number;
  41110. sideOrientation?: number;
  41111. frontUVs?: Vector4;
  41112. backUVs?: Vector4;
  41113. }, scene: any): Mesh;
  41114. }
  41115. }
  41116. declare module BABYLON {
  41117. /**
  41118. * Options to modify the vr teleportation behavior.
  41119. */
  41120. export interface VRTeleportationOptions {
  41121. /**
  41122. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41123. */
  41124. floorMeshName?: string;
  41125. /**
  41126. * A list of meshes to be used as the teleportation floor. (default: empty)
  41127. */
  41128. floorMeshes?: Mesh[];
  41129. }
  41130. /**
  41131. * Options to modify the vr experience helper's behavior.
  41132. */
  41133. export interface VRExperienceHelperOptions extends WebVROptions {
  41134. /**
  41135. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41136. */
  41137. createDeviceOrientationCamera?: boolean;
  41138. /**
  41139. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41140. */
  41141. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41142. /**
  41143. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41144. */
  41145. laserToggle?: boolean;
  41146. /**
  41147. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41148. */
  41149. floorMeshes?: Mesh[];
  41150. /**
  41151. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41152. */
  41153. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41154. }
  41155. /**
  41156. * Event containing information after VR has been entered
  41157. */
  41158. export class OnAfterEnteringVRObservableEvent {
  41159. /**
  41160. * If entering vr was successful
  41161. */
  41162. success: boolean;
  41163. }
  41164. /**
  41165. * Helps to quickly add VR support to an existing scene.
  41166. * See http://doc.babylonjs.com/how_to/webvr_helper
  41167. */
  41168. export class VRExperienceHelper {
  41169. /** Options to modify the vr experience helper's behavior. */
  41170. webVROptions: VRExperienceHelperOptions;
  41171. private _scene;
  41172. private _position;
  41173. private _btnVR;
  41174. private _btnVRDisplayed;
  41175. private _webVRsupported;
  41176. private _webVRready;
  41177. private _webVRrequesting;
  41178. private _webVRpresenting;
  41179. private _hasEnteredVR;
  41180. private _fullscreenVRpresenting;
  41181. private _canvas;
  41182. private _webVRCamera;
  41183. private _vrDeviceOrientationCamera;
  41184. private _deviceOrientationCamera;
  41185. private _existingCamera;
  41186. private _onKeyDown;
  41187. private _onVrDisplayPresentChange;
  41188. private _onVRDisplayChanged;
  41189. private _onVRRequestPresentStart;
  41190. private _onVRRequestPresentComplete;
  41191. /**
  41192. * 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)
  41193. */
  41194. enableGazeEvenWhenNoPointerLock: boolean;
  41195. /**
  41196. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41197. */
  41198. exitVROnDoubleTap: boolean;
  41199. /**
  41200. * Observable raised right before entering VR.
  41201. */
  41202. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41203. /**
  41204. * Observable raised when entering VR has completed.
  41205. */
  41206. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41207. /**
  41208. * Observable raised when exiting VR.
  41209. */
  41210. onExitingVRObservable: Observable<VRExperienceHelper>;
  41211. /**
  41212. * Observable raised when controller mesh is loaded.
  41213. */
  41214. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41215. /** Return this.onEnteringVRObservable
  41216. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41217. */
  41218. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41219. /** Return this.onExitingVRObservable
  41220. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41221. */
  41222. readonly onExitingVR: Observable<VRExperienceHelper>;
  41223. /** Return this.onControllerMeshLoadedObservable
  41224. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41225. */
  41226. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41227. private _rayLength;
  41228. private _useCustomVRButton;
  41229. private _teleportationRequested;
  41230. private _teleportActive;
  41231. private _floorMeshName;
  41232. private _floorMeshesCollection;
  41233. private _rotationAllowed;
  41234. private _teleportBackwardsVector;
  41235. private _teleportationTarget;
  41236. private _isDefaultTeleportationTarget;
  41237. private _postProcessMove;
  41238. private _teleportationFillColor;
  41239. private _teleportationBorderColor;
  41240. private _rotationAngle;
  41241. private _haloCenter;
  41242. private _cameraGazer;
  41243. private _padSensibilityUp;
  41244. private _padSensibilityDown;
  41245. private _leftController;
  41246. private _rightController;
  41247. /**
  41248. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41249. */
  41250. onNewMeshSelected: Observable<AbstractMesh>;
  41251. /**
  41252. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41253. * This observable will provide the mesh and the controller used to select the mesh
  41254. */
  41255. onMeshSelectedWithController: Observable<{
  41256. mesh: AbstractMesh;
  41257. controller: WebVRController;
  41258. }>;
  41259. /**
  41260. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41261. */
  41262. onNewMeshPicked: Observable<PickingInfo>;
  41263. private _circleEase;
  41264. /**
  41265. * Observable raised before camera teleportation
  41266. */
  41267. onBeforeCameraTeleport: Observable<Vector3>;
  41268. /**
  41269. * Observable raised after camera teleportation
  41270. */
  41271. onAfterCameraTeleport: Observable<Vector3>;
  41272. /**
  41273. * Observable raised when current selected mesh gets unselected
  41274. */
  41275. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41276. private _raySelectionPredicate;
  41277. /**
  41278. * To be optionaly changed by user to define custom ray selection
  41279. */
  41280. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41281. /**
  41282. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41283. */
  41284. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41285. /**
  41286. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41287. */
  41288. teleportationEnabled: boolean;
  41289. private _defaultHeight;
  41290. private _teleportationInitialized;
  41291. private _interactionsEnabled;
  41292. private _interactionsRequested;
  41293. private _displayGaze;
  41294. private _displayLaserPointer;
  41295. /**
  41296. * The mesh used to display where the user is going to teleport.
  41297. */
  41298. /**
  41299. * Sets the mesh to be used to display where the user is going to teleport.
  41300. */
  41301. teleportationTarget: Mesh;
  41302. /**
  41303. * 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
  41304. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41305. * See http://doc.babylonjs.com/resources/baking_transformations
  41306. */
  41307. gazeTrackerMesh: Mesh;
  41308. /**
  41309. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41310. */
  41311. updateGazeTrackerScale: boolean;
  41312. /**
  41313. * If the gaze trackers color should be updated when selecting meshes
  41314. */
  41315. updateGazeTrackerColor: boolean;
  41316. /**
  41317. * If the controller laser color should be updated when selecting meshes
  41318. */
  41319. updateControllerLaserColor: boolean;
  41320. /**
  41321. * The gaze tracking mesh corresponding to the left controller
  41322. */
  41323. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41324. /**
  41325. * The gaze tracking mesh corresponding to the right controller
  41326. */
  41327. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41328. /**
  41329. * If the ray of the gaze should be displayed.
  41330. */
  41331. /**
  41332. * Sets if the ray of the gaze should be displayed.
  41333. */
  41334. displayGaze: boolean;
  41335. /**
  41336. * If the ray of the LaserPointer should be displayed.
  41337. */
  41338. /**
  41339. * Sets if the ray of the LaserPointer should be displayed.
  41340. */
  41341. displayLaserPointer: boolean;
  41342. /**
  41343. * The deviceOrientationCamera used as the camera when not in VR.
  41344. */
  41345. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41346. /**
  41347. * Based on the current WebVR support, returns the current VR camera used.
  41348. */
  41349. readonly currentVRCamera: Nullable<Camera>;
  41350. /**
  41351. * The webVRCamera which is used when in VR.
  41352. */
  41353. readonly webVRCamera: WebVRFreeCamera;
  41354. /**
  41355. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41356. */
  41357. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41358. /**
  41359. * The html button that is used to trigger entering into VR.
  41360. */
  41361. readonly vrButton: Nullable<HTMLButtonElement>;
  41362. private readonly _teleportationRequestInitiated;
  41363. /**
  41364. * Defines wether or not Pointer lock should be requested when switching to
  41365. * full screen.
  41366. */
  41367. requestPointerLockOnFullScreen: boolean;
  41368. /**
  41369. * Instantiates a VRExperienceHelper.
  41370. * Helps to quickly add VR support to an existing scene.
  41371. * @param scene The scene the VRExperienceHelper belongs to.
  41372. * @param webVROptions Options to modify the vr experience helper's behavior.
  41373. */
  41374. constructor(scene: Scene,
  41375. /** Options to modify the vr experience helper's behavior. */
  41376. webVROptions?: VRExperienceHelperOptions);
  41377. private _onDefaultMeshLoaded;
  41378. private _onResize;
  41379. private _onFullscreenChange;
  41380. /**
  41381. * Gets a value indicating if we are currently in VR mode.
  41382. */
  41383. readonly isInVRMode: boolean;
  41384. private onVrDisplayPresentChange;
  41385. private onVRDisplayChanged;
  41386. private moveButtonToBottomRight;
  41387. private displayVRButton;
  41388. private updateButtonVisibility;
  41389. private _cachedAngularSensibility;
  41390. /**
  41391. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41392. * Otherwise, will use the fullscreen API.
  41393. */
  41394. enterVR(): void;
  41395. /**
  41396. * Attempt to exit VR, or fullscreen.
  41397. */
  41398. exitVR(): void;
  41399. /**
  41400. * The position of the vr experience helper.
  41401. */
  41402. /**
  41403. * Sets the position of the vr experience helper.
  41404. */
  41405. position: Vector3;
  41406. /**
  41407. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41408. */
  41409. enableInteractions(): void;
  41410. private readonly _noControllerIsActive;
  41411. private beforeRender;
  41412. private _isTeleportationFloor;
  41413. /**
  41414. * Adds a floor mesh to be used for teleportation.
  41415. * @param floorMesh the mesh to be used for teleportation.
  41416. */
  41417. addFloorMesh(floorMesh: Mesh): void;
  41418. /**
  41419. * Removes a floor mesh from being used for teleportation.
  41420. * @param floorMesh the mesh to be removed.
  41421. */
  41422. removeFloorMesh(floorMesh: Mesh): void;
  41423. /**
  41424. * Enables interactions and teleportation using the VR controllers and gaze.
  41425. * @param vrTeleportationOptions options to modify teleportation behavior.
  41426. */
  41427. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41428. private _onNewGamepadConnected;
  41429. private _tryEnableInteractionOnController;
  41430. private _onNewGamepadDisconnected;
  41431. private _enableInteractionOnController;
  41432. private _checkTeleportWithRay;
  41433. private _checkRotate;
  41434. private _checkTeleportBackwards;
  41435. private _enableTeleportationOnController;
  41436. private _createTeleportationCircles;
  41437. private _displayTeleportationTarget;
  41438. private _hideTeleportationTarget;
  41439. private _rotateCamera;
  41440. private _moveTeleportationSelectorTo;
  41441. private _workingVector;
  41442. private _workingQuaternion;
  41443. private _workingMatrix;
  41444. /**
  41445. * Teleports the users feet to the desired location
  41446. * @param location The location where the user's feet should be placed
  41447. */
  41448. teleportCamera(location: Vector3): void;
  41449. private _convertNormalToDirectionOfRay;
  41450. private _castRayAndSelectObject;
  41451. private _notifySelectedMeshUnselected;
  41452. /**
  41453. * Sets the color of the laser ray from the vr controllers.
  41454. * @param color new color for the ray.
  41455. */
  41456. changeLaserColor(color: Color3): void;
  41457. /**
  41458. * Sets the color of the ray from the vr headsets gaze.
  41459. * @param color new color for the ray.
  41460. */
  41461. changeGazeColor(color: Color3): void;
  41462. /**
  41463. * Exits VR and disposes of the vr experience helper
  41464. */
  41465. dispose(): void;
  41466. /**
  41467. * Gets the name of the VRExperienceHelper class
  41468. * @returns "VRExperienceHelper"
  41469. */
  41470. getClassName(): string;
  41471. }
  41472. }
  41473. declare module BABYLON {
  41474. /**
  41475. * Manages an XRSession to work with Babylon's engine
  41476. * @see https://doc.babylonjs.com/how_to/webxr
  41477. */
  41478. export class WebXRSessionManager implements IDisposable {
  41479. private scene;
  41480. /**
  41481. * Fires every time a new xrFrame arrives which can be used to update the camera
  41482. */
  41483. onXRFrameObservable: Observable<any>;
  41484. /**
  41485. * Fires when the xr session is ended either by the device or manually done
  41486. */
  41487. onXRSessionEnded: Observable<any>;
  41488. /**
  41489. * Underlying xr session
  41490. */
  41491. session: XRSession;
  41492. /**
  41493. * Type of reference space used when creating the session
  41494. */
  41495. referenceSpace: XRReferenceSpace;
  41496. /** @hidden */
  41497. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41498. /**
  41499. * Current XR frame
  41500. */
  41501. currentFrame: Nullable<XRFrame>;
  41502. private _xrNavigator;
  41503. private baseLayer;
  41504. private _sessionEnded;
  41505. /**
  41506. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41507. * @param scene The scene which the session should be created for
  41508. */
  41509. constructor(scene: Scene);
  41510. /**
  41511. * Initializes the manager
  41512. * After initialization enterXR can be called to start an XR session
  41513. * @returns Promise which resolves after it is initialized
  41514. */
  41515. initializeAsync(): Promise<void>;
  41516. /**
  41517. * Initializes an xr session
  41518. * @param xrSessionMode mode to initialize
  41519. * @returns a promise which will resolve once the session has been initialized
  41520. */
  41521. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41522. /**
  41523. * Sets the reference space on the xr session
  41524. * @param referenceSpace space to set
  41525. * @returns a promise that will resolve once the reference space has been set
  41526. */
  41527. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41528. /**
  41529. * Updates the render state of the session
  41530. * @param state state to set
  41531. * @returns a promise that resolves once the render state has been updated
  41532. */
  41533. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41534. /**
  41535. * Starts rendering to the xr layer
  41536. * @returns a promise that will resolve once rendering has started
  41537. */
  41538. startRenderingToXRAsync(): Promise<void>;
  41539. /**
  41540. * Stops the xrSession and restores the renderloop
  41541. * @returns Promise which resolves after it exits XR
  41542. */
  41543. exitXRAsync(): Promise<unknown>;
  41544. /**
  41545. * Checks if a session would be supported for the creation options specified
  41546. * @param sessionMode session mode to check if supported eg. immersive-vr
  41547. * @returns true if supported
  41548. */
  41549. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41550. /**
  41551. * @hidden
  41552. * Converts the render layer of xrSession to a render target
  41553. * @param session session to create render target for
  41554. * @param scene scene the new render target should be created for
  41555. */
  41556. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41557. /**
  41558. * Disposes of the session manager
  41559. */
  41560. dispose(): void;
  41561. }
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * WebXR Camera which holds the views for the xrSession
  41566. * @see https://doc.babylonjs.com/how_to/webxr
  41567. */
  41568. export class WebXRCamera extends FreeCamera {
  41569. private static _TmpMatrix;
  41570. /**
  41571. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41572. * @param name the name of the camera
  41573. * @param scene the scene to add the camera to
  41574. */
  41575. constructor(name: string, scene: Scene);
  41576. private _updateNumberOfRigCameras;
  41577. /** @hidden */
  41578. _updateForDualEyeDebugging(): void;
  41579. /**
  41580. * Updates the cameras position from the current pose information of the XR session
  41581. * @param xrSessionManager the session containing pose information
  41582. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41583. */
  41584. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41585. }
  41586. }
  41587. declare module BABYLON {
  41588. /**
  41589. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41590. */
  41591. export class WebXRManagedOutputCanvas implements IDisposable {
  41592. private helper;
  41593. private _canvas;
  41594. /**
  41595. * xrpresent context of the canvas which can be used to display/mirror xr content
  41596. */
  41597. canvasContext: WebGLRenderingContext;
  41598. /**
  41599. * xr layer for the canvas
  41600. */
  41601. xrLayer: Nullable<XRWebGLLayer>;
  41602. /**
  41603. * Initializes the xr layer for the session
  41604. * @param xrSession xr session
  41605. * @returns a promise that will resolve once the XR Layer has been created
  41606. */
  41607. initializeXRLayerAsync(xrSession: any): any;
  41608. /**
  41609. * Initializes the canvas to be added/removed upon entering/exiting xr
  41610. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41611. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41612. */
  41613. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41614. /**
  41615. * Disposes of the object
  41616. */
  41617. dispose(): void;
  41618. private _setManagedOutputCanvas;
  41619. private _addCanvas;
  41620. private _removeCanvas;
  41621. }
  41622. }
  41623. declare module BABYLON {
  41624. /**
  41625. * States of the webXR experience
  41626. */
  41627. export enum WebXRState {
  41628. /**
  41629. * Transitioning to being in XR mode
  41630. */
  41631. ENTERING_XR = 0,
  41632. /**
  41633. * Transitioning to non XR mode
  41634. */
  41635. EXITING_XR = 1,
  41636. /**
  41637. * In XR mode and presenting
  41638. */
  41639. IN_XR = 2,
  41640. /**
  41641. * Not entered XR mode
  41642. */
  41643. NOT_IN_XR = 3
  41644. }
  41645. /**
  41646. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41647. * @see https://doc.babylonjs.com/how_to/webxr
  41648. */
  41649. export class WebXRExperienceHelper implements IDisposable {
  41650. private scene;
  41651. /**
  41652. * 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
  41653. */
  41654. container: AbstractMesh;
  41655. /**
  41656. * Camera used to render xr content
  41657. */
  41658. camera: WebXRCamera;
  41659. /**
  41660. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41661. */
  41662. state: WebXRState;
  41663. private _setState;
  41664. private static _TmpVector;
  41665. /**
  41666. * Fires when the state of the experience helper has changed
  41667. */
  41668. onStateChangedObservable: Observable<WebXRState>;
  41669. /** Session manager used to keep track of xr session */
  41670. sessionManager: WebXRSessionManager;
  41671. private _nonVRCamera;
  41672. private _originalSceneAutoClear;
  41673. private _supported;
  41674. /**
  41675. * Creates the experience helper
  41676. * @param scene the scene to attach the experience helper to
  41677. * @returns a promise for the experience helper
  41678. */
  41679. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41680. /**
  41681. * Creates a WebXRExperienceHelper
  41682. * @param scene The scene the helper should be created in
  41683. */
  41684. private constructor();
  41685. /**
  41686. * Exits XR mode and returns the scene to its original state
  41687. * @returns promise that resolves after xr mode has exited
  41688. */
  41689. exitXRAsync(): Promise<unknown>;
  41690. /**
  41691. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41692. * @param sessionCreationOptions options for the XR session
  41693. * @param referenceSpaceType frame of reference of the XR session
  41694. * @param outputCanvas the output canvas that will be used to enter XR mode
  41695. * @returns promise that resolves after xr mode has entered
  41696. */
  41697. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41698. /**
  41699. * Updates the global position of the camera by moving the camera's container
  41700. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41701. * @param position The desired global position of the camera
  41702. */
  41703. setPositionOfCameraUsingContainer(position: Vector3): void;
  41704. /**
  41705. * Rotates the xr camera by rotating the camera's container around the camera's position
  41706. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41707. * @param rotation the desired quaternion rotation to apply to the camera
  41708. */
  41709. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41710. /**
  41711. * Disposes of the experience helper
  41712. */
  41713. dispose(): void;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. /**
  41718. * Button which can be used to enter a different mode of XR
  41719. */
  41720. export class WebXREnterExitUIButton {
  41721. /** button element */
  41722. element: HTMLElement;
  41723. /** XR initialization options for the button */
  41724. sessionMode: XRSessionMode;
  41725. /** Reference space type */
  41726. referenceSpaceType: XRReferenceSpaceType;
  41727. /**
  41728. * Creates a WebXREnterExitUIButton
  41729. * @param element button element
  41730. * @param sessionMode XR initialization session mode
  41731. * @param referenceSpaceType the type of reference space to be used
  41732. */
  41733. constructor(
  41734. /** button element */
  41735. element: HTMLElement,
  41736. /** XR initialization options for the button */
  41737. sessionMode: XRSessionMode,
  41738. /** Reference space type */
  41739. referenceSpaceType: XRReferenceSpaceType);
  41740. /**
  41741. * Overwritable function which can be used to update the button's visuals when the state changes
  41742. * @param activeButton the current active button in the UI
  41743. */
  41744. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41745. }
  41746. /**
  41747. * Options to create the webXR UI
  41748. */
  41749. export class WebXREnterExitUIOptions {
  41750. /**
  41751. * Context to enter xr with
  41752. */
  41753. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41754. /**
  41755. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41756. */
  41757. customButtons?: Array<WebXREnterExitUIButton>;
  41758. }
  41759. /**
  41760. * UI to allow the user to enter/exit XR mode
  41761. */
  41762. export class WebXREnterExitUI implements IDisposable {
  41763. private scene;
  41764. private _overlay;
  41765. private _buttons;
  41766. private _activeButton;
  41767. /**
  41768. * Fired every time the active button is changed.
  41769. *
  41770. * When xr is entered via a button that launches xr that button will be the callback parameter
  41771. *
  41772. * When exiting xr the callback parameter will be null)
  41773. */
  41774. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41775. /**
  41776. * Creates UI to allow the user to enter/exit XR mode
  41777. * @param scene the scene to add the ui to
  41778. * @param helper the xr experience helper to enter/exit xr with
  41779. * @param options options to configure the UI
  41780. * @returns the created ui
  41781. */
  41782. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41783. private constructor();
  41784. private _updateButtons;
  41785. /**
  41786. * Disposes of the object
  41787. */
  41788. dispose(): void;
  41789. }
  41790. }
  41791. declare module BABYLON {
  41792. /**
  41793. * Represents an XR input
  41794. */
  41795. export class WebXRController {
  41796. private scene;
  41797. /** The underlying input source for the controller */
  41798. inputSource: XRInputSource;
  41799. private parentContainer;
  41800. /**
  41801. * 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
  41802. */
  41803. grip?: AbstractMesh;
  41804. /**
  41805. * Pointer which can be used to select objects or attach a visible laser to
  41806. */
  41807. pointer: AbstractMesh;
  41808. private _gamepadMode;
  41809. /**
  41810. * If available, this is the gamepad object related to this controller.
  41811. * Using this object it is possible to get click events and trackpad changes of the
  41812. * webxr controller that is currently being used.
  41813. */
  41814. gamepadController?: WebVRController;
  41815. /**
  41816. * Event that fires when the controller is removed/disposed
  41817. */
  41818. onDisposeObservable: Observable<{}>;
  41819. private _tmpMatrix;
  41820. private _tmpQuaternion;
  41821. private _tmpVector;
  41822. /**
  41823. * Creates the controller
  41824. * @see https://doc.babylonjs.com/how_to/webxr
  41825. * @param scene the scene which the controller should be associated to
  41826. * @param inputSource the underlying input source for the controller
  41827. * @param parentContainer parent that the controller meshes should be children of
  41828. */
  41829. constructor(scene: Scene,
  41830. /** The underlying input source for the controller */
  41831. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41832. /**
  41833. * Updates the controller pose based on the given XRFrame
  41834. * @param xrFrame xr frame to update the pose with
  41835. * @param referenceSpace reference space to use
  41836. */
  41837. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41838. /**
  41839. * Gets a world space ray coming from the controller
  41840. * @param result the resulting ray
  41841. */
  41842. getWorldPointerRayToRef(result: Ray): void;
  41843. /**
  41844. * Get the scene associated with this controller
  41845. * @returns the scene object
  41846. */
  41847. getScene(): Scene;
  41848. /**
  41849. * Disposes of the object
  41850. */
  41851. dispose(): void;
  41852. }
  41853. }
  41854. declare module BABYLON {
  41855. /**
  41856. * XR input used to track XR inputs such as controllers/rays
  41857. */
  41858. export class WebXRInput implements IDisposable {
  41859. /**
  41860. * Base experience the input listens to
  41861. */
  41862. baseExperience: WebXRExperienceHelper;
  41863. /**
  41864. * XR controllers being tracked
  41865. */
  41866. controllers: Array<WebXRController>;
  41867. private _frameObserver;
  41868. private _stateObserver;
  41869. /**
  41870. * Event when a controller has been connected/added
  41871. */
  41872. onControllerAddedObservable: Observable<WebXRController>;
  41873. /**
  41874. * Event when a controller has been removed/disconnected
  41875. */
  41876. onControllerRemovedObservable: Observable<WebXRController>;
  41877. /**
  41878. * Initializes the WebXRInput
  41879. * @param baseExperience experience helper which the input should be created for
  41880. */
  41881. constructor(
  41882. /**
  41883. * Base experience the input listens to
  41884. */
  41885. baseExperience: WebXRExperienceHelper);
  41886. private _onInputSourcesChange;
  41887. private _addAndRemoveControllers;
  41888. /**
  41889. * Disposes of the object
  41890. */
  41891. dispose(): void;
  41892. }
  41893. }
  41894. declare module BABYLON {
  41895. /**
  41896. * Enables teleportation
  41897. */
  41898. export class WebXRControllerTeleportation {
  41899. private _teleportationFillColor;
  41900. private _teleportationBorderColor;
  41901. private _tmpRay;
  41902. private _tmpVector;
  41903. /**
  41904. * Creates a WebXRControllerTeleportation
  41905. * @param input input manager to add teleportation to
  41906. * @param floorMeshes floormeshes which can be teleported to
  41907. */
  41908. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41909. }
  41910. }
  41911. declare module BABYLON {
  41912. /**
  41913. * Handles pointer input automatically for the pointer of XR controllers
  41914. */
  41915. export class WebXRControllerPointerSelection {
  41916. private static _idCounter;
  41917. private _tmpRay;
  41918. /**
  41919. * Creates a WebXRControllerPointerSelection
  41920. * @param input input manager to setup pointer selection
  41921. */
  41922. constructor(input: WebXRInput);
  41923. private _convertNormalToDirectionOfRay;
  41924. private _updatePointerDistance;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * Class used to represent data loading progression
  41930. */
  41931. export class SceneLoaderProgressEvent {
  41932. /** defines if data length to load can be evaluated */
  41933. readonly lengthComputable: boolean;
  41934. /** defines the loaded data length */
  41935. readonly loaded: number;
  41936. /** defines the data length to load */
  41937. readonly total: number;
  41938. /**
  41939. * Create a new progress event
  41940. * @param lengthComputable defines if data length to load can be evaluated
  41941. * @param loaded defines the loaded data length
  41942. * @param total defines the data length to load
  41943. */
  41944. constructor(
  41945. /** defines if data length to load can be evaluated */
  41946. lengthComputable: boolean,
  41947. /** defines the loaded data length */
  41948. loaded: number,
  41949. /** defines the data length to load */
  41950. total: number);
  41951. /**
  41952. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41953. * @param event defines the source event
  41954. * @returns a new SceneLoaderProgressEvent
  41955. */
  41956. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41957. }
  41958. /**
  41959. * Interface used by SceneLoader plugins to define supported file extensions
  41960. */
  41961. export interface ISceneLoaderPluginExtensions {
  41962. /**
  41963. * Defines the list of supported extensions
  41964. */
  41965. [extension: string]: {
  41966. isBinary: boolean;
  41967. };
  41968. }
  41969. /**
  41970. * Interface used by SceneLoader plugin factory
  41971. */
  41972. export interface ISceneLoaderPluginFactory {
  41973. /**
  41974. * Defines the name of the factory
  41975. */
  41976. name: string;
  41977. /**
  41978. * Function called to create a new plugin
  41979. * @return the new plugin
  41980. */
  41981. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41982. /**
  41983. * The callback that returns true if the data can be directly loaded.
  41984. * @param data string containing the file data
  41985. * @returns if the data can be loaded directly
  41986. */
  41987. canDirectLoad?(data: string): boolean;
  41988. }
  41989. /**
  41990. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  41991. */
  41992. export interface ISceneLoaderPluginBase {
  41993. /**
  41994. * The friendly name of this plugin.
  41995. */
  41996. name: string;
  41997. /**
  41998. * The file extensions supported by this plugin.
  41999. */
  42000. extensions: string | ISceneLoaderPluginExtensions;
  42001. /**
  42002. * The callback called when loading from a url.
  42003. * @param scene scene loading this url
  42004. * @param url url to load
  42005. * @param onSuccess callback called when the file successfully loads
  42006. * @param onProgress callback called while file is loading (if the server supports this mode)
  42007. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42008. * @param onError callback called when the file fails to load
  42009. * @returns a file request object
  42010. */
  42011. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42012. /**
  42013. * The callback called when loading from a file object.
  42014. * @param scene scene loading this file
  42015. * @param file defines the file to load
  42016. * @param onSuccess defines the callback to call when data is loaded
  42017. * @param onProgress defines the callback to call during loading process
  42018. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42019. * @param onError defines the callback to call when an error occurs
  42020. * @returns a file request object
  42021. */
  42022. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42023. /**
  42024. * The callback that returns true if the data can be directly loaded.
  42025. * @param data string containing the file data
  42026. * @returns if the data can be loaded directly
  42027. */
  42028. canDirectLoad?(data: string): boolean;
  42029. /**
  42030. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42031. * @param scene scene loading this data
  42032. * @param data string containing the data
  42033. * @returns data to pass to the plugin
  42034. */
  42035. directLoad?(scene: Scene, data: string): any;
  42036. /**
  42037. * The callback that allows custom handling of the root url based on the response url.
  42038. * @param rootUrl the original root url
  42039. * @param responseURL the response url if available
  42040. * @returns the new root url
  42041. */
  42042. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42043. }
  42044. /**
  42045. * Interface used to define a SceneLoader plugin
  42046. */
  42047. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42048. /**
  42049. * Import meshes into a scene.
  42050. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42051. * @param scene The scene to import into
  42052. * @param data The data to import
  42053. * @param rootUrl The root url for scene and resources
  42054. * @param meshes The meshes array to import into
  42055. * @param particleSystems The particle systems array to import into
  42056. * @param skeletons The skeletons array to import into
  42057. * @param onError The callback when import fails
  42058. * @returns True if successful or false otherwise
  42059. */
  42060. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42061. /**
  42062. * Load into a scene.
  42063. * @param scene The scene to load into
  42064. * @param data The data to import
  42065. * @param rootUrl The root url for scene and resources
  42066. * @param onError The callback when import fails
  42067. * @returns True if successful or false otherwise
  42068. */
  42069. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42070. /**
  42071. * Load into an asset container.
  42072. * @param scene The scene to load into
  42073. * @param data The data to import
  42074. * @param rootUrl The root url for scene and resources
  42075. * @param onError The callback when import fails
  42076. * @returns The loaded asset container
  42077. */
  42078. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42079. }
  42080. /**
  42081. * Interface used to define an async SceneLoader plugin
  42082. */
  42083. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42084. /**
  42085. * Import meshes into a scene.
  42086. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42087. * @param scene The scene to import into
  42088. * @param data The data to import
  42089. * @param rootUrl The root url for scene and resources
  42090. * @param onProgress The callback when the load progresses
  42091. * @param fileName Defines the name of the file to load
  42092. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42093. */
  42094. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42095. meshes: AbstractMesh[];
  42096. particleSystems: IParticleSystem[];
  42097. skeletons: Skeleton[];
  42098. animationGroups: AnimationGroup[];
  42099. }>;
  42100. /**
  42101. * Load into a scene.
  42102. * @param scene The scene to load into
  42103. * @param data The data to import
  42104. * @param rootUrl The root url for scene and resources
  42105. * @param onProgress The callback when the load progresses
  42106. * @param fileName Defines the name of the file to load
  42107. * @returns Nothing
  42108. */
  42109. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42110. /**
  42111. * Load into an asset container.
  42112. * @param scene The scene to load into
  42113. * @param data The data to import
  42114. * @param rootUrl The root url for scene and resources
  42115. * @param onProgress The callback when the load progresses
  42116. * @param fileName Defines the name of the file to load
  42117. * @returns The loaded asset container
  42118. */
  42119. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42120. }
  42121. /**
  42122. * Class used to load scene from various file formats using registered plugins
  42123. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42124. */
  42125. export class SceneLoader {
  42126. /**
  42127. * No logging while loading
  42128. */
  42129. static readonly NO_LOGGING: number;
  42130. /**
  42131. * Minimal logging while loading
  42132. */
  42133. static readonly MINIMAL_LOGGING: number;
  42134. /**
  42135. * Summary logging while loading
  42136. */
  42137. static readonly SUMMARY_LOGGING: number;
  42138. /**
  42139. * Detailled logging while loading
  42140. */
  42141. static readonly DETAILED_LOGGING: number;
  42142. /**
  42143. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42144. */
  42145. static ForceFullSceneLoadingForIncremental: boolean;
  42146. /**
  42147. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42148. */
  42149. static ShowLoadingScreen: boolean;
  42150. /**
  42151. * Defines the current logging level (while loading the scene)
  42152. * @ignorenaming
  42153. */
  42154. static loggingLevel: number;
  42155. /**
  42156. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42157. */
  42158. static CleanBoneMatrixWeights: boolean;
  42159. /**
  42160. * Event raised when a plugin is used to load a scene
  42161. */
  42162. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42163. private static _registeredPlugins;
  42164. private static _getDefaultPlugin;
  42165. private static _getPluginForExtension;
  42166. private static _getPluginForDirectLoad;
  42167. private static _getPluginForFilename;
  42168. private static _getDirectLoad;
  42169. private static _loadData;
  42170. private static _getFileInfo;
  42171. /**
  42172. * Gets a plugin that can load the given extension
  42173. * @param extension defines the extension to load
  42174. * @returns a plugin or null if none works
  42175. */
  42176. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42177. /**
  42178. * Gets a boolean indicating that the given extension can be loaded
  42179. * @param extension defines the extension to load
  42180. * @returns true if the extension is supported
  42181. */
  42182. static IsPluginForExtensionAvailable(extension: string): boolean;
  42183. /**
  42184. * Adds a new plugin to the list of registered plugins
  42185. * @param plugin defines the plugin to add
  42186. */
  42187. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42188. /**
  42189. * Import meshes into a scene
  42190. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42191. * @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)
  42192. * @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)
  42193. * @param scene the instance of BABYLON.Scene to append to
  42194. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42195. * @param onProgress a callback with a progress event for each file being loaded
  42196. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42197. * @param pluginExtension the extension used to determine the plugin
  42198. * @returns The loaded plugin
  42199. */
  42200. 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>;
  42201. /**
  42202. * Import meshes into a scene
  42203. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42204. * @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)
  42205. * @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)
  42206. * @param scene the instance of BABYLON.Scene to append to
  42207. * @param onProgress a callback with a progress event for each file being loaded
  42208. * @param pluginExtension the extension used to determine the plugin
  42209. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42210. */
  42211. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42212. meshes: AbstractMesh[];
  42213. particleSystems: IParticleSystem[];
  42214. skeletons: Skeleton[];
  42215. animationGroups: AnimationGroup[];
  42216. }>;
  42217. /**
  42218. * Load a scene
  42219. * @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)
  42220. * @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)
  42221. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42222. * @param onSuccess a callback with the scene when import succeeds
  42223. * @param onProgress a callback with a progress event for each file being loaded
  42224. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42225. * @param pluginExtension the extension used to determine the plugin
  42226. * @returns The loaded plugin
  42227. */
  42228. 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>;
  42229. /**
  42230. * Load a scene
  42231. * @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)
  42232. * @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)
  42233. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42234. * @param onProgress a callback with a progress event for each file being loaded
  42235. * @param pluginExtension the extension used to determine the plugin
  42236. * @returns The loaded scene
  42237. */
  42238. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42239. /**
  42240. * Append a scene
  42241. * @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)
  42242. * @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)
  42243. * @param scene is the instance of BABYLON.Scene to append to
  42244. * @param onSuccess a callback with the scene when import succeeds
  42245. * @param onProgress a callback with a progress event for each file being loaded
  42246. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42247. * @param pluginExtension the extension used to determine the plugin
  42248. * @returns The loaded plugin
  42249. */
  42250. 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>;
  42251. /**
  42252. * Append a scene
  42253. * @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)
  42254. * @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)
  42255. * @param scene is the instance of BABYLON.Scene to append to
  42256. * @param onProgress a callback with a progress event for each file being loaded
  42257. * @param pluginExtension the extension used to determine the plugin
  42258. * @returns The given scene
  42259. */
  42260. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42261. /**
  42262. * Load a scene into an asset container
  42263. * @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)
  42264. * @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)
  42265. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42266. * @param onSuccess a callback with the scene when import succeeds
  42267. * @param onProgress a callback with a progress event for each file being loaded
  42268. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42269. * @param pluginExtension the extension used to determine the plugin
  42270. * @returns The loaded plugin
  42271. */
  42272. 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>;
  42273. /**
  42274. * Load a scene into an asset container
  42275. * @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)
  42276. * @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)
  42277. * @param scene is the instance of Scene to append to
  42278. * @param onProgress a callback with a progress event for each file being loaded
  42279. * @param pluginExtension the extension used to determine the plugin
  42280. * @returns The loaded asset container
  42281. */
  42282. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42283. }
  42284. }
  42285. declare module BABYLON {
  42286. /**
  42287. * Generic Controller
  42288. */
  42289. export class GenericController extends WebVRController {
  42290. /**
  42291. * Base Url for the controller model.
  42292. */
  42293. static readonly MODEL_BASE_URL: string;
  42294. /**
  42295. * File name for the controller model.
  42296. */
  42297. static readonly MODEL_FILENAME: string;
  42298. /**
  42299. * Creates a new GenericController from a gamepad
  42300. * @param vrGamepad the gamepad that the controller should be created from
  42301. */
  42302. constructor(vrGamepad: any);
  42303. /**
  42304. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42305. * @param scene scene in which to add meshes
  42306. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42307. */
  42308. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42309. /**
  42310. * Called once for each button that changed state since the last frame
  42311. * @param buttonIdx Which button index changed
  42312. * @param state New state of the button
  42313. * @param changes Which properties on the state changed since last frame
  42314. */
  42315. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42316. }
  42317. }
  42318. declare module BABYLON {
  42319. /**
  42320. * Defines the WindowsMotionController object that the state of the windows motion controller
  42321. */
  42322. export class WindowsMotionController extends WebVRController {
  42323. /**
  42324. * The base url used to load the left and right controller models
  42325. */
  42326. static MODEL_BASE_URL: string;
  42327. /**
  42328. * The name of the left controller model file
  42329. */
  42330. static MODEL_LEFT_FILENAME: string;
  42331. /**
  42332. * The name of the right controller model file
  42333. */
  42334. static MODEL_RIGHT_FILENAME: string;
  42335. /**
  42336. * The controller name prefix for this controller type
  42337. */
  42338. static readonly GAMEPAD_ID_PREFIX: string;
  42339. /**
  42340. * The controller id pattern for this controller type
  42341. */
  42342. private static readonly GAMEPAD_ID_PATTERN;
  42343. private _loadedMeshInfo;
  42344. private readonly _mapping;
  42345. /**
  42346. * Fired when the trackpad on this controller is clicked
  42347. */
  42348. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42349. /**
  42350. * Fired when the trackpad on this controller is modified
  42351. */
  42352. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42353. /**
  42354. * The current x and y values of this controller's trackpad
  42355. */
  42356. trackpad: StickValues;
  42357. /**
  42358. * Creates a new WindowsMotionController from a gamepad
  42359. * @param vrGamepad the gamepad that the controller should be created from
  42360. */
  42361. constructor(vrGamepad: any);
  42362. /**
  42363. * Fired when the trigger on this controller is modified
  42364. */
  42365. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42366. /**
  42367. * Fired when the menu button on this controller is modified
  42368. */
  42369. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42370. /**
  42371. * Fired when the grip button on this controller is modified
  42372. */
  42373. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42374. /**
  42375. * Fired when the thumbstick button on this controller is modified
  42376. */
  42377. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42378. /**
  42379. * Fired when the touchpad button on this controller is modified
  42380. */
  42381. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42382. /**
  42383. * Fired when the touchpad values on this controller are modified
  42384. */
  42385. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42386. private _updateTrackpad;
  42387. /**
  42388. * Called once per frame by the engine.
  42389. */
  42390. update(): void;
  42391. /**
  42392. * Called once for each button that changed state since the last frame
  42393. * @param buttonIdx Which button index changed
  42394. * @param state New state of the button
  42395. * @param changes Which properties on the state changed since last frame
  42396. */
  42397. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42398. /**
  42399. * Moves the buttons on the controller mesh based on their current state
  42400. * @param buttonName the name of the button to move
  42401. * @param buttonValue the value of the button which determines the buttons new position
  42402. */
  42403. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42404. /**
  42405. * Moves the axis on the controller mesh based on its current state
  42406. * @param axis the index of the axis
  42407. * @param axisValue the value of the axis which determines the meshes new position
  42408. * @hidden
  42409. */
  42410. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42411. /**
  42412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42413. * @param scene scene in which to add meshes
  42414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42415. */
  42416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42417. /**
  42418. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42419. * can be transformed by button presses and axes values, based on this._mapping.
  42420. *
  42421. * @param scene scene in which the meshes exist
  42422. * @param meshes list of meshes that make up the controller model to process
  42423. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42424. */
  42425. private processModel;
  42426. private createMeshInfo;
  42427. /**
  42428. * Gets the ray of the controller in the direction the controller is pointing
  42429. * @param length the length the resulting ray should be
  42430. * @returns a ray in the direction the controller is pointing
  42431. */
  42432. getForwardRay(length?: number): Ray;
  42433. /**
  42434. * Disposes of the controller
  42435. */
  42436. dispose(): void;
  42437. }
  42438. }
  42439. declare module BABYLON {
  42440. /**
  42441. * Oculus Touch Controller
  42442. */
  42443. export class OculusTouchController extends WebVRController {
  42444. /**
  42445. * Base Url for the controller model.
  42446. */
  42447. static MODEL_BASE_URL: string;
  42448. /**
  42449. * File name for the left controller model.
  42450. */
  42451. static MODEL_LEFT_FILENAME: string;
  42452. /**
  42453. * File name for the right controller model.
  42454. */
  42455. static MODEL_RIGHT_FILENAME: string;
  42456. /**
  42457. * Base Url for the Quest controller model.
  42458. */
  42459. static QUEST_MODEL_BASE_URL: string;
  42460. /**
  42461. * @hidden
  42462. * If the controllers are running on a device that needs the updated Quest controller models
  42463. */
  42464. static _IsQuest: boolean;
  42465. /**
  42466. * Fired when the secondary trigger on this controller is modified
  42467. */
  42468. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42469. /**
  42470. * Fired when the thumb rest on this controller is modified
  42471. */
  42472. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42473. /**
  42474. * Creates a new OculusTouchController from a gamepad
  42475. * @param vrGamepad the gamepad that the controller should be created from
  42476. */
  42477. constructor(vrGamepad: any);
  42478. /**
  42479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42480. * @param scene scene in which to add meshes
  42481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42482. */
  42483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42484. /**
  42485. * Fired when the A button on this controller is modified
  42486. */
  42487. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42488. /**
  42489. * Fired when the B button on this controller is modified
  42490. */
  42491. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42492. /**
  42493. * Fired when the X button on this controller is modified
  42494. */
  42495. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42496. /**
  42497. * Fired when the Y button on this controller is modified
  42498. */
  42499. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42500. /**
  42501. * Called once for each button that changed state since the last frame
  42502. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42503. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42504. * 2) secondary trigger (same)
  42505. * 3) A (right) X (left), touch, pressed = value
  42506. * 4) B / Y
  42507. * 5) thumb rest
  42508. * @param buttonIdx Which button index changed
  42509. * @param state New state of the button
  42510. * @param changes Which properties on the state changed since last frame
  42511. */
  42512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /**
  42517. * Vive Controller
  42518. */
  42519. export class ViveController extends WebVRController {
  42520. /**
  42521. * Base Url for the controller model.
  42522. */
  42523. static MODEL_BASE_URL: string;
  42524. /**
  42525. * File name for the controller model.
  42526. */
  42527. static MODEL_FILENAME: string;
  42528. /**
  42529. * Creates a new ViveController from a gamepad
  42530. * @param vrGamepad the gamepad that the controller should be created from
  42531. */
  42532. constructor(vrGamepad: any);
  42533. /**
  42534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42535. * @param scene scene in which to add meshes
  42536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42537. */
  42538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42539. /**
  42540. * Fired when the left button on this controller is modified
  42541. */
  42542. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42543. /**
  42544. * Fired when the right button on this controller is modified
  42545. */
  42546. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42547. /**
  42548. * Fired when the menu button on this controller is modified
  42549. */
  42550. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42551. /**
  42552. * Called once for each button that changed state since the last frame
  42553. * Vive mapping:
  42554. * 0: touchpad
  42555. * 1: trigger
  42556. * 2: left AND right buttons
  42557. * 3: menu button
  42558. * @param buttonIdx Which button index changed
  42559. * @param state New state of the button
  42560. * @param changes Which properties on the state changed since last frame
  42561. */
  42562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42568. */
  42569. export class WebXRControllerModelLoader {
  42570. /**
  42571. * Creates the WebXRControllerModelLoader
  42572. * @param input xr input that creates the controllers
  42573. */
  42574. constructor(input: WebXRInput);
  42575. }
  42576. }
  42577. declare module BABYLON {
  42578. /**
  42579. * Contains an array of blocks representing the octree
  42580. */
  42581. export interface IOctreeContainer<T> {
  42582. /**
  42583. * Blocks within the octree
  42584. */
  42585. blocks: Array<OctreeBlock<T>>;
  42586. }
  42587. /**
  42588. * Class used to store a cell in an octree
  42589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42590. */
  42591. export class OctreeBlock<T> {
  42592. /**
  42593. * Gets the content of the current block
  42594. */
  42595. entries: T[];
  42596. /**
  42597. * Gets the list of block children
  42598. */
  42599. blocks: Array<OctreeBlock<T>>;
  42600. private _depth;
  42601. private _maxDepth;
  42602. private _capacity;
  42603. private _minPoint;
  42604. private _maxPoint;
  42605. private _boundingVectors;
  42606. private _creationFunc;
  42607. /**
  42608. * Creates a new block
  42609. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42610. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42611. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42612. * @param depth defines the current depth of this block in the octree
  42613. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42614. * @param creationFunc defines a callback to call when an element is added to the block
  42615. */
  42616. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42617. /**
  42618. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42619. */
  42620. readonly capacity: number;
  42621. /**
  42622. * Gets the minimum vector (in world space) of the block's bounding box
  42623. */
  42624. readonly minPoint: Vector3;
  42625. /**
  42626. * Gets the maximum vector (in world space) of the block's bounding box
  42627. */
  42628. readonly maxPoint: Vector3;
  42629. /**
  42630. * Add a new element to this block
  42631. * @param entry defines the element to add
  42632. */
  42633. addEntry(entry: T): void;
  42634. /**
  42635. * Remove an element from this block
  42636. * @param entry defines the element to remove
  42637. */
  42638. removeEntry(entry: T): void;
  42639. /**
  42640. * Add an array of elements to this block
  42641. * @param entries defines the array of elements to add
  42642. */
  42643. addEntries(entries: T[]): void;
  42644. /**
  42645. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42646. * @param frustumPlanes defines the frustum planes to test
  42647. * @param selection defines the array to store current content if selection is positive
  42648. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42649. */
  42650. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42651. /**
  42652. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42653. * @param sphereCenter defines the bounding sphere center
  42654. * @param sphereRadius defines the bounding sphere radius
  42655. * @param selection defines the array to store current content if selection is positive
  42656. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42657. */
  42658. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42659. /**
  42660. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42661. * @param ray defines the ray to test with
  42662. * @param selection defines the array to store current content if selection is positive
  42663. */
  42664. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42665. /**
  42666. * Subdivide the content into child blocks (this block will then be empty)
  42667. */
  42668. createInnerBlocks(): void;
  42669. /**
  42670. * @hidden
  42671. */
  42672. 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;
  42673. }
  42674. }
  42675. declare module BABYLON {
  42676. /**
  42677. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42678. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42679. */
  42680. export class Octree<T> {
  42681. /** 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.) */
  42682. maxDepth: number;
  42683. /**
  42684. * Blocks within the octree containing objects
  42685. */
  42686. blocks: Array<OctreeBlock<T>>;
  42687. /**
  42688. * Content stored in the octree
  42689. */
  42690. dynamicContent: T[];
  42691. private _maxBlockCapacity;
  42692. private _selectionContent;
  42693. private _creationFunc;
  42694. /**
  42695. * Creates a octree
  42696. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42697. * @param creationFunc function to be used to instatiate the octree
  42698. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42699. * @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.)
  42700. */
  42701. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42702. /** 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.) */
  42703. maxDepth?: number);
  42704. /**
  42705. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42706. * @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);
  42707. * @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);
  42708. * @param entries meshes to be added to the octree blocks
  42709. */
  42710. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42711. /**
  42712. * Adds a mesh to the octree
  42713. * @param entry Mesh to add to the octree
  42714. */
  42715. addMesh(entry: T): void;
  42716. /**
  42717. * Remove an element from the octree
  42718. * @param entry defines the element to remove
  42719. */
  42720. removeMesh(entry: T): void;
  42721. /**
  42722. * Selects an array of meshes within the frustum
  42723. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42724. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42725. * @returns array of meshes within the frustum
  42726. */
  42727. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42728. /**
  42729. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42730. * @param sphereCenter defines the bounding sphere center
  42731. * @param sphereRadius defines the bounding sphere radius
  42732. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42733. * @returns an array of objects that intersect the sphere
  42734. */
  42735. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42736. /**
  42737. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42738. * @param ray defines the ray to test with
  42739. * @returns array of intersected objects
  42740. */
  42741. intersectsRay(ray: Ray): SmartArray<T>;
  42742. /**
  42743. * Adds a mesh into the octree block if it intersects the block
  42744. */
  42745. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42746. /**
  42747. * Adds a submesh into the octree block if it intersects the block
  42748. */
  42749. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. interface Scene {
  42754. /**
  42755. * @hidden
  42756. * Backing Filed
  42757. */
  42758. _selectionOctree: Octree<AbstractMesh>;
  42759. /**
  42760. * Gets the octree used to boost mesh selection (picking)
  42761. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42762. */
  42763. selectionOctree: Octree<AbstractMesh>;
  42764. /**
  42765. * Creates or updates the octree used to boost selection (picking)
  42766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42767. * @param maxCapacity defines the maximum capacity per leaf
  42768. * @param maxDepth defines the maximum depth of the octree
  42769. * @returns an octree of AbstractMesh
  42770. */
  42771. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42772. }
  42773. interface AbstractMesh {
  42774. /**
  42775. * @hidden
  42776. * Backing Field
  42777. */
  42778. _submeshesOctree: Octree<SubMesh>;
  42779. /**
  42780. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42781. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42782. * @param maxCapacity defines the maximum size of each block (64 by default)
  42783. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42784. * @returns the new octree
  42785. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42786. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42787. */
  42788. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42789. }
  42790. /**
  42791. * Defines the octree scene component responsible to manage any octrees
  42792. * in a given scene.
  42793. */
  42794. export class OctreeSceneComponent {
  42795. /**
  42796. * The component name help to identify the component in the list of scene components.
  42797. */
  42798. readonly name: string;
  42799. /**
  42800. * The scene the component belongs to.
  42801. */
  42802. scene: Scene;
  42803. /**
  42804. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42805. */
  42806. readonly checksIsEnabled: boolean;
  42807. /**
  42808. * Creates a new instance of the component for the given scene
  42809. * @param scene Defines the scene to register the component in
  42810. */
  42811. constructor(scene: Scene);
  42812. /**
  42813. * Registers the component in a given scene
  42814. */
  42815. register(): void;
  42816. /**
  42817. * Return the list of active meshes
  42818. * @returns the list of active meshes
  42819. */
  42820. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42821. /**
  42822. * Return the list of active sub meshes
  42823. * @param mesh The mesh to get the candidates sub meshes from
  42824. * @returns the list of active sub meshes
  42825. */
  42826. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42827. private _tempRay;
  42828. /**
  42829. * Return the list of sub meshes intersecting with a given local ray
  42830. * @param mesh defines the mesh to find the submesh for
  42831. * @param localRay defines the ray in local space
  42832. * @returns the list of intersecting sub meshes
  42833. */
  42834. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42835. /**
  42836. * Return the list of sub meshes colliding with a collider
  42837. * @param mesh defines the mesh to find the submesh for
  42838. * @param collider defines the collider to evaluate the collision against
  42839. * @returns the list of colliding sub meshes
  42840. */
  42841. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42842. /**
  42843. * Rebuilds the elements related to this component in case of
  42844. * context lost for instance.
  42845. */
  42846. rebuild(): void;
  42847. /**
  42848. * Disposes the component and the associated ressources.
  42849. */
  42850. dispose(): void;
  42851. }
  42852. }
  42853. declare module BABYLON {
  42854. /**
  42855. * Renders a layer on top of an existing scene
  42856. */
  42857. export class UtilityLayerRenderer implements IDisposable {
  42858. /** the original scene that will be rendered on top of */
  42859. originalScene: Scene;
  42860. private _pointerCaptures;
  42861. private _lastPointerEvents;
  42862. private static _DefaultUtilityLayer;
  42863. private static _DefaultKeepDepthUtilityLayer;
  42864. private _sharedGizmoLight;
  42865. private _renderCamera;
  42866. /**
  42867. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42868. * @returns the camera that is used when rendering the utility layer
  42869. */
  42870. getRenderCamera(): Nullable<Camera>;
  42871. /**
  42872. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42873. * @param cam the camera that should be used when rendering the utility layer
  42874. */
  42875. setRenderCamera(cam: Nullable<Camera>): void;
  42876. /**
  42877. * @hidden
  42878. * Light which used by gizmos to get light shading
  42879. */
  42880. _getSharedGizmoLight(): HemisphericLight;
  42881. /**
  42882. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42883. */
  42884. pickUtilitySceneFirst: boolean;
  42885. /**
  42886. * 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)
  42887. */
  42888. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42889. /**
  42890. * 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)
  42891. */
  42892. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42893. /**
  42894. * The scene that is rendered on top of the original scene
  42895. */
  42896. utilityLayerScene: Scene;
  42897. /**
  42898. * If the utility layer should automatically be rendered on top of existing scene
  42899. */
  42900. shouldRender: boolean;
  42901. /**
  42902. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42903. */
  42904. onlyCheckPointerDownEvents: boolean;
  42905. /**
  42906. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42907. */
  42908. processAllEvents: boolean;
  42909. /**
  42910. * Observable raised when the pointer move from the utility layer scene to the main scene
  42911. */
  42912. onPointerOutObservable: Observable<number>;
  42913. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42914. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42915. private _afterRenderObserver;
  42916. private _sceneDisposeObserver;
  42917. private _originalPointerObserver;
  42918. /**
  42919. * Instantiates a UtilityLayerRenderer
  42920. * @param originalScene the original scene that will be rendered on top of
  42921. * @param handleEvents boolean indicating if the utility layer should handle events
  42922. */
  42923. constructor(
  42924. /** the original scene that will be rendered on top of */
  42925. originalScene: Scene, handleEvents?: boolean);
  42926. private _notifyObservers;
  42927. /**
  42928. * Renders the utility layers scene on top of the original scene
  42929. */
  42930. render(): void;
  42931. /**
  42932. * Disposes of the renderer
  42933. */
  42934. dispose(): void;
  42935. private _updateCamera;
  42936. }
  42937. }
  42938. declare module BABYLON {
  42939. /**
  42940. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42941. */
  42942. export class Gizmo implements IDisposable {
  42943. /** The utility layer the gizmo will be added to */
  42944. gizmoLayer: UtilityLayerRenderer;
  42945. /**
  42946. * The root mesh of the gizmo
  42947. */
  42948. _rootMesh: Mesh;
  42949. private _attachedMesh;
  42950. /**
  42951. * Ratio for the scale of the gizmo (Default: 1)
  42952. */
  42953. scaleRatio: number;
  42954. /**
  42955. * If a custom mesh has been set (Default: false)
  42956. */
  42957. protected _customMeshSet: boolean;
  42958. /**
  42959. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42960. * * When set, interactions will be enabled
  42961. */
  42962. attachedMesh: Nullable<AbstractMesh>;
  42963. /**
  42964. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42965. * @param mesh The mesh to replace the default mesh of the gizmo
  42966. */
  42967. setCustomMesh(mesh: Mesh): void;
  42968. /**
  42969. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42970. */
  42971. updateGizmoRotationToMatchAttachedMesh: boolean;
  42972. /**
  42973. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42974. */
  42975. updateGizmoPositionToMatchAttachedMesh: boolean;
  42976. /**
  42977. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42978. */
  42979. updateScale: boolean;
  42980. protected _interactionsEnabled: boolean;
  42981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42982. private _beforeRenderObserver;
  42983. private _tempVector;
  42984. /**
  42985. * Creates a gizmo
  42986. * @param gizmoLayer The utility layer the gizmo will be added to
  42987. */
  42988. constructor(
  42989. /** The utility layer the gizmo will be added to */
  42990. gizmoLayer?: UtilityLayerRenderer);
  42991. /**
  42992. * Updates the gizmo to match the attached mesh's position/rotation
  42993. */
  42994. protected _update(): void;
  42995. /**
  42996. * Disposes of the gizmo
  42997. */
  42998. dispose(): void;
  42999. }
  43000. }
  43001. declare module BABYLON {
  43002. /**
  43003. * Single plane drag gizmo
  43004. */
  43005. export class PlaneDragGizmo extends Gizmo {
  43006. /**
  43007. * Drag behavior responsible for the gizmos dragging interactions
  43008. */
  43009. dragBehavior: PointerDragBehavior;
  43010. private _pointerObserver;
  43011. /**
  43012. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43013. */
  43014. snapDistance: number;
  43015. /**
  43016. * Event that fires each time the gizmo snaps to a new location.
  43017. * * snapDistance is the the change in distance
  43018. */
  43019. onSnapObservable: Observable<{
  43020. snapDistance: number;
  43021. }>;
  43022. private _plane;
  43023. private _coloredMaterial;
  43024. private _hoverMaterial;
  43025. private _isEnabled;
  43026. private _parent;
  43027. /** @hidden */
  43028. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43029. /** @hidden */
  43030. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43031. /**
  43032. * Creates a PlaneDragGizmo
  43033. * @param gizmoLayer The utility layer the gizmo will be added to
  43034. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43035. * @param color The color of the gizmo
  43036. */
  43037. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43038. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43039. /**
  43040. * If the gizmo is enabled
  43041. */
  43042. isEnabled: boolean;
  43043. /**
  43044. * Disposes of the gizmo
  43045. */
  43046. dispose(): void;
  43047. }
  43048. }
  43049. declare module BABYLON {
  43050. /**
  43051. * Gizmo that enables dragging a mesh along 3 axis
  43052. */
  43053. export class PositionGizmo extends Gizmo {
  43054. /**
  43055. * Internal gizmo used for interactions on the x axis
  43056. */
  43057. xGizmo: AxisDragGizmo;
  43058. /**
  43059. * Internal gizmo used for interactions on the y axis
  43060. */
  43061. yGizmo: AxisDragGizmo;
  43062. /**
  43063. * Internal gizmo used for interactions on the z axis
  43064. */
  43065. zGizmo: AxisDragGizmo;
  43066. /**
  43067. * Internal gizmo used for interactions on the yz plane
  43068. */
  43069. xPlaneGizmo: PlaneDragGizmo;
  43070. /**
  43071. * Internal gizmo used for interactions on the xz plane
  43072. */
  43073. yPlaneGizmo: PlaneDragGizmo;
  43074. /**
  43075. * Internal gizmo used for interactions on the xy plane
  43076. */
  43077. zPlaneGizmo: PlaneDragGizmo;
  43078. /**
  43079. * private variables
  43080. */
  43081. private _meshAttached;
  43082. private _updateGizmoRotationToMatchAttachedMesh;
  43083. private _snapDistance;
  43084. private _scaleRatio;
  43085. /** Fires an event when any of it's sub gizmos are dragged */
  43086. onDragStartObservable: Observable<unknown>;
  43087. /** Fires an event when any of it's sub gizmos are released from dragging */
  43088. onDragEndObservable: Observable<unknown>;
  43089. /**
  43090. * If set to true, planar drag is enabled
  43091. */
  43092. private _planarGizmoEnabled;
  43093. attachedMesh: Nullable<AbstractMesh>;
  43094. /**
  43095. * Creates a PositionGizmo
  43096. * @param gizmoLayer The utility layer the gizmo will be added to
  43097. */
  43098. constructor(gizmoLayer?: UtilityLayerRenderer);
  43099. /**
  43100. * If the planar drag gizmo is enabled
  43101. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43102. */
  43103. planarGizmoEnabled: boolean;
  43104. updateGizmoRotationToMatchAttachedMesh: boolean;
  43105. /**
  43106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43107. */
  43108. snapDistance: number;
  43109. /**
  43110. * Ratio for the scale of the gizmo (Default: 1)
  43111. */
  43112. scaleRatio: number;
  43113. /**
  43114. * Disposes of the gizmo
  43115. */
  43116. dispose(): void;
  43117. /**
  43118. * CustomMeshes are not supported by this gizmo
  43119. * @param mesh The mesh to replace the default mesh of the gizmo
  43120. */
  43121. setCustomMesh(mesh: Mesh): void;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Single axis drag gizmo
  43127. */
  43128. export class AxisDragGizmo extends Gizmo {
  43129. /**
  43130. * Drag behavior responsible for the gizmos dragging interactions
  43131. */
  43132. dragBehavior: PointerDragBehavior;
  43133. private _pointerObserver;
  43134. /**
  43135. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43136. */
  43137. snapDistance: number;
  43138. /**
  43139. * Event that fires each time the gizmo snaps to a new location.
  43140. * * snapDistance is the the change in distance
  43141. */
  43142. onSnapObservable: Observable<{
  43143. snapDistance: number;
  43144. }>;
  43145. private _isEnabled;
  43146. private _parent;
  43147. private _arrow;
  43148. private _coloredMaterial;
  43149. private _hoverMaterial;
  43150. /** @hidden */
  43151. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43152. /** @hidden */
  43153. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43154. /**
  43155. * Creates an AxisDragGizmo
  43156. * @param gizmoLayer The utility layer the gizmo will be added to
  43157. * @param dragAxis The axis which the gizmo will be able to drag on
  43158. * @param color The color of the gizmo
  43159. */
  43160. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43162. /**
  43163. * If the gizmo is enabled
  43164. */
  43165. isEnabled: boolean;
  43166. /**
  43167. * Disposes of the gizmo
  43168. */
  43169. dispose(): void;
  43170. }
  43171. }
  43172. declare module BABYLON.Debug {
  43173. /**
  43174. * The Axes viewer will show 3 axes in a specific point in space
  43175. */
  43176. export class AxesViewer {
  43177. private _xAxis;
  43178. private _yAxis;
  43179. private _zAxis;
  43180. private _scaleLinesFactor;
  43181. private _instanced;
  43182. /**
  43183. * Gets the hosting scene
  43184. */
  43185. scene: Scene;
  43186. /**
  43187. * Gets or sets a number used to scale line length
  43188. */
  43189. scaleLines: number;
  43190. /** Gets the node hierarchy used to render x-axis */
  43191. readonly xAxis: TransformNode;
  43192. /** Gets the node hierarchy used to render y-axis */
  43193. readonly yAxis: TransformNode;
  43194. /** Gets the node hierarchy used to render z-axis */
  43195. readonly zAxis: TransformNode;
  43196. /**
  43197. * Creates a new AxesViewer
  43198. * @param scene defines the hosting scene
  43199. * @param scaleLines defines a number used to scale line length (1 by default)
  43200. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43201. * @param xAxis defines the node hierarchy used to render the x-axis
  43202. * @param yAxis defines the node hierarchy used to render the y-axis
  43203. * @param zAxis defines the node hierarchy used to render the z-axis
  43204. */
  43205. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43206. /**
  43207. * Force the viewer to update
  43208. * @param position defines the position of the viewer
  43209. * @param xaxis defines the x axis of the viewer
  43210. * @param yaxis defines the y axis of the viewer
  43211. * @param zaxis defines the z axis of the viewer
  43212. */
  43213. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43214. /**
  43215. * Creates an instance of this axes viewer.
  43216. * @returns a new axes viewer with instanced meshes
  43217. */
  43218. createInstance(): AxesViewer;
  43219. /** Releases resources */
  43220. dispose(): void;
  43221. private static _SetRenderingGroupId;
  43222. }
  43223. }
  43224. declare module BABYLON.Debug {
  43225. /**
  43226. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43227. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43228. */
  43229. export class BoneAxesViewer extends AxesViewer {
  43230. /**
  43231. * Gets or sets the target mesh where to display the axes viewer
  43232. */
  43233. mesh: Nullable<Mesh>;
  43234. /**
  43235. * Gets or sets the target bone where to display the axes viewer
  43236. */
  43237. bone: Nullable<Bone>;
  43238. /** Gets current position */
  43239. pos: Vector3;
  43240. /** Gets direction of X axis */
  43241. xaxis: Vector3;
  43242. /** Gets direction of Y axis */
  43243. yaxis: Vector3;
  43244. /** Gets direction of Z axis */
  43245. zaxis: Vector3;
  43246. /**
  43247. * Creates a new BoneAxesViewer
  43248. * @param scene defines the hosting scene
  43249. * @param bone defines the target bone
  43250. * @param mesh defines the target mesh
  43251. * @param scaleLines defines a scaling factor for line length (1 by default)
  43252. */
  43253. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43254. /**
  43255. * Force the viewer to update
  43256. */
  43257. update(): void;
  43258. /** Releases resources */
  43259. dispose(): void;
  43260. }
  43261. }
  43262. declare module BABYLON {
  43263. /**
  43264. * Interface used to define scene explorer extensibility option
  43265. */
  43266. export interface IExplorerExtensibilityOption {
  43267. /**
  43268. * Define the option label
  43269. */
  43270. label: string;
  43271. /**
  43272. * Defines the action to execute on click
  43273. */
  43274. action: (entity: any) => void;
  43275. }
  43276. /**
  43277. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43278. */
  43279. export interface IExplorerExtensibilityGroup {
  43280. /**
  43281. * Defines a predicate to test if a given type mut be extended
  43282. */
  43283. predicate: (entity: any) => boolean;
  43284. /**
  43285. * Gets the list of options added to a type
  43286. */
  43287. entries: IExplorerExtensibilityOption[];
  43288. }
  43289. /**
  43290. * Interface used to define the options to use to create the Inspector
  43291. */
  43292. export interface IInspectorOptions {
  43293. /**
  43294. * Display in overlay mode (default: false)
  43295. */
  43296. overlay?: boolean;
  43297. /**
  43298. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43299. */
  43300. globalRoot?: HTMLElement;
  43301. /**
  43302. * Display the Scene explorer
  43303. */
  43304. showExplorer?: boolean;
  43305. /**
  43306. * Display the property inspector
  43307. */
  43308. showInspector?: boolean;
  43309. /**
  43310. * Display in embed mode (both panes on the right)
  43311. */
  43312. embedMode?: boolean;
  43313. /**
  43314. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43315. */
  43316. handleResize?: boolean;
  43317. /**
  43318. * Allow the panes to popup (default: true)
  43319. */
  43320. enablePopup?: boolean;
  43321. /**
  43322. * Allow the panes to be closed by users (default: true)
  43323. */
  43324. enableClose?: boolean;
  43325. /**
  43326. * Optional list of extensibility entries
  43327. */
  43328. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43329. /**
  43330. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43331. */
  43332. inspectorURL?: string;
  43333. }
  43334. interface Scene {
  43335. /**
  43336. * @hidden
  43337. * Backing field
  43338. */
  43339. _debugLayer: DebugLayer;
  43340. /**
  43341. * Gets the debug layer (aka Inspector) associated with the scene
  43342. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43343. */
  43344. debugLayer: DebugLayer;
  43345. }
  43346. /**
  43347. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43348. * what is happening in your scene
  43349. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43350. */
  43351. export class DebugLayer {
  43352. /**
  43353. * Define the url to get the inspector script from.
  43354. * By default it uses the babylonjs CDN.
  43355. * @ignoreNaming
  43356. */
  43357. static InspectorURL: string;
  43358. private _scene;
  43359. private BJSINSPECTOR;
  43360. private _onPropertyChangedObservable?;
  43361. /**
  43362. * Observable triggered when a property is changed through the inspector.
  43363. */
  43364. readonly onPropertyChangedObservable: any;
  43365. /**
  43366. * Instantiates a new debug layer.
  43367. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43368. * what is happening in your scene
  43369. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43370. * @param scene Defines the scene to inspect
  43371. */
  43372. constructor(scene: Scene);
  43373. /** Creates the inspector window. */
  43374. private _createInspector;
  43375. /**
  43376. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43377. * @param entity defines the entity to select
  43378. * @param lineContainerTitle defines the specific block to highlight
  43379. */
  43380. select(entity: any, lineContainerTitle?: string): void;
  43381. /** Get the inspector from bundle or global */
  43382. private _getGlobalInspector;
  43383. /**
  43384. * Get if the inspector is visible or not.
  43385. * @returns true if visible otherwise, false
  43386. */
  43387. isVisible(): boolean;
  43388. /**
  43389. * Hide the inspector and close its window.
  43390. */
  43391. hide(): void;
  43392. /**
  43393. * Launch the debugLayer.
  43394. * @param config Define the configuration of the inspector
  43395. * @return a promise fulfilled when the debug layer is visible
  43396. */
  43397. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43398. }
  43399. }
  43400. declare module BABYLON {
  43401. /**
  43402. * Class containing static functions to help procedurally build meshes
  43403. */
  43404. export class BoxBuilder {
  43405. /**
  43406. * Creates a box mesh
  43407. * * The parameter `size` sets the size (float) of each box side (default 1)
  43408. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43409. * * 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)
  43410. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43412. * * 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
  43413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43414. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43415. * @param name defines the name of the mesh
  43416. * @param options defines the options used to create the mesh
  43417. * @param scene defines the hosting scene
  43418. * @returns the box mesh
  43419. */
  43420. static CreateBox(name: string, options: {
  43421. size?: number;
  43422. width?: number;
  43423. height?: number;
  43424. depth?: number;
  43425. faceUV?: Vector4[];
  43426. faceColors?: Color4[];
  43427. sideOrientation?: number;
  43428. frontUVs?: Vector4;
  43429. backUVs?: Vector4;
  43430. wrap?: boolean;
  43431. topBaseAt?: number;
  43432. bottomBaseAt?: number;
  43433. updatable?: boolean;
  43434. }, scene?: Nullable<Scene>): Mesh;
  43435. }
  43436. }
  43437. declare module BABYLON {
  43438. /**
  43439. * Class containing static functions to help procedurally build meshes
  43440. */
  43441. export class SphereBuilder {
  43442. /**
  43443. * Creates a sphere mesh
  43444. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43445. * * 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`)
  43446. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43447. * * 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
  43448. * * 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)
  43449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43450. * * 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
  43451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43452. * @param name defines the name of the mesh
  43453. * @param options defines the options used to create the mesh
  43454. * @param scene defines the hosting scene
  43455. * @returns the sphere mesh
  43456. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43457. */
  43458. static CreateSphere(name: string, options: {
  43459. segments?: number;
  43460. diameter?: number;
  43461. diameterX?: number;
  43462. diameterY?: number;
  43463. diameterZ?: number;
  43464. arc?: number;
  43465. slice?: number;
  43466. sideOrientation?: number;
  43467. frontUVs?: Vector4;
  43468. backUVs?: Vector4;
  43469. updatable?: boolean;
  43470. }, scene?: Nullable<Scene>): Mesh;
  43471. }
  43472. }
  43473. declare module BABYLON.Debug {
  43474. /**
  43475. * Used to show the physics impostor around the specific mesh
  43476. */
  43477. export class PhysicsViewer {
  43478. /** @hidden */
  43479. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43480. /** @hidden */
  43481. protected _meshes: Array<Nullable<AbstractMesh>>;
  43482. /** @hidden */
  43483. protected _scene: Nullable<Scene>;
  43484. /** @hidden */
  43485. protected _numMeshes: number;
  43486. /** @hidden */
  43487. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43488. private _renderFunction;
  43489. private _utilityLayer;
  43490. private _debugBoxMesh;
  43491. private _debugSphereMesh;
  43492. private _debugCylinderMesh;
  43493. private _debugMaterial;
  43494. private _debugMeshMeshes;
  43495. /**
  43496. * Creates a new PhysicsViewer
  43497. * @param scene defines the hosting scene
  43498. */
  43499. constructor(scene: Scene);
  43500. /** @hidden */
  43501. protected _updateDebugMeshes(): void;
  43502. /**
  43503. * Renders a specified physic impostor
  43504. * @param impostor defines the impostor to render
  43505. * @param targetMesh defines the mesh represented by the impostor
  43506. * @returns the new debug mesh used to render the impostor
  43507. */
  43508. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43509. /**
  43510. * Hides a specified physic impostor
  43511. * @param impostor defines the impostor to hide
  43512. */
  43513. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43514. private _getDebugMaterial;
  43515. private _getDebugBoxMesh;
  43516. private _getDebugSphereMesh;
  43517. private _getDebugCylinderMesh;
  43518. private _getDebugMeshMesh;
  43519. private _getDebugMesh;
  43520. /** Releases all resources */
  43521. dispose(): void;
  43522. }
  43523. }
  43524. declare module BABYLON {
  43525. /**
  43526. * Class containing static functions to help procedurally build meshes
  43527. */
  43528. export class LinesBuilder {
  43529. /**
  43530. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43531. * * 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
  43532. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43533. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43534. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43535. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43536. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43537. * * 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
  43538. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43541. * @param name defines the name of the new line system
  43542. * @param options defines the options used to create the line system
  43543. * @param scene defines the hosting scene
  43544. * @returns a new line system mesh
  43545. */
  43546. static CreateLineSystem(name: string, options: {
  43547. lines: Vector3[][];
  43548. updatable?: boolean;
  43549. instance?: Nullable<LinesMesh>;
  43550. colors?: Nullable<Color4[][]>;
  43551. useVertexAlpha?: boolean;
  43552. }, scene: Nullable<Scene>): LinesMesh;
  43553. /**
  43554. * Creates a line mesh
  43555. * 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
  43556. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43557. * * The parameter `points` is an array successive Vector3
  43558. * * 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
  43559. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43560. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43561. * * When updating an instance, remember that only point positions can change, not the number of points
  43562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43564. * @param name defines the name of the new line system
  43565. * @param options defines the options used to create the line system
  43566. * @param scene defines the hosting scene
  43567. * @returns a new line mesh
  43568. */
  43569. static CreateLines(name: string, options: {
  43570. points: Vector3[];
  43571. updatable?: boolean;
  43572. instance?: Nullable<LinesMesh>;
  43573. colors?: Color4[];
  43574. useVertexAlpha?: boolean;
  43575. }, scene?: Nullable<Scene>): LinesMesh;
  43576. /**
  43577. * Creates a dashed line mesh
  43578. * * 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
  43579. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43580. * * The parameter `points` is an array successive Vector3
  43581. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43582. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43583. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43584. * * 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
  43585. * * When updating an instance, remember that only point positions can change, not the number of points
  43586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43587. * @param name defines the name of the mesh
  43588. * @param options defines the options used to create the mesh
  43589. * @param scene defines the hosting scene
  43590. * @returns the dashed line mesh
  43591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43592. */
  43593. static CreateDashedLines(name: string, options: {
  43594. points: Vector3[];
  43595. dashSize?: number;
  43596. gapSize?: number;
  43597. dashNb?: number;
  43598. updatable?: boolean;
  43599. instance?: LinesMesh;
  43600. }, scene?: Nullable<Scene>): LinesMesh;
  43601. }
  43602. }
  43603. declare module BABYLON {
  43604. /**
  43605. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43606. * in order to better appreciate the issue one might have.
  43607. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43608. */
  43609. export class RayHelper {
  43610. /**
  43611. * Defines the ray we are currently tryin to visualize.
  43612. */
  43613. ray: Nullable<Ray>;
  43614. private _renderPoints;
  43615. private _renderLine;
  43616. private _renderFunction;
  43617. private _scene;
  43618. private _updateToMeshFunction;
  43619. private _attachedToMesh;
  43620. private _meshSpaceDirection;
  43621. private _meshSpaceOrigin;
  43622. /**
  43623. * Helper function to create a colored helper in a scene in one line.
  43624. * @param ray Defines the ray we are currently tryin to visualize
  43625. * @param scene Defines the scene the ray is used in
  43626. * @param color Defines the color we want to see the ray in
  43627. * @returns The newly created ray helper.
  43628. */
  43629. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43630. /**
  43631. * Instantiate a new ray helper.
  43632. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43633. * in order to better appreciate the issue one might have.
  43634. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43635. * @param ray Defines the ray we are currently tryin to visualize
  43636. */
  43637. constructor(ray: Ray);
  43638. /**
  43639. * Shows the ray we are willing to debug.
  43640. * @param scene Defines the scene the ray needs to be rendered in
  43641. * @param color Defines the color the ray needs to be rendered in
  43642. */
  43643. show(scene: Scene, color?: Color3): void;
  43644. /**
  43645. * Hides the ray we are debugging.
  43646. */
  43647. hide(): void;
  43648. private _render;
  43649. /**
  43650. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43651. * @param mesh Defines the mesh we want the helper attached to
  43652. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43653. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43654. * @param length Defines the length of the ray
  43655. */
  43656. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43657. /**
  43658. * Detach the ray helper from the mesh it has previously been attached to.
  43659. */
  43660. detachFromMesh(): void;
  43661. private _updateToMesh;
  43662. /**
  43663. * Dispose the helper and release its associated resources.
  43664. */
  43665. dispose(): void;
  43666. }
  43667. }
  43668. declare module BABYLON.Debug {
  43669. /**
  43670. * Class used to render a debug view of a given skeleton
  43671. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43672. */
  43673. export class SkeletonViewer {
  43674. /** defines the skeleton to render */
  43675. skeleton: Skeleton;
  43676. /** defines the mesh attached to the skeleton */
  43677. mesh: AbstractMesh;
  43678. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43679. autoUpdateBonesMatrices: boolean;
  43680. /** defines the rendering group id to use with the viewer */
  43681. renderingGroupId: number;
  43682. /** Gets or sets the color used to render the skeleton */
  43683. color: Color3;
  43684. private _scene;
  43685. private _debugLines;
  43686. private _debugMesh;
  43687. private _isEnabled;
  43688. private _renderFunction;
  43689. private _utilityLayer;
  43690. /**
  43691. * Returns the mesh used to render the bones
  43692. */
  43693. readonly debugMesh: Nullable<LinesMesh>;
  43694. /**
  43695. * Creates a new SkeletonViewer
  43696. * @param skeleton defines the skeleton to render
  43697. * @param mesh defines the mesh attached to the skeleton
  43698. * @param scene defines the hosting scene
  43699. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43700. * @param renderingGroupId defines the rendering group id to use with the viewer
  43701. */
  43702. constructor(
  43703. /** defines the skeleton to render */
  43704. skeleton: Skeleton,
  43705. /** defines the mesh attached to the skeleton */
  43706. mesh: AbstractMesh, scene: Scene,
  43707. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43708. autoUpdateBonesMatrices?: boolean,
  43709. /** defines the rendering group id to use with the viewer */
  43710. renderingGroupId?: number);
  43711. /** Gets or sets a boolean indicating if the viewer is enabled */
  43712. isEnabled: boolean;
  43713. private _getBonePosition;
  43714. private _getLinesForBonesWithLength;
  43715. private _getLinesForBonesNoLength;
  43716. /** Update the viewer to sync with current skeleton state */
  43717. update(): void;
  43718. /** Release associated resources */
  43719. dispose(): void;
  43720. }
  43721. }
  43722. declare module BABYLON {
  43723. /**
  43724. * Options to create the null engine
  43725. */
  43726. export class NullEngineOptions {
  43727. /**
  43728. * Render width (Default: 512)
  43729. */
  43730. renderWidth: number;
  43731. /**
  43732. * Render height (Default: 256)
  43733. */
  43734. renderHeight: number;
  43735. /**
  43736. * Texture size (Default: 512)
  43737. */
  43738. textureSize: number;
  43739. /**
  43740. * If delta time between frames should be constant
  43741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43742. */
  43743. deterministicLockstep: boolean;
  43744. /**
  43745. * Maximum about of steps between frames (Default: 4)
  43746. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43747. */
  43748. lockstepMaxSteps: number;
  43749. }
  43750. /**
  43751. * The null engine class provides support for headless version of babylon.js.
  43752. * This can be used in server side scenario or for testing purposes
  43753. */
  43754. export class NullEngine extends Engine {
  43755. private _options;
  43756. /**
  43757. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43759. * @returns true if engine is in deterministic lock step mode
  43760. */
  43761. isDeterministicLockStep(): boolean;
  43762. /**
  43763. * Gets the max steps when engine is running in deterministic lock step
  43764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43765. * @returns the max steps
  43766. */
  43767. getLockstepMaxSteps(): number;
  43768. /**
  43769. * Gets the current hardware scaling level.
  43770. * By default the hardware scaling level is computed from the window device ratio.
  43771. * 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.
  43772. * @returns a number indicating the current hardware scaling level
  43773. */
  43774. getHardwareScalingLevel(): number;
  43775. constructor(options?: NullEngineOptions);
  43776. /**
  43777. * Creates a vertex buffer
  43778. * @param vertices the data for the vertex buffer
  43779. * @returns the new WebGL static buffer
  43780. */
  43781. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43782. /**
  43783. * Creates a new index buffer
  43784. * @param indices defines the content of the index buffer
  43785. * @param updatable defines if the index buffer must be updatable
  43786. * @returns a new webGL buffer
  43787. */
  43788. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43789. /**
  43790. * Clear the current render buffer or the current render target (if any is set up)
  43791. * @param color defines the color to use
  43792. * @param backBuffer defines if the back buffer must be cleared
  43793. * @param depth defines if the depth buffer must be cleared
  43794. * @param stencil defines if the stencil buffer must be cleared
  43795. */
  43796. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43797. /**
  43798. * Gets the current render width
  43799. * @param useScreen defines if screen size must be used (or the current render target if any)
  43800. * @returns a number defining the current render width
  43801. */
  43802. getRenderWidth(useScreen?: boolean): number;
  43803. /**
  43804. * Gets the current render height
  43805. * @param useScreen defines if screen size must be used (or the current render target if any)
  43806. * @returns a number defining the current render height
  43807. */
  43808. getRenderHeight(useScreen?: boolean): number;
  43809. /**
  43810. * Set the WebGL's viewport
  43811. * @param viewport defines the viewport element to be used
  43812. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43813. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43814. */
  43815. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43816. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43817. /**
  43818. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43819. * @param pipelineContext defines the pipeline context to use
  43820. * @param uniformsNames defines the list of uniform names
  43821. * @returns an array of webGL uniform locations
  43822. */
  43823. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43824. /**
  43825. * Gets the lsit of active attributes for a given webGL program
  43826. * @param pipelineContext defines the pipeline context to use
  43827. * @param attributesNames defines the list of attribute names to get
  43828. * @returns an array of indices indicating the offset of each attribute
  43829. */
  43830. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43831. /**
  43832. * Binds an effect to the webGL context
  43833. * @param effect defines the effect to bind
  43834. */
  43835. bindSamplers(effect: Effect): void;
  43836. /**
  43837. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43838. * @param effect defines the effect to activate
  43839. */
  43840. enableEffect(effect: Effect): void;
  43841. /**
  43842. * Set various states to the webGL context
  43843. * @param culling defines backface culling state
  43844. * @param zOffset defines the value to apply to zOffset (0 by default)
  43845. * @param force defines if states must be applied even if cache is up to date
  43846. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43847. */
  43848. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43849. /**
  43850. * Set the value of an uniform to an array of int32
  43851. * @param uniform defines the webGL uniform location where to store the value
  43852. * @param array defines the array of int32 to store
  43853. */
  43854. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43855. /**
  43856. * Set the value of an uniform to an array of int32 (stored as vec2)
  43857. * @param uniform defines the webGL uniform location where to store the value
  43858. * @param array defines the array of int32 to store
  43859. */
  43860. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43861. /**
  43862. * Set the value of an uniform to an array of int32 (stored as vec3)
  43863. * @param uniform defines the webGL uniform location where to store the value
  43864. * @param array defines the array of int32 to store
  43865. */
  43866. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43867. /**
  43868. * Set the value of an uniform to an array of int32 (stored as vec4)
  43869. * @param uniform defines the webGL uniform location where to store the value
  43870. * @param array defines the array of int32 to store
  43871. */
  43872. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43873. /**
  43874. * Set the value of an uniform to an array of float32
  43875. * @param uniform defines the webGL uniform location where to store the value
  43876. * @param array defines the array of float32 to store
  43877. */
  43878. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43879. /**
  43880. * Set the value of an uniform to an array of float32 (stored as vec2)
  43881. * @param uniform defines the webGL uniform location where to store the value
  43882. * @param array defines the array of float32 to store
  43883. */
  43884. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43885. /**
  43886. * Set the value of an uniform to an array of float32 (stored as vec3)
  43887. * @param uniform defines the webGL uniform location where to store the value
  43888. * @param array defines the array of float32 to store
  43889. */
  43890. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43891. /**
  43892. * Set the value of an uniform to an array of float32 (stored as vec4)
  43893. * @param uniform defines the webGL uniform location where to store the value
  43894. * @param array defines the array of float32 to store
  43895. */
  43896. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43897. /**
  43898. * Set the value of an uniform to an array of number
  43899. * @param uniform defines the webGL uniform location where to store the value
  43900. * @param array defines the array of number to store
  43901. */
  43902. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43903. /**
  43904. * Set the value of an uniform to an array of number (stored as vec2)
  43905. * @param uniform defines the webGL uniform location where to store the value
  43906. * @param array defines the array of number to store
  43907. */
  43908. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43909. /**
  43910. * Set the value of an uniform to an array of number (stored as vec3)
  43911. * @param uniform defines the webGL uniform location where to store the value
  43912. * @param array defines the array of number to store
  43913. */
  43914. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43915. /**
  43916. * Set the value of an uniform to an array of number (stored as vec4)
  43917. * @param uniform defines the webGL uniform location where to store the value
  43918. * @param array defines the array of number to store
  43919. */
  43920. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43921. /**
  43922. * Set the value of an uniform to an array of float32 (stored as matrices)
  43923. * @param uniform defines the webGL uniform location where to store the value
  43924. * @param matrices defines the array of float32 to store
  43925. */
  43926. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43927. /**
  43928. * Set the value of an uniform to a matrix (3x3)
  43929. * @param uniform defines the webGL uniform location where to store the value
  43930. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43931. */
  43932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43933. /**
  43934. * Set the value of an uniform to a matrix (2x2)
  43935. * @param uniform defines the webGL uniform location where to store the value
  43936. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43937. */
  43938. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43939. /**
  43940. * Set the value of an uniform to a number (float)
  43941. * @param uniform defines the webGL uniform location where to store the value
  43942. * @param value defines the float number to store
  43943. */
  43944. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43945. /**
  43946. * Set the value of an uniform to a vec2
  43947. * @param uniform defines the webGL uniform location where to store the value
  43948. * @param x defines the 1st component of the value
  43949. * @param y defines the 2nd component of the value
  43950. */
  43951. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43952. /**
  43953. * Set the value of an uniform to a vec3
  43954. * @param uniform defines the webGL uniform location where to store the value
  43955. * @param x defines the 1st component of the value
  43956. * @param y defines the 2nd component of the value
  43957. * @param z defines the 3rd component of the value
  43958. */
  43959. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43960. /**
  43961. * Set the value of an uniform to a boolean
  43962. * @param uniform defines the webGL uniform location where to store the value
  43963. * @param bool defines the boolean to store
  43964. */
  43965. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43966. /**
  43967. * Set the value of an uniform to a vec4
  43968. * @param uniform defines the webGL uniform location where to store the value
  43969. * @param x defines the 1st component of the value
  43970. * @param y defines the 2nd component of the value
  43971. * @param z defines the 3rd component of the value
  43972. * @param w defines the 4th component of the value
  43973. */
  43974. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43975. /**
  43976. * Sets the current alpha mode
  43977. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43978. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43980. */
  43981. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43982. /**
  43983. * Bind webGl buffers directly to the webGL context
  43984. * @param vertexBuffers defines the vertex buffer to bind
  43985. * @param indexBuffer defines the index buffer to bind
  43986. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43987. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43988. * @param effect defines the effect associated with the vertex buffer
  43989. */
  43990. bindBuffers(vertexBuffers: {
  43991. [key: string]: VertexBuffer;
  43992. }, indexBuffer: DataBuffer, effect: Effect): void;
  43993. /**
  43994. * Force the entire cache to be cleared
  43995. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43996. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43997. */
  43998. wipeCaches(bruteForce?: boolean): void;
  43999. /**
  44000. * Send a draw order
  44001. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44002. * @param indexStart defines the starting index
  44003. * @param indexCount defines the number of index to draw
  44004. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44005. */
  44006. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44007. /**
  44008. * Draw a list of indexed primitives
  44009. * @param fillMode defines the primitive to use
  44010. * @param indexStart defines the starting index
  44011. * @param indexCount defines the number of index to draw
  44012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44013. */
  44014. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44015. /**
  44016. * Draw a list of unindexed primitives
  44017. * @param fillMode defines the primitive to use
  44018. * @param verticesStart defines the index of first vertex to draw
  44019. * @param verticesCount defines the count of vertices to draw
  44020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44021. */
  44022. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44023. /** @hidden */
  44024. _createTexture(): WebGLTexture;
  44025. /** @hidden */
  44026. _releaseTexture(texture: InternalTexture): void;
  44027. /**
  44028. * Usually called from Texture.ts.
  44029. * Passed information to create a WebGLTexture
  44030. * @param urlArg defines a value which contains one of the following:
  44031. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44032. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44033. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44034. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44035. * @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)
  44036. * @param scene needed for loading to the correct scene
  44037. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44038. * @param onLoad optional callback to be called upon successful completion
  44039. * @param onError optional callback to be called upon failure
  44040. * @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
  44041. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44042. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44043. * @param forcedExtension defines the extension to use to pick the right loader
  44044. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44045. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44046. */
  44047. 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;
  44048. /**
  44049. * Creates a new render target texture
  44050. * @param size defines the size of the texture
  44051. * @param options defines the options used to create the texture
  44052. * @returns a new render target texture stored in an InternalTexture
  44053. */
  44054. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44055. /**
  44056. * Update the sampling mode of a given texture
  44057. * @param samplingMode defines the required sampling mode
  44058. * @param texture defines the texture to update
  44059. */
  44060. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44061. /**
  44062. * Binds the frame buffer to the specified texture.
  44063. * @param texture The texture to render to or null for the default canvas
  44064. * @param faceIndex The face of the texture to render to in case of cube texture
  44065. * @param requiredWidth The width of the target to render to
  44066. * @param requiredHeight The height of the target to render to
  44067. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44068. * @param depthStencilTexture The depth stencil texture to use to render
  44069. * @param lodLevel defines le lod level to bind to the frame buffer
  44070. */
  44071. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44072. /**
  44073. * Unbind the current render target texture from the webGL context
  44074. * @param texture defines the render target texture to unbind
  44075. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44076. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44077. */
  44078. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44079. /**
  44080. * Creates a dynamic vertex buffer
  44081. * @param vertices the data for the dynamic vertex buffer
  44082. * @returns the new WebGL dynamic buffer
  44083. */
  44084. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44085. /**
  44086. * Update the content of a dynamic texture
  44087. * @param texture defines the texture to update
  44088. * @param canvas defines the canvas containing the source
  44089. * @param invertY defines if data must be stored with Y axis inverted
  44090. * @param premulAlpha defines if alpha is stored as premultiplied
  44091. * @param format defines the format of the data
  44092. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44093. */
  44094. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44095. /**
  44096. * Gets a boolean indicating if all created effects are ready
  44097. * @returns true if all effects are ready
  44098. */
  44099. areAllEffectsReady(): boolean;
  44100. /**
  44101. * @hidden
  44102. * Get the current error code of the webGL context
  44103. * @returns the error code
  44104. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44105. */
  44106. getError(): number;
  44107. /** @hidden */
  44108. _getUnpackAlignement(): number;
  44109. /** @hidden */
  44110. _unpackFlipY(value: boolean): void;
  44111. /**
  44112. * Update a dynamic index buffer
  44113. * @param indexBuffer defines the target index buffer
  44114. * @param indices defines the data to update
  44115. * @param offset defines the offset in the target index buffer where update should start
  44116. */
  44117. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44118. /**
  44119. * Updates a dynamic vertex buffer.
  44120. * @param vertexBuffer the vertex buffer to update
  44121. * @param vertices the data used to update the vertex buffer
  44122. * @param byteOffset the byte offset of the data (optional)
  44123. * @param byteLength the byte length of the data (optional)
  44124. */
  44125. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44126. /** @hidden */
  44127. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44128. /** @hidden */
  44129. _bindTexture(channel: number, texture: InternalTexture): void;
  44130. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44131. /**
  44132. * 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
  44133. */
  44134. releaseEffects(): void;
  44135. displayLoadingUI(): void;
  44136. hideLoadingUI(): void;
  44137. /** @hidden */
  44138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44139. /** @hidden */
  44140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44141. /** @hidden */
  44142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44143. /** @hidden */
  44144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44145. }
  44146. }
  44147. declare module BABYLON {
  44148. /** @hidden */
  44149. export class _OcclusionDataStorage {
  44150. /** @hidden */
  44151. occlusionInternalRetryCounter: number;
  44152. /** @hidden */
  44153. isOcclusionQueryInProgress: boolean;
  44154. /** @hidden */
  44155. isOccluded: boolean;
  44156. /** @hidden */
  44157. occlusionRetryCount: number;
  44158. /** @hidden */
  44159. occlusionType: number;
  44160. /** @hidden */
  44161. occlusionQueryAlgorithmType: number;
  44162. }
  44163. interface Engine {
  44164. /**
  44165. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44166. * @return the new query
  44167. */
  44168. createQuery(): WebGLQuery;
  44169. /**
  44170. * Delete and release a webGL query
  44171. * @param query defines the query to delete
  44172. * @return the current engine
  44173. */
  44174. deleteQuery(query: WebGLQuery): Engine;
  44175. /**
  44176. * Check if a given query has resolved and got its value
  44177. * @param query defines the query to check
  44178. * @returns true if the query got its value
  44179. */
  44180. isQueryResultAvailable(query: WebGLQuery): boolean;
  44181. /**
  44182. * Gets the value of a given query
  44183. * @param query defines the query to check
  44184. * @returns the value of the query
  44185. */
  44186. getQueryResult(query: WebGLQuery): number;
  44187. /**
  44188. * Initiates an occlusion query
  44189. * @param algorithmType defines the algorithm to use
  44190. * @param query defines the query to use
  44191. * @returns the current engine
  44192. * @see http://doc.babylonjs.com/features/occlusionquery
  44193. */
  44194. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44195. /**
  44196. * Ends an occlusion query
  44197. * @see http://doc.babylonjs.com/features/occlusionquery
  44198. * @param algorithmType defines the algorithm to use
  44199. * @returns the current engine
  44200. */
  44201. endOcclusionQuery(algorithmType: number): Engine;
  44202. /**
  44203. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44204. * Please note that only one query can be issued at a time
  44205. * @returns a time token used to track the time span
  44206. */
  44207. startTimeQuery(): Nullable<_TimeToken>;
  44208. /**
  44209. * Ends a time query
  44210. * @param token defines the token used to measure the time span
  44211. * @returns the time spent (in ns)
  44212. */
  44213. endTimeQuery(token: _TimeToken): int;
  44214. /** @hidden */
  44215. _currentNonTimestampToken: Nullable<_TimeToken>;
  44216. /** @hidden */
  44217. _createTimeQuery(): WebGLQuery;
  44218. /** @hidden */
  44219. _deleteTimeQuery(query: WebGLQuery): void;
  44220. /** @hidden */
  44221. _getGlAlgorithmType(algorithmType: number): number;
  44222. /** @hidden */
  44223. _getTimeQueryResult(query: WebGLQuery): any;
  44224. /** @hidden */
  44225. _getTimeQueryAvailability(query: WebGLQuery): any;
  44226. }
  44227. interface AbstractMesh {
  44228. /**
  44229. * Backing filed
  44230. * @hidden
  44231. */
  44232. __occlusionDataStorage: _OcclusionDataStorage;
  44233. /**
  44234. * Access property
  44235. * @hidden
  44236. */
  44237. _occlusionDataStorage: _OcclusionDataStorage;
  44238. /**
  44239. * 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.
  44240. * The default value is -1 which means don't break the query and wait till the result
  44241. * @see http://doc.babylonjs.com/features/occlusionquery
  44242. */
  44243. occlusionRetryCount: number;
  44244. /**
  44245. * 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:
  44246. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44247. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44248. * * 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.
  44249. * @see http://doc.babylonjs.com/features/occlusionquery
  44250. */
  44251. occlusionType: number;
  44252. /**
  44253. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44254. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44255. * * 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.
  44256. * @see http://doc.babylonjs.com/features/occlusionquery
  44257. */
  44258. occlusionQueryAlgorithmType: number;
  44259. /**
  44260. * 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
  44261. * @see http://doc.babylonjs.com/features/occlusionquery
  44262. */
  44263. isOccluded: boolean;
  44264. /**
  44265. * Flag to check the progress status of the query
  44266. * @see http://doc.babylonjs.com/features/occlusionquery
  44267. */
  44268. isOcclusionQueryInProgress: boolean;
  44269. }
  44270. }
  44271. declare module BABYLON {
  44272. /** @hidden */
  44273. export var _forceTransformFeedbackToBundle: boolean;
  44274. interface Engine {
  44275. /**
  44276. * Creates a webGL transform feedback object
  44277. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44278. * @returns the webGL transform feedback object
  44279. */
  44280. createTransformFeedback(): WebGLTransformFeedback;
  44281. /**
  44282. * Delete a webGL transform feedback object
  44283. * @param value defines the webGL transform feedback object to delete
  44284. */
  44285. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44286. /**
  44287. * Bind a webGL transform feedback object to the webgl context
  44288. * @param value defines the webGL transform feedback object to bind
  44289. */
  44290. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44291. /**
  44292. * Begins a transform feedback operation
  44293. * @param usePoints defines if points or triangles must be used
  44294. */
  44295. beginTransformFeedback(usePoints: boolean): void;
  44296. /**
  44297. * Ends a transform feedback operation
  44298. */
  44299. endTransformFeedback(): void;
  44300. /**
  44301. * Specify the varyings to use with transform feedback
  44302. * @param program defines the associated webGL program
  44303. * @param value defines the list of strings representing the varying names
  44304. */
  44305. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44306. /**
  44307. * Bind a webGL buffer for a transform feedback operation
  44308. * @param value defines the webGL buffer to bind
  44309. */
  44310. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44311. }
  44312. }
  44313. declare module BABYLON {
  44314. /**
  44315. * Creation options of the multi render target texture.
  44316. */
  44317. export interface IMultiRenderTargetOptions {
  44318. /**
  44319. * Define if the texture needs to create mip maps after render.
  44320. */
  44321. generateMipMaps?: boolean;
  44322. /**
  44323. * Define the types of all the draw buffers we want to create
  44324. */
  44325. types?: number[];
  44326. /**
  44327. * Define the sampling modes of all the draw buffers we want to create
  44328. */
  44329. samplingModes?: number[];
  44330. /**
  44331. * Define if a depth buffer is required
  44332. */
  44333. generateDepthBuffer?: boolean;
  44334. /**
  44335. * Define if a stencil buffer is required
  44336. */
  44337. generateStencilBuffer?: boolean;
  44338. /**
  44339. * Define if a depth texture is required instead of a depth buffer
  44340. */
  44341. generateDepthTexture?: boolean;
  44342. /**
  44343. * Define the number of desired draw buffers
  44344. */
  44345. textureCount?: number;
  44346. /**
  44347. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44348. */
  44349. doNotChangeAspectRatio?: boolean;
  44350. /**
  44351. * Define the default type of the buffers we are creating
  44352. */
  44353. defaultType?: number;
  44354. }
  44355. /**
  44356. * A multi render target, like a render target provides the ability to render to a texture.
  44357. * Unlike the render target, it can render to several draw buffers in one draw.
  44358. * This is specially interesting in deferred rendering or for any effects requiring more than
  44359. * just one color from a single pass.
  44360. */
  44361. export class MultiRenderTarget extends RenderTargetTexture {
  44362. private _internalTextures;
  44363. private _textures;
  44364. private _multiRenderTargetOptions;
  44365. /**
  44366. * Get if draw buffers are currently supported by the used hardware and browser.
  44367. */
  44368. readonly isSupported: boolean;
  44369. /**
  44370. * Get the list of textures generated by the multi render target.
  44371. */
  44372. readonly textures: Texture[];
  44373. /**
  44374. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44375. */
  44376. readonly depthTexture: Texture;
  44377. /**
  44378. * Set the wrapping mode on U of all the textures we are rendering to.
  44379. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44380. */
  44381. wrapU: number;
  44382. /**
  44383. * Set the wrapping mode on V of all the textures we are rendering to.
  44384. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44385. */
  44386. wrapV: number;
  44387. /**
  44388. * Instantiate a new multi render target texture.
  44389. * A multi render target, like a render target provides the ability to render to a texture.
  44390. * Unlike the render target, it can render to several draw buffers in one draw.
  44391. * This is specially interesting in deferred rendering or for any effects requiring more than
  44392. * just one color from a single pass.
  44393. * @param name Define the name of the texture
  44394. * @param size Define the size of the buffers to render to
  44395. * @param count Define the number of target we are rendering into
  44396. * @param scene Define the scene the texture belongs to
  44397. * @param options Define the options used to create the multi render target
  44398. */
  44399. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44400. /** @hidden */
  44401. _rebuild(): void;
  44402. private _createInternalTextures;
  44403. private _createTextures;
  44404. /**
  44405. * Define the number of samples used if MSAA is enabled.
  44406. */
  44407. samples: number;
  44408. /**
  44409. * Resize all the textures in the multi render target.
  44410. * Be carrefull as it will recreate all the data in the new texture.
  44411. * @param size Define the new size
  44412. */
  44413. resize(size: any): void;
  44414. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44415. /**
  44416. * Dispose the render targets and their associated resources
  44417. */
  44418. dispose(): void;
  44419. /**
  44420. * Release all the underlying texture used as draw buffers.
  44421. */
  44422. releaseInternalTextures(): void;
  44423. }
  44424. }
  44425. declare module BABYLON {
  44426. interface ThinEngine {
  44427. /**
  44428. * Unbind a list of render target textures from the webGL context
  44429. * This is used only when drawBuffer extension or webGL2 are active
  44430. * @param textures defines the render target textures to unbind
  44431. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44432. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44433. */
  44434. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44435. /**
  44436. * Create a multi render target texture
  44437. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44438. * @param size defines the size of the texture
  44439. * @param options defines the creation options
  44440. * @returns the cube texture as an InternalTexture
  44441. */
  44442. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44443. /**
  44444. * Update the sample count for a given multiple render target texture
  44445. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44446. * @param textures defines the textures to update
  44447. * @param samples defines the sample count to set
  44448. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44449. */
  44450. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44451. }
  44452. }
  44453. declare module BABYLON {
  44454. /**
  44455. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44456. */
  44457. export interface CubeMapInfo {
  44458. /**
  44459. * The pixel array for the front face.
  44460. * This is stored in format, left to right, up to down format.
  44461. */
  44462. front: Nullable<ArrayBufferView>;
  44463. /**
  44464. * The pixel array for the back face.
  44465. * This is stored in format, left to right, up to down format.
  44466. */
  44467. back: Nullable<ArrayBufferView>;
  44468. /**
  44469. * The pixel array for the left face.
  44470. * This is stored in format, left to right, up to down format.
  44471. */
  44472. left: Nullable<ArrayBufferView>;
  44473. /**
  44474. * The pixel array for the right face.
  44475. * This is stored in format, left to right, up to down format.
  44476. */
  44477. right: Nullable<ArrayBufferView>;
  44478. /**
  44479. * The pixel array for the up face.
  44480. * This is stored in format, left to right, up to down format.
  44481. */
  44482. up: Nullable<ArrayBufferView>;
  44483. /**
  44484. * The pixel array for the down face.
  44485. * This is stored in format, left to right, up to down format.
  44486. */
  44487. down: Nullable<ArrayBufferView>;
  44488. /**
  44489. * The size of the cubemap stored.
  44490. *
  44491. * Each faces will be size * size pixels.
  44492. */
  44493. size: number;
  44494. /**
  44495. * The format of the texture.
  44496. *
  44497. * RGBA, RGB.
  44498. */
  44499. format: number;
  44500. /**
  44501. * The type of the texture data.
  44502. *
  44503. * UNSIGNED_INT, FLOAT.
  44504. */
  44505. type: number;
  44506. /**
  44507. * Specifies whether the texture is in gamma space.
  44508. */
  44509. gammaSpace: boolean;
  44510. }
  44511. /**
  44512. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44513. */
  44514. export class PanoramaToCubeMapTools {
  44515. private static FACE_FRONT;
  44516. private static FACE_BACK;
  44517. private static FACE_RIGHT;
  44518. private static FACE_LEFT;
  44519. private static FACE_DOWN;
  44520. private static FACE_UP;
  44521. /**
  44522. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44523. *
  44524. * @param float32Array The source data.
  44525. * @param inputWidth The width of the input panorama.
  44526. * @param inputHeight The height of the input panorama.
  44527. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44528. * @return The cubemap data
  44529. */
  44530. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44531. private static CreateCubemapTexture;
  44532. private static CalcProjectionSpherical;
  44533. }
  44534. }
  44535. declare module BABYLON {
  44536. /**
  44537. * Helper class dealing with the extraction of spherical polynomial dataArray
  44538. * from a cube map.
  44539. */
  44540. export class CubeMapToSphericalPolynomialTools {
  44541. private static FileFaces;
  44542. /**
  44543. * Converts a texture to the according Spherical Polynomial data.
  44544. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44545. *
  44546. * @param texture The texture to extract the information from.
  44547. * @return The Spherical Polynomial data.
  44548. */
  44549. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44550. /**
  44551. * Converts a cubemap to the according Spherical Polynomial data.
  44552. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44553. *
  44554. * @param cubeInfo The Cube map to extract the information from.
  44555. * @return The Spherical Polynomial data.
  44556. */
  44557. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44558. }
  44559. }
  44560. declare module BABYLON {
  44561. interface BaseTexture {
  44562. /**
  44563. * Get the polynomial representation of the texture data.
  44564. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44565. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44566. */
  44567. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44568. }
  44569. }
  44570. declare module BABYLON {
  44571. /** @hidden */
  44572. export var rgbdEncodePixelShader: {
  44573. name: string;
  44574. shader: string;
  44575. };
  44576. }
  44577. declare module BABYLON {
  44578. /** @hidden */
  44579. export var rgbdDecodePixelShader: {
  44580. name: string;
  44581. shader: string;
  44582. };
  44583. }
  44584. declare module BABYLON {
  44585. /**
  44586. * Raw texture data and descriptor sufficient for WebGL texture upload
  44587. */
  44588. export interface EnvironmentTextureInfo {
  44589. /**
  44590. * Version of the environment map
  44591. */
  44592. version: number;
  44593. /**
  44594. * Width of image
  44595. */
  44596. width: number;
  44597. /**
  44598. * Irradiance information stored in the file.
  44599. */
  44600. irradiance: any;
  44601. /**
  44602. * Specular information stored in the file.
  44603. */
  44604. specular: any;
  44605. }
  44606. /**
  44607. * Defines One Image in the file. It requires only the position in the file
  44608. * as well as the length.
  44609. */
  44610. interface BufferImageData {
  44611. /**
  44612. * Length of the image data.
  44613. */
  44614. length: number;
  44615. /**
  44616. * Position of the data from the null terminator delimiting the end of the JSON.
  44617. */
  44618. position: number;
  44619. }
  44620. /**
  44621. * Defines the specular data enclosed in the file.
  44622. * This corresponds to the version 1 of the data.
  44623. */
  44624. export interface EnvironmentTextureSpecularInfoV1 {
  44625. /**
  44626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44627. */
  44628. specularDataPosition?: number;
  44629. /**
  44630. * This contains all the images data needed to reconstruct the cubemap.
  44631. */
  44632. mipmaps: Array<BufferImageData>;
  44633. /**
  44634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44635. */
  44636. lodGenerationScale: number;
  44637. }
  44638. /**
  44639. * Sets of helpers addressing the serialization and deserialization of environment texture
  44640. * stored in a BabylonJS env file.
  44641. * Those files are usually stored as .env files.
  44642. */
  44643. export class EnvironmentTextureTools {
  44644. /**
  44645. * Magic number identifying the env file.
  44646. */
  44647. private static _MagicBytes;
  44648. /**
  44649. * Gets the environment info from an env file.
  44650. * @param data The array buffer containing the .env bytes.
  44651. * @returns the environment file info (the json header) if successfully parsed.
  44652. */
  44653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44654. /**
  44655. * Creates an environment texture from a loaded cube texture.
  44656. * @param texture defines the cube texture to convert in env file
  44657. * @return a promise containing the environment data if succesfull.
  44658. */
  44659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44660. /**
  44661. * Creates a JSON representation of the spherical data.
  44662. * @param texture defines the texture containing the polynomials
  44663. * @return the JSON representation of the spherical info
  44664. */
  44665. private static _CreateEnvTextureIrradiance;
  44666. /**
  44667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44670. * @return the views described by info providing access to the underlying buffer
  44671. */
  44672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44673. /**
  44674. * Uploads the texture info contained in the env file to the GPU.
  44675. * @param texture defines the internal texture to upload to
  44676. * @param arrayBuffer defines the buffer cotaining the data to load
  44677. * @param info defines the texture info retrieved through the GetEnvInfo method
  44678. * @returns a promise
  44679. */
  44680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44681. private static _OnImageReadyAsync;
  44682. /**
  44683. * Uploads the levels of image data to the GPU.
  44684. * @param texture defines the internal texture to upload to
  44685. * @param imageData defines the array buffer views of image data [mipmap][face]
  44686. * @returns a promise
  44687. */
  44688. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44689. /**
  44690. * Uploads spherical polynomials information to the texture.
  44691. * @param texture defines the texture we are trying to upload the information to
  44692. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44693. */
  44694. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44695. /** @hidden */
  44696. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44697. }
  44698. }
  44699. declare module BABYLON {
  44700. /**
  44701. * Contains position and normal vectors for a vertex
  44702. */
  44703. export class PositionNormalVertex {
  44704. /** the position of the vertex (defaut: 0,0,0) */
  44705. position: Vector3;
  44706. /** the normal of the vertex (defaut: 0,1,0) */
  44707. normal: Vector3;
  44708. /**
  44709. * Creates a PositionNormalVertex
  44710. * @param position the position of the vertex (defaut: 0,0,0)
  44711. * @param normal the normal of the vertex (defaut: 0,1,0)
  44712. */
  44713. constructor(
  44714. /** the position of the vertex (defaut: 0,0,0) */
  44715. position?: Vector3,
  44716. /** the normal of the vertex (defaut: 0,1,0) */
  44717. normal?: Vector3);
  44718. /**
  44719. * Clones the PositionNormalVertex
  44720. * @returns the cloned PositionNormalVertex
  44721. */
  44722. clone(): PositionNormalVertex;
  44723. }
  44724. /**
  44725. * Contains position, normal and uv vectors for a vertex
  44726. */
  44727. export class PositionNormalTextureVertex {
  44728. /** the position of the vertex (defaut: 0,0,0) */
  44729. position: Vector3;
  44730. /** the normal of the vertex (defaut: 0,1,0) */
  44731. normal: Vector3;
  44732. /** the uv of the vertex (default: 0,0) */
  44733. uv: Vector2;
  44734. /**
  44735. * Creates a PositionNormalTextureVertex
  44736. * @param position the position of the vertex (defaut: 0,0,0)
  44737. * @param normal the normal of the vertex (defaut: 0,1,0)
  44738. * @param uv the uv of the vertex (default: 0,0)
  44739. */
  44740. constructor(
  44741. /** the position of the vertex (defaut: 0,0,0) */
  44742. position?: Vector3,
  44743. /** the normal of the vertex (defaut: 0,1,0) */
  44744. normal?: Vector3,
  44745. /** the uv of the vertex (default: 0,0) */
  44746. uv?: Vector2);
  44747. /**
  44748. * Clones the PositionNormalTextureVertex
  44749. * @returns the cloned PositionNormalTextureVertex
  44750. */
  44751. clone(): PositionNormalTextureVertex;
  44752. }
  44753. }
  44754. declare module BABYLON {
  44755. /** @hidden */
  44756. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44757. private _genericAttributeLocation;
  44758. private _varyingLocationCount;
  44759. private _varyingLocationMap;
  44760. private _replacements;
  44761. private _textureCount;
  44762. private _uniforms;
  44763. lineProcessor(line: string): string;
  44764. attributeProcessor(attribute: string): string;
  44765. varyingProcessor(varying: string, isFragment: boolean): string;
  44766. uniformProcessor(uniform: string): string;
  44767. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44768. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44769. }
  44770. }
  44771. declare module BABYLON {
  44772. /**
  44773. * Container for accessors for natively-stored mesh data buffers.
  44774. */
  44775. class NativeDataBuffer extends DataBuffer {
  44776. /**
  44777. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44778. */
  44779. nativeIndexBuffer?: any;
  44780. /**
  44781. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44782. */
  44783. nativeVertexBuffer?: any;
  44784. }
  44785. /** @hidden */
  44786. export class NativeEngine extends Engine {
  44787. private readonly _native;
  44788. getHardwareScalingLevel(): number;
  44789. constructor();
  44790. /**
  44791. * Can be used to override the current requestAnimationFrame requester.
  44792. * @hidden
  44793. */
  44794. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44795. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44796. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44797. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44798. recordVertexArrayObject(vertexBuffers: {
  44799. [key: string]: VertexBuffer;
  44800. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44801. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44802. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44803. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44804. /**
  44805. * Draw a list of indexed primitives
  44806. * @param fillMode defines the primitive to use
  44807. * @param indexStart defines the starting index
  44808. * @param indexCount defines the number of index to draw
  44809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44810. */
  44811. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44812. /**
  44813. * Draw a list of unindexed primitives
  44814. * @param fillMode defines the primitive to use
  44815. * @param verticesStart defines the index of first vertex to draw
  44816. * @param verticesCount defines the count of vertices to draw
  44817. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44818. */
  44819. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44820. createPipelineContext(): IPipelineContext;
  44821. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44822. /** @hidden */
  44823. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44824. /** @hidden */
  44825. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44826. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44827. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44828. protected _setProgram(program: WebGLProgram): void;
  44829. _releaseEffect(effect: Effect): void;
  44830. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44831. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44832. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44833. bindSamplers(effect: Effect): void;
  44834. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44835. getRenderWidth(useScreen?: boolean): number;
  44836. getRenderHeight(useScreen?: boolean): number;
  44837. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44838. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44839. /**
  44840. * Set the z offset to apply to current rendering
  44841. * @param value defines the offset to apply
  44842. */
  44843. setZOffset(value: number): void;
  44844. /**
  44845. * Gets the current value of the zOffset
  44846. * @returns the current zOffset state
  44847. */
  44848. getZOffset(): number;
  44849. /**
  44850. * Enable or disable depth buffering
  44851. * @param enable defines the state to set
  44852. */
  44853. setDepthBuffer(enable: boolean): void;
  44854. /**
  44855. * Gets a boolean indicating if depth writing is enabled
  44856. * @returns the current depth writing state
  44857. */
  44858. getDepthWrite(): boolean;
  44859. /**
  44860. * Enable or disable depth writing
  44861. * @param enable defines the state to set
  44862. */
  44863. setDepthWrite(enable: boolean): void;
  44864. /**
  44865. * Enable or disable color writing
  44866. * @param enable defines the state to set
  44867. */
  44868. setColorWrite(enable: boolean): void;
  44869. /**
  44870. * Gets a boolean indicating if color writing is enabled
  44871. * @returns the current color writing state
  44872. */
  44873. getColorWrite(): boolean;
  44874. /**
  44875. * Sets alpha constants used by some alpha blending modes
  44876. * @param r defines the red component
  44877. * @param g defines the green component
  44878. * @param b defines the blue component
  44879. * @param a defines the alpha component
  44880. */
  44881. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44882. /**
  44883. * Sets the current alpha mode
  44884. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44885. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44886. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44887. */
  44888. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44889. /**
  44890. * Gets the current alpha mode
  44891. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44892. * @returns the current alpha mode
  44893. */
  44894. getAlphaMode(): number;
  44895. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44896. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44897. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44898. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44899. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44900. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44901. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44902. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44903. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44904. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44905. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44906. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44907. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44908. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44909. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44910. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44911. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44912. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44913. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44914. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44915. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44916. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44917. wipeCaches(bruteForce?: boolean): void;
  44918. _createTexture(): WebGLTexture;
  44919. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44920. /**
  44921. * Usually called from BABYLON.Texture.ts.
  44922. * Passed information to create a WebGLTexture
  44923. * @param urlArg defines a value which contains one of the following:
  44924. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44925. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44926. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44927. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44928. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44929. * @param scene needed for loading to the correct scene
  44930. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44931. * @param onLoad optional callback to be called upon successful completion
  44932. * @param onError optional callback to be called upon failure
  44933. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44934. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44935. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44936. * @param forcedExtension defines the extension to use to pick the right loader
  44937. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44938. */
  44939. 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;
  44940. /**
  44941. * Creates a cube texture
  44942. * @param rootUrl defines the url where the files to load is located
  44943. * @param scene defines the current scene
  44944. * @param files defines the list of files to load (1 per face)
  44945. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44946. * @param onLoad defines an optional callback raised when the texture is loaded
  44947. * @param onError defines an optional callback raised if there is an issue to load the texture
  44948. * @param format defines the format of the data
  44949. * @param forcedExtension defines the extension to use to pick the right loader
  44950. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44953. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44954. * @returns the cube texture as an InternalTexture
  44955. */
  44956. 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;
  44957. private _getSamplingFilter;
  44958. private static _GetNativeTextureFormat;
  44959. createRenderTargetTexture(size: number | {
  44960. width: number;
  44961. height: number;
  44962. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44963. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44964. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44965. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44966. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44967. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44968. /**
  44969. * Updates a dynamic vertex buffer.
  44970. * @param vertexBuffer the vertex buffer to update
  44971. * @param data the data used to update the vertex buffer
  44972. * @param byteOffset the byte offset of the data (optional)
  44973. * @param byteLength the byte length of the data (optional)
  44974. */
  44975. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44976. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44977. private _updateAnisotropicLevel;
  44978. private _getAddressMode;
  44979. /** @hidden */
  44980. _bindTexture(channel: number, texture: InternalTexture): void;
  44981. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44982. releaseEffects(): void;
  44983. /** @hidden */
  44984. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44985. /** @hidden */
  44986. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44987. /** @hidden */
  44988. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44989. /** @hidden */
  44990. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44991. }
  44992. }
  44993. declare module BABYLON {
  44994. /**
  44995. * Gather the list of clipboard event types as constants.
  44996. */
  44997. export class ClipboardEventTypes {
  44998. /**
  44999. * The clipboard event is fired when a copy command is active (pressed).
  45000. */
  45001. static readonly COPY: number;
  45002. /**
  45003. * The clipboard event is fired when a cut command is active (pressed).
  45004. */
  45005. static readonly CUT: number;
  45006. /**
  45007. * The clipboard event is fired when a paste command is active (pressed).
  45008. */
  45009. static readonly PASTE: number;
  45010. }
  45011. /**
  45012. * This class is used to store clipboard related info for the onClipboardObservable event.
  45013. */
  45014. export class ClipboardInfo {
  45015. /**
  45016. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45017. */
  45018. type: number;
  45019. /**
  45020. * Defines the related dom event
  45021. */
  45022. event: ClipboardEvent;
  45023. /**
  45024. *Creates an instance of ClipboardInfo.
  45025. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45026. * @param event Defines the related dom event
  45027. */
  45028. constructor(
  45029. /**
  45030. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45031. */
  45032. type: number,
  45033. /**
  45034. * Defines the related dom event
  45035. */
  45036. event: ClipboardEvent);
  45037. /**
  45038. * Get the clipboard event's type from the keycode.
  45039. * @param keyCode Defines the keyCode for the current keyboard event.
  45040. * @return {number}
  45041. */
  45042. static GetTypeFromCharacter(keyCode: number): number;
  45043. }
  45044. }
  45045. declare module BABYLON {
  45046. /**
  45047. * Google Daydream controller
  45048. */
  45049. export class DaydreamController extends WebVRController {
  45050. /**
  45051. * Base Url for the controller model.
  45052. */
  45053. static MODEL_BASE_URL: string;
  45054. /**
  45055. * File name for the controller model.
  45056. */
  45057. static MODEL_FILENAME: string;
  45058. /**
  45059. * Gamepad Id prefix used to identify Daydream Controller.
  45060. */
  45061. static readonly GAMEPAD_ID_PREFIX: string;
  45062. /**
  45063. * Creates a new DaydreamController from a gamepad
  45064. * @param vrGamepad the gamepad that the controller should be created from
  45065. */
  45066. constructor(vrGamepad: any);
  45067. /**
  45068. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45069. * @param scene scene in which to add meshes
  45070. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45071. */
  45072. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45073. /**
  45074. * Called once for each button that changed state since the last frame
  45075. * @param buttonIdx Which button index changed
  45076. * @param state New state of the button
  45077. * @param changes Which properties on the state changed since last frame
  45078. */
  45079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45080. }
  45081. }
  45082. declare module BABYLON {
  45083. /**
  45084. * Gear VR Controller
  45085. */
  45086. export class GearVRController extends WebVRController {
  45087. /**
  45088. * Base Url for the controller model.
  45089. */
  45090. static MODEL_BASE_URL: string;
  45091. /**
  45092. * File name for the controller model.
  45093. */
  45094. static MODEL_FILENAME: string;
  45095. /**
  45096. * Gamepad Id prefix used to identify this controller.
  45097. */
  45098. static readonly GAMEPAD_ID_PREFIX: string;
  45099. private readonly _buttonIndexToObservableNameMap;
  45100. /**
  45101. * Creates a new GearVRController from a gamepad
  45102. * @param vrGamepad the gamepad that the controller should be created from
  45103. */
  45104. constructor(vrGamepad: any);
  45105. /**
  45106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45107. * @param scene scene in which to add meshes
  45108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45109. */
  45110. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45111. /**
  45112. * Called once for each button that changed state since the last frame
  45113. * @param buttonIdx Which button index changed
  45114. * @param state New state of the button
  45115. * @param changes Which properties on the state changed since last frame
  45116. */
  45117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45118. }
  45119. }
  45120. declare module BABYLON {
  45121. /**
  45122. * Class containing static functions to help procedurally build meshes
  45123. */
  45124. export class PolyhedronBuilder {
  45125. /**
  45126. * Creates a polyhedron mesh
  45127. * * 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
  45128. * * The parameter `size` (positive float, default 1) sets the polygon size
  45129. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45130. * * 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`
  45131. * * 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
  45132. * * 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)`)
  45133. * * 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
  45134. * * 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
  45135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45136. * * 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
  45137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45138. * @param name defines the name of the mesh
  45139. * @param options defines the options used to create the mesh
  45140. * @param scene defines the hosting scene
  45141. * @returns the polyhedron mesh
  45142. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45143. */
  45144. static CreatePolyhedron(name: string, options: {
  45145. type?: number;
  45146. size?: number;
  45147. sizeX?: number;
  45148. sizeY?: number;
  45149. sizeZ?: number;
  45150. custom?: any;
  45151. faceUV?: Vector4[];
  45152. faceColors?: Color4[];
  45153. flat?: boolean;
  45154. updatable?: boolean;
  45155. sideOrientation?: number;
  45156. frontUVs?: Vector4;
  45157. backUVs?: Vector4;
  45158. }, scene?: Nullable<Scene>): Mesh;
  45159. }
  45160. }
  45161. declare module BABYLON {
  45162. /**
  45163. * Gizmo that enables scaling a mesh along 3 axis
  45164. */
  45165. export class ScaleGizmo extends Gizmo {
  45166. /**
  45167. * Internal gizmo used for interactions on the x axis
  45168. */
  45169. xGizmo: AxisScaleGizmo;
  45170. /**
  45171. * Internal gizmo used for interactions on the y axis
  45172. */
  45173. yGizmo: AxisScaleGizmo;
  45174. /**
  45175. * Internal gizmo used for interactions on the z axis
  45176. */
  45177. zGizmo: AxisScaleGizmo;
  45178. /**
  45179. * Internal gizmo used to scale all axis equally
  45180. */
  45181. uniformScaleGizmo: AxisScaleGizmo;
  45182. private _meshAttached;
  45183. private _updateGizmoRotationToMatchAttachedMesh;
  45184. private _snapDistance;
  45185. private _scaleRatio;
  45186. private _uniformScalingMesh;
  45187. private _octahedron;
  45188. /** Fires an event when any of it's sub gizmos are dragged */
  45189. onDragStartObservable: Observable<unknown>;
  45190. /** Fires an event when any of it's sub gizmos are released from dragging */
  45191. onDragEndObservable: Observable<unknown>;
  45192. attachedMesh: Nullable<AbstractMesh>;
  45193. /**
  45194. * Creates a ScaleGizmo
  45195. * @param gizmoLayer The utility layer the gizmo will be added to
  45196. */
  45197. constructor(gizmoLayer?: UtilityLayerRenderer);
  45198. updateGizmoRotationToMatchAttachedMesh: boolean;
  45199. /**
  45200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45201. */
  45202. snapDistance: number;
  45203. /**
  45204. * Ratio for the scale of the gizmo (Default: 1)
  45205. */
  45206. scaleRatio: number;
  45207. /**
  45208. * Disposes of the gizmo
  45209. */
  45210. dispose(): void;
  45211. }
  45212. }
  45213. declare module BABYLON {
  45214. /**
  45215. * Single axis scale gizmo
  45216. */
  45217. export class AxisScaleGizmo extends Gizmo {
  45218. /**
  45219. * Drag behavior responsible for the gizmos dragging interactions
  45220. */
  45221. dragBehavior: PointerDragBehavior;
  45222. private _pointerObserver;
  45223. /**
  45224. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45225. */
  45226. snapDistance: number;
  45227. /**
  45228. * Event that fires each time the gizmo snaps to a new location.
  45229. * * snapDistance is the the change in distance
  45230. */
  45231. onSnapObservable: Observable<{
  45232. snapDistance: number;
  45233. }>;
  45234. /**
  45235. * If the scaling operation should be done on all axis (default: false)
  45236. */
  45237. uniformScaling: boolean;
  45238. private _isEnabled;
  45239. private _parent;
  45240. private _arrow;
  45241. private _coloredMaterial;
  45242. private _hoverMaterial;
  45243. /**
  45244. * Creates an AxisScaleGizmo
  45245. * @param gizmoLayer The utility layer the gizmo will be added to
  45246. * @param dragAxis The axis which the gizmo will be able to scale on
  45247. * @param color The color of the gizmo
  45248. */
  45249. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45250. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45251. /**
  45252. * If the gizmo is enabled
  45253. */
  45254. isEnabled: boolean;
  45255. /**
  45256. * Disposes of the gizmo
  45257. */
  45258. dispose(): void;
  45259. /**
  45260. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45261. * @param mesh The mesh to replace the default mesh of the gizmo
  45262. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45263. */
  45264. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45265. }
  45266. }
  45267. declare module BABYLON {
  45268. /**
  45269. * Bounding box gizmo
  45270. */
  45271. export class BoundingBoxGizmo extends Gizmo {
  45272. private _lineBoundingBox;
  45273. private _rotateSpheresParent;
  45274. private _scaleBoxesParent;
  45275. private _boundingDimensions;
  45276. private _renderObserver;
  45277. private _pointerObserver;
  45278. private _scaleDragSpeed;
  45279. private _tmpQuaternion;
  45280. private _tmpVector;
  45281. private _tmpRotationMatrix;
  45282. /**
  45283. * 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)
  45284. */
  45285. ignoreChildren: boolean;
  45286. /**
  45287. * 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)
  45288. */
  45289. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45290. /**
  45291. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45292. */
  45293. rotationSphereSize: number;
  45294. /**
  45295. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45296. */
  45297. scaleBoxSize: number;
  45298. /**
  45299. * 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)
  45300. */
  45301. fixedDragMeshScreenSize: boolean;
  45302. /**
  45303. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45304. */
  45305. fixedDragMeshScreenSizeDistanceFactor: number;
  45306. /**
  45307. * Fired when a rotation sphere or scale box is dragged
  45308. */
  45309. onDragStartObservable: Observable<{}>;
  45310. /**
  45311. * Fired when a scale box is dragged
  45312. */
  45313. onScaleBoxDragObservable: Observable<{}>;
  45314. /**
  45315. * Fired when a scale box drag is ended
  45316. */
  45317. onScaleBoxDragEndObservable: Observable<{}>;
  45318. /**
  45319. * Fired when a rotation sphere is dragged
  45320. */
  45321. onRotationSphereDragObservable: Observable<{}>;
  45322. /**
  45323. * Fired when a rotation sphere drag is ended
  45324. */
  45325. onRotationSphereDragEndObservable: Observable<{}>;
  45326. /**
  45327. * 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)
  45328. */
  45329. scalePivot: Nullable<Vector3>;
  45330. /**
  45331. * Mesh used as a pivot to rotate the attached mesh
  45332. */
  45333. private _anchorMesh;
  45334. private _existingMeshScale;
  45335. private _dragMesh;
  45336. private pointerDragBehavior;
  45337. private coloredMaterial;
  45338. private hoverColoredMaterial;
  45339. /**
  45340. * Sets the color of the bounding box gizmo
  45341. * @param color the color to set
  45342. */
  45343. setColor(color: Color3): void;
  45344. /**
  45345. * Creates an BoundingBoxGizmo
  45346. * @param gizmoLayer The utility layer the gizmo will be added to
  45347. * @param color The color of the gizmo
  45348. */
  45349. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45350. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45351. private _selectNode;
  45352. /**
  45353. * Updates the bounding box information for the Gizmo
  45354. */
  45355. updateBoundingBox(): void;
  45356. private _updateRotationSpheres;
  45357. private _updateScaleBoxes;
  45358. /**
  45359. * Enables rotation on the specified axis and disables rotation on the others
  45360. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45361. */
  45362. setEnabledRotationAxis(axis: string): void;
  45363. /**
  45364. * Enables/disables scaling
  45365. * @param enable if scaling should be enabled
  45366. */
  45367. setEnabledScaling(enable: boolean): void;
  45368. private _updateDummy;
  45369. /**
  45370. * Enables a pointer drag behavior on the bounding box of the gizmo
  45371. */
  45372. enableDragBehavior(): void;
  45373. /**
  45374. * Disposes of the gizmo
  45375. */
  45376. dispose(): void;
  45377. /**
  45378. * 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)
  45379. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45380. * @returns the bounding box mesh with the passed in mesh as a child
  45381. */
  45382. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45383. /**
  45384. * CustomMeshes are not supported by this gizmo
  45385. * @param mesh The mesh to replace the default mesh of the gizmo
  45386. */
  45387. setCustomMesh(mesh: Mesh): void;
  45388. }
  45389. }
  45390. declare module BABYLON {
  45391. /**
  45392. * Single plane rotation gizmo
  45393. */
  45394. export class PlaneRotationGizmo extends Gizmo {
  45395. /**
  45396. * Drag behavior responsible for the gizmos dragging interactions
  45397. */
  45398. dragBehavior: PointerDragBehavior;
  45399. private _pointerObserver;
  45400. /**
  45401. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45402. */
  45403. snapDistance: number;
  45404. /**
  45405. * Event that fires each time the gizmo snaps to a new location.
  45406. * * snapDistance is the the change in distance
  45407. */
  45408. onSnapObservable: Observable<{
  45409. snapDistance: number;
  45410. }>;
  45411. private _isEnabled;
  45412. private _parent;
  45413. /**
  45414. * Creates a PlaneRotationGizmo
  45415. * @param gizmoLayer The utility layer the gizmo will be added to
  45416. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45417. * @param color The color of the gizmo
  45418. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45419. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45420. */
  45421. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45423. /**
  45424. * If the gizmo is enabled
  45425. */
  45426. isEnabled: boolean;
  45427. /**
  45428. * Disposes of the gizmo
  45429. */
  45430. dispose(): void;
  45431. }
  45432. }
  45433. declare module BABYLON {
  45434. /**
  45435. * Gizmo that enables rotating a mesh along 3 axis
  45436. */
  45437. export class RotationGizmo extends Gizmo {
  45438. /**
  45439. * Internal gizmo used for interactions on the x axis
  45440. */
  45441. xGizmo: PlaneRotationGizmo;
  45442. /**
  45443. * Internal gizmo used for interactions on the y axis
  45444. */
  45445. yGizmo: PlaneRotationGizmo;
  45446. /**
  45447. * Internal gizmo used for interactions on the z axis
  45448. */
  45449. zGizmo: PlaneRotationGizmo;
  45450. /** Fires an event when any of it's sub gizmos are dragged */
  45451. onDragStartObservable: Observable<unknown>;
  45452. /** Fires an event when any of it's sub gizmos are released from dragging */
  45453. onDragEndObservable: Observable<unknown>;
  45454. private _meshAttached;
  45455. attachedMesh: Nullable<AbstractMesh>;
  45456. /**
  45457. * Creates a RotationGizmo
  45458. * @param gizmoLayer The utility layer the gizmo will be added to
  45459. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45460. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45461. */
  45462. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45463. updateGizmoRotationToMatchAttachedMesh: boolean;
  45464. /**
  45465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45466. */
  45467. snapDistance: number;
  45468. /**
  45469. * Ratio for the scale of the gizmo (Default: 1)
  45470. */
  45471. scaleRatio: number;
  45472. /**
  45473. * Disposes of the gizmo
  45474. */
  45475. dispose(): void;
  45476. /**
  45477. * CustomMeshes are not supported by this gizmo
  45478. * @param mesh The mesh to replace the default mesh of the gizmo
  45479. */
  45480. setCustomMesh(mesh: Mesh): void;
  45481. }
  45482. }
  45483. declare module BABYLON {
  45484. /**
  45485. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45486. */
  45487. export class GizmoManager implements IDisposable {
  45488. private scene;
  45489. /**
  45490. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45491. */
  45492. gizmos: {
  45493. positionGizmo: Nullable<PositionGizmo>;
  45494. rotationGizmo: Nullable<RotationGizmo>;
  45495. scaleGizmo: Nullable<ScaleGizmo>;
  45496. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45497. };
  45498. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45499. clearGizmoOnEmptyPointerEvent: boolean;
  45500. /** Fires an event when the manager is attached to a mesh */
  45501. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45502. private _gizmosEnabled;
  45503. private _pointerObserver;
  45504. private _attachedMesh;
  45505. private _boundingBoxColor;
  45506. private _defaultUtilityLayer;
  45507. private _defaultKeepDepthUtilityLayer;
  45508. /**
  45509. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45510. */
  45511. boundingBoxDragBehavior: SixDofDragBehavior;
  45512. /**
  45513. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45514. */
  45515. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45516. /**
  45517. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45518. */
  45519. usePointerToAttachGizmos: boolean;
  45520. /**
  45521. * Utility layer that the bounding box gizmo belongs to
  45522. */
  45523. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45524. /**
  45525. * Utility layer that all gizmos besides bounding box belong to
  45526. */
  45527. readonly utilityLayer: UtilityLayerRenderer;
  45528. /**
  45529. * Instatiates a gizmo manager
  45530. * @param scene the scene to overlay the gizmos on top of
  45531. */
  45532. constructor(scene: Scene);
  45533. /**
  45534. * Attaches a set of gizmos to the specified mesh
  45535. * @param mesh The mesh the gizmo's should be attached to
  45536. */
  45537. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45538. /**
  45539. * If the position gizmo is enabled
  45540. */
  45541. positionGizmoEnabled: boolean;
  45542. /**
  45543. * If the rotation gizmo is enabled
  45544. */
  45545. rotationGizmoEnabled: boolean;
  45546. /**
  45547. * If the scale gizmo is enabled
  45548. */
  45549. scaleGizmoEnabled: boolean;
  45550. /**
  45551. * If the boundingBox gizmo is enabled
  45552. */
  45553. boundingBoxGizmoEnabled: boolean;
  45554. /**
  45555. * Disposes of the gizmo manager
  45556. */
  45557. dispose(): void;
  45558. }
  45559. }
  45560. declare module BABYLON {
  45561. /**
  45562. * A directional light is defined by a direction (what a surprise!).
  45563. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45564. * 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.
  45565. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45566. */
  45567. export class DirectionalLight extends ShadowLight {
  45568. private _shadowFrustumSize;
  45569. /**
  45570. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45571. */
  45572. /**
  45573. * Specifies a fix frustum size for the shadow generation.
  45574. */
  45575. shadowFrustumSize: number;
  45576. private _shadowOrthoScale;
  45577. /**
  45578. * Gets the shadow projection scale against the optimal computed one.
  45579. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45580. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45581. */
  45582. /**
  45583. * Sets the shadow projection scale against the optimal computed one.
  45584. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45585. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45586. */
  45587. shadowOrthoScale: number;
  45588. /**
  45589. * Automatically compute the projection matrix to best fit (including all the casters)
  45590. * on each frame.
  45591. */
  45592. autoUpdateExtends: boolean;
  45593. private _orthoLeft;
  45594. private _orthoRight;
  45595. private _orthoTop;
  45596. private _orthoBottom;
  45597. /**
  45598. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45599. * The directional light is emitted from everywhere in the given direction.
  45600. * It can cast shadows.
  45601. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45602. * @param name The friendly name of the light
  45603. * @param direction The direction of the light
  45604. * @param scene The scene the light belongs to
  45605. */
  45606. constructor(name: string, direction: Vector3, scene: Scene);
  45607. /**
  45608. * Returns the string "DirectionalLight".
  45609. * @return The class name
  45610. */
  45611. getClassName(): string;
  45612. /**
  45613. * Returns the integer 1.
  45614. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45615. */
  45616. getTypeID(): number;
  45617. /**
  45618. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45619. * Returns the DirectionalLight Shadow projection matrix.
  45620. */
  45621. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45622. /**
  45623. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45624. * Returns the DirectionalLight Shadow projection matrix.
  45625. */
  45626. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45627. /**
  45628. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45629. * Returns the DirectionalLight Shadow projection matrix.
  45630. */
  45631. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45632. protected _buildUniformLayout(): void;
  45633. /**
  45634. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45635. * @param effect The effect to update
  45636. * @param lightIndex The index of the light in the effect to update
  45637. * @returns The directional light
  45638. */
  45639. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45640. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45641. /**
  45642. * Gets the minZ used for shadow according to both the scene and the light.
  45643. *
  45644. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45645. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45646. * @param activeCamera The camera we are returning the min for
  45647. * @returns the depth min z
  45648. */
  45649. getDepthMinZ(activeCamera: Camera): number;
  45650. /**
  45651. * Gets the maxZ used for shadow according to both the scene and the light.
  45652. *
  45653. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45654. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45655. * @param activeCamera The camera we are returning the max for
  45656. * @returns the depth max z
  45657. */
  45658. getDepthMaxZ(activeCamera: Camera): number;
  45659. /**
  45660. * Prepares the list of defines specific to the light type.
  45661. * @param defines the list of defines
  45662. * @param lightIndex defines the index of the light for the effect
  45663. */
  45664. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45665. }
  45666. }
  45667. declare module BABYLON {
  45668. /**
  45669. * Class containing static functions to help procedurally build meshes
  45670. */
  45671. export class HemisphereBuilder {
  45672. /**
  45673. * Creates a hemisphere mesh
  45674. * @param name defines the name of the mesh
  45675. * @param options defines the options used to create the mesh
  45676. * @param scene defines the hosting scene
  45677. * @returns the hemisphere mesh
  45678. */
  45679. static CreateHemisphere(name: string, options: {
  45680. segments?: number;
  45681. diameter?: number;
  45682. sideOrientation?: number;
  45683. }, scene: any): Mesh;
  45684. }
  45685. }
  45686. declare module BABYLON {
  45687. /**
  45688. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45689. * These values define a cone of light starting from the position, emitting toward the direction.
  45690. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45691. * and the exponent defines the speed of the decay of the light with distance (reach).
  45692. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45693. */
  45694. export class SpotLight extends ShadowLight {
  45695. private _angle;
  45696. private _innerAngle;
  45697. private _cosHalfAngle;
  45698. private _lightAngleScale;
  45699. private _lightAngleOffset;
  45700. /**
  45701. * Gets the cone angle of the spot light in Radians.
  45702. */
  45703. /**
  45704. * Sets the cone angle of the spot light in Radians.
  45705. */
  45706. angle: number;
  45707. /**
  45708. * Only used in gltf falloff mode, this defines the angle where
  45709. * the directional falloff will start before cutting at angle which could be seen
  45710. * as outer angle.
  45711. */
  45712. /**
  45713. * Only used in gltf falloff mode, this defines the angle where
  45714. * the directional falloff will start before cutting at angle which could be seen
  45715. * as outer angle.
  45716. */
  45717. innerAngle: number;
  45718. private _shadowAngleScale;
  45719. /**
  45720. * Allows scaling the angle of the light for shadow generation only.
  45721. */
  45722. /**
  45723. * Allows scaling the angle of the light for shadow generation only.
  45724. */
  45725. shadowAngleScale: number;
  45726. /**
  45727. * The light decay speed with the distance from the emission spot.
  45728. */
  45729. exponent: number;
  45730. private _projectionTextureMatrix;
  45731. /**
  45732. * Allows reading the projecton texture
  45733. */
  45734. readonly projectionTextureMatrix: Matrix;
  45735. protected _projectionTextureLightNear: number;
  45736. /**
  45737. * Gets the near clip of the Spotlight for texture projection.
  45738. */
  45739. /**
  45740. * Sets the near clip of the Spotlight for texture projection.
  45741. */
  45742. projectionTextureLightNear: number;
  45743. protected _projectionTextureLightFar: number;
  45744. /**
  45745. * Gets the far clip of the Spotlight for texture projection.
  45746. */
  45747. /**
  45748. * Sets the far clip of the Spotlight for texture projection.
  45749. */
  45750. projectionTextureLightFar: number;
  45751. protected _projectionTextureUpDirection: Vector3;
  45752. /**
  45753. * Gets the Up vector of the Spotlight for texture projection.
  45754. */
  45755. /**
  45756. * Sets the Up vector of the Spotlight for texture projection.
  45757. */
  45758. projectionTextureUpDirection: Vector3;
  45759. private _projectionTexture;
  45760. /**
  45761. * Gets the projection texture of the light.
  45762. */
  45763. /**
  45764. * Sets the projection texture of the light.
  45765. */
  45766. projectionTexture: Nullable<BaseTexture>;
  45767. private _projectionTextureViewLightDirty;
  45768. private _projectionTextureProjectionLightDirty;
  45769. private _projectionTextureDirty;
  45770. private _projectionTextureViewTargetVector;
  45771. private _projectionTextureViewLightMatrix;
  45772. private _projectionTextureProjectionLightMatrix;
  45773. private _projectionTextureScalingMatrix;
  45774. /**
  45775. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45776. * It can cast shadows.
  45777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45778. * @param name The light friendly name
  45779. * @param position The position of the spot light in the scene
  45780. * @param direction The direction of the light in the scene
  45781. * @param angle The cone angle of the light in Radians
  45782. * @param exponent The light decay speed with the distance from the emission spot
  45783. * @param scene The scene the lights belongs to
  45784. */
  45785. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45786. /**
  45787. * Returns the string "SpotLight".
  45788. * @returns the class name
  45789. */
  45790. getClassName(): string;
  45791. /**
  45792. * Returns the integer 2.
  45793. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45794. */
  45795. getTypeID(): number;
  45796. /**
  45797. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45798. */
  45799. protected _setDirection(value: Vector3): void;
  45800. /**
  45801. * Overrides the position setter to recompute the projection texture view light Matrix.
  45802. */
  45803. protected _setPosition(value: Vector3): void;
  45804. /**
  45805. * 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.
  45806. * Returns the SpotLight.
  45807. */
  45808. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45809. protected _computeProjectionTextureViewLightMatrix(): void;
  45810. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45811. /**
  45812. * Main function for light texture projection matrix computing.
  45813. */
  45814. protected _computeProjectionTextureMatrix(): void;
  45815. protected _buildUniformLayout(): void;
  45816. private _computeAngleValues;
  45817. /**
  45818. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45819. * @param effect The effect to update
  45820. * @param lightIndex The index of the light in the effect to update
  45821. * @returns The spot light
  45822. */
  45823. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45824. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45825. /**
  45826. * Disposes the light and the associated resources.
  45827. */
  45828. dispose(): void;
  45829. /**
  45830. * Prepares the list of defines specific to the light type.
  45831. * @param defines the list of defines
  45832. * @param lightIndex defines the index of the light for the effect
  45833. */
  45834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45835. }
  45836. }
  45837. declare module BABYLON {
  45838. /**
  45839. * Gizmo that enables viewing a light
  45840. */
  45841. export class LightGizmo extends Gizmo {
  45842. private _lightMesh;
  45843. private _material;
  45844. private cachedPosition;
  45845. private cachedForward;
  45846. /**
  45847. * Creates a LightGizmo
  45848. * @param gizmoLayer The utility layer the gizmo will be added to
  45849. */
  45850. constructor(gizmoLayer?: UtilityLayerRenderer);
  45851. private _light;
  45852. /**
  45853. * The light that the gizmo is attached to
  45854. */
  45855. light: Nullable<Light>;
  45856. /**
  45857. * Gets the material used to render the light gizmo
  45858. */
  45859. readonly material: StandardMaterial;
  45860. /**
  45861. * @hidden
  45862. * Updates the gizmo to match the attached mesh's position/rotation
  45863. */
  45864. protected _update(): void;
  45865. private static _Scale;
  45866. /**
  45867. * Creates the lines for a light mesh
  45868. */
  45869. private static _createLightLines;
  45870. /**
  45871. * Disposes of the light gizmo
  45872. */
  45873. dispose(): void;
  45874. private static _CreateHemisphericLightMesh;
  45875. private static _CreatePointLightMesh;
  45876. private static _CreateSpotLightMesh;
  45877. private static _CreateDirectionalLightMesh;
  45878. }
  45879. }
  45880. declare module BABYLON {
  45881. /** @hidden */
  45882. export var backgroundFragmentDeclaration: {
  45883. name: string;
  45884. shader: string;
  45885. };
  45886. }
  45887. declare module BABYLON {
  45888. /** @hidden */
  45889. export var backgroundUboDeclaration: {
  45890. name: string;
  45891. shader: string;
  45892. };
  45893. }
  45894. declare module BABYLON {
  45895. /** @hidden */
  45896. export var backgroundPixelShader: {
  45897. name: string;
  45898. shader: string;
  45899. };
  45900. }
  45901. declare module BABYLON {
  45902. /** @hidden */
  45903. export var backgroundVertexDeclaration: {
  45904. name: string;
  45905. shader: string;
  45906. };
  45907. }
  45908. declare module BABYLON {
  45909. /** @hidden */
  45910. export var backgroundVertexShader: {
  45911. name: string;
  45912. shader: string;
  45913. };
  45914. }
  45915. declare module BABYLON {
  45916. /**
  45917. * Background material used to create an efficient environement around your scene.
  45918. */
  45919. export class BackgroundMaterial extends PushMaterial {
  45920. /**
  45921. * Standard reflectance value at parallel view angle.
  45922. */
  45923. static StandardReflectance0: number;
  45924. /**
  45925. * Standard reflectance value at grazing angle.
  45926. */
  45927. static StandardReflectance90: number;
  45928. protected _primaryColor: Color3;
  45929. /**
  45930. * Key light Color (multiply against the environement texture)
  45931. */
  45932. primaryColor: Color3;
  45933. protected __perceptualColor: Nullable<Color3>;
  45934. /**
  45935. * Experimental Internal Use Only.
  45936. *
  45937. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45938. * This acts as a helper to set the primary color to a more "human friendly" value.
  45939. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45940. * output color as close as possible from the chosen value.
  45941. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45942. * part of lighting setup.)
  45943. */
  45944. _perceptualColor: Nullable<Color3>;
  45945. protected _primaryColorShadowLevel: float;
  45946. /**
  45947. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45948. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45949. */
  45950. primaryColorShadowLevel: float;
  45951. protected _primaryColorHighlightLevel: float;
  45952. /**
  45953. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45954. * The primary color is used at the level chosen to define what the white area would look.
  45955. */
  45956. primaryColorHighlightLevel: float;
  45957. protected _reflectionTexture: Nullable<BaseTexture>;
  45958. /**
  45959. * Reflection Texture used in the material.
  45960. * Should be author in a specific way for the best result (refer to the documentation).
  45961. */
  45962. reflectionTexture: Nullable<BaseTexture>;
  45963. protected _reflectionBlur: float;
  45964. /**
  45965. * Reflection Texture level of blur.
  45966. *
  45967. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45968. * texture twice.
  45969. */
  45970. reflectionBlur: float;
  45971. protected _diffuseTexture: Nullable<BaseTexture>;
  45972. /**
  45973. * Diffuse Texture used in the material.
  45974. * Should be author in a specific way for the best result (refer to the documentation).
  45975. */
  45976. diffuseTexture: Nullable<BaseTexture>;
  45977. protected _shadowLights: Nullable<IShadowLight[]>;
  45978. /**
  45979. * Specify the list of lights casting shadow on the material.
  45980. * All scene shadow lights will be included if null.
  45981. */
  45982. shadowLights: Nullable<IShadowLight[]>;
  45983. protected _shadowLevel: float;
  45984. /**
  45985. * Helps adjusting the shadow to a softer level if required.
  45986. * 0 means black shadows and 1 means no shadows.
  45987. */
  45988. shadowLevel: float;
  45989. protected _sceneCenter: Vector3;
  45990. /**
  45991. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45992. * It is usually zero but might be interesting to modify according to your setup.
  45993. */
  45994. sceneCenter: Vector3;
  45995. protected _opacityFresnel: boolean;
  45996. /**
  45997. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45998. * This helps ensuring a nice transition when the camera goes under the ground.
  45999. */
  46000. opacityFresnel: boolean;
  46001. protected _reflectionFresnel: boolean;
  46002. /**
  46003. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46004. * This helps adding a mirror texture on the ground.
  46005. */
  46006. reflectionFresnel: boolean;
  46007. protected _reflectionFalloffDistance: number;
  46008. /**
  46009. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46010. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46011. */
  46012. reflectionFalloffDistance: number;
  46013. protected _reflectionAmount: number;
  46014. /**
  46015. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46016. */
  46017. reflectionAmount: number;
  46018. protected _reflectionReflectance0: number;
  46019. /**
  46020. * This specifies the weight of the reflection at grazing angle.
  46021. */
  46022. reflectionReflectance0: number;
  46023. protected _reflectionReflectance90: number;
  46024. /**
  46025. * This specifies the weight of the reflection at a perpendicular point of view.
  46026. */
  46027. reflectionReflectance90: number;
  46028. /**
  46029. * Sets the reflection reflectance fresnel values according to the default standard
  46030. * empirically know to work well :-)
  46031. */
  46032. reflectionStandardFresnelWeight: number;
  46033. protected _useRGBColor: boolean;
  46034. /**
  46035. * Helps to directly use the maps channels instead of their level.
  46036. */
  46037. useRGBColor: boolean;
  46038. protected _enableNoise: boolean;
  46039. /**
  46040. * This helps reducing the banding effect that could occur on the background.
  46041. */
  46042. enableNoise: boolean;
  46043. /**
  46044. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46045. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46046. * Recommended to be keep at 1.0 except for special cases.
  46047. */
  46048. fovMultiplier: number;
  46049. private _fovMultiplier;
  46050. /**
  46051. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46052. */
  46053. useEquirectangularFOV: boolean;
  46054. private _maxSimultaneousLights;
  46055. /**
  46056. * Number of Simultaneous lights allowed on the material.
  46057. */
  46058. maxSimultaneousLights: int;
  46059. /**
  46060. * Default configuration related to image processing available in the Background Material.
  46061. */
  46062. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46063. /**
  46064. * Keep track of the image processing observer to allow dispose and replace.
  46065. */
  46066. private _imageProcessingObserver;
  46067. /**
  46068. * Attaches a new image processing configuration to the PBR Material.
  46069. * @param configuration (if null the scene configuration will be use)
  46070. */
  46071. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46072. /**
  46073. * Gets the image processing configuration used either in this material.
  46074. */
  46075. /**
  46076. * Sets the Default image processing configuration used either in the this material.
  46077. *
  46078. * If sets to null, the scene one is in use.
  46079. */
  46080. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46081. /**
  46082. * Gets wether the color curves effect is enabled.
  46083. */
  46084. /**
  46085. * Sets wether the color curves effect is enabled.
  46086. */
  46087. cameraColorCurvesEnabled: boolean;
  46088. /**
  46089. * Gets wether the color grading effect is enabled.
  46090. */
  46091. /**
  46092. * Gets wether the color grading effect is enabled.
  46093. */
  46094. cameraColorGradingEnabled: boolean;
  46095. /**
  46096. * Gets wether tonemapping is enabled or not.
  46097. */
  46098. /**
  46099. * Sets wether tonemapping is enabled or not
  46100. */
  46101. cameraToneMappingEnabled: boolean;
  46102. /**
  46103. * The camera exposure used on this material.
  46104. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46105. * This corresponds to a photographic exposure.
  46106. */
  46107. /**
  46108. * The camera exposure used on this material.
  46109. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46110. * This corresponds to a photographic exposure.
  46111. */
  46112. cameraExposure: float;
  46113. /**
  46114. * Gets The camera contrast used on this material.
  46115. */
  46116. /**
  46117. * Sets The camera contrast used on this material.
  46118. */
  46119. cameraContrast: float;
  46120. /**
  46121. * Gets the Color Grading 2D Lookup Texture.
  46122. */
  46123. /**
  46124. * Sets the Color Grading 2D Lookup Texture.
  46125. */
  46126. cameraColorGradingTexture: Nullable<BaseTexture>;
  46127. /**
  46128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46130. * 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;
  46131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46132. */
  46133. /**
  46134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46136. * 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;
  46137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46138. */
  46139. cameraColorCurves: Nullable<ColorCurves>;
  46140. /**
  46141. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46142. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46143. */
  46144. switchToBGR: boolean;
  46145. private _renderTargets;
  46146. private _reflectionControls;
  46147. private _white;
  46148. private _primaryShadowColor;
  46149. private _primaryHighlightColor;
  46150. /**
  46151. * Instantiates a Background Material in the given scene
  46152. * @param name The friendly name of the material
  46153. * @param scene The scene to add the material to
  46154. */
  46155. constructor(name: string, scene: Scene);
  46156. /**
  46157. * Gets a boolean indicating that current material needs to register RTT
  46158. */
  46159. readonly hasRenderTargetTextures: boolean;
  46160. /**
  46161. * The entire material has been created in order to prevent overdraw.
  46162. * @returns false
  46163. */
  46164. needAlphaTesting(): boolean;
  46165. /**
  46166. * The entire material has been created in order to prevent overdraw.
  46167. * @returns true if blending is enable
  46168. */
  46169. needAlphaBlending(): boolean;
  46170. /**
  46171. * Checks wether the material is ready to be rendered for a given mesh.
  46172. * @param mesh The mesh to render
  46173. * @param subMesh The submesh to check against
  46174. * @param useInstances Specify wether or not the material is used with instances
  46175. * @returns true if all the dependencies are ready (Textures, Effects...)
  46176. */
  46177. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46178. /**
  46179. * Compute the primary color according to the chosen perceptual color.
  46180. */
  46181. private _computePrimaryColorFromPerceptualColor;
  46182. /**
  46183. * Compute the highlights and shadow colors according to their chosen levels.
  46184. */
  46185. private _computePrimaryColors;
  46186. /**
  46187. * Build the uniform buffer used in the material.
  46188. */
  46189. buildUniformLayout(): void;
  46190. /**
  46191. * Unbind the material.
  46192. */
  46193. unbind(): void;
  46194. /**
  46195. * Bind only the world matrix to the material.
  46196. * @param world The world matrix to bind.
  46197. */
  46198. bindOnlyWorldMatrix(world: Matrix): void;
  46199. /**
  46200. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46201. * @param world The world matrix to bind.
  46202. * @param subMesh The submesh to bind for.
  46203. */
  46204. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46205. /**
  46206. * Checks to see if a texture is used in the material.
  46207. * @param texture - Base texture to use.
  46208. * @returns - Boolean specifying if a texture is used in the material.
  46209. */
  46210. hasTexture(texture: BaseTexture): boolean;
  46211. /**
  46212. * Dispose the material.
  46213. * @param forceDisposeEffect Force disposal of the associated effect.
  46214. * @param forceDisposeTextures Force disposal of the associated textures.
  46215. */
  46216. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46217. /**
  46218. * Clones the material.
  46219. * @param name The cloned name.
  46220. * @returns The cloned material.
  46221. */
  46222. clone(name: string): BackgroundMaterial;
  46223. /**
  46224. * Serializes the current material to its JSON representation.
  46225. * @returns The JSON representation.
  46226. */
  46227. serialize(): any;
  46228. /**
  46229. * Gets the class name of the material
  46230. * @returns "BackgroundMaterial"
  46231. */
  46232. getClassName(): string;
  46233. /**
  46234. * Parse a JSON input to create back a background material.
  46235. * @param source The JSON data to parse
  46236. * @param scene The scene to create the parsed material in
  46237. * @param rootUrl The root url of the assets the material depends upon
  46238. * @returns the instantiated BackgroundMaterial.
  46239. */
  46240. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46241. }
  46242. }
  46243. declare module BABYLON {
  46244. /**
  46245. * Represents the different options available during the creation of
  46246. * a Environment helper.
  46247. *
  46248. * This can control the default ground, skybox and image processing setup of your scene.
  46249. */
  46250. export interface IEnvironmentHelperOptions {
  46251. /**
  46252. * Specifies wether or not to create a ground.
  46253. * True by default.
  46254. */
  46255. createGround: boolean;
  46256. /**
  46257. * Specifies the ground size.
  46258. * 15 by default.
  46259. */
  46260. groundSize: number;
  46261. /**
  46262. * The texture used on the ground for the main color.
  46263. * Comes from the BabylonJS CDN by default.
  46264. *
  46265. * Remarks: Can be either a texture or a url.
  46266. */
  46267. groundTexture: string | BaseTexture;
  46268. /**
  46269. * The color mixed in the ground texture by default.
  46270. * BabylonJS clearColor by default.
  46271. */
  46272. groundColor: Color3;
  46273. /**
  46274. * Specifies the ground opacity.
  46275. * 1 by default.
  46276. */
  46277. groundOpacity: number;
  46278. /**
  46279. * Enables the ground to receive shadows.
  46280. * True by default.
  46281. */
  46282. enableGroundShadow: boolean;
  46283. /**
  46284. * Helps preventing the shadow to be fully black on the ground.
  46285. * 0.5 by default.
  46286. */
  46287. groundShadowLevel: number;
  46288. /**
  46289. * Creates a mirror texture attach to the ground.
  46290. * false by default.
  46291. */
  46292. enableGroundMirror: boolean;
  46293. /**
  46294. * Specifies the ground mirror size ratio.
  46295. * 0.3 by default as the default kernel is 64.
  46296. */
  46297. groundMirrorSizeRatio: number;
  46298. /**
  46299. * Specifies the ground mirror blur kernel size.
  46300. * 64 by default.
  46301. */
  46302. groundMirrorBlurKernel: number;
  46303. /**
  46304. * Specifies the ground mirror visibility amount.
  46305. * 1 by default
  46306. */
  46307. groundMirrorAmount: number;
  46308. /**
  46309. * Specifies the ground mirror reflectance weight.
  46310. * This uses the standard weight of the background material to setup the fresnel effect
  46311. * of the mirror.
  46312. * 1 by default.
  46313. */
  46314. groundMirrorFresnelWeight: number;
  46315. /**
  46316. * Specifies the ground mirror Falloff distance.
  46317. * This can helps reducing the size of the reflection.
  46318. * 0 by Default.
  46319. */
  46320. groundMirrorFallOffDistance: number;
  46321. /**
  46322. * Specifies the ground mirror texture type.
  46323. * Unsigned Int by Default.
  46324. */
  46325. groundMirrorTextureType: number;
  46326. /**
  46327. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46328. * the shown objects.
  46329. */
  46330. groundYBias: number;
  46331. /**
  46332. * Specifies wether or not to create a skybox.
  46333. * True by default.
  46334. */
  46335. createSkybox: boolean;
  46336. /**
  46337. * Specifies the skybox size.
  46338. * 20 by default.
  46339. */
  46340. skyboxSize: number;
  46341. /**
  46342. * The texture used on the skybox for the main color.
  46343. * Comes from the BabylonJS CDN by default.
  46344. *
  46345. * Remarks: Can be either a texture or a url.
  46346. */
  46347. skyboxTexture: string | BaseTexture;
  46348. /**
  46349. * The color mixed in the skybox texture by default.
  46350. * BabylonJS clearColor by default.
  46351. */
  46352. skyboxColor: Color3;
  46353. /**
  46354. * The background rotation around the Y axis of the scene.
  46355. * This helps aligning the key lights of your scene with the background.
  46356. * 0 by default.
  46357. */
  46358. backgroundYRotation: number;
  46359. /**
  46360. * Compute automatically the size of the elements to best fit with the scene.
  46361. */
  46362. sizeAuto: boolean;
  46363. /**
  46364. * Default position of the rootMesh if autoSize is not true.
  46365. */
  46366. rootPosition: Vector3;
  46367. /**
  46368. * Sets up the image processing in the scene.
  46369. * true by default.
  46370. */
  46371. setupImageProcessing: boolean;
  46372. /**
  46373. * The texture used as your environment texture in the scene.
  46374. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46375. *
  46376. * Remarks: Can be either a texture or a url.
  46377. */
  46378. environmentTexture: string | BaseTexture;
  46379. /**
  46380. * The value of the exposure to apply to the scene.
  46381. * 0.6 by default if setupImageProcessing is true.
  46382. */
  46383. cameraExposure: number;
  46384. /**
  46385. * The value of the contrast to apply to the scene.
  46386. * 1.6 by default if setupImageProcessing is true.
  46387. */
  46388. cameraContrast: number;
  46389. /**
  46390. * Specifies wether or not tonemapping should be enabled in the scene.
  46391. * true by default if setupImageProcessing is true.
  46392. */
  46393. toneMappingEnabled: boolean;
  46394. }
  46395. /**
  46396. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46397. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46398. * It also helps with the default setup of your imageProcessing configuration.
  46399. */
  46400. export class EnvironmentHelper {
  46401. /**
  46402. * Default ground texture URL.
  46403. */
  46404. private static _groundTextureCDNUrl;
  46405. /**
  46406. * Default skybox texture URL.
  46407. */
  46408. private static _skyboxTextureCDNUrl;
  46409. /**
  46410. * Default environment texture URL.
  46411. */
  46412. private static _environmentTextureCDNUrl;
  46413. /**
  46414. * Creates the default options for the helper.
  46415. */
  46416. private static _getDefaultOptions;
  46417. private _rootMesh;
  46418. /**
  46419. * Gets the root mesh created by the helper.
  46420. */
  46421. readonly rootMesh: Mesh;
  46422. private _skybox;
  46423. /**
  46424. * Gets the skybox created by the helper.
  46425. */
  46426. readonly skybox: Nullable<Mesh>;
  46427. private _skyboxTexture;
  46428. /**
  46429. * Gets the skybox texture created by the helper.
  46430. */
  46431. readonly skyboxTexture: Nullable<BaseTexture>;
  46432. private _skyboxMaterial;
  46433. /**
  46434. * Gets the skybox material created by the helper.
  46435. */
  46436. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46437. private _ground;
  46438. /**
  46439. * Gets the ground mesh created by the helper.
  46440. */
  46441. readonly ground: Nullable<Mesh>;
  46442. private _groundTexture;
  46443. /**
  46444. * Gets the ground texture created by the helper.
  46445. */
  46446. readonly groundTexture: Nullable<BaseTexture>;
  46447. private _groundMirror;
  46448. /**
  46449. * Gets the ground mirror created by the helper.
  46450. */
  46451. readonly groundMirror: Nullable<MirrorTexture>;
  46452. /**
  46453. * Gets the ground mirror render list to helps pushing the meshes
  46454. * you wish in the ground reflection.
  46455. */
  46456. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46457. private _groundMaterial;
  46458. /**
  46459. * Gets the ground material created by the helper.
  46460. */
  46461. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46462. /**
  46463. * Stores the creation options.
  46464. */
  46465. private readonly _scene;
  46466. private _options;
  46467. /**
  46468. * This observable will be notified with any error during the creation of the environment,
  46469. * mainly texture creation errors.
  46470. */
  46471. onErrorObservable: Observable<{
  46472. message?: string;
  46473. exception?: any;
  46474. }>;
  46475. /**
  46476. * constructor
  46477. * @param options Defines the options we want to customize the helper
  46478. * @param scene The scene to add the material to
  46479. */
  46480. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46481. /**
  46482. * Updates the background according to the new options
  46483. * @param options
  46484. */
  46485. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46486. /**
  46487. * Sets the primary color of all the available elements.
  46488. * @param color the main color to affect to the ground and the background
  46489. */
  46490. setMainColor(color: Color3): void;
  46491. /**
  46492. * Setup the image processing according to the specified options.
  46493. */
  46494. private _setupImageProcessing;
  46495. /**
  46496. * Setup the environment texture according to the specified options.
  46497. */
  46498. private _setupEnvironmentTexture;
  46499. /**
  46500. * Setup the background according to the specified options.
  46501. */
  46502. private _setupBackground;
  46503. /**
  46504. * Get the scene sizes according to the setup.
  46505. */
  46506. private _getSceneSize;
  46507. /**
  46508. * Setup the ground according to the specified options.
  46509. */
  46510. private _setupGround;
  46511. /**
  46512. * Setup the ground material according to the specified options.
  46513. */
  46514. private _setupGroundMaterial;
  46515. /**
  46516. * Setup the ground diffuse texture according to the specified options.
  46517. */
  46518. private _setupGroundDiffuseTexture;
  46519. /**
  46520. * Setup the ground mirror texture according to the specified options.
  46521. */
  46522. private _setupGroundMirrorTexture;
  46523. /**
  46524. * Setup the ground to receive the mirror texture.
  46525. */
  46526. private _setupMirrorInGroundMaterial;
  46527. /**
  46528. * Setup the skybox according to the specified options.
  46529. */
  46530. private _setupSkybox;
  46531. /**
  46532. * Setup the skybox material according to the specified options.
  46533. */
  46534. private _setupSkyboxMaterial;
  46535. /**
  46536. * Setup the skybox reflection texture according to the specified options.
  46537. */
  46538. private _setupSkyboxReflectionTexture;
  46539. private _errorHandler;
  46540. /**
  46541. * Dispose all the elements created by the Helper.
  46542. */
  46543. dispose(): void;
  46544. }
  46545. }
  46546. declare module BABYLON {
  46547. /**
  46548. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46549. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46550. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46551. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46552. */
  46553. export class PhotoDome extends TransformNode {
  46554. /**
  46555. * Define the image as a Monoscopic panoramic 360 image.
  46556. */
  46557. static readonly MODE_MONOSCOPIC: number;
  46558. /**
  46559. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46560. */
  46561. static readonly MODE_TOPBOTTOM: number;
  46562. /**
  46563. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46564. */
  46565. static readonly MODE_SIDEBYSIDE: number;
  46566. private _useDirectMapping;
  46567. /**
  46568. * The texture being displayed on the sphere
  46569. */
  46570. protected _photoTexture: Texture;
  46571. /**
  46572. * Gets or sets the texture being displayed on the sphere
  46573. */
  46574. photoTexture: Texture;
  46575. /**
  46576. * Observable raised when an error occured while loading the 360 image
  46577. */
  46578. onLoadErrorObservable: Observable<string>;
  46579. /**
  46580. * The skybox material
  46581. */
  46582. protected _material: BackgroundMaterial;
  46583. /**
  46584. * The surface used for the skybox
  46585. */
  46586. protected _mesh: Mesh;
  46587. /**
  46588. * Gets the mesh used for the skybox.
  46589. */
  46590. readonly mesh: Mesh;
  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. * Also see the options.resolution property.
  46594. */
  46595. fovMultiplier: number;
  46596. private _imageMode;
  46597. /**
  46598. * Gets or set the current video mode for the video. It can be:
  46599. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46600. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46601. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46602. */
  46603. imageMode: number;
  46604. /**
  46605. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46606. * @param name Element's name, child elements will append suffixes for their own names.
  46607. * @param urlsOfPhoto defines the url of the photo to display
  46608. * @param options defines an object containing optional or exposed sub element properties
  46609. * @param onError defines a callback called when an error occured while loading the texture
  46610. */
  46611. constructor(name: string, urlOfPhoto: string, options: {
  46612. resolution?: number;
  46613. size?: number;
  46614. useDirectMapping?: boolean;
  46615. faceForward?: boolean;
  46616. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46617. private _onBeforeCameraRenderObserver;
  46618. private _changeImageMode;
  46619. /**
  46620. * Releases resources associated with this node.
  46621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46623. */
  46624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46625. }
  46626. }
  46627. declare module BABYLON {
  46628. /**
  46629. * Class used to host RGBD texture specific utilities
  46630. */
  46631. export class RGBDTextureTools {
  46632. /**
  46633. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46634. * @param texture the texture to expand.
  46635. */
  46636. static ExpandRGBDTexture(texture: Texture): void;
  46637. }
  46638. }
  46639. declare module BABYLON {
  46640. /**
  46641. * Class used to host texture specific utilities
  46642. */
  46643. export class BRDFTextureTools {
  46644. /**
  46645. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46646. * @param scene defines the hosting scene
  46647. * @returns the environment BRDF texture
  46648. */
  46649. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46650. private static _environmentBRDFBase64Texture;
  46651. }
  46652. }
  46653. declare module BABYLON {
  46654. /**
  46655. * @hidden
  46656. */
  46657. export interface IMaterialClearCoatDefines {
  46658. CLEARCOAT: boolean;
  46659. CLEARCOAT_DEFAULTIOR: boolean;
  46660. CLEARCOAT_TEXTURE: boolean;
  46661. CLEARCOAT_TEXTUREDIRECTUV: number;
  46662. CLEARCOAT_BUMP: boolean;
  46663. CLEARCOAT_BUMPDIRECTUV: number;
  46664. CLEARCOAT_TINT: boolean;
  46665. CLEARCOAT_TINT_TEXTURE: boolean;
  46666. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46667. /** @hidden */
  46668. _areTexturesDirty: boolean;
  46669. }
  46670. /**
  46671. * Define the code related to the clear coat parameters of the pbr material.
  46672. */
  46673. export class PBRClearCoatConfiguration {
  46674. /**
  46675. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46676. * The default fits with a polyurethane material.
  46677. */
  46678. private static readonly _DefaultIndexOfRefraction;
  46679. private _isEnabled;
  46680. /**
  46681. * Defines if the clear coat is enabled in the material.
  46682. */
  46683. isEnabled: boolean;
  46684. /**
  46685. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46686. */
  46687. intensity: number;
  46688. /**
  46689. * Defines the clear coat layer roughness.
  46690. */
  46691. roughness: number;
  46692. private _indexOfRefraction;
  46693. /**
  46694. * Defines the index of refraction of the clear coat.
  46695. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46696. * The default fits with a polyurethane material.
  46697. * Changing the default value is more performance intensive.
  46698. */
  46699. indexOfRefraction: number;
  46700. private _texture;
  46701. /**
  46702. * Stores the clear coat values in a texture.
  46703. */
  46704. texture: Nullable<BaseTexture>;
  46705. private _bumpTexture;
  46706. /**
  46707. * Define the clear coat specific bump texture.
  46708. */
  46709. bumpTexture: Nullable<BaseTexture>;
  46710. private _isTintEnabled;
  46711. /**
  46712. * Defines if the clear coat tint is enabled in the material.
  46713. */
  46714. isTintEnabled: boolean;
  46715. /**
  46716. * Defines the clear coat tint of the material.
  46717. * This is only use if tint is enabled
  46718. */
  46719. tintColor: Color3;
  46720. /**
  46721. * Defines the distance at which the tint color should be found in the
  46722. * clear coat media.
  46723. * This is only use if tint is enabled
  46724. */
  46725. tintColorAtDistance: number;
  46726. /**
  46727. * Defines the clear coat layer thickness.
  46728. * This is only use if tint is enabled
  46729. */
  46730. tintThickness: number;
  46731. private _tintTexture;
  46732. /**
  46733. * Stores the clear tint values in a texture.
  46734. * rgb is tint
  46735. * a is a thickness factor
  46736. */
  46737. tintTexture: Nullable<BaseTexture>;
  46738. /** @hidden */
  46739. private _internalMarkAllSubMeshesAsTexturesDirty;
  46740. /** @hidden */
  46741. _markAllSubMeshesAsTexturesDirty(): void;
  46742. /**
  46743. * Instantiate a new istance of clear coat configuration.
  46744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46745. */
  46746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46747. /**
  46748. * Gets wehter the submesh is ready to be used or not.
  46749. * @param defines the list of "defines" to update.
  46750. * @param scene defines the scene the material belongs to.
  46751. * @param engine defines the engine the material belongs to.
  46752. * @param disableBumpMap defines wether the material disables bump or not.
  46753. * @returns - boolean indicating that the submesh is ready or not.
  46754. */
  46755. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46756. /**
  46757. * Checks to see if a texture is used in the material.
  46758. * @param defines the list of "defines" to update.
  46759. * @param scene defines the scene to the material belongs to.
  46760. */
  46761. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46762. /**
  46763. * Binds the material data.
  46764. * @param uniformBuffer defines the Uniform buffer to fill in.
  46765. * @param scene defines the scene the material belongs to.
  46766. * @param engine defines the engine the material belongs to.
  46767. * @param disableBumpMap defines wether the material disables bump or not.
  46768. * @param isFrozen defines wether the material is frozen or not.
  46769. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46770. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46771. */
  46772. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46773. /**
  46774. * Checks to see if a texture is used in the material.
  46775. * @param texture - Base texture to use.
  46776. * @returns - Boolean specifying if a texture is used in the material.
  46777. */
  46778. hasTexture(texture: BaseTexture): boolean;
  46779. /**
  46780. * Returns an array of the actively used textures.
  46781. * @param activeTextures Array of BaseTextures
  46782. */
  46783. getActiveTextures(activeTextures: BaseTexture[]): void;
  46784. /**
  46785. * Returns the animatable textures.
  46786. * @param animatables Array of animatable textures.
  46787. */
  46788. getAnimatables(animatables: IAnimatable[]): void;
  46789. /**
  46790. * Disposes the resources of the material.
  46791. * @param forceDisposeTextures - Forces the disposal of all textures.
  46792. */
  46793. dispose(forceDisposeTextures?: boolean): void;
  46794. /**
  46795. * Get the current class name of the texture useful for serialization or dynamic coding.
  46796. * @returns "PBRClearCoatConfiguration"
  46797. */
  46798. getClassName(): string;
  46799. /**
  46800. * Add fallbacks to the effect fallbacks list.
  46801. * @param defines defines the Base texture to use.
  46802. * @param fallbacks defines the current fallback list.
  46803. * @param currentRank defines the current fallback rank.
  46804. * @returns the new fallback rank.
  46805. */
  46806. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46807. /**
  46808. * Add the required uniforms to the current list.
  46809. * @param uniforms defines the current uniform list.
  46810. */
  46811. static AddUniforms(uniforms: string[]): void;
  46812. /**
  46813. * Add the required samplers to the current list.
  46814. * @param samplers defines the current sampler list.
  46815. */
  46816. static AddSamplers(samplers: string[]): void;
  46817. /**
  46818. * Add the required uniforms to the current buffer.
  46819. * @param uniformBuffer defines the current uniform buffer.
  46820. */
  46821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46822. /**
  46823. * Makes a duplicate of the current configuration into another one.
  46824. * @param clearCoatConfiguration define the config where to copy the info
  46825. */
  46826. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46827. /**
  46828. * Serializes this clear coat configuration.
  46829. * @returns - An object with the serialized config.
  46830. */
  46831. serialize(): any;
  46832. /**
  46833. * Parses a anisotropy Configuration from a serialized object.
  46834. * @param source - Serialized object.
  46835. * @param scene Defines the scene we are parsing for
  46836. * @param rootUrl Defines the rootUrl to load from
  46837. */
  46838. parse(source: any, scene: Scene, rootUrl: string): void;
  46839. }
  46840. }
  46841. declare module BABYLON {
  46842. /**
  46843. * @hidden
  46844. */
  46845. export interface IMaterialAnisotropicDefines {
  46846. ANISOTROPIC: boolean;
  46847. ANISOTROPIC_TEXTURE: boolean;
  46848. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46849. MAINUV1: boolean;
  46850. _areTexturesDirty: boolean;
  46851. _needUVs: boolean;
  46852. }
  46853. /**
  46854. * Define the code related to the anisotropic parameters of the pbr material.
  46855. */
  46856. export class PBRAnisotropicConfiguration {
  46857. private _isEnabled;
  46858. /**
  46859. * Defines if the anisotropy is enabled in the material.
  46860. */
  46861. isEnabled: boolean;
  46862. /**
  46863. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46864. */
  46865. intensity: number;
  46866. /**
  46867. * Defines if the effect is along the tangents, bitangents or in between.
  46868. * By default, the effect is "strectching" the highlights along the tangents.
  46869. */
  46870. direction: Vector2;
  46871. private _texture;
  46872. /**
  46873. * Stores the anisotropy values in a texture.
  46874. * rg is direction (like normal from -1 to 1)
  46875. * b is a intensity
  46876. */
  46877. texture: Nullable<BaseTexture>;
  46878. /** @hidden */
  46879. private _internalMarkAllSubMeshesAsTexturesDirty;
  46880. /** @hidden */
  46881. _markAllSubMeshesAsTexturesDirty(): void;
  46882. /**
  46883. * Instantiate a new istance of anisotropy configuration.
  46884. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46885. */
  46886. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46887. /**
  46888. * Specifies that the submesh is ready to be used.
  46889. * @param defines the list of "defines" to update.
  46890. * @param scene defines the scene the material belongs to.
  46891. * @returns - boolean indicating that the submesh is ready or not.
  46892. */
  46893. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46894. /**
  46895. * Checks to see if a texture is used in the material.
  46896. * @param defines the list of "defines" to update.
  46897. * @param mesh the mesh we are preparing the defines for.
  46898. * @param scene defines the scene the material belongs to.
  46899. */
  46900. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46901. /**
  46902. * Binds the material data.
  46903. * @param uniformBuffer defines the Uniform buffer to fill in.
  46904. * @param scene defines the scene the material belongs to.
  46905. * @param isFrozen defines wether the material is frozen or not.
  46906. */
  46907. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46908. /**
  46909. * Checks to see if a texture is used in the material.
  46910. * @param texture - Base texture to use.
  46911. * @returns - Boolean specifying if a texture is used in the material.
  46912. */
  46913. hasTexture(texture: BaseTexture): boolean;
  46914. /**
  46915. * Returns an array of the actively used textures.
  46916. * @param activeTextures Array of BaseTextures
  46917. */
  46918. getActiveTextures(activeTextures: BaseTexture[]): void;
  46919. /**
  46920. * Returns the animatable textures.
  46921. * @param animatables Array of animatable textures.
  46922. */
  46923. getAnimatables(animatables: IAnimatable[]): void;
  46924. /**
  46925. * Disposes the resources of the material.
  46926. * @param forceDisposeTextures - Forces the disposal of all textures.
  46927. */
  46928. dispose(forceDisposeTextures?: boolean): void;
  46929. /**
  46930. * Get the current class name of the texture useful for serialization or dynamic coding.
  46931. * @returns "PBRAnisotropicConfiguration"
  46932. */
  46933. getClassName(): string;
  46934. /**
  46935. * Add fallbacks to the effect fallbacks list.
  46936. * @param defines defines the Base texture to use.
  46937. * @param fallbacks defines the current fallback list.
  46938. * @param currentRank defines the current fallback rank.
  46939. * @returns the new fallback rank.
  46940. */
  46941. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46942. /**
  46943. * Add the required uniforms to the current list.
  46944. * @param uniforms defines the current uniform list.
  46945. */
  46946. static AddUniforms(uniforms: string[]): void;
  46947. /**
  46948. * Add the required uniforms to the current buffer.
  46949. * @param uniformBuffer defines the current uniform buffer.
  46950. */
  46951. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46952. /**
  46953. * Add the required samplers to the current list.
  46954. * @param samplers defines the current sampler list.
  46955. */
  46956. static AddSamplers(samplers: string[]): void;
  46957. /**
  46958. * Makes a duplicate of the current configuration into another one.
  46959. * @param anisotropicConfiguration define the config where to copy the info
  46960. */
  46961. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46962. /**
  46963. * Serializes this anisotropy configuration.
  46964. * @returns - An object with the serialized config.
  46965. */
  46966. serialize(): any;
  46967. /**
  46968. * Parses a anisotropy Configuration from a serialized object.
  46969. * @param source - Serialized object.
  46970. * @param scene Defines the scene we are parsing for
  46971. * @param rootUrl Defines the rootUrl to load from
  46972. */
  46973. parse(source: any, scene: Scene, rootUrl: string): void;
  46974. }
  46975. }
  46976. declare module BABYLON {
  46977. /**
  46978. * @hidden
  46979. */
  46980. export interface IMaterialBRDFDefines {
  46981. BRDF_V_HEIGHT_CORRELATED: boolean;
  46982. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46983. SPHERICAL_HARMONICS: boolean;
  46984. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46985. /** @hidden */
  46986. _areMiscDirty: boolean;
  46987. }
  46988. /**
  46989. * Define the code related to the BRDF parameters of the pbr material.
  46990. */
  46991. export class PBRBRDFConfiguration {
  46992. /**
  46993. * Default value used for the energy conservation.
  46994. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46995. */
  46996. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46997. /**
  46998. * Default value used for the Smith Visibility Height Correlated mode.
  46999. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47000. */
  47001. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47002. /**
  47003. * Default value used for the IBL diffuse part.
  47004. * This can help switching back to the polynomials mode globally which is a tiny bit
  47005. * less GPU intensive at the drawback of a lower quality.
  47006. */
  47007. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47008. /**
  47009. * Default value used for activating energy conservation for the specular workflow.
  47010. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47011. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47012. */
  47013. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47014. private _useEnergyConservation;
  47015. /**
  47016. * Defines if the material uses energy conservation.
  47017. */
  47018. useEnergyConservation: boolean;
  47019. private _useSmithVisibilityHeightCorrelated;
  47020. /**
  47021. * LEGACY Mode set to false
  47022. * Defines if the material uses height smith correlated visibility term.
  47023. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47024. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47025. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47026. * Not relying on height correlated will also disable energy conservation.
  47027. */
  47028. useSmithVisibilityHeightCorrelated: boolean;
  47029. private _useSphericalHarmonics;
  47030. /**
  47031. * LEGACY Mode set to false
  47032. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47033. * diffuse part of the IBL.
  47034. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47035. * to the ground truth.
  47036. */
  47037. useSphericalHarmonics: boolean;
  47038. private _useSpecularGlossinessInputEnergyConservation;
  47039. /**
  47040. * Defines if the material uses energy conservation, when the specular workflow is active.
  47041. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47042. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47043. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47044. */
  47045. useSpecularGlossinessInputEnergyConservation: boolean;
  47046. /** @hidden */
  47047. private _internalMarkAllSubMeshesAsMiscDirty;
  47048. /** @hidden */
  47049. _markAllSubMeshesAsMiscDirty(): void;
  47050. /**
  47051. * Instantiate a new istance of clear coat configuration.
  47052. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47053. */
  47054. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47055. /**
  47056. * Checks to see if a texture is used in the material.
  47057. * @param defines the list of "defines" to update.
  47058. */
  47059. prepareDefines(defines: IMaterialBRDFDefines): void;
  47060. /**
  47061. * Get the current class name of the texture useful for serialization or dynamic coding.
  47062. * @returns "PBRClearCoatConfiguration"
  47063. */
  47064. getClassName(): string;
  47065. /**
  47066. * Makes a duplicate of the current configuration into another one.
  47067. * @param brdfConfiguration define the config where to copy the info
  47068. */
  47069. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47070. /**
  47071. * Serializes this BRDF configuration.
  47072. * @returns - An object with the serialized config.
  47073. */
  47074. serialize(): any;
  47075. /**
  47076. * Parses a anisotropy Configuration from a serialized object.
  47077. * @param source - Serialized object.
  47078. * @param scene Defines the scene we are parsing for
  47079. * @param rootUrl Defines the rootUrl to load from
  47080. */
  47081. parse(source: any, scene: Scene, rootUrl: string): void;
  47082. }
  47083. }
  47084. declare module BABYLON {
  47085. /**
  47086. * @hidden
  47087. */
  47088. export interface IMaterialSheenDefines {
  47089. SHEEN: boolean;
  47090. SHEEN_TEXTURE: boolean;
  47091. SHEEN_TEXTUREDIRECTUV: number;
  47092. SHEEN_LINKWITHALBEDO: boolean;
  47093. /** @hidden */
  47094. _areTexturesDirty: boolean;
  47095. }
  47096. /**
  47097. * Define the code related to the Sheen parameters of the pbr material.
  47098. */
  47099. export class PBRSheenConfiguration {
  47100. private _isEnabled;
  47101. /**
  47102. * Defines if the material uses sheen.
  47103. */
  47104. isEnabled: boolean;
  47105. private _linkSheenWithAlbedo;
  47106. /**
  47107. * Defines if the sheen is linked to the sheen color.
  47108. */
  47109. linkSheenWithAlbedo: boolean;
  47110. /**
  47111. * Defines the sheen intensity.
  47112. */
  47113. intensity: number;
  47114. /**
  47115. * Defines the sheen color.
  47116. */
  47117. color: Color3;
  47118. private _texture;
  47119. /**
  47120. * Stores the sheen tint values in a texture.
  47121. * rgb is tint
  47122. * a is a intensity
  47123. */
  47124. texture: Nullable<BaseTexture>;
  47125. /** @hidden */
  47126. private _internalMarkAllSubMeshesAsTexturesDirty;
  47127. /** @hidden */
  47128. _markAllSubMeshesAsTexturesDirty(): void;
  47129. /**
  47130. * Instantiate a new istance of clear coat configuration.
  47131. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47132. */
  47133. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47134. /**
  47135. * Specifies that the submesh is ready to be used.
  47136. * @param defines the list of "defines" to update.
  47137. * @param scene defines the scene the material belongs to.
  47138. * @returns - boolean indicating that the submesh is ready or not.
  47139. */
  47140. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47141. /**
  47142. * Checks to see if a texture is used in the material.
  47143. * @param defines the list of "defines" to update.
  47144. * @param scene defines the scene the material belongs to.
  47145. */
  47146. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47147. /**
  47148. * Binds the material data.
  47149. * @param uniformBuffer defines the Uniform buffer to fill in.
  47150. * @param scene defines the scene the material belongs to.
  47151. * @param isFrozen defines wether the material is frozen or not.
  47152. */
  47153. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47154. /**
  47155. * Checks to see if a texture is used in the material.
  47156. * @param texture - Base texture to use.
  47157. * @returns - Boolean specifying if a texture is used in the material.
  47158. */
  47159. hasTexture(texture: BaseTexture): boolean;
  47160. /**
  47161. * Returns an array of the actively used textures.
  47162. * @param activeTextures Array of BaseTextures
  47163. */
  47164. getActiveTextures(activeTextures: BaseTexture[]): void;
  47165. /**
  47166. * Returns the animatable textures.
  47167. * @param animatables Array of animatable textures.
  47168. */
  47169. getAnimatables(animatables: IAnimatable[]): void;
  47170. /**
  47171. * Disposes the resources of the material.
  47172. * @param forceDisposeTextures - Forces the disposal of all textures.
  47173. */
  47174. dispose(forceDisposeTextures?: boolean): void;
  47175. /**
  47176. * Get the current class name of the texture useful for serialization or dynamic coding.
  47177. * @returns "PBRSheenConfiguration"
  47178. */
  47179. getClassName(): string;
  47180. /**
  47181. * Add fallbacks to the effect fallbacks list.
  47182. * @param defines defines the Base texture to use.
  47183. * @param fallbacks defines the current fallback list.
  47184. * @param currentRank defines the current fallback rank.
  47185. * @returns the new fallback rank.
  47186. */
  47187. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47188. /**
  47189. * Add the required uniforms to the current list.
  47190. * @param uniforms defines the current uniform list.
  47191. */
  47192. static AddUniforms(uniforms: string[]): void;
  47193. /**
  47194. * Add the required uniforms to the current buffer.
  47195. * @param uniformBuffer defines the current uniform buffer.
  47196. */
  47197. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47198. /**
  47199. * Add the required samplers to the current list.
  47200. * @param samplers defines the current sampler list.
  47201. */
  47202. static AddSamplers(samplers: string[]): void;
  47203. /**
  47204. * Makes a duplicate of the current configuration into another one.
  47205. * @param sheenConfiguration define the config where to copy the info
  47206. */
  47207. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47208. /**
  47209. * Serializes this BRDF configuration.
  47210. * @returns - An object with the serialized config.
  47211. */
  47212. serialize(): any;
  47213. /**
  47214. * Parses a anisotropy Configuration from a serialized object.
  47215. * @param source - Serialized object.
  47216. * @param scene Defines the scene we are parsing for
  47217. * @param rootUrl Defines the rootUrl to load from
  47218. */
  47219. parse(source: any, scene: Scene, rootUrl: string): void;
  47220. }
  47221. }
  47222. declare module BABYLON {
  47223. /**
  47224. * @hidden
  47225. */
  47226. export interface IMaterialSubSurfaceDefines {
  47227. SUBSURFACE: boolean;
  47228. SS_REFRACTION: boolean;
  47229. SS_TRANSLUCENCY: boolean;
  47230. SS_SCATERRING: boolean;
  47231. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47232. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47233. SS_REFRACTIONMAP_3D: boolean;
  47234. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47235. SS_LODINREFRACTIONALPHA: boolean;
  47236. SS_GAMMAREFRACTION: boolean;
  47237. SS_RGBDREFRACTION: boolean;
  47238. SS_LINEARSPECULARREFRACTION: boolean;
  47239. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47240. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47241. /** @hidden */
  47242. _areTexturesDirty: boolean;
  47243. }
  47244. /**
  47245. * Define the code related to the sub surface parameters of the pbr material.
  47246. */
  47247. export class PBRSubSurfaceConfiguration {
  47248. private _isRefractionEnabled;
  47249. /**
  47250. * Defines if the refraction is enabled in the material.
  47251. */
  47252. isRefractionEnabled: boolean;
  47253. private _isTranslucencyEnabled;
  47254. /**
  47255. * Defines if the translucency is enabled in the material.
  47256. */
  47257. isTranslucencyEnabled: boolean;
  47258. private _isScatteringEnabled;
  47259. /**
  47260. * Defines the refraction intensity of the material.
  47261. * The refraction when enabled replaces the Diffuse part of the material.
  47262. * The intensity helps transitionning between diffuse and refraction.
  47263. */
  47264. refractionIntensity: number;
  47265. /**
  47266. * Defines the translucency intensity of the material.
  47267. * When translucency has been enabled, this defines how much of the "translucency"
  47268. * is addded to the diffuse part of the material.
  47269. */
  47270. translucencyIntensity: number;
  47271. /**
  47272. * Defines the scattering intensity of the material.
  47273. * When scattering has been enabled, this defines how much of the "scattered light"
  47274. * is addded to the diffuse part of the material.
  47275. */
  47276. scatteringIntensity: number;
  47277. private _thicknessTexture;
  47278. /**
  47279. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47280. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47281. * 0 would mean minimumThickness
  47282. * 1 would mean maximumThickness
  47283. * The other channels might be use as a mask to vary the different effects intensity.
  47284. */
  47285. thicknessTexture: Nullable<BaseTexture>;
  47286. private _refractionTexture;
  47287. /**
  47288. * Defines the texture to use for refraction.
  47289. */
  47290. refractionTexture: Nullable<BaseTexture>;
  47291. private _indexOfRefraction;
  47292. /**
  47293. * Defines the index of refraction used in the material.
  47294. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47295. */
  47296. indexOfRefraction: number;
  47297. private _invertRefractionY;
  47298. /**
  47299. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47300. */
  47301. invertRefractionY: boolean;
  47302. private _linkRefractionWithTransparency;
  47303. /**
  47304. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47305. * Materials half opaque for instance using refraction could benefit from this control.
  47306. */
  47307. linkRefractionWithTransparency: boolean;
  47308. /**
  47309. * Defines the minimum thickness stored in the thickness map.
  47310. * If no thickness map is defined, this value will be used to simulate thickness.
  47311. */
  47312. minimumThickness: number;
  47313. /**
  47314. * Defines the maximum thickness stored in the thickness map.
  47315. */
  47316. maximumThickness: number;
  47317. /**
  47318. * Defines the volume tint of the material.
  47319. * This is used for both translucency and scattering.
  47320. */
  47321. tintColor: Color3;
  47322. /**
  47323. * Defines the distance at which the tint color should be found in the media.
  47324. * This is used for refraction only.
  47325. */
  47326. tintColorAtDistance: number;
  47327. /**
  47328. * Defines how far each channel transmit through the media.
  47329. * It is defined as a color to simplify it selection.
  47330. */
  47331. diffusionDistance: Color3;
  47332. private _useMaskFromThicknessTexture;
  47333. /**
  47334. * Stores the intensity of the different subsurface effects in the thickness texture.
  47335. * * the green channel is the translucency intensity.
  47336. * * the blue channel is the scattering intensity.
  47337. * * the alpha channel is the refraction intensity.
  47338. */
  47339. useMaskFromThicknessTexture: boolean;
  47340. /** @hidden */
  47341. private _internalMarkAllSubMeshesAsTexturesDirty;
  47342. /** @hidden */
  47343. _markAllSubMeshesAsTexturesDirty(): void;
  47344. /**
  47345. * Instantiate a new istance of sub surface configuration.
  47346. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47347. */
  47348. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47349. /**
  47350. * Gets wehter the submesh is ready to be used or not.
  47351. * @param defines the list of "defines" to update.
  47352. * @param scene defines the scene the material belongs to.
  47353. * @returns - boolean indicating that the submesh is ready or not.
  47354. */
  47355. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47356. /**
  47357. * Checks to see if a texture is used in the material.
  47358. * @param defines the list of "defines" to update.
  47359. * @param scene defines the scene to the material belongs to.
  47360. */
  47361. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47362. /**
  47363. * Binds the material data.
  47364. * @param uniformBuffer defines the Uniform buffer to fill in.
  47365. * @param scene defines the scene the material belongs to.
  47366. * @param engine defines the engine the material belongs to.
  47367. * @param isFrozen defines wether the material is frozen or not.
  47368. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47369. */
  47370. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47371. /**
  47372. * Unbinds the material from the mesh.
  47373. * @param activeEffect defines the effect that should be unbound from.
  47374. * @returns true if unbound, otherwise false
  47375. */
  47376. unbind(activeEffect: Effect): boolean;
  47377. /**
  47378. * Returns the texture used for refraction or null if none is used.
  47379. * @param scene defines the scene the material belongs to.
  47380. * @returns - Refraction texture if present. If no refraction texture and refraction
  47381. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47382. */
  47383. private _getRefractionTexture;
  47384. /**
  47385. * Returns true if alpha blending should be disabled.
  47386. */
  47387. readonly disableAlphaBlending: boolean;
  47388. /**
  47389. * Fills the list of render target textures.
  47390. * @param renderTargets the list of render targets to update
  47391. */
  47392. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47393. /**
  47394. * Checks to see if a texture is used in the material.
  47395. * @param texture - Base texture to use.
  47396. * @returns - Boolean specifying if a texture is used in the material.
  47397. */
  47398. hasTexture(texture: BaseTexture): boolean;
  47399. /**
  47400. * Gets a boolean indicating that current material needs to register RTT
  47401. * @returns true if this uses a render target otherwise false.
  47402. */
  47403. hasRenderTargetTextures(): boolean;
  47404. /**
  47405. * Returns an array of the actively used textures.
  47406. * @param activeTextures Array of BaseTextures
  47407. */
  47408. getActiveTextures(activeTextures: BaseTexture[]): void;
  47409. /**
  47410. * Returns the animatable textures.
  47411. * @param animatables Array of animatable textures.
  47412. */
  47413. getAnimatables(animatables: IAnimatable[]): void;
  47414. /**
  47415. * Disposes the resources of the material.
  47416. * @param forceDisposeTextures - Forces the disposal of all textures.
  47417. */
  47418. dispose(forceDisposeTextures?: boolean): void;
  47419. /**
  47420. * Get the current class name of the texture useful for serialization or dynamic coding.
  47421. * @returns "PBRSubSurfaceConfiguration"
  47422. */
  47423. getClassName(): string;
  47424. /**
  47425. * Add fallbacks to the effect fallbacks list.
  47426. * @param defines defines the Base texture to use.
  47427. * @param fallbacks defines the current fallback list.
  47428. * @param currentRank defines the current fallback rank.
  47429. * @returns the new fallback rank.
  47430. */
  47431. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47432. /**
  47433. * Add the required uniforms to the current list.
  47434. * @param uniforms defines the current uniform list.
  47435. */
  47436. static AddUniforms(uniforms: string[]): void;
  47437. /**
  47438. * Add the required samplers to the current list.
  47439. * @param samplers defines the current sampler list.
  47440. */
  47441. static AddSamplers(samplers: string[]): void;
  47442. /**
  47443. * Add the required uniforms to the current buffer.
  47444. * @param uniformBuffer defines the current uniform buffer.
  47445. */
  47446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47447. /**
  47448. * Makes a duplicate of the current configuration into another one.
  47449. * @param configuration define the config where to copy the info
  47450. */
  47451. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47452. /**
  47453. * Serializes this Sub Surface configuration.
  47454. * @returns - An object with the serialized config.
  47455. */
  47456. serialize(): any;
  47457. /**
  47458. * Parses a anisotropy Configuration from a serialized object.
  47459. * @param source - Serialized object.
  47460. * @param scene Defines the scene we are parsing for
  47461. * @param rootUrl Defines the rootUrl to load from
  47462. */
  47463. parse(source: any, scene: Scene, rootUrl: string): void;
  47464. }
  47465. }
  47466. declare module BABYLON {
  47467. /** @hidden */
  47468. export var pbrFragmentDeclaration: {
  47469. name: string;
  47470. shader: string;
  47471. };
  47472. }
  47473. declare module BABYLON {
  47474. /** @hidden */
  47475. export var pbrUboDeclaration: {
  47476. name: string;
  47477. shader: string;
  47478. };
  47479. }
  47480. declare module BABYLON {
  47481. /** @hidden */
  47482. export var pbrFragmentExtraDeclaration: {
  47483. name: string;
  47484. shader: string;
  47485. };
  47486. }
  47487. declare module BABYLON {
  47488. /** @hidden */
  47489. export var pbrFragmentSamplersDeclaration: {
  47490. name: string;
  47491. shader: string;
  47492. };
  47493. }
  47494. declare module BABYLON {
  47495. /** @hidden */
  47496. export var pbrHelperFunctions: {
  47497. name: string;
  47498. shader: string;
  47499. };
  47500. }
  47501. declare module BABYLON {
  47502. /** @hidden */
  47503. export var harmonicsFunctions: {
  47504. name: string;
  47505. shader: string;
  47506. };
  47507. }
  47508. declare module BABYLON {
  47509. /** @hidden */
  47510. export var pbrDirectLightingSetupFunctions: {
  47511. name: string;
  47512. shader: string;
  47513. };
  47514. }
  47515. declare module BABYLON {
  47516. /** @hidden */
  47517. export var pbrDirectLightingFalloffFunctions: {
  47518. name: string;
  47519. shader: string;
  47520. };
  47521. }
  47522. declare module BABYLON {
  47523. /** @hidden */
  47524. export var pbrBRDFFunctions: {
  47525. name: string;
  47526. shader: string;
  47527. };
  47528. }
  47529. declare module BABYLON {
  47530. /** @hidden */
  47531. export var pbrDirectLightingFunctions: {
  47532. name: string;
  47533. shader: string;
  47534. };
  47535. }
  47536. declare module BABYLON {
  47537. /** @hidden */
  47538. export var pbrIBLFunctions: {
  47539. name: string;
  47540. shader: string;
  47541. };
  47542. }
  47543. declare module BABYLON {
  47544. /** @hidden */
  47545. export var pbrDebug: {
  47546. name: string;
  47547. shader: string;
  47548. };
  47549. }
  47550. declare module BABYLON {
  47551. /** @hidden */
  47552. export var pbrPixelShader: {
  47553. name: string;
  47554. shader: string;
  47555. };
  47556. }
  47557. declare module BABYLON {
  47558. /** @hidden */
  47559. export var pbrVertexDeclaration: {
  47560. name: string;
  47561. shader: string;
  47562. };
  47563. }
  47564. declare module BABYLON {
  47565. /** @hidden */
  47566. export var pbrVertexShader: {
  47567. name: string;
  47568. shader: string;
  47569. };
  47570. }
  47571. declare module BABYLON {
  47572. /**
  47573. * Manages the defines for the PBR Material.
  47574. * @hidden
  47575. */
  47576. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47577. PBR: boolean;
  47578. MAINUV1: boolean;
  47579. MAINUV2: boolean;
  47580. UV1: boolean;
  47581. UV2: boolean;
  47582. ALBEDO: boolean;
  47583. ALBEDODIRECTUV: number;
  47584. VERTEXCOLOR: boolean;
  47585. AMBIENT: boolean;
  47586. AMBIENTDIRECTUV: number;
  47587. AMBIENTINGRAYSCALE: boolean;
  47588. OPACITY: boolean;
  47589. VERTEXALPHA: boolean;
  47590. OPACITYDIRECTUV: number;
  47591. OPACITYRGB: boolean;
  47592. ALPHATEST: boolean;
  47593. DEPTHPREPASS: boolean;
  47594. ALPHABLEND: boolean;
  47595. ALPHAFROMALBEDO: boolean;
  47596. ALPHATESTVALUE: string;
  47597. SPECULAROVERALPHA: boolean;
  47598. RADIANCEOVERALPHA: boolean;
  47599. ALPHAFRESNEL: boolean;
  47600. LINEARALPHAFRESNEL: boolean;
  47601. PREMULTIPLYALPHA: boolean;
  47602. EMISSIVE: boolean;
  47603. EMISSIVEDIRECTUV: number;
  47604. REFLECTIVITY: boolean;
  47605. REFLECTIVITYDIRECTUV: number;
  47606. SPECULARTERM: boolean;
  47607. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47608. MICROSURFACEAUTOMATIC: boolean;
  47609. LODBASEDMICROSFURACE: boolean;
  47610. MICROSURFACEMAP: boolean;
  47611. MICROSURFACEMAPDIRECTUV: number;
  47612. METALLICWORKFLOW: boolean;
  47613. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47614. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47615. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47616. AOSTOREINMETALMAPRED: boolean;
  47617. ENVIRONMENTBRDF: boolean;
  47618. ENVIRONMENTBRDF_RGBD: boolean;
  47619. NORMAL: boolean;
  47620. TANGENT: boolean;
  47621. BUMP: boolean;
  47622. BUMPDIRECTUV: number;
  47623. OBJECTSPACE_NORMALMAP: boolean;
  47624. PARALLAX: boolean;
  47625. PARALLAXOCCLUSION: boolean;
  47626. NORMALXYSCALE: boolean;
  47627. LIGHTMAP: boolean;
  47628. LIGHTMAPDIRECTUV: number;
  47629. USELIGHTMAPASSHADOWMAP: boolean;
  47630. GAMMALIGHTMAP: boolean;
  47631. RGBDLIGHTMAP: boolean;
  47632. REFLECTION: boolean;
  47633. REFLECTIONMAP_3D: boolean;
  47634. REFLECTIONMAP_SPHERICAL: boolean;
  47635. REFLECTIONMAP_PLANAR: boolean;
  47636. REFLECTIONMAP_CUBIC: boolean;
  47637. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47638. REFLECTIONMAP_PROJECTION: boolean;
  47639. REFLECTIONMAP_SKYBOX: boolean;
  47640. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47641. REFLECTIONMAP_EXPLICIT: boolean;
  47642. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47643. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47644. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47645. INVERTCUBICMAP: boolean;
  47646. USESPHERICALFROMREFLECTIONMAP: boolean;
  47647. USEIRRADIANCEMAP: boolean;
  47648. SPHERICAL_HARMONICS: boolean;
  47649. USESPHERICALINVERTEX: boolean;
  47650. REFLECTIONMAP_OPPOSITEZ: boolean;
  47651. LODINREFLECTIONALPHA: boolean;
  47652. GAMMAREFLECTION: boolean;
  47653. RGBDREFLECTION: boolean;
  47654. LINEARSPECULARREFLECTION: boolean;
  47655. RADIANCEOCCLUSION: boolean;
  47656. HORIZONOCCLUSION: boolean;
  47657. INSTANCES: boolean;
  47658. NUM_BONE_INFLUENCERS: number;
  47659. BonesPerMesh: number;
  47660. BONETEXTURE: boolean;
  47661. NONUNIFORMSCALING: boolean;
  47662. MORPHTARGETS: boolean;
  47663. MORPHTARGETS_NORMAL: boolean;
  47664. MORPHTARGETS_TANGENT: boolean;
  47665. MORPHTARGETS_UV: boolean;
  47666. NUM_MORPH_INFLUENCERS: number;
  47667. IMAGEPROCESSING: boolean;
  47668. VIGNETTE: boolean;
  47669. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47670. VIGNETTEBLENDMODEOPAQUE: boolean;
  47671. TONEMAPPING: boolean;
  47672. TONEMAPPING_ACES: boolean;
  47673. CONTRAST: boolean;
  47674. COLORCURVES: boolean;
  47675. COLORGRADING: boolean;
  47676. COLORGRADING3D: boolean;
  47677. SAMPLER3DGREENDEPTH: boolean;
  47678. SAMPLER3DBGRMAP: boolean;
  47679. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47680. EXPOSURE: boolean;
  47681. MULTIVIEW: boolean;
  47682. USEPHYSICALLIGHTFALLOFF: boolean;
  47683. USEGLTFLIGHTFALLOFF: boolean;
  47684. TWOSIDEDLIGHTING: boolean;
  47685. SHADOWFLOAT: boolean;
  47686. CLIPPLANE: boolean;
  47687. CLIPPLANE2: boolean;
  47688. CLIPPLANE3: boolean;
  47689. CLIPPLANE4: boolean;
  47690. POINTSIZE: boolean;
  47691. FOG: boolean;
  47692. LOGARITHMICDEPTH: boolean;
  47693. FORCENORMALFORWARD: boolean;
  47694. SPECULARAA: boolean;
  47695. CLEARCOAT: boolean;
  47696. CLEARCOAT_DEFAULTIOR: boolean;
  47697. CLEARCOAT_TEXTURE: boolean;
  47698. CLEARCOAT_TEXTUREDIRECTUV: number;
  47699. CLEARCOAT_BUMP: boolean;
  47700. CLEARCOAT_BUMPDIRECTUV: number;
  47701. CLEARCOAT_TINT: boolean;
  47702. CLEARCOAT_TINT_TEXTURE: boolean;
  47703. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47704. ANISOTROPIC: boolean;
  47705. ANISOTROPIC_TEXTURE: boolean;
  47706. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47707. BRDF_V_HEIGHT_CORRELATED: boolean;
  47708. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47709. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47710. SHEEN: boolean;
  47711. SHEEN_TEXTURE: boolean;
  47712. SHEEN_TEXTUREDIRECTUV: number;
  47713. SHEEN_LINKWITHALBEDO: boolean;
  47714. SUBSURFACE: boolean;
  47715. SS_REFRACTION: boolean;
  47716. SS_TRANSLUCENCY: boolean;
  47717. SS_SCATERRING: boolean;
  47718. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47719. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47720. SS_REFRACTIONMAP_3D: boolean;
  47721. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47722. SS_LODINREFRACTIONALPHA: boolean;
  47723. SS_GAMMAREFRACTION: boolean;
  47724. SS_RGBDREFRACTION: boolean;
  47725. SS_LINEARSPECULARREFRACTION: boolean;
  47726. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47727. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47728. UNLIT: boolean;
  47729. DEBUGMODE: number;
  47730. /**
  47731. * Initializes the PBR Material defines.
  47732. */
  47733. constructor();
  47734. /**
  47735. * Resets the PBR Material defines.
  47736. */
  47737. reset(): void;
  47738. }
  47739. /**
  47740. * The Physically based material base class of BJS.
  47741. *
  47742. * This offers the main features of a standard PBR material.
  47743. * For more information, please refer to the documentation :
  47744. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47745. */
  47746. export abstract class PBRBaseMaterial extends PushMaterial {
  47747. /**
  47748. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47749. */
  47750. static readonly PBRMATERIAL_OPAQUE: number;
  47751. /**
  47752. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47753. */
  47754. static readonly PBRMATERIAL_ALPHATEST: number;
  47755. /**
  47756. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47757. */
  47758. static readonly PBRMATERIAL_ALPHABLEND: number;
  47759. /**
  47760. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47761. * They are also discarded below the alpha cutoff threshold to improve performances.
  47762. */
  47763. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47764. /**
  47765. * Defines the default value of how much AO map is occluding the analytical lights
  47766. * (point spot...).
  47767. */
  47768. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47769. /**
  47770. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47771. */
  47772. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47773. /**
  47774. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47775. * to enhance interoperability with other engines.
  47776. */
  47777. static readonly LIGHTFALLOFF_GLTF: number;
  47778. /**
  47779. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47780. * to enhance interoperability with other materials.
  47781. */
  47782. static readonly LIGHTFALLOFF_STANDARD: number;
  47783. /**
  47784. * Intensity of the direct lights e.g. the four lights available in your scene.
  47785. * This impacts both the direct diffuse and specular highlights.
  47786. */
  47787. protected _directIntensity: number;
  47788. /**
  47789. * Intensity of the emissive part of the material.
  47790. * This helps controlling the emissive effect without modifying the emissive color.
  47791. */
  47792. protected _emissiveIntensity: number;
  47793. /**
  47794. * Intensity of the environment e.g. how much the environment will light the object
  47795. * either through harmonics for rough material or through the refelction for shiny ones.
  47796. */
  47797. protected _environmentIntensity: number;
  47798. /**
  47799. * This is a special control allowing the reduction of the specular highlights coming from the
  47800. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47801. */
  47802. protected _specularIntensity: number;
  47803. /**
  47804. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47805. */
  47806. private _lightingInfos;
  47807. /**
  47808. * Debug Control allowing disabling the bump map on this material.
  47809. */
  47810. protected _disableBumpMap: boolean;
  47811. /**
  47812. * AKA Diffuse Texture in standard nomenclature.
  47813. */
  47814. protected _albedoTexture: Nullable<BaseTexture>;
  47815. /**
  47816. * AKA Occlusion Texture in other nomenclature.
  47817. */
  47818. protected _ambientTexture: Nullable<BaseTexture>;
  47819. /**
  47820. * AKA Occlusion Texture Intensity in other nomenclature.
  47821. */
  47822. protected _ambientTextureStrength: number;
  47823. /**
  47824. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47825. * 1 means it completely occludes it
  47826. * 0 mean it has no impact
  47827. */
  47828. protected _ambientTextureImpactOnAnalyticalLights: number;
  47829. /**
  47830. * Stores the alpha values in a texture.
  47831. */
  47832. protected _opacityTexture: Nullable<BaseTexture>;
  47833. /**
  47834. * Stores the reflection values in a texture.
  47835. */
  47836. protected _reflectionTexture: Nullable<BaseTexture>;
  47837. /**
  47838. * Stores the emissive values in a texture.
  47839. */
  47840. protected _emissiveTexture: Nullable<BaseTexture>;
  47841. /**
  47842. * AKA Specular texture in other nomenclature.
  47843. */
  47844. protected _reflectivityTexture: Nullable<BaseTexture>;
  47845. /**
  47846. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47847. */
  47848. protected _metallicTexture: Nullable<BaseTexture>;
  47849. /**
  47850. * Specifies the metallic scalar of the metallic/roughness workflow.
  47851. * Can also be used to scale the metalness values of the metallic texture.
  47852. */
  47853. protected _metallic: Nullable<number>;
  47854. /**
  47855. * Specifies the roughness scalar of the metallic/roughness workflow.
  47856. * Can also be used to scale the roughness values of the metallic texture.
  47857. */
  47858. protected _roughness: Nullable<number>;
  47859. /**
  47860. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47861. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47862. */
  47863. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47864. /**
  47865. * Stores surface normal data used to displace a mesh in a texture.
  47866. */
  47867. protected _bumpTexture: Nullable<BaseTexture>;
  47868. /**
  47869. * Stores the pre-calculated light information of a mesh in a texture.
  47870. */
  47871. protected _lightmapTexture: Nullable<BaseTexture>;
  47872. /**
  47873. * The color of a material in ambient lighting.
  47874. */
  47875. protected _ambientColor: Color3;
  47876. /**
  47877. * AKA Diffuse Color in other nomenclature.
  47878. */
  47879. protected _albedoColor: Color3;
  47880. /**
  47881. * AKA Specular Color in other nomenclature.
  47882. */
  47883. protected _reflectivityColor: Color3;
  47884. /**
  47885. * The color applied when light is reflected from a material.
  47886. */
  47887. protected _reflectionColor: Color3;
  47888. /**
  47889. * The color applied when light is emitted from a material.
  47890. */
  47891. protected _emissiveColor: Color3;
  47892. /**
  47893. * AKA Glossiness in other nomenclature.
  47894. */
  47895. protected _microSurface: number;
  47896. /**
  47897. * Specifies that the material will use the light map as a show map.
  47898. */
  47899. protected _useLightmapAsShadowmap: boolean;
  47900. /**
  47901. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47902. * makes the reflect vector face the model (under horizon).
  47903. */
  47904. protected _useHorizonOcclusion: boolean;
  47905. /**
  47906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47907. * too much the area relying on ambient texture to define their ambient occlusion.
  47908. */
  47909. protected _useRadianceOcclusion: boolean;
  47910. /**
  47911. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47912. */
  47913. protected _useAlphaFromAlbedoTexture: boolean;
  47914. /**
  47915. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47916. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47917. */
  47918. protected _useSpecularOverAlpha: boolean;
  47919. /**
  47920. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47921. */
  47922. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47923. /**
  47924. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47925. */
  47926. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47927. /**
  47928. * Specifies if the metallic texture contains the roughness information in its green channel.
  47929. */
  47930. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47931. /**
  47932. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47933. */
  47934. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47935. /**
  47936. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47937. */
  47938. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47939. /**
  47940. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47941. */
  47942. protected _useAmbientInGrayScale: boolean;
  47943. /**
  47944. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47945. * The material will try to infer what glossiness each pixel should be.
  47946. */
  47947. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47948. /**
  47949. * Defines the falloff type used in this material.
  47950. * It by default is Physical.
  47951. */
  47952. protected _lightFalloff: number;
  47953. /**
  47954. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47955. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47956. */
  47957. protected _useRadianceOverAlpha: boolean;
  47958. /**
  47959. * Allows using an object space normal map (instead of tangent space).
  47960. */
  47961. protected _useObjectSpaceNormalMap: boolean;
  47962. /**
  47963. * Allows using the bump map in parallax mode.
  47964. */
  47965. protected _useParallax: boolean;
  47966. /**
  47967. * Allows using the bump map in parallax occlusion mode.
  47968. */
  47969. protected _useParallaxOcclusion: boolean;
  47970. /**
  47971. * Controls the scale bias of the parallax mode.
  47972. */
  47973. protected _parallaxScaleBias: number;
  47974. /**
  47975. * If sets to true, disables all the lights affecting the material.
  47976. */
  47977. protected _disableLighting: boolean;
  47978. /**
  47979. * Number of Simultaneous lights allowed on the material.
  47980. */
  47981. protected _maxSimultaneousLights: number;
  47982. /**
  47983. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47984. */
  47985. protected _invertNormalMapX: boolean;
  47986. /**
  47987. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47988. */
  47989. protected _invertNormalMapY: boolean;
  47990. /**
  47991. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47992. */
  47993. protected _twoSidedLighting: boolean;
  47994. /**
  47995. * Defines the alpha limits in alpha test mode.
  47996. */
  47997. protected _alphaCutOff: number;
  47998. /**
  47999. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48000. */
  48001. protected _forceAlphaTest: boolean;
  48002. /**
  48003. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48004. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48005. */
  48006. protected _useAlphaFresnel: boolean;
  48007. /**
  48008. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48009. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48010. */
  48011. protected _useLinearAlphaFresnel: boolean;
  48012. /**
  48013. * The transparency mode of the material.
  48014. */
  48015. protected _transparencyMode: Nullable<number>;
  48016. /**
  48017. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48018. * from cos thetav and roughness:
  48019. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48020. */
  48021. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48022. /**
  48023. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48024. */
  48025. protected _forceIrradianceInFragment: boolean;
  48026. /**
  48027. * Force normal to face away from face.
  48028. */
  48029. protected _forceNormalForward: boolean;
  48030. /**
  48031. * Enables specular anti aliasing in the PBR shader.
  48032. * It will both interacts on the Geometry for analytical and IBL lighting.
  48033. * It also prefilter the roughness map based on the bump values.
  48034. */
  48035. protected _enableSpecularAntiAliasing: boolean;
  48036. /**
  48037. * Default configuration related to image processing available in the PBR Material.
  48038. */
  48039. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48040. /**
  48041. * Keep track of the image processing observer to allow dispose and replace.
  48042. */
  48043. private _imageProcessingObserver;
  48044. /**
  48045. * Attaches a new image processing configuration to the PBR Material.
  48046. * @param configuration
  48047. */
  48048. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48049. /**
  48050. * Stores the available render targets.
  48051. */
  48052. private _renderTargets;
  48053. /**
  48054. * Sets the global ambient color for the material used in lighting calculations.
  48055. */
  48056. private _globalAmbientColor;
  48057. /**
  48058. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48059. */
  48060. private _useLogarithmicDepth;
  48061. /**
  48062. * If set to true, no lighting calculations will be applied.
  48063. */
  48064. private _unlit;
  48065. private _debugMode;
  48066. /**
  48067. * @hidden
  48068. * This is reserved for the inspector.
  48069. * Defines the material debug mode.
  48070. * It helps seeing only some components of the material while troubleshooting.
  48071. */
  48072. debugMode: number;
  48073. /**
  48074. * @hidden
  48075. * This is reserved for the inspector.
  48076. * Specify from where on screen the debug mode should start.
  48077. * The value goes from -1 (full screen) to 1 (not visible)
  48078. * It helps with side by side comparison against the final render
  48079. * This defaults to -1
  48080. */
  48081. private debugLimit;
  48082. /**
  48083. * @hidden
  48084. * This is reserved for the inspector.
  48085. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48086. * You can use the factor to better multiply the final value.
  48087. */
  48088. private debugFactor;
  48089. /**
  48090. * Defines the clear coat layer parameters for the material.
  48091. */
  48092. readonly clearCoat: PBRClearCoatConfiguration;
  48093. /**
  48094. * Defines the anisotropic parameters for the material.
  48095. */
  48096. readonly anisotropy: PBRAnisotropicConfiguration;
  48097. /**
  48098. * Defines the BRDF parameters for the material.
  48099. */
  48100. readonly brdf: PBRBRDFConfiguration;
  48101. /**
  48102. * Defines the Sheen parameters for the material.
  48103. */
  48104. readonly sheen: PBRSheenConfiguration;
  48105. /**
  48106. * Defines the SubSurface parameters for the material.
  48107. */
  48108. readonly subSurface: PBRSubSurfaceConfiguration;
  48109. /**
  48110. * Custom callback helping to override the default shader used in the material.
  48111. */
  48112. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48113. protected _rebuildInParallel: boolean;
  48114. /**
  48115. * Instantiates a new PBRMaterial instance.
  48116. *
  48117. * @param name The material name
  48118. * @param scene The scene the material will be use in.
  48119. */
  48120. constructor(name: string, scene: Scene);
  48121. /**
  48122. * Gets a boolean indicating that current material needs to register RTT
  48123. */
  48124. readonly hasRenderTargetTextures: boolean;
  48125. /**
  48126. * Gets the name of the material class.
  48127. */
  48128. getClassName(): string;
  48129. /**
  48130. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48131. */
  48132. /**
  48133. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48134. */
  48135. useLogarithmicDepth: boolean;
  48136. /**
  48137. * Gets the current transparency mode.
  48138. */
  48139. /**
  48140. * Sets the transparency mode of the material.
  48141. *
  48142. * | Value | Type | Description |
  48143. * | ----- | ----------------------------------- | ----------- |
  48144. * | 0 | OPAQUE | |
  48145. * | 1 | ALPHATEST | |
  48146. * | 2 | ALPHABLEND | |
  48147. * | 3 | ALPHATESTANDBLEND | |
  48148. *
  48149. */
  48150. transparencyMode: Nullable<number>;
  48151. /**
  48152. * Returns true if alpha blending should be disabled.
  48153. */
  48154. private readonly _disableAlphaBlending;
  48155. /**
  48156. * Specifies whether or not this material should be rendered in alpha blend mode.
  48157. */
  48158. needAlphaBlending(): boolean;
  48159. /**
  48160. * Specifies if the mesh will require alpha blending.
  48161. * @param mesh - BJS mesh.
  48162. */
  48163. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48164. /**
  48165. * Specifies whether or not this material should be rendered in alpha test mode.
  48166. */
  48167. needAlphaTesting(): boolean;
  48168. /**
  48169. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48170. */
  48171. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48172. /**
  48173. * Gets the texture used for the alpha test.
  48174. */
  48175. getAlphaTestTexture(): Nullable<BaseTexture>;
  48176. /**
  48177. * Specifies that the submesh is ready to be used.
  48178. * @param mesh - BJS mesh.
  48179. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48180. * @param useInstances - Specifies that instances should be used.
  48181. * @returns - boolean indicating that the submesh is ready or not.
  48182. */
  48183. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48184. /**
  48185. * Specifies if the material uses metallic roughness workflow.
  48186. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48187. */
  48188. isMetallicWorkflow(): boolean;
  48189. private _prepareEffect;
  48190. private _prepareDefines;
  48191. /**
  48192. * Force shader compilation
  48193. */
  48194. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48195. /**
  48196. * Initializes the uniform buffer layout for the shader.
  48197. */
  48198. buildUniformLayout(): void;
  48199. /**
  48200. * Unbinds the material from the mesh
  48201. */
  48202. unbind(): void;
  48203. /**
  48204. * Binds the submesh data.
  48205. * @param world - The world matrix.
  48206. * @param mesh - The BJS mesh.
  48207. * @param subMesh - A submesh of the BJS mesh.
  48208. */
  48209. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48210. /**
  48211. * Returns the animatable textures.
  48212. * @returns - Array of animatable textures.
  48213. */
  48214. getAnimatables(): IAnimatable[];
  48215. /**
  48216. * Returns the texture used for reflections.
  48217. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48218. */
  48219. private _getReflectionTexture;
  48220. /**
  48221. * Returns an array of the actively used textures.
  48222. * @returns - Array of BaseTextures
  48223. */
  48224. getActiveTextures(): BaseTexture[];
  48225. /**
  48226. * Checks to see if a texture is used in the material.
  48227. * @param texture - Base texture to use.
  48228. * @returns - Boolean specifying if a texture is used in the material.
  48229. */
  48230. hasTexture(texture: BaseTexture): boolean;
  48231. /**
  48232. * Disposes the resources of the material.
  48233. * @param forceDisposeEffect - Forces the disposal of effects.
  48234. * @param forceDisposeTextures - Forces the disposal of all textures.
  48235. */
  48236. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48237. }
  48238. }
  48239. declare module BABYLON {
  48240. /**
  48241. * The Physically based material of BJS.
  48242. *
  48243. * This offers the main features of a standard PBR material.
  48244. * For more information, please refer to the documentation :
  48245. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48246. */
  48247. export class PBRMaterial extends PBRBaseMaterial {
  48248. /**
  48249. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48250. */
  48251. static readonly PBRMATERIAL_OPAQUE: number;
  48252. /**
  48253. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48254. */
  48255. static readonly PBRMATERIAL_ALPHATEST: number;
  48256. /**
  48257. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48258. */
  48259. static readonly PBRMATERIAL_ALPHABLEND: number;
  48260. /**
  48261. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48262. * They are also discarded below the alpha cutoff threshold to improve performances.
  48263. */
  48264. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48265. /**
  48266. * Defines the default value of how much AO map is occluding the analytical lights
  48267. * (point spot...).
  48268. */
  48269. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48270. /**
  48271. * Intensity of the direct lights e.g. the four lights available in your scene.
  48272. * This impacts both the direct diffuse and specular highlights.
  48273. */
  48274. directIntensity: number;
  48275. /**
  48276. * Intensity of the emissive part of the material.
  48277. * This helps controlling the emissive effect without modifying the emissive color.
  48278. */
  48279. emissiveIntensity: number;
  48280. /**
  48281. * Intensity of the environment e.g. how much the environment will light the object
  48282. * either through harmonics for rough material or through the refelction for shiny ones.
  48283. */
  48284. environmentIntensity: number;
  48285. /**
  48286. * This is a special control allowing the reduction of the specular highlights coming from the
  48287. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48288. */
  48289. specularIntensity: number;
  48290. /**
  48291. * Debug Control allowing disabling the bump map on this material.
  48292. */
  48293. disableBumpMap: boolean;
  48294. /**
  48295. * AKA Diffuse Texture in standard nomenclature.
  48296. */
  48297. albedoTexture: BaseTexture;
  48298. /**
  48299. * AKA Occlusion Texture in other nomenclature.
  48300. */
  48301. ambientTexture: BaseTexture;
  48302. /**
  48303. * AKA Occlusion Texture Intensity in other nomenclature.
  48304. */
  48305. ambientTextureStrength: number;
  48306. /**
  48307. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48308. * 1 means it completely occludes it
  48309. * 0 mean it has no impact
  48310. */
  48311. ambientTextureImpactOnAnalyticalLights: number;
  48312. /**
  48313. * Stores the alpha values in a texture.
  48314. */
  48315. opacityTexture: BaseTexture;
  48316. /**
  48317. * Stores the reflection values in a texture.
  48318. */
  48319. reflectionTexture: Nullable<BaseTexture>;
  48320. /**
  48321. * Stores the emissive values in a texture.
  48322. */
  48323. emissiveTexture: BaseTexture;
  48324. /**
  48325. * AKA Specular texture in other nomenclature.
  48326. */
  48327. reflectivityTexture: BaseTexture;
  48328. /**
  48329. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48330. */
  48331. metallicTexture: BaseTexture;
  48332. /**
  48333. * Specifies the metallic scalar of the metallic/roughness workflow.
  48334. * Can also be used to scale the metalness values of the metallic texture.
  48335. */
  48336. metallic: Nullable<number>;
  48337. /**
  48338. * Specifies the roughness scalar of the metallic/roughness workflow.
  48339. * Can also be used to scale the roughness values of the metallic texture.
  48340. */
  48341. roughness: Nullable<number>;
  48342. /**
  48343. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48344. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48345. */
  48346. microSurfaceTexture: BaseTexture;
  48347. /**
  48348. * Stores surface normal data used to displace a mesh in a texture.
  48349. */
  48350. bumpTexture: BaseTexture;
  48351. /**
  48352. * Stores the pre-calculated light information of a mesh in a texture.
  48353. */
  48354. lightmapTexture: BaseTexture;
  48355. /**
  48356. * Stores the refracted light information in a texture.
  48357. */
  48358. refractionTexture: Nullable<BaseTexture>;
  48359. /**
  48360. * The color of a material in ambient lighting.
  48361. */
  48362. ambientColor: Color3;
  48363. /**
  48364. * AKA Diffuse Color in other nomenclature.
  48365. */
  48366. albedoColor: Color3;
  48367. /**
  48368. * AKA Specular Color in other nomenclature.
  48369. */
  48370. reflectivityColor: Color3;
  48371. /**
  48372. * The color reflected from the material.
  48373. */
  48374. reflectionColor: Color3;
  48375. /**
  48376. * The color emitted from the material.
  48377. */
  48378. emissiveColor: Color3;
  48379. /**
  48380. * AKA Glossiness in other nomenclature.
  48381. */
  48382. microSurface: number;
  48383. /**
  48384. * source material index of refraction (IOR)' / 'destination material IOR.
  48385. */
  48386. indexOfRefraction: number;
  48387. /**
  48388. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48389. */
  48390. invertRefractionY: boolean;
  48391. /**
  48392. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48393. * Materials half opaque for instance using refraction could benefit from this control.
  48394. */
  48395. linkRefractionWithTransparency: boolean;
  48396. /**
  48397. * If true, the light map contains occlusion information instead of lighting info.
  48398. */
  48399. useLightmapAsShadowmap: boolean;
  48400. /**
  48401. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48402. */
  48403. useAlphaFromAlbedoTexture: boolean;
  48404. /**
  48405. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48406. */
  48407. forceAlphaTest: boolean;
  48408. /**
  48409. * Defines the alpha limits in alpha test mode.
  48410. */
  48411. alphaCutOff: number;
  48412. /**
  48413. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48414. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48415. */
  48416. useSpecularOverAlpha: boolean;
  48417. /**
  48418. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48419. */
  48420. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48421. /**
  48422. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48423. */
  48424. useRoughnessFromMetallicTextureAlpha: boolean;
  48425. /**
  48426. * Specifies if the metallic texture contains the roughness information in its green channel.
  48427. */
  48428. useRoughnessFromMetallicTextureGreen: boolean;
  48429. /**
  48430. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48431. */
  48432. useMetallnessFromMetallicTextureBlue: boolean;
  48433. /**
  48434. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48435. */
  48436. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48437. /**
  48438. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48439. */
  48440. useAmbientInGrayScale: boolean;
  48441. /**
  48442. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48443. * The material will try to infer what glossiness each pixel should be.
  48444. */
  48445. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48446. /**
  48447. * BJS is using an harcoded light falloff based on a manually sets up range.
  48448. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48449. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48450. */
  48451. /**
  48452. * BJS is using an harcoded light falloff based on a manually sets up range.
  48453. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48454. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48455. */
  48456. usePhysicalLightFalloff: boolean;
  48457. /**
  48458. * In order to support the falloff compatibility with gltf, a special mode has been added
  48459. * to reproduce the gltf light falloff.
  48460. */
  48461. /**
  48462. * In order to support the falloff compatibility with gltf, a special mode has been added
  48463. * to reproduce the gltf light falloff.
  48464. */
  48465. useGLTFLightFalloff: boolean;
  48466. /**
  48467. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48468. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48469. */
  48470. useRadianceOverAlpha: boolean;
  48471. /**
  48472. * Allows using an object space normal map (instead of tangent space).
  48473. */
  48474. useObjectSpaceNormalMap: boolean;
  48475. /**
  48476. * Allows using the bump map in parallax mode.
  48477. */
  48478. useParallax: boolean;
  48479. /**
  48480. * Allows using the bump map in parallax occlusion mode.
  48481. */
  48482. useParallaxOcclusion: boolean;
  48483. /**
  48484. * Controls the scale bias of the parallax mode.
  48485. */
  48486. parallaxScaleBias: number;
  48487. /**
  48488. * If sets to true, disables all the lights affecting the material.
  48489. */
  48490. disableLighting: boolean;
  48491. /**
  48492. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48493. */
  48494. forceIrradianceInFragment: boolean;
  48495. /**
  48496. * Number of Simultaneous lights allowed on the material.
  48497. */
  48498. maxSimultaneousLights: number;
  48499. /**
  48500. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48501. */
  48502. invertNormalMapX: boolean;
  48503. /**
  48504. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48505. */
  48506. invertNormalMapY: boolean;
  48507. /**
  48508. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48509. */
  48510. twoSidedLighting: boolean;
  48511. /**
  48512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48513. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48514. */
  48515. useAlphaFresnel: boolean;
  48516. /**
  48517. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48518. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48519. */
  48520. useLinearAlphaFresnel: boolean;
  48521. /**
  48522. * Let user defines the brdf lookup texture used for IBL.
  48523. * A default 8bit version is embedded but you could point at :
  48524. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48525. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48526. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48527. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48528. */
  48529. environmentBRDFTexture: Nullable<BaseTexture>;
  48530. /**
  48531. * Force normal to face away from face.
  48532. */
  48533. forceNormalForward: boolean;
  48534. /**
  48535. * Enables specular anti aliasing in the PBR shader.
  48536. * It will both interacts on the Geometry for analytical and IBL lighting.
  48537. * It also prefilter the roughness map based on the bump values.
  48538. */
  48539. enableSpecularAntiAliasing: boolean;
  48540. /**
  48541. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48542. * makes the reflect vector face the model (under horizon).
  48543. */
  48544. useHorizonOcclusion: boolean;
  48545. /**
  48546. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48547. * too much the area relying on ambient texture to define their ambient occlusion.
  48548. */
  48549. useRadianceOcclusion: boolean;
  48550. /**
  48551. * If set to true, no lighting calculations will be applied.
  48552. */
  48553. unlit: boolean;
  48554. /**
  48555. * Gets the image processing configuration used either in this material.
  48556. */
  48557. /**
  48558. * Sets the Default image processing configuration used either in the this material.
  48559. *
  48560. * If sets to null, the scene one is in use.
  48561. */
  48562. imageProcessingConfiguration: ImageProcessingConfiguration;
  48563. /**
  48564. * Gets wether the color curves effect is enabled.
  48565. */
  48566. /**
  48567. * Sets wether the color curves effect is enabled.
  48568. */
  48569. cameraColorCurvesEnabled: boolean;
  48570. /**
  48571. * Gets wether the color grading effect is enabled.
  48572. */
  48573. /**
  48574. * Gets wether the color grading effect is enabled.
  48575. */
  48576. cameraColorGradingEnabled: boolean;
  48577. /**
  48578. * Gets wether tonemapping is enabled or not.
  48579. */
  48580. /**
  48581. * Sets wether tonemapping is enabled or not
  48582. */
  48583. cameraToneMappingEnabled: boolean;
  48584. /**
  48585. * The camera exposure used on this material.
  48586. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48587. * This corresponds to a photographic exposure.
  48588. */
  48589. /**
  48590. * The camera exposure used on this material.
  48591. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48592. * This corresponds to a photographic exposure.
  48593. */
  48594. cameraExposure: number;
  48595. /**
  48596. * Gets The camera contrast used on this material.
  48597. */
  48598. /**
  48599. * Sets The camera contrast used on this material.
  48600. */
  48601. cameraContrast: number;
  48602. /**
  48603. * Gets the Color Grading 2D Lookup Texture.
  48604. */
  48605. /**
  48606. * Sets the Color Grading 2D Lookup Texture.
  48607. */
  48608. cameraColorGradingTexture: Nullable<BaseTexture>;
  48609. /**
  48610. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48611. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48612. * 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;
  48613. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48614. */
  48615. /**
  48616. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48617. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48618. * 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;
  48619. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48620. */
  48621. cameraColorCurves: Nullable<ColorCurves>;
  48622. /**
  48623. * Instantiates a new PBRMaterial instance.
  48624. *
  48625. * @param name The material name
  48626. * @param scene The scene the material will be use in.
  48627. */
  48628. constructor(name: string, scene: Scene);
  48629. /**
  48630. * Returns the name of this material class.
  48631. */
  48632. getClassName(): string;
  48633. /**
  48634. * Makes a duplicate of the current material.
  48635. * @param name - name to use for the new material.
  48636. */
  48637. clone(name: string): PBRMaterial;
  48638. /**
  48639. * Serializes this PBR Material.
  48640. * @returns - An object with the serialized material.
  48641. */
  48642. serialize(): any;
  48643. /**
  48644. * Parses a PBR Material from a serialized object.
  48645. * @param source - Serialized object.
  48646. * @param scene - BJS scene instance.
  48647. * @param rootUrl - url for the scene object
  48648. * @returns - PBRMaterial
  48649. */
  48650. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48651. }
  48652. }
  48653. declare module BABYLON {
  48654. /**
  48655. * Direct draw surface info
  48656. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48657. */
  48658. export interface DDSInfo {
  48659. /**
  48660. * Width of the texture
  48661. */
  48662. width: number;
  48663. /**
  48664. * Width of the texture
  48665. */
  48666. height: number;
  48667. /**
  48668. * Number of Mipmaps for the texture
  48669. * @see https://en.wikipedia.org/wiki/Mipmap
  48670. */
  48671. mipmapCount: number;
  48672. /**
  48673. * If the textures format is a known fourCC format
  48674. * @see https://www.fourcc.org/
  48675. */
  48676. isFourCC: boolean;
  48677. /**
  48678. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48679. */
  48680. isRGB: boolean;
  48681. /**
  48682. * If the texture is a lumincance format
  48683. */
  48684. isLuminance: boolean;
  48685. /**
  48686. * If this is a cube texture
  48687. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48688. */
  48689. isCube: boolean;
  48690. /**
  48691. * If the texture is a compressed format eg. FOURCC_DXT1
  48692. */
  48693. isCompressed: boolean;
  48694. /**
  48695. * The dxgiFormat of the texture
  48696. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48697. */
  48698. dxgiFormat: number;
  48699. /**
  48700. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48701. */
  48702. textureType: number;
  48703. /**
  48704. * Sphericle polynomial created for the dds texture
  48705. */
  48706. sphericalPolynomial?: SphericalPolynomial;
  48707. }
  48708. /**
  48709. * Class used to provide DDS decompression tools
  48710. */
  48711. export class DDSTools {
  48712. /**
  48713. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48714. */
  48715. static StoreLODInAlphaChannel: boolean;
  48716. /**
  48717. * Gets DDS information from an array buffer
  48718. * @param arrayBuffer defines the array buffer to read data from
  48719. * @returns the DDS information
  48720. */
  48721. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48722. private static _FloatView;
  48723. private static _Int32View;
  48724. private static _ToHalfFloat;
  48725. private static _FromHalfFloat;
  48726. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48727. private static _GetHalfFloatRGBAArrayBuffer;
  48728. private static _GetFloatRGBAArrayBuffer;
  48729. private static _GetFloatAsUIntRGBAArrayBuffer;
  48730. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48731. private static _GetRGBAArrayBuffer;
  48732. private static _ExtractLongWordOrder;
  48733. private static _GetRGBArrayBuffer;
  48734. private static _GetLuminanceArrayBuffer;
  48735. /**
  48736. * Uploads DDS Levels to a Babylon Texture
  48737. * @hidden
  48738. */
  48739. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48740. }
  48741. interface ThinEngine {
  48742. /**
  48743. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48744. * @param rootUrl defines the url where the file to load is located
  48745. * @param scene defines the current scene
  48746. * @param lodScale defines scale to apply to the mip map selection
  48747. * @param lodOffset defines offset to apply to the mip map selection
  48748. * @param onLoad defines an optional callback raised when the texture is loaded
  48749. * @param onError defines an optional callback raised if there is an issue to load the texture
  48750. * @param format defines the format of the data
  48751. * @param forcedExtension defines the extension to use to pick the right loader
  48752. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48753. * @returns the cube texture as an InternalTexture
  48754. */
  48755. 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;
  48756. }
  48757. }
  48758. declare module BABYLON {
  48759. /**
  48760. * Implementation of the DDS Texture Loader.
  48761. * @hidden
  48762. */
  48763. export class _DDSTextureLoader implements IInternalTextureLoader {
  48764. /**
  48765. * Defines wether the loader supports cascade loading the different faces.
  48766. */
  48767. readonly supportCascades: boolean;
  48768. /**
  48769. * This returns if the loader support the current file information.
  48770. * @param extension defines the file extension of the file being loaded
  48771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48772. * @param fallback defines the fallback internal texture if any
  48773. * @param isBase64 defines whether the texture is encoded as a base64
  48774. * @param isBuffer defines whether the texture data are stored as a buffer
  48775. * @returns true if the loader can load the specified file
  48776. */
  48777. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48778. /**
  48779. * Transform the url before loading if required.
  48780. * @param rootUrl the url of the texture
  48781. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48782. * @returns the transformed texture
  48783. */
  48784. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48785. /**
  48786. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48787. * @param rootUrl the url of the texture
  48788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48789. * @returns the fallback texture
  48790. */
  48791. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48792. /**
  48793. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48794. * @param data contains the texture data
  48795. * @param texture defines the BabylonJS internal texture
  48796. * @param createPolynomials will be true if polynomials have been requested
  48797. * @param onLoad defines the callback to trigger once the texture is ready
  48798. * @param onError defines the callback to trigger in case of error
  48799. */
  48800. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48801. /**
  48802. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48803. * @param data contains the texture data
  48804. * @param texture defines the BabylonJS internal texture
  48805. * @param callback defines the method to call once ready to upload
  48806. */
  48807. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48808. }
  48809. }
  48810. declare module BABYLON {
  48811. /**
  48812. * Implementation of the ENV Texture Loader.
  48813. * @hidden
  48814. */
  48815. export class _ENVTextureLoader implements IInternalTextureLoader {
  48816. /**
  48817. * Defines wether the loader supports cascade loading the different faces.
  48818. */
  48819. readonly supportCascades: boolean;
  48820. /**
  48821. * This returns if the loader support the current file information.
  48822. * @param extension defines the file extension of the file being loaded
  48823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48824. * @param fallback defines the fallback internal texture if any
  48825. * @param isBase64 defines whether the texture is encoded as a base64
  48826. * @param isBuffer defines whether the texture data are stored as a buffer
  48827. * @returns true if the loader can load the specified file
  48828. */
  48829. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48830. /**
  48831. * Transform the url before loading if required.
  48832. * @param rootUrl the url of the texture
  48833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48834. * @returns the transformed texture
  48835. */
  48836. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48837. /**
  48838. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48839. * @param rootUrl the url of the texture
  48840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48841. * @returns the fallback texture
  48842. */
  48843. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48844. /**
  48845. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48846. * @param data contains the texture data
  48847. * @param texture defines the BabylonJS internal texture
  48848. * @param createPolynomials will be true if polynomials have been requested
  48849. * @param onLoad defines the callback to trigger once the texture is ready
  48850. * @param onError defines the callback to trigger in case of error
  48851. */
  48852. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48853. /**
  48854. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48855. * @param data contains the texture data
  48856. * @param texture defines the BabylonJS internal texture
  48857. * @param callback defines the method to call once ready to upload
  48858. */
  48859. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48860. }
  48861. }
  48862. declare module BABYLON {
  48863. /**
  48864. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48865. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48866. */
  48867. export class KhronosTextureContainer {
  48868. /** contents of the KTX container file */
  48869. arrayBuffer: any;
  48870. private static HEADER_LEN;
  48871. private static COMPRESSED_2D;
  48872. private static COMPRESSED_3D;
  48873. private static TEX_2D;
  48874. private static TEX_3D;
  48875. /**
  48876. * Gets the openGL type
  48877. */
  48878. glType: number;
  48879. /**
  48880. * Gets the openGL type size
  48881. */
  48882. glTypeSize: number;
  48883. /**
  48884. * Gets the openGL format
  48885. */
  48886. glFormat: number;
  48887. /**
  48888. * Gets the openGL internal format
  48889. */
  48890. glInternalFormat: number;
  48891. /**
  48892. * Gets the base internal format
  48893. */
  48894. glBaseInternalFormat: number;
  48895. /**
  48896. * Gets image width in pixel
  48897. */
  48898. pixelWidth: number;
  48899. /**
  48900. * Gets image height in pixel
  48901. */
  48902. pixelHeight: number;
  48903. /**
  48904. * Gets image depth in pixels
  48905. */
  48906. pixelDepth: number;
  48907. /**
  48908. * Gets the number of array elements
  48909. */
  48910. numberOfArrayElements: number;
  48911. /**
  48912. * Gets the number of faces
  48913. */
  48914. numberOfFaces: number;
  48915. /**
  48916. * Gets the number of mipmap levels
  48917. */
  48918. numberOfMipmapLevels: number;
  48919. /**
  48920. * Gets the bytes of key value data
  48921. */
  48922. bytesOfKeyValueData: number;
  48923. /**
  48924. * Gets the load type
  48925. */
  48926. loadType: number;
  48927. /**
  48928. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48929. */
  48930. isInvalid: boolean;
  48931. /**
  48932. * Creates a new KhronosTextureContainer
  48933. * @param arrayBuffer contents of the KTX container file
  48934. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48935. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48936. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48937. */
  48938. constructor(
  48939. /** contents of the KTX container file */
  48940. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48941. /**
  48942. * Uploads KTX content to a Babylon Texture.
  48943. * It is assumed that the texture has already been created & is currently bound
  48944. * @hidden
  48945. */
  48946. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48947. private _upload2DCompressedLevels;
  48948. }
  48949. }
  48950. declare module BABYLON {
  48951. /**
  48952. * Implementation of the KTX Texture Loader.
  48953. * @hidden
  48954. */
  48955. export class _KTXTextureLoader implements IInternalTextureLoader {
  48956. /**
  48957. * Defines wether the loader supports cascade loading the different faces.
  48958. */
  48959. readonly supportCascades: boolean;
  48960. /**
  48961. * This returns if the loader support the current file information.
  48962. * @param extension defines the file extension of the file being loaded
  48963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48964. * @param fallback defines the fallback internal texture if any
  48965. * @param isBase64 defines whether the texture is encoded as a base64
  48966. * @param isBuffer defines whether the texture data are stored as a buffer
  48967. * @returns true if the loader can load the specified file
  48968. */
  48969. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48970. /**
  48971. * Transform the url before loading if required.
  48972. * @param rootUrl the url of the texture
  48973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48974. * @returns the transformed texture
  48975. */
  48976. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48977. /**
  48978. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48979. * @param rootUrl the url of the texture
  48980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48981. * @returns the fallback texture
  48982. */
  48983. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48984. /**
  48985. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48986. * @param data contains the texture data
  48987. * @param texture defines the BabylonJS internal texture
  48988. * @param createPolynomials will be true if polynomials have been requested
  48989. * @param onLoad defines the callback to trigger once the texture is ready
  48990. * @param onError defines the callback to trigger in case of error
  48991. */
  48992. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48993. /**
  48994. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48995. * @param data contains the texture data
  48996. * @param texture defines the BabylonJS internal texture
  48997. * @param callback defines the method to call once ready to upload
  48998. */
  48999. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49000. }
  49001. }
  49002. declare module BABYLON {
  49003. /**
  49004. * Options for the default xr helper
  49005. */
  49006. export class WebXRDefaultExperienceOptions {
  49007. /**
  49008. * Floor meshes that should be used for teleporting
  49009. */
  49010. floorMeshes: Array<AbstractMesh>;
  49011. }
  49012. /**
  49013. * Default experience which provides a similar setup to the previous webVRExperience
  49014. */
  49015. export class WebXRDefaultExperience {
  49016. /**
  49017. * Base experience
  49018. */
  49019. baseExperience: WebXRExperienceHelper;
  49020. /**
  49021. * Input experience extension
  49022. */
  49023. input: WebXRInput;
  49024. /**
  49025. * Loads the controller models
  49026. */
  49027. controllerModelLoader: WebXRControllerModelLoader;
  49028. /**
  49029. * Enables laser pointer and selection
  49030. */
  49031. pointerSelection: WebXRControllerPointerSelection;
  49032. /**
  49033. * Enables teleportation
  49034. */
  49035. teleportation: WebXRControllerTeleportation;
  49036. /**
  49037. * Enables ui for enetering/exiting xr
  49038. */
  49039. enterExitUI: WebXREnterExitUI;
  49040. /**
  49041. * Default output canvas xr should render to
  49042. */
  49043. outputCanvas: WebXRManagedOutputCanvas;
  49044. /**
  49045. * Creates the default xr experience
  49046. * @param scene scene
  49047. * @param options options for basic configuration
  49048. * @returns resulting WebXRDefaultExperience
  49049. */
  49050. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49051. private constructor();
  49052. /**
  49053. * DIsposes of the experience helper
  49054. */
  49055. dispose(): void;
  49056. }
  49057. }
  49058. declare module BABYLON {
  49059. /** @hidden */
  49060. export var _forceSceneHelpersToBundle: boolean;
  49061. interface Scene {
  49062. /**
  49063. * Creates a default light for the scene.
  49064. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49065. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49066. */
  49067. createDefaultLight(replace?: boolean): void;
  49068. /**
  49069. * Creates a default camera for the scene.
  49070. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49071. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49072. * @param replace has default false, when true replaces the active camera in the scene
  49073. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49074. */
  49075. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49076. /**
  49077. * Creates a default camera and a default light.
  49078. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49079. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49080. * @param replace has the default false, when true replaces the active camera/light in the scene
  49081. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49082. */
  49083. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49084. /**
  49085. * Creates a new sky box
  49086. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49087. * @param environmentTexture defines the texture to use as environment texture
  49088. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49089. * @param scale defines the overall scale of the skybox
  49090. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49091. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49092. * @returns a new mesh holding the sky box
  49093. */
  49094. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49095. /**
  49096. * Creates a new environment
  49097. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49098. * @param options defines the options you can use to configure the environment
  49099. * @returns the new EnvironmentHelper
  49100. */
  49101. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49102. /**
  49103. * Creates a new VREXperienceHelper
  49104. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49105. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49106. * @returns a new VREXperienceHelper
  49107. */
  49108. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49109. /**
  49110. * Creates a new WebXRDefaultExperience
  49111. * @see http://doc.babylonjs.com/how_to/webxr
  49112. * @param options experience options
  49113. * @returns a promise for a new WebXRDefaultExperience
  49114. */
  49115. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49116. }
  49117. }
  49118. declare module BABYLON {
  49119. /**
  49120. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49121. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49122. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49123. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49124. */
  49125. export class VideoDome extends TransformNode {
  49126. /**
  49127. * Define the video source as a Monoscopic panoramic 360 video.
  49128. */
  49129. static readonly MODE_MONOSCOPIC: number;
  49130. /**
  49131. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49132. */
  49133. static readonly MODE_TOPBOTTOM: number;
  49134. /**
  49135. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49136. */
  49137. static readonly MODE_SIDEBYSIDE: number;
  49138. private _halfDome;
  49139. private _useDirectMapping;
  49140. /**
  49141. * The video texture being displayed on the sphere
  49142. */
  49143. protected _videoTexture: VideoTexture;
  49144. /**
  49145. * Gets the video texture being displayed on the sphere
  49146. */
  49147. readonly videoTexture: VideoTexture;
  49148. /**
  49149. * The skybox material
  49150. */
  49151. protected _material: BackgroundMaterial;
  49152. /**
  49153. * The surface used for the skybox
  49154. */
  49155. protected _mesh: Mesh;
  49156. /**
  49157. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49158. */
  49159. private _halfDomeMask;
  49160. /**
  49161. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49162. * Also see the options.resolution property.
  49163. */
  49164. fovMultiplier: number;
  49165. private _videoMode;
  49166. /**
  49167. * Gets or set the current video mode for the video. It can be:
  49168. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49169. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49170. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49171. */
  49172. videoMode: number;
  49173. /**
  49174. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49175. *
  49176. */
  49177. /**
  49178. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49179. */
  49180. halfDome: boolean;
  49181. /**
  49182. * Oberserver used in Stereoscopic VR Mode.
  49183. */
  49184. private _onBeforeCameraRenderObserver;
  49185. /**
  49186. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49187. * @param name Element's name, child elements will append suffixes for their own names.
  49188. * @param urlsOrVideo defines the url(s) or the video element to use
  49189. * @param options An object containing optional or exposed sub element properties
  49190. */
  49191. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49192. resolution?: number;
  49193. clickToPlay?: boolean;
  49194. autoPlay?: boolean;
  49195. loop?: boolean;
  49196. size?: number;
  49197. poster?: string;
  49198. faceForward?: boolean;
  49199. useDirectMapping?: boolean;
  49200. halfDomeMode?: boolean;
  49201. }, scene: Scene);
  49202. private _changeVideoMode;
  49203. /**
  49204. * Releases resources associated with this node.
  49205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49207. */
  49208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49209. }
  49210. }
  49211. declare module BABYLON {
  49212. /**
  49213. * This class can be used to get instrumentation data from a Babylon engine
  49214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49215. */
  49216. export class EngineInstrumentation implements IDisposable {
  49217. /**
  49218. * Define the instrumented engine.
  49219. */
  49220. engine: Engine;
  49221. private _captureGPUFrameTime;
  49222. private _gpuFrameTimeToken;
  49223. private _gpuFrameTime;
  49224. private _captureShaderCompilationTime;
  49225. private _shaderCompilationTime;
  49226. private _onBeginFrameObserver;
  49227. private _onEndFrameObserver;
  49228. private _onBeforeShaderCompilationObserver;
  49229. private _onAfterShaderCompilationObserver;
  49230. /**
  49231. * Gets the perf counter used for GPU frame time
  49232. */
  49233. readonly gpuFrameTimeCounter: PerfCounter;
  49234. /**
  49235. * Gets the GPU frame time capture status
  49236. */
  49237. /**
  49238. * Enable or disable the GPU frame time capture
  49239. */
  49240. captureGPUFrameTime: boolean;
  49241. /**
  49242. * Gets the perf counter used for shader compilation time
  49243. */
  49244. readonly shaderCompilationTimeCounter: PerfCounter;
  49245. /**
  49246. * Gets the shader compilation time capture status
  49247. */
  49248. /**
  49249. * Enable or disable the shader compilation time capture
  49250. */
  49251. captureShaderCompilationTime: boolean;
  49252. /**
  49253. * Instantiates a new engine instrumentation.
  49254. * This class can be used to get instrumentation data from a Babylon engine
  49255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49256. * @param engine Defines the engine to instrument
  49257. */
  49258. constructor(
  49259. /**
  49260. * Define the instrumented engine.
  49261. */
  49262. engine: Engine);
  49263. /**
  49264. * Dispose and release associated resources.
  49265. */
  49266. dispose(): void;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /**
  49271. * This class can be used to get instrumentation data from a Babylon engine
  49272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49273. */
  49274. export class SceneInstrumentation implements IDisposable {
  49275. /**
  49276. * Defines the scene to instrument
  49277. */
  49278. scene: Scene;
  49279. private _captureActiveMeshesEvaluationTime;
  49280. private _activeMeshesEvaluationTime;
  49281. private _captureRenderTargetsRenderTime;
  49282. private _renderTargetsRenderTime;
  49283. private _captureFrameTime;
  49284. private _frameTime;
  49285. private _captureRenderTime;
  49286. private _renderTime;
  49287. private _captureInterFrameTime;
  49288. private _interFrameTime;
  49289. private _captureParticlesRenderTime;
  49290. private _particlesRenderTime;
  49291. private _captureSpritesRenderTime;
  49292. private _spritesRenderTime;
  49293. private _capturePhysicsTime;
  49294. private _physicsTime;
  49295. private _captureAnimationsTime;
  49296. private _animationsTime;
  49297. private _captureCameraRenderTime;
  49298. private _cameraRenderTime;
  49299. private _onBeforeActiveMeshesEvaluationObserver;
  49300. private _onAfterActiveMeshesEvaluationObserver;
  49301. private _onBeforeRenderTargetsRenderObserver;
  49302. private _onAfterRenderTargetsRenderObserver;
  49303. private _onAfterRenderObserver;
  49304. private _onBeforeDrawPhaseObserver;
  49305. private _onAfterDrawPhaseObserver;
  49306. private _onBeforeAnimationsObserver;
  49307. private _onBeforeParticlesRenderingObserver;
  49308. private _onAfterParticlesRenderingObserver;
  49309. private _onBeforeSpritesRenderingObserver;
  49310. private _onAfterSpritesRenderingObserver;
  49311. private _onBeforePhysicsObserver;
  49312. private _onAfterPhysicsObserver;
  49313. private _onAfterAnimationsObserver;
  49314. private _onBeforeCameraRenderObserver;
  49315. private _onAfterCameraRenderObserver;
  49316. /**
  49317. * Gets the perf counter used for active meshes evaluation time
  49318. */
  49319. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49320. /**
  49321. * Gets the active meshes evaluation time capture status
  49322. */
  49323. /**
  49324. * Enable or disable the active meshes evaluation time capture
  49325. */
  49326. captureActiveMeshesEvaluationTime: boolean;
  49327. /**
  49328. * Gets the perf counter used for render targets render time
  49329. */
  49330. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49331. /**
  49332. * Gets the render targets render time capture status
  49333. */
  49334. /**
  49335. * Enable or disable the render targets render time capture
  49336. */
  49337. captureRenderTargetsRenderTime: boolean;
  49338. /**
  49339. * Gets the perf counter used for particles render time
  49340. */
  49341. readonly particlesRenderTimeCounter: PerfCounter;
  49342. /**
  49343. * Gets the particles render time capture status
  49344. */
  49345. /**
  49346. * Enable or disable the particles render time capture
  49347. */
  49348. captureParticlesRenderTime: boolean;
  49349. /**
  49350. * Gets the perf counter used for sprites render time
  49351. */
  49352. readonly spritesRenderTimeCounter: PerfCounter;
  49353. /**
  49354. * Gets the sprites render time capture status
  49355. */
  49356. /**
  49357. * Enable or disable the sprites render time capture
  49358. */
  49359. captureSpritesRenderTime: boolean;
  49360. /**
  49361. * Gets the perf counter used for physics time
  49362. */
  49363. readonly physicsTimeCounter: PerfCounter;
  49364. /**
  49365. * Gets the physics time capture status
  49366. */
  49367. /**
  49368. * Enable or disable the physics time capture
  49369. */
  49370. capturePhysicsTime: boolean;
  49371. /**
  49372. * Gets the perf counter used for animations time
  49373. */
  49374. readonly animationsTimeCounter: PerfCounter;
  49375. /**
  49376. * Gets the animations time capture status
  49377. */
  49378. /**
  49379. * Enable or disable the animations time capture
  49380. */
  49381. captureAnimationsTime: boolean;
  49382. /**
  49383. * Gets the perf counter used for frame time capture
  49384. */
  49385. readonly frameTimeCounter: PerfCounter;
  49386. /**
  49387. * Gets the frame time capture status
  49388. */
  49389. /**
  49390. * Enable or disable the frame time capture
  49391. */
  49392. captureFrameTime: boolean;
  49393. /**
  49394. * Gets the perf counter used for inter-frames time capture
  49395. */
  49396. readonly interFrameTimeCounter: PerfCounter;
  49397. /**
  49398. * Gets the inter-frames time capture status
  49399. */
  49400. /**
  49401. * Enable or disable the inter-frames time capture
  49402. */
  49403. captureInterFrameTime: boolean;
  49404. /**
  49405. * Gets the perf counter used for render time capture
  49406. */
  49407. readonly renderTimeCounter: PerfCounter;
  49408. /**
  49409. * Gets the render time capture status
  49410. */
  49411. /**
  49412. * Enable or disable the render time capture
  49413. */
  49414. captureRenderTime: boolean;
  49415. /**
  49416. * Gets the perf counter used for camera render time capture
  49417. */
  49418. readonly cameraRenderTimeCounter: PerfCounter;
  49419. /**
  49420. * Gets the camera render time capture status
  49421. */
  49422. /**
  49423. * Enable or disable the camera render time capture
  49424. */
  49425. captureCameraRenderTime: boolean;
  49426. /**
  49427. * Gets the perf counter used for draw calls
  49428. */
  49429. readonly drawCallsCounter: PerfCounter;
  49430. /**
  49431. * Instantiates a new scene instrumentation.
  49432. * This class can be used to get instrumentation data from a Babylon engine
  49433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49434. * @param scene Defines the scene to instrument
  49435. */
  49436. constructor(
  49437. /**
  49438. * Defines the scene to instrument
  49439. */
  49440. scene: Scene);
  49441. /**
  49442. * Dispose and release associated resources.
  49443. */
  49444. dispose(): void;
  49445. }
  49446. }
  49447. declare module BABYLON {
  49448. /** @hidden */
  49449. export var glowMapGenerationPixelShader: {
  49450. name: string;
  49451. shader: string;
  49452. };
  49453. }
  49454. declare module BABYLON {
  49455. /** @hidden */
  49456. export var glowMapGenerationVertexShader: {
  49457. name: string;
  49458. shader: string;
  49459. };
  49460. }
  49461. declare module BABYLON {
  49462. /**
  49463. * Effect layer options. This helps customizing the behaviour
  49464. * of the effect layer.
  49465. */
  49466. export interface IEffectLayerOptions {
  49467. /**
  49468. * Multiplication factor apply to the canvas size to compute the render target size
  49469. * used to generated the objects (the smaller the faster).
  49470. */
  49471. mainTextureRatio: number;
  49472. /**
  49473. * Enforces a fixed size texture to ensure effect stability across devices.
  49474. */
  49475. mainTextureFixedSize?: number;
  49476. /**
  49477. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49478. */
  49479. alphaBlendingMode: number;
  49480. /**
  49481. * The camera attached to the layer.
  49482. */
  49483. camera: Nullable<Camera>;
  49484. /**
  49485. * The rendering group to draw the layer in.
  49486. */
  49487. renderingGroupId: number;
  49488. }
  49489. /**
  49490. * The effect layer Helps adding post process effect blended with the main pass.
  49491. *
  49492. * This can be for instance use to generate glow or higlight effects on the scene.
  49493. *
  49494. * The effect layer class can not be used directly and is intented to inherited from to be
  49495. * customized per effects.
  49496. */
  49497. export abstract class EffectLayer {
  49498. private _vertexBuffers;
  49499. private _indexBuffer;
  49500. private _cachedDefines;
  49501. private _effectLayerMapGenerationEffect;
  49502. private _effectLayerOptions;
  49503. private _mergeEffect;
  49504. protected _scene: Scene;
  49505. protected _engine: Engine;
  49506. protected _maxSize: number;
  49507. protected _mainTextureDesiredSize: ISize;
  49508. protected _mainTexture: RenderTargetTexture;
  49509. protected _shouldRender: boolean;
  49510. protected _postProcesses: PostProcess[];
  49511. protected _textures: BaseTexture[];
  49512. protected _emissiveTextureAndColor: {
  49513. texture: Nullable<BaseTexture>;
  49514. color: Color4;
  49515. };
  49516. /**
  49517. * The name of the layer
  49518. */
  49519. name: string;
  49520. /**
  49521. * The clear color of the texture used to generate the glow map.
  49522. */
  49523. neutralColor: Color4;
  49524. /**
  49525. * Specifies wether the highlight layer is enabled or not.
  49526. */
  49527. isEnabled: boolean;
  49528. /**
  49529. * Gets the camera attached to the layer.
  49530. */
  49531. readonly camera: Nullable<Camera>;
  49532. /**
  49533. * Gets the rendering group id the layer should render in.
  49534. */
  49535. renderingGroupId: number;
  49536. /**
  49537. * An event triggered when the effect layer has been disposed.
  49538. */
  49539. onDisposeObservable: Observable<EffectLayer>;
  49540. /**
  49541. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49542. */
  49543. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49544. /**
  49545. * An event triggered when the generated texture is being merged in the scene.
  49546. */
  49547. onBeforeComposeObservable: Observable<EffectLayer>;
  49548. /**
  49549. * An event triggered when the generated texture has been merged in the scene.
  49550. */
  49551. onAfterComposeObservable: Observable<EffectLayer>;
  49552. /**
  49553. * An event triggered when the efffect layer changes its size.
  49554. */
  49555. onSizeChangedObservable: Observable<EffectLayer>;
  49556. /** @hidden */
  49557. static _SceneComponentInitialization: (scene: Scene) => void;
  49558. /**
  49559. * Instantiates a new effect Layer and references it in the scene.
  49560. * @param name The name of the layer
  49561. * @param scene The scene to use the layer in
  49562. */
  49563. constructor(
  49564. /** The Friendly of the effect in the scene */
  49565. name: string, scene: Scene);
  49566. /**
  49567. * Get the effect name of the layer.
  49568. * @return The effect name
  49569. */
  49570. abstract getEffectName(): string;
  49571. /**
  49572. * Checks for the readiness of the element composing the layer.
  49573. * @param subMesh the mesh to check for
  49574. * @param useInstances specify wether or not to use instances to render the mesh
  49575. * @return true if ready otherwise, false
  49576. */
  49577. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49578. /**
  49579. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49580. * @returns true if the effect requires stencil during the main canvas render pass.
  49581. */
  49582. abstract needStencil(): boolean;
  49583. /**
  49584. * Create the merge effect. This is the shader use to blit the information back
  49585. * to the main canvas at the end of the scene rendering.
  49586. * @returns The effect containing the shader used to merge the effect on the main canvas
  49587. */
  49588. protected abstract _createMergeEffect(): Effect;
  49589. /**
  49590. * Creates the render target textures and post processes used in the effect layer.
  49591. */
  49592. protected abstract _createTextureAndPostProcesses(): void;
  49593. /**
  49594. * Implementation specific of rendering the generating effect on the main canvas.
  49595. * @param effect The effect used to render through
  49596. */
  49597. protected abstract _internalRender(effect: Effect): void;
  49598. /**
  49599. * Sets the required values for both the emissive texture and and the main color.
  49600. */
  49601. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49602. /**
  49603. * Free any resources and references associated to a mesh.
  49604. * Internal use
  49605. * @param mesh The mesh to free.
  49606. */
  49607. abstract _disposeMesh(mesh: Mesh): void;
  49608. /**
  49609. * Serializes this layer (Glow or Highlight for example)
  49610. * @returns a serialized layer object
  49611. */
  49612. abstract serialize?(): any;
  49613. /**
  49614. * Initializes the effect layer with the required options.
  49615. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49616. */
  49617. protected _init(options: Partial<IEffectLayerOptions>): void;
  49618. /**
  49619. * Generates the index buffer of the full screen quad blending to the main canvas.
  49620. */
  49621. private _generateIndexBuffer;
  49622. /**
  49623. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49624. */
  49625. private _generateVertexBuffer;
  49626. /**
  49627. * Sets the main texture desired size which is the closest power of two
  49628. * of the engine canvas size.
  49629. */
  49630. private _setMainTextureSize;
  49631. /**
  49632. * Creates the main texture for the effect layer.
  49633. */
  49634. protected _createMainTexture(): void;
  49635. /**
  49636. * Adds specific effects defines.
  49637. * @param defines The defines to add specifics to.
  49638. */
  49639. protected _addCustomEffectDefines(defines: string[]): void;
  49640. /**
  49641. * Checks for the readiness of the element composing the layer.
  49642. * @param subMesh the mesh to check for
  49643. * @param useInstances specify wether or not to use instances to render the mesh
  49644. * @param emissiveTexture the associated emissive texture used to generate the glow
  49645. * @return true if ready otherwise, false
  49646. */
  49647. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49648. /**
  49649. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49650. */
  49651. render(): void;
  49652. /**
  49653. * Determine if a given mesh will be used in the current effect.
  49654. * @param mesh mesh to test
  49655. * @returns true if the mesh will be used
  49656. */
  49657. hasMesh(mesh: AbstractMesh): boolean;
  49658. /**
  49659. * Returns true if the layer contains information to display, otherwise false.
  49660. * @returns true if the glow layer should be rendered
  49661. */
  49662. shouldRender(): boolean;
  49663. /**
  49664. * Returns true if the mesh should render, otherwise false.
  49665. * @param mesh The mesh to render
  49666. * @returns true if it should render otherwise false
  49667. */
  49668. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49669. /**
  49670. * Returns true if the mesh can be rendered, otherwise false.
  49671. * @param mesh The mesh to render
  49672. * @param material The material used on the mesh
  49673. * @returns true if it can be rendered otherwise false
  49674. */
  49675. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49676. /**
  49677. * Returns true if the mesh should render, otherwise false.
  49678. * @param mesh The mesh to render
  49679. * @returns true if it should render otherwise false
  49680. */
  49681. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49682. /**
  49683. * Renders the submesh passed in parameter to the generation map.
  49684. */
  49685. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49686. /**
  49687. * Rebuild the required buffers.
  49688. * @hidden Internal use only.
  49689. */
  49690. _rebuild(): void;
  49691. /**
  49692. * Dispose only the render target textures and post process.
  49693. */
  49694. private _disposeTextureAndPostProcesses;
  49695. /**
  49696. * Dispose the highlight layer and free resources.
  49697. */
  49698. dispose(): void;
  49699. /**
  49700. * Gets the class name of the effect layer
  49701. * @returns the string with the class name of the effect layer
  49702. */
  49703. getClassName(): string;
  49704. /**
  49705. * Creates an effect layer from parsed effect layer data
  49706. * @param parsedEffectLayer defines effect layer data
  49707. * @param scene defines the current scene
  49708. * @param rootUrl defines the root URL containing the effect layer information
  49709. * @returns a parsed effect Layer
  49710. */
  49711. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49712. }
  49713. }
  49714. declare module BABYLON {
  49715. interface AbstractScene {
  49716. /**
  49717. * The list of effect layers (highlights/glow) added to the scene
  49718. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49719. * @see http://doc.babylonjs.com/how_to/glow_layer
  49720. */
  49721. effectLayers: Array<EffectLayer>;
  49722. /**
  49723. * Removes the given effect layer from this scene.
  49724. * @param toRemove defines the effect layer to remove
  49725. * @returns the index of the removed effect layer
  49726. */
  49727. removeEffectLayer(toRemove: EffectLayer): number;
  49728. /**
  49729. * Adds the given effect layer to this scene
  49730. * @param newEffectLayer defines the effect layer to add
  49731. */
  49732. addEffectLayer(newEffectLayer: EffectLayer): void;
  49733. }
  49734. /**
  49735. * Defines the layer scene component responsible to manage any effect layers
  49736. * in a given scene.
  49737. */
  49738. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49739. /**
  49740. * The component name helpfull to identify the component in the list of scene components.
  49741. */
  49742. readonly name: string;
  49743. /**
  49744. * The scene the component belongs to.
  49745. */
  49746. scene: Scene;
  49747. private _engine;
  49748. private _renderEffects;
  49749. private _needStencil;
  49750. private _previousStencilState;
  49751. /**
  49752. * Creates a new instance of the component for the given scene
  49753. * @param scene Defines the scene to register the component in
  49754. */
  49755. constructor(scene: Scene);
  49756. /**
  49757. * Registers the component in a given scene
  49758. */
  49759. register(): void;
  49760. /**
  49761. * Rebuilds the elements related to this component in case of
  49762. * context lost for instance.
  49763. */
  49764. rebuild(): void;
  49765. /**
  49766. * Serializes the component data to the specified json object
  49767. * @param serializationObject The object to serialize to
  49768. */
  49769. serialize(serializationObject: any): void;
  49770. /**
  49771. * Adds all the elements from the container to the scene
  49772. * @param container the container holding the elements
  49773. */
  49774. addFromContainer(container: AbstractScene): void;
  49775. /**
  49776. * Removes all the elements in the container from the scene
  49777. * @param container contains the elements to remove
  49778. * @param dispose if the removed element should be disposed (default: false)
  49779. */
  49780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49781. /**
  49782. * Disposes the component and the associated ressources.
  49783. */
  49784. dispose(): void;
  49785. private _isReadyForMesh;
  49786. private _renderMainTexture;
  49787. private _setStencil;
  49788. private _setStencilBack;
  49789. private _draw;
  49790. private _drawCamera;
  49791. private _drawRenderingGroup;
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /** @hidden */
  49796. export var glowMapMergePixelShader: {
  49797. name: string;
  49798. shader: string;
  49799. };
  49800. }
  49801. declare module BABYLON {
  49802. /** @hidden */
  49803. export var glowMapMergeVertexShader: {
  49804. name: string;
  49805. shader: string;
  49806. };
  49807. }
  49808. declare module BABYLON {
  49809. interface AbstractScene {
  49810. /**
  49811. * Return a the first highlight layer of the scene with a given name.
  49812. * @param name The name of the highlight layer to look for.
  49813. * @return The highlight layer if found otherwise null.
  49814. */
  49815. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49816. }
  49817. /**
  49818. * Glow layer options. This helps customizing the behaviour
  49819. * of the glow layer.
  49820. */
  49821. export interface IGlowLayerOptions {
  49822. /**
  49823. * Multiplication factor apply to the canvas size to compute the render target size
  49824. * used to generated the glowing objects (the smaller the faster).
  49825. */
  49826. mainTextureRatio: number;
  49827. /**
  49828. * Enforces a fixed size texture to ensure resize independant blur.
  49829. */
  49830. mainTextureFixedSize?: number;
  49831. /**
  49832. * How big is the kernel of the blur texture.
  49833. */
  49834. blurKernelSize: number;
  49835. /**
  49836. * The camera attached to the layer.
  49837. */
  49838. camera: Nullable<Camera>;
  49839. /**
  49840. * Enable MSAA by chosing the number of samples.
  49841. */
  49842. mainTextureSamples?: number;
  49843. /**
  49844. * The rendering group to draw the layer in.
  49845. */
  49846. renderingGroupId: number;
  49847. }
  49848. /**
  49849. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49850. *
  49851. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  49852. * glowy meshes to your scene.
  49853. *
  49854. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49855. */
  49856. export class GlowLayer extends EffectLayer {
  49857. /**
  49858. * Effect Name of the layer.
  49859. */
  49860. static readonly EffectName: string;
  49861. /**
  49862. * The default blur kernel size used for the glow.
  49863. */
  49864. static DefaultBlurKernelSize: number;
  49865. /**
  49866. * The default texture size ratio used for the glow.
  49867. */
  49868. static DefaultTextureRatio: number;
  49869. /**
  49870. * Sets the kernel size of the blur.
  49871. */
  49872. /**
  49873. * Gets the kernel size of the blur.
  49874. */
  49875. blurKernelSize: number;
  49876. /**
  49877. * Sets the glow intensity.
  49878. */
  49879. /**
  49880. * Gets the glow intensity.
  49881. */
  49882. intensity: number;
  49883. private _options;
  49884. private _intensity;
  49885. private _horizontalBlurPostprocess1;
  49886. private _verticalBlurPostprocess1;
  49887. private _horizontalBlurPostprocess2;
  49888. private _verticalBlurPostprocess2;
  49889. private _blurTexture1;
  49890. private _blurTexture2;
  49891. private _postProcesses1;
  49892. private _postProcesses2;
  49893. private _includedOnlyMeshes;
  49894. private _excludedMeshes;
  49895. /**
  49896. * Callback used to let the user override the color selection on a per mesh basis
  49897. */
  49898. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49899. /**
  49900. * Callback used to let the user override the texture selection on a per mesh basis
  49901. */
  49902. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49903. /**
  49904. * Instantiates a new glow Layer and references it to the scene.
  49905. * @param name The name of the layer
  49906. * @param scene The scene to use the layer in
  49907. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49908. */
  49909. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49910. /**
  49911. * Get the effect name of the layer.
  49912. * @return The effect name
  49913. */
  49914. getEffectName(): string;
  49915. /**
  49916. * Create the merge effect. This is the shader use to blit the information back
  49917. * to the main canvas at the end of the scene rendering.
  49918. */
  49919. protected _createMergeEffect(): Effect;
  49920. /**
  49921. * Creates the render target textures and post processes used in the glow layer.
  49922. */
  49923. protected _createTextureAndPostProcesses(): void;
  49924. /**
  49925. * Checks for the readiness of the element composing the layer.
  49926. * @param subMesh the mesh to check for
  49927. * @param useInstances specify wether or not to use instances to render the mesh
  49928. * @param emissiveTexture the associated emissive texture used to generate the glow
  49929. * @return true if ready otherwise, false
  49930. */
  49931. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49932. /**
  49933. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49934. */
  49935. needStencil(): boolean;
  49936. /**
  49937. * Returns true if the mesh can be rendered, otherwise false.
  49938. * @param mesh The mesh to render
  49939. * @param material The material used on the mesh
  49940. * @returns true if it can be rendered otherwise false
  49941. */
  49942. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49943. /**
  49944. * Implementation specific of rendering the generating effect on the main canvas.
  49945. * @param effect The effect used to render through
  49946. */
  49947. protected _internalRender(effect: Effect): void;
  49948. /**
  49949. * Sets the required values for both the emissive texture and and the main color.
  49950. */
  49951. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49952. /**
  49953. * Returns true if the mesh should render, otherwise false.
  49954. * @param mesh The mesh to render
  49955. * @returns true if it should render otherwise false
  49956. */
  49957. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49958. /**
  49959. * Adds specific effects defines.
  49960. * @param defines The defines to add specifics to.
  49961. */
  49962. protected _addCustomEffectDefines(defines: string[]): void;
  49963. /**
  49964. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49965. * @param mesh The mesh to exclude from the glow layer
  49966. */
  49967. addExcludedMesh(mesh: Mesh): void;
  49968. /**
  49969. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49970. * @param mesh The mesh to remove
  49971. */
  49972. removeExcludedMesh(mesh: Mesh): void;
  49973. /**
  49974. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49975. * @param mesh The mesh to include in the glow layer
  49976. */
  49977. addIncludedOnlyMesh(mesh: Mesh): void;
  49978. /**
  49979. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49980. * @param mesh The mesh to remove
  49981. */
  49982. removeIncludedOnlyMesh(mesh: Mesh): void;
  49983. /**
  49984. * Determine if a given mesh will be used in the glow layer
  49985. * @param mesh The mesh to test
  49986. * @returns true if the mesh will be highlighted by the current glow layer
  49987. */
  49988. hasMesh(mesh: AbstractMesh): boolean;
  49989. /**
  49990. * Free any resources and references associated to a mesh.
  49991. * Internal use
  49992. * @param mesh The mesh to free.
  49993. * @hidden
  49994. */
  49995. _disposeMesh(mesh: Mesh): void;
  49996. /**
  49997. * Gets the class name of the effect layer
  49998. * @returns the string with the class name of the effect layer
  49999. */
  50000. getClassName(): string;
  50001. /**
  50002. * Serializes this glow layer
  50003. * @returns a serialized glow layer object
  50004. */
  50005. serialize(): any;
  50006. /**
  50007. * Creates a Glow Layer from parsed glow layer data
  50008. * @param parsedGlowLayer defines glow layer data
  50009. * @param scene defines the current scene
  50010. * @param rootUrl defines the root URL containing the glow layer information
  50011. * @returns a parsed Glow Layer
  50012. */
  50013. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50014. }
  50015. }
  50016. declare module BABYLON {
  50017. /** @hidden */
  50018. export var glowBlurPostProcessPixelShader: {
  50019. name: string;
  50020. shader: string;
  50021. };
  50022. }
  50023. declare module BABYLON {
  50024. interface AbstractScene {
  50025. /**
  50026. * Return a the first highlight layer of the scene with a given name.
  50027. * @param name The name of the highlight layer to look for.
  50028. * @return The highlight layer if found otherwise null.
  50029. */
  50030. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50031. }
  50032. /**
  50033. * Highlight layer options. This helps customizing the behaviour
  50034. * of the highlight layer.
  50035. */
  50036. export interface IHighlightLayerOptions {
  50037. /**
  50038. * Multiplication factor apply to the canvas size to compute the render target size
  50039. * used to generated the glowing objects (the smaller the faster).
  50040. */
  50041. mainTextureRatio: number;
  50042. /**
  50043. * Enforces a fixed size texture to ensure resize independant blur.
  50044. */
  50045. mainTextureFixedSize?: number;
  50046. /**
  50047. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50048. * of the picture to blur (the smaller the faster).
  50049. */
  50050. blurTextureSizeRatio: number;
  50051. /**
  50052. * How big in texel of the blur texture is the vertical blur.
  50053. */
  50054. blurVerticalSize: number;
  50055. /**
  50056. * How big in texel of the blur texture is the horizontal blur.
  50057. */
  50058. blurHorizontalSize: number;
  50059. /**
  50060. * Alpha blending mode used to apply the blur. Default is combine.
  50061. */
  50062. alphaBlendingMode: number;
  50063. /**
  50064. * The camera attached to the layer.
  50065. */
  50066. camera: Nullable<Camera>;
  50067. /**
  50068. * Should we display highlight as a solid stroke?
  50069. */
  50070. isStroke?: boolean;
  50071. /**
  50072. * The rendering group to draw the layer in.
  50073. */
  50074. renderingGroupId: number;
  50075. }
  50076. /**
  50077. * The highlight layer Helps adding a glow effect around a mesh.
  50078. *
  50079. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50080. * glowy meshes to your scene.
  50081. *
  50082. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50083. */
  50084. export class HighlightLayer extends EffectLayer {
  50085. name: string;
  50086. /**
  50087. * Effect Name of the highlight layer.
  50088. */
  50089. static readonly EffectName: string;
  50090. /**
  50091. * The neutral color used during the preparation of the glow effect.
  50092. * This is black by default as the blend operation is a blend operation.
  50093. */
  50094. static NeutralColor: Color4;
  50095. /**
  50096. * Stencil value used for glowing meshes.
  50097. */
  50098. static GlowingMeshStencilReference: number;
  50099. /**
  50100. * Stencil value used for the other meshes in the scene.
  50101. */
  50102. static NormalMeshStencilReference: number;
  50103. /**
  50104. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50105. */
  50106. innerGlow: boolean;
  50107. /**
  50108. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50109. */
  50110. outerGlow: boolean;
  50111. /**
  50112. * Specifies the horizontal size of the blur.
  50113. */
  50114. /**
  50115. * Gets the horizontal size of the blur.
  50116. */
  50117. blurHorizontalSize: number;
  50118. /**
  50119. * Specifies the vertical size of the blur.
  50120. */
  50121. /**
  50122. * Gets the vertical size of the blur.
  50123. */
  50124. blurVerticalSize: number;
  50125. /**
  50126. * An event triggered when the highlight layer is being blurred.
  50127. */
  50128. onBeforeBlurObservable: Observable<HighlightLayer>;
  50129. /**
  50130. * An event triggered when the highlight layer has been blurred.
  50131. */
  50132. onAfterBlurObservable: Observable<HighlightLayer>;
  50133. private _instanceGlowingMeshStencilReference;
  50134. private _options;
  50135. private _downSamplePostprocess;
  50136. private _horizontalBlurPostprocess;
  50137. private _verticalBlurPostprocess;
  50138. private _blurTexture;
  50139. private _meshes;
  50140. private _excludedMeshes;
  50141. /**
  50142. * Instantiates a new highlight Layer and references it to the scene..
  50143. * @param name The name of the layer
  50144. * @param scene The scene to use the layer in
  50145. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50146. */
  50147. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50148. /**
  50149. * Get the effect name of the layer.
  50150. * @return The effect name
  50151. */
  50152. getEffectName(): string;
  50153. /**
  50154. * Create the merge effect. This is the shader use to blit the information back
  50155. * to the main canvas at the end of the scene rendering.
  50156. */
  50157. protected _createMergeEffect(): Effect;
  50158. /**
  50159. * Creates the render target textures and post processes used in the highlight layer.
  50160. */
  50161. protected _createTextureAndPostProcesses(): void;
  50162. /**
  50163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50164. */
  50165. needStencil(): boolean;
  50166. /**
  50167. * Checks for the readiness of the element composing the layer.
  50168. * @param subMesh the mesh to check for
  50169. * @param useInstances specify wether or not to use instances to render the mesh
  50170. * @param emissiveTexture the associated emissive texture used to generate the glow
  50171. * @return true if ready otherwise, false
  50172. */
  50173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50174. /**
  50175. * Implementation specific of rendering the generating effect on the main canvas.
  50176. * @param effect The effect used to render through
  50177. */
  50178. protected _internalRender(effect: Effect): void;
  50179. /**
  50180. * Returns true if the layer contains information to display, otherwise false.
  50181. */
  50182. shouldRender(): boolean;
  50183. /**
  50184. * Returns true if the mesh should render, otherwise false.
  50185. * @param mesh The mesh to render
  50186. * @returns true if it should render otherwise false
  50187. */
  50188. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50189. /**
  50190. * Sets the required values for both the emissive texture and and the main color.
  50191. */
  50192. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50193. /**
  50194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50195. * @param mesh The mesh to exclude from the highlight layer
  50196. */
  50197. addExcludedMesh(mesh: Mesh): void;
  50198. /**
  50199. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50200. * @param mesh The mesh to highlight
  50201. */
  50202. removeExcludedMesh(mesh: Mesh): void;
  50203. /**
  50204. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50205. * @param mesh mesh to test
  50206. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50207. */
  50208. hasMesh(mesh: AbstractMesh): boolean;
  50209. /**
  50210. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50211. * @param mesh The mesh to highlight
  50212. * @param color The color of the highlight
  50213. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50214. */
  50215. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50216. /**
  50217. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50218. * @param mesh The mesh to highlight
  50219. */
  50220. removeMesh(mesh: Mesh): void;
  50221. /**
  50222. * Force the stencil to the normal expected value for none glowing parts
  50223. */
  50224. private _defaultStencilReference;
  50225. /**
  50226. * Free any resources and references associated to a mesh.
  50227. * Internal use
  50228. * @param mesh The mesh to free.
  50229. * @hidden
  50230. */
  50231. _disposeMesh(mesh: Mesh): void;
  50232. /**
  50233. * Dispose the highlight layer and free resources.
  50234. */
  50235. dispose(): void;
  50236. /**
  50237. * Gets the class name of the effect layer
  50238. * @returns the string with the class name of the effect layer
  50239. */
  50240. getClassName(): string;
  50241. /**
  50242. * Serializes this Highlight layer
  50243. * @returns a serialized Highlight layer object
  50244. */
  50245. serialize(): any;
  50246. /**
  50247. * Creates a Highlight layer from parsed Highlight layer data
  50248. * @param parsedHightlightLayer defines the Highlight layer data
  50249. * @param scene defines the current scene
  50250. * @param rootUrl defines the root URL containing the Highlight layer information
  50251. * @returns a parsed Highlight layer
  50252. */
  50253. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50254. }
  50255. }
  50256. declare module BABYLON {
  50257. interface AbstractScene {
  50258. /**
  50259. * The list of layers (background and foreground) of the scene
  50260. */
  50261. layers: Array<Layer>;
  50262. }
  50263. /**
  50264. * Defines the layer scene component responsible to manage any layers
  50265. * in a given scene.
  50266. */
  50267. export class LayerSceneComponent implements ISceneComponent {
  50268. /**
  50269. * The component name helpfull to identify the component in the list of scene components.
  50270. */
  50271. readonly name: string;
  50272. /**
  50273. * The scene the component belongs to.
  50274. */
  50275. scene: Scene;
  50276. private _engine;
  50277. /**
  50278. * Creates a new instance of the component for the given scene
  50279. * @param scene Defines the scene to register the component in
  50280. */
  50281. constructor(scene: Scene);
  50282. /**
  50283. * Registers the component in a given scene
  50284. */
  50285. register(): void;
  50286. /**
  50287. * Rebuilds the elements related to this component in case of
  50288. * context lost for instance.
  50289. */
  50290. rebuild(): void;
  50291. /**
  50292. * Disposes the component and the associated ressources.
  50293. */
  50294. dispose(): void;
  50295. private _draw;
  50296. private _drawCameraPredicate;
  50297. private _drawCameraBackground;
  50298. private _drawCameraForeground;
  50299. private _drawRenderTargetPredicate;
  50300. private _drawRenderTargetBackground;
  50301. private _drawRenderTargetForeground;
  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. }
  50315. declare module BABYLON {
  50316. /** @hidden */
  50317. export var layerPixelShader: {
  50318. name: string;
  50319. shader: string;
  50320. };
  50321. }
  50322. declare module BABYLON {
  50323. /** @hidden */
  50324. export var layerVertexShader: {
  50325. name: string;
  50326. shader: string;
  50327. };
  50328. }
  50329. declare module BABYLON {
  50330. /**
  50331. * This represents a full screen 2d layer.
  50332. * This can be useful to display a picture in the background of your scene for instance.
  50333. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50334. */
  50335. export class Layer {
  50336. /**
  50337. * Define the name of the layer.
  50338. */
  50339. name: string;
  50340. /**
  50341. * Define the texture the layer should display.
  50342. */
  50343. texture: Nullable<Texture>;
  50344. /**
  50345. * Is the layer in background or foreground.
  50346. */
  50347. isBackground: boolean;
  50348. /**
  50349. * Define the color of the layer (instead of texture).
  50350. */
  50351. color: Color4;
  50352. /**
  50353. * Define the scale of the layer in order to zoom in out of the texture.
  50354. */
  50355. scale: Vector2;
  50356. /**
  50357. * Define an offset for the layer in order to shift the texture.
  50358. */
  50359. offset: Vector2;
  50360. /**
  50361. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50362. */
  50363. alphaBlendingMode: number;
  50364. /**
  50365. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50366. * Alpha test will not mix with the background color in case of transparency.
  50367. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50368. */
  50369. alphaTest: boolean;
  50370. /**
  50371. * Define a mask to restrict the layer to only some of the scene cameras.
  50372. */
  50373. layerMask: number;
  50374. /**
  50375. * Define the list of render target the layer is visible into.
  50376. */
  50377. renderTargetTextures: RenderTargetTexture[];
  50378. /**
  50379. * Define if the layer is only used in renderTarget or if it also
  50380. * renders in the main frame buffer of the canvas.
  50381. */
  50382. renderOnlyInRenderTargetTextures: boolean;
  50383. private _scene;
  50384. private _vertexBuffers;
  50385. private _indexBuffer;
  50386. private _effect;
  50387. private _alphaTestEffect;
  50388. /**
  50389. * An event triggered when the layer is disposed.
  50390. */
  50391. onDisposeObservable: Observable<Layer>;
  50392. private _onDisposeObserver;
  50393. /**
  50394. * Back compatibility with callback before the onDisposeObservable existed.
  50395. * The set callback will be triggered when the layer has been disposed.
  50396. */
  50397. onDispose: () => void;
  50398. /**
  50399. * An event triggered before rendering the scene
  50400. */
  50401. onBeforeRenderObservable: Observable<Layer>;
  50402. private _onBeforeRenderObserver;
  50403. /**
  50404. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50405. * The set callback will be triggered just before rendering the layer.
  50406. */
  50407. onBeforeRender: () => void;
  50408. /**
  50409. * An event triggered after rendering the scene
  50410. */
  50411. onAfterRenderObservable: Observable<Layer>;
  50412. private _onAfterRenderObserver;
  50413. /**
  50414. * Back compatibility with callback before the onAfterRenderObservable existed.
  50415. * The set callback will be triggered just after rendering the layer.
  50416. */
  50417. onAfterRender: () => void;
  50418. /**
  50419. * Instantiates a new layer.
  50420. * This represents a full screen 2d layer.
  50421. * This can be useful to display a picture in the background of your scene for instance.
  50422. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50423. * @param name Define the name of the layer in the scene
  50424. * @param imgUrl Define the url of the texture to display in the layer
  50425. * @param scene Define the scene the layer belongs to
  50426. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50427. * @param color Defines a color for the layer
  50428. */
  50429. constructor(
  50430. /**
  50431. * Define the name of the layer.
  50432. */
  50433. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50434. private _createIndexBuffer;
  50435. /** @hidden */
  50436. _rebuild(): void;
  50437. /**
  50438. * Renders the layer in the scene.
  50439. */
  50440. render(): void;
  50441. /**
  50442. * Disposes and releases the associated ressources.
  50443. */
  50444. dispose(): void;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /** @hidden */
  50449. export var lensFlarePixelShader: {
  50450. name: string;
  50451. shader: string;
  50452. };
  50453. }
  50454. declare module BABYLON {
  50455. /** @hidden */
  50456. export var lensFlareVertexShader: {
  50457. name: string;
  50458. shader: string;
  50459. };
  50460. }
  50461. declare module BABYLON {
  50462. /**
  50463. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50464. * It is usually composed of several `lensFlare`.
  50465. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50466. */
  50467. export class LensFlareSystem {
  50468. /**
  50469. * Define the name of the lens flare system
  50470. */
  50471. name: string;
  50472. /**
  50473. * List of lens flares used in this system.
  50474. */
  50475. lensFlares: LensFlare[];
  50476. /**
  50477. * Define a limit from the border the lens flare can be visible.
  50478. */
  50479. borderLimit: number;
  50480. /**
  50481. * Define a viewport border we do not want to see the lens flare in.
  50482. */
  50483. viewportBorder: number;
  50484. /**
  50485. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50486. */
  50487. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50488. /**
  50489. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50490. */
  50491. layerMask: number;
  50492. /**
  50493. * Define the id of the lens flare system in the scene.
  50494. * (equal to name by default)
  50495. */
  50496. id: string;
  50497. private _scene;
  50498. private _emitter;
  50499. private _vertexBuffers;
  50500. private _indexBuffer;
  50501. private _effect;
  50502. private _positionX;
  50503. private _positionY;
  50504. private _isEnabled;
  50505. /** @hidden */
  50506. static _SceneComponentInitialization: (scene: Scene) => void;
  50507. /**
  50508. * Instantiates a lens flare system.
  50509. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50510. * It is usually composed of several `lensFlare`.
  50511. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50512. * @param name Define the name of the lens flare system in the scene
  50513. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50514. * @param scene Define the scene the lens flare system belongs to
  50515. */
  50516. constructor(
  50517. /**
  50518. * Define the name of the lens flare system
  50519. */
  50520. name: string, emitter: any, scene: Scene);
  50521. /**
  50522. * Define if the lens flare system is enabled.
  50523. */
  50524. isEnabled: boolean;
  50525. /**
  50526. * Get the scene the effects belongs to.
  50527. * @returns the scene holding the lens flare system
  50528. */
  50529. getScene(): Scene;
  50530. /**
  50531. * Get the emitter of the lens flare system.
  50532. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50533. * @returns the emitter of the lens flare system
  50534. */
  50535. getEmitter(): any;
  50536. /**
  50537. * Set the emitter of the lens flare system.
  50538. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50539. * @param newEmitter Define the new emitter of the system
  50540. */
  50541. setEmitter(newEmitter: any): void;
  50542. /**
  50543. * Get the lens flare system emitter position.
  50544. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50545. * @returns the position
  50546. */
  50547. getEmitterPosition(): Vector3;
  50548. /**
  50549. * @hidden
  50550. */
  50551. computeEffectivePosition(globalViewport: Viewport): boolean;
  50552. /** @hidden */
  50553. _isVisible(): boolean;
  50554. /**
  50555. * @hidden
  50556. */
  50557. render(): boolean;
  50558. /**
  50559. * Dispose and release the lens flare with its associated resources.
  50560. */
  50561. dispose(): void;
  50562. /**
  50563. * Parse a lens flare system from a JSON repressentation
  50564. * @param parsedLensFlareSystem Define the JSON to parse
  50565. * @param scene Define the scene the parsed system should be instantiated in
  50566. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50567. * @returns the parsed system
  50568. */
  50569. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50570. /**
  50571. * Serialize the current Lens Flare System into a JSON representation.
  50572. * @returns the serialized JSON
  50573. */
  50574. serialize(): any;
  50575. }
  50576. }
  50577. declare module BABYLON {
  50578. /**
  50579. * This represents one of the lens effect in a `lensFlareSystem`.
  50580. * It controls one of the indiviual texture used in the effect.
  50581. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50582. */
  50583. export class LensFlare {
  50584. /**
  50585. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50586. */
  50587. size: number;
  50588. /**
  50589. * 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.
  50590. */
  50591. position: number;
  50592. /**
  50593. * Define the lens color.
  50594. */
  50595. color: Color3;
  50596. /**
  50597. * Define the lens texture.
  50598. */
  50599. texture: Nullable<Texture>;
  50600. /**
  50601. * Define the alpha mode to render this particular lens.
  50602. */
  50603. alphaMode: number;
  50604. private _system;
  50605. /**
  50606. * Creates a new Lens Flare.
  50607. * This represents one of the lens effect in a `lensFlareSystem`.
  50608. * It controls one of the indiviual texture used in the effect.
  50609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50610. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50611. * @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.
  50612. * @param color Define the lens color
  50613. * @param imgUrl Define the lens texture url
  50614. * @param system Define the `lensFlareSystem` this flare is part of
  50615. * @returns The newly created Lens Flare
  50616. */
  50617. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50618. /**
  50619. * Instantiates a new Lens Flare.
  50620. * This represents one of the lens effect in a `lensFlareSystem`.
  50621. * It controls one of the indiviual texture used in the effect.
  50622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50623. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50624. * @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.
  50625. * @param color Define the lens color
  50626. * @param imgUrl Define the lens texture url
  50627. * @param system Define the `lensFlareSystem` this flare is part of
  50628. */
  50629. constructor(
  50630. /**
  50631. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50632. */
  50633. size: number,
  50634. /**
  50635. * 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.
  50636. */
  50637. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50638. /**
  50639. * Dispose and release the lens flare with its associated resources.
  50640. */
  50641. dispose(): void;
  50642. }
  50643. }
  50644. declare module BABYLON {
  50645. interface AbstractScene {
  50646. /**
  50647. * The list of lens flare system added to the scene
  50648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50649. */
  50650. lensFlareSystems: Array<LensFlareSystem>;
  50651. /**
  50652. * Removes the given lens flare system from this scene.
  50653. * @param toRemove The lens flare system to remove
  50654. * @returns The index of the removed lens flare system
  50655. */
  50656. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50657. /**
  50658. * Adds the given lens flare system to this scene
  50659. * @param newLensFlareSystem The lens flare system to add
  50660. */
  50661. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50662. /**
  50663. * Gets a lens flare system using its name
  50664. * @param name defines the name to look for
  50665. * @returns the lens flare system or null if not found
  50666. */
  50667. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50668. /**
  50669. * Gets a lens flare system using its id
  50670. * @param id defines the id to look for
  50671. * @returns the lens flare system or null if not found
  50672. */
  50673. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50674. }
  50675. /**
  50676. * Defines the lens flare scene component responsible to manage any lens flares
  50677. * in a given scene.
  50678. */
  50679. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50680. /**
  50681. * The component name helpfull to identify the component in the list of scene components.
  50682. */
  50683. readonly name: string;
  50684. /**
  50685. * The scene the component belongs to.
  50686. */
  50687. scene: Scene;
  50688. /**
  50689. * Creates a new instance of the component for the given scene
  50690. * @param scene Defines the scene to register the component in
  50691. */
  50692. constructor(scene: Scene);
  50693. /**
  50694. * Registers the component in a given scene
  50695. */
  50696. register(): void;
  50697. /**
  50698. * Rebuilds the elements related to this component in case of
  50699. * context lost for instance.
  50700. */
  50701. rebuild(): void;
  50702. /**
  50703. * Adds all the elements from the container to the scene
  50704. * @param container the container holding the elements
  50705. */
  50706. addFromContainer(container: AbstractScene): void;
  50707. /**
  50708. * Removes all the elements in the container from the scene
  50709. * @param container contains the elements to remove
  50710. * @param dispose if the removed element should be disposed (default: false)
  50711. */
  50712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50713. /**
  50714. * Serializes the component data to the specified json object
  50715. * @param serializationObject The object to serialize to
  50716. */
  50717. serialize(serializationObject: any): void;
  50718. /**
  50719. * Disposes the component and the associated ressources.
  50720. */
  50721. dispose(): void;
  50722. private _draw;
  50723. }
  50724. }
  50725. declare module BABYLON {
  50726. /**
  50727. * Defines the shadow generator component responsible to manage any shadow generators
  50728. * in a given scene.
  50729. */
  50730. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50731. /**
  50732. * The component name helpfull to identify the component in the list of scene components.
  50733. */
  50734. readonly name: string;
  50735. /**
  50736. * The scene the component belongs to.
  50737. */
  50738. scene: Scene;
  50739. /**
  50740. * Creates a new instance of the component for the given scene
  50741. * @param scene Defines the scene to register the component in
  50742. */
  50743. constructor(scene: Scene);
  50744. /**
  50745. * Registers the component in a given scene
  50746. */
  50747. register(): void;
  50748. /**
  50749. * Rebuilds the elements related to this component in case of
  50750. * context lost for instance.
  50751. */
  50752. rebuild(): void;
  50753. /**
  50754. * Serializes the component data to the specified json object
  50755. * @param serializationObject The object to serialize to
  50756. */
  50757. serialize(serializationObject: any): void;
  50758. /**
  50759. * Adds all the elements from the container to the scene
  50760. * @param container the container holding the elements
  50761. */
  50762. addFromContainer(container: AbstractScene): void;
  50763. /**
  50764. * Removes all the elements in the container from the scene
  50765. * @param container contains the elements to remove
  50766. * @param dispose if the removed element should be disposed (default: false)
  50767. */
  50768. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50769. /**
  50770. * Rebuilds the elements related to this component in case of
  50771. * context lost for instance.
  50772. */
  50773. dispose(): void;
  50774. private _gatherRenderTargets;
  50775. }
  50776. }
  50777. declare module BABYLON {
  50778. /**
  50779. * A point light is a light defined by an unique point in world space.
  50780. * The light is emitted in every direction from this point.
  50781. * A good example of a point light is a standard light bulb.
  50782. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50783. */
  50784. export class PointLight extends ShadowLight {
  50785. private _shadowAngle;
  50786. /**
  50787. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50788. * This specifies what angle the shadow will use to be created.
  50789. *
  50790. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50791. */
  50792. /**
  50793. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50794. * This specifies what angle the shadow will use to be created.
  50795. *
  50796. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50797. */
  50798. shadowAngle: number;
  50799. /**
  50800. * Gets the direction if it has been set.
  50801. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50802. */
  50803. /**
  50804. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50805. */
  50806. direction: Vector3;
  50807. /**
  50808. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50809. * A PointLight emits the light in every direction.
  50810. * It can cast shadows.
  50811. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50812. * ```javascript
  50813. * var pointLight = new PointLight("pl", camera.position, scene);
  50814. * ```
  50815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50816. * @param name The light friendly name
  50817. * @param position The position of the point light in the scene
  50818. * @param scene The scene the lights belongs to
  50819. */
  50820. constructor(name: string, position: Vector3, scene: Scene);
  50821. /**
  50822. * Returns the string "PointLight"
  50823. * @returns the class name
  50824. */
  50825. getClassName(): string;
  50826. /**
  50827. * Returns the integer 0.
  50828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50829. */
  50830. getTypeID(): number;
  50831. /**
  50832. * Specifies wether or not the shadowmap should be a cube texture.
  50833. * @returns true if the shadowmap needs to be a cube texture.
  50834. */
  50835. needCube(): boolean;
  50836. /**
  50837. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50840. */
  50841. getShadowDirection(faceIndex?: number): Vector3;
  50842. /**
  50843. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50844. * - fov = PI / 2
  50845. * - aspect ratio : 1.0
  50846. * - z-near and far equal to the active camera minZ and maxZ.
  50847. * Returns the PointLight.
  50848. */
  50849. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50850. protected _buildUniformLayout(): void;
  50851. /**
  50852. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50853. * @param effect The effect to update
  50854. * @param lightIndex The index of the light in the effect to update
  50855. * @returns The point light
  50856. */
  50857. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50858. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50859. /**
  50860. * Prepares the list of defines specific to the light type.
  50861. * @param defines the list of defines
  50862. * @param lightIndex defines the index of the light for the effect
  50863. */
  50864. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50865. }
  50866. }
  50867. declare module BABYLON {
  50868. /**
  50869. * Header information of HDR texture files.
  50870. */
  50871. export interface HDRInfo {
  50872. /**
  50873. * The height of the texture in pixels.
  50874. */
  50875. height: number;
  50876. /**
  50877. * The width of the texture in pixels.
  50878. */
  50879. width: number;
  50880. /**
  50881. * The index of the beginning of the data in the binary file.
  50882. */
  50883. dataPosition: number;
  50884. }
  50885. /**
  50886. * This groups tools to convert HDR texture to native colors array.
  50887. */
  50888. export class HDRTools {
  50889. private static Ldexp;
  50890. private static Rgbe2float;
  50891. private static readStringLine;
  50892. /**
  50893. * Reads header information from an RGBE texture stored in a native array.
  50894. * More information on this format are available here:
  50895. * https://en.wikipedia.org/wiki/RGBE_image_format
  50896. *
  50897. * @param uint8array The binary file stored in native array.
  50898. * @return The header information.
  50899. */
  50900. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50901. /**
  50902. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50903. * This RGBE texture needs to store the information as a panorama.
  50904. *
  50905. * More information on this format are available here:
  50906. * https://en.wikipedia.org/wiki/RGBE_image_format
  50907. *
  50908. * @param buffer The binary file stored in an array buffer.
  50909. * @param size The expected size of the extracted cubemap.
  50910. * @return The Cube Map information.
  50911. */
  50912. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50913. /**
  50914. * Returns the pixels data extracted from an RGBE texture.
  50915. * This pixels will be stored left to right up to down in the R G B order in one array.
  50916. *
  50917. * More information on this format are available here:
  50918. * https://en.wikipedia.org/wiki/RGBE_image_format
  50919. *
  50920. * @param uint8array The binary file stored in an array buffer.
  50921. * @param hdrInfo The header information of the file.
  50922. * @return The pixels data in RGB right to left up to down order.
  50923. */
  50924. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50925. private static RGBE_ReadPixels_RLE;
  50926. }
  50927. }
  50928. declare module BABYLON {
  50929. /**
  50930. * This represents a texture coming from an HDR input.
  50931. *
  50932. * The only supported format is currently panorama picture stored in RGBE format.
  50933. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50934. */
  50935. export class HDRCubeTexture extends BaseTexture {
  50936. private static _facesMapping;
  50937. private _generateHarmonics;
  50938. private _noMipmap;
  50939. private _textureMatrix;
  50940. private _size;
  50941. private _onLoad;
  50942. private _onError;
  50943. /**
  50944. * The texture URL.
  50945. */
  50946. url: string;
  50947. /**
  50948. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50949. */
  50950. coordinatesMode: number;
  50951. protected _isBlocking: boolean;
  50952. /**
  50953. * Sets wether or not the texture is blocking during loading.
  50954. */
  50955. /**
  50956. * Gets wether or not the texture is blocking during loading.
  50957. */
  50958. isBlocking: boolean;
  50959. protected _rotationY: number;
  50960. /**
  50961. * Sets texture matrix rotation angle around Y axis in radians.
  50962. */
  50963. /**
  50964. * Gets texture matrix rotation angle around Y axis radians.
  50965. */
  50966. rotationY: number;
  50967. /**
  50968. * Gets or sets the center of the bounding box associated with the cube texture
  50969. * It must define where the camera used to render the texture was set
  50970. */
  50971. boundingBoxPosition: Vector3;
  50972. private _boundingBoxSize;
  50973. /**
  50974. * Gets or sets the size of the bounding box associated with the cube texture
  50975. * When defined, the cubemap will switch to local mode
  50976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50977. * @example https://www.babylonjs-playground.com/#RNASML
  50978. */
  50979. boundingBoxSize: Vector3;
  50980. /**
  50981. * Instantiates an HDRTexture from the following parameters.
  50982. *
  50983. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50984. * @param scene The scene the texture will be used in
  50985. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50986. * @param noMipmap Forces to not generate the mipmap if true
  50987. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50988. * @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)
  50989. * @param reserved Reserved flag for internal use.
  50990. */
  50991. 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>);
  50992. /**
  50993. * Get the current class name of the texture useful for serialization or dynamic coding.
  50994. * @returns "HDRCubeTexture"
  50995. */
  50996. getClassName(): string;
  50997. /**
  50998. * Occurs when the file is raw .hdr file.
  50999. */
  51000. private loadTexture;
  51001. clone(): HDRCubeTexture;
  51002. delayLoad(): void;
  51003. /**
  51004. * Get the texture reflection matrix used to rotate/transform the reflection.
  51005. * @returns the reflection matrix
  51006. */
  51007. getReflectionTextureMatrix(): Matrix;
  51008. /**
  51009. * Set the texture reflection matrix used to rotate/transform the reflection.
  51010. * @param value Define the reflection matrix to set
  51011. */
  51012. setReflectionTextureMatrix(value: Matrix): void;
  51013. /**
  51014. * Parses a JSON representation of an HDR Texture in order to create the texture
  51015. * @param parsedTexture Define the JSON representation
  51016. * @param scene Define the scene the texture should be created in
  51017. * @param rootUrl Define the root url in case we need to load relative dependencies
  51018. * @returns the newly created texture after parsing
  51019. */
  51020. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51021. serialize(): any;
  51022. }
  51023. }
  51024. declare module BABYLON {
  51025. /**
  51026. * Class used to control physics engine
  51027. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51028. */
  51029. export class PhysicsEngine implements IPhysicsEngine {
  51030. private _physicsPlugin;
  51031. /**
  51032. * Global value used to control the smallest number supported by the simulation
  51033. */
  51034. static Epsilon: number;
  51035. private _impostors;
  51036. private _joints;
  51037. /**
  51038. * Gets the gravity vector used by the simulation
  51039. */
  51040. gravity: Vector3;
  51041. /**
  51042. * Factory used to create the default physics plugin.
  51043. * @returns The default physics plugin
  51044. */
  51045. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51046. /**
  51047. * Creates a new Physics Engine
  51048. * @param gravity defines the gravity vector used by the simulation
  51049. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51050. */
  51051. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51052. /**
  51053. * Sets the gravity vector used by the simulation
  51054. * @param gravity defines the gravity vector to use
  51055. */
  51056. setGravity(gravity: Vector3): void;
  51057. /**
  51058. * Set the time step of the physics engine.
  51059. * Default is 1/60.
  51060. * To slow it down, enter 1/600 for example.
  51061. * To speed it up, 1/30
  51062. * @param newTimeStep defines the new timestep to apply to this world.
  51063. */
  51064. setTimeStep(newTimeStep?: number): void;
  51065. /**
  51066. * Get the time step of the physics engine.
  51067. * @returns the current time step
  51068. */
  51069. getTimeStep(): number;
  51070. /**
  51071. * Release all resources
  51072. */
  51073. dispose(): void;
  51074. /**
  51075. * Gets the name of the current physics plugin
  51076. * @returns the name of the plugin
  51077. */
  51078. getPhysicsPluginName(): string;
  51079. /**
  51080. * Adding a new impostor for the impostor tracking.
  51081. * This will be done by the impostor itself.
  51082. * @param impostor the impostor to add
  51083. */
  51084. addImpostor(impostor: PhysicsImpostor): void;
  51085. /**
  51086. * Remove an impostor from the engine.
  51087. * This impostor and its mesh will not longer be updated by the physics engine.
  51088. * @param impostor the impostor to remove
  51089. */
  51090. removeImpostor(impostor: PhysicsImpostor): void;
  51091. /**
  51092. * Add a joint to the physics engine
  51093. * @param mainImpostor defines the main impostor to which the joint is added.
  51094. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51095. * @param joint defines the joint that will connect both impostors.
  51096. */
  51097. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51098. /**
  51099. * Removes a joint from the simulation
  51100. * @param mainImpostor defines the impostor used with the joint
  51101. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51102. * @param joint defines the joint to remove
  51103. */
  51104. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51105. /**
  51106. * Called by the scene. No need to call it.
  51107. * @param delta defines the timespam between frames
  51108. */
  51109. _step(delta: number): void;
  51110. /**
  51111. * Gets the current plugin used to run the simulation
  51112. * @returns current plugin
  51113. */
  51114. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51115. /**
  51116. * Gets the list of physic impostors
  51117. * @returns an array of PhysicsImpostor
  51118. */
  51119. getImpostors(): Array<PhysicsImpostor>;
  51120. /**
  51121. * Gets the impostor for a physics enabled object
  51122. * @param object defines the object impersonated by the impostor
  51123. * @returns the PhysicsImpostor or null if not found
  51124. */
  51125. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51126. /**
  51127. * Gets the impostor for a physics body object
  51128. * @param body defines physics body used by the impostor
  51129. * @returns the PhysicsImpostor or null if not found
  51130. */
  51131. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51132. /**
  51133. * Does a raycast in the physics world
  51134. * @param from when should the ray start?
  51135. * @param to when should the ray end?
  51136. * @returns PhysicsRaycastResult
  51137. */
  51138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51139. }
  51140. }
  51141. declare module BABYLON {
  51142. /** @hidden */
  51143. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51144. private _useDeltaForWorldStep;
  51145. world: any;
  51146. name: string;
  51147. private _physicsMaterials;
  51148. private _fixedTimeStep;
  51149. private _cannonRaycastResult;
  51150. private _raycastResult;
  51151. private _physicsBodysToRemoveAfterStep;
  51152. BJSCANNON: any;
  51153. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51154. setGravity(gravity: Vector3): void;
  51155. setTimeStep(timeStep: number): void;
  51156. getTimeStep(): number;
  51157. executeStep(delta: number): void;
  51158. private _removeMarkedPhysicsBodiesFromWorld;
  51159. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51160. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51161. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51162. private _processChildMeshes;
  51163. removePhysicsBody(impostor: PhysicsImpostor): void;
  51164. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51165. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51166. private _addMaterial;
  51167. private _checkWithEpsilon;
  51168. private _createShape;
  51169. private _createHeightmap;
  51170. private _minus90X;
  51171. private _plus90X;
  51172. private _tmpPosition;
  51173. private _tmpDeltaPosition;
  51174. private _tmpUnityRotation;
  51175. private _updatePhysicsBodyTransformation;
  51176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51178. isSupported(): boolean;
  51179. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51180. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51181. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51182. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51183. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51184. getBodyMass(impostor: PhysicsImpostor): number;
  51185. getBodyFriction(impostor: PhysicsImpostor): number;
  51186. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51187. getBodyRestitution(impostor: PhysicsImpostor): number;
  51188. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51189. sleepBody(impostor: PhysicsImpostor): void;
  51190. wakeUpBody(impostor: PhysicsImpostor): void;
  51191. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51192. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51193. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51195. getRadius(impostor: PhysicsImpostor): number;
  51196. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51197. dispose(): void;
  51198. private _extendNamespace;
  51199. /**
  51200. * Does a raycast in the physics world
  51201. * @param from when should the ray start?
  51202. * @param to when should the ray end?
  51203. * @returns PhysicsRaycastResult
  51204. */
  51205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51206. }
  51207. }
  51208. declare module BABYLON {
  51209. /** @hidden */
  51210. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51211. world: any;
  51212. name: string;
  51213. BJSOIMO: any;
  51214. private _raycastResult;
  51215. constructor(iterations?: number, oimoInjection?: any);
  51216. setGravity(gravity: Vector3): void;
  51217. setTimeStep(timeStep: number): void;
  51218. getTimeStep(): number;
  51219. private _tmpImpostorsArray;
  51220. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51221. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51222. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51223. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51224. private _tmpPositionVector;
  51225. removePhysicsBody(impostor: PhysicsImpostor): void;
  51226. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51227. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51228. isSupported(): boolean;
  51229. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51230. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51231. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51232. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51234. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51235. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51236. getBodyMass(impostor: PhysicsImpostor): number;
  51237. getBodyFriction(impostor: PhysicsImpostor): number;
  51238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51239. getBodyRestitution(impostor: PhysicsImpostor): number;
  51240. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51241. sleepBody(impostor: PhysicsImpostor): void;
  51242. wakeUpBody(impostor: PhysicsImpostor): void;
  51243. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51244. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51245. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51246. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51247. getRadius(impostor: PhysicsImpostor): number;
  51248. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51249. dispose(): void;
  51250. /**
  51251. * Does a raycast in the physics world
  51252. * @param from when should the ray start?
  51253. * @param to when should the ray end?
  51254. * @returns PhysicsRaycastResult
  51255. */
  51256. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51257. }
  51258. }
  51259. declare module BABYLON {
  51260. /**
  51261. * Class containing static functions to help procedurally build meshes
  51262. */
  51263. export class RibbonBuilder {
  51264. /**
  51265. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51266. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51267. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51268. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51269. * * 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
  51270. * * 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
  51271. * * 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
  51272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51273. * * 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
  51274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51275. * * 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
  51276. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51277. * * 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
  51278. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51280. * @param name defines the name of the mesh
  51281. * @param options defines the options used to create the mesh
  51282. * @param scene defines the hosting scene
  51283. * @returns the ribbon mesh
  51284. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51285. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51286. */
  51287. static CreateRibbon(name: string, options: {
  51288. pathArray: Vector3[][];
  51289. closeArray?: boolean;
  51290. closePath?: boolean;
  51291. offset?: number;
  51292. updatable?: boolean;
  51293. sideOrientation?: number;
  51294. frontUVs?: Vector4;
  51295. backUVs?: Vector4;
  51296. instance?: Mesh;
  51297. invertUV?: boolean;
  51298. uvs?: Vector2[];
  51299. colors?: Color4[];
  51300. }, scene?: Nullable<Scene>): Mesh;
  51301. }
  51302. }
  51303. declare module BABYLON {
  51304. /**
  51305. * Class containing static functions to help procedurally build meshes
  51306. */
  51307. export class ShapeBuilder {
  51308. /**
  51309. * 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.
  51310. * * 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.
  51311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51312. * * 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.
  51313. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51314. * * 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
  51315. * * 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
  51316. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51318. * * 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
  51319. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51321. * @param name defines the name of the mesh
  51322. * @param options defines the options used to create the mesh
  51323. * @param scene defines the hosting scene
  51324. * @returns the extruded shape mesh
  51325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51327. */
  51328. static ExtrudeShape(name: string, options: {
  51329. shape: Vector3[];
  51330. path: Vector3[];
  51331. scale?: number;
  51332. rotation?: number;
  51333. cap?: number;
  51334. updatable?: boolean;
  51335. sideOrientation?: number;
  51336. frontUVs?: Vector4;
  51337. backUVs?: Vector4;
  51338. instance?: Mesh;
  51339. invertUV?: boolean;
  51340. }, scene?: Nullable<Scene>): Mesh;
  51341. /**
  51342. * Creates an custom extruded shape mesh.
  51343. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51344. * * 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.
  51345. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51346. * * 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
  51347. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51348. * * 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
  51349. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51350. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51351. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51352. * * 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
  51353. * * 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
  51354. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51356. * * 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
  51357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51359. * @param name defines the name of the mesh
  51360. * @param options defines the options used to create the mesh
  51361. * @param scene defines the hosting scene
  51362. * @returns the custom extruded shape mesh
  51363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51366. */
  51367. static ExtrudeShapeCustom(name: string, options: {
  51368. shape: Vector3[];
  51369. path: Vector3[];
  51370. scaleFunction?: any;
  51371. rotationFunction?: any;
  51372. ribbonCloseArray?: boolean;
  51373. ribbonClosePath?: boolean;
  51374. cap?: number;
  51375. updatable?: boolean;
  51376. sideOrientation?: number;
  51377. frontUVs?: Vector4;
  51378. backUVs?: Vector4;
  51379. instance?: Mesh;
  51380. invertUV?: boolean;
  51381. }, scene?: Nullable<Scene>): Mesh;
  51382. private static _ExtrudeShapeGeneric;
  51383. }
  51384. }
  51385. declare module BABYLON {
  51386. /**
  51387. * AmmoJS Physics plugin
  51388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51389. * @see https://github.com/kripken/ammo.js/
  51390. */
  51391. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51392. private _useDeltaForWorldStep;
  51393. /**
  51394. * Reference to the Ammo library
  51395. */
  51396. bjsAMMO: any;
  51397. /**
  51398. * Created ammoJS world which physics bodies are added to
  51399. */
  51400. world: any;
  51401. /**
  51402. * Name of the plugin
  51403. */
  51404. name: string;
  51405. private _timeStep;
  51406. private _fixedTimeStep;
  51407. private _maxSteps;
  51408. private _tmpQuaternion;
  51409. private _tmpAmmoTransform;
  51410. private _tmpAmmoQuaternion;
  51411. private _tmpAmmoConcreteContactResultCallback;
  51412. private _collisionConfiguration;
  51413. private _dispatcher;
  51414. private _overlappingPairCache;
  51415. private _solver;
  51416. private _softBodySolver;
  51417. private _tmpAmmoVectorA;
  51418. private _tmpAmmoVectorB;
  51419. private _tmpAmmoVectorC;
  51420. private _tmpAmmoVectorD;
  51421. private _tmpContactCallbackResult;
  51422. private _tmpAmmoVectorRCA;
  51423. private _tmpAmmoVectorRCB;
  51424. private _raycastResult;
  51425. private static readonly DISABLE_COLLISION_FLAG;
  51426. private static readonly KINEMATIC_FLAG;
  51427. private static readonly DISABLE_DEACTIVATION_FLAG;
  51428. /**
  51429. * Initializes the ammoJS plugin
  51430. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51431. * @param ammoInjection can be used to inject your own ammo reference
  51432. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51433. */
  51434. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51435. /**
  51436. * Sets the gravity of the physics world (m/(s^2))
  51437. * @param gravity Gravity to set
  51438. */
  51439. setGravity(gravity: Vector3): void;
  51440. /**
  51441. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51442. * @param timeStep timestep to use in seconds
  51443. */
  51444. setTimeStep(timeStep: number): void;
  51445. /**
  51446. * 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)
  51447. * @param fixedTimeStep fixedTimeStep to use in seconds
  51448. */
  51449. setFixedTimeStep(fixedTimeStep: number): void;
  51450. /**
  51451. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51452. * @param maxSteps the maximum number of steps by the physics engine per frame
  51453. */
  51454. setMaxSteps(maxSteps: number): void;
  51455. /**
  51456. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51457. * @returns the current timestep in seconds
  51458. */
  51459. getTimeStep(): number;
  51460. private _isImpostorInContact;
  51461. private _isImpostorPairInContact;
  51462. private _stepSimulation;
  51463. /**
  51464. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51465. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51466. * After the step the babylon meshes are set to the position of the physics imposters
  51467. * @param delta amount of time to step forward
  51468. * @param impostors array of imposters to update before/after the step
  51469. */
  51470. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51471. /**
  51472. * Update babylon mesh to match physics world object
  51473. * @param impostor imposter to match
  51474. */
  51475. private _afterSoftStep;
  51476. /**
  51477. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51478. * @param impostor imposter to match
  51479. */
  51480. private _ropeStep;
  51481. /**
  51482. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51483. * @param impostor imposter to match
  51484. */
  51485. private _softbodyOrClothStep;
  51486. private _tmpVector;
  51487. private _tmpMatrix;
  51488. /**
  51489. * Applies an impulse on the imposter
  51490. * @param impostor imposter to apply impulse to
  51491. * @param force amount of force to be applied to the imposter
  51492. * @param contactPoint the location to apply the impulse on the imposter
  51493. */
  51494. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51495. /**
  51496. * Applies a force on the imposter
  51497. * @param impostor imposter to apply force
  51498. * @param force amount of force to be applied to the imposter
  51499. * @param contactPoint the location to apply the force on the imposter
  51500. */
  51501. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51502. /**
  51503. * Creates a physics body using the plugin
  51504. * @param impostor the imposter to create the physics body on
  51505. */
  51506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51507. /**
  51508. * Removes the physics body from the imposter and disposes of the body's memory
  51509. * @param impostor imposter to remove the physics body from
  51510. */
  51511. removePhysicsBody(impostor: PhysicsImpostor): void;
  51512. /**
  51513. * Generates a joint
  51514. * @param impostorJoint the imposter joint to create the joint with
  51515. */
  51516. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51517. /**
  51518. * Removes a joint
  51519. * @param impostorJoint the imposter joint to remove the joint from
  51520. */
  51521. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51522. private _addMeshVerts;
  51523. /**
  51524. * Initialise the soft body vertices to match its object's (mesh) vertices
  51525. * Softbody vertices (nodes) are in world space and to match this
  51526. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51527. * @param impostor to create the softbody for
  51528. */
  51529. private _softVertexData;
  51530. /**
  51531. * Create an impostor's soft body
  51532. * @param impostor to create the softbody for
  51533. */
  51534. private _createSoftbody;
  51535. /**
  51536. * Create cloth for an impostor
  51537. * @param impostor to create the softbody for
  51538. */
  51539. private _createCloth;
  51540. /**
  51541. * Create rope for an impostor
  51542. * @param impostor to create the softbody for
  51543. */
  51544. private _createRope;
  51545. private _addHullVerts;
  51546. private _createShape;
  51547. /**
  51548. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51549. * @param impostor imposter containing the physics body and babylon object
  51550. */
  51551. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51552. /**
  51553. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51554. * @param impostor imposter containing the physics body and babylon object
  51555. * @param newPosition new position
  51556. * @param newRotation new rotation
  51557. */
  51558. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51559. /**
  51560. * If this plugin is supported
  51561. * @returns true if its supported
  51562. */
  51563. isSupported(): boolean;
  51564. /**
  51565. * Sets the linear velocity of the physics body
  51566. * @param impostor imposter to set the velocity on
  51567. * @param velocity velocity to set
  51568. */
  51569. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51570. /**
  51571. * Sets the angular velocity of the physics body
  51572. * @param impostor imposter to set the velocity on
  51573. * @param velocity velocity to set
  51574. */
  51575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51576. /**
  51577. * gets the linear velocity
  51578. * @param impostor imposter to get linear velocity from
  51579. * @returns linear velocity
  51580. */
  51581. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51582. /**
  51583. * gets the angular velocity
  51584. * @param impostor imposter to get angular velocity from
  51585. * @returns angular velocity
  51586. */
  51587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51588. /**
  51589. * Sets the mass of physics body
  51590. * @param impostor imposter to set the mass on
  51591. * @param mass mass to set
  51592. */
  51593. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51594. /**
  51595. * Gets the mass of the physics body
  51596. * @param impostor imposter to get the mass from
  51597. * @returns mass
  51598. */
  51599. getBodyMass(impostor: PhysicsImpostor): number;
  51600. /**
  51601. * Gets friction of the impostor
  51602. * @param impostor impostor to get friction from
  51603. * @returns friction value
  51604. */
  51605. getBodyFriction(impostor: PhysicsImpostor): number;
  51606. /**
  51607. * Sets friction of the impostor
  51608. * @param impostor impostor to set friction on
  51609. * @param friction friction value
  51610. */
  51611. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51612. /**
  51613. * Gets restitution of the impostor
  51614. * @param impostor impostor to get restitution from
  51615. * @returns restitution value
  51616. */
  51617. getBodyRestitution(impostor: PhysicsImpostor): number;
  51618. /**
  51619. * Sets resitution of the impostor
  51620. * @param impostor impostor to set resitution on
  51621. * @param restitution resitution value
  51622. */
  51623. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51624. /**
  51625. * Gets pressure inside the impostor
  51626. * @param impostor impostor to get pressure from
  51627. * @returns pressure value
  51628. */
  51629. getBodyPressure(impostor: PhysicsImpostor): number;
  51630. /**
  51631. * Sets pressure inside a soft body impostor
  51632. * Cloth and rope must remain 0 pressure
  51633. * @param impostor impostor to set pressure on
  51634. * @param pressure pressure value
  51635. */
  51636. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51637. /**
  51638. * Gets stiffness of the impostor
  51639. * @param impostor impostor to get stiffness from
  51640. * @returns pressure value
  51641. */
  51642. getBodyStiffness(impostor: PhysicsImpostor): number;
  51643. /**
  51644. * Sets stiffness of the impostor
  51645. * @param impostor impostor to set stiffness on
  51646. * @param stiffness stiffness value from 0 to 1
  51647. */
  51648. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51649. /**
  51650. * Gets velocityIterations of the impostor
  51651. * @param impostor impostor to get velocity iterations from
  51652. * @returns velocityIterations value
  51653. */
  51654. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51655. /**
  51656. * Sets velocityIterations of the impostor
  51657. * @param impostor impostor to set velocity iterations on
  51658. * @param velocityIterations velocityIterations value
  51659. */
  51660. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51661. /**
  51662. * Gets positionIterations of the impostor
  51663. * @param impostor impostor to get position iterations from
  51664. * @returns positionIterations value
  51665. */
  51666. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51667. /**
  51668. * Sets positionIterations of the impostor
  51669. * @param impostor impostor to set position on
  51670. * @param positionIterations positionIterations value
  51671. */
  51672. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51673. /**
  51674. * Append an anchor to a cloth object
  51675. * @param impostor is the cloth impostor to add anchor to
  51676. * @param otherImpostor is the rigid impostor to anchor to
  51677. * @param width ratio across width from 0 to 1
  51678. * @param height ratio up height from 0 to 1
  51679. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51680. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51681. */
  51682. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51683. /**
  51684. * Append an hook to a rope object
  51685. * @param impostor is the rope impostor to add hook to
  51686. * @param otherImpostor is the rigid impostor to hook to
  51687. * @param length ratio along the rope from 0 to 1
  51688. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51689. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51690. */
  51691. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51692. /**
  51693. * Sleeps the physics body and stops it from being active
  51694. * @param impostor impostor to sleep
  51695. */
  51696. sleepBody(impostor: PhysicsImpostor): void;
  51697. /**
  51698. * Activates the physics body
  51699. * @param impostor impostor to activate
  51700. */
  51701. wakeUpBody(impostor: PhysicsImpostor): void;
  51702. /**
  51703. * Updates the distance parameters of the joint
  51704. * @param joint joint to update
  51705. * @param maxDistance maximum distance of the joint
  51706. * @param minDistance minimum distance of the joint
  51707. */
  51708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51709. /**
  51710. * Sets a motor on the joint
  51711. * @param joint joint to set motor on
  51712. * @param speed speed of the motor
  51713. * @param maxForce maximum force of the motor
  51714. * @param motorIndex index of the motor
  51715. */
  51716. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51717. /**
  51718. * Sets the motors limit
  51719. * @param joint joint to set limit on
  51720. * @param upperLimit upper limit
  51721. * @param lowerLimit lower limit
  51722. */
  51723. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51724. /**
  51725. * Syncs the position and rotation of a mesh with the impostor
  51726. * @param mesh mesh to sync
  51727. * @param impostor impostor to update the mesh with
  51728. */
  51729. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51730. /**
  51731. * Gets the radius of the impostor
  51732. * @param impostor impostor to get radius from
  51733. * @returns the radius
  51734. */
  51735. getRadius(impostor: PhysicsImpostor): number;
  51736. /**
  51737. * Gets the box size of the impostor
  51738. * @param impostor impostor to get box size from
  51739. * @param result the resulting box size
  51740. */
  51741. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51742. /**
  51743. * Disposes of the impostor
  51744. */
  51745. dispose(): void;
  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. interface AbstractScene {
  51757. /**
  51758. * The list of reflection probes added to the scene
  51759. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51760. */
  51761. reflectionProbes: Array<ReflectionProbe>;
  51762. /**
  51763. * Removes the given reflection probe from this scene.
  51764. * @param toRemove The reflection probe to remove
  51765. * @returns The index of the removed reflection probe
  51766. */
  51767. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51768. /**
  51769. * Adds the given reflection probe to this scene.
  51770. * @param newReflectionProbe The reflection probe to add
  51771. */
  51772. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51773. }
  51774. /**
  51775. * Class used to generate realtime reflection / refraction cube textures
  51776. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51777. */
  51778. export class ReflectionProbe {
  51779. /** defines the name of the probe */
  51780. name: string;
  51781. private _scene;
  51782. private _renderTargetTexture;
  51783. private _projectionMatrix;
  51784. private _viewMatrix;
  51785. private _target;
  51786. private _add;
  51787. private _attachedMesh;
  51788. private _invertYAxis;
  51789. /** Gets or sets probe position (center of the cube map) */
  51790. position: Vector3;
  51791. /**
  51792. * Creates a new reflection probe
  51793. * @param name defines the name of the probe
  51794. * @param size defines the texture resolution (for each face)
  51795. * @param scene defines the hosting scene
  51796. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51797. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51798. */
  51799. constructor(
  51800. /** defines the name of the probe */
  51801. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51802. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51803. samples: number;
  51804. /** Gets or sets the refresh rate to use (on every frame by default) */
  51805. refreshRate: number;
  51806. /**
  51807. * Gets the hosting scene
  51808. * @returns a Scene
  51809. */
  51810. getScene(): Scene;
  51811. /** Gets the internal CubeTexture used to render to */
  51812. readonly cubeTexture: RenderTargetTexture;
  51813. /** Gets the list of meshes to render */
  51814. readonly renderList: Nullable<AbstractMesh[]>;
  51815. /**
  51816. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51817. * @param mesh defines the mesh to attach to
  51818. */
  51819. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51820. /**
  51821. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51822. * @param renderingGroupId The rendering group id corresponding to its index
  51823. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51824. */
  51825. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51826. /**
  51827. * Clean all associated resources
  51828. */
  51829. dispose(): void;
  51830. /**
  51831. * Converts the reflection probe information to a readable string for debug purpose.
  51832. * @param fullDetails Supports for multiple levels of logging within scene loading
  51833. * @returns the human readable reflection probe info
  51834. */
  51835. toString(fullDetails?: boolean): string;
  51836. /**
  51837. * Get the class name of the relfection probe.
  51838. * @returns "ReflectionProbe"
  51839. */
  51840. getClassName(): string;
  51841. /**
  51842. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51843. * @returns The JSON representation of the texture
  51844. */
  51845. serialize(): any;
  51846. /**
  51847. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51848. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51849. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51850. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51851. * @returns The parsed reflection probe if successful
  51852. */
  51853. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51854. }
  51855. }
  51856. declare module BABYLON {
  51857. /** @hidden */
  51858. export var _BabylonLoaderRegistered: boolean;
  51859. }
  51860. declare module BABYLON {
  51861. /**
  51862. * The Physically based simple base material of BJS.
  51863. *
  51864. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51865. * It is used as the base class for both the specGloss and metalRough conventions.
  51866. */
  51867. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51868. /**
  51869. * Number of Simultaneous lights allowed on the material.
  51870. */
  51871. maxSimultaneousLights: number;
  51872. /**
  51873. * If sets to true, disables all the lights affecting the material.
  51874. */
  51875. disableLighting: boolean;
  51876. /**
  51877. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51878. */
  51879. environmentTexture: BaseTexture;
  51880. /**
  51881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51882. */
  51883. invertNormalMapX: boolean;
  51884. /**
  51885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51886. */
  51887. invertNormalMapY: boolean;
  51888. /**
  51889. * Normal map used in the model.
  51890. */
  51891. normalTexture: BaseTexture;
  51892. /**
  51893. * Emissivie color used to self-illuminate the model.
  51894. */
  51895. emissiveColor: Color3;
  51896. /**
  51897. * Emissivie texture used to self-illuminate the model.
  51898. */
  51899. emissiveTexture: BaseTexture;
  51900. /**
  51901. * Occlusion Channel Strenght.
  51902. */
  51903. occlusionStrength: number;
  51904. /**
  51905. * Occlusion Texture of the material (adding extra occlusion effects).
  51906. */
  51907. occlusionTexture: BaseTexture;
  51908. /**
  51909. * Defines the alpha limits in alpha test mode.
  51910. */
  51911. alphaCutOff: number;
  51912. /**
  51913. * Gets the current double sided mode.
  51914. */
  51915. /**
  51916. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51917. */
  51918. doubleSided: boolean;
  51919. /**
  51920. * Stores the pre-calculated light information of a mesh in a texture.
  51921. */
  51922. lightmapTexture: BaseTexture;
  51923. /**
  51924. * If true, the light map contains occlusion information instead of lighting info.
  51925. */
  51926. useLightmapAsShadowmap: boolean;
  51927. /**
  51928. * Instantiates a new PBRMaterial instance.
  51929. *
  51930. * @param name The material name
  51931. * @param scene The scene the material will be use in.
  51932. */
  51933. constructor(name: string, scene: Scene);
  51934. getClassName(): string;
  51935. }
  51936. }
  51937. declare module BABYLON {
  51938. /**
  51939. * The PBR material of BJS following the metal roughness convention.
  51940. *
  51941. * This fits to the PBR convention in the GLTF definition:
  51942. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51943. */
  51944. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51945. /**
  51946. * The base color has two different interpretations depending on the value of metalness.
  51947. * When the material is a metal, the base color is the specific measured reflectance value
  51948. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51949. * of the material.
  51950. */
  51951. baseColor: Color3;
  51952. /**
  51953. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51954. * well as opacity information in the alpha channel.
  51955. */
  51956. baseTexture: BaseTexture;
  51957. /**
  51958. * Specifies the metallic scalar value of the material.
  51959. * Can also be used to scale the metalness values of the metallic texture.
  51960. */
  51961. metallic: number;
  51962. /**
  51963. * Specifies the roughness scalar value of the material.
  51964. * Can also be used to scale the roughness values of the metallic texture.
  51965. */
  51966. roughness: number;
  51967. /**
  51968. * Texture containing both the metallic value in the B channel and the
  51969. * roughness value in the G channel to keep better precision.
  51970. */
  51971. metallicRoughnessTexture: BaseTexture;
  51972. /**
  51973. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51974. *
  51975. * @param name The material name
  51976. * @param scene The scene the material will be use in.
  51977. */
  51978. constructor(name: string, scene: Scene);
  51979. /**
  51980. * Return the currrent class name of the material.
  51981. */
  51982. getClassName(): string;
  51983. /**
  51984. * Makes a duplicate of the current material.
  51985. * @param name - name to use for the new material.
  51986. */
  51987. clone(name: string): PBRMetallicRoughnessMaterial;
  51988. /**
  51989. * Serialize the material to a parsable JSON object.
  51990. */
  51991. serialize(): any;
  51992. /**
  51993. * Parses a JSON object correponding to the serialize function.
  51994. */
  51995. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51996. }
  51997. }
  51998. declare module BABYLON {
  51999. /**
  52000. * The PBR material of BJS following the specular glossiness convention.
  52001. *
  52002. * This fits to the PBR convention in the GLTF definition:
  52003. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52004. */
  52005. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52006. /**
  52007. * Specifies the diffuse color of the material.
  52008. */
  52009. diffuseColor: Color3;
  52010. /**
  52011. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52012. * channel.
  52013. */
  52014. diffuseTexture: BaseTexture;
  52015. /**
  52016. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52017. */
  52018. specularColor: Color3;
  52019. /**
  52020. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52021. */
  52022. glossiness: number;
  52023. /**
  52024. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52025. */
  52026. specularGlossinessTexture: BaseTexture;
  52027. /**
  52028. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52029. *
  52030. * @param name The material name
  52031. * @param scene The scene the material will be use in.
  52032. */
  52033. constructor(name: string, scene: Scene);
  52034. /**
  52035. * Return the currrent class name of the material.
  52036. */
  52037. getClassName(): string;
  52038. /**
  52039. * Makes a duplicate of the current material.
  52040. * @param name - name to use for the new material.
  52041. */
  52042. clone(name: string): PBRSpecularGlossinessMaterial;
  52043. /**
  52044. * Serialize the material to a parsable JSON object.
  52045. */
  52046. serialize(): any;
  52047. /**
  52048. * Parses a JSON object correponding to the serialize function.
  52049. */
  52050. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52051. }
  52052. }
  52053. declare module BABYLON {
  52054. /**
  52055. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52056. * It can help converting any input color in a desired output one. This can then be used to create effects
  52057. * from sepia, black and white to sixties or futuristic rendering...
  52058. *
  52059. * The only supported format is currently 3dl.
  52060. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52061. */
  52062. export class ColorGradingTexture extends BaseTexture {
  52063. /**
  52064. * The current texture matrix. (will always be identity in color grading texture)
  52065. */
  52066. private _textureMatrix;
  52067. /**
  52068. * The texture URL.
  52069. */
  52070. url: string;
  52071. /**
  52072. * Empty line regex stored for GC.
  52073. */
  52074. private static _noneEmptyLineRegex;
  52075. private _engine;
  52076. /**
  52077. * Instantiates a ColorGradingTexture from the following parameters.
  52078. *
  52079. * @param url The location of the color gradind data (currently only supporting 3dl)
  52080. * @param scene The scene the texture will be used in
  52081. */
  52082. constructor(url: string, scene: Scene);
  52083. /**
  52084. * Returns the texture matrix used in most of the material.
  52085. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52086. */
  52087. getTextureMatrix(): Matrix;
  52088. /**
  52089. * Occurs when the file being loaded is a .3dl LUT file.
  52090. */
  52091. private load3dlTexture;
  52092. /**
  52093. * Starts the loading process of the texture.
  52094. */
  52095. private loadTexture;
  52096. /**
  52097. * Clones the color gradind texture.
  52098. */
  52099. clone(): ColorGradingTexture;
  52100. /**
  52101. * Called during delayed load for textures.
  52102. */
  52103. delayLoad(): void;
  52104. /**
  52105. * Parses a color grading texture serialized by Babylon.
  52106. * @param parsedTexture The texture information being parsedTexture
  52107. * @param scene The scene to load the texture in
  52108. * @param rootUrl The root url of the data assets to load
  52109. * @return A color gradind texture
  52110. */
  52111. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52112. /**
  52113. * Serializes the LUT texture to json format.
  52114. */
  52115. serialize(): any;
  52116. }
  52117. }
  52118. declare module BABYLON {
  52119. /**
  52120. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52121. */
  52122. export class EquiRectangularCubeTexture extends BaseTexture {
  52123. /** The six faces of the cube. */
  52124. private static _FacesMapping;
  52125. private _noMipmap;
  52126. private _onLoad;
  52127. private _onError;
  52128. /** The size of the cubemap. */
  52129. private _size;
  52130. /** The buffer of the image. */
  52131. private _buffer;
  52132. /** The width of the input image. */
  52133. private _width;
  52134. /** The height of the input image. */
  52135. private _height;
  52136. /** The URL to the image. */
  52137. url: string;
  52138. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52139. coordinatesMode: number;
  52140. /**
  52141. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52142. * @param url The location of the image
  52143. * @param scene The scene the texture will be used in
  52144. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52145. * @param noMipmap Forces to not generate the mipmap if true
  52146. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52147. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52148. * @param onLoad — defines a callback called when texture is loaded
  52149. * @param onError — defines a callback called if there is an error
  52150. */
  52151. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52152. /**
  52153. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52154. */
  52155. private loadImage;
  52156. /**
  52157. * Convert the image buffer into a cubemap and create a CubeTexture.
  52158. */
  52159. private loadTexture;
  52160. /**
  52161. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52162. * @param buffer The ArrayBuffer that should be converted.
  52163. * @returns The buffer as Float32Array.
  52164. */
  52165. private getFloat32ArrayFromArrayBuffer;
  52166. /**
  52167. * Get the current class name of the texture useful for serialization or dynamic coding.
  52168. * @returns "EquiRectangularCubeTexture"
  52169. */
  52170. getClassName(): string;
  52171. /**
  52172. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52173. * @returns A clone of the current EquiRectangularCubeTexture.
  52174. */
  52175. clone(): EquiRectangularCubeTexture;
  52176. }
  52177. }
  52178. declare module BABYLON {
  52179. /**
  52180. * Based on jsTGALoader - Javascript loader for TGA file
  52181. * By Vincent Thibault
  52182. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52183. */
  52184. export class TGATools {
  52185. private static _TYPE_INDEXED;
  52186. private static _TYPE_RGB;
  52187. private static _TYPE_GREY;
  52188. private static _TYPE_RLE_INDEXED;
  52189. private static _TYPE_RLE_RGB;
  52190. private static _TYPE_RLE_GREY;
  52191. private static _ORIGIN_MASK;
  52192. private static _ORIGIN_SHIFT;
  52193. private static _ORIGIN_BL;
  52194. private static _ORIGIN_BR;
  52195. private static _ORIGIN_UL;
  52196. private static _ORIGIN_UR;
  52197. /**
  52198. * Gets the header of a TGA file
  52199. * @param data defines the TGA data
  52200. * @returns the header
  52201. */
  52202. static GetTGAHeader(data: Uint8Array): any;
  52203. /**
  52204. * Uploads TGA content to a Babylon Texture
  52205. * @hidden
  52206. */
  52207. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52208. /** @hidden */
  52209. 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;
  52210. /** @hidden */
  52211. 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;
  52212. /** @hidden */
  52213. 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;
  52214. /** @hidden */
  52215. 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;
  52216. /** @hidden */
  52217. 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;
  52218. /** @hidden */
  52219. 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;
  52220. }
  52221. }
  52222. declare module BABYLON {
  52223. /**
  52224. * Implementation of the TGA Texture Loader.
  52225. * @hidden
  52226. */
  52227. export class _TGATextureLoader implements IInternalTextureLoader {
  52228. /**
  52229. * Defines wether the loader supports cascade loading the different faces.
  52230. */
  52231. readonly supportCascades: boolean;
  52232. /**
  52233. * This returns if the loader support the current file information.
  52234. * @param extension defines the file extension of the file being loaded
  52235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52236. * @param fallback defines the fallback internal texture if any
  52237. * @param isBase64 defines whether the texture is encoded as a base64
  52238. * @param isBuffer defines whether the texture data are stored as a buffer
  52239. * @returns true if the loader can load the specified file
  52240. */
  52241. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52242. /**
  52243. * Transform the url before loading if required.
  52244. * @param rootUrl the url of the texture
  52245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52246. * @returns the transformed texture
  52247. */
  52248. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52249. /**
  52250. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52251. * @param rootUrl the url of the texture
  52252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52253. * @returns the fallback texture
  52254. */
  52255. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52256. /**
  52257. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52258. * @param data contains the texture data
  52259. * @param texture defines the BabylonJS internal texture
  52260. * @param createPolynomials will be true if polynomials have been requested
  52261. * @param onLoad defines the callback to trigger once the texture is ready
  52262. * @param onError defines the callback to trigger in case of error
  52263. */
  52264. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52265. /**
  52266. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52267. * @param data contains the texture data
  52268. * @param texture defines the BabylonJS internal texture
  52269. * @param callback defines the method to call once ready to upload
  52270. */
  52271. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52272. }
  52273. }
  52274. declare module BABYLON {
  52275. /**
  52276. * Info about the .basis files
  52277. */
  52278. class BasisFileInfo {
  52279. /**
  52280. * If the file has alpha
  52281. */
  52282. hasAlpha: boolean;
  52283. /**
  52284. * Info about each image of the basis file
  52285. */
  52286. images: Array<{
  52287. levels: Array<{
  52288. width: number;
  52289. height: number;
  52290. transcodedPixels: ArrayBufferView;
  52291. }>;
  52292. }>;
  52293. }
  52294. /**
  52295. * Result of transcoding a basis file
  52296. */
  52297. class TranscodeResult {
  52298. /**
  52299. * Info about the .basis file
  52300. */
  52301. fileInfo: BasisFileInfo;
  52302. /**
  52303. * Format to use when loading the file
  52304. */
  52305. format: number;
  52306. }
  52307. /**
  52308. * Configuration options for the Basis transcoder
  52309. */
  52310. export class BasisTranscodeConfiguration {
  52311. /**
  52312. * Supported compression formats used to determine the supported output format of the transcoder
  52313. */
  52314. supportedCompressionFormats?: {
  52315. /**
  52316. * etc1 compression format
  52317. */
  52318. etc1?: boolean;
  52319. /**
  52320. * s3tc compression format
  52321. */
  52322. s3tc?: boolean;
  52323. /**
  52324. * pvrtc compression format
  52325. */
  52326. pvrtc?: boolean;
  52327. /**
  52328. * etc2 compression format
  52329. */
  52330. etc2?: boolean;
  52331. };
  52332. /**
  52333. * If mipmap levels should be loaded for transcoded images (Default: true)
  52334. */
  52335. loadMipmapLevels?: boolean;
  52336. /**
  52337. * Index of a single image to load (Default: all images)
  52338. */
  52339. loadSingleImage?: number;
  52340. }
  52341. /**
  52342. * Used to load .Basis files
  52343. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52344. */
  52345. export class BasisTools {
  52346. private static _IgnoreSupportedFormats;
  52347. /**
  52348. * URL to use when loading the basis transcoder
  52349. */
  52350. static JSModuleURL: string;
  52351. /**
  52352. * URL to use when loading the wasm module for the transcoder
  52353. */
  52354. static WasmModuleURL: string;
  52355. /**
  52356. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52357. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52358. * @returns internal format corresponding to the Basis format
  52359. */
  52360. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52361. private static _WorkerPromise;
  52362. private static _Worker;
  52363. private static _actionId;
  52364. private static _CreateWorkerAsync;
  52365. /**
  52366. * Transcodes a loaded image file to compressed pixel data
  52367. * @param imageData image data to transcode
  52368. * @param config configuration options for the transcoding
  52369. * @returns a promise resulting in the transcoded image
  52370. */
  52371. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52372. /**
  52373. * Loads a texture from the transcode result
  52374. * @param texture texture load to
  52375. * @param transcodeResult the result of transcoding the basis file to load from
  52376. */
  52377. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Loader for .basis file format
  52383. */
  52384. export class _BasisTextureLoader implements IInternalTextureLoader {
  52385. /**
  52386. * Defines whether the loader supports cascade loading the different faces.
  52387. */
  52388. readonly supportCascades: boolean;
  52389. /**
  52390. * This returns if the loader support the current file information.
  52391. * @param extension defines the file extension of the file being loaded
  52392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52393. * @param fallback defines the fallback internal texture if any
  52394. * @param isBase64 defines whether the texture is encoded as a base64
  52395. * @param isBuffer defines whether the texture data are stored as a buffer
  52396. * @returns true if the loader can load the specified file
  52397. */
  52398. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52399. /**
  52400. * Transform the url before loading if required.
  52401. * @param rootUrl the url of the texture
  52402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52403. * @returns the transformed texture
  52404. */
  52405. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52406. /**
  52407. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52408. * @param rootUrl the url of the texture
  52409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52410. * @returns the fallback texture
  52411. */
  52412. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52413. /**
  52414. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52415. * @param data contains the texture data
  52416. * @param texture defines the BabylonJS internal texture
  52417. * @param createPolynomials will be true if polynomials have been requested
  52418. * @param onLoad defines the callback to trigger once the texture is ready
  52419. * @param onError defines the callback to trigger in case of error
  52420. */
  52421. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52422. /**
  52423. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52424. * @param data contains the texture data
  52425. * @param texture defines the BabylonJS internal texture
  52426. * @param callback defines the method to call once ready to upload
  52427. */
  52428. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52429. }
  52430. }
  52431. declare module BABYLON {
  52432. /**
  52433. * 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.
  52434. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52435. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52436. */
  52437. export class CustomProceduralTexture extends ProceduralTexture {
  52438. private _animate;
  52439. private _time;
  52440. private _config;
  52441. private _texturePath;
  52442. /**
  52443. * Instantiates a new Custom Procedural Texture.
  52444. * 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.
  52445. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52446. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52447. * @param name Define the name of the texture
  52448. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52449. * @param size Define the size of the texture to create
  52450. * @param scene Define the scene the texture belongs to
  52451. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52452. * @param generateMipMaps Define if the texture should creates mip maps or not
  52453. */
  52454. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52455. private _loadJson;
  52456. /**
  52457. * Is the texture ready to be used ? (rendered at least once)
  52458. * @returns true if ready, otherwise, false.
  52459. */
  52460. isReady(): boolean;
  52461. /**
  52462. * Render the texture to its associated render target.
  52463. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52464. */
  52465. render(useCameraPostProcess?: boolean): void;
  52466. /**
  52467. * Update the list of dependant textures samplers in the shader.
  52468. */
  52469. updateTextures(): void;
  52470. /**
  52471. * Update the uniform values of the procedural texture in the shader.
  52472. */
  52473. updateShaderUniforms(): void;
  52474. /**
  52475. * Define if the texture animates or not.
  52476. */
  52477. animate: boolean;
  52478. }
  52479. }
  52480. declare module BABYLON {
  52481. /** @hidden */
  52482. export var noisePixelShader: {
  52483. name: string;
  52484. shader: string;
  52485. };
  52486. }
  52487. declare module BABYLON {
  52488. /**
  52489. * Class used to generate noise procedural textures
  52490. */
  52491. export class NoiseProceduralTexture extends ProceduralTexture {
  52492. private _time;
  52493. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52494. brightness: number;
  52495. /** Defines the number of octaves to process */
  52496. octaves: number;
  52497. /** Defines the level of persistence (0.8 by default) */
  52498. persistence: number;
  52499. /** Gets or sets animation speed factor (default is 1) */
  52500. animationSpeedFactor: number;
  52501. /**
  52502. * Creates a new NoiseProceduralTexture
  52503. * @param name defines the name fo the texture
  52504. * @param size defines the size of the texture (default is 256)
  52505. * @param scene defines the hosting scene
  52506. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52507. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52508. */
  52509. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52510. private _updateShaderUniforms;
  52511. protected _getDefines(): string;
  52512. /** Generate the current state of the procedural texture */
  52513. render(useCameraPostProcess?: boolean): void;
  52514. /**
  52515. * Serializes this noise procedural texture
  52516. * @returns a serialized noise procedural texture object
  52517. */
  52518. serialize(): any;
  52519. /**
  52520. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52521. * @param parsedTexture defines parsed texture data
  52522. * @param scene defines the current scene
  52523. * @param rootUrl defines the root URL containing noise procedural texture information
  52524. * @returns a parsed NoiseProceduralTexture
  52525. */
  52526. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52527. }
  52528. }
  52529. declare module BABYLON {
  52530. /**
  52531. * Raw cube texture where the raw buffers are passed in
  52532. */
  52533. export class RawCubeTexture extends CubeTexture {
  52534. /**
  52535. * Creates a cube texture where the raw buffers are passed in.
  52536. * @param scene defines the scene the texture is attached to
  52537. * @param data defines the array of data to use to create each face
  52538. * @param size defines the size of the textures
  52539. * @param format defines the format of the data
  52540. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52541. * @param generateMipMaps defines if the engine should generate the mip levels
  52542. * @param invertY defines if data must be stored with Y axis inverted
  52543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52544. * @param compression defines the compression used (null by default)
  52545. */
  52546. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52547. /**
  52548. * Updates the raw cube texture.
  52549. * @param data defines the data to store
  52550. * @param format defines the data format
  52551. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52552. * @param invertY defines if data must be stored with Y axis inverted
  52553. * @param compression defines the compression used (null by default)
  52554. * @param level defines which level of the texture to update
  52555. */
  52556. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52557. /**
  52558. * Updates a raw cube texture with RGBD encoded data.
  52559. * @param data defines the array of data [mipmap][face] to use to create each face
  52560. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52561. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52562. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52563. * @returns a promsie that resolves when the operation is complete
  52564. */
  52565. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52566. /**
  52567. * Clones the raw cube texture.
  52568. * @return a new cube texture
  52569. */
  52570. clone(): CubeTexture;
  52571. /** @hidden */
  52572. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52573. }
  52574. }
  52575. declare module BABYLON {
  52576. /**
  52577. * Class used to store 3D textures containing user data
  52578. */
  52579. export class RawTexture3D extends Texture {
  52580. /** Gets or sets the texture format to use */
  52581. format: number;
  52582. private _engine;
  52583. /**
  52584. * Create a new RawTexture3D
  52585. * @param data defines the data of the texture
  52586. * @param width defines the width of the texture
  52587. * @param height defines the height of the texture
  52588. * @param depth defines the depth of the texture
  52589. * @param format defines the texture format to use
  52590. * @param scene defines the hosting scene
  52591. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52592. * @param invertY defines if texture must be stored with Y axis inverted
  52593. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52594. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52595. */
  52596. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52597. /** Gets or sets the texture format to use */
  52598. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52599. /**
  52600. * Update the texture with new data
  52601. * @param data defines the data to store in the texture
  52602. */
  52603. update(data: ArrayBufferView): void;
  52604. }
  52605. }
  52606. declare module BABYLON {
  52607. /**
  52608. * Creates a refraction texture used by refraction channel of the standard material.
  52609. * It is like a mirror but to see through a material.
  52610. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52611. */
  52612. export class RefractionTexture extends RenderTargetTexture {
  52613. /**
  52614. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52615. * 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.
  52616. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52617. */
  52618. refractionPlane: Plane;
  52619. /**
  52620. * Define how deep under the surface we should see.
  52621. */
  52622. depth: number;
  52623. /**
  52624. * Creates a refraction texture used by refraction channel of the standard material.
  52625. * It is like a mirror but to see through a material.
  52626. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52627. * @param name Define the texture name
  52628. * @param size Define the size of the underlying texture
  52629. * @param scene Define the scene the refraction belongs to
  52630. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52631. */
  52632. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52633. /**
  52634. * Clone the refraction texture.
  52635. * @returns the cloned texture
  52636. */
  52637. clone(): RefractionTexture;
  52638. /**
  52639. * Serialize the texture to a JSON representation you could use in Parse later on
  52640. * @returns the serialized JSON representation
  52641. */
  52642. serialize(): any;
  52643. }
  52644. }
  52645. declare module BABYLON {
  52646. /**
  52647. * Defines the options related to the creation of an HtmlElementTexture
  52648. */
  52649. export interface IHtmlElementTextureOptions {
  52650. /**
  52651. * Defines wether mip maps should be created or not.
  52652. */
  52653. generateMipMaps?: boolean;
  52654. /**
  52655. * Defines the sampling mode of the texture.
  52656. */
  52657. samplingMode?: number;
  52658. /**
  52659. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52660. */
  52661. engine: Nullable<ThinEngine>;
  52662. /**
  52663. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52664. */
  52665. scene: Nullable<Scene>;
  52666. }
  52667. /**
  52668. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52669. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52670. * is automatically managed.
  52671. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52672. * in your application.
  52673. *
  52674. * As the update is not automatic, you need to call them manually.
  52675. */
  52676. export class HtmlElementTexture extends BaseTexture {
  52677. /**
  52678. * The texture URL.
  52679. */
  52680. element: HTMLVideoElement | HTMLCanvasElement;
  52681. private static readonly DefaultOptions;
  52682. private _textureMatrix;
  52683. private _engine;
  52684. private _isVideo;
  52685. private _generateMipMaps;
  52686. private _samplingMode;
  52687. /**
  52688. * Instantiates a HtmlElementTexture from the following parameters.
  52689. *
  52690. * @param name Defines the name of the texture
  52691. * @param element Defines the video or canvas the texture is filled with
  52692. * @param options Defines the other none mandatory texture creation options
  52693. */
  52694. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52695. private _createInternalTexture;
  52696. /**
  52697. * Returns the texture matrix used in most of the material.
  52698. */
  52699. getTextureMatrix(): Matrix;
  52700. /**
  52701. * Updates the content of the texture.
  52702. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52703. */
  52704. update(invertY?: Nullable<boolean>): void;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * Enum used to define the target of a block
  52710. */
  52711. export enum NodeMaterialBlockTargets {
  52712. /** Vertex shader */
  52713. Vertex = 1,
  52714. /** Fragment shader */
  52715. Fragment = 2,
  52716. /** Neutral */
  52717. Neutral = 4,
  52718. /** Vertex and Fragment */
  52719. VertexAndFragment = 3
  52720. }
  52721. }
  52722. declare module BABYLON {
  52723. /**
  52724. * Defines the kind of connection point for node based material
  52725. */
  52726. export enum NodeMaterialBlockConnectionPointTypes {
  52727. /** Float */
  52728. Float = 1,
  52729. /** Int */
  52730. Int = 2,
  52731. /** Vector2 */
  52732. Vector2 = 4,
  52733. /** Vector3 */
  52734. Vector3 = 8,
  52735. /** Vector4 */
  52736. Vector4 = 16,
  52737. /** Color3 */
  52738. Color3 = 32,
  52739. /** Color4 */
  52740. Color4 = 64,
  52741. /** Matrix */
  52742. Matrix = 128,
  52743. /** Detect type based on connection */
  52744. AutoDetect = 1024,
  52745. /** Output type that will be defined by input type */
  52746. BasedOnInput = 2048
  52747. }
  52748. }
  52749. declare module BABYLON {
  52750. /**
  52751. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52752. */
  52753. export enum NodeMaterialBlockConnectionPointMode {
  52754. /** Value is an uniform */
  52755. Uniform = 0,
  52756. /** Value is a mesh attribute */
  52757. Attribute = 1,
  52758. /** Value is a varying between vertex and fragment shaders */
  52759. Varying = 2,
  52760. /** Mode is undefined */
  52761. Undefined = 3
  52762. }
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * Enum used to define system values e.g. values automatically provided by the system
  52767. */
  52768. export enum NodeMaterialSystemValues {
  52769. /** World */
  52770. World = 1,
  52771. /** View */
  52772. View = 2,
  52773. /** Projection */
  52774. Projection = 3,
  52775. /** ViewProjection */
  52776. ViewProjection = 4,
  52777. /** WorldView */
  52778. WorldView = 5,
  52779. /** WorldViewProjection */
  52780. WorldViewProjection = 6,
  52781. /** CameraPosition */
  52782. CameraPosition = 7,
  52783. /** Fog Color */
  52784. FogColor = 8,
  52785. /** Delta time */
  52786. DeltaTime = 9
  52787. }
  52788. }
  52789. declare module BABYLON {
  52790. /**
  52791. * Root class for all node material optimizers
  52792. */
  52793. export class NodeMaterialOptimizer {
  52794. /**
  52795. * Function used to optimize a NodeMaterial graph
  52796. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52797. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52798. */
  52799. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52800. }
  52801. }
  52802. declare module BABYLON {
  52803. /**
  52804. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52805. */
  52806. export class TransformBlock extends NodeMaterialBlock {
  52807. /**
  52808. * Defines the value to use to complement W value to transform it to a Vector4
  52809. */
  52810. complementW: number;
  52811. /**
  52812. * Defines the value to use to complement z value to transform it to a Vector4
  52813. */
  52814. complementZ: number;
  52815. /**
  52816. * Creates a new TransformBlock
  52817. * @param name defines the block name
  52818. */
  52819. constructor(name: string);
  52820. /**
  52821. * Gets the current class name
  52822. * @returns the class name
  52823. */
  52824. getClassName(): string;
  52825. /**
  52826. * Gets the vector input
  52827. */
  52828. readonly vector: NodeMaterialConnectionPoint;
  52829. /**
  52830. * Gets the output component
  52831. */
  52832. readonly output: NodeMaterialConnectionPoint;
  52833. /**
  52834. * Gets the matrix transform input
  52835. */
  52836. readonly transform: NodeMaterialConnectionPoint;
  52837. protected _buildBlock(state: NodeMaterialBuildState): this;
  52838. serialize(): any;
  52839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52840. protected _dumpPropertiesCode(): string;
  52841. }
  52842. }
  52843. declare module BABYLON {
  52844. /**
  52845. * Block used to output the vertex position
  52846. */
  52847. export class VertexOutputBlock extends NodeMaterialBlock {
  52848. /**
  52849. * Creates a new VertexOutputBlock
  52850. * @param name defines the block name
  52851. */
  52852. constructor(name: string);
  52853. /**
  52854. * Gets the current class name
  52855. * @returns the class name
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Gets the vector input component
  52860. */
  52861. readonly vector: NodeMaterialConnectionPoint;
  52862. protected _buildBlock(state: NodeMaterialBuildState): this;
  52863. }
  52864. }
  52865. declare module BABYLON {
  52866. /**
  52867. * Block used to output the final color
  52868. */
  52869. export class FragmentOutputBlock extends NodeMaterialBlock {
  52870. /**
  52871. * Create a new FragmentOutputBlock
  52872. * @param name defines the block name
  52873. */
  52874. constructor(name: string);
  52875. /**
  52876. * Gets the current class name
  52877. * @returns the class name
  52878. */
  52879. getClassName(): string;
  52880. /**
  52881. * Gets the rgba input component
  52882. */
  52883. readonly rgba: NodeMaterialConnectionPoint;
  52884. /**
  52885. * Gets the rgb input component
  52886. */
  52887. readonly rgb: NodeMaterialConnectionPoint;
  52888. /**
  52889. * Gets the a input component
  52890. */
  52891. readonly a: NodeMaterialConnectionPoint;
  52892. protected _buildBlock(state: NodeMaterialBuildState): this;
  52893. }
  52894. }
  52895. declare module BABYLON {
  52896. /**
  52897. * Block used to read a reflection texture from a sampler
  52898. */
  52899. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52900. private _define3DName;
  52901. private _defineCubicName;
  52902. private _defineExplicitName;
  52903. private _defineProjectionName;
  52904. private _defineLocalCubicName;
  52905. private _defineSphericalName;
  52906. private _definePlanarName;
  52907. private _defineEquirectangularName;
  52908. private _defineMirroredEquirectangularFixedName;
  52909. private _defineEquirectangularFixedName;
  52910. private _defineSkyboxName;
  52911. private _cubeSamplerName;
  52912. private _2DSamplerName;
  52913. private _positionUVWName;
  52914. private _directionWName;
  52915. private _reflectionCoordsName;
  52916. private _reflection2DCoordsName;
  52917. private _reflectionColorName;
  52918. private _reflectionMatrixName;
  52919. /**
  52920. * Gets or sets the texture associated with the node
  52921. */
  52922. texture: Nullable<BaseTexture>;
  52923. /**
  52924. * Create a new TextureBlock
  52925. * @param name defines the block name
  52926. */
  52927. constructor(name: string);
  52928. /**
  52929. * Gets the current class name
  52930. * @returns the class name
  52931. */
  52932. getClassName(): string;
  52933. /**
  52934. * Gets the world position input component
  52935. */
  52936. readonly position: NodeMaterialConnectionPoint;
  52937. /**
  52938. * Gets the world position input component
  52939. */
  52940. readonly worldPosition: NodeMaterialConnectionPoint;
  52941. /**
  52942. * Gets the world normal input component
  52943. */
  52944. readonly worldNormal: NodeMaterialConnectionPoint;
  52945. /**
  52946. * Gets the world input component
  52947. */
  52948. readonly world: NodeMaterialConnectionPoint;
  52949. /**
  52950. * Gets the camera (or eye) position component
  52951. */
  52952. readonly cameraPosition: NodeMaterialConnectionPoint;
  52953. /**
  52954. * Gets the view input component
  52955. */
  52956. readonly view: NodeMaterialConnectionPoint;
  52957. /**
  52958. * Gets the rgb output component
  52959. */
  52960. readonly rgb: NodeMaterialConnectionPoint;
  52961. /**
  52962. * Gets the r output component
  52963. */
  52964. readonly r: NodeMaterialConnectionPoint;
  52965. /**
  52966. * Gets the g output component
  52967. */
  52968. readonly g: NodeMaterialConnectionPoint;
  52969. /**
  52970. * Gets the b output component
  52971. */
  52972. readonly b: NodeMaterialConnectionPoint;
  52973. autoConfigure(material: NodeMaterial): void;
  52974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52975. isReady(): boolean;
  52976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52977. private _injectVertexCode;
  52978. private _writeOutput;
  52979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52980. serialize(): any;
  52981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52982. }
  52983. }
  52984. declare module BABYLON {
  52985. /**
  52986. * Interface used to configure the node material editor
  52987. */
  52988. export interface INodeMaterialEditorOptions {
  52989. /** Define the URl to load node editor script */
  52990. editorURL?: string;
  52991. }
  52992. /** @hidden */
  52993. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52994. /** BONES */
  52995. NUM_BONE_INFLUENCERS: number;
  52996. BonesPerMesh: number;
  52997. BONETEXTURE: boolean;
  52998. /** MORPH TARGETS */
  52999. MORPHTARGETS: boolean;
  53000. MORPHTARGETS_NORMAL: boolean;
  53001. MORPHTARGETS_TANGENT: boolean;
  53002. MORPHTARGETS_UV: boolean;
  53003. NUM_MORPH_INFLUENCERS: number;
  53004. /** IMAGE PROCESSING */
  53005. IMAGEPROCESSING: boolean;
  53006. VIGNETTE: boolean;
  53007. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53008. VIGNETTEBLENDMODEOPAQUE: boolean;
  53009. TONEMAPPING: boolean;
  53010. TONEMAPPING_ACES: boolean;
  53011. CONTRAST: boolean;
  53012. EXPOSURE: boolean;
  53013. COLORCURVES: boolean;
  53014. COLORGRADING: boolean;
  53015. COLORGRADING3D: boolean;
  53016. SAMPLER3DGREENDEPTH: boolean;
  53017. SAMPLER3DBGRMAP: boolean;
  53018. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53019. /** MISC. */
  53020. BUMPDIRECTUV: number;
  53021. constructor();
  53022. setValue(name: string, value: boolean): void;
  53023. }
  53024. /**
  53025. * Class used to configure NodeMaterial
  53026. */
  53027. export interface INodeMaterialOptions {
  53028. /**
  53029. * Defines if blocks should emit comments
  53030. */
  53031. emitComments: boolean;
  53032. }
  53033. /**
  53034. * Class used to create a node based material built by assembling shader blocks
  53035. */
  53036. export class NodeMaterial extends PushMaterial {
  53037. private static _BuildIdGenerator;
  53038. private _options;
  53039. private _vertexCompilationState;
  53040. private _fragmentCompilationState;
  53041. private _sharedData;
  53042. private _buildId;
  53043. private _buildWasSuccessful;
  53044. private _cachedWorldViewMatrix;
  53045. private _cachedWorldViewProjectionMatrix;
  53046. private _optimizers;
  53047. private _animationFrame;
  53048. /** Define the URl to load node editor script */
  53049. static EditorURL: string;
  53050. private BJSNODEMATERIALEDITOR;
  53051. /** Get the inspector from bundle or global */
  53052. private _getGlobalNodeMaterialEditor;
  53053. /**
  53054. * 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)
  53055. */
  53056. ignoreAlpha: boolean;
  53057. /**
  53058. * Defines the maximum number of lights that can be used in the material
  53059. */
  53060. maxSimultaneousLights: number;
  53061. /**
  53062. * Observable raised when the material is built
  53063. */
  53064. onBuildObservable: Observable<NodeMaterial>;
  53065. /**
  53066. * Gets or sets the root nodes of the material vertex shader
  53067. */
  53068. _vertexOutputNodes: NodeMaterialBlock[];
  53069. /**
  53070. * Gets or sets the root nodes of the material fragment (pixel) shader
  53071. */
  53072. _fragmentOutputNodes: NodeMaterialBlock[];
  53073. /** Gets or sets options to control the node material overall behavior */
  53074. options: INodeMaterialOptions;
  53075. /**
  53076. * Default configuration related to image processing available in the standard Material.
  53077. */
  53078. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53079. /**
  53080. * Gets the image processing configuration used either in this material.
  53081. */
  53082. /**
  53083. * Sets the Default image processing configuration used either in the this material.
  53084. *
  53085. * If sets to null, the scene one is in use.
  53086. */
  53087. imageProcessingConfiguration: ImageProcessingConfiguration;
  53088. /**
  53089. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53090. */
  53091. attachedBlocks: NodeMaterialBlock[];
  53092. /**
  53093. * Create a new node based material
  53094. * @param name defines the material name
  53095. * @param scene defines the hosting scene
  53096. * @param options defines creation option
  53097. */
  53098. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53099. /**
  53100. * Gets the current class name of the material e.g. "NodeMaterial"
  53101. * @returns the class name
  53102. */
  53103. getClassName(): string;
  53104. /**
  53105. * Keep track of the image processing observer to allow dispose and replace.
  53106. */
  53107. private _imageProcessingObserver;
  53108. /**
  53109. * Attaches a new image processing configuration to the Standard Material.
  53110. * @param configuration
  53111. */
  53112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53113. /**
  53114. * Get a block by its name
  53115. * @param name defines the name of the block to retrieve
  53116. * @returns the required block or null if not found
  53117. */
  53118. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53119. /**
  53120. * Get a block by its name
  53121. * @param predicate defines the predicate used to find the good candidate
  53122. * @returns the required block or null if not found
  53123. */
  53124. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53125. /**
  53126. * Get an input block by its name
  53127. * @param predicate defines the predicate used to find the good candidate
  53128. * @returns the required input block or null if not found
  53129. */
  53130. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53131. /**
  53132. * Gets the list of input blocks attached to this material
  53133. * @returns an array of InputBlocks
  53134. */
  53135. getInputBlocks(): InputBlock[];
  53136. /**
  53137. * Adds a new optimizer to the list of optimizers
  53138. * @param optimizer defines the optimizers to add
  53139. * @returns the current material
  53140. */
  53141. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53142. /**
  53143. * Remove an optimizer from the list of optimizers
  53144. * @param optimizer defines the optimizers to remove
  53145. * @returns the current material
  53146. */
  53147. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53148. /**
  53149. * Add a new block to the list of output nodes
  53150. * @param node defines the node to add
  53151. * @returns the current material
  53152. */
  53153. addOutputNode(node: NodeMaterialBlock): this;
  53154. /**
  53155. * Remove a block from the list of root nodes
  53156. * @param node defines the node to remove
  53157. * @returns the current material
  53158. */
  53159. removeOutputNode(node: NodeMaterialBlock): this;
  53160. private _addVertexOutputNode;
  53161. private _removeVertexOutputNode;
  53162. private _addFragmentOutputNode;
  53163. private _removeFragmentOutputNode;
  53164. /**
  53165. * Specifies if the material will require alpha blending
  53166. * @returns a boolean specifying if alpha blending is needed
  53167. */
  53168. needAlphaBlending(): boolean;
  53169. /**
  53170. * Specifies if this material should be rendered in alpha test mode
  53171. * @returns a boolean specifying if an alpha test is needed.
  53172. */
  53173. needAlphaTesting(): boolean;
  53174. private _initializeBlock;
  53175. private _resetDualBlocks;
  53176. /**
  53177. * Build the material and generates the inner effect
  53178. * @param verbose defines if the build should log activity
  53179. */
  53180. build(verbose?: boolean): void;
  53181. /**
  53182. * Runs an otpimization phase to try to improve the shader code
  53183. */
  53184. optimize(): void;
  53185. private _prepareDefinesForAttributes;
  53186. /**
  53187. * Get if the submesh is ready to be used and all its information available.
  53188. * Child classes can use it to update shaders
  53189. * @param mesh defines the mesh to check
  53190. * @param subMesh defines which submesh to check
  53191. * @param useInstances specifies that instances should be used
  53192. * @returns a boolean indicating that the submesh is ready or not
  53193. */
  53194. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53195. /**
  53196. * Get a string representing the shaders built by the current node graph
  53197. */
  53198. readonly compiledShaders: string;
  53199. /**
  53200. * Binds the world matrix to the material
  53201. * @param world defines the world transformation matrix
  53202. */
  53203. bindOnlyWorldMatrix(world: Matrix): void;
  53204. /**
  53205. * Binds the submesh to this material by preparing the effect and shader to draw
  53206. * @param world defines the world transformation matrix
  53207. * @param mesh defines the mesh containing the submesh
  53208. * @param subMesh defines the submesh to bind the material to
  53209. */
  53210. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53211. /**
  53212. * Gets the active textures from the material
  53213. * @returns an array of textures
  53214. */
  53215. getActiveTextures(): BaseTexture[];
  53216. /**
  53217. * Gets the list of texture blocks
  53218. * @returns an array of texture blocks
  53219. */
  53220. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53221. /**
  53222. * Specifies if the material uses a texture
  53223. * @param texture defines the texture to check against the material
  53224. * @returns a boolean specifying if the material uses the texture
  53225. */
  53226. hasTexture(texture: BaseTexture): boolean;
  53227. /**
  53228. * Disposes the material
  53229. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53230. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53231. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53232. */
  53233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53234. /** Creates the node editor window. */
  53235. private _createNodeEditor;
  53236. /**
  53237. * Launch the node material editor
  53238. * @param config Define the configuration of the editor
  53239. * @return a promise fulfilled when the node editor is visible
  53240. */
  53241. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53242. /**
  53243. * Clear the current material
  53244. */
  53245. clear(): void;
  53246. /**
  53247. * Clear the current material and set it to a default state
  53248. */
  53249. setToDefault(): void;
  53250. /**
  53251. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53252. * @param url defines the url to load from
  53253. * @returns a promise that will fullfil when the material is fully loaded
  53254. */
  53255. loadAsync(url: string): Promise<void>;
  53256. private _gatherBlocks;
  53257. /**
  53258. * Generate a string containing the code declaration required to create an equivalent of this material
  53259. * @returns a string
  53260. */
  53261. generateCode(): string;
  53262. /**
  53263. * Serializes this material in a JSON representation
  53264. * @returns the serialized material object
  53265. */
  53266. serialize(): any;
  53267. private _restoreConnections;
  53268. /**
  53269. * Clear the current graph and load a new one from a serialization object
  53270. * @param source defines the JSON representation of the material
  53271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53272. */
  53273. loadFromSerialization(source: any, rootUrl?: string): void;
  53274. /**
  53275. * Creates a node material from parsed material data
  53276. * @param source defines the JSON representation of the material
  53277. * @param scene defines the hosting scene
  53278. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53279. * @returns a new node material
  53280. */
  53281. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53282. /**
  53283. * Creates a new node material set to default basic configuration
  53284. * @param name defines the name of the material
  53285. * @param scene defines the hosting scene
  53286. * @returns a new NodeMaterial
  53287. */
  53288. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53289. }
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Block used to read a texture from a sampler
  53294. */
  53295. export class TextureBlock extends NodeMaterialBlock {
  53296. private _defineName;
  53297. private _linearDefineName;
  53298. private _samplerName;
  53299. private _transformedUVName;
  53300. private _textureTransformName;
  53301. private _textureInfoName;
  53302. private _mainUVName;
  53303. private _mainUVDefineName;
  53304. /**
  53305. * Gets or sets the texture associated with the node
  53306. */
  53307. texture: Nullable<Texture>;
  53308. /**
  53309. * Create a new TextureBlock
  53310. * @param name defines the block name
  53311. */
  53312. constructor(name: string);
  53313. /**
  53314. * Gets the current class name
  53315. * @returns the class name
  53316. */
  53317. getClassName(): string;
  53318. /**
  53319. * Gets the uv input component
  53320. */
  53321. readonly uv: NodeMaterialConnectionPoint;
  53322. /**
  53323. * Gets the rgba output component
  53324. */
  53325. readonly rgba: NodeMaterialConnectionPoint;
  53326. /**
  53327. * Gets the rgb output component
  53328. */
  53329. readonly rgb: NodeMaterialConnectionPoint;
  53330. /**
  53331. * Gets the r output component
  53332. */
  53333. readonly r: NodeMaterialConnectionPoint;
  53334. /**
  53335. * Gets the g output component
  53336. */
  53337. readonly g: NodeMaterialConnectionPoint;
  53338. /**
  53339. * Gets the b output component
  53340. */
  53341. readonly b: NodeMaterialConnectionPoint;
  53342. /**
  53343. * Gets the a output component
  53344. */
  53345. readonly a: NodeMaterialConnectionPoint;
  53346. readonly target: NodeMaterialBlockTargets;
  53347. autoConfigure(material: NodeMaterial): void;
  53348. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53350. isReady(): boolean;
  53351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53352. private readonly _isMixed;
  53353. private _injectVertexCode;
  53354. private _writeOutput;
  53355. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53356. protected _dumpPropertiesCode(): string;
  53357. serialize(): any;
  53358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53359. }
  53360. }
  53361. declare module BABYLON {
  53362. /**
  53363. * Class used to store shared data between 2 NodeMaterialBuildState
  53364. */
  53365. export class NodeMaterialBuildStateSharedData {
  53366. /**
  53367. * Gets the list of emitted varyings
  53368. */
  53369. temps: string[];
  53370. /**
  53371. * Gets the list of emitted varyings
  53372. */
  53373. varyings: string[];
  53374. /**
  53375. * Gets the varying declaration string
  53376. */
  53377. varyingDeclaration: string;
  53378. /**
  53379. * Input blocks
  53380. */
  53381. inputBlocks: InputBlock[];
  53382. /**
  53383. * Input blocks
  53384. */
  53385. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53386. /**
  53387. * Bindable blocks (Blocks that need to set data to the effect)
  53388. */
  53389. bindableBlocks: NodeMaterialBlock[];
  53390. /**
  53391. * List of blocks that can provide a compilation fallback
  53392. */
  53393. blocksWithFallbacks: NodeMaterialBlock[];
  53394. /**
  53395. * List of blocks that can provide a define update
  53396. */
  53397. blocksWithDefines: NodeMaterialBlock[];
  53398. /**
  53399. * List of blocks that can provide a repeatable content
  53400. */
  53401. repeatableContentBlocks: NodeMaterialBlock[];
  53402. /**
  53403. * List of blocks that can provide a dynamic list of uniforms
  53404. */
  53405. dynamicUniformBlocks: NodeMaterialBlock[];
  53406. /**
  53407. * List of blocks that can block the isReady function for the material
  53408. */
  53409. blockingBlocks: NodeMaterialBlock[];
  53410. /**
  53411. * Gets the list of animated inputs
  53412. */
  53413. animatedInputs: InputBlock[];
  53414. /**
  53415. * Build Id used to avoid multiple recompilations
  53416. */
  53417. buildId: number;
  53418. /** List of emitted variables */
  53419. variableNames: {
  53420. [key: string]: number;
  53421. };
  53422. /** List of emitted defines */
  53423. defineNames: {
  53424. [key: string]: number;
  53425. };
  53426. /** Should emit comments? */
  53427. emitComments: boolean;
  53428. /** Emit build activity */
  53429. verbose: boolean;
  53430. /** Gets or sets the hosting scene */
  53431. scene: Scene;
  53432. /**
  53433. * Gets the compilation hints emitted at compilation time
  53434. */
  53435. hints: {
  53436. needWorldViewMatrix: boolean;
  53437. needWorldViewProjectionMatrix: boolean;
  53438. needAlphaBlending: boolean;
  53439. needAlphaTesting: boolean;
  53440. };
  53441. /**
  53442. * List of compilation checks
  53443. */
  53444. checks: {
  53445. emitVertex: boolean;
  53446. emitFragment: boolean;
  53447. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53448. };
  53449. /** Creates a new shared data */
  53450. constructor();
  53451. /**
  53452. * Emits console errors and exceptions if there is a failing check
  53453. */
  53454. emitErrors(): void;
  53455. }
  53456. }
  53457. declare module BABYLON {
  53458. /**
  53459. * Class used to store node based material build state
  53460. */
  53461. export class NodeMaterialBuildState {
  53462. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53463. supportUniformBuffers: boolean;
  53464. /**
  53465. * Gets the list of emitted attributes
  53466. */
  53467. attributes: string[];
  53468. /**
  53469. * Gets the list of emitted uniforms
  53470. */
  53471. uniforms: string[];
  53472. /**
  53473. * Gets the list of emitted constants
  53474. */
  53475. constants: string[];
  53476. /**
  53477. * Gets the list of emitted samplers
  53478. */
  53479. samplers: string[];
  53480. /**
  53481. * Gets the list of emitted functions
  53482. */
  53483. functions: {
  53484. [key: string]: string;
  53485. };
  53486. /**
  53487. * Gets the list of emitted extensions
  53488. */
  53489. extensions: {
  53490. [key: string]: string;
  53491. };
  53492. /**
  53493. * Gets the target of the compilation state
  53494. */
  53495. target: NodeMaterialBlockTargets;
  53496. /**
  53497. * Gets the list of emitted counters
  53498. */
  53499. counters: {
  53500. [key: string]: number;
  53501. };
  53502. /**
  53503. * Shared data between multiple NodeMaterialBuildState instances
  53504. */
  53505. sharedData: NodeMaterialBuildStateSharedData;
  53506. /** @hidden */
  53507. _vertexState: NodeMaterialBuildState;
  53508. /** @hidden */
  53509. _attributeDeclaration: string;
  53510. /** @hidden */
  53511. _uniformDeclaration: string;
  53512. /** @hidden */
  53513. _constantDeclaration: string;
  53514. /** @hidden */
  53515. _samplerDeclaration: string;
  53516. /** @hidden */
  53517. _varyingTransfer: string;
  53518. private _repeatableContentAnchorIndex;
  53519. /** @hidden */
  53520. _builtCompilationString: string;
  53521. /**
  53522. * Gets the emitted compilation strings
  53523. */
  53524. compilationString: string;
  53525. /**
  53526. * Finalize the compilation strings
  53527. * @param state defines the current compilation state
  53528. */
  53529. finalize(state: NodeMaterialBuildState): void;
  53530. /** @hidden */
  53531. readonly _repeatableContentAnchor: string;
  53532. /** @hidden */
  53533. _getFreeVariableName(prefix: string): string;
  53534. /** @hidden */
  53535. _getFreeDefineName(prefix: string): string;
  53536. /** @hidden */
  53537. _excludeVariableName(name: string): void;
  53538. /** @hidden */
  53539. _emit2DSampler(name: string): void;
  53540. /** @hidden */
  53541. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53542. /** @hidden */
  53543. _emitExtension(name: string, extension: string): void;
  53544. /** @hidden */
  53545. _emitFunction(name: string, code: string, comments: string): void;
  53546. /** @hidden */
  53547. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53548. replaceStrings?: {
  53549. search: RegExp;
  53550. replace: string;
  53551. }[];
  53552. repeatKey?: string;
  53553. }): string;
  53554. /** @hidden */
  53555. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53556. repeatKey?: string;
  53557. removeAttributes?: boolean;
  53558. removeUniforms?: boolean;
  53559. removeVaryings?: boolean;
  53560. removeIfDef?: boolean;
  53561. replaceStrings?: {
  53562. search: RegExp;
  53563. replace: string;
  53564. }[];
  53565. }, storeKey?: string): void;
  53566. /** @hidden */
  53567. _registerTempVariable(name: string): boolean;
  53568. /** @hidden */
  53569. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53570. /** @hidden */
  53571. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53572. /** @hidden */
  53573. _emitFloat(value: number): string;
  53574. }
  53575. }
  53576. declare module BABYLON {
  53577. /**
  53578. * Defines a block that can be used inside a node based material
  53579. */
  53580. export class NodeMaterialBlock {
  53581. private _buildId;
  53582. private _buildTarget;
  53583. private _target;
  53584. private _isFinalMerger;
  53585. private _isInput;
  53586. /** @hidden */
  53587. _codeVariableName: string;
  53588. /** @hidden */
  53589. _inputs: NodeMaterialConnectionPoint[];
  53590. /** @hidden */
  53591. _outputs: NodeMaterialConnectionPoint[];
  53592. /** @hidden */
  53593. _preparationId: number;
  53594. /**
  53595. * Gets or sets the name of the block
  53596. */
  53597. name: string;
  53598. /**
  53599. * Gets or sets the unique id of the node
  53600. */
  53601. uniqueId: number;
  53602. /**
  53603. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53604. */
  53605. readonly isFinalMerger: boolean;
  53606. /**
  53607. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53608. */
  53609. readonly isInput: boolean;
  53610. /**
  53611. * Gets or sets the build Id
  53612. */
  53613. buildId: number;
  53614. /**
  53615. * Gets or sets the target of the block
  53616. */
  53617. target: NodeMaterialBlockTargets;
  53618. /**
  53619. * Gets the list of input points
  53620. */
  53621. readonly inputs: NodeMaterialConnectionPoint[];
  53622. /** Gets the list of output points */
  53623. readonly outputs: NodeMaterialConnectionPoint[];
  53624. /**
  53625. * Find an input by its name
  53626. * @param name defines the name of the input to look for
  53627. * @returns the input or null if not found
  53628. */
  53629. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53630. /**
  53631. * Find an output by its name
  53632. * @param name defines the name of the outputto look for
  53633. * @returns the output or null if not found
  53634. */
  53635. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53636. /**
  53637. * Creates a new NodeMaterialBlock
  53638. * @param name defines the block name
  53639. * @param target defines the target of that block (Vertex by default)
  53640. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53641. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53642. */
  53643. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53644. /**
  53645. * Initialize the block and prepare the context for build
  53646. * @param state defines the state that will be used for the build
  53647. */
  53648. initialize(state: NodeMaterialBuildState): void;
  53649. /**
  53650. * Bind data to effect. Will only be called for blocks with isBindable === true
  53651. * @param effect defines the effect to bind data to
  53652. * @param nodeMaterial defines the hosting NodeMaterial
  53653. * @param mesh defines the mesh that will be rendered
  53654. */
  53655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53656. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53657. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53658. protected _writeFloat(value: number): string;
  53659. /**
  53660. * Gets the current class name e.g. "NodeMaterialBlock"
  53661. * @returns the class name
  53662. */
  53663. getClassName(): string;
  53664. /**
  53665. * Register a new input. Must be called inside a block constructor
  53666. * @param name defines the connection point name
  53667. * @param type defines the connection point type
  53668. * @param isOptional defines a boolean indicating that this input can be omitted
  53669. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53670. * @returns the current block
  53671. */
  53672. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53673. /**
  53674. * Register a new output. Must be called inside a block constructor
  53675. * @param name defines the connection point name
  53676. * @param type defines the connection point type
  53677. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53678. * @returns the current block
  53679. */
  53680. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53681. /**
  53682. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53683. * @param forOutput defines an optional connection point to check compatibility with
  53684. * @returns the first available input or null
  53685. */
  53686. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53687. /**
  53688. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53689. * @param forBlock defines an optional block to check compatibility with
  53690. * @returns the first available input or null
  53691. */
  53692. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53693. /**
  53694. * Gets the sibling of the given output
  53695. * @param current defines the current output
  53696. * @returns the next output in the list or null
  53697. */
  53698. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53699. /**
  53700. * Connect current block with another block
  53701. * @param other defines the block to connect with
  53702. * @param options define the various options to help pick the right connections
  53703. * @returns the current block
  53704. */
  53705. connectTo(other: NodeMaterialBlock, options?: {
  53706. input?: string;
  53707. output?: string;
  53708. outputSwizzle?: string;
  53709. }): this | undefined;
  53710. protected _buildBlock(state: NodeMaterialBuildState): void;
  53711. /**
  53712. * Add uniforms, samplers and uniform buffers at compilation time
  53713. * @param state defines the state to update
  53714. * @param nodeMaterial defines the node material requesting the update
  53715. * @param defines defines the material defines to update
  53716. * @param uniformBuffers defines the list of uniform buffer names
  53717. */
  53718. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53719. /**
  53720. * Add potential fallbacks if shader compilation fails
  53721. * @param mesh defines the mesh to be rendered
  53722. * @param fallbacks defines the current prioritized list of fallbacks
  53723. */
  53724. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53725. /**
  53726. * Initialize defines for shader compilation
  53727. * @param mesh defines the mesh to be rendered
  53728. * @param nodeMaterial defines the node material requesting the update
  53729. * @param defines defines the material defines to update
  53730. * @param useInstances specifies that instances should be used
  53731. */
  53732. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53733. /**
  53734. * Update defines for shader compilation
  53735. * @param mesh defines the mesh to be rendered
  53736. * @param nodeMaterial defines the node material requesting the update
  53737. * @param defines defines the material defines to update
  53738. * @param useInstances specifies that instances should be used
  53739. */
  53740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53741. /**
  53742. * Lets the block try to connect some inputs automatically
  53743. * @param material defines the hosting NodeMaterial
  53744. */
  53745. autoConfigure(material: NodeMaterial): void;
  53746. /**
  53747. * Function called when a block is declared as repeatable content generator
  53748. * @param vertexShaderState defines the current compilation state for the vertex shader
  53749. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53750. * @param mesh defines the mesh to be rendered
  53751. * @param defines defines the material defines to update
  53752. */
  53753. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53754. /**
  53755. * Checks if the block is ready
  53756. * @param mesh defines the mesh to be rendered
  53757. * @param nodeMaterial defines the node material requesting the update
  53758. * @param defines defines the material defines to update
  53759. * @param useInstances specifies that instances should be used
  53760. * @returns true if the block is ready
  53761. */
  53762. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53763. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53764. private _processBuild;
  53765. /**
  53766. * Compile the current node and generate the shader code
  53767. * @param state defines the current compilation state (uniforms, samplers, current string)
  53768. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53769. * @returns true if already built
  53770. */
  53771. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53772. protected _inputRename(name: string): string;
  53773. protected _outputRename(name: string): string;
  53774. protected _dumpPropertiesCode(): string;
  53775. /** @hidden */
  53776. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53777. /**
  53778. * Clone the current block to a new identical block
  53779. * @param scene defines the hosting scene
  53780. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53781. * @returns a copy of the current block
  53782. */
  53783. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53784. /**
  53785. * Serializes this block in a JSON representation
  53786. * @returns the serialized block object
  53787. */
  53788. serialize(): any;
  53789. /** @hidden */
  53790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Enum defining the type of animations supported by InputBlock
  53796. */
  53797. export enum AnimatedInputBlockTypes {
  53798. /** No animation */
  53799. None = 0,
  53800. /** Time based animation. Will only work for floats */
  53801. Time = 1
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Block used to expose an input value
  53807. */
  53808. export class InputBlock extends NodeMaterialBlock {
  53809. private _mode;
  53810. private _associatedVariableName;
  53811. private _storedValue;
  53812. private _valueCallback;
  53813. private _type;
  53814. private _animationType;
  53815. /** Gets or set a value used to limit the range of float values */
  53816. min: number;
  53817. /** Gets or set a value used to limit the range of float values */
  53818. max: number;
  53819. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53820. matrixMode: number;
  53821. /** @hidden */
  53822. _systemValue: Nullable<NodeMaterialSystemValues>;
  53823. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53824. visibleInInspector: boolean;
  53825. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53826. isConstant: boolean;
  53827. /**
  53828. * Gets or sets the connection point type (default is float)
  53829. */
  53830. readonly type: NodeMaterialBlockConnectionPointTypes;
  53831. /**
  53832. * Creates a new InputBlock
  53833. * @param name defines the block name
  53834. * @param target defines the target of that block (Vertex by default)
  53835. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53836. */
  53837. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53838. /**
  53839. * Gets the output component
  53840. */
  53841. readonly output: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Set the source of this connection point to a vertex attribute
  53844. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53845. * @returns the current connection point
  53846. */
  53847. setAsAttribute(attributeName?: string): InputBlock;
  53848. /**
  53849. * Set the source of this connection point to a system value
  53850. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53851. * @returns the current connection point
  53852. */
  53853. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53854. /**
  53855. * Gets or sets the value of that point.
  53856. * Please note that this value will be ignored if valueCallback is defined
  53857. */
  53858. value: any;
  53859. /**
  53860. * Gets or sets a callback used to get the value of that point.
  53861. * Please note that setting this value will force the connection point to ignore the value property
  53862. */
  53863. valueCallback: () => any;
  53864. /**
  53865. * Gets or sets the associated variable name in the shader
  53866. */
  53867. associatedVariableName: string;
  53868. /** Gets or sets the type of animation applied to the input */
  53869. animationType: AnimatedInputBlockTypes;
  53870. /**
  53871. * Gets a boolean indicating that this connection point not defined yet
  53872. */
  53873. readonly isUndefined: boolean;
  53874. /**
  53875. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53876. * In this case the connection point name must be the name of the uniform to use.
  53877. * Can only be set on inputs
  53878. */
  53879. isUniform: boolean;
  53880. /**
  53881. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53882. * In this case the connection point name must be the name of the attribute to use
  53883. * Can only be set on inputs
  53884. */
  53885. isAttribute: boolean;
  53886. /**
  53887. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53888. * Can only be set on exit points
  53889. */
  53890. isVarying: boolean;
  53891. /**
  53892. * Gets a boolean indicating that the current connection point is a system value
  53893. */
  53894. readonly isSystemValue: boolean;
  53895. /**
  53896. * Gets or sets the current well known value or null if not defined as a system value
  53897. */
  53898. systemValue: Nullable<NodeMaterialSystemValues>;
  53899. /**
  53900. * Gets the current class name
  53901. * @returns the class name
  53902. */
  53903. getClassName(): string;
  53904. /**
  53905. * Animate the input if animationType !== None
  53906. * @param scene defines the rendering scene
  53907. */
  53908. animate(scene: Scene): void;
  53909. private _emitDefine;
  53910. initialize(state: NodeMaterialBuildState): void;
  53911. /**
  53912. * Set the input block to its default value (based on its type)
  53913. */
  53914. setDefaultValue(): void;
  53915. private _emitConstant;
  53916. private _emit;
  53917. /** @hidden */
  53918. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53919. /** @hidden */
  53920. _transmit(effect: Effect, scene: Scene): void;
  53921. protected _buildBlock(state: NodeMaterialBuildState): void;
  53922. protected _dumpPropertiesCode(): string;
  53923. serialize(): any;
  53924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53925. }
  53926. }
  53927. declare module BABYLON {
  53928. /**
  53929. * Defines a connection point for a block
  53930. */
  53931. export class NodeMaterialConnectionPoint {
  53932. /** @hidden */
  53933. _ownerBlock: NodeMaterialBlock;
  53934. /** @hidden */
  53935. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53936. private _endpoints;
  53937. private _associatedVariableName;
  53938. /** @hidden */
  53939. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53940. /** @hidden */
  53941. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53942. private _type;
  53943. /** @hidden */
  53944. _enforceAssociatedVariableName: boolean;
  53945. /**
  53946. * Gets or sets the additional types supported by this connection point
  53947. */
  53948. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53949. /**
  53950. * Gets or sets the additional types excluded by this connection point
  53951. */
  53952. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53953. /**
  53954. * Gets or sets the associated variable name in the shader
  53955. */
  53956. associatedVariableName: string;
  53957. /**
  53958. * Gets or sets the connection point type (default is float)
  53959. */
  53960. type: NodeMaterialBlockConnectionPointTypes;
  53961. /**
  53962. * Gets or sets the connection point name
  53963. */
  53964. name: string;
  53965. /**
  53966. * Gets or sets a boolean indicating that this connection point can be omitted
  53967. */
  53968. isOptional: boolean;
  53969. /**
  53970. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53971. */
  53972. define: string;
  53973. /** @hidden */
  53974. _prioritizeVertex: boolean;
  53975. private _target;
  53976. /** Gets or sets the target of that connection point */
  53977. target: NodeMaterialBlockTargets;
  53978. /**
  53979. * Gets a boolean indicating that the current point is connected
  53980. */
  53981. readonly isConnected: boolean;
  53982. /**
  53983. * Gets a boolean indicating that the current point is connected to an input block
  53984. */
  53985. readonly isConnectedToInputBlock: boolean;
  53986. /**
  53987. * Gets a the connected input block (if any)
  53988. */
  53989. readonly connectInputBlock: Nullable<InputBlock>;
  53990. /** Get the other side of the connection (if any) */
  53991. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53992. /** Get the block that owns this connection point */
  53993. readonly ownerBlock: NodeMaterialBlock;
  53994. /** Get the block connected on the other side of this connection (if any) */
  53995. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53996. /** Get the block connected on the endpoints of this connection (if any) */
  53997. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53998. /** Gets the list of connected endpoints */
  53999. readonly endpoints: NodeMaterialConnectionPoint[];
  54000. /** Gets a boolean indicating if that output point is connected to at least one input */
  54001. readonly hasEndpoints: boolean;
  54002. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54003. readonly isConnectedInVertexShader: boolean;
  54004. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54005. readonly isConnectedInFragmentShader: boolean;
  54006. /**
  54007. * Creates a new connection point
  54008. * @param name defines the connection point name
  54009. * @param ownerBlock defines the block hosting this connection point
  54010. */
  54011. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54012. /**
  54013. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54014. * @returns the class name
  54015. */
  54016. getClassName(): string;
  54017. /**
  54018. * Gets an boolean indicating if the current point can be connected to another point
  54019. * @param connectionPoint defines the other connection point
  54020. * @returns true if the connection is possible
  54021. */
  54022. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54023. /**
  54024. * Connect this point to another connection point
  54025. * @param connectionPoint defines the other connection point
  54026. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54027. * @returns the current connection point
  54028. */
  54029. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54030. /**
  54031. * Disconnect this point from one of his endpoint
  54032. * @param endpoint defines the other connection point
  54033. * @returns the current connection point
  54034. */
  54035. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54036. /**
  54037. * Serializes this point in a JSON representation
  54038. * @returns the serialized point object
  54039. */
  54040. serialize(): any;
  54041. }
  54042. }
  54043. declare module BABYLON {
  54044. /**
  54045. * Block used to add support for vertex skinning (bones)
  54046. */
  54047. export class BonesBlock extends NodeMaterialBlock {
  54048. /**
  54049. * Creates a new BonesBlock
  54050. * @param name defines the block name
  54051. */
  54052. constructor(name: string);
  54053. /**
  54054. * Initialize the block and prepare the context for build
  54055. * @param state defines the state that will be used for the build
  54056. */
  54057. initialize(state: NodeMaterialBuildState): void;
  54058. /**
  54059. * Gets the current class name
  54060. * @returns the class name
  54061. */
  54062. getClassName(): string;
  54063. /**
  54064. * Gets the matrix indices input component
  54065. */
  54066. readonly matricesIndices: NodeMaterialConnectionPoint;
  54067. /**
  54068. * Gets the matrix weights input component
  54069. */
  54070. readonly matricesWeights: NodeMaterialConnectionPoint;
  54071. /**
  54072. * Gets the extra matrix indices input component
  54073. */
  54074. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54075. /**
  54076. * Gets the extra matrix weights input component
  54077. */
  54078. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54079. /**
  54080. * Gets the world input component
  54081. */
  54082. readonly world: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Gets the output component
  54085. */
  54086. readonly output: NodeMaterialConnectionPoint;
  54087. autoConfigure(material: NodeMaterial): void;
  54088. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54091. protected _buildBlock(state: NodeMaterialBuildState): this;
  54092. }
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * Block used to add support for instances
  54097. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54098. */
  54099. export class InstancesBlock extends NodeMaterialBlock {
  54100. /**
  54101. * Creates a new InstancesBlock
  54102. * @param name defines the block name
  54103. */
  54104. constructor(name: string);
  54105. /**
  54106. * Gets the current class name
  54107. * @returns the class name
  54108. */
  54109. getClassName(): string;
  54110. /**
  54111. * Gets the first world row input component
  54112. */
  54113. readonly world0: NodeMaterialConnectionPoint;
  54114. /**
  54115. * Gets the second world row input component
  54116. */
  54117. readonly world1: NodeMaterialConnectionPoint;
  54118. /**
  54119. * Gets the third world row input component
  54120. */
  54121. readonly world2: NodeMaterialConnectionPoint;
  54122. /**
  54123. * Gets the forth world row input component
  54124. */
  54125. readonly world3: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the world input component
  54128. */
  54129. readonly world: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the output component
  54132. */
  54133. readonly output: NodeMaterialConnectionPoint;
  54134. autoConfigure(material: NodeMaterial): void;
  54135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54136. protected _buildBlock(state: NodeMaterialBuildState): this;
  54137. }
  54138. }
  54139. declare module BABYLON {
  54140. /**
  54141. * Block used to add morph targets support to vertex shader
  54142. */
  54143. export class MorphTargetsBlock extends NodeMaterialBlock {
  54144. private _repeatableContentAnchor;
  54145. private _repeatebleContentGenerated;
  54146. /**
  54147. * Create a new MorphTargetsBlock
  54148. * @param name defines the block name
  54149. */
  54150. constructor(name: string);
  54151. /**
  54152. * Gets the current class name
  54153. * @returns the class name
  54154. */
  54155. getClassName(): string;
  54156. /**
  54157. * Gets the position input component
  54158. */
  54159. readonly position: NodeMaterialConnectionPoint;
  54160. /**
  54161. * Gets the normal input component
  54162. */
  54163. readonly normal: NodeMaterialConnectionPoint;
  54164. /**
  54165. * Gets the tangent input component
  54166. */
  54167. readonly tangent: NodeMaterialConnectionPoint;
  54168. /**
  54169. * Gets the tangent input component
  54170. */
  54171. readonly uv: NodeMaterialConnectionPoint;
  54172. /**
  54173. * Gets the position output component
  54174. */
  54175. readonly positionOutput: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the normal output component
  54178. */
  54179. readonly normalOutput: NodeMaterialConnectionPoint;
  54180. /**
  54181. * Gets the tangent output component
  54182. */
  54183. readonly tangentOutput: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the tangent output component
  54186. */
  54187. readonly uvOutput: NodeMaterialConnectionPoint;
  54188. initialize(state: NodeMaterialBuildState): void;
  54189. autoConfigure(material: NodeMaterial): void;
  54190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54192. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54193. protected _buildBlock(state: NodeMaterialBuildState): this;
  54194. }
  54195. }
  54196. declare module BABYLON {
  54197. /**
  54198. * Block used to get data information from a light
  54199. */
  54200. export class LightInformationBlock extends NodeMaterialBlock {
  54201. private _lightDataUniformName;
  54202. private _lightColorUniformName;
  54203. private _lightTypeDefineName;
  54204. /**
  54205. * Gets or sets the light associated with this block
  54206. */
  54207. light: Nullable<Light>;
  54208. /**
  54209. * Creates a new LightInformationBlock
  54210. * @param name defines the block name
  54211. */
  54212. constructor(name: string);
  54213. /**
  54214. * Gets the current class name
  54215. * @returns the class name
  54216. */
  54217. getClassName(): string;
  54218. /**
  54219. * Gets the world position input component
  54220. */
  54221. readonly worldPosition: NodeMaterialConnectionPoint;
  54222. /**
  54223. * Gets the direction output component
  54224. */
  54225. readonly direction: NodeMaterialConnectionPoint;
  54226. /**
  54227. * Gets the direction output component
  54228. */
  54229. readonly color: NodeMaterialConnectionPoint;
  54230. /**
  54231. * Gets the direction output component
  54232. */
  54233. readonly intensity: NodeMaterialConnectionPoint;
  54234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54236. protected _buildBlock(state: NodeMaterialBuildState): this;
  54237. serialize(): any;
  54238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54239. }
  54240. }
  54241. declare module BABYLON {
  54242. /**
  54243. * Block used to add image processing support to fragment shader
  54244. */
  54245. export class ImageProcessingBlock extends NodeMaterialBlock {
  54246. /**
  54247. * Create a new ImageProcessingBlock
  54248. * @param name defines the block name
  54249. */
  54250. constructor(name: string);
  54251. /**
  54252. * Gets the current class name
  54253. * @returns the class name
  54254. */
  54255. getClassName(): string;
  54256. /**
  54257. * Gets the color input component
  54258. */
  54259. readonly color: NodeMaterialConnectionPoint;
  54260. /**
  54261. * Gets the output component
  54262. */
  54263. readonly output: NodeMaterialConnectionPoint;
  54264. /**
  54265. * Initialize the block and prepare the context for build
  54266. * @param state defines the state that will be used for the build
  54267. */
  54268. initialize(state: NodeMaterialBuildState): void;
  54269. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54271. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54272. protected _buildBlock(state: NodeMaterialBuildState): this;
  54273. }
  54274. }
  54275. declare module BABYLON {
  54276. /**
  54277. * Block used to pertub normals based on a normal map
  54278. */
  54279. export class PerturbNormalBlock extends NodeMaterialBlock {
  54280. private _tangentSpaceParameterName;
  54281. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54282. invertX: boolean;
  54283. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54284. invertY: boolean;
  54285. /**
  54286. * Create a new PerturbNormalBlock
  54287. * @param name defines the block name
  54288. */
  54289. constructor(name: string);
  54290. /**
  54291. * Gets the current class name
  54292. * @returns the class name
  54293. */
  54294. getClassName(): string;
  54295. /**
  54296. * Gets the world position input component
  54297. */
  54298. readonly worldPosition: NodeMaterialConnectionPoint;
  54299. /**
  54300. * Gets the world normal input component
  54301. */
  54302. readonly worldNormal: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the uv input component
  54305. */
  54306. readonly uv: NodeMaterialConnectionPoint;
  54307. /**
  54308. * Gets the normal map color input component
  54309. */
  54310. readonly normalMapColor: NodeMaterialConnectionPoint;
  54311. /**
  54312. * Gets the strength input component
  54313. */
  54314. readonly strength: NodeMaterialConnectionPoint;
  54315. /**
  54316. * Gets the output component
  54317. */
  54318. readonly output: NodeMaterialConnectionPoint;
  54319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54321. autoConfigure(material: NodeMaterial): void;
  54322. protected _buildBlock(state: NodeMaterialBuildState): this;
  54323. protected _dumpPropertiesCode(): string;
  54324. serialize(): any;
  54325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54326. }
  54327. }
  54328. declare module BABYLON {
  54329. /**
  54330. * Block used to discard a pixel if a value is smaller than a cutoff
  54331. */
  54332. export class DiscardBlock extends NodeMaterialBlock {
  54333. /**
  54334. * Create a new DiscardBlock
  54335. * @param name defines the block name
  54336. */
  54337. constructor(name: string);
  54338. /**
  54339. * Gets the current class name
  54340. * @returns the class name
  54341. */
  54342. getClassName(): string;
  54343. /**
  54344. * Gets the color input component
  54345. */
  54346. readonly value: NodeMaterialConnectionPoint;
  54347. /**
  54348. * Gets the cutoff input component
  54349. */
  54350. readonly cutoff: NodeMaterialConnectionPoint;
  54351. protected _buildBlock(state: NodeMaterialBuildState): this;
  54352. }
  54353. }
  54354. declare module BABYLON {
  54355. /**
  54356. * Block used to add support for scene fog
  54357. */
  54358. export class FogBlock extends NodeMaterialBlock {
  54359. private _fogDistanceName;
  54360. private _fogParameters;
  54361. /**
  54362. * Create a new FogBlock
  54363. * @param name defines the block name
  54364. */
  54365. constructor(name: string);
  54366. /**
  54367. * Gets the current class name
  54368. * @returns the class name
  54369. */
  54370. getClassName(): string;
  54371. /**
  54372. * Gets the world position input component
  54373. */
  54374. readonly worldPosition: NodeMaterialConnectionPoint;
  54375. /**
  54376. * Gets the view input component
  54377. */
  54378. readonly view: NodeMaterialConnectionPoint;
  54379. /**
  54380. * Gets the color input component
  54381. */
  54382. readonly input: NodeMaterialConnectionPoint;
  54383. /**
  54384. * Gets the fog color input component
  54385. */
  54386. readonly fogColor: NodeMaterialConnectionPoint;
  54387. /**
  54388. * Gets the output component
  54389. */
  54390. readonly output: NodeMaterialConnectionPoint;
  54391. autoConfigure(material: NodeMaterial): void;
  54392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54394. protected _buildBlock(state: NodeMaterialBuildState): this;
  54395. }
  54396. }
  54397. declare module BABYLON {
  54398. /**
  54399. * Block used to add light in the fragment shader
  54400. */
  54401. export class LightBlock extends NodeMaterialBlock {
  54402. private _lightId;
  54403. /**
  54404. * Gets or sets the light associated with this block
  54405. */
  54406. light: Nullable<Light>;
  54407. /**
  54408. * Create a new LightBlock
  54409. * @param name defines the block name
  54410. */
  54411. constructor(name: string);
  54412. /**
  54413. * Gets the current class name
  54414. * @returns the class name
  54415. */
  54416. getClassName(): string;
  54417. /**
  54418. * Gets the world position input component
  54419. */
  54420. readonly worldPosition: NodeMaterialConnectionPoint;
  54421. /**
  54422. * Gets the world normal input component
  54423. */
  54424. readonly worldNormal: NodeMaterialConnectionPoint;
  54425. /**
  54426. * Gets the camera (or eye) position component
  54427. */
  54428. readonly cameraPosition: NodeMaterialConnectionPoint;
  54429. /**
  54430. * Gets the glossiness component
  54431. */
  54432. readonly glossiness: NodeMaterialConnectionPoint;
  54433. /**
  54434. * Gets the glossinness power component
  54435. */
  54436. readonly glossPower: NodeMaterialConnectionPoint;
  54437. /**
  54438. * Gets the diffuse color component
  54439. */
  54440. readonly diffuseColor: NodeMaterialConnectionPoint;
  54441. /**
  54442. * Gets the specular color component
  54443. */
  54444. readonly specularColor: NodeMaterialConnectionPoint;
  54445. /**
  54446. * Gets the diffuse output component
  54447. */
  54448. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54449. /**
  54450. * Gets the specular output component
  54451. */
  54452. readonly specularOutput: NodeMaterialConnectionPoint;
  54453. autoConfigure(material: NodeMaterial): void;
  54454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54455. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54456. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54457. private _injectVertexCode;
  54458. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54459. serialize(): any;
  54460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54461. }
  54462. }
  54463. declare module BABYLON {
  54464. /**
  54465. * Block used to multiply 2 values
  54466. */
  54467. export class MultiplyBlock extends NodeMaterialBlock {
  54468. /**
  54469. * Creates a new MultiplyBlock
  54470. * @param name defines the block name
  54471. */
  54472. constructor(name: string);
  54473. /**
  54474. * Gets the current class name
  54475. * @returns the class name
  54476. */
  54477. getClassName(): string;
  54478. /**
  54479. * Gets the left operand input component
  54480. */
  54481. readonly left: NodeMaterialConnectionPoint;
  54482. /**
  54483. * Gets the right operand input component
  54484. */
  54485. readonly right: NodeMaterialConnectionPoint;
  54486. /**
  54487. * Gets the output component
  54488. */
  54489. readonly output: NodeMaterialConnectionPoint;
  54490. protected _buildBlock(state: NodeMaterialBuildState): this;
  54491. }
  54492. }
  54493. declare module BABYLON {
  54494. /**
  54495. * Block used to add 2 vectors
  54496. */
  54497. export class AddBlock extends NodeMaterialBlock {
  54498. /**
  54499. * Creates a new AddBlock
  54500. * @param name defines the block name
  54501. */
  54502. constructor(name: string);
  54503. /**
  54504. * Gets the current class name
  54505. * @returns the class name
  54506. */
  54507. getClassName(): string;
  54508. /**
  54509. * Gets the left operand input component
  54510. */
  54511. readonly left: NodeMaterialConnectionPoint;
  54512. /**
  54513. * Gets the right operand input component
  54514. */
  54515. readonly right: NodeMaterialConnectionPoint;
  54516. /**
  54517. * Gets the output component
  54518. */
  54519. readonly output: NodeMaterialConnectionPoint;
  54520. protected _buildBlock(state: NodeMaterialBuildState): this;
  54521. }
  54522. }
  54523. declare module BABYLON {
  54524. /**
  54525. * Block used to scale a vector by a float
  54526. */
  54527. export class ScaleBlock extends NodeMaterialBlock {
  54528. /**
  54529. * Creates a new ScaleBlock
  54530. * @param name defines the block name
  54531. */
  54532. constructor(name: string);
  54533. /**
  54534. * Gets the current class name
  54535. * @returns the class name
  54536. */
  54537. getClassName(): string;
  54538. /**
  54539. * Gets the input component
  54540. */
  54541. readonly input: NodeMaterialConnectionPoint;
  54542. /**
  54543. * Gets the factor input component
  54544. */
  54545. readonly factor: NodeMaterialConnectionPoint;
  54546. /**
  54547. * Gets the output component
  54548. */
  54549. readonly output: NodeMaterialConnectionPoint;
  54550. protected _buildBlock(state: NodeMaterialBuildState): this;
  54551. }
  54552. }
  54553. declare module BABYLON {
  54554. /**
  54555. * Block used to clamp a float
  54556. */
  54557. export class ClampBlock extends NodeMaterialBlock {
  54558. /** Gets or sets the minimum range */
  54559. minimum: number;
  54560. /** Gets or sets the maximum range */
  54561. maximum: number;
  54562. /**
  54563. * Creates a new ClampBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the value input component
  54574. */
  54575. readonly value: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the output component
  54578. */
  54579. readonly output: NodeMaterialConnectionPoint;
  54580. protected _buildBlock(state: NodeMaterialBuildState): this;
  54581. protected _dumpPropertiesCode(): string;
  54582. serialize(): any;
  54583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54584. }
  54585. }
  54586. declare module BABYLON {
  54587. /**
  54588. * Block used to apply a cross product between 2 vectors
  54589. */
  54590. export class CrossBlock extends NodeMaterialBlock {
  54591. /**
  54592. * Creates a new CrossBlock
  54593. * @param name defines the block name
  54594. */
  54595. constructor(name: string);
  54596. /**
  54597. * Gets the current class name
  54598. * @returns the class name
  54599. */
  54600. getClassName(): string;
  54601. /**
  54602. * Gets the left operand input component
  54603. */
  54604. readonly left: NodeMaterialConnectionPoint;
  54605. /**
  54606. * Gets the right operand input component
  54607. */
  54608. readonly right: NodeMaterialConnectionPoint;
  54609. /**
  54610. * Gets the output component
  54611. */
  54612. readonly output: NodeMaterialConnectionPoint;
  54613. protected _buildBlock(state: NodeMaterialBuildState): this;
  54614. }
  54615. }
  54616. declare module BABYLON {
  54617. /**
  54618. * Block used to apply a dot product between 2 vectors
  54619. */
  54620. export class DotBlock extends NodeMaterialBlock {
  54621. /**
  54622. * Creates a new DotBlock
  54623. * @param name defines the block name
  54624. */
  54625. constructor(name: string);
  54626. /**
  54627. * Gets the current class name
  54628. * @returns the class name
  54629. */
  54630. getClassName(): string;
  54631. /**
  54632. * Gets the left operand input component
  54633. */
  54634. readonly left: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the right operand input component
  54637. */
  54638. readonly right: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the output component
  54641. */
  54642. readonly output: NodeMaterialConnectionPoint;
  54643. protected _buildBlock(state: NodeMaterialBuildState): this;
  54644. }
  54645. }
  54646. declare module BABYLON {
  54647. /**
  54648. * Block used to remap a float from a range to a new one
  54649. */
  54650. export class RemapBlock extends NodeMaterialBlock {
  54651. /**
  54652. * Gets or sets the source range
  54653. */
  54654. sourceRange: Vector2;
  54655. /**
  54656. * Gets or sets the target range
  54657. */
  54658. targetRange: Vector2;
  54659. /**
  54660. * Creates a new RemapBlock
  54661. * @param name defines the block name
  54662. */
  54663. constructor(name: string);
  54664. /**
  54665. * Gets the current class name
  54666. * @returns the class name
  54667. */
  54668. getClassName(): string;
  54669. /**
  54670. * Gets the input component
  54671. */
  54672. readonly input: NodeMaterialConnectionPoint;
  54673. /**
  54674. * Gets the source min input component
  54675. */
  54676. readonly sourceMin: NodeMaterialConnectionPoint;
  54677. /**
  54678. * Gets the source max input component
  54679. */
  54680. readonly sourceMax: NodeMaterialConnectionPoint;
  54681. /**
  54682. * Gets the target min input component
  54683. */
  54684. readonly targetMin: NodeMaterialConnectionPoint;
  54685. /**
  54686. * Gets the target max input component
  54687. */
  54688. readonly targetMax: NodeMaterialConnectionPoint;
  54689. /**
  54690. * Gets the output component
  54691. */
  54692. readonly output: NodeMaterialConnectionPoint;
  54693. protected _buildBlock(state: NodeMaterialBuildState): this;
  54694. protected _dumpPropertiesCode(): string;
  54695. serialize(): any;
  54696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54697. }
  54698. }
  54699. declare module BABYLON {
  54700. /**
  54701. * Block used to normalize a vector
  54702. */
  54703. export class NormalizeBlock extends NodeMaterialBlock {
  54704. /**
  54705. * Creates a new NormalizeBlock
  54706. * @param name defines the block name
  54707. */
  54708. constructor(name: string);
  54709. /**
  54710. * Gets the current class name
  54711. * @returns the class name
  54712. */
  54713. getClassName(): string;
  54714. /**
  54715. * Gets the input component
  54716. */
  54717. readonly input: NodeMaterialConnectionPoint;
  54718. /**
  54719. * Gets the output component
  54720. */
  54721. readonly output: NodeMaterialConnectionPoint;
  54722. protected _buildBlock(state: NodeMaterialBuildState): this;
  54723. }
  54724. }
  54725. declare module BABYLON {
  54726. /**
  54727. * Operations supported by the Trigonometry block
  54728. */
  54729. export enum TrigonometryBlockOperations {
  54730. /** Cos */
  54731. Cos = 0,
  54732. /** Sin */
  54733. Sin = 1,
  54734. /** Abs */
  54735. Abs = 2,
  54736. /** Exp */
  54737. Exp = 3,
  54738. /** Exp2 */
  54739. Exp2 = 4,
  54740. /** Round */
  54741. Round = 5,
  54742. /** Floor */
  54743. Floor = 6,
  54744. /** Ceiling */
  54745. Ceiling = 7,
  54746. /** Square root */
  54747. Sqrt = 8,
  54748. /** Log */
  54749. Log = 9,
  54750. /** Tangent */
  54751. Tan = 10,
  54752. /** Arc tangent */
  54753. ArcTan = 11,
  54754. /** Arc cosinus */
  54755. ArcCos = 12,
  54756. /** Arc sinus */
  54757. ArcSin = 13,
  54758. /** Fraction */
  54759. Fract = 14,
  54760. /** Sign */
  54761. Sign = 15,
  54762. /** To radians (from degrees) */
  54763. Radians = 16,
  54764. /** To degrees (from radians) */
  54765. Degrees = 17
  54766. }
  54767. /**
  54768. * Block used to apply trigonometry operation to floats
  54769. */
  54770. export class TrigonometryBlock extends NodeMaterialBlock {
  54771. /**
  54772. * Gets or sets the operation applied by the block
  54773. */
  54774. operation: TrigonometryBlockOperations;
  54775. /**
  54776. * Creates a new TrigonometryBlock
  54777. * @param name defines the block name
  54778. */
  54779. constructor(name: string);
  54780. /**
  54781. * Gets the current class name
  54782. * @returns the class name
  54783. */
  54784. getClassName(): string;
  54785. /**
  54786. * Gets the input component
  54787. */
  54788. readonly input: NodeMaterialConnectionPoint;
  54789. /**
  54790. * Gets the output component
  54791. */
  54792. readonly output: NodeMaterialConnectionPoint;
  54793. protected _buildBlock(state: NodeMaterialBuildState): this;
  54794. serialize(): any;
  54795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54796. }
  54797. }
  54798. declare module BABYLON {
  54799. /**
  54800. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54801. */
  54802. export class ColorMergerBlock extends NodeMaterialBlock {
  54803. /**
  54804. * Create a new ColorMergerBlock
  54805. * @param name defines the block name
  54806. */
  54807. constructor(name: string);
  54808. /**
  54809. * Gets the current class name
  54810. * @returns the class name
  54811. */
  54812. getClassName(): string;
  54813. /**
  54814. * Gets the r component (input)
  54815. */
  54816. readonly r: NodeMaterialConnectionPoint;
  54817. /**
  54818. * Gets the g component (input)
  54819. */
  54820. readonly g: NodeMaterialConnectionPoint;
  54821. /**
  54822. * Gets the b component (input)
  54823. */
  54824. readonly b: NodeMaterialConnectionPoint;
  54825. /**
  54826. * Gets the a component (input)
  54827. */
  54828. readonly a: NodeMaterialConnectionPoint;
  54829. /**
  54830. * Gets the rgba component (output)
  54831. */
  54832. readonly rgba: NodeMaterialConnectionPoint;
  54833. /**
  54834. * Gets the rgb component (output)
  54835. */
  54836. readonly rgb: NodeMaterialConnectionPoint;
  54837. protected _buildBlock(state: NodeMaterialBuildState): this;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54843. */
  54844. export class VectorMergerBlock extends NodeMaterialBlock {
  54845. /**
  54846. * Create a new VectorMergerBlock
  54847. * @param name defines the block name
  54848. */
  54849. constructor(name: string);
  54850. /**
  54851. * Gets the current class name
  54852. * @returns the class name
  54853. */
  54854. getClassName(): string;
  54855. /**
  54856. * Gets the x component (input)
  54857. */
  54858. readonly x: NodeMaterialConnectionPoint;
  54859. /**
  54860. * Gets the y component (input)
  54861. */
  54862. readonly y: NodeMaterialConnectionPoint;
  54863. /**
  54864. * Gets the z component (input)
  54865. */
  54866. readonly z: NodeMaterialConnectionPoint;
  54867. /**
  54868. * Gets the w component (input)
  54869. */
  54870. readonly w: NodeMaterialConnectionPoint;
  54871. /**
  54872. * Gets the xyzw component (output)
  54873. */
  54874. readonly xyzw: NodeMaterialConnectionPoint;
  54875. /**
  54876. * Gets the xyz component (output)
  54877. */
  54878. readonly xyz: NodeMaterialConnectionPoint;
  54879. /**
  54880. * Gets the xy component (output)
  54881. */
  54882. readonly xy: NodeMaterialConnectionPoint;
  54883. protected _buildBlock(state: NodeMaterialBuildState): this;
  54884. }
  54885. }
  54886. declare module BABYLON {
  54887. /**
  54888. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54889. */
  54890. export class ColorSplitterBlock extends NodeMaterialBlock {
  54891. /**
  54892. * Create a new ColorSplitterBlock
  54893. * @param name defines the block name
  54894. */
  54895. constructor(name: string);
  54896. /**
  54897. * Gets the current class name
  54898. * @returns the class name
  54899. */
  54900. getClassName(): string;
  54901. /**
  54902. * Gets the rgba component (input)
  54903. */
  54904. readonly rgba: NodeMaterialConnectionPoint;
  54905. /**
  54906. * Gets the rgb component (input)
  54907. */
  54908. readonly rgbIn: NodeMaterialConnectionPoint;
  54909. /**
  54910. * Gets the rgb component (output)
  54911. */
  54912. readonly rgbOut: NodeMaterialConnectionPoint;
  54913. /**
  54914. * Gets the r component (output)
  54915. */
  54916. readonly r: NodeMaterialConnectionPoint;
  54917. /**
  54918. * Gets the g component (output)
  54919. */
  54920. readonly g: NodeMaterialConnectionPoint;
  54921. /**
  54922. * Gets the b component (output)
  54923. */
  54924. readonly b: NodeMaterialConnectionPoint;
  54925. /**
  54926. * Gets the a component (output)
  54927. */
  54928. readonly a: NodeMaterialConnectionPoint;
  54929. protected _inputRename(name: string): string;
  54930. protected _outputRename(name: string): string;
  54931. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54932. }
  54933. }
  54934. declare module BABYLON {
  54935. /**
  54936. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54937. */
  54938. export class VectorSplitterBlock extends NodeMaterialBlock {
  54939. /**
  54940. * Create a new VectorSplitterBlock
  54941. * @param name defines the block name
  54942. */
  54943. constructor(name: string);
  54944. /**
  54945. * Gets the current class name
  54946. * @returns the class name
  54947. */
  54948. getClassName(): string;
  54949. /**
  54950. * Gets the xyzw component (input)
  54951. */
  54952. readonly xyzw: NodeMaterialConnectionPoint;
  54953. /**
  54954. * Gets the xyz component (input)
  54955. */
  54956. readonly xyzIn: NodeMaterialConnectionPoint;
  54957. /**
  54958. * Gets the xy component (input)
  54959. */
  54960. readonly xyIn: NodeMaterialConnectionPoint;
  54961. /**
  54962. * Gets the xyz component (output)
  54963. */
  54964. readonly xyzOut: NodeMaterialConnectionPoint;
  54965. /**
  54966. * Gets the xy component (output)
  54967. */
  54968. readonly xyOut: NodeMaterialConnectionPoint;
  54969. /**
  54970. * Gets the x component (output)
  54971. */
  54972. readonly x: NodeMaterialConnectionPoint;
  54973. /**
  54974. * Gets the y component (output)
  54975. */
  54976. readonly y: NodeMaterialConnectionPoint;
  54977. /**
  54978. * Gets the z component (output)
  54979. */
  54980. readonly z: NodeMaterialConnectionPoint;
  54981. /**
  54982. * Gets the w component (output)
  54983. */
  54984. readonly w: NodeMaterialConnectionPoint;
  54985. protected _inputRename(name: string): string;
  54986. protected _outputRename(name: string): string;
  54987. protected _buildBlock(state: NodeMaterialBuildState): this;
  54988. }
  54989. }
  54990. declare module BABYLON {
  54991. /**
  54992. * Block used to lerp between 2 values
  54993. */
  54994. export class LerpBlock extends NodeMaterialBlock {
  54995. /**
  54996. * Creates a new LerpBlock
  54997. * @param name defines the block name
  54998. */
  54999. constructor(name: string);
  55000. /**
  55001. * Gets the current class name
  55002. * @returns the class name
  55003. */
  55004. getClassName(): string;
  55005. /**
  55006. * Gets the left operand input component
  55007. */
  55008. readonly left: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Gets the right operand input component
  55011. */
  55012. readonly right: NodeMaterialConnectionPoint;
  55013. /**
  55014. * Gets the gradient operand input component
  55015. */
  55016. readonly gradient: NodeMaterialConnectionPoint;
  55017. /**
  55018. * Gets the output component
  55019. */
  55020. readonly output: NodeMaterialConnectionPoint;
  55021. protected _buildBlock(state: NodeMaterialBuildState): this;
  55022. }
  55023. }
  55024. declare module BABYLON {
  55025. /**
  55026. * Block used to divide 2 vectors
  55027. */
  55028. export class DivideBlock extends NodeMaterialBlock {
  55029. /**
  55030. * Creates a new DivideBlock
  55031. * @param name defines the block name
  55032. */
  55033. constructor(name: string);
  55034. /**
  55035. * Gets the current class name
  55036. * @returns the class name
  55037. */
  55038. getClassName(): string;
  55039. /**
  55040. * Gets the left operand input component
  55041. */
  55042. readonly left: NodeMaterialConnectionPoint;
  55043. /**
  55044. * Gets the right operand input component
  55045. */
  55046. readonly right: NodeMaterialConnectionPoint;
  55047. /**
  55048. * Gets the output component
  55049. */
  55050. readonly output: NodeMaterialConnectionPoint;
  55051. protected _buildBlock(state: NodeMaterialBuildState): this;
  55052. }
  55053. }
  55054. declare module BABYLON {
  55055. /**
  55056. * Block used to subtract 2 vectors
  55057. */
  55058. export class SubtractBlock extends NodeMaterialBlock {
  55059. /**
  55060. * Creates a new SubtractBlock
  55061. * @param name defines the block name
  55062. */
  55063. constructor(name: string);
  55064. /**
  55065. * Gets the current class name
  55066. * @returns the class name
  55067. */
  55068. getClassName(): string;
  55069. /**
  55070. * Gets the left operand input component
  55071. */
  55072. readonly left: NodeMaterialConnectionPoint;
  55073. /**
  55074. * Gets the right operand input component
  55075. */
  55076. readonly right: NodeMaterialConnectionPoint;
  55077. /**
  55078. * Gets the output component
  55079. */
  55080. readonly output: NodeMaterialConnectionPoint;
  55081. protected _buildBlock(state: NodeMaterialBuildState): this;
  55082. }
  55083. }
  55084. declare module BABYLON {
  55085. /**
  55086. * Block used to step a value
  55087. */
  55088. export class StepBlock extends NodeMaterialBlock {
  55089. /**
  55090. * Creates a new StepBlock
  55091. * @param name defines the block name
  55092. */
  55093. constructor(name: string);
  55094. /**
  55095. * Gets the current class name
  55096. * @returns the class name
  55097. */
  55098. getClassName(): string;
  55099. /**
  55100. * Gets the value operand input component
  55101. */
  55102. readonly value: NodeMaterialConnectionPoint;
  55103. /**
  55104. * Gets the edge operand input component
  55105. */
  55106. readonly edge: NodeMaterialConnectionPoint;
  55107. /**
  55108. * Gets the output component
  55109. */
  55110. readonly output: NodeMaterialConnectionPoint;
  55111. protected _buildBlock(state: NodeMaterialBuildState): this;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Block used to get the opposite (1 - x) of a value
  55117. */
  55118. export class OneMinusBlock extends NodeMaterialBlock {
  55119. /**
  55120. * Creates a new OneMinusBlock
  55121. * @param name defines the block name
  55122. */
  55123. constructor(name: string);
  55124. /**
  55125. * Gets the current class name
  55126. * @returns the class name
  55127. */
  55128. getClassName(): string;
  55129. /**
  55130. * Gets the input component
  55131. */
  55132. readonly input: NodeMaterialConnectionPoint;
  55133. /**
  55134. * Gets the output component
  55135. */
  55136. readonly output: NodeMaterialConnectionPoint;
  55137. protected _buildBlock(state: NodeMaterialBuildState): this;
  55138. }
  55139. }
  55140. declare module BABYLON {
  55141. /**
  55142. * Block used to get the view direction
  55143. */
  55144. export class ViewDirectionBlock extends NodeMaterialBlock {
  55145. /**
  55146. * Creates a new ViewDirectionBlock
  55147. * @param name defines the block name
  55148. */
  55149. constructor(name: string);
  55150. /**
  55151. * Gets the current class name
  55152. * @returns the class name
  55153. */
  55154. getClassName(): string;
  55155. /**
  55156. * Gets the world position component
  55157. */
  55158. readonly worldPosition: NodeMaterialConnectionPoint;
  55159. /**
  55160. * Gets the camera position component
  55161. */
  55162. readonly cameraPosition: NodeMaterialConnectionPoint;
  55163. /**
  55164. * Gets the output component
  55165. */
  55166. readonly output: NodeMaterialConnectionPoint;
  55167. autoConfigure(material: NodeMaterial): void;
  55168. protected _buildBlock(state: NodeMaterialBuildState): this;
  55169. }
  55170. }
  55171. declare module BABYLON {
  55172. /**
  55173. * Block used to compute fresnel value
  55174. */
  55175. export class FresnelBlock extends NodeMaterialBlock {
  55176. /**
  55177. * Create a new FresnelBlock
  55178. * @param name defines the block name
  55179. */
  55180. constructor(name: string);
  55181. /**
  55182. * Gets the current class name
  55183. * @returns the class name
  55184. */
  55185. getClassName(): string;
  55186. /**
  55187. * Gets the world normal input component
  55188. */
  55189. readonly worldNormal: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the view direction input component
  55192. */
  55193. readonly viewDirection: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the bias input component
  55196. */
  55197. readonly bias: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the camera (or eye) position component
  55200. */
  55201. readonly power: NodeMaterialConnectionPoint;
  55202. /**
  55203. * Gets the fresnel output component
  55204. */
  55205. readonly fresnel: NodeMaterialConnectionPoint;
  55206. autoConfigure(material: NodeMaterial): void;
  55207. protected _buildBlock(state: NodeMaterialBuildState): this;
  55208. }
  55209. }
  55210. declare module BABYLON {
  55211. /**
  55212. * Block used to get the max of 2 values
  55213. */
  55214. export class MaxBlock extends NodeMaterialBlock {
  55215. /**
  55216. * Creates a new MaxBlock
  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 left operand input component
  55227. */
  55228. readonly left: NodeMaterialConnectionPoint;
  55229. /**
  55230. * Gets the right operand input component
  55231. */
  55232. readonly right: NodeMaterialConnectionPoint;
  55233. /**
  55234. * Gets the output component
  55235. */
  55236. readonly output: NodeMaterialConnectionPoint;
  55237. protected _buildBlock(state: NodeMaterialBuildState): this;
  55238. }
  55239. }
  55240. declare module BABYLON {
  55241. /**
  55242. * Block used to get the min of 2 values
  55243. */
  55244. export class MinBlock extends NodeMaterialBlock {
  55245. /**
  55246. * Creates a new MinBlock
  55247. * @param name defines the block name
  55248. */
  55249. constructor(name: string);
  55250. /**
  55251. * Gets the current class name
  55252. * @returns the class name
  55253. */
  55254. getClassName(): string;
  55255. /**
  55256. * Gets the left operand input component
  55257. */
  55258. readonly left: NodeMaterialConnectionPoint;
  55259. /**
  55260. * Gets the right operand input component
  55261. */
  55262. readonly right: NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the output component
  55265. */
  55266. readonly output: NodeMaterialConnectionPoint;
  55267. protected _buildBlock(state: NodeMaterialBuildState): this;
  55268. }
  55269. }
  55270. declare module BABYLON {
  55271. /**
  55272. * Block used to get the distance between 2 values
  55273. */
  55274. export class DistanceBlock extends NodeMaterialBlock {
  55275. /**
  55276. * Creates a new DistanceBlock
  55277. * @param name defines the block name
  55278. */
  55279. constructor(name: string);
  55280. /**
  55281. * Gets the current class name
  55282. * @returns the class name
  55283. */
  55284. getClassName(): string;
  55285. /**
  55286. * Gets the left operand input component
  55287. */
  55288. readonly left: NodeMaterialConnectionPoint;
  55289. /**
  55290. * Gets the right operand input component
  55291. */
  55292. readonly right: NodeMaterialConnectionPoint;
  55293. /**
  55294. * Gets the output component
  55295. */
  55296. readonly output: NodeMaterialConnectionPoint;
  55297. protected _buildBlock(state: NodeMaterialBuildState): this;
  55298. }
  55299. }
  55300. declare module BABYLON {
  55301. /**
  55302. * Block used to get the length of a vector
  55303. */
  55304. export class LengthBlock extends NodeMaterialBlock {
  55305. /**
  55306. * Creates a new LengthBlock
  55307. * @param name defines the block name
  55308. */
  55309. constructor(name: string);
  55310. /**
  55311. * Gets the current class name
  55312. * @returns the class name
  55313. */
  55314. getClassName(): string;
  55315. /**
  55316. * Gets the value input component
  55317. */
  55318. readonly value: NodeMaterialConnectionPoint;
  55319. /**
  55320. * Gets the output component
  55321. */
  55322. readonly output: NodeMaterialConnectionPoint;
  55323. protected _buildBlock(state: NodeMaterialBuildState): this;
  55324. }
  55325. }
  55326. declare module BABYLON {
  55327. /**
  55328. * Block used to get negative version of a value (i.e. x * -1)
  55329. */
  55330. export class NegateBlock extends NodeMaterialBlock {
  55331. /**
  55332. * Creates a new NegateBlock
  55333. * @param name defines the block name
  55334. */
  55335. constructor(name: string);
  55336. /**
  55337. * Gets the current class name
  55338. * @returns the class name
  55339. */
  55340. getClassName(): string;
  55341. /**
  55342. * Gets the value input component
  55343. */
  55344. readonly value: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the output component
  55347. */
  55348. readonly output: NodeMaterialConnectionPoint;
  55349. protected _buildBlock(state: NodeMaterialBuildState): this;
  55350. }
  55351. }
  55352. declare module BABYLON {
  55353. /**
  55354. * Block used to get the value of the first parameter raised to the power of the second
  55355. */
  55356. export class PowBlock extends NodeMaterialBlock {
  55357. /**
  55358. * Creates a new PowBlock
  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 value operand input component
  55369. */
  55370. readonly value: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the power operand input component
  55373. */
  55374. readonly power: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the output component
  55377. */
  55378. readonly output: NodeMaterialConnectionPoint;
  55379. protected _buildBlock(state: NodeMaterialBuildState): this;
  55380. }
  55381. }
  55382. declare module BABYLON {
  55383. /**
  55384. * Block used to get a random number
  55385. */
  55386. export class RandomNumberBlock extends NodeMaterialBlock {
  55387. /**
  55388. * Creates a new RandomNumberBlock
  55389. * @param name defines the block name
  55390. */
  55391. constructor(name: string);
  55392. /**
  55393. * Gets the current class name
  55394. * @returns the class name
  55395. */
  55396. getClassName(): string;
  55397. /**
  55398. * Gets the seed input component
  55399. */
  55400. readonly seed: NodeMaterialConnectionPoint;
  55401. /**
  55402. * Gets the output component
  55403. */
  55404. readonly output: NodeMaterialConnectionPoint;
  55405. protected _buildBlock(state: NodeMaterialBuildState): this;
  55406. }
  55407. }
  55408. declare module BABYLON {
  55409. /**
  55410. * Block used to compute arc tangent of 2 values
  55411. */
  55412. export class ArcTan2Block extends NodeMaterialBlock {
  55413. /**
  55414. * Creates a new ArcTan2Block
  55415. * @param name defines the block name
  55416. */
  55417. constructor(name: string);
  55418. /**
  55419. * Gets the current class name
  55420. * @returns the class name
  55421. */
  55422. getClassName(): string;
  55423. /**
  55424. * Gets the x operand input component
  55425. */
  55426. readonly x: NodeMaterialConnectionPoint;
  55427. /**
  55428. * Gets the y operand input component
  55429. */
  55430. readonly y: NodeMaterialConnectionPoint;
  55431. /**
  55432. * Gets the output component
  55433. */
  55434. readonly output: NodeMaterialConnectionPoint;
  55435. protected _buildBlock(state: NodeMaterialBuildState): this;
  55436. }
  55437. }
  55438. declare module BABYLON {
  55439. /**
  55440. * Block used to smooth step a value
  55441. */
  55442. export class SmoothStepBlock extends NodeMaterialBlock {
  55443. /**
  55444. * Creates a new SmoothStepBlock
  55445. * @param name defines the block name
  55446. */
  55447. constructor(name: string);
  55448. /**
  55449. * Gets the current class name
  55450. * @returns the class name
  55451. */
  55452. getClassName(): string;
  55453. /**
  55454. * Gets the value operand input component
  55455. */
  55456. readonly value: NodeMaterialConnectionPoint;
  55457. /**
  55458. * Gets the first edge operand input component
  55459. */
  55460. readonly edge0: NodeMaterialConnectionPoint;
  55461. /**
  55462. * Gets the second edge operand input component
  55463. */
  55464. readonly edge1: NodeMaterialConnectionPoint;
  55465. /**
  55466. * Gets the output component
  55467. */
  55468. readonly output: NodeMaterialConnectionPoint;
  55469. protected _buildBlock(state: NodeMaterialBuildState): this;
  55470. }
  55471. }
  55472. declare module BABYLON {
  55473. /**
  55474. * Block used to get the reciprocal (1 / x) of a value
  55475. */
  55476. export class ReciprocalBlock extends NodeMaterialBlock {
  55477. /**
  55478. * Creates a new ReciprocalBlock
  55479. * @param name defines the block name
  55480. */
  55481. constructor(name: string);
  55482. /**
  55483. * Gets the current class name
  55484. * @returns the class name
  55485. */
  55486. getClassName(): string;
  55487. /**
  55488. * Gets the input component
  55489. */
  55490. readonly input: NodeMaterialConnectionPoint;
  55491. /**
  55492. * Gets the output component
  55493. */
  55494. readonly output: NodeMaterialConnectionPoint;
  55495. protected _buildBlock(state: NodeMaterialBuildState): this;
  55496. }
  55497. }
  55498. declare module BABYLON {
  55499. /**
  55500. * Block used to replace a color by another one
  55501. */
  55502. export class ReplaceColorBlock extends NodeMaterialBlock {
  55503. /**
  55504. * Creates a new ReplaceColorBlock
  55505. * @param name defines the block name
  55506. */
  55507. constructor(name: string);
  55508. /**
  55509. * Gets the current class name
  55510. * @returns the class name
  55511. */
  55512. getClassName(): string;
  55513. /**
  55514. * Gets the value input component
  55515. */
  55516. readonly value: NodeMaterialConnectionPoint;
  55517. /**
  55518. * Gets the reference input component
  55519. */
  55520. readonly reference: NodeMaterialConnectionPoint;
  55521. /**
  55522. * Gets the distance input component
  55523. */
  55524. readonly distance: NodeMaterialConnectionPoint;
  55525. /**
  55526. * Gets the replacement input component
  55527. */
  55528. readonly replacement: NodeMaterialConnectionPoint;
  55529. /**
  55530. * Gets the output component
  55531. */
  55532. readonly output: NodeMaterialConnectionPoint;
  55533. protected _buildBlock(state: NodeMaterialBuildState): this;
  55534. }
  55535. }
  55536. declare module BABYLON {
  55537. /**
  55538. * Block used to posterize a value
  55539. * @see https://en.wikipedia.org/wiki/Posterization
  55540. */
  55541. export class PosterizeBlock extends NodeMaterialBlock {
  55542. /**
  55543. * Creates a new PosterizeBlock
  55544. * @param name defines the block name
  55545. */
  55546. constructor(name: string);
  55547. /**
  55548. * Gets the current class name
  55549. * @returns the class name
  55550. */
  55551. getClassName(): string;
  55552. /**
  55553. * Gets the value input component
  55554. */
  55555. readonly value: NodeMaterialConnectionPoint;
  55556. /**
  55557. * Gets the steps input component
  55558. */
  55559. readonly steps: NodeMaterialConnectionPoint;
  55560. /**
  55561. * Gets the output component
  55562. */
  55563. readonly output: NodeMaterialConnectionPoint;
  55564. protected _buildBlock(state: NodeMaterialBuildState): this;
  55565. }
  55566. }
  55567. declare module BABYLON {
  55568. /**
  55569. * Operations supported by the Wave block
  55570. */
  55571. export enum WaveBlockKind {
  55572. /** SawTooth */
  55573. SawTooth = 0,
  55574. /** Square */
  55575. Square = 1,
  55576. /** Triangle */
  55577. Triangle = 2
  55578. }
  55579. /**
  55580. * Block used to apply wave operation to floats
  55581. */
  55582. export class WaveBlock extends NodeMaterialBlock {
  55583. /**
  55584. * Gets or sets the kibnd of wave to be applied by the block
  55585. */
  55586. kind: WaveBlockKind;
  55587. /**
  55588. * Creates a new WaveBlock
  55589. * @param name defines the block name
  55590. */
  55591. constructor(name: string);
  55592. /**
  55593. * Gets the current class name
  55594. * @returns the class name
  55595. */
  55596. getClassName(): string;
  55597. /**
  55598. * Gets the input component
  55599. */
  55600. readonly input: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the output component
  55603. */
  55604. readonly output: NodeMaterialConnectionPoint;
  55605. protected _buildBlock(state: NodeMaterialBuildState): this;
  55606. serialize(): any;
  55607. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55608. }
  55609. }
  55610. declare module BABYLON {
  55611. /**
  55612. * Class used to store a color step for the GradientBlock
  55613. */
  55614. export class GradientBlockColorStep {
  55615. /**
  55616. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55617. */
  55618. step: number;
  55619. /**
  55620. * Gets or sets the color associated with this step
  55621. */
  55622. color: Color3;
  55623. /**
  55624. * Creates a new GradientBlockColorStep
  55625. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55626. * @param color defines the color associated with this step
  55627. */
  55628. constructor(
  55629. /**
  55630. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55631. */
  55632. step: number,
  55633. /**
  55634. * Gets or sets the color associated with this step
  55635. */
  55636. color: Color3);
  55637. }
  55638. /**
  55639. * Block used to return a color from a gradient based on an input value between 0 and 1
  55640. */
  55641. export class GradientBlock extends NodeMaterialBlock {
  55642. /**
  55643. * Gets or sets the list of color steps
  55644. */
  55645. colorSteps: GradientBlockColorStep[];
  55646. /**
  55647. * Creates a new GradientBlock
  55648. * @param name defines the block name
  55649. */
  55650. constructor(name: string);
  55651. /**
  55652. * Gets the current class name
  55653. * @returns the class name
  55654. */
  55655. getClassName(): string;
  55656. /**
  55657. * Gets the gradient input component
  55658. */
  55659. readonly gradient: NodeMaterialConnectionPoint;
  55660. /**
  55661. * Gets the output component
  55662. */
  55663. readonly output: NodeMaterialConnectionPoint;
  55664. private _writeColorConstant;
  55665. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55666. serialize(): any;
  55667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55668. protected _dumpPropertiesCode(): string;
  55669. }
  55670. }
  55671. declare module BABYLON {
  55672. /**
  55673. * Block used to normalize lerp between 2 values
  55674. */
  55675. export class NLerpBlock extends NodeMaterialBlock {
  55676. /**
  55677. * Creates a new NLerpBlock
  55678. * @param name defines the block name
  55679. */
  55680. constructor(name: string);
  55681. /**
  55682. * Gets the current class name
  55683. * @returns the class name
  55684. */
  55685. getClassName(): string;
  55686. /**
  55687. * Gets the left operand input component
  55688. */
  55689. readonly left: NodeMaterialConnectionPoint;
  55690. /**
  55691. * Gets the right operand input component
  55692. */
  55693. readonly right: NodeMaterialConnectionPoint;
  55694. /**
  55695. * Gets the gradient operand input component
  55696. */
  55697. readonly gradient: NodeMaterialConnectionPoint;
  55698. /**
  55699. * Gets the output component
  55700. */
  55701. readonly output: NodeMaterialConnectionPoint;
  55702. protected _buildBlock(state: NodeMaterialBuildState): this;
  55703. }
  55704. }
  55705. declare module BABYLON {
  55706. /**
  55707. * Effect Render Options
  55708. */
  55709. export interface IEffectRendererOptions {
  55710. /**
  55711. * Defines the vertices positions.
  55712. */
  55713. positions?: number[];
  55714. /**
  55715. * Defines the indices.
  55716. */
  55717. indices?: number[];
  55718. }
  55719. /**
  55720. * Helper class to render one or more effects
  55721. */
  55722. export class EffectRenderer {
  55723. private engine;
  55724. private static _DefaultOptions;
  55725. private _vertexBuffers;
  55726. private _indexBuffer;
  55727. private _ringBufferIndex;
  55728. private _ringScreenBuffer;
  55729. private _fullscreenViewport;
  55730. private _getNextFrameBuffer;
  55731. /**
  55732. * Creates an effect renderer
  55733. * @param engine the engine to use for rendering
  55734. * @param options defines the options of the effect renderer
  55735. */
  55736. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55737. /**
  55738. * Sets the current viewport in normalized coordinates 0-1
  55739. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55740. */
  55741. setViewport(viewport?: Viewport): void;
  55742. /**
  55743. * Binds the embedded attributes buffer to the effect.
  55744. * @param effect Defines the effect to bind the attributes for
  55745. */
  55746. bindBuffers(effect: Effect): void;
  55747. /**
  55748. * Sets the current effect wrapper to use during draw.
  55749. * The effect needs to be ready before calling this api.
  55750. * This also sets the default full screen position attribute.
  55751. * @param effectWrapper Defines the effect to draw with
  55752. */
  55753. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55754. /**
  55755. * Draws a full screen quad.
  55756. */
  55757. draw(): void;
  55758. /**
  55759. * renders one or more effects to a specified texture
  55760. * @param effectWrappers list of effects to renderer
  55761. * @param outputTexture texture to draw to, if null it will render to the screen
  55762. */
  55763. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55764. /**
  55765. * Disposes of the effect renderer
  55766. */
  55767. dispose(): void;
  55768. }
  55769. /**
  55770. * Options to create an EffectWrapper
  55771. */
  55772. interface EffectWrapperCreationOptions {
  55773. /**
  55774. * Engine to use to create the effect
  55775. */
  55776. engine: ThinEngine;
  55777. /**
  55778. * Fragment shader for the effect
  55779. */
  55780. fragmentShader: string;
  55781. /**
  55782. * Vertex shader for the effect
  55783. */
  55784. vertexShader?: string;
  55785. /**
  55786. * Attributes to use in the shader
  55787. */
  55788. attributeNames?: Array<string>;
  55789. /**
  55790. * Uniforms to use in the shader
  55791. */
  55792. uniformNames?: Array<string>;
  55793. /**
  55794. * Texture sampler names to use in the shader
  55795. */
  55796. samplerNames?: Array<string>;
  55797. /**
  55798. * The friendly name of the effect displayed in Spector.
  55799. */
  55800. name?: string;
  55801. }
  55802. /**
  55803. * Wraps an effect to be used for rendering
  55804. */
  55805. export class EffectWrapper {
  55806. /**
  55807. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55808. */
  55809. onApplyObservable: Observable<{}>;
  55810. /**
  55811. * The underlying effect
  55812. */
  55813. effect: Effect;
  55814. /**
  55815. * Creates an effect to be renderer
  55816. * @param creationOptions options to create the effect
  55817. */
  55818. constructor(creationOptions: EffectWrapperCreationOptions);
  55819. /**
  55820. * Disposes of the effect wrapper
  55821. */
  55822. dispose(): void;
  55823. }
  55824. }
  55825. declare module BABYLON {
  55826. /**
  55827. * Helper class to push actions to a pool of workers.
  55828. */
  55829. export class WorkerPool implements IDisposable {
  55830. private _workerInfos;
  55831. private _pendingActions;
  55832. /**
  55833. * Constructor
  55834. * @param workers Array of workers to use for actions
  55835. */
  55836. constructor(workers: Array<Worker>);
  55837. /**
  55838. * Terminates all workers and clears any pending actions.
  55839. */
  55840. dispose(): void;
  55841. /**
  55842. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55843. * pended until a worker has completed its action.
  55844. * @param action The action to perform. Call onComplete when the action is complete.
  55845. */
  55846. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55847. private _execute;
  55848. }
  55849. }
  55850. declare module BABYLON {
  55851. /**
  55852. * Configuration for Draco compression
  55853. */
  55854. export interface IDracoCompressionConfiguration {
  55855. /**
  55856. * Configuration for the decoder.
  55857. */
  55858. decoder: {
  55859. /**
  55860. * The url to the WebAssembly module.
  55861. */
  55862. wasmUrl?: string;
  55863. /**
  55864. * The url to the WebAssembly binary.
  55865. */
  55866. wasmBinaryUrl?: string;
  55867. /**
  55868. * The url to the fallback JavaScript module.
  55869. */
  55870. fallbackUrl?: string;
  55871. };
  55872. }
  55873. /**
  55874. * Draco compression (https://google.github.io/draco/)
  55875. *
  55876. * This class wraps the Draco module.
  55877. *
  55878. * **Encoder**
  55879. *
  55880. * The encoder is not currently implemented.
  55881. *
  55882. * **Decoder**
  55883. *
  55884. * 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.
  55885. *
  55886. * To update the configuration, use the following code:
  55887. * ```javascript
  55888. * DracoCompression.Configuration = {
  55889. * decoder: {
  55890. * wasmUrl: "<url to the WebAssembly library>",
  55891. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55892. * fallbackUrl: "<url to the fallback JavaScript library>",
  55893. * }
  55894. * };
  55895. * ```
  55896. *
  55897. * 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.
  55898. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55899. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55900. *
  55901. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55902. * ```javascript
  55903. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55904. * ```
  55905. *
  55906. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55907. */
  55908. export class DracoCompression implements IDisposable {
  55909. private _workerPoolPromise?;
  55910. private _decoderModulePromise?;
  55911. /**
  55912. * The configuration. Defaults to the following urls:
  55913. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55914. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55915. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55916. */
  55917. static Configuration: IDracoCompressionConfiguration;
  55918. /**
  55919. * Returns true if the decoder configuration is available.
  55920. */
  55921. static readonly DecoderAvailable: boolean;
  55922. /**
  55923. * Default number of workers to create when creating the draco compression object.
  55924. */
  55925. static DefaultNumWorkers: number;
  55926. private static GetDefaultNumWorkers;
  55927. private static _Default;
  55928. /**
  55929. * Default instance for the draco compression object.
  55930. */
  55931. static readonly Default: DracoCompression;
  55932. /**
  55933. * Constructor
  55934. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55935. */
  55936. constructor(numWorkers?: number);
  55937. /**
  55938. * Stop all async operations and release resources.
  55939. */
  55940. dispose(): void;
  55941. /**
  55942. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55943. * @returns a promise that resolves when ready
  55944. */
  55945. whenReadyAsync(): Promise<void>;
  55946. /**
  55947. * Decode Draco compressed mesh data to vertex data.
  55948. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55949. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55950. * @returns A promise that resolves with the decoded vertex data
  55951. */
  55952. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55953. [kind: string]: number;
  55954. }): Promise<VertexData>;
  55955. }
  55956. }
  55957. declare module BABYLON {
  55958. /**
  55959. * Class for building Constructive Solid Geometry
  55960. */
  55961. export class CSG {
  55962. private polygons;
  55963. /**
  55964. * The world matrix
  55965. */
  55966. matrix: Matrix;
  55967. /**
  55968. * Stores the position
  55969. */
  55970. position: Vector3;
  55971. /**
  55972. * Stores the rotation
  55973. */
  55974. rotation: Vector3;
  55975. /**
  55976. * Stores the rotation quaternion
  55977. */
  55978. rotationQuaternion: Nullable<Quaternion>;
  55979. /**
  55980. * Stores the scaling vector
  55981. */
  55982. scaling: Vector3;
  55983. /**
  55984. * Convert the Mesh to CSG
  55985. * @param mesh The Mesh to convert to CSG
  55986. * @returns A new CSG from the Mesh
  55987. */
  55988. static FromMesh(mesh: Mesh): CSG;
  55989. /**
  55990. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55991. * @param polygons Polygons used to construct a CSG solid
  55992. */
  55993. private static FromPolygons;
  55994. /**
  55995. * Clones, or makes a deep copy, of the CSG
  55996. * @returns A new CSG
  55997. */
  55998. clone(): CSG;
  55999. /**
  56000. * Unions this CSG with another CSG
  56001. * @param csg The CSG to union against this CSG
  56002. * @returns The unioned CSG
  56003. */
  56004. union(csg: CSG): CSG;
  56005. /**
  56006. * Unions this CSG with another CSG in place
  56007. * @param csg The CSG to union against this CSG
  56008. */
  56009. unionInPlace(csg: CSG): void;
  56010. /**
  56011. * Subtracts this CSG with another CSG
  56012. * @param csg The CSG to subtract against this CSG
  56013. * @returns A new CSG
  56014. */
  56015. subtract(csg: CSG): CSG;
  56016. /**
  56017. * Subtracts this CSG with another CSG in place
  56018. * @param csg The CSG to subtact against this CSG
  56019. */
  56020. subtractInPlace(csg: CSG): void;
  56021. /**
  56022. * Intersect this CSG with another CSG
  56023. * @param csg The CSG to intersect against this CSG
  56024. * @returns A new CSG
  56025. */
  56026. intersect(csg: CSG): CSG;
  56027. /**
  56028. * Intersects this CSG with another CSG in place
  56029. * @param csg The CSG to intersect against this CSG
  56030. */
  56031. intersectInPlace(csg: CSG): void;
  56032. /**
  56033. * Return a new CSG solid with solid and empty space switched. This solid is
  56034. * not modified.
  56035. * @returns A new CSG solid with solid and empty space switched
  56036. */
  56037. inverse(): CSG;
  56038. /**
  56039. * Inverses the CSG in place
  56040. */
  56041. inverseInPlace(): void;
  56042. /**
  56043. * This is used to keep meshes transformations so they can be restored
  56044. * when we build back a Babylon Mesh
  56045. * NB : All CSG operations are performed in world coordinates
  56046. * @param csg The CSG to copy the transform attributes from
  56047. * @returns This CSG
  56048. */
  56049. copyTransformAttributes(csg: CSG): CSG;
  56050. /**
  56051. * Build Raw mesh from CSG
  56052. * Coordinates here are in world space
  56053. * @param name The name of the mesh geometry
  56054. * @param scene The Scene
  56055. * @param keepSubMeshes Specifies if the submeshes should be kept
  56056. * @returns A new Mesh
  56057. */
  56058. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56059. /**
  56060. * Build Mesh from CSG taking material and transforms into account
  56061. * @param name The name of the Mesh
  56062. * @param material The material of the Mesh
  56063. * @param scene The Scene
  56064. * @param keepSubMeshes Specifies if submeshes should be kept
  56065. * @returns The new Mesh
  56066. */
  56067. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56068. }
  56069. }
  56070. declare module BABYLON {
  56071. /**
  56072. * Class used to create a trail following a mesh
  56073. */
  56074. export class TrailMesh extends Mesh {
  56075. private _generator;
  56076. private _autoStart;
  56077. private _running;
  56078. private _diameter;
  56079. private _length;
  56080. private _sectionPolygonPointsCount;
  56081. private _sectionVectors;
  56082. private _sectionNormalVectors;
  56083. private _beforeRenderObserver;
  56084. /**
  56085. * @constructor
  56086. * @param name The value used by scene.getMeshByName() to do a lookup.
  56087. * @param generator The mesh to generate a trail.
  56088. * @param scene The scene to add this mesh to.
  56089. * @param diameter Diameter of trailing mesh. Default is 1.
  56090. * @param length Length of trailing mesh. Default is 60.
  56091. * @param autoStart Automatically start trailing mesh. Default true.
  56092. */
  56093. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56094. /**
  56095. * "TrailMesh"
  56096. * @returns "TrailMesh"
  56097. */
  56098. getClassName(): string;
  56099. private _createMesh;
  56100. /**
  56101. * Start trailing mesh.
  56102. */
  56103. start(): void;
  56104. /**
  56105. * Stop trailing mesh.
  56106. */
  56107. stop(): void;
  56108. /**
  56109. * Update trailing mesh geometry.
  56110. */
  56111. update(): void;
  56112. /**
  56113. * Returns a new TrailMesh object.
  56114. * @param name is a string, the name given to the new mesh
  56115. * @param newGenerator use new generator object for cloned trail mesh
  56116. * @returns a new mesh
  56117. */
  56118. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56119. /**
  56120. * Serializes this trail mesh
  56121. * @param serializationObject object to write serialization to
  56122. */
  56123. serialize(serializationObject: any): void;
  56124. /**
  56125. * Parses a serialized trail mesh
  56126. * @param parsedMesh the serialized mesh
  56127. * @param scene the scene to create the trail mesh in
  56128. * @returns the created trail mesh
  56129. */
  56130. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56131. }
  56132. }
  56133. declare module BABYLON {
  56134. /**
  56135. * Class containing static functions to help procedurally build meshes
  56136. */
  56137. export class TiledBoxBuilder {
  56138. /**
  56139. * Creates a box mesh
  56140. * 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)
  56141. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56143. * * 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
  56144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56145. * @param name defines the name of the mesh
  56146. * @param options defines the options used to create the mesh
  56147. * @param scene defines the hosting scene
  56148. * @returns the box mesh
  56149. */
  56150. static CreateTiledBox(name: string, options: {
  56151. pattern?: number;
  56152. width?: number;
  56153. height?: number;
  56154. depth?: number;
  56155. tileSize?: number;
  56156. tileWidth?: number;
  56157. tileHeight?: number;
  56158. alignHorizontal?: number;
  56159. alignVertical?: number;
  56160. faceUV?: Vector4[];
  56161. faceColors?: Color4[];
  56162. sideOrientation?: number;
  56163. updatable?: boolean;
  56164. }, scene?: Nullable<Scene>): Mesh;
  56165. }
  56166. }
  56167. declare module BABYLON {
  56168. /**
  56169. * Class containing static functions to help procedurally build meshes
  56170. */
  56171. export class TorusKnotBuilder {
  56172. /**
  56173. * Creates a torus knot mesh
  56174. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56175. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56176. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56177. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56179. * * 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
  56180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56181. * @param name defines the name of the mesh
  56182. * @param options defines the options used to create the mesh
  56183. * @param scene defines the hosting scene
  56184. * @returns the torus knot mesh
  56185. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56186. */
  56187. static CreateTorusKnot(name: string, options: {
  56188. radius?: number;
  56189. tube?: number;
  56190. radialSegments?: number;
  56191. tubularSegments?: number;
  56192. p?: number;
  56193. q?: number;
  56194. updatable?: boolean;
  56195. sideOrientation?: number;
  56196. frontUVs?: Vector4;
  56197. backUVs?: Vector4;
  56198. }, scene: any): Mesh;
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /**
  56203. * Polygon
  56204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56205. */
  56206. export class Polygon {
  56207. /**
  56208. * Creates a rectangle
  56209. * @param xmin bottom X coord
  56210. * @param ymin bottom Y coord
  56211. * @param xmax top X coord
  56212. * @param ymax top Y coord
  56213. * @returns points that make the resulting rectation
  56214. */
  56215. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56216. /**
  56217. * Creates a circle
  56218. * @param radius radius of circle
  56219. * @param cx scale in x
  56220. * @param cy scale in y
  56221. * @param numberOfSides number of sides that make up the circle
  56222. * @returns points that make the resulting circle
  56223. */
  56224. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56225. /**
  56226. * Creates a polygon from input string
  56227. * @param input Input polygon data
  56228. * @returns the parsed points
  56229. */
  56230. static Parse(input: string): Vector2[];
  56231. /**
  56232. * Starts building a polygon from x and y coordinates
  56233. * @param x x coordinate
  56234. * @param y y coordinate
  56235. * @returns the started path2
  56236. */
  56237. static StartingAt(x: number, y: number): Path2;
  56238. }
  56239. /**
  56240. * Builds a polygon
  56241. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56242. */
  56243. export class PolygonMeshBuilder {
  56244. private _points;
  56245. private _outlinepoints;
  56246. private _holes;
  56247. private _name;
  56248. private _scene;
  56249. private _epoints;
  56250. private _eholes;
  56251. private _addToepoint;
  56252. /**
  56253. * Babylon reference to the earcut plugin.
  56254. */
  56255. bjsEarcut: any;
  56256. /**
  56257. * Creates a PolygonMeshBuilder
  56258. * @param name name of the builder
  56259. * @param contours Path of the polygon
  56260. * @param scene scene to add to when creating the mesh
  56261. * @param earcutInjection can be used to inject your own earcut reference
  56262. */
  56263. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56264. /**
  56265. * Adds a whole within the polygon
  56266. * @param hole Array of points defining the hole
  56267. * @returns this
  56268. */
  56269. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56270. /**
  56271. * Creates the polygon
  56272. * @param updatable If the mesh should be updatable
  56273. * @param depth The depth of the mesh created
  56274. * @returns the created mesh
  56275. */
  56276. build(updatable?: boolean, depth?: number): Mesh;
  56277. /**
  56278. * Creates the polygon
  56279. * @param depth The depth of the mesh created
  56280. * @returns the created VertexData
  56281. */
  56282. buildVertexData(depth?: number): VertexData;
  56283. /**
  56284. * Adds a side to the polygon
  56285. * @param positions points that make the polygon
  56286. * @param normals normals of the polygon
  56287. * @param uvs uvs of the polygon
  56288. * @param indices indices of the polygon
  56289. * @param bounds bounds of the polygon
  56290. * @param points points of the polygon
  56291. * @param depth depth of the polygon
  56292. * @param flip flip of the polygon
  56293. */
  56294. private addSide;
  56295. }
  56296. }
  56297. declare module BABYLON {
  56298. /**
  56299. * Class containing static functions to help procedurally build meshes
  56300. */
  56301. export class PolygonBuilder {
  56302. /**
  56303. * Creates a polygon mesh
  56304. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56305. * * 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
  56306. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56308. * * 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)
  56309. * * Remember you can only change the shape positions, not their number when updating a polygon
  56310. * @param name defines the name of the mesh
  56311. * @param options defines the options used to create the mesh
  56312. * @param scene defines the hosting scene
  56313. * @param earcutInjection can be used to inject your own earcut reference
  56314. * @returns the polygon mesh
  56315. */
  56316. static CreatePolygon(name: string, options: {
  56317. shape: Vector3[];
  56318. holes?: Vector3[][];
  56319. depth?: number;
  56320. faceUV?: Vector4[];
  56321. faceColors?: Color4[];
  56322. updatable?: boolean;
  56323. sideOrientation?: number;
  56324. frontUVs?: Vector4;
  56325. backUVs?: Vector4;
  56326. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56327. /**
  56328. * Creates an extruded polygon mesh, with depth in the Y direction.
  56329. * * 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)
  56330. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56331. * @param name defines the name of the mesh
  56332. * @param options defines the options used to create the mesh
  56333. * @param scene defines the hosting scene
  56334. * @param earcutInjection can be used to inject your own earcut reference
  56335. * @returns the polygon mesh
  56336. */
  56337. static ExtrudePolygon(name: string, options: {
  56338. shape: Vector3[];
  56339. holes?: Vector3[][];
  56340. depth?: number;
  56341. faceUV?: Vector4[];
  56342. faceColors?: Color4[];
  56343. updatable?: boolean;
  56344. sideOrientation?: number;
  56345. frontUVs?: Vector4;
  56346. backUVs?: Vector4;
  56347. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56348. }
  56349. }
  56350. declare module BABYLON {
  56351. /**
  56352. * Class containing static functions to help procedurally build meshes
  56353. */
  56354. export class LatheBuilder {
  56355. /**
  56356. * Creates lathe mesh.
  56357. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56358. * * 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
  56359. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56360. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56361. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56362. * * 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
  56363. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56364. * * 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
  56365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56366. * * 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
  56367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56369. * @param name defines the name of the mesh
  56370. * @param options defines the options used to create the mesh
  56371. * @param scene defines the hosting scene
  56372. * @returns the lathe mesh
  56373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56374. */
  56375. static CreateLathe(name: string, options: {
  56376. shape: Vector3[];
  56377. radius?: number;
  56378. tessellation?: number;
  56379. clip?: number;
  56380. arc?: number;
  56381. closed?: boolean;
  56382. updatable?: boolean;
  56383. sideOrientation?: number;
  56384. frontUVs?: Vector4;
  56385. backUVs?: Vector4;
  56386. cap?: number;
  56387. invertUV?: boolean;
  56388. }, scene?: Nullable<Scene>): Mesh;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * Class containing static functions to help procedurally build meshes
  56394. */
  56395. export class TiledPlaneBuilder {
  56396. /**
  56397. * Creates a tiled plane mesh
  56398. * * The parameter `pattern` will, depending on value, do nothing or
  56399. * * * flip (reflect about central vertical) alternate tiles across and up
  56400. * * * flip every tile on alternate rows
  56401. * * * rotate (180 degs) alternate tiles across and up
  56402. * * * rotate every tile on alternate rows
  56403. * * * flip and rotate alternate tiles across and up
  56404. * * * flip and rotate every tile on alternate rows
  56405. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56406. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56407. * * 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
  56408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56409. * * 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)
  56410. * * 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)
  56411. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56412. * @param name defines the name of the mesh
  56413. * @param options defines the options used to create the mesh
  56414. * @param scene defines the hosting scene
  56415. * @returns the box mesh
  56416. */
  56417. static CreateTiledPlane(name: string, options: {
  56418. pattern?: number;
  56419. tileSize?: number;
  56420. tileWidth?: number;
  56421. tileHeight?: number;
  56422. size?: number;
  56423. width?: number;
  56424. height?: number;
  56425. alignHorizontal?: number;
  56426. alignVertical?: number;
  56427. sideOrientation?: number;
  56428. frontUVs?: Vector4;
  56429. backUVs?: Vector4;
  56430. updatable?: boolean;
  56431. }, scene?: Nullable<Scene>): Mesh;
  56432. }
  56433. }
  56434. declare module BABYLON {
  56435. /**
  56436. * Class containing static functions to help procedurally build meshes
  56437. */
  56438. export class TubeBuilder {
  56439. /**
  56440. * Creates a tube mesh.
  56441. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56442. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56443. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56444. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56445. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56446. * * 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)
  56447. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56448. * * 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
  56449. * * 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
  56450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56451. * * 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
  56452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56454. * @param name defines the name of the mesh
  56455. * @param options defines the options used to create the mesh
  56456. * @param scene defines the hosting scene
  56457. * @returns the tube mesh
  56458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56459. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56460. */
  56461. static CreateTube(name: string, options: {
  56462. path: Vector3[];
  56463. radius?: number;
  56464. tessellation?: number;
  56465. radiusFunction?: {
  56466. (i: number, distance: number): number;
  56467. };
  56468. cap?: number;
  56469. arc?: number;
  56470. updatable?: boolean;
  56471. sideOrientation?: number;
  56472. frontUVs?: Vector4;
  56473. backUVs?: Vector4;
  56474. instance?: Mesh;
  56475. invertUV?: boolean;
  56476. }, scene?: Nullable<Scene>): Mesh;
  56477. }
  56478. }
  56479. declare module BABYLON {
  56480. /**
  56481. * Class containing static functions to help procedurally build meshes
  56482. */
  56483. export class IcoSphereBuilder {
  56484. /**
  56485. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56486. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56487. * * 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`)
  56488. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56489. * * 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
  56490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56491. * * 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
  56492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56493. * @param name defines the name of the mesh
  56494. * @param options defines the options used to create the mesh
  56495. * @param scene defines the hosting scene
  56496. * @returns the icosahedron mesh
  56497. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56498. */
  56499. static CreateIcoSphere(name: string, options: {
  56500. radius?: number;
  56501. radiusX?: number;
  56502. radiusY?: number;
  56503. radiusZ?: number;
  56504. flat?: boolean;
  56505. subdivisions?: number;
  56506. sideOrientation?: number;
  56507. frontUVs?: Vector4;
  56508. backUVs?: Vector4;
  56509. updatable?: boolean;
  56510. }, scene?: Nullable<Scene>): Mesh;
  56511. }
  56512. }
  56513. declare module BABYLON {
  56514. /**
  56515. * Class containing static functions to help procedurally build meshes
  56516. */
  56517. export class DecalBuilder {
  56518. /**
  56519. * Creates a decal mesh.
  56520. * 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
  56521. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56522. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56523. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56524. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56525. * @param name defines the name of the mesh
  56526. * @param sourceMesh defines the mesh where the decal must be applied
  56527. * @param options defines the options used to create the mesh
  56528. * @param scene defines the hosting scene
  56529. * @returns the decal mesh
  56530. * @see https://doc.babylonjs.com/how_to/decals
  56531. */
  56532. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56533. position?: Vector3;
  56534. normal?: Vector3;
  56535. size?: Vector3;
  56536. angle?: number;
  56537. }): Mesh;
  56538. }
  56539. }
  56540. declare module BABYLON {
  56541. /**
  56542. * Class containing static functions to help procedurally build meshes
  56543. */
  56544. export class MeshBuilder {
  56545. /**
  56546. * Creates a box mesh
  56547. * * The parameter `size` sets the size (float) of each box side (default 1)
  56548. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56549. * * 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)
  56550. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56552. * * 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
  56553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56554. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56555. * @param name defines the name of the mesh
  56556. * @param options defines the options used to create the mesh
  56557. * @param scene defines the hosting scene
  56558. * @returns the box mesh
  56559. */
  56560. static CreateBox(name: string, options: {
  56561. size?: number;
  56562. width?: number;
  56563. height?: number;
  56564. depth?: number;
  56565. faceUV?: Vector4[];
  56566. faceColors?: Color4[];
  56567. sideOrientation?: number;
  56568. frontUVs?: Vector4;
  56569. backUVs?: Vector4;
  56570. updatable?: boolean;
  56571. }, scene?: Nullable<Scene>): Mesh;
  56572. /**
  56573. * Creates a tiled box mesh
  56574. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56576. * @param name defines the name of the mesh
  56577. * @param options defines the options used to create the mesh
  56578. * @param scene defines the hosting scene
  56579. * @returns the tiled box mesh
  56580. */
  56581. static CreateTiledBox(name: string, options: {
  56582. pattern?: number;
  56583. size?: number;
  56584. width?: number;
  56585. height?: number;
  56586. depth: number;
  56587. tileSize?: number;
  56588. tileWidth?: number;
  56589. tileHeight?: number;
  56590. faceUV?: Vector4[];
  56591. faceColors?: Color4[];
  56592. alignHorizontal?: number;
  56593. alignVertical?: number;
  56594. sideOrientation?: number;
  56595. updatable?: boolean;
  56596. }, scene?: Nullable<Scene>): Mesh;
  56597. /**
  56598. * Creates a sphere mesh
  56599. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56600. * * 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`)
  56601. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56602. * * 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
  56603. * * 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)
  56604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56605. * * 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
  56606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56607. * @param name defines the name of the mesh
  56608. * @param options defines the options used to create the mesh
  56609. * @param scene defines the hosting scene
  56610. * @returns the sphere mesh
  56611. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56612. */
  56613. static CreateSphere(name: string, options: {
  56614. segments?: number;
  56615. diameter?: number;
  56616. diameterX?: number;
  56617. diameterY?: number;
  56618. diameterZ?: number;
  56619. arc?: number;
  56620. slice?: number;
  56621. sideOrientation?: number;
  56622. frontUVs?: Vector4;
  56623. backUVs?: Vector4;
  56624. updatable?: boolean;
  56625. }, scene?: Nullable<Scene>): Mesh;
  56626. /**
  56627. * Creates a plane polygonal mesh. By default, this is a disc
  56628. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56629. * * 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
  56630. * * 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
  56631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56632. * * 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
  56633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56634. * @param name defines the name of the mesh
  56635. * @param options defines the options used to create the mesh
  56636. * @param scene defines the hosting scene
  56637. * @returns the plane polygonal mesh
  56638. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56639. */
  56640. static CreateDisc(name: string, options: {
  56641. radius?: number;
  56642. tessellation?: number;
  56643. arc?: number;
  56644. updatable?: boolean;
  56645. sideOrientation?: number;
  56646. frontUVs?: Vector4;
  56647. backUVs?: Vector4;
  56648. }, scene?: Nullable<Scene>): Mesh;
  56649. /**
  56650. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56651. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56652. * * 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`)
  56653. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56654. * * 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
  56655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56656. * * 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
  56657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56658. * @param name defines the name of the mesh
  56659. * @param options defines the options used to create the mesh
  56660. * @param scene defines the hosting scene
  56661. * @returns the icosahedron mesh
  56662. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56663. */
  56664. static CreateIcoSphere(name: string, options: {
  56665. radius?: number;
  56666. radiusX?: number;
  56667. radiusY?: number;
  56668. radiusZ?: number;
  56669. flat?: boolean;
  56670. subdivisions?: number;
  56671. sideOrientation?: number;
  56672. frontUVs?: Vector4;
  56673. backUVs?: Vector4;
  56674. updatable?: boolean;
  56675. }, scene?: Nullable<Scene>): Mesh;
  56676. /**
  56677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56681. * * 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
  56682. * * 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
  56683. * * 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
  56684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56685. * * 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
  56686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56687. * * 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
  56688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56689. * * 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
  56690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56692. * @param name defines the name of the mesh
  56693. * @param options defines the options used to create the mesh
  56694. * @param scene defines the hosting scene
  56695. * @returns the ribbon mesh
  56696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56698. */
  56699. static CreateRibbon(name: string, options: {
  56700. pathArray: Vector3[][];
  56701. closeArray?: boolean;
  56702. closePath?: boolean;
  56703. offset?: number;
  56704. updatable?: boolean;
  56705. sideOrientation?: number;
  56706. frontUVs?: Vector4;
  56707. backUVs?: Vector4;
  56708. instance?: Mesh;
  56709. invertUV?: boolean;
  56710. uvs?: Vector2[];
  56711. colors?: Color4[];
  56712. }, scene?: Nullable<Scene>): Mesh;
  56713. /**
  56714. * Creates a cylinder or a cone mesh
  56715. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56716. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56717. * * 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.
  56718. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56719. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56720. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56721. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56722. * * 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).
  56723. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56724. * * 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).
  56725. * * 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
  56726. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56727. * * 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
  56728. * * 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.
  56729. * * If `enclose` is false, a ring surface is one element.
  56730. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56731. * * 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
  56732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56733. * * 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
  56734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56735. * @param name defines the name of the mesh
  56736. * @param options defines the options used to create the mesh
  56737. * @param scene defines the hosting scene
  56738. * @returns the cylinder mesh
  56739. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56740. */
  56741. static CreateCylinder(name: string, options: {
  56742. height?: number;
  56743. diameterTop?: number;
  56744. diameterBottom?: number;
  56745. diameter?: number;
  56746. tessellation?: number;
  56747. subdivisions?: number;
  56748. arc?: number;
  56749. faceColors?: Color4[];
  56750. faceUV?: Vector4[];
  56751. updatable?: boolean;
  56752. hasRings?: boolean;
  56753. enclose?: boolean;
  56754. cap?: number;
  56755. sideOrientation?: number;
  56756. frontUVs?: Vector4;
  56757. backUVs?: Vector4;
  56758. }, scene?: Nullable<Scene>): Mesh;
  56759. /**
  56760. * Creates a torus mesh
  56761. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56762. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56763. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56765. * * 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
  56766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56767. * @param name defines the name of the mesh
  56768. * @param options defines the options used to create the mesh
  56769. * @param scene defines the hosting scene
  56770. * @returns the torus mesh
  56771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56772. */
  56773. static CreateTorus(name: string, options: {
  56774. diameter?: number;
  56775. thickness?: number;
  56776. tessellation?: number;
  56777. updatable?: boolean;
  56778. sideOrientation?: number;
  56779. frontUVs?: Vector4;
  56780. backUVs?: Vector4;
  56781. }, scene?: Nullable<Scene>): Mesh;
  56782. /**
  56783. * Creates a torus knot mesh
  56784. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56785. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56786. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56787. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56789. * * 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
  56790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56791. * @param name defines the name of the mesh
  56792. * @param options defines the options used to create the mesh
  56793. * @param scene defines the hosting scene
  56794. * @returns the torus knot mesh
  56795. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56796. */
  56797. static CreateTorusKnot(name: string, options: {
  56798. radius?: number;
  56799. tube?: number;
  56800. radialSegments?: number;
  56801. tubularSegments?: number;
  56802. p?: number;
  56803. q?: number;
  56804. updatable?: boolean;
  56805. sideOrientation?: number;
  56806. frontUVs?: Vector4;
  56807. backUVs?: Vector4;
  56808. }, scene?: Nullable<Scene>): Mesh;
  56809. /**
  56810. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56811. * * 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
  56812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56813. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56814. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56815. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56817. * * 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
  56818. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56821. * @param name defines the name of the new line system
  56822. * @param options defines the options used to create the line system
  56823. * @param scene defines the hosting scene
  56824. * @returns a new line system mesh
  56825. */
  56826. static CreateLineSystem(name: string, options: {
  56827. lines: Vector3[][];
  56828. updatable?: boolean;
  56829. instance?: Nullable<LinesMesh>;
  56830. colors?: Nullable<Color4[][]>;
  56831. useVertexAlpha?: boolean;
  56832. }, scene: Nullable<Scene>): LinesMesh;
  56833. /**
  56834. * Creates a line mesh
  56835. * 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
  56836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56837. * * The parameter `points` is an array successive Vector3
  56838. * * 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
  56839. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56841. * * When updating an instance, remember that only point positions can change, not the number of points
  56842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56844. * @param name defines the name of the new line system
  56845. * @param options defines the options used to create the line system
  56846. * @param scene defines the hosting scene
  56847. * @returns a new line mesh
  56848. */
  56849. static CreateLines(name: string, options: {
  56850. points: Vector3[];
  56851. updatable?: boolean;
  56852. instance?: Nullable<LinesMesh>;
  56853. colors?: Color4[];
  56854. useVertexAlpha?: boolean;
  56855. }, scene?: Nullable<Scene>): LinesMesh;
  56856. /**
  56857. * Creates a dashed line mesh
  56858. * * 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
  56859. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56860. * * The parameter `points` is an array successive Vector3
  56861. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56862. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56863. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56864. * * 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
  56865. * * When updating an instance, remember that only point positions can change, not the number of points
  56866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56867. * @param name defines the name of the mesh
  56868. * @param options defines the options used to create the mesh
  56869. * @param scene defines the hosting scene
  56870. * @returns the dashed line mesh
  56871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56872. */
  56873. static CreateDashedLines(name: string, options: {
  56874. points: Vector3[];
  56875. dashSize?: number;
  56876. gapSize?: number;
  56877. dashNb?: number;
  56878. updatable?: boolean;
  56879. instance?: LinesMesh;
  56880. }, scene?: Nullable<Scene>): LinesMesh;
  56881. /**
  56882. * 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.
  56883. * * 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.
  56884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56885. * * 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.
  56886. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56887. * * 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
  56888. * * 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
  56889. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56891. * * 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
  56892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56894. * @param name defines the name of the mesh
  56895. * @param options defines the options used to create the mesh
  56896. * @param scene defines the hosting scene
  56897. * @returns the extruded shape mesh
  56898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56900. */
  56901. static ExtrudeShape(name: string, options: {
  56902. shape: Vector3[];
  56903. path: Vector3[];
  56904. scale?: number;
  56905. rotation?: number;
  56906. cap?: number;
  56907. updatable?: boolean;
  56908. sideOrientation?: number;
  56909. frontUVs?: Vector4;
  56910. backUVs?: Vector4;
  56911. instance?: Mesh;
  56912. invertUV?: boolean;
  56913. }, scene?: Nullable<Scene>): Mesh;
  56914. /**
  56915. * Creates an custom extruded shape mesh.
  56916. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56917. * * 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.
  56918. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56919. * * 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
  56920. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56921. * * 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
  56922. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56923. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56924. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56925. * * 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
  56926. * * 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
  56927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56929. * * 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
  56930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56932. * @param name defines the name of the mesh
  56933. * @param options defines the options used to create the mesh
  56934. * @param scene defines the hosting scene
  56935. * @returns the custom extruded shape mesh
  56936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56939. */
  56940. static ExtrudeShapeCustom(name: string, options: {
  56941. shape: Vector3[];
  56942. path: Vector3[];
  56943. scaleFunction?: any;
  56944. rotationFunction?: any;
  56945. ribbonCloseArray?: boolean;
  56946. ribbonClosePath?: boolean;
  56947. cap?: number;
  56948. updatable?: boolean;
  56949. sideOrientation?: number;
  56950. frontUVs?: Vector4;
  56951. backUVs?: Vector4;
  56952. instance?: Mesh;
  56953. invertUV?: boolean;
  56954. }, scene?: Nullable<Scene>): Mesh;
  56955. /**
  56956. * Creates lathe mesh.
  56957. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56958. * * 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
  56959. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56960. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56961. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56962. * * 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
  56963. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56964. * * 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
  56965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56966. * * 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
  56967. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56969. * @param name defines the name of the mesh
  56970. * @param options defines the options used to create the mesh
  56971. * @param scene defines the hosting scene
  56972. * @returns the lathe mesh
  56973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56974. */
  56975. static CreateLathe(name: string, options: {
  56976. shape: Vector3[];
  56977. radius?: number;
  56978. tessellation?: number;
  56979. clip?: number;
  56980. arc?: number;
  56981. closed?: boolean;
  56982. updatable?: boolean;
  56983. sideOrientation?: number;
  56984. frontUVs?: Vector4;
  56985. backUVs?: Vector4;
  56986. cap?: number;
  56987. invertUV?: boolean;
  56988. }, scene?: Nullable<Scene>): Mesh;
  56989. /**
  56990. * Creates a tiled plane mesh
  56991. * * You can set a limited pattern arrangement with the tiles
  56992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56993. * * 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
  56994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56995. * @param name defines the name of the mesh
  56996. * @param options defines the options used to create the mesh
  56997. * @param scene defines the hosting scene
  56998. * @returns the plane mesh
  56999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57000. */
  57001. static CreateTiledPlane(name: string, options: {
  57002. pattern?: number;
  57003. tileSize?: number;
  57004. tileWidth?: number;
  57005. tileHeight?: number;
  57006. size?: number;
  57007. width?: number;
  57008. height?: number;
  57009. alignHorizontal?: number;
  57010. alignVertical?: number;
  57011. sideOrientation?: number;
  57012. frontUVs?: Vector4;
  57013. backUVs?: Vector4;
  57014. updatable?: boolean;
  57015. }, scene?: Nullable<Scene>): Mesh;
  57016. /**
  57017. * Creates a plane mesh
  57018. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57019. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57020. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57022. * * 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
  57023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57024. * @param name defines the name of the mesh
  57025. * @param options defines the options used to create the mesh
  57026. * @param scene defines the hosting scene
  57027. * @returns the plane mesh
  57028. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57029. */
  57030. static CreatePlane(name: string, options: {
  57031. size?: number;
  57032. width?: number;
  57033. height?: number;
  57034. sideOrientation?: number;
  57035. frontUVs?: Vector4;
  57036. backUVs?: Vector4;
  57037. updatable?: boolean;
  57038. sourcePlane?: Plane;
  57039. }, scene?: Nullable<Scene>): Mesh;
  57040. /**
  57041. * Creates a ground mesh
  57042. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57043. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57045. * @param name defines the name of the mesh
  57046. * @param options defines the options used to create the mesh
  57047. * @param scene defines the hosting scene
  57048. * @returns the ground mesh
  57049. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57050. */
  57051. static CreateGround(name: string, options: {
  57052. width?: number;
  57053. height?: number;
  57054. subdivisions?: number;
  57055. subdivisionsX?: number;
  57056. subdivisionsY?: number;
  57057. updatable?: boolean;
  57058. }, scene?: Nullable<Scene>): Mesh;
  57059. /**
  57060. * Creates a tiled ground mesh
  57061. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57062. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57063. * * 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
  57064. * * 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
  57065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57066. * @param name defines the name of the mesh
  57067. * @param options defines the options used to create the mesh
  57068. * @param scene defines the hosting scene
  57069. * @returns the tiled ground mesh
  57070. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57071. */
  57072. static CreateTiledGround(name: string, options: {
  57073. xmin: number;
  57074. zmin: number;
  57075. xmax: number;
  57076. zmax: number;
  57077. subdivisions?: {
  57078. w: number;
  57079. h: number;
  57080. };
  57081. precision?: {
  57082. w: number;
  57083. h: number;
  57084. };
  57085. updatable?: boolean;
  57086. }, scene?: Nullable<Scene>): Mesh;
  57087. /**
  57088. * Creates a ground mesh from a height map
  57089. * * The parameter `url` sets the URL of the height map image resource.
  57090. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57091. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57092. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57093. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57094. * * 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.
  57095. * * 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).
  57096. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57098. * @param name defines the name of the mesh
  57099. * @param url defines the url to the height map
  57100. * @param options defines the options used to create the mesh
  57101. * @param scene defines the hosting scene
  57102. * @returns the ground mesh
  57103. * @see https://doc.babylonjs.com/babylon101/height_map
  57104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57105. */
  57106. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57107. width?: number;
  57108. height?: number;
  57109. subdivisions?: number;
  57110. minHeight?: number;
  57111. maxHeight?: number;
  57112. colorFilter?: Color3;
  57113. alphaFilter?: number;
  57114. updatable?: boolean;
  57115. onReady?: (mesh: GroundMesh) => void;
  57116. }, scene?: Nullable<Scene>): GroundMesh;
  57117. /**
  57118. * Creates a polygon mesh
  57119. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57120. * * 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
  57121. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57123. * * 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)
  57124. * * Remember you can only change the shape positions, not their number when updating a polygon
  57125. * @param name defines the name of the mesh
  57126. * @param options defines the options used to create the mesh
  57127. * @param scene defines the hosting scene
  57128. * @param earcutInjection can be used to inject your own earcut reference
  57129. * @returns the polygon mesh
  57130. */
  57131. static CreatePolygon(name: string, options: {
  57132. shape: Vector3[];
  57133. holes?: Vector3[][];
  57134. depth?: number;
  57135. faceUV?: Vector4[];
  57136. faceColors?: Color4[];
  57137. updatable?: boolean;
  57138. sideOrientation?: number;
  57139. frontUVs?: Vector4;
  57140. backUVs?: Vector4;
  57141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57142. /**
  57143. * Creates an extruded polygon mesh, with depth in the Y direction.
  57144. * * 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)
  57145. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57146. * @param name defines the name of the mesh
  57147. * @param options defines the options used to create the mesh
  57148. * @param scene defines the hosting scene
  57149. * @param earcutInjection can be used to inject your own earcut reference
  57150. * @returns the polygon mesh
  57151. */
  57152. static ExtrudePolygon(name: string, options: {
  57153. shape: Vector3[];
  57154. holes?: Vector3[][];
  57155. depth?: number;
  57156. faceUV?: Vector4[];
  57157. faceColors?: Color4[];
  57158. updatable?: boolean;
  57159. sideOrientation?: number;
  57160. frontUVs?: Vector4;
  57161. backUVs?: Vector4;
  57162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  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. * Creates a polyhedron mesh
  57203. * * 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
  57204. * * The parameter `size` (positive float, default 1) sets the polygon size
  57205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57206. * * 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`
  57207. * * 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
  57208. * * 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)`)
  57209. * * 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
  57210. * * 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
  57211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57212. * * 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
  57213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57214. * @param name defines the name of the mesh
  57215. * @param options defines the options used to create the mesh
  57216. * @param scene defines the hosting scene
  57217. * @returns the polyhedron mesh
  57218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57219. */
  57220. static CreatePolyhedron(name: string, options: {
  57221. type?: number;
  57222. size?: number;
  57223. sizeX?: number;
  57224. sizeY?: number;
  57225. sizeZ?: number;
  57226. custom?: any;
  57227. faceUV?: Vector4[];
  57228. faceColors?: Color4[];
  57229. flat?: boolean;
  57230. updatable?: boolean;
  57231. sideOrientation?: number;
  57232. frontUVs?: Vector4;
  57233. backUVs?: Vector4;
  57234. }, scene?: Nullable<Scene>): Mesh;
  57235. /**
  57236. * Creates a decal mesh.
  57237. * 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
  57238. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57239. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57240. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57241. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57242. * @param name defines the name of the mesh
  57243. * @param sourceMesh defines the mesh where the decal must be applied
  57244. * @param options defines the options used to create the mesh
  57245. * @param scene defines the hosting scene
  57246. * @returns the decal mesh
  57247. * @see https://doc.babylonjs.com/how_to/decals
  57248. */
  57249. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57250. position?: Vector3;
  57251. normal?: Vector3;
  57252. size?: Vector3;
  57253. angle?: number;
  57254. }): Mesh;
  57255. }
  57256. }
  57257. declare module BABYLON {
  57258. /**
  57259. * A simplifier interface for future simplification implementations
  57260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57261. */
  57262. export interface ISimplifier {
  57263. /**
  57264. * Simplification of a given mesh according to the given settings.
  57265. * Since this requires computation, it is assumed that the function runs async.
  57266. * @param settings The settings of the simplification, including quality and distance
  57267. * @param successCallback A callback that will be called after the mesh was simplified.
  57268. * @param errorCallback in case of an error, this callback will be called. optional.
  57269. */
  57270. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57271. }
  57272. /**
  57273. * Expected simplification settings.
  57274. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57275. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57276. */
  57277. export interface ISimplificationSettings {
  57278. /**
  57279. * Gets or sets the expected quality
  57280. */
  57281. quality: number;
  57282. /**
  57283. * Gets or sets the distance when this optimized version should be used
  57284. */
  57285. distance: number;
  57286. /**
  57287. * Gets an already optimized mesh
  57288. */
  57289. optimizeMesh?: boolean;
  57290. }
  57291. /**
  57292. * Class used to specify simplification options
  57293. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57294. */
  57295. export class SimplificationSettings implements ISimplificationSettings {
  57296. /** expected quality */
  57297. quality: number;
  57298. /** distance when this optimized version should be used */
  57299. distance: number;
  57300. /** already optimized mesh */
  57301. optimizeMesh?: boolean | undefined;
  57302. /**
  57303. * Creates a SimplificationSettings
  57304. * @param quality expected quality
  57305. * @param distance distance when this optimized version should be used
  57306. * @param optimizeMesh already optimized mesh
  57307. */
  57308. constructor(
  57309. /** expected quality */
  57310. quality: number,
  57311. /** distance when this optimized version should be used */
  57312. distance: number,
  57313. /** already optimized mesh */
  57314. optimizeMesh?: boolean | undefined);
  57315. }
  57316. /**
  57317. * Interface used to define a simplification task
  57318. */
  57319. export interface ISimplificationTask {
  57320. /**
  57321. * Array of settings
  57322. */
  57323. settings: Array<ISimplificationSettings>;
  57324. /**
  57325. * Simplification type
  57326. */
  57327. simplificationType: SimplificationType;
  57328. /**
  57329. * Mesh to simplify
  57330. */
  57331. mesh: Mesh;
  57332. /**
  57333. * Callback called on success
  57334. */
  57335. successCallback?: () => void;
  57336. /**
  57337. * Defines if parallel processing can be used
  57338. */
  57339. parallelProcessing: boolean;
  57340. }
  57341. /**
  57342. * Queue used to order the simplification tasks
  57343. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57344. */
  57345. export class SimplificationQueue {
  57346. private _simplificationArray;
  57347. /**
  57348. * Gets a boolean indicating that the process is still running
  57349. */
  57350. running: boolean;
  57351. /**
  57352. * Creates a new queue
  57353. */
  57354. constructor();
  57355. /**
  57356. * Adds a new simplification task
  57357. * @param task defines a task to add
  57358. */
  57359. addTask(task: ISimplificationTask): void;
  57360. /**
  57361. * Execute next task
  57362. */
  57363. executeNext(): void;
  57364. /**
  57365. * Execute a simplification task
  57366. * @param task defines the task to run
  57367. */
  57368. runSimplification(task: ISimplificationTask): void;
  57369. private getSimplifier;
  57370. }
  57371. /**
  57372. * The implemented types of simplification
  57373. * At the moment only Quadratic Error Decimation is implemented
  57374. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57375. */
  57376. export enum SimplificationType {
  57377. /** Quadratic error decimation */
  57378. QUADRATIC = 0
  57379. }
  57380. }
  57381. declare module BABYLON {
  57382. interface Scene {
  57383. /** @hidden (Backing field) */
  57384. _simplificationQueue: SimplificationQueue;
  57385. /**
  57386. * Gets or sets the simplification queue attached to the scene
  57387. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57388. */
  57389. simplificationQueue: SimplificationQueue;
  57390. }
  57391. interface Mesh {
  57392. /**
  57393. * Simplify the mesh according to the given array of settings.
  57394. * Function will return immediately and will simplify async
  57395. * @param settings a collection of simplification settings
  57396. * @param parallelProcessing should all levels calculate parallel or one after the other
  57397. * @param simplificationType the type of simplification to run
  57398. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57399. * @returns the current mesh
  57400. */
  57401. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57402. }
  57403. /**
  57404. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57405. * created in a scene
  57406. */
  57407. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57408. /**
  57409. * The component name helpfull to identify the component in the list of scene components.
  57410. */
  57411. readonly name: string;
  57412. /**
  57413. * The scene the component belongs to.
  57414. */
  57415. scene: Scene;
  57416. /**
  57417. * Creates a new instance of the component for the given scene
  57418. * @param scene Defines the scene to register the component in
  57419. */
  57420. constructor(scene: Scene);
  57421. /**
  57422. * Registers the component in a given scene
  57423. */
  57424. register(): void;
  57425. /**
  57426. * Rebuilds the elements related to this component in case of
  57427. * context lost for instance.
  57428. */
  57429. rebuild(): void;
  57430. /**
  57431. * Disposes the component and the associated ressources
  57432. */
  57433. dispose(): void;
  57434. private _beforeCameraUpdate;
  57435. }
  57436. }
  57437. declare module BABYLON {
  57438. /**
  57439. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57440. */
  57441. export interface INavigationEnginePlugin {
  57442. /**
  57443. * plugin name
  57444. */
  57445. name: string;
  57446. /**
  57447. * Creates a navigation mesh
  57448. * @param meshes array of all the geometry used to compute the navigatio mesh
  57449. * @param parameters bunch of parameters used to filter geometry
  57450. */
  57451. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57452. /**
  57453. * Create a navigation mesh debug mesh
  57454. * @param scene is where the mesh will be added
  57455. * @returns debug display mesh
  57456. */
  57457. createDebugNavMesh(scene: Scene): Mesh;
  57458. /**
  57459. * Get a navigation mesh constrained position, closest to the parameter position
  57460. * @param position world position
  57461. * @returns the closest point to position constrained by the navigation mesh
  57462. */
  57463. getClosestPoint(position: Vector3): Vector3;
  57464. /**
  57465. * Get a navigation mesh constrained position, within a particular radius
  57466. * @param position world position
  57467. * @param maxRadius the maximum distance to the constrained world position
  57468. * @returns the closest point to position constrained by the navigation mesh
  57469. */
  57470. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57471. /**
  57472. * Compute the final position from a segment made of destination-position
  57473. * @param position world position
  57474. * @param destination world position
  57475. * @returns the resulting point along the navmesh
  57476. */
  57477. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57478. /**
  57479. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57480. * @param start world position
  57481. * @param end world position
  57482. * @returns array containing world position composing the path
  57483. */
  57484. computePath(start: Vector3, end: Vector3): Vector3[];
  57485. /**
  57486. * If this plugin is supported
  57487. * @returns true if plugin is supported
  57488. */
  57489. isSupported(): boolean;
  57490. /**
  57491. * Create a new Crowd so you can add agents
  57492. * @param maxAgents the maximum agent count in the crowd
  57493. * @param maxAgentRadius the maximum radius an agent can have
  57494. * @param scene to attach the crowd to
  57495. * @returns the crowd you can add agents to
  57496. */
  57497. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57498. /**
  57499. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57500. * The queries will try to find a solution within those bounds
  57501. * default is (1,1,1)
  57502. * @param extent x,y,z value that define the extent around the queries point of reference
  57503. */
  57504. setDefaultQueryExtent(extent: Vector3): void;
  57505. /**
  57506. * Get the Bounding box extent specified by setDefaultQueryExtent
  57507. * @returns the box extent values
  57508. */
  57509. getDefaultQueryExtent(): Vector3;
  57510. /**
  57511. * Release all resources
  57512. */
  57513. dispose(): void;
  57514. }
  57515. /**
  57516. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57517. */
  57518. export interface ICrowd {
  57519. /**
  57520. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57521. * You can attach anything to that node. The node position is updated in the scene update tick.
  57522. * @param pos world position that will be constrained by the navigation mesh
  57523. * @param parameters agent parameters
  57524. * @param transform hooked to the agent that will be update by the scene
  57525. * @returns agent index
  57526. */
  57527. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57528. /**
  57529. * Returns the agent position in world space
  57530. * @param index agent index returned by addAgent
  57531. * @returns world space position
  57532. */
  57533. getAgentPosition(index: number): Vector3;
  57534. /**
  57535. * Gets the agent velocity in world space
  57536. * @param index agent index returned by addAgent
  57537. * @returns world space velocity
  57538. */
  57539. getAgentVelocity(index: number): Vector3;
  57540. /**
  57541. * remove a particular agent previously created
  57542. * @param index agent index returned by addAgent
  57543. */
  57544. removeAgent(index: number): void;
  57545. /**
  57546. * get the list of all agents attached to this crowd
  57547. * @returns list of agent indices
  57548. */
  57549. getAgents(): number[];
  57550. /**
  57551. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57552. * @param deltaTime in seconds
  57553. */
  57554. update(deltaTime: number): void;
  57555. /**
  57556. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57557. * @param index agent index returned by addAgent
  57558. * @param destination targeted world position
  57559. */
  57560. agentGoto(index: number, destination: Vector3): void;
  57561. /**
  57562. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57563. * The queries will try to find a solution within those bounds
  57564. * default is (1,1,1)
  57565. * @param extent x,y,z value that define the extent around the queries point of reference
  57566. */
  57567. setDefaultQueryExtent(extent: Vector3): void;
  57568. /**
  57569. * Get the Bounding box extent specified by setDefaultQueryExtent
  57570. * @returns the box extent values
  57571. */
  57572. getDefaultQueryExtent(): Vector3;
  57573. /**
  57574. * Release all resources
  57575. */
  57576. dispose(): void;
  57577. }
  57578. /**
  57579. * Configures an agent
  57580. */
  57581. export interface IAgentParameters {
  57582. /**
  57583. * Agent radius. [Limit: >= 0]
  57584. */
  57585. radius: number;
  57586. /**
  57587. * Agent height. [Limit: > 0]
  57588. */
  57589. height: number;
  57590. /**
  57591. * Maximum allowed acceleration. [Limit: >= 0]
  57592. */
  57593. maxAcceleration: number;
  57594. /**
  57595. * Maximum allowed speed. [Limit: >= 0]
  57596. */
  57597. maxSpeed: number;
  57598. /**
  57599. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57600. */
  57601. collisionQueryRange: number;
  57602. /**
  57603. * The path visibility optimization range. [Limit: > 0]
  57604. */
  57605. pathOptimizationRange: number;
  57606. /**
  57607. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57608. */
  57609. separationWeight: number;
  57610. }
  57611. /**
  57612. * Configures the navigation mesh creation
  57613. */
  57614. export interface INavMeshParameters {
  57615. /**
  57616. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57617. */
  57618. cs: number;
  57619. /**
  57620. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57621. */
  57622. ch: number;
  57623. /**
  57624. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57625. */
  57626. walkableSlopeAngle: number;
  57627. /**
  57628. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57629. * be considered walkable. [Limit: >= 3] [Units: vx]
  57630. */
  57631. walkableHeight: number;
  57632. /**
  57633. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57634. */
  57635. walkableClimb: number;
  57636. /**
  57637. * The distance to erode/shrink the walkable area of the heightfield away from
  57638. * obstructions. [Limit: >=0] [Units: vx]
  57639. */
  57640. walkableRadius: number;
  57641. /**
  57642. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57643. */
  57644. maxEdgeLen: number;
  57645. /**
  57646. * The maximum distance a simplfied contour's border edges should deviate
  57647. * the original raw contour. [Limit: >=0] [Units: vx]
  57648. */
  57649. maxSimplificationError: number;
  57650. /**
  57651. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57652. */
  57653. minRegionArea: number;
  57654. /**
  57655. * Any regions with a span count smaller than this value will, if possible,
  57656. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57657. */
  57658. mergeRegionArea: number;
  57659. /**
  57660. * The maximum number of vertices allowed for polygons generated during the
  57661. * contour to polygon conversion process. [Limit: >= 3]
  57662. */
  57663. maxVertsPerPoly: number;
  57664. /**
  57665. * Sets the sampling distance to use when generating the detail mesh.
  57666. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57667. */
  57668. detailSampleDist: number;
  57669. /**
  57670. * The maximum distance the detail mesh surface should deviate from heightfield
  57671. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57672. */
  57673. detailSampleMaxError: number;
  57674. }
  57675. }
  57676. declare module BABYLON {
  57677. /**
  57678. * RecastJS navigation plugin
  57679. */
  57680. export class RecastJSPlugin implements INavigationEnginePlugin {
  57681. /**
  57682. * Reference to the Recast library
  57683. */
  57684. bjsRECAST: any;
  57685. /**
  57686. * plugin name
  57687. */
  57688. name: string;
  57689. /**
  57690. * the first navmesh created. We might extend this to support multiple navmeshes
  57691. */
  57692. navMesh: any;
  57693. /**
  57694. * Initializes the recastJS plugin
  57695. * @param recastInjection can be used to inject your own recast reference
  57696. */
  57697. constructor(recastInjection?: any);
  57698. /**
  57699. * Creates a navigation mesh
  57700. * @param meshes array of all the geometry used to compute the navigatio mesh
  57701. * @param parameters bunch of parameters used to filter geometry
  57702. */
  57703. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57704. /**
  57705. * Create a navigation mesh debug mesh
  57706. * @param scene is where the mesh will be added
  57707. * @returns debug display mesh
  57708. */
  57709. createDebugNavMesh(scene: Scene): Mesh;
  57710. /**
  57711. * Get a navigation mesh constrained position, closest to the parameter position
  57712. * @param position world position
  57713. * @returns the closest point to position constrained by the navigation mesh
  57714. */
  57715. getClosestPoint(position: Vector3): Vector3;
  57716. /**
  57717. * Get a navigation mesh constrained position, within a particular radius
  57718. * @param position world position
  57719. * @param maxRadius the maximum distance to the constrained world position
  57720. * @returns the closest point to position constrained by the navigation mesh
  57721. */
  57722. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57723. /**
  57724. * Compute the final position from a segment made of destination-position
  57725. * @param position world position
  57726. * @param destination world position
  57727. * @returns the resulting point along the navmesh
  57728. */
  57729. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57730. /**
  57731. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57732. * @param start world position
  57733. * @param end world position
  57734. * @returns array containing world position composing the path
  57735. */
  57736. computePath(start: Vector3, end: Vector3): Vector3[];
  57737. /**
  57738. * Create a new Crowd so you can add agents
  57739. * @param maxAgents the maximum agent count in the crowd
  57740. * @param maxAgentRadius the maximum radius an agent can have
  57741. * @param scene to attach the crowd to
  57742. * @returns the crowd you can add agents to
  57743. */
  57744. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57745. /**
  57746. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57747. * The queries will try to find a solution within those bounds
  57748. * default is (1,1,1)
  57749. * @param extent x,y,z value that define the extent around the queries point of reference
  57750. */
  57751. setDefaultQueryExtent(extent: Vector3): void;
  57752. /**
  57753. * Get the Bounding box extent specified by setDefaultQueryExtent
  57754. * @returns the box extent values
  57755. */
  57756. getDefaultQueryExtent(): Vector3;
  57757. /**
  57758. * Disposes
  57759. */
  57760. dispose(): void;
  57761. /**
  57762. * If this plugin is supported
  57763. * @returns true if plugin is supported
  57764. */
  57765. isSupported(): boolean;
  57766. }
  57767. /**
  57768. * Recast detour crowd implementation
  57769. */
  57770. export class RecastJSCrowd implements ICrowd {
  57771. /**
  57772. * Recast/detour plugin
  57773. */
  57774. bjsRECASTPlugin: RecastJSPlugin;
  57775. /**
  57776. * Link to the detour crowd
  57777. */
  57778. recastCrowd: any;
  57779. /**
  57780. * One transform per agent
  57781. */
  57782. transforms: TransformNode[];
  57783. /**
  57784. * All agents created
  57785. */
  57786. agents: number[];
  57787. /**
  57788. * Link to the scene is kept to unregister the crowd from the scene
  57789. */
  57790. private _scene;
  57791. /**
  57792. * Observer for crowd updates
  57793. */
  57794. private _onBeforeAnimationsObserver;
  57795. /**
  57796. * Constructor
  57797. * @param plugin recastJS plugin
  57798. * @param maxAgents the maximum agent count in the crowd
  57799. * @param maxAgentRadius the maximum radius an agent can have
  57800. * @param scene to attach the crowd to
  57801. * @returns the crowd you can add agents to
  57802. */
  57803. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57804. /**
  57805. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57806. * You can attach anything to that node. The node position is updated in the scene update tick.
  57807. * @param pos world position that will be constrained by the navigation mesh
  57808. * @param parameters agent parameters
  57809. * @param transform hooked to the agent that will be update by the scene
  57810. * @returns agent index
  57811. */
  57812. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57813. /**
  57814. * Returns the agent position in world space
  57815. * @param index agent index returned by addAgent
  57816. * @returns world space position
  57817. */
  57818. getAgentPosition(index: number): Vector3;
  57819. /**
  57820. * Returns the agent velocity in world space
  57821. * @param index agent index returned by addAgent
  57822. * @returns world space velocity
  57823. */
  57824. getAgentVelocity(index: number): Vector3;
  57825. /**
  57826. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57827. * @param index agent index returned by addAgent
  57828. * @param destination targeted world position
  57829. */
  57830. agentGoto(index: number, destination: Vector3): void;
  57831. /**
  57832. * remove a particular agent previously created
  57833. * @param index agent index returned by addAgent
  57834. */
  57835. removeAgent(index: number): void;
  57836. /**
  57837. * get the list of all agents attached to this crowd
  57838. * @returns list of agent indices
  57839. */
  57840. getAgents(): number[];
  57841. /**
  57842. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57843. * @param deltaTime in seconds
  57844. */
  57845. update(deltaTime: number): void;
  57846. /**
  57847. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57848. * The queries will try to find a solution within those bounds
  57849. * default is (1,1,1)
  57850. * @param extent x,y,z value that define the extent around the queries point of reference
  57851. */
  57852. setDefaultQueryExtent(extent: Vector3): void;
  57853. /**
  57854. * Get the Bounding box extent specified by setDefaultQueryExtent
  57855. * @returns the box extent values
  57856. */
  57857. getDefaultQueryExtent(): Vector3;
  57858. /**
  57859. * Release all resources
  57860. */
  57861. dispose(): void;
  57862. }
  57863. }
  57864. declare module BABYLON {
  57865. /**
  57866. * Class used to enable access to IndexedDB
  57867. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57868. */
  57869. export class Database implements IOfflineProvider {
  57870. private _callbackManifestChecked;
  57871. private _currentSceneUrl;
  57872. private _db;
  57873. private _enableSceneOffline;
  57874. private _enableTexturesOffline;
  57875. private _manifestVersionFound;
  57876. private _mustUpdateRessources;
  57877. private _hasReachedQuota;
  57878. private _isSupported;
  57879. private _idbFactory;
  57880. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57881. private static IsUASupportingBlobStorage;
  57882. /**
  57883. * Gets a boolean indicating if Database storate is enabled (off by default)
  57884. */
  57885. static IDBStorageEnabled: boolean;
  57886. /**
  57887. * Gets a boolean indicating if scene must be saved in the database
  57888. */
  57889. readonly enableSceneOffline: boolean;
  57890. /**
  57891. * Gets a boolean indicating if textures must be saved in the database
  57892. */
  57893. readonly enableTexturesOffline: boolean;
  57894. /**
  57895. * Creates a new Database
  57896. * @param urlToScene defines the url to load the scene
  57897. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57898. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57899. */
  57900. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57901. private static _ParseURL;
  57902. private static _ReturnFullUrlLocation;
  57903. private _checkManifestFile;
  57904. /**
  57905. * Open the database and make it available
  57906. * @param successCallback defines the callback to call on success
  57907. * @param errorCallback defines the callback to call on error
  57908. */
  57909. open(successCallback: () => void, errorCallback: () => void): void;
  57910. /**
  57911. * Loads an image from the database
  57912. * @param url defines the url to load from
  57913. * @param image defines the target DOM image
  57914. */
  57915. loadImage(url: string, image: HTMLImageElement): void;
  57916. private _loadImageFromDBAsync;
  57917. private _saveImageIntoDBAsync;
  57918. private _checkVersionFromDB;
  57919. private _loadVersionFromDBAsync;
  57920. private _saveVersionIntoDBAsync;
  57921. /**
  57922. * Loads a file from database
  57923. * @param url defines the URL to load from
  57924. * @param sceneLoaded defines a callback to call on success
  57925. * @param progressCallBack defines a callback to call when progress changed
  57926. * @param errorCallback defines a callback to call on error
  57927. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57928. */
  57929. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57930. private _loadFileAsync;
  57931. private _saveFileAsync;
  57932. /**
  57933. * Validates if xhr data is correct
  57934. * @param xhr defines the request to validate
  57935. * @param dataType defines the expected data type
  57936. * @returns true if data is correct
  57937. */
  57938. private static _ValidateXHRData;
  57939. }
  57940. }
  57941. declare module BABYLON {
  57942. /** @hidden */
  57943. export var gpuUpdateParticlesPixelShader: {
  57944. name: string;
  57945. shader: string;
  57946. };
  57947. }
  57948. declare module BABYLON {
  57949. /** @hidden */
  57950. export var gpuUpdateParticlesVertexShader: {
  57951. name: string;
  57952. shader: string;
  57953. };
  57954. }
  57955. declare module BABYLON {
  57956. /** @hidden */
  57957. export var clipPlaneFragmentDeclaration2: {
  57958. name: string;
  57959. shader: string;
  57960. };
  57961. }
  57962. declare module BABYLON {
  57963. /** @hidden */
  57964. export var gpuRenderParticlesPixelShader: {
  57965. name: string;
  57966. shader: string;
  57967. };
  57968. }
  57969. declare module BABYLON {
  57970. /** @hidden */
  57971. export var clipPlaneVertexDeclaration2: {
  57972. name: string;
  57973. shader: string;
  57974. };
  57975. }
  57976. declare module BABYLON {
  57977. /** @hidden */
  57978. export var gpuRenderParticlesVertexShader: {
  57979. name: string;
  57980. shader: string;
  57981. };
  57982. }
  57983. declare module BABYLON {
  57984. /**
  57985. * This represents a GPU particle system in Babylon
  57986. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57987. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57988. */
  57989. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57990. /**
  57991. * The layer mask we are rendering the particles through.
  57992. */
  57993. layerMask: number;
  57994. private _capacity;
  57995. private _activeCount;
  57996. private _currentActiveCount;
  57997. private _accumulatedCount;
  57998. private _renderEffect;
  57999. private _updateEffect;
  58000. private _buffer0;
  58001. private _buffer1;
  58002. private _spriteBuffer;
  58003. private _updateVAO;
  58004. private _renderVAO;
  58005. private _targetIndex;
  58006. private _sourceBuffer;
  58007. private _targetBuffer;
  58008. private _engine;
  58009. private _currentRenderId;
  58010. private _started;
  58011. private _stopped;
  58012. private _timeDelta;
  58013. private _randomTexture;
  58014. private _randomTexture2;
  58015. private _attributesStrideSize;
  58016. private _updateEffectOptions;
  58017. private _randomTextureSize;
  58018. private _actualFrame;
  58019. private readonly _rawTextureWidth;
  58020. /**
  58021. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58022. */
  58023. static readonly IsSupported: boolean;
  58024. /**
  58025. * An event triggered when the system is disposed.
  58026. */
  58027. onDisposeObservable: Observable<GPUParticleSystem>;
  58028. /**
  58029. * Gets the maximum number of particles active at the same time.
  58030. * @returns The max number of active particles.
  58031. */
  58032. getCapacity(): number;
  58033. /**
  58034. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58035. * to override the particles.
  58036. */
  58037. forceDepthWrite: boolean;
  58038. /**
  58039. * Gets or set the number of active particles
  58040. */
  58041. activeParticleCount: number;
  58042. private _preWarmDone;
  58043. /**
  58044. * Is this system ready to be used/rendered
  58045. * @return true if the system is ready
  58046. */
  58047. isReady(): boolean;
  58048. /**
  58049. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58050. * @returns True if it has been started, otherwise false.
  58051. */
  58052. isStarted(): boolean;
  58053. /**
  58054. * Starts the particle system and begins to emit
  58055. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58056. */
  58057. start(delay?: number): void;
  58058. /**
  58059. * Stops the particle system.
  58060. */
  58061. stop(): void;
  58062. /**
  58063. * Remove all active particles
  58064. */
  58065. reset(): void;
  58066. /**
  58067. * Returns the string "GPUParticleSystem"
  58068. * @returns a string containing the class name
  58069. */
  58070. getClassName(): string;
  58071. private _colorGradientsTexture;
  58072. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58073. /**
  58074. * Adds a new color gradient
  58075. * @param gradient defines the gradient to use (between 0 and 1)
  58076. * @param color1 defines the color to affect to the specified gradient
  58077. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58078. * @returns the current particle system
  58079. */
  58080. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58081. /**
  58082. * Remove a specific color gradient
  58083. * @param gradient defines the gradient to remove
  58084. * @returns the current particle system
  58085. */
  58086. removeColorGradient(gradient: number): GPUParticleSystem;
  58087. private _angularSpeedGradientsTexture;
  58088. private _sizeGradientsTexture;
  58089. private _velocityGradientsTexture;
  58090. private _limitVelocityGradientsTexture;
  58091. private _dragGradientsTexture;
  58092. private _addFactorGradient;
  58093. /**
  58094. * Adds a new size gradient
  58095. * @param gradient defines the gradient to use (between 0 and 1)
  58096. * @param factor defines the size factor to affect to the specified gradient
  58097. * @returns the current particle system
  58098. */
  58099. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58100. /**
  58101. * Remove a specific size gradient
  58102. * @param gradient defines the gradient to remove
  58103. * @returns the current particle system
  58104. */
  58105. removeSizeGradient(gradient: number): GPUParticleSystem;
  58106. /**
  58107. * Adds a new angular speed gradient
  58108. * @param gradient defines the gradient to use (between 0 and 1)
  58109. * @param factor defines the angular speed to affect to the specified gradient
  58110. * @returns the current particle system
  58111. */
  58112. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58113. /**
  58114. * Remove a specific angular speed gradient
  58115. * @param gradient defines the gradient to remove
  58116. * @returns the current particle system
  58117. */
  58118. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58119. /**
  58120. * Adds a new velocity gradient
  58121. * @param gradient defines the gradient to use (between 0 and 1)
  58122. * @param factor defines the velocity to affect to the specified gradient
  58123. * @returns the current particle system
  58124. */
  58125. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58126. /**
  58127. * Remove a specific velocity gradient
  58128. * @param gradient defines the gradient to remove
  58129. * @returns the current particle system
  58130. */
  58131. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58132. /**
  58133. * Adds a new limit velocity gradient
  58134. * @param gradient defines the gradient to use (between 0 and 1)
  58135. * @param factor defines the limit velocity value to affect to the specified gradient
  58136. * @returns the current particle system
  58137. */
  58138. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58139. /**
  58140. * Remove a specific limit velocity gradient
  58141. * @param gradient defines the gradient to remove
  58142. * @returns the current particle system
  58143. */
  58144. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58145. /**
  58146. * Adds a new drag gradient
  58147. * @param gradient defines the gradient to use (between 0 and 1)
  58148. * @param factor defines the drag value to affect to the specified gradient
  58149. * @returns the current particle system
  58150. */
  58151. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58152. /**
  58153. * Remove a specific drag gradient
  58154. * @param gradient defines the gradient to remove
  58155. * @returns the current particle system
  58156. */
  58157. removeDragGradient(gradient: number): GPUParticleSystem;
  58158. /**
  58159. * Not supported by GPUParticleSystem
  58160. * @param gradient defines the gradient to use (between 0 and 1)
  58161. * @param factor defines the emit rate value to affect to the specified gradient
  58162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58163. * @returns the current particle system
  58164. */
  58165. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58166. /**
  58167. * Not supported by GPUParticleSystem
  58168. * @param gradient defines the gradient to remove
  58169. * @returns the current particle system
  58170. */
  58171. removeEmitRateGradient(gradient: number): IParticleSystem;
  58172. /**
  58173. * Not supported by GPUParticleSystem
  58174. * @param gradient defines the gradient to use (between 0 and 1)
  58175. * @param factor defines the start size value to affect to the specified gradient
  58176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58177. * @returns the current particle system
  58178. */
  58179. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58180. /**
  58181. * Not supported by GPUParticleSystem
  58182. * @param gradient defines the gradient to remove
  58183. * @returns the current particle system
  58184. */
  58185. removeStartSizeGradient(gradient: number): IParticleSystem;
  58186. /**
  58187. * Not supported by GPUParticleSystem
  58188. * @param gradient defines the gradient to use (between 0 and 1)
  58189. * @param min defines the color remap minimal range
  58190. * @param max defines the color remap maximal range
  58191. * @returns the current particle system
  58192. */
  58193. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58194. /**
  58195. * Not supported by GPUParticleSystem
  58196. * @param gradient defines the gradient to remove
  58197. * @returns the current particle system
  58198. */
  58199. removeColorRemapGradient(): IParticleSystem;
  58200. /**
  58201. * Not supported by GPUParticleSystem
  58202. * @param gradient defines the gradient to use (between 0 and 1)
  58203. * @param min defines the alpha remap minimal range
  58204. * @param max defines the alpha remap maximal range
  58205. * @returns the current particle system
  58206. */
  58207. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58208. /**
  58209. * Not supported by GPUParticleSystem
  58210. * @param gradient defines the gradient to remove
  58211. * @returns the current particle system
  58212. */
  58213. removeAlphaRemapGradient(): IParticleSystem;
  58214. /**
  58215. * Not supported by GPUParticleSystem
  58216. * @param gradient defines the gradient to use (between 0 and 1)
  58217. * @param color defines the color to affect to the specified gradient
  58218. * @returns the current particle system
  58219. */
  58220. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58221. /**
  58222. * Not supported by GPUParticleSystem
  58223. * @param gradient defines the gradient to remove
  58224. * @returns the current particle system
  58225. */
  58226. removeRampGradient(): IParticleSystem;
  58227. /**
  58228. * Not supported by GPUParticleSystem
  58229. * @returns the list of ramp gradients
  58230. */
  58231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58232. /**
  58233. * Not supported by GPUParticleSystem
  58234. * Gets or sets a boolean indicating that ramp gradients must be used
  58235. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58236. */
  58237. useRampGradients: boolean;
  58238. /**
  58239. * Not supported by GPUParticleSystem
  58240. * @param gradient defines the gradient to use (between 0 and 1)
  58241. * @param factor defines the life time factor to affect to the specified gradient
  58242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58243. * @returns the current particle system
  58244. */
  58245. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58246. /**
  58247. * Not supported by GPUParticleSystem
  58248. * @param gradient defines the gradient to remove
  58249. * @returns the current particle system
  58250. */
  58251. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58252. /**
  58253. * Instantiates a GPU particle system.
  58254. * 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.
  58255. * @param name The name of the particle system
  58256. * @param options The options used to create the system
  58257. * @param scene The scene the particle system belongs to
  58258. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58259. */
  58260. constructor(name: string, options: Partial<{
  58261. capacity: number;
  58262. randomTextureSize: number;
  58263. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58264. protected _reset(): void;
  58265. private _createUpdateVAO;
  58266. private _createRenderVAO;
  58267. private _initialize;
  58268. /** @hidden */
  58269. _recreateUpdateEffect(): void;
  58270. /** @hidden */
  58271. _recreateRenderEffect(): void;
  58272. /**
  58273. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58274. * @param preWarm defines if we are in the pre-warmimg phase
  58275. */
  58276. animate(preWarm?: boolean): void;
  58277. private _createFactorGradientTexture;
  58278. private _createSizeGradientTexture;
  58279. private _createAngularSpeedGradientTexture;
  58280. private _createVelocityGradientTexture;
  58281. private _createLimitVelocityGradientTexture;
  58282. private _createDragGradientTexture;
  58283. private _createColorGradientTexture;
  58284. /**
  58285. * Renders the particle system in its current state
  58286. * @param preWarm defines if the system should only update the particles but not render them
  58287. * @returns the current number of particles
  58288. */
  58289. render(preWarm?: boolean): number;
  58290. /**
  58291. * Rebuilds the particle system
  58292. */
  58293. rebuild(): void;
  58294. private _releaseBuffers;
  58295. private _releaseVAOs;
  58296. /**
  58297. * Disposes the particle system and free the associated resources
  58298. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58299. */
  58300. dispose(disposeTexture?: boolean): void;
  58301. /**
  58302. * Clones the particle system.
  58303. * @param name The name of the cloned object
  58304. * @param newEmitter The new emitter to use
  58305. * @returns the cloned particle system
  58306. */
  58307. clone(name: string, newEmitter: any): GPUParticleSystem;
  58308. /**
  58309. * Serializes the particle system to a JSON object.
  58310. * @returns the JSON object
  58311. */
  58312. serialize(): any;
  58313. /**
  58314. * Parses a JSON object to create a GPU particle system.
  58315. * @param parsedParticleSystem The JSON object to parse
  58316. * @param scene The scene to create the particle system in
  58317. * @param rootUrl The root url to use to load external dependencies like texture
  58318. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58319. * @returns the parsed GPU particle system
  58320. */
  58321. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58322. }
  58323. }
  58324. declare module BABYLON {
  58325. /**
  58326. * Represents a set of particle systems working together to create a specific effect
  58327. */
  58328. export class ParticleSystemSet implements IDisposable {
  58329. /**
  58330. * Gets or sets base Assets URL
  58331. */
  58332. static BaseAssetsUrl: string;
  58333. private _emitterCreationOptions;
  58334. private _emitterNode;
  58335. /**
  58336. * Gets the particle system list
  58337. */
  58338. systems: IParticleSystem[];
  58339. /**
  58340. * Gets the emitter node used with this set
  58341. */
  58342. readonly emitterNode: Nullable<TransformNode>;
  58343. /**
  58344. * Creates a new emitter mesh as a sphere
  58345. * @param options defines the options used to create the sphere
  58346. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58347. * @param scene defines the hosting scene
  58348. */
  58349. setEmitterAsSphere(options: {
  58350. diameter: number;
  58351. segments: number;
  58352. color: Color3;
  58353. }, renderingGroupId: number, scene: Scene): void;
  58354. /**
  58355. * Starts all particle systems of the set
  58356. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58357. */
  58358. start(emitter?: AbstractMesh): void;
  58359. /**
  58360. * Release all associated resources
  58361. */
  58362. dispose(): void;
  58363. /**
  58364. * Serialize the set into a JSON compatible object
  58365. * @returns a JSON compatible representation of the set
  58366. */
  58367. serialize(): any;
  58368. /**
  58369. * Parse a new ParticleSystemSet from a serialized source
  58370. * @param data defines a JSON compatible representation of the set
  58371. * @param scene defines the hosting scene
  58372. * @param gpu defines if we want GPU particles or CPU particles
  58373. * @returns a new ParticleSystemSet
  58374. */
  58375. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58376. }
  58377. }
  58378. declare module BABYLON {
  58379. /**
  58380. * This class is made for on one-liner static method to help creating particle system set.
  58381. */
  58382. export class ParticleHelper {
  58383. /**
  58384. * Gets or sets base Assets URL
  58385. */
  58386. static BaseAssetsUrl: string;
  58387. /**
  58388. * Create a default particle system that you can tweak
  58389. * @param emitter defines the emitter to use
  58390. * @param capacity defines the system capacity (default is 500 particles)
  58391. * @param scene defines the hosting scene
  58392. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58393. * @returns the new Particle system
  58394. */
  58395. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58396. /**
  58397. * This is the main static method (one-liner) of this helper to create different particle systems
  58398. * @param type This string represents the type to the particle system to create
  58399. * @param scene The scene where the particle system should live
  58400. * @param gpu If the system will use gpu
  58401. * @returns the ParticleSystemSet created
  58402. */
  58403. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58404. /**
  58405. * Static function used to export a particle system to a ParticleSystemSet variable.
  58406. * Please note that the emitter shape is not exported
  58407. * @param systems defines the particle systems to export
  58408. * @returns the created particle system set
  58409. */
  58410. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58411. }
  58412. }
  58413. declare module BABYLON {
  58414. interface Engine {
  58415. /**
  58416. * Create an effect to use with particle systems.
  58417. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58418. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58419. * @param uniformsNames defines a list of attribute names
  58420. * @param samplers defines an array of string used to represent textures
  58421. * @param defines defines the string containing the defines to use to compile the shaders
  58422. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58423. * @param onCompiled defines a function to call when the effect creation is successful
  58424. * @param onError defines a function to call when the effect creation has failed
  58425. * @returns the new Effect
  58426. */
  58427. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58428. }
  58429. interface Mesh {
  58430. /**
  58431. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58432. * @returns an array of IParticleSystem
  58433. */
  58434. getEmittedParticleSystems(): IParticleSystem[];
  58435. /**
  58436. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58437. * @returns an array of IParticleSystem
  58438. */
  58439. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58440. }
  58441. /**
  58442. * @hidden
  58443. */
  58444. export var _IDoNeedToBeInTheBuild: number;
  58445. }
  58446. declare module BABYLON {
  58447. /** Defines the 4 color options */
  58448. export enum PointColor {
  58449. /** color value */
  58450. Color = 2,
  58451. /** uv value */
  58452. UV = 1,
  58453. /** random value */
  58454. Random = 0,
  58455. /** stated value */
  58456. Stated = 3
  58457. }
  58458. /**
  58459. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58460. * 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.
  58461. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58462. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58463. *
  58464. * Full documentation here : TO BE ENTERED
  58465. */
  58466. export class PointsCloudSystem implements IDisposable {
  58467. /**
  58468. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58469. * Example : var p = SPS.particles[i];
  58470. */
  58471. particles: CloudPoint[];
  58472. /**
  58473. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58474. */
  58475. nbParticles: number;
  58476. /**
  58477. * This a counter for your own usage. It's not set by any SPS functions.
  58478. */
  58479. counter: number;
  58480. /**
  58481. * The PCS name. This name is also given to the underlying mesh.
  58482. */
  58483. name: string;
  58484. /**
  58485. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58486. */
  58487. mesh: Mesh;
  58488. /**
  58489. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58490. * Please read :
  58491. */
  58492. vars: any;
  58493. /**
  58494. * @hidden
  58495. */
  58496. _size: number;
  58497. private _scene;
  58498. private _promises;
  58499. private _positions;
  58500. private _indices;
  58501. private _normals;
  58502. private _colors;
  58503. private _uvs;
  58504. private _indices32;
  58505. private _positions32;
  58506. private _colors32;
  58507. private _uvs32;
  58508. private _updatable;
  58509. private _isVisibilityBoxLocked;
  58510. private _alwaysVisible;
  58511. private _groups;
  58512. private _groupCounter;
  58513. private _computeParticleColor;
  58514. private _computeParticleTexture;
  58515. private _computeParticleRotation;
  58516. private _computeBoundingBox;
  58517. private _isReady;
  58518. /**
  58519. * Creates a PCS (Points Cloud System) object
  58520. * @param name (String) is the PCS name, this will be the underlying mesh name
  58521. * @param pointSize (number) is the size for each point
  58522. * @param scene (Scene) is the scene in which the PCS is added
  58523. * @param options defines the options of the PCS e.g.
  58524. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58525. */
  58526. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58527. updatable?: boolean;
  58528. });
  58529. /**
  58530. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58531. * If no points were added to the PCS, the returned mesh is just a single point.
  58532. * @returns a promise for the created mesh
  58533. */
  58534. buildMeshAsync(): Promise<Mesh>;
  58535. /**
  58536. * @hidden
  58537. */
  58538. private _buildMesh;
  58539. private _addParticle;
  58540. private _randomUnitVector;
  58541. private _getColorIndicesForCoord;
  58542. private _setPointsColorOrUV;
  58543. private _colorFromTexture;
  58544. private _calculateDensity;
  58545. /**
  58546. * Adds points to the PCS in random positions within a unit sphere
  58547. * @param nb (positive integer) the number of particles to be created from this model
  58548. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58549. * @returns the number of groups in the system
  58550. */
  58551. addPoints(nb: number, pointFunction?: any): number;
  58552. /**
  58553. * Adds points to the PCS from the surface of the model shape
  58554. * @param mesh is any Mesh object that will be used as a surface model for the points
  58555. * @param nb (positive integer) the number of particles to be created from this model
  58556. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58557. * @param color (color3) to be used when colorWith is stated
  58558. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58559. * @returns the number of groups in the system
  58560. */
  58561. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58562. /**
  58563. * Adds points to the PCS inside the model shape
  58564. * @param mesh is any Mesh object that will be used as a surface model for the points
  58565. * @param nb (positive integer) the number of particles to be created from this model
  58566. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58567. * @param color (color4) to be used when colorWith is stated
  58568. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58569. * @returns the number of groups in the system
  58570. */
  58571. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58572. /**
  58573. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58574. * This method calls `updateParticle()` for each particle of the SPS.
  58575. * For an animated SPS, it is usually called within the render loop.
  58576. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58577. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58578. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58579. * @returns the PCS.
  58580. */
  58581. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58582. /**
  58583. * Disposes the PCS.
  58584. */
  58585. dispose(): void;
  58586. /**
  58587. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58588. * doc :
  58589. * @returns the PCS.
  58590. */
  58591. refreshVisibleSize(): PointsCloudSystem;
  58592. /**
  58593. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58594. * @param size the size (float) of the visibility box
  58595. * note : this doesn't lock the PCS mesh bounding box.
  58596. * doc :
  58597. */
  58598. setVisibilityBox(size: number): void;
  58599. /**
  58600. * Gets whether the PCS is always visible or not
  58601. * doc :
  58602. */
  58603. /**
  58604. * Sets the PCS as always visible or not
  58605. * doc :
  58606. */
  58607. isAlwaysVisible: boolean;
  58608. /**
  58609. * Tells to `setParticles()` to compute the particle rotations or not
  58610. * Default value : false. The PCS is faster when it's set to false
  58611. * Note : particle rotations are only applied to parent particles
  58612. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58613. */
  58614. computeParticleRotation: boolean;
  58615. /**
  58616. * Tells to `setParticles()` to compute the particle colors or not.
  58617. * Default value : true. The PCS is faster when it's set to false.
  58618. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58619. */
  58620. /**
  58621. * Gets if `setParticles()` computes the particle colors or not.
  58622. * Default value : false. The PCS is faster when it's set to false.
  58623. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58624. */
  58625. computeParticleColor: boolean;
  58626. /**
  58627. * Gets if `setParticles()` computes the particle textures or not.
  58628. * Default value : false. The PCS is faster when it's set to false.
  58629. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58630. */
  58631. computeParticleTexture: boolean;
  58632. /**
  58633. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58634. */
  58635. /**
  58636. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58637. */
  58638. computeBoundingBox: boolean;
  58639. /**
  58640. * This function does nothing. It may be overwritten to set all the particle first values.
  58641. * The PCS doesn't call this function, you may have to call it by your own.
  58642. * doc :
  58643. */
  58644. initParticles(): void;
  58645. /**
  58646. * This function does nothing. It may be overwritten to recycle a particle
  58647. * The PCS doesn't call this function, you can to call it
  58648. * doc :
  58649. * @param particle The particle to recycle
  58650. * @returns the recycled particle
  58651. */
  58652. recycleParticle(particle: CloudPoint): CloudPoint;
  58653. /**
  58654. * Updates a particle : this function should be overwritten by the user.
  58655. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58656. * doc :
  58657. * @example : just set a particle position or velocity and recycle conditions
  58658. * @param particle The particle to update
  58659. * @returns the updated particle
  58660. */
  58661. updateParticle(particle: CloudPoint): CloudPoint;
  58662. /**
  58663. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58664. * This does nothing and may be overwritten by the user.
  58665. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58666. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58667. * @param update the boolean update value actually passed to setParticles()
  58668. */
  58669. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58670. /**
  58671. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58672. * This will be passed three parameters.
  58673. * This does nothing and may be overwritten by the user.
  58674. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58675. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58676. * @param update the boolean update value actually passed to setParticles()
  58677. */
  58678. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /**
  58683. * Represents one particle of a points cloud system.
  58684. */
  58685. export class CloudPoint {
  58686. /**
  58687. * particle global index
  58688. */
  58689. idx: number;
  58690. /**
  58691. * The color of the particle
  58692. */
  58693. color: Nullable<Color4>;
  58694. /**
  58695. * The world space position of the particle.
  58696. */
  58697. position: Vector3;
  58698. /**
  58699. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58700. */
  58701. rotation: Vector3;
  58702. /**
  58703. * The world space rotation quaternion of the particle.
  58704. */
  58705. rotationQuaternion: Nullable<Quaternion>;
  58706. /**
  58707. * The uv of the particle.
  58708. */
  58709. uv: Nullable<Vector2>;
  58710. /**
  58711. * The current speed of the particle.
  58712. */
  58713. velocity: Vector3;
  58714. /**
  58715. * The pivot point in the particle local space.
  58716. */
  58717. pivot: Vector3;
  58718. /**
  58719. * Must the particle be translated from its pivot point in its local space ?
  58720. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58721. * Default : false
  58722. */
  58723. translateFromPivot: boolean;
  58724. /**
  58725. * Index of this particle in the global "positions" array (Internal use)
  58726. * @hidden
  58727. */
  58728. _pos: number;
  58729. /**
  58730. * @hidden Index of this particle in the global "indices" array (Internal use)
  58731. */
  58732. _ind: number;
  58733. /**
  58734. * Group this particle belongs to
  58735. */
  58736. _group: PointsGroup;
  58737. /**
  58738. * Group id of this particle
  58739. */
  58740. groupId: number;
  58741. /**
  58742. * Index of the particle in its group id (Internal use)
  58743. */
  58744. idxInGroup: number;
  58745. /**
  58746. * @hidden Particle BoundingInfo object (Internal use)
  58747. */
  58748. _boundingInfo: BoundingInfo;
  58749. /**
  58750. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58751. */
  58752. _pcs: PointsCloudSystem;
  58753. /**
  58754. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58755. */
  58756. _stillInvisible: boolean;
  58757. /**
  58758. * @hidden Last computed particle rotation matrix
  58759. */
  58760. _rotationMatrix: number[];
  58761. /**
  58762. * Parent particle Id, if any.
  58763. * Default null.
  58764. */
  58765. parentId: Nullable<number>;
  58766. /**
  58767. * @hidden Internal global position in the PCS.
  58768. */
  58769. _globalPosition: Vector3;
  58770. /**
  58771. * Creates a Point Cloud object.
  58772. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58773. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58774. * @param group (PointsGroup) is the group the particle belongs to
  58775. * @param groupId (integer) is the group identifier in the PCS.
  58776. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58777. * @param pcs defines the PCS it is associated to
  58778. */
  58779. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58780. /**
  58781. * get point size
  58782. */
  58783. /**
  58784. * Set point size
  58785. */
  58786. size: Vector3;
  58787. /**
  58788. * Legacy support, changed quaternion to rotationQuaternion
  58789. */
  58790. /**
  58791. * Legacy support, changed quaternion to rotationQuaternion
  58792. */
  58793. quaternion: Nullable<Quaternion>;
  58794. /**
  58795. * Returns a boolean. True if the particle intersects a mesh, else false
  58796. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58797. * @param target is the object (point or mesh) what the intersection is computed against
  58798. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58799. * @returns true if it intersects
  58800. */
  58801. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58802. /**
  58803. * get the rotation matrix of the particle
  58804. * @hidden
  58805. */
  58806. getRotationMatrix(m: Matrix): void;
  58807. }
  58808. /**
  58809. * Represents a group of points in a points cloud system
  58810. * * PCS internal tool, don't use it manually.
  58811. */
  58812. export class PointsGroup {
  58813. /**
  58814. * The group id
  58815. * @hidden
  58816. */
  58817. groupID: number;
  58818. /**
  58819. * image data for group (internal use)
  58820. * @hidden
  58821. */
  58822. _groupImageData: Nullable<ArrayBufferView>;
  58823. /**
  58824. * Image Width (internal use)
  58825. * @hidden
  58826. */
  58827. _groupImgWidth: number;
  58828. /**
  58829. * Image Height (internal use)
  58830. * @hidden
  58831. */
  58832. _groupImgHeight: number;
  58833. /**
  58834. * Custom position function (internal use)
  58835. * @hidden
  58836. */
  58837. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58838. /**
  58839. * density per facet for surface points
  58840. * @hidden
  58841. */
  58842. _groupDensity: number[];
  58843. /**
  58844. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58845. * PCS internal tool, don't use it manually.
  58846. * @hidden
  58847. */
  58848. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58849. }
  58850. }
  58851. declare module BABYLON {
  58852. interface Scene {
  58853. /** @hidden (Backing field) */
  58854. _physicsEngine: Nullable<IPhysicsEngine>;
  58855. /**
  58856. * Gets the current physics engine
  58857. * @returns a IPhysicsEngine or null if none attached
  58858. */
  58859. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58860. /**
  58861. * Enables physics to the current scene
  58862. * @param gravity defines the scene's gravity for the physics engine
  58863. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58864. * @return a boolean indicating if the physics engine was initialized
  58865. */
  58866. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58867. /**
  58868. * Disables and disposes the physics engine associated with the scene
  58869. */
  58870. disablePhysicsEngine(): void;
  58871. /**
  58872. * Gets a boolean indicating if there is an active physics engine
  58873. * @returns a boolean indicating if there is an active physics engine
  58874. */
  58875. isPhysicsEnabled(): boolean;
  58876. /**
  58877. * Deletes a physics compound impostor
  58878. * @param compound defines the compound to delete
  58879. */
  58880. deleteCompoundImpostor(compound: any): void;
  58881. /**
  58882. * An event triggered when physic simulation is about to be run
  58883. */
  58884. onBeforePhysicsObservable: Observable<Scene>;
  58885. /**
  58886. * An event triggered when physic simulation has been done
  58887. */
  58888. onAfterPhysicsObservable: Observable<Scene>;
  58889. }
  58890. interface AbstractMesh {
  58891. /** @hidden */
  58892. _physicsImpostor: Nullable<PhysicsImpostor>;
  58893. /**
  58894. * Gets or sets impostor used for physic simulation
  58895. * @see http://doc.babylonjs.com/features/physics_engine
  58896. */
  58897. physicsImpostor: Nullable<PhysicsImpostor>;
  58898. /**
  58899. * Gets the current physics impostor
  58900. * @see http://doc.babylonjs.com/features/physics_engine
  58901. * @returns a physics impostor or null
  58902. */
  58903. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58904. /** Apply a physic impulse to the mesh
  58905. * @param force defines the force to apply
  58906. * @param contactPoint defines where to apply the force
  58907. * @returns the current mesh
  58908. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58909. */
  58910. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58911. /**
  58912. * Creates a physic joint between two meshes
  58913. * @param otherMesh defines the other mesh to use
  58914. * @param pivot1 defines the pivot to use on this mesh
  58915. * @param pivot2 defines the pivot to use on the other mesh
  58916. * @param options defines additional options (can be plugin dependent)
  58917. * @returns the current mesh
  58918. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58919. */
  58920. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58921. /** @hidden */
  58922. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58923. }
  58924. /**
  58925. * Defines the physics engine scene component responsible to manage a physics engine
  58926. */
  58927. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58928. /**
  58929. * The component name helpful to identify the component in the list of scene components.
  58930. */
  58931. readonly name: string;
  58932. /**
  58933. * The scene the component belongs to.
  58934. */
  58935. scene: Scene;
  58936. /**
  58937. * Creates a new instance of the component for the given scene
  58938. * @param scene Defines the scene to register the component in
  58939. */
  58940. constructor(scene: Scene);
  58941. /**
  58942. * Registers the component in a given scene
  58943. */
  58944. register(): void;
  58945. /**
  58946. * Rebuilds the elements related to this component in case of
  58947. * context lost for instance.
  58948. */
  58949. rebuild(): void;
  58950. /**
  58951. * Disposes the component and the associated ressources
  58952. */
  58953. dispose(): void;
  58954. }
  58955. }
  58956. declare module BABYLON {
  58957. /**
  58958. * A helper for physics simulations
  58959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58960. */
  58961. export class PhysicsHelper {
  58962. private _scene;
  58963. private _physicsEngine;
  58964. /**
  58965. * Initializes the Physics helper
  58966. * @param scene Babylon.js scene
  58967. */
  58968. constructor(scene: Scene);
  58969. /**
  58970. * Applies a radial explosion impulse
  58971. * @param origin the origin of the explosion
  58972. * @param radiusOrEventOptions the radius or the options of radial explosion
  58973. * @param strength the explosion strength
  58974. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58975. * @returns A physics radial explosion event, or null
  58976. */
  58977. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58978. /**
  58979. * Applies a radial explosion force
  58980. * @param origin the origin of the explosion
  58981. * @param radiusOrEventOptions the radius or the options of radial explosion
  58982. * @param strength the explosion strength
  58983. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58984. * @returns A physics radial explosion event, or null
  58985. */
  58986. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58987. /**
  58988. * Creates a gravitational field
  58989. * @param origin the origin of the explosion
  58990. * @param radiusOrEventOptions the radius or the options of radial explosion
  58991. * @param strength the explosion strength
  58992. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58993. * @returns A physics gravitational field event, or null
  58994. */
  58995. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58996. /**
  58997. * Creates a physics updraft event
  58998. * @param origin the origin of the updraft
  58999. * @param radiusOrEventOptions the radius or the options of the updraft
  59000. * @param strength the strength of the updraft
  59001. * @param height the height of the updraft
  59002. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59003. * @returns A physics updraft event, or null
  59004. */
  59005. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59006. /**
  59007. * Creates a physics vortex event
  59008. * @param origin the of the vortex
  59009. * @param radiusOrEventOptions the radius or the options of the vortex
  59010. * @param strength the strength of the vortex
  59011. * @param height the height of the vortex
  59012. * @returns a Physics vortex event, or null
  59013. * A physics vortex event or null
  59014. */
  59015. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59016. }
  59017. /**
  59018. * Represents a physics radial explosion event
  59019. */
  59020. class PhysicsRadialExplosionEvent {
  59021. private _scene;
  59022. private _options;
  59023. private _sphere;
  59024. private _dataFetched;
  59025. /**
  59026. * Initializes a radial explosioin event
  59027. * @param _scene BabylonJS scene
  59028. * @param _options The options for the vortex event
  59029. */
  59030. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59031. /**
  59032. * Returns the data related to the radial explosion event (sphere).
  59033. * @returns The radial explosion event data
  59034. */
  59035. getData(): PhysicsRadialExplosionEventData;
  59036. /**
  59037. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59038. * @param impostor A physics imposter
  59039. * @param origin the origin of the explosion
  59040. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59041. */
  59042. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59043. /**
  59044. * Triggers affecterd impostors callbacks
  59045. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59046. */
  59047. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59048. /**
  59049. * Disposes the sphere.
  59050. * @param force Specifies if the sphere should be disposed by force
  59051. */
  59052. dispose(force?: boolean): void;
  59053. /*** Helpers ***/
  59054. private _prepareSphere;
  59055. private _intersectsWithSphere;
  59056. }
  59057. /**
  59058. * Represents a gravitational field event
  59059. */
  59060. class PhysicsGravitationalFieldEvent {
  59061. private _physicsHelper;
  59062. private _scene;
  59063. private _origin;
  59064. private _options;
  59065. private _tickCallback;
  59066. private _sphere;
  59067. private _dataFetched;
  59068. /**
  59069. * Initializes the physics gravitational field event
  59070. * @param _physicsHelper A physics helper
  59071. * @param _scene BabylonJS scene
  59072. * @param _origin The origin position of the gravitational field event
  59073. * @param _options The options for the vortex event
  59074. */
  59075. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59076. /**
  59077. * Returns the data related to the gravitational field event (sphere).
  59078. * @returns A gravitational field event
  59079. */
  59080. getData(): PhysicsGravitationalFieldEventData;
  59081. /**
  59082. * Enables the gravitational field.
  59083. */
  59084. enable(): void;
  59085. /**
  59086. * Disables the gravitational field.
  59087. */
  59088. disable(): void;
  59089. /**
  59090. * Disposes the sphere.
  59091. * @param force The force to dispose from the gravitational field event
  59092. */
  59093. dispose(force?: boolean): void;
  59094. private _tick;
  59095. }
  59096. /**
  59097. * Represents a physics updraft event
  59098. */
  59099. class PhysicsUpdraftEvent {
  59100. private _scene;
  59101. private _origin;
  59102. private _options;
  59103. private _physicsEngine;
  59104. private _originTop;
  59105. private _originDirection;
  59106. private _tickCallback;
  59107. private _cylinder;
  59108. private _cylinderPosition;
  59109. private _dataFetched;
  59110. /**
  59111. * Initializes the physics updraft event
  59112. * @param _scene BabylonJS scene
  59113. * @param _origin The origin position of the updraft
  59114. * @param _options The options for the updraft event
  59115. */
  59116. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59117. /**
  59118. * Returns the data related to the updraft event (cylinder).
  59119. * @returns A physics updraft event
  59120. */
  59121. getData(): PhysicsUpdraftEventData;
  59122. /**
  59123. * Enables the updraft.
  59124. */
  59125. enable(): void;
  59126. /**
  59127. * Disables the updraft.
  59128. */
  59129. disable(): void;
  59130. /**
  59131. * Disposes the cylinder.
  59132. * @param force Specifies if the updraft should be disposed by force
  59133. */
  59134. dispose(force?: boolean): void;
  59135. private getImpostorHitData;
  59136. private _tick;
  59137. /*** Helpers ***/
  59138. private _prepareCylinder;
  59139. private _intersectsWithCylinder;
  59140. }
  59141. /**
  59142. * Represents a physics vortex event
  59143. */
  59144. class PhysicsVortexEvent {
  59145. private _scene;
  59146. private _origin;
  59147. private _options;
  59148. private _physicsEngine;
  59149. private _originTop;
  59150. private _tickCallback;
  59151. private _cylinder;
  59152. private _cylinderPosition;
  59153. private _dataFetched;
  59154. /**
  59155. * Initializes the physics vortex event
  59156. * @param _scene The BabylonJS scene
  59157. * @param _origin The origin position of the vortex
  59158. * @param _options The options for the vortex event
  59159. */
  59160. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59161. /**
  59162. * Returns the data related to the vortex event (cylinder).
  59163. * @returns The physics vortex event data
  59164. */
  59165. getData(): PhysicsVortexEventData;
  59166. /**
  59167. * Enables the vortex.
  59168. */
  59169. enable(): void;
  59170. /**
  59171. * Disables the cortex.
  59172. */
  59173. disable(): void;
  59174. /**
  59175. * Disposes the sphere.
  59176. * @param force
  59177. */
  59178. dispose(force?: boolean): void;
  59179. private getImpostorHitData;
  59180. private _tick;
  59181. /*** Helpers ***/
  59182. private _prepareCylinder;
  59183. private _intersectsWithCylinder;
  59184. }
  59185. /**
  59186. * Options fot the radial explosion event
  59187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59188. */
  59189. export class PhysicsRadialExplosionEventOptions {
  59190. /**
  59191. * The radius of the sphere for the radial explosion.
  59192. */
  59193. radius: number;
  59194. /**
  59195. * The strenth of the explosion.
  59196. */
  59197. strength: number;
  59198. /**
  59199. * The strenght of the force in correspondence to the distance of the affected object
  59200. */
  59201. falloff: PhysicsRadialImpulseFalloff;
  59202. /**
  59203. * Sphere options for the radial explosion.
  59204. */
  59205. sphere: {
  59206. segments: number;
  59207. diameter: number;
  59208. };
  59209. /**
  59210. * Sphere options for the radial explosion.
  59211. */
  59212. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59213. }
  59214. /**
  59215. * Options fot the updraft event
  59216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59217. */
  59218. export class PhysicsUpdraftEventOptions {
  59219. /**
  59220. * The radius of the cylinder for the vortex
  59221. */
  59222. radius: number;
  59223. /**
  59224. * The strenth of the updraft.
  59225. */
  59226. strength: number;
  59227. /**
  59228. * The height of the cylinder for the updraft.
  59229. */
  59230. height: number;
  59231. /**
  59232. * The mode for the the updraft.
  59233. */
  59234. updraftMode: PhysicsUpdraftMode;
  59235. }
  59236. /**
  59237. * Options fot the vortex event
  59238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59239. */
  59240. export class PhysicsVortexEventOptions {
  59241. /**
  59242. * The radius of the cylinder for the vortex
  59243. */
  59244. radius: number;
  59245. /**
  59246. * The strenth of the vortex.
  59247. */
  59248. strength: number;
  59249. /**
  59250. * The height of the cylinder for the vortex.
  59251. */
  59252. height: number;
  59253. /**
  59254. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59255. */
  59256. centripetalForceThreshold: number;
  59257. /**
  59258. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59259. */
  59260. centripetalForceMultiplier: number;
  59261. /**
  59262. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59263. */
  59264. centrifugalForceMultiplier: number;
  59265. /**
  59266. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59267. */
  59268. updraftForceMultiplier: number;
  59269. }
  59270. /**
  59271. * The strenght of the force in correspondence to the distance of the affected object
  59272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59273. */
  59274. export enum PhysicsRadialImpulseFalloff {
  59275. /** Defines that impulse is constant in strength across it's whole radius */
  59276. Constant = 0,
  59277. /** Defines that impulse gets weaker if it's further from the origin */
  59278. Linear = 1
  59279. }
  59280. /**
  59281. * The strength of the force in correspondence to the distance of the affected object
  59282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59283. */
  59284. export enum PhysicsUpdraftMode {
  59285. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59286. Center = 0,
  59287. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59288. Perpendicular = 1
  59289. }
  59290. /**
  59291. * Interface for a physics hit data
  59292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59293. */
  59294. export interface PhysicsHitData {
  59295. /**
  59296. * The force applied at the contact point
  59297. */
  59298. force: Vector3;
  59299. /**
  59300. * The contact point
  59301. */
  59302. contactPoint: Vector3;
  59303. /**
  59304. * The distance from the origin to the contact point
  59305. */
  59306. distanceFromOrigin: number;
  59307. }
  59308. /**
  59309. * Interface for radial explosion event data
  59310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59311. */
  59312. export interface PhysicsRadialExplosionEventData {
  59313. /**
  59314. * A sphere used for the radial explosion event
  59315. */
  59316. sphere: Mesh;
  59317. }
  59318. /**
  59319. * Interface for gravitational field event data
  59320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59321. */
  59322. export interface PhysicsGravitationalFieldEventData {
  59323. /**
  59324. * A sphere mesh used for the gravitational field event
  59325. */
  59326. sphere: Mesh;
  59327. }
  59328. /**
  59329. * Interface for updraft event data
  59330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59331. */
  59332. export interface PhysicsUpdraftEventData {
  59333. /**
  59334. * A cylinder used for the updraft event
  59335. */
  59336. cylinder: Mesh;
  59337. }
  59338. /**
  59339. * Interface for vortex event data
  59340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59341. */
  59342. export interface PhysicsVortexEventData {
  59343. /**
  59344. * A cylinder used for the vortex event
  59345. */
  59346. cylinder: Mesh;
  59347. }
  59348. /**
  59349. * Interface for an affected physics impostor
  59350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59351. */
  59352. export interface PhysicsAffectedImpostorWithData {
  59353. /**
  59354. * The impostor affected by the effect
  59355. */
  59356. impostor: PhysicsImpostor;
  59357. /**
  59358. * The data about the hit/horce from the explosion
  59359. */
  59360. hitData: PhysicsHitData;
  59361. }
  59362. }
  59363. declare module BABYLON {
  59364. /** @hidden */
  59365. export var blackAndWhitePixelShader: {
  59366. name: string;
  59367. shader: string;
  59368. };
  59369. }
  59370. declare module BABYLON {
  59371. /**
  59372. * Post process used to render in black and white
  59373. */
  59374. export class BlackAndWhitePostProcess extends PostProcess {
  59375. /**
  59376. * Linear about to convert he result to black and white (default: 1)
  59377. */
  59378. degree: number;
  59379. /**
  59380. * Creates a black and white post process
  59381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59382. * @param name The name of the effect.
  59383. * @param options The required width/height ratio to downsize to before computing the render pass.
  59384. * @param camera The camera to apply the render pass to.
  59385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59386. * @param engine The engine which the post process will be applied. (default: current engine)
  59387. * @param reusable If the post process can be reused on the same frame. (default: false)
  59388. */
  59389. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59390. }
  59391. }
  59392. declare module BABYLON {
  59393. /**
  59394. * This represents a set of one or more post processes in Babylon.
  59395. * A post process can be used to apply a shader to a texture after it is rendered.
  59396. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59397. */
  59398. export class PostProcessRenderEffect {
  59399. private _postProcesses;
  59400. private _getPostProcesses;
  59401. private _singleInstance;
  59402. private _cameras;
  59403. private _indicesForCamera;
  59404. /**
  59405. * Name of the effect
  59406. * @hidden
  59407. */
  59408. _name: string;
  59409. /**
  59410. * Instantiates a post process render effect.
  59411. * A post process can be used to apply a shader to a texture after it is rendered.
  59412. * @param engine The engine the effect is tied to
  59413. * @param name The name of the effect
  59414. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59415. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59416. */
  59417. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59418. /**
  59419. * Checks if all the post processes in the effect are supported.
  59420. */
  59421. readonly isSupported: boolean;
  59422. /**
  59423. * Updates the current state of the effect
  59424. * @hidden
  59425. */
  59426. _update(): void;
  59427. /**
  59428. * Attaches the effect on cameras
  59429. * @param cameras The camera to attach to.
  59430. * @hidden
  59431. */
  59432. _attachCameras(cameras: Camera): void;
  59433. /**
  59434. * Attaches the effect on cameras
  59435. * @param cameras The camera to attach to.
  59436. * @hidden
  59437. */
  59438. _attachCameras(cameras: Camera[]): void;
  59439. /**
  59440. * Detaches the effect on cameras
  59441. * @param cameras The camera to detatch from.
  59442. * @hidden
  59443. */
  59444. _detachCameras(cameras: Camera): void;
  59445. /**
  59446. * Detatches the effect on cameras
  59447. * @param cameras The camera to detatch from.
  59448. * @hidden
  59449. */
  59450. _detachCameras(cameras: Camera[]): void;
  59451. /**
  59452. * Enables the effect on given cameras
  59453. * @param cameras The camera to enable.
  59454. * @hidden
  59455. */
  59456. _enable(cameras: Camera): void;
  59457. /**
  59458. * Enables the effect on given cameras
  59459. * @param cameras The camera to enable.
  59460. * @hidden
  59461. */
  59462. _enable(cameras: Nullable<Camera[]>): void;
  59463. /**
  59464. * Disables the effect on the given cameras
  59465. * @param cameras The camera to disable.
  59466. * @hidden
  59467. */
  59468. _disable(cameras: Camera): void;
  59469. /**
  59470. * Disables the effect on the given cameras
  59471. * @param cameras The camera to disable.
  59472. * @hidden
  59473. */
  59474. _disable(cameras: Nullable<Camera[]>): void;
  59475. /**
  59476. * Gets a list of the post processes contained in the effect.
  59477. * @param camera The camera to get the post processes on.
  59478. * @returns The list of the post processes in the effect.
  59479. */
  59480. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59481. }
  59482. }
  59483. declare module BABYLON {
  59484. /** @hidden */
  59485. export var extractHighlightsPixelShader: {
  59486. name: string;
  59487. shader: string;
  59488. };
  59489. }
  59490. declare module BABYLON {
  59491. /**
  59492. * 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.
  59493. */
  59494. export class ExtractHighlightsPostProcess extends PostProcess {
  59495. /**
  59496. * The luminance threshold, pixels below this value will be set to black.
  59497. */
  59498. threshold: number;
  59499. /** @hidden */
  59500. _exposure: number;
  59501. /**
  59502. * Post process which has the input texture to be used when performing highlight extraction
  59503. * @hidden
  59504. */
  59505. _inputPostProcess: Nullable<PostProcess>;
  59506. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59507. }
  59508. }
  59509. declare module BABYLON {
  59510. /** @hidden */
  59511. export var bloomMergePixelShader: {
  59512. name: string;
  59513. shader: string;
  59514. };
  59515. }
  59516. declare module BABYLON {
  59517. /**
  59518. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59519. */
  59520. export class BloomMergePostProcess extends PostProcess {
  59521. /** Weight of the bloom to be added to the original input. */
  59522. weight: number;
  59523. /**
  59524. * Creates a new instance of @see BloomMergePostProcess
  59525. * @param name The name of the effect.
  59526. * @param originalFromInput Post process which's input will be used for the merge.
  59527. * @param blurred Blurred highlights post process which's output will be used.
  59528. * @param weight Weight of the bloom to be added to the original input.
  59529. * @param options The required width/height ratio to downsize to before computing the render pass.
  59530. * @param camera The camera to apply the render pass to.
  59531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59532. * @param engine The engine which the post process will be applied. (default: current engine)
  59533. * @param reusable If the post process can be reused on the same frame. (default: false)
  59534. * @param textureType Type of textures used when performing the post process. (default: 0)
  59535. * @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)
  59536. */
  59537. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59538. /** Weight of the bloom to be added to the original input. */
  59539. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59540. }
  59541. }
  59542. declare module BABYLON {
  59543. /**
  59544. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59545. */
  59546. export class BloomEffect extends PostProcessRenderEffect {
  59547. private bloomScale;
  59548. /**
  59549. * @hidden Internal
  59550. */
  59551. _effects: Array<PostProcess>;
  59552. /**
  59553. * @hidden Internal
  59554. */
  59555. _downscale: ExtractHighlightsPostProcess;
  59556. private _blurX;
  59557. private _blurY;
  59558. private _merge;
  59559. /**
  59560. * The luminance threshold to find bright areas of the image to bloom.
  59561. */
  59562. threshold: number;
  59563. /**
  59564. * The strength of the bloom.
  59565. */
  59566. weight: number;
  59567. /**
  59568. * Specifies the size of the bloom blur kernel, relative to the final output size
  59569. */
  59570. kernel: number;
  59571. /**
  59572. * Creates a new instance of @see BloomEffect
  59573. * @param scene The scene the effect belongs to.
  59574. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59575. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59576. * @param bloomWeight The the strength of bloom.
  59577. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59578. * @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)
  59579. */
  59580. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59581. /**
  59582. * Disposes each of the internal effects for a given camera.
  59583. * @param camera The camera to dispose the effect on.
  59584. */
  59585. disposeEffects(camera: Camera): void;
  59586. /**
  59587. * @hidden Internal
  59588. */
  59589. _updateEffects(): void;
  59590. /**
  59591. * Internal
  59592. * @returns if all the contained post processes are ready.
  59593. * @hidden
  59594. */
  59595. _isReady(): boolean;
  59596. }
  59597. }
  59598. declare module BABYLON {
  59599. /** @hidden */
  59600. export var chromaticAberrationPixelShader: {
  59601. name: string;
  59602. shader: string;
  59603. };
  59604. }
  59605. declare module BABYLON {
  59606. /**
  59607. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59608. */
  59609. export class ChromaticAberrationPostProcess extends PostProcess {
  59610. /**
  59611. * The amount of seperation of rgb channels (default: 30)
  59612. */
  59613. aberrationAmount: number;
  59614. /**
  59615. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59616. */
  59617. radialIntensity: number;
  59618. /**
  59619. * 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))
  59620. */
  59621. direction: Vector2;
  59622. /**
  59623. * 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))
  59624. */
  59625. centerPosition: Vector2;
  59626. /**
  59627. * Creates a new instance ChromaticAberrationPostProcess
  59628. * @param name The name of the effect.
  59629. * @param screenWidth The width of the screen to apply the effect on.
  59630. * @param screenHeight The height of the screen to apply the effect on.
  59631. * @param options The required width/height ratio to downsize to before computing the render pass.
  59632. * @param camera The camera to apply the render pass to.
  59633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59634. * @param engine The engine which the post process will be applied. (default: current engine)
  59635. * @param reusable If the post process can be reused on the same frame. (default: false)
  59636. * @param textureType Type of textures used when performing the post process. (default: 0)
  59637. * @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)
  59638. */
  59639. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59640. }
  59641. }
  59642. declare module BABYLON {
  59643. /** @hidden */
  59644. export var circleOfConfusionPixelShader: {
  59645. name: string;
  59646. shader: string;
  59647. };
  59648. }
  59649. declare module BABYLON {
  59650. /**
  59651. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59652. */
  59653. export class CircleOfConfusionPostProcess extends PostProcess {
  59654. /**
  59655. * 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.
  59656. */
  59657. lensSize: number;
  59658. /**
  59659. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59660. */
  59661. fStop: number;
  59662. /**
  59663. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59664. */
  59665. focusDistance: number;
  59666. /**
  59667. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59668. */
  59669. focalLength: number;
  59670. private _depthTexture;
  59671. /**
  59672. * Creates a new instance CircleOfConfusionPostProcess
  59673. * @param name The name of the effect.
  59674. * @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.
  59675. * @param options The required width/height ratio to downsize to before computing the render pass.
  59676. * @param camera The camera to apply the render pass to.
  59677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59678. * @param engine The engine which the post process will be applied. (default: current engine)
  59679. * @param reusable If the post process can be reused on the same frame. (default: false)
  59680. * @param textureType Type of textures used when performing the post process. (default: 0)
  59681. * @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)
  59682. */
  59683. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59684. /**
  59685. * 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.
  59686. */
  59687. depthTexture: RenderTargetTexture;
  59688. }
  59689. }
  59690. declare module BABYLON {
  59691. /** @hidden */
  59692. export var colorCorrectionPixelShader: {
  59693. name: string;
  59694. shader: string;
  59695. };
  59696. }
  59697. declare module BABYLON {
  59698. /**
  59699. *
  59700. * This post-process allows the modification of rendered colors by using
  59701. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59702. *
  59703. * The object needs to be provided an url to a texture containing the color
  59704. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59705. * Use an image editing software to tweak the LUT to match your needs.
  59706. *
  59707. * For an example of a color LUT, see here:
  59708. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59709. * For explanations on color grading, see here:
  59710. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59711. *
  59712. */
  59713. export class ColorCorrectionPostProcess extends PostProcess {
  59714. private _colorTableTexture;
  59715. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59716. }
  59717. }
  59718. declare module BABYLON {
  59719. /** @hidden */
  59720. export var convolutionPixelShader: {
  59721. name: string;
  59722. shader: string;
  59723. };
  59724. }
  59725. declare module BABYLON {
  59726. /**
  59727. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59728. * input texture to perform effects such as edge detection or sharpening
  59729. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59730. */
  59731. export class ConvolutionPostProcess extends PostProcess {
  59732. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59733. kernel: number[];
  59734. /**
  59735. * Creates a new instance ConvolutionPostProcess
  59736. * @param name The name of the effect.
  59737. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59738. * @param options The required width/height ratio to downsize to before computing the render pass.
  59739. * @param camera The camera to apply the render pass to.
  59740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59741. * @param engine The engine which the post process will be applied. (default: current engine)
  59742. * @param reusable If the post process can be reused on the same frame. (default: false)
  59743. * @param textureType Type of textures used when performing the post process. (default: 0)
  59744. */
  59745. constructor(name: string,
  59746. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59747. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59748. /**
  59749. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59750. */
  59751. static EdgeDetect0Kernel: number[];
  59752. /**
  59753. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59754. */
  59755. static EdgeDetect1Kernel: number[];
  59756. /**
  59757. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59758. */
  59759. static EdgeDetect2Kernel: number[];
  59760. /**
  59761. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59762. */
  59763. static SharpenKernel: number[];
  59764. /**
  59765. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59766. */
  59767. static EmbossKernel: number[];
  59768. /**
  59769. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59770. */
  59771. static GaussianKernel: number[];
  59772. }
  59773. }
  59774. declare module BABYLON {
  59775. /**
  59776. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59777. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59778. * based on samples that have a large difference in distance than the center pixel.
  59779. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59780. */
  59781. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59782. direction: Vector2;
  59783. /**
  59784. * Creates a new instance CircleOfConfusionPostProcess
  59785. * @param name The name of the effect.
  59786. * @param scene The scene the effect belongs to.
  59787. * @param direction The direction the blur should be applied.
  59788. * @param kernel The size of the kernel used to blur.
  59789. * @param options The required width/height ratio to downsize to before computing the render pass.
  59790. * @param camera The camera to apply the render pass to.
  59791. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59792. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59794. * @param engine The engine which the post process will be applied. (default: current engine)
  59795. * @param reusable If the post process can be reused on the same frame. (default: false)
  59796. * @param textureType Type of textures used when performing the post process. (default: 0)
  59797. * @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)
  59798. */
  59799. 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);
  59800. }
  59801. }
  59802. declare module BABYLON {
  59803. /** @hidden */
  59804. export var depthOfFieldMergePixelShader: {
  59805. name: string;
  59806. shader: string;
  59807. };
  59808. }
  59809. declare module BABYLON {
  59810. /**
  59811. * Options to be set when merging outputs from the default pipeline.
  59812. */
  59813. export class DepthOfFieldMergePostProcessOptions {
  59814. /**
  59815. * The original image to merge on top of
  59816. */
  59817. originalFromInput: PostProcess;
  59818. /**
  59819. * Parameters to perform the merge of the depth of field effect
  59820. */
  59821. depthOfField?: {
  59822. circleOfConfusion: PostProcess;
  59823. blurSteps: Array<PostProcess>;
  59824. };
  59825. /**
  59826. * Parameters to perform the merge of bloom effect
  59827. */
  59828. bloom?: {
  59829. blurred: PostProcess;
  59830. weight: number;
  59831. };
  59832. }
  59833. /**
  59834. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59835. */
  59836. export class DepthOfFieldMergePostProcess extends PostProcess {
  59837. private blurSteps;
  59838. /**
  59839. * Creates a new instance of DepthOfFieldMergePostProcess
  59840. * @param name The name of the effect.
  59841. * @param originalFromInput Post process which's input will be used for the merge.
  59842. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59843. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59844. * @param options The required width/height ratio to downsize to before computing the render pass.
  59845. * @param camera The camera to apply the render pass to.
  59846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59847. * @param engine The engine which the post process will be applied. (default: current engine)
  59848. * @param reusable If the post process can be reused on the same frame. (default: false)
  59849. * @param textureType Type of textures used when performing the post process. (default: 0)
  59850. * @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)
  59851. */
  59852. 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);
  59853. /**
  59854. * Updates the effect with the current post process compile time values and recompiles the shader.
  59855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59858. * @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
  59859. * @param onCompiled Called when the shader has been compiled.
  59860. * @param onError Called if there is an error when compiling a shader.
  59861. */
  59862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59863. }
  59864. }
  59865. declare module BABYLON {
  59866. /**
  59867. * Specifies the level of max blur that should be applied when using the depth of field effect
  59868. */
  59869. export enum DepthOfFieldEffectBlurLevel {
  59870. /**
  59871. * Subtle blur
  59872. */
  59873. Low = 0,
  59874. /**
  59875. * Medium blur
  59876. */
  59877. Medium = 1,
  59878. /**
  59879. * Large blur
  59880. */
  59881. High = 2
  59882. }
  59883. /**
  59884. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59885. */
  59886. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59887. private _circleOfConfusion;
  59888. /**
  59889. * @hidden Internal, blurs from high to low
  59890. */
  59891. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59892. private _depthOfFieldBlurY;
  59893. private _dofMerge;
  59894. /**
  59895. * @hidden Internal post processes in depth of field effect
  59896. */
  59897. _effects: Array<PostProcess>;
  59898. /**
  59899. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59900. */
  59901. focalLength: number;
  59902. /**
  59903. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59904. */
  59905. fStop: number;
  59906. /**
  59907. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59908. */
  59909. focusDistance: number;
  59910. /**
  59911. * 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.
  59912. */
  59913. lensSize: number;
  59914. /**
  59915. * Creates a new instance DepthOfFieldEffect
  59916. * @param scene The scene the effect belongs to.
  59917. * @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.
  59918. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59919. * @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)
  59920. */
  59921. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59922. /**
  59923. * Get the current class name of the current effet
  59924. * @returns "DepthOfFieldEffect"
  59925. */
  59926. getClassName(): string;
  59927. /**
  59928. * 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.
  59929. */
  59930. depthTexture: RenderTargetTexture;
  59931. /**
  59932. * Disposes each of the internal effects for a given camera.
  59933. * @param camera The camera to dispose the effect on.
  59934. */
  59935. disposeEffects(camera: Camera): void;
  59936. /**
  59937. * @hidden Internal
  59938. */
  59939. _updateEffects(): void;
  59940. /**
  59941. * Internal
  59942. * @returns if all the contained post processes are ready.
  59943. * @hidden
  59944. */
  59945. _isReady(): boolean;
  59946. }
  59947. }
  59948. declare module BABYLON {
  59949. /** @hidden */
  59950. export var displayPassPixelShader: {
  59951. name: string;
  59952. shader: string;
  59953. };
  59954. }
  59955. declare module BABYLON {
  59956. /**
  59957. * DisplayPassPostProcess which produces an output the same as it's input
  59958. */
  59959. export class DisplayPassPostProcess extends PostProcess {
  59960. /**
  59961. * Creates the DisplayPassPostProcess
  59962. * @param name The name of the effect.
  59963. * @param options The required width/height ratio to downsize to before computing the render pass.
  59964. * @param camera The camera to apply the render pass to.
  59965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59966. * @param engine The engine which the post process will be applied. (default: current engine)
  59967. * @param reusable If the post process can be reused on the same frame. (default: false)
  59968. */
  59969. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59970. }
  59971. }
  59972. declare module BABYLON {
  59973. /** @hidden */
  59974. export var filterPixelShader: {
  59975. name: string;
  59976. shader: string;
  59977. };
  59978. }
  59979. declare module BABYLON {
  59980. /**
  59981. * Applies a kernel filter to the image
  59982. */
  59983. export class FilterPostProcess extends PostProcess {
  59984. /** The matrix to be applied to the image */
  59985. kernelMatrix: Matrix;
  59986. /**
  59987. *
  59988. * @param name The name of the effect.
  59989. * @param kernelMatrix The matrix to be applied to the image
  59990. * @param options The required width/height ratio to downsize to before computing the render pass.
  59991. * @param camera The camera to apply the render pass to.
  59992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59993. * @param engine The engine which the post process will be applied. (default: current engine)
  59994. * @param reusable If the post process can be reused on the same frame. (default: false)
  59995. */
  59996. constructor(name: string,
  59997. /** The matrix to be applied to the image */
  59998. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59999. }
  60000. }
  60001. declare module BABYLON {
  60002. /** @hidden */
  60003. export var fxaaPixelShader: {
  60004. name: string;
  60005. shader: string;
  60006. };
  60007. }
  60008. declare module BABYLON {
  60009. /** @hidden */
  60010. export var fxaaVertexShader: {
  60011. name: string;
  60012. shader: string;
  60013. };
  60014. }
  60015. declare module BABYLON {
  60016. /**
  60017. * Fxaa post process
  60018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60019. */
  60020. export class FxaaPostProcess extends PostProcess {
  60021. /** @hidden */
  60022. texelWidth: number;
  60023. /** @hidden */
  60024. texelHeight: number;
  60025. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60026. private _getDefines;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /** @hidden */
  60031. export var grainPixelShader: {
  60032. name: string;
  60033. shader: string;
  60034. };
  60035. }
  60036. declare module BABYLON {
  60037. /**
  60038. * The GrainPostProcess adds noise to the image at mid luminance levels
  60039. */
  60040. export class GrainPostProcess extends PostProcess {
  60041. /**
  60042. * The intensity of the grain added (default: 30)
  60043. */
  60044. intensity: number;
  60045. /**
  60046. * If the grain should be randomized on every frame
  60047. */
  60048. animated: boolean;
  60049. /**
  60050. * Creates a new instance of @see GrainPostProcess
  60051. * @param name The name of the effect.
  60052. * @param options The required width/height ratio to downsize to before computing the render pass.
  60053. * @param camera The camera to apply the render pass to.
  60054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60055. * @param engine The engine which the post process will be applied. (default: current engine)
  60056. * @param reusable If the post process can be reused on the same frame. (default: false)
  60057. * @param textureType Type of textures used when performing the post process. (default: 0)
  60058. * @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)
  60059. */
  60060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /** @hidden */
  60065. export var highlightsPixelShader: {
  60066. name: string;
  60067. shader: string;
  60068. };
  60069. }
  60070. declare module BABYLON {
  60071. /**
  60072. * Extracts highlights from the image
  60073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60074. */
  60075. export class HighlightsPostProcess extends PostProcess {
  60076. /**
  60077. * Extracts highlights from the image
  60078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60079. * @param name The name of the effect.
  60080. * @param options The required width/height ratio to downsize to before computing the render pass.
  60081. * @param camera The camera to apply the render pass to.
  60082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60083. * @param engine The engine which the post process will be applied. (default: current engine)
  60084. * @param reusable If the post process can be reused on the same frame. (default: false)
  60085. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60086. */
  60087. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60088. }
  60089. }
  60090. declare module BABYLON {
  60091. /** @hidden */
  60092. export var mrtFragmentDeclaration: {
  60093. name: string;
  60094. shader: string;
  60095. };
  60096. }
  60097. declare module BABYLON {
  60098. /** @hidden */
  60099. export var geometryPixelShader: {
  60100. name: string;
  60101. shader: string;
  60102. };
  60103. }
  60104. declare module BABYLON {
  60105. /** @hidden */
  60106. export var geometryVertexShader: {
  60107. name: string;
  60108. shader: string;
  60109. };
  60110. }
  60111. declare module BABYLON {
  60112. /** @hidden */
  60113. interface ISavedTransformationMatrix {
  60114. world: Matrix;
  60115. viewProjection: Matrix;
  60116. }
  60117. /**
  60118. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60119. */
  60120. export class GeometryBufferRenderer {
  60121. /**
  60122. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60123. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60124. */
  60125. static readonly POSITION_TEXTURE_TYPE: number;
  60126. /**
  60127. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60128. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60129. */
  60130. static readonly VELOCITY_TEXTURE_TYPE: number;
  60131. /**
  60132. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60133. * in order to compute objects velocities when enableVelocity is set to "true"
  60134. * @hidden
  60135. */
  60136. _previousTransformationMatrices: {
  60137. [index: number]: ISavedTransformationMatrix;
  60138. };
  60139. /**
  60140. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60141. * in order to compute objects velocities when enableVelocity is set to "true"
  60142. * @hidden
  60143. */
  60144. _previousBonesTransformationMatrices: {
  60145. [index: number]: Float32Array;
  60146. };
  60147. /**
  60148. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60149. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60150. */
  60151. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60152. private _scene;
  60153. private _multiRenderTarget;
  60154. private _ratio;
  60155. private _enablePosition;
  60156. private _enableVelocity;
  60157. private _positionIndex;
  60158. private _velocityIndex;
  60159. protected _effect: Effect;
  60160. protected _cachedDefines: string;
  60161. /**
  60162. * Set the render list (meshes to be rendered) used in the G buffer.
  60163. */
  60164. renderList: Mesh[];
  60165. /**
  60166. * Gets wether or not G buffer are supported by the running hardware.
  60167. * This requires draw buffer supports
  60168. */
  60169. readonly isSupported: boolean;
  60170. /**
  60171. * Returns the index of the given texture type in the G-Buffer textures array
  60172. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60173. * @returns the index of the given texture type in the G-Buffer textures array
  60174. */
  60175. getTextureIndex(textureType: number): number;
  60176. /**
  60177. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60178. */
  60179. /**
  60180. * Sets whether or not objects positions are enabled for the G buffer.
  60181. */
  60182. enablePosition: boolean;
  60183. /**
  60184. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60185. */
  60186. /**
  60187. * Sets wether or not objects velocities are enabled for the G buffer.
  60188. */
  60189. enableVelocity: boolean;
  60190. /**
  60191. * Gets the scene associated with the buffer.
  60192. */
  60193. readonly scene: Scene;
  60194. /**
  60195. * Gets the ratio used by the buffer during its creation.
  60196. * How big is the buffer related to the main canvas.
  60197. */
  60198. readonly ratio: number;
  60199. /** @hidden */
  60200. static _SceneComponentInitialization: (scene: Scene) => void;
  60201. /**
  60202. * Creates a new G Buffer for the scene
  60203. * @param scene The scene the buffer belongs to
  60204. * @param ratio How big is the buffer related to the main canvas.
  60205. */
  60206. constructor(scene: Scene, ratio?: number);
  60207. /**
  60208. * Checks wether everything is ready to render a submesh to the G buffer.
  60209. * @param subMesh the submesh to check readiness for
  60210. * @param useInstances is the mesh drawn using instance or not
  60211. * @returns true if ready otherwise false
  60212. */
  60213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60214. /**
  60215. * Gets the current underlying G Buffer.
  60216. * @returns the buffer
  60217. */
  60218. getGBuffer(): MultiRenderTarget;
  60219. /**
  60220. * Gets the number of samples used to render the buffer (anti aliasing).
  60221. */
  60222. /**
  60223. * Sets the number of samples used to render the buffer (anti aliasing).
  60224. */
  60225. samples: number;
  60226. /**
  60227. * Disposes the renderer and frees up associated resources.
  60228. */
  60229. dispose(): void;
  60230. protected _createRenderTargets(): void;
  60231. private _copyBonesTransformationMatrices;
  60232. }
  60233. }
  60234. declare module BABYLON {
  60235. interface Scene {
  60236. /** @hidden (Backing field) */
  60237. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60238. /**
  60239. * Gets or Sets the current geometry buffer associated to the scene.
  60240. */
  60241. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60242. /**
  60243. * Enables a GeometryBufferRender and associates it with the scene
  60244. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60245. * @returns the GeometryBufferRenderer
  60246. */
  60247. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60248. /**
  60249. * Disables the GeometryBufferRender associated with the scene
  60250. */
  60251. disableGeometryBufferRenderer(): void;
  60252. }
  60253. /**
  60254. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60255. * in several rendering techniques.
  60256. */
  60257. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60258. /**
  60259. * The component name helpful to identify the component in the list of scene components.
  60260. */
  60261. readonly name: string;
  60262. /**
  60263. * The scene the component belongs to.
  60264. */
  60265. scene: Scene;
  60266. /**
  60267. * Creates a new instance of the component for the given scene
  60268. * @param scene Defines the scene to register the component in
  60269. */
  60270. constructor(scene: Scene);
  60271. /**
  60272. * Registers the component in a given scene
  60273. */
  60274. register(): void;
  60275. /**
  60276. * Rebuilds the elements related to this component in case of
  60277. * context lost for instance.
  60278. */
  60279. rebuild(): void;
  60280. /**
  60281. * Disposes the component and the associated ressources
  60282. */
  60283. dispose(): void;
  60284. private _gatherRenderTargets;
  60285. }
  60286. }
  60287. declare module BABYLON {
  60288. /** @hidden */
  60289. export var motionBlurPixelShader: {
  60290. name: string;
  60291. shader: string;
  60292. };
  60293. }
  60294. declare module BABYLON {
  60295. /**
  60296. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60297. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60298. * As an example, all you have to do is to create the post-process:
  60299. * var mb = new BABYLON.MotionBlurPostProcess(
  60300. * 'mb', // The name of the effect.
  60301. * scene, // The scene containing the objects to blur according to their velocity.
  60302. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60303. * camera // The camera to apply the render pass to.
  60304. * );
  60305. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60306. */
  60307. export class MotionBlurPostProcess extends PostProcess {
  60308. /**
  60309. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60310. */
  60311. motionStrength: number;
  60312. /**
  60313. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60314. */
  60315. /**
  60316. * Sets the number of iterations to be used for motion blur quality
  60317. */
  60318. motionBlurSamples: number;
  60319. private _motionBlurSamples;
  60320. private _geometryBufferRenderer;
  60321. /**
  60322. * Creates a new instance MotionBlurPostProcess
  60323. * @param name The name of the effect.
  60324. * @param scene The scene containing the objects to blur according to their velocity.
  60325. * @param options The required width/height ratio to downsize to before computing the render pass.
  60326. * @param camera The camera to apply the render pass to.
  60327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60328. * @param engine The engine which the post process will be applied. (default: current engine)
  60329. * @param reusable If the post process can be reused on the same frame. (default: false)
  60330. * @param textureType Type of textures used when performing the post process. (default: 0)
  60331. * @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)
  60332. */
  60333. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60334. /**
  60335. * Excludes the given skinned mesh from computing bones velocities.
  60336. * 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.
  60337. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60338. */
  60339. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60340. /**
  60341. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60342. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60343. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60344. */
  60345. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60346. /**
  60347. * Disposes the post process.
  60348. * @param camera The camera to dispose the post process on.
  60349. */
  60350. dispose(camera?: Camera): void;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /** @hidden */
  60355. export var refractionPixelShader: {
  60356. name: string;
  60357. shader: string;
  60358. };
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Post process which applies a refractin texture
  60363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60364. */
  60365. export class RefractionPostProcess extends PostProcess {
  60366. /** the base color of the refraction (used to taint the rendering) */
  60367. color: Color3;
  60368. /** simulated refraction depth */
  60369. depth: number;
  60370. /** the coefficient of the base color (0 to remove base color tainting) */
  60371. colorLevel: number;
  60372. private _refTexture;
  60373. private _ownRefractionTexture;
  60374. /**
  60375. * Gets or sets the refraction texture
  60376. * Please note that you are responsible for disposing the texture if you set it manually
  60377. */
  60378. refractionTexture: Texture;
  60379. /**
  60380. * Initializes the RefractionPostProcess
  60381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60382. * @param name The name of the effect.
  60383. * @param refractionTextureUrl Url of the refraction texture to use
  60384. * @param color the base color of the refraction (used to taint the rendering)
  60385. * @param depth simulated refraction depth
  60386. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60387. * @param camera The camera to apply the render pass to.
  60388. * @param options The required width/height ratio to downsize to before computing the render pass.
  60389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60390. * @param engine The engine which the post process will be applied. (default: current engine)
  60391. * @param reusable If the post process can be reused on the same frame. (default: false)
  60392. */
  60393. constructor(name: string, refractionTextureUrl: string,
  60394. /** the base color of the refraction (used to taint the rendering) */
  60395. color: Color3,
  60396. /** simulated refraction depth */
  60397. depth: number,
  60398. /** the coefficient of the base color (0 to remove base color tainting) */
  60399. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60400. /**
  60401. * Disposes of the post process
  60402. * @param camera Camera to dispose post process on
  60403. */
  60404. dispose(camera: Camera): void;
  60405. }
  60406. }
  60407. declare module BABYLON {
  60408. /** @hidden */
  60409. export var sharpenPixelShader: {
  60410. name: string;
  60411. shader: string;
  60412. };
  60413. }
  60414. declare module BABYLON {
  60415. /**
  60416. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60417. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60418. */
  60419. export class SharpenPostProcess extends PostProcess {
  60420. /**
  60421. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60422. */
  60423. colorAmount: number;
  60424. /**
  60425. * How much sharpness should be applied (default: 0.3)
  60426. */
  60427. edgeAmount: number;
  60428. /**
  60429. * Creates a new instance ConvolutionPostProcess
  60430. * @param name The name of the effect.
  60431. * @param options The required width/height ratio to downsize to before computing the render pass.
  60432. * @param camera The camera to apply the render pass to.
  60433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60434. * @param engine The engine which the post process will be applied. (default: current engine)
  60435. * @param reusable If the post process can be reused on the same frame. (default: false)
  60436. * @param textureType Type of textures used when performing the post process. (default: 0)
  60437. * @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)
  60438. */
  60439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60440. }
  60441. }
  60442. declare module BABYLON {
  60443. /**
  60444. * PostProcessRenderPipeline
  60445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60446. */
  60447. export class PostProcessRenderPipeline {
  60448. private engine;
  60449. private _renderEffects;
  60450. private _renderEffectsForIsolatedPass;
  60451. /**
  60452. * List of inspectable custom properties (used by the Inspector)
  60453. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60454. */
  60455. inspectableCustomProperties: IInspectable[];
  60456. /**
  60457. * @hidden
  60458. */
  60459. protected _cameras: Camera[];
  60460. /** @hidden */
  60461. _name: string;
  60462. /**
  60463. * Gets pipeline name
  60464. */
  60465. readonly name: string;
  60466. /**
  60467. * Initializes a PostProcessRenderPipeline
  60468. * @param engine engine to add the pipeline to
  60469. * @param name name of the pipeline
  60470. */
  60471. constructor(engine: Engine, name: string);
  60472. /**
  60473. * Gets the class name
  60474. * @returns "PostProcessRenderPipeline"
  60475. */
  60476. getClassName(): string;
  60477. /**
  60478. * If all the render effects in the pipeline are supported
  60479. */
  60480. readonly isSupported: boolean;
  60481. /**
  60482. * Adds an effect to the pipeline
  60483. * @param renderEffect the effect to add
  60484. */
  60485. addEffect(renderEffect: PostProcessRenderEffect): void;
  60486. /** @hidden */
  60487. _rebuild(): void;
  60488. /** @hidden */
  60489. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60490. /** @hidden */
  60491. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60492. /** @hidden */
  60493. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60494. /** @hidden */
  60495. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60496. /** @hidden */
  60497. _attachCameras(cameras: Camera, unique: boolean): void;
  60498. /** @hidden */
  60499. _attachCameras(cameras: Camera[], unique: boolean): void;
  60500. /** @hidden */
  60501. _detachCameras(cameras: Camera): void;
  60502. /** @hidden */
  60503. _detachCameras(cameras: Nullable<Camera[]>): void;
  60504. /** @hidden */
  60505. _update(): void;
  60506. /** @hidden */
  60507. _reset(): void;
  60508. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60509. /**
  60510. * Disposes of the pipeline
  60511. */
  60512. dispose(): void;
  60513. }
  60514. }
  60515. declare module BABYLON {
  60516. /**
  60517. * PostProcessRenderPipelineManager class
  60518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60519. */
  60520. export class PostProcessRenderPipelineManager {
  60521. private _renderPipelines;
  60522. /**
  60523. * Initializes a PostProcessRenderPipelineManager
  60524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60525. */
  60526. constructor();
  60527. /**
  60528. * Gets the list of supported render pipelines
  60529. */
  60530. readonly supportedPipelines: PostProcessRenderPipeline[];
  60531. /**
  60532. * Adds a pipeline to the manager
  60533. * @param renderPipeline The pipeline to add
  60534. */
  60535. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60536. /**
  60537. * Attaches a camera to the pipeline
  60538. * @param renderPipelineName The name of the pipeline to attach to
  60539. * @param cameras the camera to attach
  60540. * @param unique if the camera can be attached multiple times to the pipeline
  60541. */
  60542. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60543. /**
  60544. * Detaches a camera from the pipeline
  60545. * @param renderPipelineName The name of the pipeline to detach from
  60546. * @param cameras the camera to detach
  60547. */
  60548. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60549. /**
  60550. * Enables an effect by name on a pipeline
  60551. * @param renderPipelineName the name of the pipeline to enable the effect in
  60552. * @param renderEffectName the name of the effect to enable
  60553. * @param cameras the cameras that the effect should be enabled on
  60554. */
  60555. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60556. /**
  60557. * Disables an effect by name on a pipeline
  60558. * @param renderPipelineName the name of the pipeline to disable the effect in
  60559. * @param renderEffectName the name of the effect to disable
  60560. * @param cameras the cameras that the effect should be disabled on
  60561. */
  60562. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60563. /**
  60564. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60565. */
  60566. update(): void;
  60567. /** @hidden */
  60568. _rebuild(): void;
  60569. /**
  60570. * Disposes of the manager and pipelines
  60571. */
  60572. dispose(): void;
  60573. }
  60574. }
  60575. declare module BABYLON {
  60576. interface Scene {
  60577. /** @hidden (Backing field) */
  60578. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60579. /**
  60580. * Gets the postprocess render pipeline manager
  60581. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60582. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60583. */
  60584. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60585. }
  60586. /**
  60587. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60588. */
  60589. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60590. /**
  60591. * The component name helpfull to identify the component in the list of scene components.
  60592. */
  60593. readonly name: string;
  60594. /**
  60595. * The scene the component belongs to.
  60596. */
  60597. scene: Scene;
  60598. /**
  60599. * Creates a new instance of the component for the given scene
  60600. * @param scene Defines the scene to register the component in
  60601. */
  60602. constructor(scene: Scene);
  60603. /**
  60604. * Registers the component in a given scene
  60605. */
  60606. register(): void;
  60607. /**
  60608. * Rebuilds the elements related to this component in case of
  60609. * context lost for instance.
  60610. */
  60611. rebuild(): void;
  60612. /**
  60613. * Disposes the component and the associated ressources
  60614. */
  60615. dispose(): void;
  60616. private _gatherRenderTargets;
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60622. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60623. */
  60624. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60625. private _scene;
  60626. private _camerasToBeAttached;
  60627. /**
  60628. * ID of the sharpen post process,
  60629. */
  60630. private readonly SharpenPostProcessId;
  60631. /**
  60632. * @ignore
  60633. * ID of the image processing post process;
  60634. */
  60635. readonly ImageProcessingPostProcessId: string;
  60636. /**
  60637. * @ignore
  60638. * ID of the Fast Approximate Anti-Aliasing post process;
  60639. */
  60640. readonly FxaaPostProcessId: string;
  60641. /**
  60642. * ID of the chromatic aberration post process,
  60643. */
  60644. private readonly ChromaticAberrationPostProcessId;
  60645. /**
  60646. * ID of the grain post process
  60647. */
  60648. private readonly GrainPostProcessId;
  60649. /**
  60650. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60651. */
  60652. sharpen: SharpenPostProcess;
  60653. private _sharpenEffect;
  60654. private bloom;
  60655. /**
  60656. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60657. */
  60658. depthOfField: DepthOfFieldEffect;
  60659. /**
  60660. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60661. */
  60662. fxaa: FxaaPostProcess;
  60663. /**
  60664. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60665. */
  60666. imageProcessing: ImageProcessingPostProcess;
  60667. /**
  60668. * Chromatic aberration post process which will shift rgb colors in the image
  60669. */
  60670. chromaticAberration: ChromaticAberrationPostProcess;
  60671. private _chromaticAberrationEffect;
  60672. /**
  60673. * Grain post process which add noise to the image
  60674. */
  60675. grain: GrainPostProcess;
  60676. private _grainEffect;
  60677. /**
  60678. * Glow post process which adds a glow to emissive areas of the image
  60679. */
  60680. private _glowLayer;
  60681. /**
  60682. * Animations which can be used to tweak settings over a period of time
  60683. */
  60684. animations: Animation[];
  60685. private _imageProcessingConfigurationObserver;
  60686. private _sharpenEnabled;
  60687. private _bloomEnabled;
  60688. private _depthOfFieldEnabled;
  60689. private _depthOfFieldBlurLevel;
  60690. private _fxaaEnabled;
  60691. private _imageProcessingEnabled;
  60692. private _defaultPipelineTextureType;
  60693. private _bloomScale;
  60694. private _chromaticAberrationEnabled;
  60695. private _grainEnabled;
  60696. private _buildAllowed;
  60697. /**
  60698. * Gets active scene
  60699. */
  60700. readonly scene: Scene;
  60701. /**
  60702. * Enable or disable the sharpen process from the pipeline
  60703. */
  60704. sharpenEnabled: boolean;
  60705. private _resizeObserver;
  60706. private _hardwareScaleLevel;
  60707. private _bloomKernel;
  60708. /**
  60709. * Specifies the size of the bloom blur kernel, relative to the final output size
  60710. */
  60711. bloomKernel: number;
  60712. /**
  60713. * Specifies the weight of the bloom in the final rendering
  60714. */
  60715. private _bloomWeight;
  60716. /**
  60717. * Specifies the luma threshold for the area that will be blurred by the bloom
  60718. */
  60719. private _bloomThreshold;
  60720. private _hdr;
  60721. /**
  60722. * The strength of the bloom.
  60723. */
  60724. bloomWeight: number;
  60725. /**
  60726. * The strength of the bloom.
  60727. */
  60728. bloomThreshold: number;
  60729. /**
  60730. * The scale of the bloom, lower value will provide better performance.
  60731. */
  60732. bloomScale: number;
  60733. /**
  60734. * Enable or disable the bloom from the pipeline
  60735. */
  60736. bloomEnabled: boolean;
  60737. private _rebuildBloom;
  60738. /**
  60739. * If the depth of field is enabled.
  60740. */
  60741. depthOfFieldEnabled: boolean;
  60742. /**
  60743. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60744. */
  60745. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60746. /**
  60747. * If the anti aliasing is enabled.
  60748. */
  60749. fxaaEnabled: boolean;
  60750. private _samples;
  60751. /**
  60752. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60753. */
  60754. samples: number;
  60755. /**
  60756. * If image processing is enabled.
  60757. */
  60758. imageProcessingEnabled: boolean;
  60759. /**
  60760. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60761. */
  60762. glowLayerEnabled: boolean;
  60763. /**
  60764. * Gets the glow layer (or null if not defined)
  60765. */
  60766. readonly glowLayer: Nullable<GlowLayer>;
  60767. /**
  60768. * Enable or disable the chromaticAberration process from the pipeline
  60769. */
  60770. chromaticAberrationEnabled: boolean;
  60771. /**
  60772. * Enable or disable the grain process from the pipeline
  60773. */
  60774. grainEnabled: boolean;
  60775. /**
  60776. * @constructor
  60777. * @param name - The rendering pipeline name (default: "")
  60778. * @param hdr - If high dynamic range textures should be used (default: true)
  60779. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60780. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60781. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60782. */
  60783. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60784. /**
  60785. * Get the class name
  60786. * @returns "DefaultRenderingPipeline"
  60787. */
  60788. getClassName(): string;
  60789. /**
  60790. * Force the compilation of the entire pipeline.
  60791. */
  60792. prepare(): void;
  60793. private _hasCleared;
  60794. private _prevPostProcess;
  60795. private _prevPrevPostProcess;
  60796. private _setAutoClearAndTextureSharing;
  60797. private _depthOfFieldSceneObserver;
  60798. private _buildPipeline;
  60799. private _disposePostProcesses;
  60800. /**
  60801. * Adds a camera to the pipeline
  60802. * @param camera the camera to be added
  60803. */
  60804. addCamera(camera: Camera): void;
  60805. /**
  60806. * Removes a camera from the pipeline
  60807. * @param camera the camera to remove
  60808. */
  60809. removeCamera(camera: Camera): void;
  60810. /**
  60811. * Dispose of the pipeline and stop all post processes
  60812. */
  60813. dispose(): void;
  60814. /**
  60815. * Serialize the rendering pipeline (Used when exporting)
  60816. * @returns the serialized object
  60817. */
  60818. serialize(): any;
  60819. /**
  60820. * Parse the serialized pipeline
  60821. * @param source Source pipeline.
  60822. * @param scene The scene to load the pipeline to.
  60823. * @param rootUrl The URL of the serialized pipeline.
  60824. * @returns An instantiated pipeline from the serialized object.
  60825. */
  60826. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60827. }
  60828. }
  60829. declare module BABYLON {
  60830. /** @hidden */
  60831. export var lensHighlightsPixelShader: {
  60832. name: string;
  60833. shader: string;
  60834. };
  60835. }
  60836. declare module BABYLON {
  60837. /** @hidden */
  60838. export var depthOfFieldPixelShader: {
  60839. name: string;
  60840. shader: string;
  60841. };
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * BABYLON.JS Chromatic Aberration GLSL Shader
  60846. * Author: Olivier Guyot
  60847. * Separates very slightly R, G and B colors on the edges of the screen
  60848. * Inspired by Francois Tarlier & Martins Upitis
  60849. */
  60850. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60851. /**
  60852. * @ignore
  60853. * The chromatic aberration PostProcess id in the pipeline
  60854. */
  60855. LensChromaticAberrationEffect: string;
  60856. /**
  60857. * @ignore
  60858. * The highlights enhancing PostProcess id in the pipeline
  60859. */
  60860. HighlightsEnhancingEffect: string;
  60861. /**
  60862. * @ignore
  60863. * The depth-of-field PostProcess id in the pipeline
  60864. */
  60865. LensDepthOfFieldEffect: string;
  60866. private _scene;
  60867. private _depthTexture;
  60868. private _grainTexture;
  60869. private _chromaticAberrationPostProcess;
  60870. private _highlightsPostProcess;
  60871. private _depthOfFieldPostProcess;
  60872. private _edgeBlur;
  60873. private _grainAmount;
  60874. private _chromaticAberration;
  60875. private _distortion;
  60876. private _highlightsGain;
  60877. private _highlightsThreshold;
  60878. private _dofDistance;
  60879. private _dofAperture;
  60880. private _dofDarken;
  60881. private _dofPentagon;
  60882. private _blurNoise;
  60883. /**
  60884. * @constructor
  60885. *
  60886. * Effect parameters are as follow:
  60887. * {
  60888. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60889. * edge_blur: number; // from 0 to x (1 for realism)
  60890. * distortion: number; // from 0 to x (1 for realism)
  60891. * grain_amount: number; // from 0 to 1
  60892. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60893. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60894. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60895. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60896. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60897. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60898. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60899. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60900. * }
  60901. * Note: if an effect parameter is unset, effect is disabled
  60902. *
  60903. * @param name The rendering pipeline name
  60904. * @param parameters - An object containing all parameters (see above)
  60905. * @param scene The scene linked to this pipeline
  60906. * @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)
  60907. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60908. */
  60909. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60910. /**
  60911. * Get the class name
  60912. * @returns "LensRenderingPipeline"
  60913. */
  60914. getClassName(): string;
  60915. /**
  60916. * Gets associated scene
  60917. */
  60918. readonly scene: Scene;
  60919. /**
  60920. * Gets or sets the edge blur
  60921. */
  60922. edgeBlur: number;
  60923. /**
  60924. * Gets or sets the grain amount
  60925. */
  60926. grainAmount: number;
  60927. /**
  60928. * Gets or sets the chromatic aberration amount
  60929. */
  60930. chromaticAberration: number;
  60931. /**
  60932. * Gets or sets the depth of field aperture
  60933. */
  60934. dofAperture: number;
  60935. /**
  60936. * Gets or sets the edge distortion
  60937. */
  60938. edgeDistortion: number;
  60939. /**
  60940. * Gets or sets the depth of field distortion
  60941. */
  60942. dofDistortion: number;
  60943. /**
  60944. * Gets or sets the darken out of focus amount
  60945. */
  60946. darkenOutOfFocus: number;
  60947. /**
  60948. * Gets or sets a boolean indicating if blur noise is enabled
  60949. */
  60950. blurNoise: boolean;
  60951. /**
  60952. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60953. */
  60954. pentagonBokeh: boolean;
  60955. /**
  60956. * Gets or sets the highlight grain amount
  60957. */
  60958. highlightsGain: number;
  60959. /**
  60960. * Gets or sets the highlight threshold
  60961. */
  60962. highlightsThreshold: number;
  60963. /**
  60964. * Sets the amount of blur at the edges
  60965. * @param amount blur amount
  60966. */
  60967. setEdgeBlur(amount: number): void;
  60968. /**
  60969. * Sets edge blur to 0
  60970. */
  60971. disableEdgeBlur(): void;
  60972. /**
  60973. * Sets the amout of grain
  60974. * @param amount Amount of grain
  60975. */
  60976. setGrainAmount(amount: number): void;
  60977. /**
  60978. * Set grain amount to 0
  60979. */
  60980. disableGrain(): void;
  60981. /**
  60982. * Sets the chromatic aberration amount
  60983. * @param amount amount of chromatic aberration
  60984. */
  60985. setChromaticAberration(amount: number): void;
  60986. /**
  60987. * Sets chromatic aberration amount to 0
  60988. */
  60989. disableChromaticAberration(): void;
  60990. /**
  60991. * Sets the EdgeDistortion amount
  60992. * @param amount amount of EdgeDistortion
  60993. */
  60994. setEdgeDistortion(amount: number): void;
  60995. /**
  60996. * Sets edge distortion to 0
  60997. */
  60998. disableEdgeDistortion(): void;
  60999. /**
  61000. * Sets the FocusDistance amount
  61001. * @param amount amount of FocusDistance
  61002. */
  61003. setFocusDistance(amount: number): void;
  61004. /**
  61005. * Disables depth of field
  61006. */
  61007. disableDepthOfField(): void;
  61008. /**
  61009. * Sets the Aperture amount
  61010. * @param amount amount of Aperture
  61011. */
  61012. setAperture(amount: number): void;
  61013. /**
  61014. * Sets the DarkenOutOfFocus amount
  61015. * @param amount amount of DarkenOutOfFocus
  61016. */
  61017. setDarkenOutOfFocus(amount: number): void;
  61018. private _pentagonBokehIsEnabled;
  61019. /**
  61020. * Creates a pentagon bokeh effect
  61021. */
  61022. enablePentagonBokeh(): void;
  61023. /**
  61024. * Disables the pentagon bokeh effect
  61025. */
  61026. disablePentagonBokeh(): void;
  61027. /**
  61028. * Enables noise blur
  61029. */
  61030. enableNoiseBlur(): void;
  61031. /**
  61032. * Disables noise blur
  61033. */
  61034. disableNoiseBlur(): void;
  61035. /**
  61036. * Sets the HighlightsGain amount
  61037. * @param amount amount of HighlightsGain
  61038. */
  61039. setHighlightsGain(amount: number): void;
  61040. /**
  61041. * Sets the HighlightsThreshold amount
  61042. * @param amount amount of HighlightsThreshold
  61043. */
  61044. setHighlightsThreshold(amount: number): void;
  61045. /**
  61046. * Disables highlights
  61047. */
  61048. disableHighlights(): void;
  61049. /**
  61050. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61051. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61052. */
  61053. dispose(disableDepthRender?: boolean): void;
  61054. private _createChromaticAberrationPostProcess;
  61055. private _createHighlightsPostProcess;
  61056. private _createDepthOfFieldPostProcess;
  61057. private _createGrainTexture;
  61058. }
  61059. }
  61060. declare module BABYLON {
  61061. /** @hidden */
  61062. export var ssao2PixelShader: {
  61063. name: string;
  61064. shader: string;
  61065. };
  61066. }
  61067. declare module BABYLON {
  61068. /** @hidden */
  61069. export var ssaoCombinePixelShader: {
  61070. name: string;
  61071. shader: string;
  61072. };
  61073. }
  61074. declare module BABYLON {
  61075. /**
  61076. * Render pipeline to produce ssao effect
  61077. */
  61078. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61079. /**
  61080. * @ignore
  61081. * The PassPostProcess id in the pipeline that contains the original scene color
  61082. */
  61083. SSAOOriginalSceneColorEffect: string;
  61084. /**
  61085. * @ignore
  61086. * The SSAO PostProcess id in the pipeline
  61087. */
  61088. SSAORenderEffect: string;
  61089. /**
  61090. * @ignore
  61091. * The horizontal blur PostProcess id in the pipeline
  61092. */
  61093. SSAOBlurHRenderEffect: string;
  61094. /**
  61095. * @ignore
  61096. * The vertical blur PostProcess id in the pipeline
  61097. */
  61098. SSAOBlurVRenderEffect: string;
  61099. /**
  61100. * @ignore
  61101. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61102. */
  61103. SSAOCombineRenderEffect: string;
  61104. /**
  61105. * The output strength of the SSAO post-process. Default value is 1.0.
  61106. */
  61107. totalStrength: number;
  61108. /**
  61109. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61110. */
  61111. maxZ: number;
  61112. /**
  61113. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61114. */
  61115. minZAspect: number;
  61116. private _samples;
  61117. /**
  61118. * Number of samples used for the SSAO calculations. Default value is 8
  61119. */
  61120. samples: number;
  61121. private _textureSamples;
  61122. /**
  61123. * Number of samples to use for antialiasing
  61124. */
  61125. textureSamples: number;
  61126. /**
  61127. * Ratio object used for SSAO ratio and blur ratio
  61128. */
  61129. private _ratio;
  61130. /**
  61131. * Dynamically generated sphere sampler.
  61132. */
  61133. private _sampleSphere;
  61134. /**
  61135. * Blur filter offsets
  61136. */
  61137. private _samplerOffsets;
  61138. private _expensiveBlur;
  61139. /**
  61140. * If bilateral blur should be used
  61141. */
  61142. expensiveBlur: boolean;
  61143. /**
  61144. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61145. */
  61146. radius: number;
  61147. /**
  61148. * The base color of the SSAO post-process
  61149. * The final result is "base + ssao" between [0, 1]
  61150. */
  61151. base: number;
  61152. /**
  61153. * Support test.
  61154. */
  61155. static readonly IsSupported: boolean;
  61156. private _scene;
  61157. private _depthTexture;
  61158. private _normalTexture;
  61159. private _randomTexture;
  61160. private _originalColorPostProcess;
  61161. private _ssaoPostProcess;
  61162. private _blurHPostProcess;
  61163. private _blurVPostProcess;
  61164. private _ssaoCombinePostProcess;
  61165. private _firstUpdate;
  61166. /**
  61167. * Gets active scene
  61168. */
  61169. readonly scene: Scene;
  61170. /**
  61171. * @constructor
  61172. * @param name The rendering pipeline name
  61173. * @param scene The scene linked to this pipeline
  61174. * @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 }
  61175. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61176. */
  61177. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61178. /**
  61179. * Get the class name
  61180. * @returns "SSAO2RenderingPipeline"
  61181. */
  61182. getClassName(): string;
  61183. /**
  61184. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61185. */
  61186. dispose(disableGeometryBufferRenderer?: boolean): void;
  61187. private _createBlurPostProcess;
  61188. /** @hidden */
  61189. _rebuild(): void;
  61190. private _bits;
  61191. private _radicalInverse_VdC;
  61192. private _hammersley;
  61193. private _hemisphereSample_uniform;
  61194. private _generateHemisphere;
  61195. private _createSSAOPostProcess;
  61196. private _createSSAOCombinePostProcess;
  61197. private _createRandomTexture;
  61198. /**
  61199. * Serialize the rendering pipeline (Used when exporting)
  61200. * @returns the serialized object
  61201. */
  61202. serialize(): any;
  61203. /**
  61204. * Parse the serialized pipeline
  61205. * @param source Source pipeline.
  61206. * @param scene The scene to load the pipeline to.
  61207. * @param rootUrl The URL of the serialized pipeline.
  61208. * @returns An instantiated pipeline from the serialized object.
  61209. */
  61210. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61211. }
  61212. }
  61213. declare module BABYLON {
  61214. /** @hidden */
  61215. export var ssaoPixelShader: {
  61216. name: string;
  61217. shader: string;
  61218. };
  61219. }
  61220. declare module BABYLON {
  61221. /**
  61222. * Render pipeline to produce ssao effect
  61223. */
  61224. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61225. /**
  61226. * @ignore
  61227. * The PassPostProcess id in the pipeline that contains the original scene color
  61228. */
  61229. SSAOOriginalSceneColorEffect: string;
  61230. /**
  61231. * @ignore
  61232. * The SSAO PostProcess id in the pipeline
  61233. */
  61234. SSAORenderEffect: string;
  61235. /**
  61236. * @ignore
  61237. * The horizontal blur PostProcess id in the pipeline
  61238. */
  61239. SSAOBlurHRenderEffect: string;
  61240. /**
  61241. * @ignore
  61242. * The vertical blur PostProcess id in the pipeline
  61243. */
  61244. SSAOBlurVRenderEffect: string;
  61245. /**
  61246. * @ignore
  61247. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61248. */
  61249. SSAOCombineRenderEffect: string;
  61250. /**
  61251. * The output strength of the SSAO post-process. Default value is 1.0.
  61252. */
  61253. totalStrength: number;
  61254. /**
  61255. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61256. */
  61257. radius: number;
  61258. /**
  61259. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61260. * Must not be equal to fallOff and superior to fallOff.
  61261. * Default value is 0.0075
  61262. */
  61263. area: number;
  61264. /**
  61265. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61266. * Must not be equal to area and inferior to area.
  61267. * Default value is 0.000001
  61268. */
  61269. fallOff: number;
  61270. /**
  61271. * The base color of the SSAO post-process
  61272. * The final result is "base + ssao" between [0, 1]
  61273. */
  61274. base: number;
  61275. private _scene;
  61276. private _depthTexture;
  61277. private _randomTexture;
  61278. private _originalColorPostProcess;
  61279. private _ssaoPostProcess;
  61280. private _blurHPostProcess;
  61281. private _blurVPostProcess;
  61282. private _ssaoCombinePostProcess;
  61283. private _firstUpdate;
  61284. /**
  61285. * Gets active scene
  61286. */
  61287. readonly scene: Scene;
  61288. /**
  61289. * @constructor
  61290. * @param name - The rendering pipeline name
  61291. * @param scene - The scene linked to this pipeline
  61292. * @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 }
  61293. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61294. */
  61295. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61296. /**
  61297. * Get the class name
  61298. * @returns "SSAORenderingPipeline"
  61299. */
  61300. getClassName(): string;
  61301. /**
  61302. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61303. */
  61304. dispose(disableDepthRender?: boolean): void;
  61305. private _createBlurPostProcess;
  61306. /** @hidden */
  61307. _rebuild(): void;
  61308. private _createSSAOPostProcess;
  61309. private _createSSAOCombinePostProcess;
  61310. private _createRandomTexture;
  61311. }
  61312. }
  61313. declare module BABYLON {
  61314. /** @hidden */
  61315. export var standardPixelShader: {
  61316. name: string;
  61317. shader: string;
  61318. };
  61319. }
  61320. declare module BABYLON {
  61321. /**
  61322. * Standard rendering pipeline
  61323. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61324. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61325. */
  61326. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61327. /**
  61328. * Public members
  61329. */
  61330. /**
  61331. * Post-process which contains the original scene color before the pipeline applies all the effects
  61332. */
  61333. originalPostProcess: Nullable<PostProcess>;
  61334. /**
  61335. * Post-process used to down scale an image x4
  61336. */
  61337. downSampleX4PostProcess: Nullable<PostProcess>;
  61338. /**
  61339. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61340. */
  61341. brightPassPostProcess: Nullable<PostProcess>;
  61342. /**
  61343. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61344. */
  61345. blurHPostProcesses: PostProcess[];
  61346. /**
  61347. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61348. */
  61349. blurVPostProcesses: PostProcess[];
  61350. /**
  61351. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61352. */
  61353. textureAdderPostProcess: Nullable<PostProcess>;
  61354. /**
  61355. * Post-process used to create volumetric lighting effect
  61356. */
  61357. volumetricLightPostProcess: Nullable<PostProcess>;
  61358. /**
  61359. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61360. */
  61361. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61362. /**
  61363. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61364. */
  61365. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61366. /**
  61367. * Post-process used to merge the volumetric light effect and the real scene color
  61368. */
  61369. volumetricLightMergePostProces: Nullable<PostProcess>;
  61370. /**
  61371. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61372. */
  61373. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61374. /**
  61375. * Base post-process used to calculate the average luminance of the final image for HDR
  61376. */
  61377. luminancePostProcess: Nullable<PostProcess>;
  61378. /**
  61379. * Post-processes used to create down sample post-processes in order to get
  61380. * the average luminance of the final image for HDR
  61381. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61382. */
  61383. luminanceDownSamplePostProcesses: PostProcess[];
  61384. /**
  61385. * Post-process used to create a HDR effect (light adaptation)
  61386. */
  61387. hdrPostProcess: Nullable<PostProcess>;
  61388. /**
  61389. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61390. */
  61391. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61392. /**
  61393. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61394. */
  61395. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61396. /**
  61397. * Post-process used to merge the final HDR post-process and the real scene color
  61398. */
  61399. hdrFinalPostProcess: Nullable<PostProcess>;
  61400. /**
  61401. * Post-process used to create a lens flare effect
  61402. */
  61403. lensFlarePostProcess: Nullable<PostProcess>;
  61404. /**
  61405. * Post-process that merges the result of the lens flare post-process and the real scene color
  61406. */
  61407. lensFlareComposePostProcess: Nullable<PostProcess>;
  61408. /**
  61409. * Post-process used to create a motion blur effect
  61410. */
  61411. motionBlurPostProcess: Nullable<PostProcess>;
  61412. /**
  61413. * Post-process used to create a depth of field effect
  61414. */
  61415. depthOfFieldPostProcess: Nullable<PostProcess>;
  61416. /**
  61417. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61418. */
  61419. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61420. /**
  61421. * Represents the brightness threshold in order to configure the illuminated surfaces
  61422. */
  61423. brightThreshold: number;
  61424. /**
  61425. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61426. */
  61427. blurWidth: number;
  61428. /**
  61429. * Sets if the blur for highlighted surfaces must be only horizontal
  61430. */
  61431. horizontalBlur: boolean;
  61432. /**
  61433. * Gets the overall exposure used by the pipeline
  61434. */
  61435. /**
  61436. * Sets the overall exposure used by the pipeline
  61437. */
  61438. exposure: number;
  61439. /**
  61440. * Texture used typically to simulate "dirty" on camera lens
  61441. */
  61442. lensTexture: Nullable<Texture>;
  61443. /**
  61444. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61445. */
  61446. volumetricLightCoefficient: number;
  61447. /**
  61448. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61449. */
  61450. volumetricLightPower: number;
  61451. /**
  61452. * Used the set the blur intensity to smooth the volumetric lights
  61453. */
  61454. volumetricLightBlurScale: number;
  61455. /**
  61456. * Light (spot or directional) used to generate the volumetric lights rays
  61457. * The source light must have a shadow generate so the pipeline can get its
  61458. * depth map
  61459. */
  61460. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61461. /**
  61462. * For eye adaptation, represents the minimum luminance the eye can see
  61463. */
  61464. hdrMinimumLuminance: number;
  61465. /**
  61466. * For eye adaptation, represents the decrease luminance speed
  61467. */
  61468. hdrDecreaseRate: number;
  61469. /**
  61470. * For eye adaptation, represents the increase luminance speed
  61471. */
  61472. hdrIncreaseRate: number;
  61473. /**
  61474. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61475. */
  61476. /**
  61477. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61478. */
  61479. hdrAutoExposure: boolean;
  61480. /**
  61481. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61482. */
  61483. lensColorTexture: Nullable<Texture>;
  61484. /**
  61485. * The overall strengh for the lens flare effect
  61486. */
  61487. lensFlareStrength: number;
  61488. /**
  61489. * Dispersion coefficient for lens flare ghosts
  61490. */
  61491. lensFlareGhostDispersal: number;
  61492. /**
  61493. * Main lens flare halo width
  61494. */
  61495. lensFlareHaloWidth: number;
  61496. /**
  61497. * Based on the lens distortion effect, defines how much the lens flare result
  61498. * is distorted
  61499. */
  61500. lensFlareDistortionStrength: number;
  61501. /**
  61502. * Configures the blur intensity used for for lens flare (halo)
  61503. */
  61504. lensFlareBlurWidth: number;
  61505. /**
  61506. * Lens star texture must be used to simulate rays on the flares and is available
  61507. * in the documentation
  61508. */
  61509. lensStarTexture: Nullable<Texture>;
  61510. /**
  61511. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61512. * flare effect by taking account of the dirt texture
  61513. */
  61514. lensFlareDirtTexture: Nullable<Texture>;
  61515. /**
  61516. * Represents the focal length for the depth of field effect
  61517. */
  61518. depthOfFieldDistance: number;
  61519. /**
  61520. * Represents the blur intensity for the blurred part of the depth of field effect
  61521. */
  61522. depthOfFieldBlurWidth: number;
  61523. /**
  61524. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61525. */
  61526. /**
  61527. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61528. */
  61529. motionStrength: number;
  61530. /**
  61531. * Gets wether or not the motion blur post-process is object based or screen based.
  61532. */
  61533. /**
  61534. * Sets wether or not the motion blur post-process should be object based or screen based
  61535. */
  61536. objectBasedMotionBlur: boolean;
  61537. /**
  61538. * List of animations for the pipeline (IAnimatable implementation)
  61539. */
  61540. animations: Animation[];
  61541. /**
  61542. * Private members
  61543. */
  61544. private _scene;
  61545. private _currentDepthOfFieldSource;
  61546. private _basePostProcess;
  61547. private _fixedExposure;
  61548. private _currentExposure;
  61549. private _hdrAutoExposure;
  61550. private _hdrCurrentLuminance;
  61551. private _motionStrength;
  61552. private _isObjectBasedMotionBlur;
  61553. private _floatTextureType;
  61554. private _camerasToBeAttached;
  61555. private _ratio;
  61556. private _bloomEnabled;
  61557. private _depthOfFieldEnabled;
  61558. private _vlsEnabled;
  61559. private _lensFlareEnabled;
  61560. private _hdrEnabled;
  61561. private _motionBlurEnabled;
  61562. private _fxaaEnabled;
  61563. private _motionBlurSamples;
  61564. private _volumetricLightStepsCount;
  61565. private _samples;
  61566. /**
  61567. * @ignore
  61568. * Specifies if the bloom pipeline is enabled
  61569. */
  61570. BloomEnabled: boolean;
  61571. /**
  61572. * @ignore
  61573. * Specifies if the depth of field pipeline is enabed
  61574. */
  61575. DepthOfFieldEnabled: boolean;
  61576. /**
  61577. * @ignore
  61578. * Specifies if the lens flare pipeline is enabed
  61579. */
  61580. LensFlareEnabled: boolean;
  61581. /**
  61582. * @ignore
  61583. * Specifies if the HDR pipeline is enabled
  61584. */
  61585. HDREnabled: boolean;
  61586. /**
  61587. * @ignore
  61588. * Specifies if the volumetric lights scattering effect is enabled
  61589. */
  61590. VLSEnabled: boolean;
  61591. /**
  61592. * @ignore
  61593. * Specifies if the motion blur effect is enabled
  61594. */
  61595. MotionBlurEnabled: boolean;
  61596. /**
  61597. * Specifies if anti-aliasing is enabled
  61598. */
  61599. fxaaEnabled: boolean;
  61600. /**
  61601. * Specifies the number of steps used to calculate the volumetric lights
  61602. * Typically in interval [50, 200]
  61603. */
  61604. volumetricLightStepsCount: number;
  61605. /**
  61606. * Specifies the number of samples used for the motion blur effect
  61607. * Typically in interval [16, 64]
  61608. */
  61609. motionBlurSamples: number;
  61610. /**
  61611. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61612. */
  61613. samples: number;
  61614. /**
  61615. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61616. * @constructor
  61617. * @param name The rendering pipeline name
  61618. * @param scene The scene linked to this pipeline
  61619. * @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)
  61620. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61621. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61622. */
  61623. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61624. private _buildPipeline;
  61625. private _createDownSampleX4PostProcess;
  61626. private _createBrightPassPostProcess;
  61627. private _createBlurPostProcesses;
  61628. private _createTextureAdderPostProcess;
  61629. private _createVolumetricLightPostProcess;
  61630. private _createLuminancePostProcesses;
  61631. private _createHdrPostProcess;
  61632. private _createLensFlarePostProcess;
  61633. private _createDepthOfFieldPostProcess;
  61634. private _createMotionBlurPostProcess;
  61635. private _getDepthTexture;
  61636. private _disposePostProcesses;
  61637. /**
  61638. * Dispose of the pipeline and stop all post processes
  61639. */
  61640. dispose(): void;
  61641. /**
  61642. * Serialize the rendering pipeline (Used when exporting)
  61643. * @returns the serialized object
  61644. */
  61645. serialize(): any;
  61646. /**
  61647. * Parse the serialized pipeline
  61648. * @param source Source pipeline.
  61649. * @param scene The scene to load the pipeline to.
  61650. * @param rootUrl The URL of the serialized pipeline.
  61651. * @returns An instantiated pipeline from the serialized object.
  61652. */
  61653. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61654. /**
  61655. * Luminance steps
  61656. */
  61657. static LuminanceSteps: number;
  61658. }
  61659. }
  61660. declare module BABYLON {
  61661. /** @hidden */
  61662. export var tonemapPixelShader: {
  61663. name: string;
  61664. shader: string;
  61665. };
  61666. }
  61667. declare module BABYLON {
  61668. /** Defines operator used for tonemapping */
  61669. export enum TonemappingOperator {
  61670. /** Hable */
  61671. Hable = 0,
  61672. /** Reinhard */
  61673. Reinhard = 1,
  61674. /** HejiDawson */
  61675. HejiDawson = 2,
  61676. /** Photographic */
  61677. Photographic = 3
  61678. }
  61679. /**
  61680. * Defines a post process to apply tone mapping
  61681. */
  61682. export class TonemapPostProcess extends PostProcess {
  61683. private _operator;
  61684. /** Defines the required exposure adjustement */
  61685. exposureAdjustment: number;
  61686. /**
  61687. * Creates a new TonemapPostProcess
  61688. * @param name defines the name of the postprocess
  61689. * @param _operator defines the operator to use
  61690. * @param exposureAdjustment defines the required exposure adjustement
  61691. * @param camera defines the camera to use (can be null)
  61692. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61693. * @param engine defines the hosting engine (can be ignore if camera is set)
  61694. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61695. */
  61696. constructor(name: string, _operator: TonemappingOperator,
  61697. /** Defines the required exposure adjustement */
  61698. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61699. }
  61700. }
  61701. declare module BABYLON {
  61702. /** @hidden */
  61703. export var depthVertexShader: {
  61704. name: string;
  61705. shader: string;
  61706. };
  61707. }
  61708. declare module BABYLON {
  61709. /** @hidden */
  61710. export var volumetricLightScatteringPixelShader: {
  61711. name: string;
  61712. shader: string;
  61713. };
  61714. }
  61715. declare module BABYLON {
  61716. /** @hidden */
  61717. export var volumetricLightScatteringPassVertexShader: {
  61718. name: string;
  61719. shader: string;
  61720. };
  61721. }
  61722. declare module BABYLON {
  61723. /** @hidden */
  61724. export var volumetricLightScatteringPassPixelShader: {
  61725. name: string;
  61726. shader: string;
  61727. };
  61728. }
  61729. declare module BABYLON {
  61730. /**
  61731. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61732. */
  61733. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61734. private _volumetricLightScatteringPass;
  61735. private _volumetricLightScatteringRTT;
  61736. private _viewPort;
  61737. private _screenCoordinates;
  61738. private _cachedDefines;
  61739. /**
  61740. * If not undefined, the mesh position is computed from the attached node position
  61741. */
  61742. attachedNode: {
  61743. position: Vector3;
  61744. };
  61745. /**
  61746. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61747. */
  61748. customMeshPosition: Vector3;
  61749. /**
  61750. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61751. */
  61752. useCustomMeshPosition: boolean;
  61753. /**
  61754. * If the post-process should inverse the light scattering direction
  61755. */
  61756. invert: boolean;
  61757. /**
  61758. * The internal mesh used by the post-process
  61759. */
  61760. mesh: Mesh;
  61761. /**
  61762. * @hidden
  61763. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61764. */
  61765. useDiffuseColor: boolean;
  61766. /**
  61767. * Array containing the excluded meshes not rendered in the internal pass
  61768. */
  61769. excludedMeshes: AbstractMesh[];
  61770. /**
  61771. * Controls the overall intensity of the post-process
  61772. */
  61773. exposure: number;
  61774. /**
  61775. * Dissipates each sample's contribution in range [0, 1]
  61776. */
  61777. decay: number;
  61778. /**
  61779. * Controls the overall intensity of each sample
  61780. */
  61781. weight: number;
  61782. /**
  61783. * Controls the density of each sample
  61784. */
  61785. density: number;
  61786. /**
  61787. * @constructor
  61788. * @param name The post-process name
  61789. * @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)
  61790. * @param camera The camera that the post-process will be attached to
  61791. * @param mesh The mesh used to create the light scattering
  61792. * @param samples The post-process quality, default 100
  61793. * @param samplingModeThe post-process filtering mode
  61794. * @param engine The babylon engine
  61795. * @param reusable If the post-process is reusable
  61796. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61797. */
  61798. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61799. /**
  61800. * Returns the string "VolumetricLightScatteringPostProcess"
  61801. * @returns "VolumetricLightScatteringPostProcess"
  61802. */
  61803. getClassName(): string;
  61804. private _isReady;
  61805. /**
  61806. * Sets the new light position for light scattering effect
  61807. * @param position The new custom light position
  61808. */
  61809. setCustomMeshPosition(position: Vector3): void;
  61810. /**
  61811. * Returns the light position for light scattering effect
  61812. * @return Vector3 The custom light position
  61813. */
  61814. getCustomMeshPosition(): Vector3;
  61815. /**
  61816. * Disposes the internal assets and detaches the post-process from the camera
  61817. */
  61818. dispose(camera: Camera): void;
  61819. /**
  61820. * Returns the render target texture used by the post-process
  61821. * @return the render target texture used by the post-process
  61822. */
  61823. getPass(): RenderTargetTexture;
  61824. private _meshExcluded;
  61825. private _createPass;
  61826. private _updateMeshScreenCoordinates;
  61827. /**
  61828. * Creates a default mesh for the Volumeric Light Scattering post-process
  61829. * @param name The mesh name
  61830. * @param scene The scene where to create the mesh
  61831. * @return the default mesh
  61832. */
  61833. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61834. }
  61835. }
  61836. declare module BABYLON {
  61837. interface Scene {
  61838. /** @hidden (Backing field) */
  61839. _boundingBoxRenderer: BoundingBoxRenderer;
  61840. /** @hidden (Backing field) */
  61841. _forceShowBoundingBoxes: boolean;
  61842. /**
  61843. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61844. */
  61845. forceShowBoundingBoxes: boolean;
  61846. /**
  61847. * Gets the bounding box renderer associated with the scene
  61848. * @returns a BoundingBoxRenderer
  61849. */
  61850. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61851. }
  61852. interface AbstractMesh {
  61853. /** @hidden (Backing field) */
  61854. _showBoundingBox: boolean;
  61855. /**
  61856. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61857. */
  61858. showBoundingBox: boolean;
  61859. }
  61860. /**
  61861. * Component responsible of rendering the bounding box of the meshes in a scene.
  61862. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61863. */
  61864. export class BoundingBoxRenderer implements ISceneComponent {
  61865. /**
  61866. * The component name helpfull to identify the component in the list of scene components.
  61867. */
  61868. readonly name: string;
  61869. /**
  61870. * The scene the component belongs to.
  61871. */
  61872. scene: Scene;
  61873. /**
  61874. * Color of the bounding box lines placed in front of an object
  61875. */
  61876. frontColor: Color3;
  61877. /**
  61878. * Color of the bounding box lines placed behind an object
  61879. */
  61880. backColor: Color3;
  61881. /**
  61882. * Defines if the renderer should show the back lines or not
  61883. */
  61884. showBackLines: boolean;
  61885. /**
  61886. * @hidden
  61887. */
  61888. renderList: SmartArray<BoundingBox>;
  61889. private _colorShader;
  61890. private _vertexBuffers;
  61891. private _indexBuffer;
  61892. private _fillIndexBuffer;
  61893. private _fillIndexData;
  61894. /**
  61895. * Instantiates a new bounding box renderer in a scene.
  61896. * @param scene the scene the renderer renders in
  61897. */
  61898. constructor(scene: Scene);
  61899. /**
  61900. * Registers the component in a given scene
  61901. */
  61902. register(): void;
  61903. private _evaluateSubMesh;
  61904. private _activeMesh;
  61905. private _prepareRessources;
  61906. private _createIndexBuffer;
  61907. /**
  61908. * Rebuilds the elements related to this component in case of
  61909. * context lost for instance.
  61910. */
  61911. rebuild(): void;
  61912. /**
  61913. * @hidden
  61914. */
  61915. reset(): void;
  61916. /**
  61917. * Render the bounding boxes of a specific rendering group
  61918. * @param renderingGroupId defines the rendering group to render
  61919. */
  61920. render(renderingGroupId: number): void;
  61921. /**
  61922. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61923. * @param mesh Define the mesh to render the occlusion bounding box for
  61924. */
  61925. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61926. /**
  61927. * Dispose and release the resources attached to this renderer.
  61928. */
  61929. dispose(): void;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. /** @hidden */
  61934. export var depthPixelShader: {
  61935. name: string;
  61936. shader: string;
  61937. };
  61938. }
  61939. declare module BABYLON {
  61940. /**
  61941. * This represents a depth renderer in Babylon.
  61942. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61943. */
  61944. export class DepthRenderer {
  61945. private _scene;
  61946. private _depthMap;
  61947. private _effect;
  61948. private readonly _storeNonLinearDepth;
  61949. private readonly _clearColor;
  61950. /** Get if the depth renderer is using packed depth or not */
  61951. readonly isPacked: boolean;
  61952. private _cachedDefines;
  61953. private _camera;
  61954. /**
  61955. * Specifiess that the depth renderer will only be used within
  61956. * the camera it is created for.
  61957. * This can help forcing its rendering during the camera processing.
  61958. */
  61959. useOnlyInActiveCamera: boolean;
  61960. /** @hidden */
  61961. static _SceneComponentInitialization: (scene: Scene) => void;
  61962. /**
  61963. * Instantiates a depth renderer
  61964. * @param scene The scene the renderer belongs to
  61965. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61966. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61967. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61968. */
  61969. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61970. /**
  61971. * Creates the depth rendering effect and checks if the effect is ready.
  61972. * @param subMesh The submesh to be used to render the depth map of
  61973. * @param useInstances If multiple world instances should be used
  61974. * @returns if the depth renderer is ready to render the depth map
  61975. */
  61976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61977. /**
  61978. * Gets the texture which the depth map will be written to.
  61979. * @returns The depth map texture
  61980. */
  61981. getDepthMap(): RenderTargetTexture;
  61982. /**
  61983. * Disposes of the depth renderer.
  61984. */
  61985. dispose(): void;
  61986. }
  61987. }
  61988. declare module BABYLON {
  61989. interface Scene {
  61990. /** @hidden (Backing field) */
  61991. _depthRenderer: {
  61992. [id: string]: DepthRenderer;
  61993. };
  61994. /**
  61995. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61996. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61997. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61998. * @returns the created depth renderer
  61999. */
  62000. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62001. /**
  62002. * Disables a depth renderer for a given camera
  62003. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62004. */
  62005. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62006. }
  62007. /**
  62008. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62009. * in several rendering techniques.
  62010. */
  62011. export class DepthRendererSceneComponent implements ISceneComponent {
  62012. /**
  62013. * The component name helpfull to identify the component in the list of scene components.
  62014. */
  62015. readonly name: string;
  62016. /**
  62017. * The scene the component belongs to.
  62018. */
  62019. scene: Scene;
  62020. /**
  62021. * Creates a new instance of the component for the given scene
  62022. * @param scene Defines the scene to register the component in
  62023. */
  62024. constructor(scene: Scene);
  62025. /**
  62026. * Registers the component in a given scene
  62027. */
  62028. register(): void;
  62029. /**
  62030. * Rebuilds the elements related to this component in case of
  62031. * context lost for instance.
  62032. */
  62033. rebuild(): void;
  62034. /**
  62035. * Disposes the component and the associated ressources
  62036. */
  62037. dispose(): void;
  62038. private _gatherRenderTargets;
  62039. private _gatherActiveCameraRenderTargets;
  62040. }
  62041. }
  62042. declare module BABYLON {
  62043. /** @hidden */
  62044. export var outlinePixelShader: {
  62045. name: string;
  62046. shader: string;
  62047. };
  62048. }
  62049. declare module BABYLON {
  62050. /** @hidden */
  62051. export var outlineVertexShader: {
  62052. name: string;
  62053. shader: string;
  62054. };
  62055. }
  62056. declare module BABYLON {
  62057. interface Scene {
  62058. /** @hidden */
  62059. _outlineRenderer: OutlineRenderer;
  62060. /**
  62061. * Gets the outline renderer associated with the scene
  62062. * @returns a OutlineRenderer
  62063. */
  62064. getOutlineRenderer(): OutlineRenderer;
  62065. }
  62066. interface AbstractMesh {
  62067. /** @hidden (Backing field) */
  62068. _renderOutline: boolean;
  62069. /**
  62070. * Gets or sets a boolean indicating if the outline must be rendered as well
  62071. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62072. */
  62073. renderOutline: boolean;
  62074. /** @hidden (Backing field) */
  62075. _renderOverlay: boolean;
  62076. /**
  62077. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62078. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62079. */
  62080. renderOverlay: boolean;
  62081. }
  62082. /**
  62083. * This class is responsible to draw bothe outline/overlay of meshes.
  62084. * It should not be used directly but through the available method on mesh.
  62085. */
  62086. export class OutlineRenderer implements ISceneComponent {
  62087. /**
  62088. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62089. */
  62090. private static _StencilReference;
  62091. /**
  62092. * The name of the component. Each component must have a unique name.
  62093. */
  62094. name: string;
  62095. /**
  62096. * The scene the component belongs to.
  62097. */
  62098. scene: Scene;
  62099. /**
  62100. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62101. */
  62102. zOffset: number;
  62103. private _engine;
  62104. private _effect;
  62105. private _cachedDefines;
  62106. private _savedDepthWrite;
  62107. /**
  62108. * Instantiates a new outline renderer. (There could be only one per scene).
  62109. * @param scene Defines the scene it belongs to
  62110. */
  62111. constructor(scene: Scene);
  62112. /**
  62113. * Register the component to one instance of a scene.
  62114. */
  62115. register(): void;
  62116. /**
  62117. * Rebuilds the elements related to this component in case of
  62118. * context lost for instance.
  62119. */
  62120. rebuild(): void;
  62121. /**
  62122. * Disposes the component and the associated ressources.
  62123. */
  62124. dispose(): void;
  62125. /**
  62126. * Renders the outline in the canvas.
  62127. * @param subMesh Defines the sumesh to render
  62128. * @param batch Defines the batch of meshes in case of instances
  62129. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62130. */
  62131. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62132. /**
  62133. * Returns whether or not the outline renderer is ready for a given submesh.
  62134. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62135. * @param subMesh Defines the submesh to check readyness for
  62136. * @param useInstances Defines wheter wee are trying to render instances or not
  62137. * @returns true if ready otherwise false
  62138. */
  62139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62140. private _beforeRenderingMesh;
  62141. private _afterRenderingMesh;
  62142. }
  62143. }
  62144. declare module BABYLON {
  62145. /**
  62146. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62147. * @see http://doc.babylonjs.com/babylon101/sprites
  62148. */
  62149. export class SpritePackedManager extends SpriteManager {
  62150. /** defines the packed manager's name */
  62151. name: string;
  62152. /**
  62153. * Creates a new sprite manager from a packed sprite sheet
  62154. * @param name defines the manager's name
  62155. * @param imgUrl defines the sprite sheet url
  62156. * @param capacity defines the maximum allowed number of sprites
  62157. * @param scene defines the hosting scene
  62158. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62159. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62160. * @param samplingMode defines the smapling mode to use with spritesheet
  62161. * @param fromPacked set to true; do not alter
  62162. */
  62163. constructor(
  62164. /** defines the packed manager's name */
  62165. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62166. }
  62167. }
  62168. declare module BABYLON {
  62169. /**
  62170. * Defines the list of states available for a task inside a AssetsManager
  62171. */
  62172. export enum AssetTaskState {
  62173. /**
  62174. * Initialization
  62175. */
  62176. INIT = 0,
  62177. /**
  62178. * Running
  62179. */
  62180. RUNNING = 1,
  62181. /**
  62182. * Done
  62183. */
  62184. DONE = 2,
  62185. /**
  62186. * Error
  62187. */
  62188. ERROR = 3
  62189. }
  62190. /**
  62191. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62192. */
  62193. export abstract class AbstractAssetTask {
  62194. /**
  62195. * Task name
  62196. */ name: string;
  62197. /**
  62198. * Callback called when the task is successful
  62199. */
  62200. onSuccess: (task: any) => void;
  62201. /**
  62202. * Callback called when the task is not successful
  62203. */
  62204. onError: (task: any, message?: string, exception?: any) => void;
  62205. /**
  62206. * Creates a new AssetsManager
  62207. * @param name defines the name of the task
  62208. */
  62209. constructor(
  62210. /**
  62211. * Task name
  62212. */ name: string);
  62213. private _isCompleted;
  62214. private _taskState;
  62215. private _errorObject;
  62216. /**
  62217. * Get if the task is completed
  62218. */
  62219. readonly isCompleted: boolean;
  62220. /**
  62221. * Gets the current state of the task
  62222. */
  62223. readonly taskState: AssetTaskState;
  62224. /**
  62225. * Gets the current error object (if task is in error)
  62226. */
  62227. readonly errorObject: {
  62228. message?: string;
  62229. exception?: any;
  62230. };
  62231. /**
  62232. * Internal only
  62233. * @hidden
  62234. */
  62235. _setErrorObject(message?: string, exception?: any): void;
  62236. /**
  62237. * Execute the current task
  62238. * @param scene defines the scene where you want your assets to be loaded
  62239. * @param onSuccess is a callback called when the task is successfully executed
  62240. * @param onError is a callback called if an error occurs
  62241. */
  62242. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62243. /**
  62244. * Execute the current task
  62245. * @param scene defines the scene where you want your assets to be loaded
  62246. * @param onSuccess is a callback called when the task is successfully executed
  62247. * @param onError is a callback called if an error occurs
  62248. */
  62249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62250. /**
  62251. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62252. * This can be used with failed tasks that have the reason for failure fixed.
  62253. */
  62254. reset(): void;
  62255. private onErrorCallback;
  62256. private onDoneCallback;
  62257. }
  62258. /**
  62259. * Define the interface used by progress events raised during assets loading
  62260. */
  62261. export interface IAssetsProgressEvent {
  62262. /**
  62263. * Defines the number of remaining tasks to process
  62264. */
  62265. remainingCount: number;
  62266. /**
  62267. * Defines the total number of tasks
  62268. */
  62269. totalCount: number;
  62270. /**
  62271. * Defines the task that was just processed
  62272. */
  62273. task: AbstractAssetTask;
  62274. }
  62275. /**
  62276. * Class used to share progress information about assets loading
  62277. */
  62278. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62279. /**
  62280. * Defines the number of remaining tasks to process
  62281. */
  62282. remainingCount: number;
  62283. /**
  62284. * Defines the total number of tasks
  62285. */
  62286. totalCount: number;
  62287. /**
  62288. * Defines the task that was just processed
  62289. */
  62290. task: AbstractAssetTask;
  62291. /**
  62292. * Creates a AssetsProgressEvent
  62293. * @param remainingCount defines the number of remaining tasks to process
  62294. * @param totalCount defines the total number of tasks
  62295. * @param task defines the task that was just processed
  62296. */
  62297. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62298. }
  62299. /**
  62300. * Define a task used by AssetsManager to load meshes
  62301. */
  62302. export class MeshAssetTask extends AbstractAssetTask {
  62303. /**
  62304. * Defines the name of the task
  62305. */
  62306. name: string;
  62307. /**
  62308. * Defines the list of mesh's names you want to load
  62309. */
  62310. meshesNames: any;
  62311. /**
  62312. * Defines the root url to use as a base to load your meshes and associated resources
  62313. */
  62314. rootUrl: string;
  62315. /**
  62316. * Defines the filename of the scene to load from
  62317. */
  62318. sceneFilename: string;
  62319. /**
  62320. * Gets the list of loaded meshes
  62321. */
  62322. loadedMeshes: Array<AbstractMesh>;
  62323. /**
  62324. * Gets the list of loaded particle systems
  62325. */
  62326. loadedParticleSystems: Array<IParticleSystem>;
  62327. /**
  62328. * Gets the list of loaded skeletons
  62329. */
  62330. loadedSkeletons: Array<Skeleton>;
  62331. /**
  62332. * Gets the list of loaded animation groups
  62333. */
  62334. loadedAnimationGroups: Array<AnimationGroup>;
  62335. /**
  62336. * Callback called when the task is successful
  62337. */
  62338. onSuccess: (task: MeshAssetTask) => void;
  62339. /**
  62340. * Callback called when the task is successful
  62341. */
  62342. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62343. /**
  62344. * Creates a new MeshAssetTask
  62345. * @param name defines the name of the task
  62346. * @param meshesNames defines the list of mesh's names you want to load
  62347. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62348. * @param sceneFilename defines the filename of the scene to load from
  62349. */
  62350. constructor(
  62351. /**
  62352. * Defines the name of the task
  62353. */
  62354. name: string,
  62355. /**
  62356. * Defines the list of mesh's names you want to load
  62357. */
  62358. meshesNames: any,
  62359. /**
  62360. * Defines the root url to use as a base to load your meshes and associated resources
  62361. */
  62362. rootUrl: string,
  62363. /**
  62364. * Defines the filename of the scene to load from
  62365. */
  62366. sceneFilename: string);
  62367. /**
  62368. * Execute the current task
  62369. * @param scene defines the scene where you want your assets to be loaded
  62370. * @param onSuccess is a callback called when the task is successfully executed
  62371. * @param onError is a callback called if an error occurs
  62372. */
  62373. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62374. }
  62375. /**
  62376. * Define a task used by AssetsManager to load text content
  62377. */
  62378. export class TextFileAssetTask extends AbstractAssetTask {
  62379. /**
  62380. * Defines the name of the task
  62381. */
  62382. name: string;
  62383. /**
  62384. * Defines the location of the file to load
  62385. */
  62386. url: string;
  62387. /**
  62388. * Gets the loaded text string
  62389. */
  62390. text: string;
  62391. /**
  62392. * Callback called when the task is successful
  62393. */
  62394. onSuccess: (task: TextFileAssetTask) => void;
  62395. /**
  62396. * Callback called when the task is successful
  62397. */
  62398. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62399. /**
  62400. * Creates a new TextFileAssetTask object
  62401. * @param name defines the name of the task
  62402. * @param url defines the location of the file to load
  62403. */
  62404. constructor(
  62405. /**
  62406. * Defines the name of the task
  62407. */
  62408. name: string,
  62409. /**
  62410. * Defines the location of the file to load
  62411. */
  62412. url: string);
  62413. /**
  62414. * Execute the current task
  62415. * @param scene defines the scene where you want your assets to be loaded
  62416. * @param onSuccess is a callback called when the task is successfully executed
  62417. * @param onError is a callback called if an error occurs
  62418. */
  62419. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62420. }
  62421. /**
  62422. * Define a task used by AssetsManager to load binary data
  62423. */
  62424. export class BinaryFileAssetTask extends AbstractAssetTask {
  62425. /**
  62426. * Defines the name of the task
  62427. */
  62428. name: string;
  62429. /**
  62430. * Defines the location of the file to load
  62431. */
  62432. url: string;
  62433. /**
  62434. * Gets the lodaded data (as an array buffer)
  62435. */
  62436. data: ArrayBuffer;
  62437. /**
  62438. * Callback called when the task is successful
  62439. */
  62440. onSuccess: (task: BinaryFileAssetTask) => void;
  62441. /**
  62442. * Callback called when the task is successful
  62443. */
  62444. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62445. /**
  62446. * Creates a new BinaryFileAssetTask object
  62447. * @param name defines the name of the new task
  62448. * @param url defines the location of the file to load
  62449. */
  62450. constructor(
  62451. /**
  62452. * Defines the name of the task
  62453. */
  62454. name: string,
  62455. /**
  62456. * Defines the location of the file to load
  62457. */
  62458. url: string);
  62459. /**
  62460. * Execute the current task
  62461. * @param scene defines the scene where you want your assets to be loaded
  62462. * @param onSuccess is a callback called when the task is successfully executed
  62463. * @param onError is a callback called if an error occurs
  62464. */
  62465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62466. }
  62467. /**
  62468. * Define a task used by AssetsManager to load images
  62469. */
  62470. export class ImageAssetTask extends AbstractAssetTask {
  62471. /**
  62472. * Defines the name of the task
  62473. */
  62474. name: string;
  62475. /**
  62476. * Defines the location of the image to load
  62477. */
  62478. url: string;
  62479. /**
  62480. * Gets the loaded images
  62481. */
  62482. image: HTMLImageElement;
  62483. /**
  62484. * Callback called when the task is successful
  62485. */
  62486. onSuccess: (task: ImageAssetTask) => void;
  62487. /**
  62488. * Callback called when the task is successful
  62489. */
  62490. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62491. /**
  62492. * Creates a new ImageAssetTask
  62493. * @param name defines the name of the task
  62494. * @param url defines the location of the image to load
  62495. */
  62496. constructor(
  62497. /**
  62498. * Defines the name of the task
  62499. */
  62500. name: string,
  62501. /**
  62502. * Defines the location of the image to load
  62503. */
  62504. url: string);
  62505. /**
  62506. * Execute the current task
  62507. * @param scene defines the scene where you want your assets to be loaded
  62508. * @param onSuccess is a callback called when the task is successfully executed
  62509. * @param onError is a callback called if an error occurs
  62510. */
  62511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62512. }
  62513. /**
  62514. * Defines the interface used by texture loading tasks
  62515. */
  62516. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62517. /**
  62518. * Gets the loaded texture
  62519. */
  62520. texture: TEX;
  62521. }
  62522. /**
  62523. * Define a task used by AssetsManager to load 2D textures
  62524. */
  62525. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62526. /**
  62527. * Defines the name of the task
  62528. */
  62529. name: string;
  62530. /**
  62531. * Defines the location of the file to load
  62532. */
  62533. url: string;
  62534. /**
  62535. * Defines if mipmap should not be generated (default is false)
  62536. */
  62537. noMipmap?: boolean | undefined;
  62538. /**
  62539. * Defines if texture must be inverted on Y axis (default is false)
  62540. */
  62541. invertY?: boolean | undefined;
  62542. /**
  62543. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62544. */
  62545. samplingMode: number;
  62546. /**
  62547. * Gets the loaded texture
  62548. */
  62549. texture: Texture;
  62550. /**
  62551. * Callback called when the task is successful
  62552. */
  62553. onSuccess: (task: TextureAssetTask) => void;
  62554. /**
  62555. * Callback called when the task is successful
  62556. */
  62557. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62558. /**
  62559. * Creates a new TextureAssetTask object
  62560. * @param name defines the name of the task
  62561. * @param url defines the location of the file to load
  62562. * @param noMipmap defines if mipmap should not be generated (default is false)
  62563. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62564. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62565. */
  62566. constructor(
  62567. /**
  62568. * Defines the name of the task
  62569. */
  62570. name: string,
  62571. /**
  62572. * Defines the location of the file to load
  62573. */
  62574. url: string,
  62575. /**
  62576. * Defines if mipmap should not be generated (default is false)
  62577. */
  62578. noMipmap?: boolean | undefined,
  62579. /**
  62580. * Defines if texture must be inverted on Y axis (default is false)
  62581. */
  62582. invertY?: boolean | undefined,
  62583. /**
  62584. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62585. */
  62586. samplingMode?: number);
  62587. /**
  62588. * Execute the current task
  62589. * @param scene defines the scene where you want your assets to be loaded
  62590. * @param onSuccess is a callback called when the task is successfully executed
  62591. * @param onError is a callback called if an error occurs
  62592. */
  62593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62594. }
  62595. /**
  62596. * Define a task used by AssetsManager to load cube textures
  62597. */
  62598. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62599. /**
  62600. * Defines the name of the task
  62601. */
  62602. name: string;
  62603. /**
  62604. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62605. */
  62606. url: string;
  62607. /**
  62608. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62609. */
  62610. extensions?: string[] | undefined;
  62611. /**
  62612. * Defines if mipmaps should not be generated (default is false)
  62613. */
  62614. noMipmap?: boolean | undefined;
  62615. /**
  62616. * Defines the explicit list of files (undefined by default)
  62617. */
  62618. files?: string[] | undefined;
  62619. /**
  62620. * Gets the loaded texture
  62621. */
  62622. texture: CubeTexture;
  62623. /**
  62624. * Callback called when the task is successful
  62625. */
  62626. onSuccess: (task: CubeTextureAssetTask) => void;
  62627. /**
  62628. * Callback called when the task is successful
  62629. */
  62630. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62631. /**
  62632. * Creates a new CubeTextureAssetTask
  62633. * @param name defines the name of the task
  62634. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62635. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62636. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62637. * @param files defines the explicit list of files (undefined by default)
  62638. */
  62639. constructor(
  62640. /**
  62641. * Defines the name of the task
  62642. */
  62643. name: string,
  62644. /**
  62645. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62646. */
  62647. url: string,
  62648. /**
  62649. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62650. */
  62651. extensions?: string[] | undefined,
  62652. /**
  62653. * Defines if mipmaps should not be generated (default is false)
  62654. */
  62655. noMipmap?: boolean | undefined,
  62656. /**
  62657. * Defines the explicit list of files (undefined by default)
  62658. */
  62659. files?: string[] | undefined);
  62660. /**
  62661. * Execute the current task
  62662. * @param scene defines the scene where you want your assets to be loaded
  62663. * @param onSuccess is a callback called when the task is successfully executed
  62664. * @param onError is a callback called if an error occurs
  62665. */
  62666. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62667. }
  62668. /**
  62669. * Define a task used by AssetsManager to load HDR cube textures
  62670. */
  62671. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62672. /**
  62673. * Defines the name of the task
  62674. */
  62675. name: string;
  62676. /**
  62677. * Defines the location of the file to load
  62678. */
  62679. url: string;
  62680. /**
  62681. * Defines the desired size (the more it increases the longer the generation will be)
  62682. */
  62683. size: number;
  62684. /**
  62685. * Defines if mipmaps should not be generated (default is false)
  62686. */
  62687. noMipmap: boolean;
  62688. /**
  62689. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62690. */
  62691. generateHarmonics: boolean;
  62692. /**
  62693. * 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)
  62694. */
  62695. gammaSpace: boolean;
  62696. /**
  62697. * Internal Use Only
  62698. */
  62699. reserved: boolean;
  62700. /**
  62701. * Gets the loaded texture
  62702. */
  62703. texture: HDRCubeTexture;
  62704. /**
  62705. * Callback called when the task is successful
  62706. */
  62707. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62708. /**
  62709. * Callback called when the task is successful
  62710. */
  62711. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62712. /**
  62713. * Creates a new HDRCubeTextureAssetTask object
  62714. * @param name defines the name of the task
  62715. * @param url defines the location of the file to load
  62716. * @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.
  62717. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62718. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62719. * @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)
  62720. * @param reserved Internal use only
  62721. */
  62722. constructor(
  62723. /**
  62724. * Defines the name of the task
  62725. */
  62726. name: string,
  62727. /**
  62728. * Defines the location of the file to load
  62729. */
  62730. url: string,
  62731. /**
  62732. * Defines the desired size (the more it increases the longer the generation will be)
  62733. */
  62734. size: number,
  62735. /**
  62736. * Defines if mipmaps should not be generated (default is false)
  62737. */
  62738. noMipmap?: boolean,
  62739. /**
  62740. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62741. */
  62742. generateHarmonics?: boolean,
  62743. /**
  62744. * 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)
  62745. */
  62746. gammaSpace?: boolean,
  62747. /**
  62748. * Internal Use Only
  62749. */
  62750. reserved?: boolean);
  62751. /**
  62752. * Execute the current task
  62753. * @param scene defines the scene where you want your assets to be loaded
  62754. * @param onSuccess is a callback called when the task is successfully executed
  62755. * @param onError is a callback called if an error occurs
  62756. */
  62757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62758. }
  62759. /**
  62760. * Define a task used by AssetsManager to load Equirectangular cube textures
  62761. */
  62762. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62763. /**
  62764. * Defines the name of the task
  62765. */
  62766. name: string;
  62767. /**
  62768. * Defines the location of the file to load
  62769. */
  62770. url: string;
  62771. /**
  62772. * Defines the desired size (the more it increases the longer the generation will be)
  62773. */
  62774. size: number;
  62775. /**
  62776. * Defines if mipmaps should not be generated (default is false)
  62777. */
  62778. noMipmap: boolean;
  62779. /**
  62780. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62781. * but the standard material would require them in Gamma space) (default is true)
  62782. */
  62783. gammaSpace: boolean;
  62784. /**
  62785. * Gets the loaded texture
  62786. */
  62787. texture: EquiRectangularCubeTexture;
  62788. /**
  62789. * Callback called when the task is successful
  62790. */
  62791. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62792. /**
  62793. * Callback called when the task is successful
  62794. */
  62795. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62796. /**
  62797. * Creates a new EquiRectangularCubeTextureAssetTask object
  62798. * @param name defines the name of the task
  62799. * @param url defines the location of the file to load
  62800. * @param size defines the desired size (the more it increases the longer the generation will be)
  62801. * If the size is omitted this implies you are using a preprocessed cubemap.
  62802. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62803. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62804. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62805. * (default is true)
  62806. */
  62807. constructor(
  62808. /**
  62809. * Defines the name of the task
  62810. */
  62811. name: string,
  62812. /**
  62813. * Defines the location of the file to load
  62814. */
  62815. url: string,
  62816. /**
  62817. * Defines the desired size (the more it increases the longer the generation will be)
  62818. */
  62819. size: number,
  62820. /**
  62821. * Defines if mipmaps should not be generated (default is false)
  62822. */
  62823. noMipmap?: boolean,
  62824. /**
  62825. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62826. * but the standard material would require them in Gamma space) (default is true)
  62827. */
  62828. gammaSpace?: boolean);
  62829. /**
  62830. * Execute the current task
  62831. * @param scene defines the scene where you want your assets to be loaded
  62832. * @param onSuccess is a callback called when the task is successfully executed
  62833. * @param onError is a callback called if an error occurs
  62834. */
  62835. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62836. }
  62837. /**
  62838. * This class can be used to easily import assets into a scene
  62839. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62840. */
  62841. export class AssetsManager {
  62842. private _scene;
  62843. private _isLoading;
  62844. protected _tasks: AbstractAssetTask[];
  62845. protected _waitingTasksCount: number;
  62846. protected _totalTasksCount: number;
  62847. /**
  62848. * Callback called when all tasks are processed
  62849. */
  62850. onFinish: (tasks: AbstractAssetTask[]) => void;
  62851. /**
  62852. * Callback called when a task is successful
  62853. */
  62854. onTaskSuccess: (task: AbstractAssetTask) => void;
  62855. /**
  62856. * Callback called when a task had an error
  62857. */
  62858. onTaskError: (task: AbstractAssetTask) => void;
  62859. /**
  62860. * Callback called when a task is done (whatever the result is)
  62861. */
  62862. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62863. /**
  62864. * Observable called when all tasks are processed
  62865. */
  62866. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62867. /**
  62868. * Observable called when a task had an error
  62869. */
  62870. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62871. /**
  62872. * Observable called when all tasks were executed
  62873. */
  62874. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62875. /**
  62876. * Observable called when a task is done (whatever the result is)
  62877. */
  62878. onProgressObservable: Observable<IAssetsProgressEvent>;
  62879. /**
  62880. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62882. */
  62883. useDefaultLoadingScreen: boolean;
  62884. /**
  62885. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62886. * when all assets have been downloaded.
  62887. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62888. */
  62889. autoHideLoadingUI: boolean;
  62890. /**
  62891. * Creates a new AssetsManager
  62892. * @param scene defines the scene to work on
  62893. */
  62894. constructor(scene: Scene);
  62895. /**
  62896. * Add a MeshAssetTask to the list of active tasks
  62897. * @param taskName defines the name of the new task
  62898. * @param meshesNames defines the name of meshes to load
  62899. * @param rootUrl defines the root url to use to locate files
  62900. * @param sceneFilename defines the filename of the scene file
  62901. * @returns a new MeshAssetTask object
  62902. */
  62903. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62904. /**
  62905. * Add a TextFileAssetTask to the list of active tasks
  62906. * @param taskName defines the name of the new task
  62907. * @param url defines the url of the file to load
  62908. * @returns a new TextFileAssetTask object
  62909. */
  62910. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62911. /**
  62912. * Add a BinaryFileAssetTask to the list of active tasks
  62913. * @param taskName defines the name of the new task
  62914. * @param url defines the url of the file to load
  62915. * @returns a new BinaryFileAssetTask object
  62916. */
  62917. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62918. /**
  62919. * Add a ImageAssetTask to the list of active tasks
  62920. * @param taskName defines the name of the new task
  62921. * @param url defines the url of the file to load
  62922. * @returns a new ImageAssetTask object
  62923. */
  62924. addImageTask(taskName: string, url: string): ImageAssetTask;
  62925. /**
  62926. * Add a TextureAssetTask to the list of active tasks
  62927. * @param taskName defines the name of the new task
  62928. * @param url defines the url of the file to load
  62929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62930. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62931. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62932. * @returns a new TextureAssetTask object
  62933. */
  62934. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62935. /**
  62936. * Add a CubeTextureAssetTask to the list of active tasks
  62937. * @param taskName defines the name of the new task
  62938. * @param url defines the url of the file to load
  62939. * @param extensions defines the extension to use to load the cube map (can be null)
  62940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62941. * @param files defines the list of files to load (can be null)
  62942. * @returns a new CubeTextureAssetTask object
  62943. */
  62944. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62945. /**
  62946. *
  62947. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62948. * @param taskName defines the name of the new task
  62949. * @param url defines the url of the file to load
  62950. * @param size defines the size you want for the cubemap (can be null)
  62951. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62952. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62953. * @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)
  62954. * @param reserved Internal use only
  62955. * @returns a new HDRCubeTextureAssetTask object
  62956. */
  62957. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62958. /**
  62959. *
  62960. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62961. * @param taskName defines the name of the new task
  62962. * @param url defines the url of the file to load
  62963. * @param size defines the size you want for the cubemap (can be null)
  62964. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62965. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62966. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62967. * @returns a new EquiRectangularCubeTextureAssetTask object
  62968. */
  62969. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62970. /**
  62971. * Remove a task from the assets manager.
  62972. * @param task the task to remove
  62973. */
  62974. removeTask(task: AbstractAssetTask): void;
  62975. private _decreaseWaitingTasksCount;
  62976. private _runTask;
  62977. /**
  62978. * Reset the AssetsManager and remove all tasks
  62979. * @return the current instance of the AssetsManager
  62980. */
  62981. reset(): AssetsManager;
  62982. /**
  62983. * Start the loading process
  62984. * @return the current instance of the AssetsManager
  62985. */
  62986. load(): AssetsManager;
  62987. /**
  62988. * Start the loading process as an async operation
  62989. * @return a promise returning the list of failed tasks
  62990. */
  62991. loadAsync(): Promise<void>;
  62992. }
  62993. }
  62994. declare module BABYLON {
  62995. /**
  62996. * Wrapper class for promise with external resolve and reject.
  62997. */
  62998. export class Deferred<T> {
  62999. /**
  63000. * The promise associated with this deferred object.
  63001. */
  63002. readonly promise: Promise<T>;
  63003. private _resolve;
  63004. private _reject;
  63005. /**
  63006. * The resolve method of the promise associated with this deferred object.
  63007. */
  63008. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63009. /**
  63010. * The reject method of the promise associated with this deferred object.
  63011. */
  63012. readonly reject: (reason?: any) => void;
  63013. /**
  63014. * Constructor for this deferred object.
  63015. */
  63016. constructor();
  63017. }
  63018. }
  63019. declare module BABYLON {
  63020. /**
  63021. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63022. */
  63023. export class MeshExploder {
  63024. private _centerMesh;
  63025. private _meshes;
  63026. private _meshesOrigins;
  63027. private _toCenterVectors;
  63028. private _scaledDirection;
  63029. private _newPosition;
  63030. private _centerPosition;
  63031. /**
  63032. * Explodes meshes from a center mesh.
  63033. * @param meshes The meshes to explode.
  63034. * @param centerMesh The mesh to be center of explosion.
  63035. */
  63036. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63037. private _setCenterMesh;
  63038. /**
  63039. * Get class name
  63040. * @returns "MeshExploder"
  63041. */
  63042. getClassName(): string;
  63043. /**
  63044. * "Exploded meshes"
  63045. * @returns Array of meshes with the centerMesh at index 0.
  63046. */
  63047. getMeshes(): Array<Mesh>;
  63048. /**
  63049. * Explodes meshes giving a specific direction
  63050. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63051. */
  63052. explode(direction?: number): void;
  63053. }
  63054. }
  63055. declare module BABYLON {
  63056. /**
  63057. * Class used to help managing file picking and drag'n'drop
  63058. */
  63059. export class FilesInput {
  63060. /**
  63061. * List of files ready to be loaded
  63062. */
  63063. static readonly FilesToLoad: {
  63064. [key: string]: File;
  63065. };
  63066. /**
  63067. * Callback called when a file is processed
  63068. */
  63069. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63070. private _engine;
  63071. private _currentScene;
  63072. private _sceneLoadedCallback;
  63073. private _progressCallback;
  63074. private _additionalRenderLoopLogicCallback;
  63075. private _textureLoadingCallback;
  63076. private _startingProcessingFilesCallback;
  63077. private _onReloadCallback;
  63078. private _errorCallback;
  63079. private _elementToMonitor;
  63080. private _sceneFileToLoad;
  63081. private _filesToLoad;
  63082. /**
  63083. * Creates a new FilesInput
  63084. * @param engine defines the rendering engine
  63085. * @param scene defines the hosting scene
  63086. * @param sceneLoadedCallback callback called when scene is loaded
  63087. * @param progressCallback callback called to track progress
  63088. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63089. * @param textureLoadingCallback callback called when a texture is loading
  63090. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63091. * @param onReloadCallback callback called when a reload is requested
  63092. * @param errorCallback callback call if an error occurs
  63093. */
  63094. 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);
  63095. private _dragEnterHandler;
  63096. private _dragOverHandler;
  63097. private _dropHandler;
  63098. /**
  63099. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63100. * @param elementToMonitor defines the DOM element to track
  63101. */
  63102. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63103. /**
  63104. * Release all associated resources
  63105. */
  63106. dispose(): void;
  63107. private renderFunction;
  63108. private drag;
  63109. private drop;
  63110. private _traverseFolder;
  63111. private _processFiles;
  63112. /**
  63113. * Load files from a drop event
  63114. * @param event defines the drop event to use as source
  63115. */
  63116. loadFiles(event: any): void;
  63117. private _processReload;
  63118. /**
  63119. * Reload the current scene from the loaded files
  63120. */
  63121. reload(): void;
  63122. }
  63123. }
  63124. declare module BABYLON {
  63125. /**
  63126. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63128. */
  63129. export class SceneOptimization {
  63130. /**
  63131. * Defines the priority of this optimization (0 by default which means first in the list)
  63132. */
  63133. priority: number;
  63134. /**
  63135. * Gets a string describing the action executed by the current optimization
  63136. * @returns description string
  63137. */
  63138. getDescription(): string;
  63139. /**
  63140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63141. * @param scene defines the current scene where to apply this optimization
  63142. * @param optimizer defines the current optimizer
  63143. * @returns true if everything that can be done was applied
  63144. */
  63145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63146. /**
  63147. * Creates the SceneOptimization object
  63148. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63149. * @param desc defines the description associated with the optimization
  63150. */
  63151. constructor(
  63152. /**
  63153. * Defines the priority of this optimization (0 by default which means first in the list)
  63154. */
  63155. priority?: number);
  63156. }
  63157. /**
  63158. * Defines an optimization used to reduce the size of render target textures
  63159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63160. */
  63161. export class TextureOptimization extends SceneOptimization {
  63162. /**
  63163. * Defines the priority of this optimization (0 by default which means first in the list)
  63164. */
  63165. priority: number;
  63166. /**
  63167. * 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
  63168. */
  63169. maximumSize: number;
  63170. /**
  63171. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63172. */
  63173. step: number;
  63174. /**
  63175. * Gets a string describing the action executed by the current optimization
  63176. * @returns description string
  63177. */
  63178. getDescription(): string;
  63179. /**
  63180. * Creates the TextureOptimization object
  63181. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63182. * @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
  63183. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63184. */
  63185. constructor(
  63186. /**
  63187. * Defines the priority of this optimization (0 by default which means first in the list)
  63188. */
  63189. priority?: number,
  63190. /**
  63191. * 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
  63192. */
  63193. maximumSize?: number,
  63194. /**
  63195. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63196. */
  63197. step?: number);
  63198. /**
  63199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63200. * @param scene defines the current scene where to apply this optimization
  63201. * @param optimizer defines the current optimizer
  63202. * @returns true if everything that can be done was applied
  63203. */
  63204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63205. }
  63206. /**
  63207. * Defines an optimization used to increase or decrease the rendering resolution
  63208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63209. */
  63210. export class HardwareScalingOptimization extends SceneOptimization {
  63211. /**
  63212. * Defines the priority of this optimization (0 by default which means first in the list)
  63213. */
  63214. priority: number;
  63215. /**
  63216. * Defines the maximum scale to use (2 by default)
  63217. */
  63218. maximumScale: number;
  63219. /**
  63220. * Defines the step to use between two passes (0.5 by default)
  63221. */
  63222. step: number;
  63223. private _currentScale;
  63224. private _directionOffset;
  63225. /**
  63226. * Gets a string describing the action executed by the current optimization
  63227. * @return description string
  63228. */
  63229. getDescription(): string;
  63230. /**
  63231. * Creates the HardwareScalingOptimization object
  63232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63233. * @param maximumScale defines the maximum scale to use (2 by default)
  63234. * @param step defines the step to use between two passes (0.5 by default)
  63235. */
  63236. constructor(
  63237. /**
  63238. * Defines the priority of this optimization (0 by default which means first in the list)
  63239. */
  63240. priority?: number,
  63241. /**
  63242. * Defines the maximum scale to use (2 by default)
  63243. */
  63244. maximumScale?: number,
  63245. /**
  63246. * Defines the step to use between two passes (0.5 by default)
  63247. */
  63248. step?: number);
  63249. /**
  63250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63251. * @param scene defines the current scene where to apply this optimization
  63252. * @param optimizer defines the current optimizer
  63253. * @returns true if everything that can be done was applied
  63254. */
  63255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63256. }
  63257. /**
  63258. * Defines an optimization used to remove shadows
  63259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63260. */
  63261. export class ShadowsOptimization extends SceneOptimization {
  63262. /**
  63263. * Gets a string describing the action executed by the current optimization
  63264. * @return description string
  63265. */
  63266. getDescription(): string;
  63267. /**
  63268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63269. * @param scene defines the current scene where to apply this optimization
  63270. * @param optimizer defines the current optimizer
  63271. * @returns true if everything that can be done was applied
  63272. */
  63273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63274. }
  63275. /**
  63276. * Defines an optimization used to turn post-processes off
  63277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63278. */
  63279. export class PostProcessesOptimization extends SceneOptimization {
  63280. /**
  63281. * Gets a string describing the action executed by the current optimization
  63282. * @return description string
  63283. */
  63284. getDescription(): string;
  63285. /**
  63286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63287. * @param scene defines the current scene where to apply this optimization
  63288. * @param optimizer defines the current optimizer
  63289. * @returns true if everything that can be done was applied
  63290. */
  63291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63292. }
  63293. /**
  63294. * Defines an optimization used to turn lens flares off
  63295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63296. */
  63297. export class LensFlaresOptimization extends SceneOptimization {
  63298. /**
  63299. * Gets a string describing the action executed by the current optimization
  63300. * @return description string
  63301. */
  63302. getDescription(): string;
  63303. /**
  63304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63305. * @param scene defines the current scene where to apply this optimization
  63306. * @param optimizer defines the current optimizer
  63307. * @returns true if everything that can be done was applied
  63308. */
  63309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63310. }
  63311. /**
  63312. * Defines an optimization based on user defined callback.
  63313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63314. */
  63315. export class CustomOptimization extends SceneOptimization {
  63316. /**
  63317. * Callback called to apply the custom optimization.
  63318. */
  63319. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63320. /**
  63321. * Callback called to get custom description
  63322. */
  63323. onGetDescription: () => string;
  63324. /**
  63325. * Gets a string describing the action executed by the current optimization
  63326. * @returns description string
  63327. */
  63328. getDescription(): string;
  63329. /**
  63330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63331. * @param scene defines the current scene where to apply this optimization
  63332. * @param optimizer defines the current optimizer
  63333. * @returns true if everything that can be done was applied
  63334. */
  63335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63336. }
  63337. /**
  63338. * Defines an optimization used to turn particles off
  63339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63340. */
  63341. export class ParticlesOptimization extends SceneOptimization {
  63342. /**
  63343. * Gets a string describing the action executed by the current optimization
  63344. * @return description string
  63345. */
  63346. getDescription(): string;
  63347. /**
  63348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63349. * @param scene defines the current scene where to apply this optimization
  63350. * @param optimizer defines the current optimizer
  63351. * @returns true if everything that can be done was applied
  63352. */
  63353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63354. }
  63355. /**
  63356. * Defines an optimization used to turn render targets off
  63357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63358. */
  63359. export class RenderTargetsOptimization extends SceneOptimization {
  63360. /**
  63361. * Gets a string describing the action executed by the current optimization
  63362. * @return description string
  63363. */
  63364. getDescription(): string;
  63365. /**
  63366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63367. * @param scene defines the current scene where to apply this optimization
  63368. * @param optimizer defines the current optimizer
  63369. * @returns true if everything that can be done was applied
  63370. */
  63371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63372. }
  63373. /**
  63374. * Defines an optimization used to merge meshes with compatible materials
  63375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63376. */
  63377. export class MergeMeshesOptimization extends SceneOptimization {
  63378. private static _UpdateSelectionTree;
  63379. /**
  63380. * Gets or sets a boolean which defines if optimization octree has to be updated
  63381. */
  63382. /**
  63383. * Gets or sets a boolean which defines if optimization octree has to be updated
  63384. */
  63385. static UpdateSelectionTree: boolean;
  63386. /**
  63387. * Gets a string describing the action executed by the current optimization
  63388. * @return description string
  63389. */
  63390. getDescription(): string;
  63391. private _canBeMerged;
  63392. /**
  63393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63394. * @param scene defines the current scene where to apply this optimization
  63395. * @param optimizer defines the current optimizer
  63396. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63397. * @returns true if everything that can be done was applied
  63398. */
  63399. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63400. }
  63401. /**
  63402. * Defines a list of options used by SceneOptimizer
  63403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63404. */
  63405. export class SceneOptimizerOptions {
  63406. /**
  63407. * Defines the target frame rate to reach (60 by default)
  63408. */
  63409. targetFrameRate: number;
  63410. /**
  63411. * Defines the interval between two checkes (2000ms by default)
  63412. */
  63413. trackerDuration: number;
  63414. /**
  63415. * Gets the list of optimizations to apply
  63416. */
  63417. optimizations: SceneOptimization[];
  63418. /**
  63419. * Creates a new list of options used by SceneOptimizer
  63420. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63421. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63422. */
  63423. constructor(
  63424. /**
  63425. * Defines the target frame rate to reach (60 by default)
  63426. */
  63427. targetFrameRate?: number,
  63428. /**
  63429. * Defines the interval between two checkes (2000ms by default)
  63430. */
  63431. trackerDuration?: number);
  63432. /**
  63433. * Add a new optimization
  63434. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63435. * @returns the current SceneOptimizerOptions
  63436. */
  63437. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63438. /**
  63439. * Add a new custom optimization
  63440. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63441. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63442. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63443. * @returns the current SceneOptimizerOptions
  63444. */
  63445. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63446. /**
  63447. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63448. * @param targetFrameRate defines the target frame rate (60 by default)
  63449. * @returns a SceneOptimizerOptions object
  63450. */
  63451. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63452. /**
  63453. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63454. * @param targetFrameRate defines the target frame rate (60 by default)
  63455. * @returns a SceneOptimizerOptions object
  63456. */
  63457. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63458. /**
  63459. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63460. * @param targetFrameRate defines the target frame rate (60 by default)
  63461. * @returns a SceneOptimizerOptions object
  63462. */
  63463. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63464. }
  63465. /**
  63466. * Class used to run optimizations in order to reach a target frame rate
  63467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63468. */
  63469. export class SceneOptimizer implements IDisposable {
  63470. private _isRunning;
  63471. private _options;
  63472. private _scene;
  63473. private _currentPriorityLevel;
  63474. private _targetFrameRate;
  63475. private _trackerDuration;
  63476. private _currentFrameRate;
  63477. private _sceneDisposeObserver;
  63478. private _improvementMode;
  63479. /**
  63480. * Defines an observable called when the optimizer reaches the target frame rate
  63481. */
  63482. onSuccessObservable: Observable<SceneOptimizer>;
  63483. /**
  63484. * Defines an observable called when the optimizer enables an optimization
  63485. */
  63486. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63487. /**
  63488. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63489. */
  63490. onFailureObservable: Observable<SceneOptimizer>;
  63491. /**
  63492. * Gets a boolean indicating if the optimizer is in improvement mode
  63493. */
  63494. readonly isInImprovementMode: boolean;
  63495. /**
  63496. * Gets the current priority level (0 at start)
  63497. */
  63498. readonly currentPriorityLevel: number;
  63499. /**
  63500. * Gets the current frame rate checked by the SceneOptimizer
  63501. */
  63502. readonly currentFrameRate: number;
  63503. /**
  63504. * Gets or sets the current target frame rate (60 by default)
  63505. */
  63506. /**
  63507. * Gets or sets the current target frame rate (60 by default)
  63508. */
  63509. targetFrameRate: number;
  63510. /**
  63511. * Gets or sets the current interval between two checks (every 2000ms by default)
  63512. */
  63513. /**
  63514. * Gets or sets the current interval between two checks (every 2000ms by default)
  63515. */
  63516. trackerDuration: number;
  63517. /**
  63518. * Gets the list of active optimizations
  63519. */
  63520. readonly optimizations: SceneOptimization[];
  63521. /**
  63522. * Creates a new SceneOptimizer
  63523. * @param scene defines the scene to work on
  63524. * @param options defines the options to use with the SceneOptimizer
  63525. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63526. * @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)
  63527. */
  63528. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63529. /**
  63530. * Stops the current optimizer
  63531. */
  63532. stop(): void;
  63533. /**
  63534. * Reset the optimizer to initial step (current priority level = 0)
  63535. */
  63536. reset(): void;
  63537. /**
  63538. * Start the optimizer. By default it will try to reach a specific framerate
  63539. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63540. */
  63541. start(): void;
  63542. private _checkCurrentState;
  63543. /**
  63544. * Release all resources
  63545. */
  63546. dispose(): void;
  63547. /**
  63548. * Helper function to create a SceneOptimizer with one single line of code
  63549. * @param scene defines the scene to work on
  63550. * @param options defines the options to use with the SceneOptimizer
  63551. * @param onSuccess defines a callback to call on success
  63552. * @param onFailure defines a callback to call on failure
  63553. * @returns the new SceneOptimizer object
  63554. */
  63555. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * Class used to serialize a scene into a string
  63561. */
  63562. export class SceneSerializer {
  63563. /**
  63564. * Clear cache used by a previous serialization
  63565. */
  63566. static ClearCache(): void;
  63567. /**
  63568. * Serialize a scene into a JSON compatible object
  63569. * @param scene defines the scene to serialize
  63570. * @returns a JSON compatible object
  63571. */
  63572. static Serialize(scene: Scene): any;
  63573. /**
  63574. * Serialize a mesh into a JSON compatible object
  63575. * @param toSerialize defines the mesh to serialize
  63576. * @param withParents defines if parents must be serialized as well
  63577. * @param withChildren defines if children must be serialized as well
  63578. * @returns a JSON compatible object
  63579. */
  63580. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63581. }
  63582. }
  63583. declare module BABYLON {
  63584. /**
  63585. * Class used to host texture specific utilities
  63586. */
  63587. export class TextureTools {
  63588. /**
  63589. * Uses the GPU to create a copy texture rescaled at a given size
  63590. * @param texture Texture to copy from
  63591. * @param width defines the desired width
  63592. * @param height defines the desired height
  63593. * @param useBilinearMode defines if bilinear mode has to be used
  63594. * @return the generated texture
  63595. */
  63596. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * This represents the different options available for the video capture.
  63602. */
  63603. export interface VideoRecorderOptions {
  63604. /** Defines the mime type of the video. */
  63605. mimeType: string;
  63606. /** Defines the FPS the video should be recorded at. */
  63607. fps: number;
  63608. /** Defines the chunk size for the recording data. */
  63609. recordChunckSize: number;
  63610. /** The audio tracks to attach to the recording. */
  63611. audioTracks?: MediaStreamTrack[];
  63612. }
  63613. /**
  63614. * This can help with recording videos from BabylonJS.
  63615. * This is based on the available WebRTC functionalities of the browser.
  63616. *
  63617. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63618. */
  63619. export class VideoRecorder {
  63620. private static readonly _defaultOptions;
  63621. /**
  63622. * Returns whether or not the VideoRecorder is available in your browser.
  63623. * @param engine Defines the Babylon Engine.
  63624. * @returns true if supported otherwise false.
  63625. */
  63626. static IsSupported(engine: Engine): boolean;
  63627. private readonly _options;
  63628. private _canvas;
  63629. private _mediaRecorder;
  63630. private _recordedChunks;
  63631. private _fileName;
  63632. private _resolve;
  63633. private _reject;
  63634. /**
  63635. * True when a recording is already in progress.
  63636. */
  63637. readonly isRecording: boolean;
  63638. /**
  63639. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63640. * @param engine Defines the BabylonJS Engine you wish to record.
  63641. * @param options Defines options that can be used to customize the capture.
  63642. */
  63643. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63644. /**
  63645. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63646. */
  63647. stopRecording(): void;
  63648. /**
  63649. * Starts recording the canvas for a max duration specified in parameters.
  63650. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63651. * If null no automatic download will start and you can rely on the promise to get the data back.
  63652. * @param maxDuration Defines the maximum recording time in seconds.
  63653. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63654. * @return A promise callback at the end of the recording with the video data in Blob.
  63655. */
  63656. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63657. /**
  63658. * Releases internal resources used during the recording.
  63659. */
  63660. dispose(): void;
  63661. private _handleDataAvailable;
  63662. private _handleError;
  63663. private _handleStop;
  63664. }
  63665. }
  63666. declare module BABYLON {
  63667. /**
  63668. * Class containing a set of static utilities functions for screenshots
  63669. */
  63670. export class ScreenshotTools {
  63671. /**
  63672. * Captures a screenshot of the current rendering
  63673. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63674. * @param engine defines the rendering engine
  63675. * @param camera defines the source camera
  63676. * @param size This parameter can be set to a single number or to an object with the
  63677. * following (optional) properties: precision, width, height. If a single number is passed,
  63678. * it will be used for both width and height. If an object is passed, the screenshot size
  63679. * will be derived from the parameters. The precision property is a multiplier allowing
  63680. * rendering at a higher or lower resolution
  63681. * @param successCallback defines the callback receives a single parameter which contains the
  63682. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63683. * src parameter of an <img> to display it
  63684. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63685. * Check your browser for supported MIME types
  63686. */
  63687. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63688. /**
  63689. * Captures a screenshot of the current rendering
  63690. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63691. * @param engine defines the rendering engine
  63692. * @param camera defines the source camera
  63693. * @param size This parameter can be set to a single number or to an object with the
  63694. * following (optional) properties: precision, width, height. If a single number is passed,
  63695. * it will be used for both width and height. If an object is passed, the screenshot size
  63696. * will be derived from the parameters. The precision property is a multiplier allowing
  63697. * rendering at a higher or lower resolution
  63698. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63699. * Check your browser for supported MIME types
  63700. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63701. * to the src parameter of an <img> to display it
  63702. */
  63703. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63704. /**
  63705. * Generates an image screenshot from the specified camera.
  63706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63707. * @param engine The engine to use for rendering
  63708. * @param camera The camera to use for rendering
  63709. * @param size This parameter can be set to a single number or to an object with the
  63710. * following (optional) properties: precision, width, height. If a single number is passed,
  63711. * it will be used for both width and height. If an object is passed, the screenshot size
  63712. * will be derived from the parameters. The precision property is a multiplier allowing
  63713. * rendering at a higher or lower resolution
  63714. * @param successCallback The callback receives a single parameter which contains the
  63715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63716. * src parameter of an <img> to display it
  63717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63718. * Check your browser for supported MIME types
  63719. * @param samples Texture samples (default: 1)
  63720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63721. * @param fileName A name for for the downloaded file.
  63722. */
  63723. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63724. /**
  63725. * Generates an image screenshot from the specified camera.
  63726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63727. * @param engine The engine to use for rendering
  63728. * @param camera The camera to use for rendering
  63729. * @param size This parameter can be set to a single number or to an object with the
  63730. * following (optional) properties: precision, width, height. If a single number is passed,
  63731. * it will be used for both width and height. If an object is passed, the screenshot size
  63732. * will be derived from the parameters. The precision property is a multiplier allowing
  63733. * rendering at a higher or lower resolution
  63734. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63735. * Check your browser for supported MIME types
  63736. * @param samples Texture samples (default: 1)
  63737. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63738. * @param fileName A name for for the downloaded file.
  63739. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63740. * to the src parameter of an <img> to display it
  63741. */
  63742. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63743. /**
  63744. * Gets height and width for screenshot size
  63745. * @private
  63746. */
  63747. private static _getScreenshotSize;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /**
  63752. * A cursor which tracks a point on a path
  63753. */
  63754. export class PathCursor {
  63755. private path;
  63756. /**
  63757. * Stores path cursor callbacks for when an onchange event is triggered
  63758. */
  63759. private _onchange;
  63760. /**
  63761. * The value of the path cursor
  63762. */
  63763. value: number;
  63764. /**
  63765. * The animation array of the path cursor
  63766. */
  63767. animations: Animation[];
  63768. /**
  63769. * Initializes the path cursor
  63770. * @param path The path to track
  63771. */
  63772. constructor(path: Path2);
  63773. /**
  63774. * Gets the cursor point on the path
  63775. * @returns A point on the path cursor at the cursor location
  63776. */
  63777. getPoint(): Vector3;
  63778. /**
  63779. * Moves the cursor ahead by the step amount
  63780. * @param step The amount to move the cursor forward
  63781. * @returns This path cursor
  63782. */
  63783. moveAhead(step?: number): PathCursor;
  63784. /**
  63785. * Moves the cursor behind by the step amount
  63786. * @param step The amount to move the cursor back
  63787. * @returns This path cursor
  63788. */
  63789. moveBack(step?: number): PathCursor;
  63790. /**
  63791. * Moves the cursor by the step amount
  63792. * If the step amount is greater than one, an exception is thrown
  63793. * @param step The amount to move the cursor
  63794. * @returns This path cursor
  63795. */
  63796. move(step: number): PathCursor;
  63797. /**
  63798. * Ensures that the value is limited between zero and one
  63799. * @returns This path cursor
  63800. */
  63801. private ensureLimits;
  63802. /**
  63803. * Runs onchange callbacks on change (used by the animation engine)
  63804. * @returns This path cursor
  63805. */
  63806. private raiseOnChange;
  63807. /**
  63808. * Executes a function on change
  63809. * @param f A path cursor onchange callback
  63810. * @returns This path cursor
  63811. */
  63812. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /** @hidden */
  63817. export var blurPixelShader: {
  63818. name: string;
  63819. shader: string;
  63820. };
  63821. }
  63822. declare module BABYLON {
  63823. /** @hidden */
  63824. export var pointCloudVertexDeclaration: {
  63825. name: string;
  63826. shader: string;
  63827. };
  63828. }
  63829. // Mixins
  63830. interface Window {
  63831. mozIndexedDB: IDBFactory;
  63832. webkitIndexedDB: IDBFactory;
  63833. msIndexedDB: IDBFactory;
  63834. webkitURL: typeof URL;
  63835. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63836. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63837. WebGLRenderingContext: WebGLRenderingContext;
  63838. MSGesture: MSGesture;
  63839. CANNON: any;
  63840. AudioContext: AudioContext;
  63841. webkitAudioContext: AudioContext;
  63842. PointerEvent: any;
  63843. Math: Math;
  63844. Uint8Array: Uint8ArrayConstructor;
  63845. Float32Array: Float32ArrayConstructor;
  63846. mozURL: typeof URL;
  63847. msURL: typeof URL;
  63848. VRFrameData: any; // WebVR, from specs 1.1
  63849. DracoDecoderModule: any;
  63850. setImmediate(handler: (...args: any[]) => void): number;
  63851. }
  63852. interface HTMLCanvasElement {
  63853. requestPointerLock(): void;
  63854. msRequestPointerLock?(): void;
  63855. mozRequestPointerLock?(): void;
  63856. webkitRequestPointerLock?(): void;
  63857. /** Track wether a record is in progress */
  63858. isRecording: boolean;
  63859. /** Capture Stream method defined by some browsers */
  63860. captureStream(fps?: number): MediaStream;
  63861. }
  63862. interface CanvasRenderingContext2D {
  63863. msImageSmoothingEnabled: boolean;
  63864. }
  63865. interface MouseEvent {
  63866. mozMovementX: number;
  63867. mozMovementY: number;
  63868. webkitMovementX: number;
  63869. webkitMovementY: number;
  63870. msMovementX: number;
  63871. msMovementY: number;
  63872. }
  63873. interface Navigator {
  63874. mozGetVRDevices: (any: any) => any;
  63875. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63876. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63877. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63878. webkitGetGamepads(): Gamepad[];
  63879. msGetGamepads(): Gamepad[];
  63880. webkitGamepads(): Gamepad[];
  63881. }
  63882. interface HTMLVideoElement {
  63883. mozSrcObject: any;
  63884. }
  63885. interface Math {
  63886. fround(x: number): number;
  63887. imul(a: number, b: number): number;
  63888. }
  63889. interface WebGLRenderingContext {
  63890. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63891. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63892. vertexAttribDivisor(index: number, divisor: number): void;
  63893. createVertexArray(): any;
  63894. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63895. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63896. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63897. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63898. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63899. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63900. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63901. // Queries
  63902. createQuery(): WebGLQuery;
  63903. deleteQuery(query: WebGLQuery): void;
  63904. beginQuery(target: number, query: WebGLQuery): void;
  63905. endQuery(target: number): void;
  63906. getQueryParameter(query: WebGLQuery, pname: number): any;
  63907. getQuery(target: number, pname: number): any;
  63908. MAX_SAMPLES: number;
  63909. RGBA8: number;
  63910. READ_FRAMEBUFFER: number;
  63911. DRAW_FRAMEBUFFER: number;
  63912. UNIFORM_BUFFER: number;
  63913. HALF_FLOAT_OES: number;
  63914. RGBA16F: number;
  63915. RGBA32F: number;
  63916. R32F: number;
  63917. RG32F: number;
  63918. RGB32F: number;
  63919. R16F: number;
  63920. RG16F: number;
  63921. RGB16F: number;
  63922. RED: number;
  63923. RG: number;
  63924. R8: number;
  63925. RG8: number;
  63926. UNSIGNED_INT_24_8: number;
  63927. DEPTH24_STENCIL8: number;
  63928. MIN: number;
  63929. MAX: number;
  63930. /* Multiple Render Targets */
  63931. drawBuffers(buffers: number[]): void;
  63932. readBuffer(src: number): void;
  63933. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63934. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63935. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63936. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63937. // Occlusion Query
  63938. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63939. ANY_SAMPLES_PASSED: number;
  63940. QUERY_RESULT_AVAILABLE: number;
  63941. QUERY_RESULT: number;
  63942. }
  63943. interface WebGLProgram {
  63944. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63945. }
  63946. interface EXT_disjoint_timer_query {
  63947. QUERY_COUNTER_BITS_EXT: number;
  63948. TIME_ELAPSED_EXT: number;
  63949. TIMESTAMP_EXT: number;
  63950. GPU_DISJOINT_EXT: number;
  63951. QUERY_RESULT_EXT: number;
  63952. QUERY_RESULT_AVAILABLE_EXT: number;
  63953. queryCounterEXT(query: WebGLQuery, target: number): void;
  63954. createQueryEXT(): WebGLQuery;
  63955. beginQueryEXT(target: number, query: WebGLQuery): void;
  63956. endQueryEXT(target: number): void;
  63957. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63958. deleteQueryEXT(query: WebGLQuery): void;
  63959. }
  63960. interface WebGLUniformLocation {
  63961. _currentState: any;
  63962. }
  63963. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63964. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63965. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63966. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63967. interface WebGLRenderingContext {
  63968. readonly RASTERIZER_DISCARD: number;
  63969. readonly DEPTH_COMPONENT24: number;
  63970. readonly TEXTURE_3D: number;
  63971. readonly TEXTURE_2D_ARRAY: number;
  63972. readonly TEXTURE_COMPARE_FUNC: number;
  63973. readonly TEXTURE_COMPARE_MODE: number;
  63974. readonly COMPARE_REF_TO_TEXTURE: number;
  63975. readonly TEXTURE_WRAP_R: number;
  63976. readonly HALF_FLOAT: number;
  63977. readonly RGB8: number;
  63978. readonly RED_INTEGER: number;
  63979. readonly RG_INTEGER: number;
  63980. readonly RGB_INTEGER: number;
  63981. readonly RGBA_INTEGER: number;
  63982. readonly R8_SNORM: number;
  63983. readonly RG8_SNORM: number;
  63984. readonly RGB8_SNORM: number;
  63985. readonly RGBA8_SNORM: number;
  63986. readonly R8I: number;
  63987. readonly RG8I: number;
  63988. readonly RGB8I: number;
  63989. readonly RGBA8I: number;
  63990. readonly R8UI: number;
  63991. readonly RG8UI: number;
  63992. readonly RGB8UI: number;
  63993. readonly RGBA8UI: number;
  63994. readonly R16I: number;
  63995. readonly RG16I: number;
  63996. readonly RGB16I: number;
  63997. readonly RGBA16I: number;
  63998. readonly R16UI: number;
  63999. readonly RG16UI: number;
  64000. readonly RGB16UI: number;
  64001. readonly RGBA16UI: number;
  64002. readonly R32I: number;
  64003. readonly RG32I: number;
  64004. readonly RGB32I: number;
  64005. readonly RGBA32I: number;
  64006. readonly R32UI: number;
  64007. readonly RG32UI: number;
  64008. readonly RGB32UI: number;
  64009. readonly RGBA32UI: number;
  64010. readonly RGB10_A2UI: number;
  64011. readonly R11F_G11F_B10F: number;
  64012. readonly RGB9_E5: number;
  64013. readonly RGB10_A2: number;
  64014. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64015. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64016. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64017. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64018. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64019. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64020. 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;
  64021. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64022. readonly TRANSFORM_FEEDBACK: number;
  64023. readonly INTERLEAVED_ATTRIBS: number;
  64024. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64025. createTransformFeedback(): WebGLTransformFeedback;
  64026. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64027. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64028. beginTransformFeedback(primitiveMode: number): void;
  64029. endTransformFeedback(): void;
  64030. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64031. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64032. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64033. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64034. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64035. }
  64036. interface ImageBitmap {
  64037. readonly width: number;
  64038. readonly height: number;
  64039. close(): void;
  64040. }
  64041. interface WebGLQuery extends WebGLObject {
  64042. }
  64043. declare var WebGLQuery: {
  64044. prototype: WebGLQuery;
  64045. new(): WebGLQuery;
  64046. };
  64047. interface WebGLSampler extends WebGLObject {
  64048. }
  64049. declare var WebGLSampler: {
  64050. prototype: WebGLSampler;
  64051. new(): WebGLSampler;
  64052. };
  64053. interface WebGLSync extends WebGLObject {
  64054. }
  64055. declare var WebGLSync: {
  64056. prototype: WebGLSync;
  64057. new(): WebGLSync;
  64058. };
  64059. interface WebGLTransformFeedback extends WebGLObject {
  64060. }
  64061. declare var WebGLTransformFeedback: {
  64062. prototype: WebGLTransformFeedback;
  64063. new(): WebGLTransformFeedback;
  64064. };
  64065. interface WebGLVertexArrayObject extends WebGLObject {
  64066. }
  64067. declare var WebGLVertexArrayObject: {
  64068. prototype: WebGLVertexArrayObject;
  64069. new(): WebGLVertexArrayObject;
  64070. };
  64071. // Type definitions for WebVR API
  64072. // Project: https://w3c.github.io/webvr/
  64073. // Definitions by: six a <https://github.com/lostfictions>
  64074. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64075. interface VRDisplay extends EventTarget {
  64076. /**
  64077. * Dictionary of capabilities describing the VRDisplay.
  64078. */
  64079. readonly capabilities: VRDisplayCapabilities;
  64080. /**
  64081. * z-depth defining the far plane of the eye view frustum
  64082. * enables mapping of values in the render target depth
  64083. * attachment to scene coordinates. Initially set to 10000.0.
  64084. */
  64085. depthFar: number;
  64086. /**
  64087. * z-depth defining the near plane of the eye view frustum
  64088. * enables mapping of values in the render target depth
  64089. * attachment to scene coordinates. Initially set to 0.01.
  64090. */
  64091. depthNear: number;
  64092. /**
  64093. * An identifier for this distinct VRDisplay. Used as an
  64094. * association point in the Gamepad API.
  64095. */
  64096. readonly displayId: number;
  64097. /**
  64098. * A display name, a user-readable name identifying it.
  64099. */
  64100. readonly displayName: string;
  64101. readonly isConnected: boolean;
  64102. readonly isPresenting: boolean;
  64103. /**
  64104. * If this VRDisplay supports room-scale experiences, the optional
  64105. * stage attribute contains details on the room-scale parameters.
  64106. */
  64107. readonly stageParameters: VRStageParameters | null;
  64108. /**
  64109. * Passing the value returned by `requestAnimationFrame` to
  64110. * `cancelAnimationFrame` will unregister the callback.
  64111. * @param handle Define the hanle of the request to cancel
  64112. */
  64113. cancelAnimationFrame(handle: number): void;
  64114. /**
  64115. * Stops presenting to the VRDisplay.
  64116. * @returns a promise to know when it stopped
  64117. */
  64118. exitPresent(): Promise<void>;
  64119. /**
  64120. * Return the current VREyeParameters for the given eye.
  64121. * @param whichEye Define the eye we want the parameter for
  64122. * @returns the eye parameters
  64123. */
  64124. getEyeParameters(whichEye: string): VREyeParameters;
  64125. /**
  64126. * Populates the passed VRFrameData with the information required to render
  64127. * the current frame.
  64128. * @param frameData Define the data structure to populate
  64129. * @returns true if ok otherwise false
  64130. */
  64131. getFrameData(frameData: VRFrameData): boolean;
  64132. /**
  64133. * Get the layers currently being presented.
  64134. * @returns the list of VR layers
  64135. */
  64136. getLayers(): VRLayer[];
  64137. /**
  64138. * Return a VRPose containing the future predicted pose of the VRDisplay
  64139. * when the current frame will be presented. The value returned will not
  64140. * change until JavaScript has returned control to the browser.
  64141. *
  64142. * The VRPose will contain the position, orientation, velocity,
  64143. * and acceleration of each of these properties.
  64144. * @returns the pose object
  64145. */
  64146. getPose(): VRPose;
  64147. /**
  64148. * Return the current instantaneous pose of the VRDisplay, with no
  64149. * prediction applied.
  64150. * @returns the current instantaneous pose
  64151. */
  64152. getImmediatePose(): VRPose;
  64153. /**
  64154. * The callback passed to `requestAnimationFrame` will be called
  64155. * any time a new frame should be rendered. When the VRDisplay is
  64156. * presenting the callback will be called at the native refresh
  64157. * rate of the HMD. When not presenting this function acts
  64158. * identically to how window.requestAnimationFrame acts. Content should
  64159. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64160. * asynchronously from other displays and at differing refresh rates.
  64161. * @param callback Define the eaction to run next frame
  64162. * @returns the request handle it
  64163. */
  64164. requestAnimationFrame(callback: FrameRequestCallback): number;
  64165. /**
  64166. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64167. * Repeat calls while already presenting will update the VRLayers being displayed.
  64168. * @param layers Define the list of layer to present
  64169. * @returns a promise to know when the request has been fulfilled
  64170. */
  64171. requestPresent(layers: VRLayer[]): Promise<void>;
  64172. /**
  64173. * Reset the pose for this display, treating its current position and
  64174. * orientation as the "origin/zero" values. VRPose.position,
  64175. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64176. * updated when calling resetPose(). This should be called in only
  64177. * sitting-space experiences.
  64178. */
  64179. resetPose(): void;
  64180. /**
  64181. * The VRLayer provided to the VRDisplay will be captured and presented
  64182. * in the HMD. Calling this function has the same effect on the source
  64183. * canvas as any other operation that uses its source image, and canvases
  64184. * created without preserveDrawingBuffer set to true will be cleared.
  64185. * @param pose Define the pose to submit
  64186. */
  64187. submitFrame(pose?: VRPose): void;
  64188. }
  64189. declare var VRDisplay: {
  64190. prototype: VRDisplay;
  64191. new(): VRDisplay;
  64192. };
  64193. interface VRLayer {
  64194. leftBounds?: number[] | Float32Array | null;
  64195. rightBounds?: number[] | Float32Array | null;
  64196. source?: HTMLCanvasElement | null;
  64197. }
  64198. interface VRDisplayCapabilities {
  64199. readonly canPresent: boolean;
  64200. readonly hasExternalDisplay: boolean;
  64201. readonly hasOrientation: boolean;
  64202. readonly hasPosition: boolean;
  64203. readonly maxLayers: number;
  64204. }
  64205. interface VREyeParameters {
  64206. /** @deprecated */
  64207. readonly fieldOfView: VRFieldOfView;
  64208. readonly offset: Float32Array;
  64209. readonly renderHeight: number;
  64210. readonly renderWidth: number;
  64211. }
  64212. interface VRFieldOfView {
  64213. readonly downDegrees: number;
  64214. readonly leftDegrees: number;
  64215. readonly rightDegrees: number;
  64216. readonly upDegrees: number;
  64217. }
  64218. interface VRFrameData {
  64219. readonly leftProjectionMatrix: Float32Array;
  64220. readonly leftViewMatrix: Float32Array;
  64221. readonly pose: VRPose;
  64222. readonly rightProjectionMatrix: Float32Array;
  64223. readonly rightViewMatrix: Float32Array;
  64224. readonly timestamp: number;
  64225. }
  64226. interface VRPose {
  64227. readonly angularAcceleration: Float32Array | null;
  64228. readonly angularVelocity: Float32Array | null;
  64229. readonly linearAcceleration: Float32Array | null;
  64230. readonly linearVelocity: Float32Array | null;
  64231. readonly orientation: Float32Array | null;
  64232. readonly position: Float32Array | null;
  64233. readonly timestamp: number;
  64234. }
  64235. interface VRStageParameters {
  64236. sittingToStandingTransform?: Float32Array;
  64237. sizeX?: number;
  64238. sizeY?: number;
  64239. }
  64240. interface Navigator {
  64241. getVRDisplays(): Promise<VRDisplay[]>;
  64242. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64243. }
  64244. interface Window {
  64245. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64246. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64247. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64248. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64249. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64250. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64251. }
  64252. interface Gamepad {
  64253. readonly displayId: number;
  64254. }
  64255. type XRSessionMode =
  64256. | "inline"
  64257. | "immersive-vr"
  64258. | "immersive-ar";
  64259. type XRReferenceSpaceType =
  64260. | "viewer"
  64261. | "local"
  64262. | "local-floor"
  64263. | "bounded-floor"
  64264. | "unbounded";
  64265. type XREnvironmentBlendMode =
  64266. | "opaque"
  64267. | "additive"
  64268. | "alpha-blend";
  64269. type XRVisibilityState =
  64270. | "visible"
  64271. | "visible-blurred"
  64272. | "hidden";
  64273. type XRHandedness =
  64274. | "none"
  64275. | "left"
  64276. | "right";
  64277. type XRTargetRayMode =
  64278. | "gaze"
  64279. | "tracked-pointer"
  64280. | "screen";
  64281. type XREye =
  64282. | "none"
  64283. | "left"
  64284. | "right";
  64285. interface XRSpace extends EventTarget {
  64286. }
  64287. interface XRRenderState {
  64288. depthNear?: number;
  64289. depthFar?: number;
  64290. inlineVerticalFieldOfView?: number;
  64291. baseLayer?: XRWebGLLayer;
  64292. }
  64293. interface XRInputSource {
  64294. handedness: XRHandedness;
  64295. targetRayMode: XRTargetRayMode;
  64296. targetRaySpace: XRSpace;
  64297. gripSpace: XRSpace | undefined;
  64298. gamepad: Gamepad | undefined;
  64299. profiles: Array<string>;
  64300. }
  64301. interface XRSession {
  64302. addEventListener: Function;
  64303. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64304. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64305. requestAnimationFrame: Function;
  64306. end(): Promise<void>;
  64307. renderState: XRRenderState;
  64308. inputSources: Array<XRInputSource>;
  64309. }
  64310. interface XRReferenceSpace extends XRSpace {
  64311. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64312. onreset: any;
  64313. }
  64314. interface XRFrame {
  64315. session: XRSession;
  64316. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64317. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64318. }
  64319. interface XRViewerPose extends XRPose {
  64320. views: Array<XRView>;
  64321. }
  64322. interface XRPose {
  64323. transform: XRRigidTransform;
  64324. emulatedPosition: boolean;
  64325. }
  64326. declare var XRWebGLLayer: {
  64327. prototype: XRWebGLLayer;
  64328. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64329. };
  64330. interface XRWebGLLayer {
  64331. framebuffer: WebGLFramebuffer;
  64332. framebufferWidth: number;
  64333. framebufferHeight: number;
  64334. getViewport: Function;
  64335. }
  64336. interface XRRigidTransform {
  64337. position: DOMPointReadOnly;
  64338. orientation: DOMPointReadOnly;
  64339. matrix: Float32Array;
  64340. inverse: XRRigidTransform;
  64341. }
  64342. interface XRView {
  64343. eye: XREye;
  64344. projectionMatrix: Float32Array;
  64345. transform: XRRigidTransform;
  64346. }
  64347. interface XRInputSourceChangeEvent {
  64348. session: XRSession;
  64349. removed: Array<XRInputSource>;
  64350. added: Array<XRInputSource>;
  64351. }
  64352. /**
  64353. * @ignore
  64354. */
  64355. declare module BABYLON.GLTF2.Exporter {
  64356. }
  64357. /**
  64358. * @ignore
  64359. */
  64360. declare module BABYLON.GLTF1 {
  64361. }
  64362. declare module BABYLON.GUI {
  64363. /**
  64364. * Class used to specific a value and its associated unit
  64365. */
  64366. export class ValueAndUnit {
  64367. /** defines the unit to store */
  64368. unit: number;
  64369. /** defines a boolean indicating if the value can be negative */
  64370. negativeValueAllowed: boolean;
  64371. private _value;
  64372. private _originalUnit;
  64373. /**
  64374. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64375. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64376. */
  64377. ignoreAdaptiveScaling: boolean;
  64378. /**
  64379. * Creates a new ValueAndUnit
  64380. * @param value defines the value to store
  64381. * @param unit defines the unit to store
  64382. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64383. */
  64384. constructor(value: number,
  64385. /** defines the unit to store */
  64386. unit?: number,
  64387. /** defines a boolean indicating if the value can be negative */
  64388. negativeValueAllowed?: boolean);
  64389. /** Gets a boolean indicating if the value is a percentage */
  64390. readonly isPercentage: boolean;
  64391. /** Gets a boolean indicating if the value is store as pixel */
  64392. readonly isPixel: boolean;
  64393. /** Gets direct internal value */
  64394. readonly internalValue: number;
  64395. /**
  64396. * Gets value as pixel
  64397. * @param host defines the root host
  64398. * @param refValue defines the reference value for percentages
  64399. * @returns the value as pixel
  64400. */
  64401. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64402. /**
  64403. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64404. * @param value defines the value to store
  64405. * @param unit defines the unit to store
  64406. * @returns the current ValueAndUnit
  64407. */
  64408. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64409. /**
  64410. * Gets the value accordingly to its unit
  64411. * @param host defines the root host
  64412. * @returns the value
  64413. */
  64414. getValue(host: AdvancedDynamicTexture): number;
  64415. /**
  64416. * Gets a string representation of the value
  64417. * @param host defines the root host
  64418. * @param decimals defines an optional number of decimals to display
  64419. * @returns a string
  64420. */
  64421. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64422. /**
  64423. * Store a value parsed from a string
  64424. * @param source defines the source string
  64425. * @returns true if the value was successfully parsed
  64426. */
  64427. fromString(source: string | number): boolean;
  64428. private static _Regex;
  64429. private static _UNITMODE_PERCENTAGE;
  64430. private static _UNITMODE_PIXEL;
  64431. /** UNITMODE_PERCENTAGE */
  64432. static readonly UNITMODE_PERCENTAGE: number;
  64433. /** UNITMODE_PIXEL */
  64434. static readonly UNITMODE_PIXEL: number;
  64435. }
  64436. }
  64437. declare module BABYLON.GUI {
  64438. /**
  64439. * Define a style used by control to automatically setup properties based on a template.
  64440. * Only support font related properties so far
  64441. */
  64442. export class Style implements BABYLON.IDisposable {
  64443. private _fontFamily;
  64444. private _fontStyle;
  64445. private _fontWeight;
  64446. /** @hidden */
  64447. _host: AdvancedDynamicTexture;
  64448. /** @hidden */
  64449. _fontSize: ValueAndUnit;
  64450. /**
  64451. * BABYLON.Observable raised when the style values are changed
  64452. */
  64453. onChangedObservable: BABYLON.Observable<Style>;
  64454. /**
  64455. * Creates a new style object
  64456. * @param host defines the AdvancedDynamicTexture which hosts this style
  64457. */
  64458. constructor(host: AdvancedDynamicTexture);
  64459. /**
  64460. * Gets or sets the font size
  64461. */
  64462. fontSize: string | number;
  64463. /**
  64464. * Gets or sets the font family
  64465. */
  64466. fontFamily: string;
  64467. /**
  64468. * Gets or sets the font style
  64469. */
  64470. fontStyle: string;
  64471. /** Gets or sets font weight */
  64472. fontWeight: string;
  64473. /** Dispose all associated resources */
  64474. dispose(): void;
  64475. }
  64476. }
  64477. declare module BABYLON.GUI {
  64478. /**
  64479. * Class used to transport BABYLON.Vector2 information for pointer events
  64480. */
  64481. export class Vector2WithInfo extends BABYLON.Vector2 {
  64482. /** defines the current mouse button index */
  64483. buttonIndex: number;
  64484. /**
  64485. * Creates a new Vector2WithInfo
  64486. * @param source defines the vector2 data to transport
  64487. * @param buttonIndex defines the current mouse button index
  64488. */
  64489. constructor(source: BABYLON.Vector2,
  64490. /** defines the current mouse button index */
  64491. buttonIndex?: number);
  64492. }
  64493. /** Class used to provide 2D matrix features */
  64494. export class Matrix2D {
  64495. /** Gets the internal array of 6 floats used to store matrix data */
  64496. m: Float32Array;
  64497. /**
  64498. * Creates a new matrix
  64499. * @param m00 defines value for (0, 0)
  64500. * @param m01 defines value for (0, 1)
  64501. * @param m10 defines value for (1, 0)
  64502. * @param m11 defines value for (1, 1)
  64503. * @param m20 defines value for (2, 0)
  64504. * @param m21 defines value for (2, 1)
  64505. */
  64506. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64507. /**
  64508. * Fills the matrix from direct values
  64509. * @param m00 defines value for (0, 0)
  64510. * @param m01 defines value for (0, 1)
  64511. * @param m10 defines value for (1, 0)
  64512. * @param m11 defines value for (1, 1)
  64513. * @param m20 defines value for (2, 0)
  64514. * @param m21 defines value for (2, 1)
  64515. * @returns the current modified matrix
  64516. */
  64517. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64518. /**
  64519. * Gets matrix determinant
  64520. * @returns the determinant
  64521. */
  64522. determinant(): number;
  64523. /**
  64524. * Inverses the matrix and stores it in a target matrix
  64525. * @param result defines the target matrix
  64526. * @returns the current matrix
  64527. */
  64528. invertToRef(result: Matrix2D): Matrix2D;
  64529. /**
  64530. * Multiplies the current matrix with another one
  64531. * @param other defines the second operand
  64532. * @param result defines the target matrix
  64533. * @returns the current matrix
  64534. */
  64535. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64536. /**
  64537. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64538. * @param x defines the x coordinate to transform
  64539. * @param y defines the x coordinate to transform
  64540. * @param result defines the target vector2
  64541. * @returns the current matrix
  64542. */
  64543. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64544. /**
  64545. * Creates an identity matrix
  64546. * @returns a new matrix
  64547. */
  64548. static Identity(): Matrix2D;
  64549. /**
  64550. * Creates a translation matrix and stores it in a target matrix
  64551. * @param x defines the x coordinate of the translation
  64552. * @param y defines the y coordinate of the translation
  64553. * @param result defines the target matrix
  64554. */
  64555. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64556. /**
  64557. * Creates a scaling matrix and stores it in a target matrix
  64558. * @param x defines the x coordinate of the scaling
  64559. * @param y defines the y coordinate of the scaling
  64560. * @param result defines the target matrix
  64561. */
  64562. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64563. /**
  64564. * Creates a rotation matrix and stores it in a target matrix
  64565. * @param angle defines the rotation angle
  64566. * @param result defines the target matrix
  64567. */
  64568. static RotationToRef(angle: number, result: Matrix2D): void;
  64569. private static _TempPreTranslationMatrix;
  64570. private static _TempPostTranslationMatrix;
  64571. private static _TempRotationMatrix;
  64572. private static _TempScalingMatrix;
  64573. private static _TempCompose0;
  64574. private static _TempCompose1;
  64575. private static _TempCompose2;
  64576. /**
  64577. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64578. * @param tx defines the x coordinate of the translation
  64579. * @param ty defines the y coordinate of the translation
  64580. * @param angle defines the rotation angle
  64581. * @param scaleX defines the x coordinate of the scaling
  64582. * @param scaleY defines the y coordinate of the scaling
  64583. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64584. * @param result defines the target matrix
  64585. */
  64586. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64587. }
  64588. }
  64589. declare module BABYLON.GUI {
  64590. /**
  64591. * Class used to store 2D control sizes
  64592. */
  64593. export class Measure {
  64594. /** defines left coordinate */
  64595. left: number;
  64596. /** defines top coordinate */
  64597. top: number;
  64598. /** defines width dimension */
  64599. width: number;
  64600. /** defines height dimension */
  64601. height: number;
  64602. /**
  64603. * Creates a new measure
  64604. * @param left defines left coordinate
  64605. * @param top defines top coordinate
  64606. * @param width defines width dimension
  64607. * @param height defines height dimension
  64608. */
  64609. constructor(
  64610. /** defines left coordinate */
  64611. left: number,
  64612. /** defines top coordinate */
  64613. top: number,
  64614. /** defines width dimension */
  64615. width: number,
  64616. /** defines height dimension */
  64617. height: number);
  64618. /**
  64619. * Copy from another measure
  64620. * @param other defines the other measure to copy from
  64621. */
  64622. copyFrom(other: Measure): void;
  64623. /**
  64624. * Copy from a group of 4 floats
  64625. * @param left defines left coordinate
  64626. * @param top defines top coordinate
  64627. * @param width defines width dimension
  64628. * @param height defines height dimension
  64629. */
  64630. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64631. /**
  64632. * Computes the axis aligned bounding box measure for two given measures
  64633. * @param a Input measure
  64634. * @param b Input measure
  64635. * @param result the resulting bounding measure
  64636. */
  64637. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64638. /**
  64639. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64640. * @param transform the matrix to transform the measure before computing the AABB
  64641. * @param result the resulting AABB
  64642. */
  64643. transformToRef(transform: Matrix2D, result: Measure): void;
  64644. /**
  64645. * Check equality between this measure and another one
  64646. * @param other defines the other measures
  64647. * @returns true if both measures are equals
  64648. */
  64649. isEqualsTo(other: Measure): boolean;
  64650. /**
  64651. * Creates an empty measure
  64652. * @returns a new measure
  64653. */
  64654. static Empty(): Measure;
  64655. }
  64656. }
  64657. declare module BABYLON.GUI {
  64658. /**
  64659. * Interface used to define a control that can receive focus
  64660. */
  64661. export interface IFocusableControl {
  64662. /**
  64663. * Function called when the control receives the focus
  64664. */
  64665. onFocus(): void;
  64666. /**
  64667. * Function called when the control loses the focus
  64668. */
  64669. onBlur(): void;
  64670. /**
  64671. * Function called to let the control handle keyboard events
  64672. * @param evt defines the current keyboard event
  64673. */
  64674. processKeyboard(evt: KeyboardEvent): void;
  64675. /**
  64676. * Function called to get the list of controls that should not steal the focus from this control
  64677. * @returns an array of controls
  64678. */
  64679. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64680. }
  64681. /**
  64682. * Class used to create texture to support 2D GUI elements
  64683. * @see http://doc.babylonjs.com/how_to/gui
  64684. */
  64685. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64686. private _isDirty;
  64687. private _renderObserver;
  64688. private _resizeObserver;
  64689. private _preKeyboardObserver;
  64690. private _pointerMoveObserver;
  64691. private _pointerObserver;
  64692. private _canvasPointerOutObserver;
  64693. private _background;
  64694. /** @hidden */
  64695. _rootContainer: Container;
  64696. /** @hidden */
  64697. _lastPickedControl: Control;
  64698. /** @hidden */
  64699. _lastControlOver: {
  64700. [pointerId: number]: Control;
  64701. };
  64702. /** @hidden */
  64703. _lastControlDown: {
  64704. [pointerId: number]: Control;
  64705. };
  64706. /** @hidden */
  64707. _capturingControl: {
  64708. [pointerId: number]: Control;
  64709. };
  64710. /** @hidden */
  64711. _shouldBlockPointer: boolean;
  64712. /** @hidden */
  64713. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64714. /** @hidden */
  64715. _linkedControls: Control[];
  64716. private _isFullscreen;
  64717. private _fullscreenViewport;
  64718. private _idealWidth;
  64719. private _idealHeight;
  64720. private _useSmallestIdeal;
  64721. private _renderAtIdealSize;
  64722. private _focusedControl;
  64723. private _blockNextFocusCheck;
  64724. private _renderScale;
  64725. private _rootCanvas;
  64726. private _cursorChanged;
  64727. /**
  64728. * Define type to string to ensure compatibility across browsers
  64729. * Safari doesn't support DataTransfer constructor
  64730. */
  64731. private _clipboardData;
  64732. /**
  64733. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64734. */
  64735. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64736. /**
  64737. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64738. */
  64739. onControlPickedObservable: BABYLON.Observable<Control>;
  64740. /**
  64741. * BABYLON.Observable event triggered before layout is evaluated
  64742. */
  64743. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64744. /**
  64745. * BABYLON.Observable event triggered after the layout was evaluated
  64746. */
  64747. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64748. /**
  64749. * BABYLON.Observable event triggered before the texture is rendered
  64750. */
  64751. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64752. /**
  64753. * BABYLON.Observable event triggered after the texture was rendered
  64754. */
  64755. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64756. /**
  64757. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64758. */
  64759. premulAlpha: boolean;
  64760. /**
  64761. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64762. * Useful when you want more antialiasing
  64763. */
  64764. renderScale: number;
  64765. /** Gets or sets the background color */
  64766. background: string;
  64767. /**
  64768. * Gets or sets the ideal width used to design controls.
  64769. * The GUI will then rescale everything accordingly
  64770. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64771. */
  64772. idealWidth: number;
  64773. /**
  64774. * Gets or sets the ideal height used to design controls.
  64775. * The GUI will then rescale everything accordingly
  64776. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64777. */
  64778. idealHeight: number;
  64779. /**
  64780. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64781. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64782. */
  64783. useSmallestIdeal: boolean;
  64784. /**
  64785. * Gets or sets a boolean indicating if adaptive scaling must be used
  64786. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64787. */
  64788. renderAtIdealSize: boolean;
  64789. /**
  64790. * Gets the underlying layer used to render the texture when in fullscreen mode
  64791. */
  64792. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64793. /**
  64794. * Gets the root container control
  64795. */
  64796. readonly rootContainer: Container;
  64797. /**
  64798. * Returns an array containing the root container.
  64799. * This is mostly used to let the Inspector introspects the ADT
  64800. * @returns an array containing the rootContainer
  64801. */
  64802. getChildren(): Array<Container>;
  64803. /**
  64804. * Will return all controls that are inside this texture
  64805. * @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
  64806. * @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
  64807. * @return all child controls
  64808. */
  64809. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64810. /**
  64811. * Gets or sets the current focused control
  64812. */
  64813. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64814. /**
  64815. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64816. */
  64817. isForeground: boolean;
  64818. /**
  64819. * Gets or set information about clipboardData
  64820. */
  64821. clipboardData: string;
  64822. /**
  64823. * Creates a new AdvancedDynamicTexture
  64824. * @param name defines the name of the texture
  64825. * @param width defines the width of the texture
  64826. * @param height defines the height of the texture
  64827. * @param scene defines the hosting scene
  64828. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64829. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64830. */
  64831. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64832. /**
  64833. * Get the current class name of the texture useful for serialization or dynamic coding.
  64834. * @returns "AdvancedDynamicTexture"
  64835. */
  64836. getClassName(): string;
  64837. /**
  64838. * Function used to execute a function on all controls
  64839. * @param func defines the function to execute
  64840. * @param container defines the container where controls belong. If null the root container will be used
  64841. */
  64842. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64843. private _useInvalidateRectOptimization;
  64844. /**
  64845. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64846. */
  64847. useInvalidateRectOptimization: boolean;
  64848. private _invalidatedRectangle;
  64849. /**
  64850. * Invalidates a rectangle area on the gui texture
  64851. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64852. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64853. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64854. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64855. */
  64856. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64857. /**
  64858. * Marks the texture as dirty forcing a complete update
  64859. */
  64860. markAsDirty(): void;
  64861. /**
  64862. * Helper function used to create a new style
  64863. * @returns a new style
  64864. * @see http://doc.babylonjs.com/how_to/gui#styles
  64865. */
  64866. createStyle(): Style;
  64867. /**
  64868. * Adds a new control to the root container
  64869. * @param control defines the control to add
  64870. * @returns the current texture
  64871. */
  64872. addControl(control: Control): AdvancedDynamicTexture;
  64873. /**
  64874. * Removes a control from the root container
  64875. * @param control defines the control to remove
  64876. * @returns the current texture
  64877. */
  64878. removeControl(control: Control): AdvancedDynamicTexture;
  64879. /**
  64880. * Release all resources
  64881. */
  64882. dispose(): void;
  64883. private _onResize;
  64884. /** @hidden */
  64885. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64886. /**
  64887. * Get screen coordinates for a vector3
  64888. * @param position defines the position to project
  64889. * @param worldMatrix defines the world matrix to use
  64890. * @returns the projected position
  64891. */
  64892. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64893. private _checkUpdate;
  64894. private _clearMeasure;
  64895. private _render;
  64896. /** @hidden */
  64897. _changeCursor(cursor: string): void;
  64898. /** @hidden */
  64899. _registerLastControlDown(control: Control, pointerId: number): void;
  64900. private _doPicking;
  64901. /** @hidden */
  64902. _cleanControlAfterRemovalFromList(list: {
  64903. [pointerId: number]: Control;
  64904. }, control: Control): void;
  64905. /** @hidden */
  64906. _cleanControlAfterRemoval(control: Control): void;
  64907. /** Attach to all scene events required to support pointer events */
  64908. attach(): void;
  64909. /** @hidden */
  64910. private onClipboardCopy;
  64911. /** @hidden */
  64912. private onClipboardCut;
  64913. /** @hidden */
  64914. private onClipboardPaste;
  64915. /**
  64916. * Register the clipboard Events onto the canvas
  64917. */
  64918. registerClipboardEvents(): void;
  64919. /**
  64920. * Unregister the clipboard Events from the canvas
  64921. */
  64922. unRegisterClipboardEvents(): void;
  64923. /**
  64924. * Connect the texture to a hosting mesh to enable interactions
  64925. * @param mesh defines the mesh to attach to
  64926. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64927. */
  64928. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64929. /**
  64930. * Move the focus to a specific control
  64931. * @param control defines the control which will receive the focus
  64932. */
  64933. moveFocusToControl(control: IFocusableControl): void;
  64934. private _manageFocus;
  64935. private _attachToOnPointerOut;
  64936. /**
  64937. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64938. * @param mesh defines the mesh which will receive the texture
  64939. * @param width defines the texture width (1024 by default)
  64940. * @param height defines the texture height (1024 by default)
  64941. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64942. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64943. * @returns a new AdvancedDynamicTexture
  64944. */
  64945. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64946. /**
  64947. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64948. * In this mode the texture will rely on a layer for its rendering.
  64949. * This allows it to be treated like any other layer.
  64950. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64951. * LayerMask is set through advancedTexture.layer.layerMask
  64952. * @param name defines name for the texture
  64953. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64954. * @param scene defines the hsoting scene
  64955. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64956. * @returns a new AdvancedDynamicTexture
  64957. */
  64958. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64959. }
  64960. }
  64961. declare module BABYLON.GUI {
  64962. /**
  64963. * Root class used for all 2D controls
  64964. * @see http://doc.babylonjs.com/how_to/gui#controls
  64965. */
  64966. export class Control {
  64967. /** defines the name of the control */
  64968. name?: string | undefined;
  64969. /**
  64970. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64971. */
  64972. static AllowAlphaInheritance: boolean;
  64973. private _alpha;
  64974. private _alphaSet;
  64975. private _zIndex;
  64976. /** @hidden */
  64977. _host: AdvancedDynamicTexture;
  64978. /** Gets or sets the control parent */
  64979. parent: BABYLON.Nullable<Container>;
  64980. /** @hidden */
  64981. _currentMeasure: Measure;
  64982. private _fontFamily;
  64983. private _fontStyle;
  64984. private _fontWeight;
  64985. private _fontSize;
  64986. private _font;
  64987. /** @hidden */
  64988. _width: ValueAndUnit;
  64989. /** @hidden */
  64990. _height: ValueAndUnit;
  64991. /** @hidden */
  64992. protected _fontOffset: {
  64993. ascent: number;
  64994. height: number;
  64995. descent: number;
  64996. };
  64997. private _color;
  64998. private _style;
  64999. private _styleObserver;
  65000. /** @hidden */
  65001. protected _horizontalAlignment: number;
  65002. /** @hidden */
  65003. protected _verticalAlignment: number;
  65004. /** @hidden */
  65005. protected _isDirty: boolean;
  65006. /** @hidden */
  65007. protected _wasDirty: boolean;
  65008. /** @hidden */
  65009. _tempParentMeasure: Measure;
  65010. /** @hidden */
  65011. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65012. /** @hidden */
  65013. protected _cachedParentMeasure: Measure;
  65014. private _paddingLeft;
  65015. private _paddingRight;
  65016. private _paddingTop;
  65017. private _paddingBottom;
  65018. /** @hidden */
  65019. _left: ValueAndUnit;
  65020. /** @hidden */
  65021. _top: ValueAndUnit;
  65022. private _scaleX;
  65023. private _scaleY;
  65024. private _rotation;
  65025. private _transformCenterX;
  65026. private _transformCenterY;
  65027. /** @hidden */
  65028. _transformMatrix: Matrix2D;
  65029. /** @hidden */
  65030. protected _invertTransformMatrix: Matrix2D;
  65031. /** @hidden */
  65032. protected _transformedPosition: BABYLON.Vector2;
  65033. private _isMatrixDirty;
  65034. private _cachedOffsetX;
  65035. private _cachedOffsetY;
  65036. private _isVisible;
  65037. private _isHighlighted;
  65038. /** @hidden */
  65039. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65040. private _fontSet;
  65041. private _dummyVector2;
  65042. private _downCount;
  65043. private _enterCount;
  65044. private _doNotRender;
  65045. private _downPointerIds;
  65046. protected _isEnabled: boolean;
  65047. protected _disabledColor: string;
  65048. /** @hidden */
  65049. protected _rebuildLayout: boolean;
  65050. /** @hidden */
  65051. _isClipped: boolean;
  65052. /** @hidden */
  65053. _tag: any;
  65054. /**
  65055. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  65056. */
  65057. uniqueId: number;
  65058. /**
  65059. * Gets or sets an object used to store user defined information for the node
  65060. */
  65061. metadata: any;
  65062. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65063. isHitTestVisible: boolean;
  65064. /** Gets or sets a boolean indicating if the control can block pointer events */
  65065. isPointerBlocker: boolean;
  65066. /** Gets or sets a boolean indicating if the control can be focusable */
  65067. isFocusInvisible: boolean;
  65068. /**
  65069. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65070. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  65071. */
  65072. clipChildren: boolean;
  65073. /**
  65074. * Gets or sets a boolean indicating that control content must be clipped
  65075. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  65076. */
  65077. clipContent: boolean;
  65078. /**
  65079. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65080. */
  65081. useBitmapCache: boolean;
  65082. private _cacheData;
  65083. private _shadowOffsetX;
  65084. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65085. shadowOffsetX: number;
  65086. private _shadowOffsetY;
  65087. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65088. shadowOffsetY: number;
  65089. private _shadowBlur;
  65090. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65091. shadowBlur: number;
  65092. private _shadowColor;
  65093. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65094. shadowColor: string;
  65095. /** Gets or sets the cursor to use when the control is hovered */
  65096. hoverCursor: string;
  65097. /** @hidden */
  65098. protected _linkOffsetX: ValueAndUnit;
  65099. /** @hidden */
  65100. protected _linkOffsetY: ValueAndUnit;
  65101. /** Gets the control type name */
  65102. readonly typeName: string;
  65103. /**
  65104. * Get the current class name of the control.
  65105. * @returns current class name
  65106. */
  65107. getClassName(): string;
  65108. /**
  65109. * An event triggered when the pointer move over the control.
  65110. */
  65111. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65112. /**
  65113. * An event triggered when the pointer move out of the control.
  65114. */
  65115. onPointerOutObservable: BABYLON.Observable<Control>;
  65116. /**
  65117. * An event triggered when the pointer taps the control
  65118. */
  65119. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65120. /**
  65121. * An event triggered when pointer up
  65122. */
  65123. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65124. /**
  65125. * An event triggered when a control is clicked on
  65126. */
  65127. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65128. /**
  65129. * An event triggered when pointer enters the control
  65130. */
  65131. onPointerEnterObservable: BABYLON.Observable<Control>;
  65132. /**
  65133. * An event triggered when the control is marked as dirty
  65134. */
  65135. onDirtyObservable: BABYLON.Observable<Control>;
  65136. /**
  65137. * An event triggered before drawing the control
  65138. */
  65139. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65140. /**
  65141. * An event triggered after the control was drawn
  65142. */
  65143. onAfterDrawObservable: BABYLON.Observable<Control>;
  65144. /**
  65145. * Get the hosting AdvancedDynamicTexture
  65146. */
  65147. readonly host: AdvancedDynamicTexture;
  65148. /** Gets or set information about font offsets (used to render and align text) */
  65149. fontOffset: {
  65150. ascent: number;
  65151. height: number;
  65152. descent: number;
  65153. };
  65154. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65155. alpha: number;
  65156. /**
  65157. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65158. */
  65159. isHighlighted: boolean;
  65160. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65161. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65162. */
  65163. scaleX: number;
  65164. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65165. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65166. */
  65167. scaleY: number;
  65168. /** Gets or sets the rotation angle (0 by default)
  65169. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65170. */
  65171. rotation: number;
  65172. /** Gets or sets the transformation center on Y axis (0 by default)
  65173. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65174. */
  65175. transformCenterY: number;
  65176. /** Gets or sets the transformation center on X axis (0 by default)
  65177. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65178. */
  65179. transformCenterX: number;
  65180. /**
  65181. * Gets or sets the horizontal alignment
  65182. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65183. */
  65184. horizontalAlignment: number;
  65185. /**
  65186. * Gets or sets the vertical alignment
  65187. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65188. */
  65189. verticalAlignment: number;
  65190. /**
  65191. * Gets or sets control width
  65192. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65193. */
  65194. width: string | number;
  65195. /**
  65196. * Gets or sets the control width in pixel
  65197. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65198. */
  65199. widthInPixels: number;
  65200. /**
  65201. * Gets or sets control height
  65202. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65203. */
  65204. height: string | number;
  65205. /**
  65206. * Gets or sets control height in pixel
  65207. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65208. */
  65209. heightInPixels: number;
  65210. /** Gets or set font family */
  65211. fontFamily: string;
  65212. /** Gets or sets font style */
  65213. fontStyle: string;
  65214. /** Gets or sets font weight */
  65215. fontWeight: string;
  65216. /**
  65217. * Gets or sets style
  65218. * @see http://doc.babylonjs.com/how_to/gui#styles
  65219. */
  65220. style: BABYLON.Nullable<Style>;
  65221. /** @hidden */
  65222. readonly _isFontSizeInPercentage: boolean;
  65223. /** Gets or sets font size in pixels */
  65224. fontSizeInPixels: number;
  65225. /** Gets or sets font size */
  65226. fontSize: string | number;
  65227. /** Gets or sets foreground color */
  65228. color: string;
  65229. /** Gets or sets z index which is used to reorder controls on the z axis */
  65230. zIndex: number;
  65231. /** Gets or sets a boolean indicating if the control can be rendered */
  65232. notRenderable: boolean;
  65233. /** Gets or sets a boolean indicating if the control is visible */
  65234. isVisible: boolean;
  65235. /** Gets a boolean indicating that the control needs to update its rendering */
  65236. readonly isDirty: boolean;
  65237. /**
  65238. * Gets the current linked mesh (or null if none)
  65239. */
  65240. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65241. /**
  65242. * Gets or sets a value indicating the padding to use on the left of the control
  65243. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65244. */
  65245. paddingLeft: string | number;
  65246. /**
  65247. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65249. */
  65250. paddingLeftInPixels: number;
  65251. /**
  65252. * Gets or sets a value indicating the padding to use on the right of the control
  65253. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65254. */
  65255. paddingRight: string | number;
  65256. /**
  65257. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65258. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65259. */
  65260. paddingRightInPixels: number;
  65261. /**
  65262. * Gets or sets a value indicating the padding to use on the top of the control
  65263. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65264. */
  65265. paddingTop: string | number;
  65266. /**
  65267. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65269. */
  65270. paddingTopInPixels: number;
  65271. /**
  65272. * Gets or sets a value indicating the padding to use on the bottom of the control
  65273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65274. */
  65275. paddingBottom: string | number;
  65276. /**
  65277. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65278. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65279. */
  65280. paddingBottomInPixels: number;
  65281. /**
  65282. * Gets or sets a value indicating the left coordinate of the control
  65283. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65284. */
  65285. left: string | number;
  65286. /**
  65287. * Gets or sets a value indicating the left coordinate in pixels of the control
  65288. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65289. */
  65290. leftInPixels: number;
  65291. /**
  65292. * Gets or sets a value indicating the top coordinate of the control
  65293. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65294. */
  65295. top: string | number;
  65296. /**
  65297. * Gets or sets a value indicating the top coordinate in pixels of the control
  65298. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65299. */
  65300. topInPixels: number;
  65301. /**
  65302. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65303. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65304. */
  65305. linkOffsetX: string | number;
  65306. /**
  65307. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65308. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65309. */
  65310. linkOffsetXInPixels: number;
  65311. /**
  65312. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65313. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65314. */
  65315. linkOffsetY: string | number;
  65316. /**
  65317. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65318. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65319. */
  65320. linkOffsetYInPixels: number;
  65321. /** Gets the center coordinate on X axis */
  65322. readonly centerX: number;
  65323. /** Gets the center coordinate on Y axis */
  65324. readonly centerY: number;
  65325. /** Gets or sets if control is Enabled*/
  65326. isEnabled: boolean;
  65327. /** Gets or sets background color of control if it's disabled*/
  65328. disabledColor: string;
  65329. /**
  65330. * Creates a new control
  65331. * @param name defines the name of the control
  65332. */
  65333. constructor(
  65334. /** defines the name of the control */
  65335. name?: string | undefined);
  65336. /** @hidden */
  65337. protected _getTypeName(): string;
  65338. /**
  65339. * Gets the first ascendant in the hierarchy of the given type
  65340. * @param className defines the required type
  65341. * @returns the ascendant or null if not found
  65342. */
  65343. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65344. /** @hidden */
  65345. _resetFontCache(): void;
  65346. /**
  65347. * Determines if a container is an ascendant of the current control
  65348. * @param container defines the container to look for
  65349. * @returns true if the container is one of the ascendant of the control
  65350. */
  65351. isAscendant(container: Control): boolean;
  65352. /**
  65353. * Gets coordinates in local control space
  65354. * @param globalCoordinates defines the coordinates to transform
  65355. * @returns the new coordinates in local space
  65356. */
  65357. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65358. /**
  65359. * Gets coordinates in local control space
  65360. * @param globalCoordinates defines the coordinates to transform
  65361. * @param result defines the target vector2 where to store the result
  65362. * @returns the current control
  65363. */
  65364. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65365. /**
  65366. * Gets coordinates in parent local control space
  65367. * @param globalCoordinates defines the coordinates to transform
  65368. * @returns the new coordinates in parent local space
  65369. */
  65370. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65371. /**
  65372. * Move the current control to a vector3 position projected onto the screen.
  65373. * @param position defines the target position
  65374. * @param scene defines the hosting scene
  65375. */
  65376. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65377. /** @hidden */
  65378. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65379. /**
  65380. * Will return all controls that have this control as ascendant
  65381. * @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
  65382. * @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
  65383. * @return all child controls
  65384. */
  65385. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65386. /**
  65387. * Link current control with a target mesh
  65388. * @param mesh defines the mesh to link with
  65389. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65390. */
  65391. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65392. /** @hidden */
  65393. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65394. /** @hidden */
  65395. _offsetLeft(offset: number): void;
  65396. /** @hidden */
  65397. _offsetTop(offset: number): void;
  65398. /** @hidden */
  65399. _markMatrixAsDirty(): void;
  65400. /** @hidden */
  65401. _flagDescendantsAsMatrixDirty(): void;
  65402. /** @hidden */
  65403. _intersectsRect(rect: Measure): boolean;
  65404. /** @hidden */
  65405. protected invalidateRect(): void;
  65406. /** @hidden */
  65407. _markAsDirty(force?: boolean): void;
  65408. /** @hidden */
  65409. _markAllAsDirty(): void;
  65410. /** @hidden */
  65411. _link(host: AdvancedDynamicTexture): void;
  65412. /** @hidden */
  65413. protected _transform(context?: CanvasRenderingContext2D): void;
  65414. /** @hidden */
  65415. _renderHighlight(context: CanvasRenderingContext2D): void;
  65416. /** @hidden */
  65417. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65418. /** @hidden */
  65419. protected _applyStates(context: CanvasRenderingContext2D): void;
  65420. /** @hidden */
  65421. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65422. /** @hidden */
  65423. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65424. protected _evaluateClippingState(parentMeasure: Measure): void;
  65425. /** @hidden */
  65426. _measure(): void;
  65427. /** @hidden */
  65428. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65429. /** @hidden */
  65430. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65431. /** @hidden */
  65432. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65433. /** @hidden */
  65434. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65435. private static _ClipMeasure;
  65436. private _tmpMeasureA;
  65437. private _clip;
  65438. /** @hidden */
  65439. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65440. /** @hidden */
  65441. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65442. /**
  65443. * Tests if a given coordinates belong to the current control
  65444. * @param x defines x coordinate to test
  65445. * @param y defines y coordinate to test
  65446. * @returns true if the coordinates are inside the control
  65447. */
  65448. contains(x: number, y: number): boolean;
  65449. /** @hidden */
  65450. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65451. /** @hidden */
  65452. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65453. /** @hidden */
  65454. _onPointerEnter(target: Control): boolean;
  65455. /** @hidden */
  65456. _onPointerOut(target: Control, force?: boolean): void;
  65457. /** @hidden */
  65458. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65459. /** @hidden */
  65460. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65461. /** @hidden */
  65462. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65463. /** @hidden */
  65464. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65465. private _prepareFont;
  65466. /** Releases associated resources */
  65467. dispose(): void;
  65468. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65469. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65470. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65471. private static _VERTICAL_ALIGNMENT_TOP;
  65472. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65473. private static _VERTICAL_ALIGNMENT_CENTER;
  65474. /** HORIZONTAL_ALIGNMENT_LEFT */
  65475. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65476. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65477. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65478. /** HORIZONTAL_ALIGNMENT_CENTER */
  65479. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65480. /** VERTICAL_ALIGNMENT_TOP */
  65481. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65482. /** VERTICAL_ALIGNMENT_BOTTOM */
  65483. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65484. /** VERTICAL_ALIGNMENT_CENTER */
  65485. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65486. private static _FontHeightSizes;
  65487. /** @hidden */
  65488. static _GetFontOffset(font: string): {
  65489. ascent: number;
  65490. height: number;
  65491. descent: number;
  65492. };
  65493. /**
  65494. * Creates a stack panel that can be used to render headers
  65495. * @param control defines the control to associate with the header
  65496. * @param text defines the text of the header
  65497. * @param size defines the size of the header
  65498. * @param options defines options used to configure the header
  65499. * @returns a new StackPanel
  65500. * @ignore
  65501. * @hidden
  65502. */
  65503. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65504. isHorizontal: boolean;
  65505. controlFirst: boolean;
  65506. }) => any;
  65507. /** @hidden */
  65508. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65509. }
  65510. }
  65511. declare module BABYLON.GUI {
  65512. /**
  65513. * Root class for 2D containers
  65514. * @see http://doc.babylonjs.com/how_to/gui#containers
  65515. */
  65516. export class Container extends Control {
  65517. name?: string | undefined;
  65518. /** @hidden */
  65519. protected _children: Control[];
  65520. /** @hidden */
  65521. protected _measureForChildren: Measure;
  65522. /** @hidden */
  65523. protected _background: string;
  65524. /** @hidden */
  65525. protected _adaptWidthToChildren: boolean;
  65526. /** @hidden */
  65527. protected _adaptHeightToChildren: boolean;
  65528. /**
  65529. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65530. */
  65531. logLayoutCycleErrors: boolean;
  65532. /**
  65533. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65534. */
  65535. maxLayoutCycle: number;
  65536. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65537. adaptHeightToChildren: boolean;
  65538. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65539. adaptWidthToChildren: boolean;
  65540. /** Gets or sets background color */
  65541. background: string;
  65542. /** Gets the list of children */
  65543. readonly children: Control[];
  65544. /**
  65545. * Creates a new Container
  65546. * @param name defines the name of the container
  65547. */
  65548. constructor(name?: string | undefined);
  65549. protected _getTypeName(): string;
  65550. _flagDescendantsAsMatrixDirty(): void;
  65551. /**
  65552. * Gets a child using its name
  65553. * @param name defines the child name to look for
  65554. * @returns the child control if found
  65555. */
  65556. getChildByName(name: string): BABYLON.Nullable<Control>;
  65557. /**
  65558. * Gets a child using its type and its name
  65559. * @param name defines the child name to look for
  65560. * @param type defines the child type to look for
  65561. * @returns the child control if found
  65562. */
  65563. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65564. /**
  65565. * Search for a specific control in children
  65566. * @param control defines the control to look for
  65567. * @returns true if the control is in child list
  65568. */
  65569. containsControl(control: Control): boolean;
  65570. /**
  65571. * Adds a new control to the current container
  65572. * @param control defines the control to add
  65573. * @returns the current container
  65574. */
  65575. addControl(control: BABYLON.Nullable<Control>): Container;
  65576. /**
  65577. * Removes all controls from the current container
  65578. * @returns the current container
  65579. */
  65580. clearControls(): Container;
  65581. /**
  65582. * Removes a control from the current container
  65583. * @param control defines the control to remove
  65584. * @returns the current container
  65585. */
  65586. removeControl(control: Control): Container;
  65587. /** @hidden */
  65588. _reOrderControl(control: Control): void;
  65589. /** @hidden */
  65590. _offsetLeft(offset: number): void;
  65591. /** @hidden */
  65592. _offsetTop(offset: number): void;
  65593. /** @hidden */
  65594. _markAllAsDirty(): void;
  65595. /** @hidden */
  65596. protected _localDraw(context: CanvasRenderingContext2D): void;
  65597. /** @hidden */
  65598. _link(host: AdvancedDynamicTexture): void;
  65599. /** @hidden */
  65600. protected _beforeLayout(): void;
  65601. /** @hidden */
  65602. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65603. /** @hidden */
  65604. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65605. protected _postMeasure(): void;
  65606. /** @hidden */
  65607. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65608. /** @hidden */
  65609. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65610. /** @hidden */
  65611. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65612. /** @hidden */
  65613. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65614. /** Releases associated resources */
  65615. dispose(): void;
  65616. }
  65617. }
  65618. declare module BABYLON.GUI {
  65619. /** Class used to create rectangle container */
  65620. export class Rectangle extends Container {
  65621. name?: string | undefined;
  65622. private _thickness;
  65623. private _cornerRadius;
  65624. /** Gets or sets border thickness */
  65625. thickness: number;
  65626. /** Gets or sets the corner radius angle */
  65627. cornerRadius: number;
  65628. /**
  65629. * Creates a new Rectangle
  65630. * @param name defines the control name
  65631. */
  65632. constructor(name?: string | undefined);
  65633. protected _getTypeName(): string;
  65634. protected _localDraw(context: CanvasRenderingContext2D): void;
  65635. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65636. private _drawRoundedRect;
  65637. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65638. }
  65639. }
  65640. declare module BABYLON.GUI {
  65641. /**
  65642. * Enum that determines the text-wrapping mode to use.
  65643. */
  65644. export enum TextWrapping {
  65645. /**
  65646. * Clip the text when it's larger than Control.width; this is the default mode.
  65647. */
  65648. Clip = 0,
  65649. /**
  65650. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65651. */
  65652. WordWrap = 1,
  65653. /**
  65654. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65655. */
  65656. Ellipsis = 2
  65657. }
  65658. /**
  65659. * Class used to create text block control
  65660. */
  65661. export class TextBlock extends Control {
  65662. /**
  65663. * Defines the name of the control
  65664. */
  65665. name?: string | undefined;
  65666. private _text;
  65667. private _textWrapping;
  65668. private _textHorizontalAlignment;
  65669. private _textVerticalAlignment;
  65670. private _lines;
  65671. private _resizeToFit;
  65672. private _lineSpacing;
  65673. private _outlineWidth;
  65674. private _outlineColor;
  65675. /**
  65676. * An event triggered after the text is changed
  65677. */
  65678. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65679. /**
  65680. * An event triggered after the text was broken up into lines
  65681. */
  65682. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65683. /**
  65684. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65685. */
  65686. readonly lines: any[];
  65687. /**
  65688. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65689. */
  65690. /**
  65691. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65692. */
  65693. resizeToFit: boolean;
  65694. /**
  65695. * Gets or sets a boolean indicating if text must be wrapped
  65696. */
  65697. /**
  65698. * Gets or sets a boolean indicating if text must be wrapped
  65699. */
  65700. textWrapping: TextWrapping | boolean;
  65701. /**
  65702. * Gets or sets text to display
  65703. */
  65704. /**
  65705. * Gets or sets text to display
  65706. */
  65707. text: string;
  65708. /**
  65709. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65710. */
  65711. /**
  65712. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65713. */
  65714. textHorizontalAlignment: number;
  65715. /**
  65716. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65717. */
  65718. /**
  65719. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65720. */
  65721. textVerticalAlignment: number;
  65722. /**
  65723. * Gets or sets line spacing value
  65724. */
  65725. /**
  65726. * Gets or sets line spacing value
  65727. */
  65728. lineSpacing: string | number;
  65729. /**
  65730. * Gets or sets outlineWidth of the text to display
  65731. */
  65732. /**
  65733. * Gets or sets outlineWidth of the text to display
  65734. */
  65735. outlineWidth: number;
  65736. /**
  65737. * Gets or sets outlineColor of the text to display
  65738. */
  65739. /**
  65740. * Gets or sets outlineColor of the text to display
  65741. */
  65742. outlineColor: string;
  65743. /**
  65744. * Creates a new TextBlock object
  65745. * @param name defines the name of the control
  65746. * @param text defines the text to display (emptry string by default)
  65747. */
  65748. constructor(
  65749. /**
  65750. * Defines the name of the control
  65751. */
  65752. name?: string | undefined, text?: string);
  65753. protected _getTypeName(): string;
  65754. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65755. private _drawText;
  65756. /** @hidden */
  65757. _draw(context: CanvasRenderingContext2D): void;
  65758. protected _applyStates(context: CanvasRenderingContext2D): void;
  65759. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65760. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65761. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65762. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65763. protected _renderLines(context: CanvasRenderingContext2D): void;
  65764. /**
  65765. * Given a width constraint applied on the text block, find the expected height
  65766. * @returns expected height
  65767. */
  65768. computeExpectedHeight(): number;
  65769. dispose(): void;
  65770. }
  65771. }
  65772. declare module BABYLON.GUI {
  65773. /**
  65774. * Class used to create 2D images
  65775. */
  65776. export class Image extends Control {
  65777. name?: string | undefined;
  65778. private static _WorkingCanvas;
  65779. private _domImage;
  65780. private _imageWidth;
  65781. private _imageHeight;
  65782. private _loaded;
  65783. private _stretch;
  65784. private _source;
  65785. private _autoScale;
  65786. private _sourceLeft;
  65787. private _sourceTop;
  65788. private _sourceWidth;
  65789. private _sourceHeight;
  65790. private _cellWidth;
  65791. private _cellHeight;
  65792. private _cellId;
  65793. private _populateNinePatchSlicesFromImage;
  65794. private _sliceLeft;
  65795. private _sliceRight;
  65796. private _sliceTop;
  65797. private _sliceBottom;
  65798. private _detectPointerOnOpaqueOnly;
  65799. /**
  65800. * BABYLON.Observable notified when the content is loaded
  65801. */
  65802. onImageLoadedObservable: BABYLON.Observable<Image>;
  65803. /**
  65804. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65805. */
  65806. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65807. /**
  65808. * Gets a boolean indicating that the content is loaded
  65809. */
  65810. readonly isLoaded: boolean;
  65811. /**
  65812. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65813. */
  65814. populateNinePatchSlicesFromImage: boolean;
  65815. /**
  65816. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65817. * Beware using this as this will comsume more memory as the image has to be stored twice
  65818. */
  65819. detectPointerOnOpaqueOnly: boolean;
  65820. /**
  65821. * Gets or sets the left value for slicing (9-patch)
  65822. */
  65823. sliceLeft: number;
  65824. /**
  65825. * Gets or sets the right value for slicing (9-patch)
  65826. */
  65827. sliceRight: number;
  65828. /**
  65829. * Gets or sets the top value for slicing (9-patch)
  65830. */
  65831. sliceTop: number;
  65832. /**
  65833. * Gets or sets the bottom value for slicing (9-patch)
  65834. */
  65835. sliceBottom: number;
  65836. /**
  65837. * Gets or sets the left coordinate in the source image
  65838. */
  65839. sourceLeft: number;
  65840. /**
  65841. * Gets or sets the top coordinate in the source image
  65842. */
  65843. sourceTop: number;
  65844. /**
  65845. * Gets or sets the width to capture in the source image
  65846. */
  65847. sourceWidth: number;
  65848. /**
  65849. * Gets or sets the height to capture in the source image
  65850. */
  65851. sourceHeight: number;
  65852. /**
  65853. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65854. * @see http://doc.babylonjs.com/how_to/gui#image
  65855. */
  65856. autoScale: boolean;
  65857. /** Gets or sets the streching mode used by the image */
  65858. stretch: number;
  65859. /**
  65860. * Gets or sets the internal DOM image used to render the control
  65861. */
  65862. domImage: HTMLImageElement;
  65863. private _onImageLoaded;
  65864. private _extractNinePatchSliceDataFromImage;
  65865. /**
  65866. * Gets or sets image source url
  65867. */
  65868. source: BABYLON.Nullable<string>;
  65869. /**
  65870. * Checks for svg document with icon id present
  65871. */
  65872. private _svgCheck;
  65873. /**
  65874. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65875. * given external svg file and icon id
  65876. */
  65877. private _getSVGAttribs;
  65878. /**
  65879. * Gets or sets the cell width to use when animation sheet is enabled
  65880. * @see http://doc.babylonjs.com/how_to/gui#image
  65881. */
  65882. cellWidth: number;
  65883. /**
  65884. * Gets or sets the cell height to use when animation sheet is enabled
  65885. * @see http://doc.babylonjs.com/how_to/gui#image
  65886. */
  65887. cellHeight: number;
  65888. /**
  65889. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65890. * @see http://doc.babylonjs.com/how_to/gui#image
  65891. */
  65892. cellId: number;
  65893. /**
  65894. * Creates a new Image
  65895. * @param name defines the control name
  65896. * @param url defines the image url
  65897. */
  65898. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65899. /**
  65900. * Tests if a given coordinates belong to the current control
  65901. * @param x defines x coordinate to test
  65902. * @param y defines y coordinate to test
  65903. * @returns true if the coordinates are inside the control
  65904. */
  65905. contains(x: number, y: number): boolean;
  65906. protected _getTypeName(): string;
  65907. /** Force the control to synchronize with its content */
  65908. synchronizeSizeWithContent(): void;
  65909. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65910. private _prepareWorkingCanvasForOpaqueDetection;
  65911. private _drawImage;
  65912. _draw(context: CanvasRenderingContext2D): void;
  65913. private _renderCornerPatch;
  65914. private _renderNinePatch;
  65915. dispose(): void;
  65916. /** STRETCH_NONE */
  65917. static readonly STRETCH_NONE: number;
  65918. /** STRETCH_FILL */
  65919. static readonly STRETCH_FILL: number;
  65920. /** STRETCH_UNIFORM */
  65921. static readonly STRETCH_UNIFORM: number;
  65922. /** STRETCH_EXTEND */
  65923. static readonly STRETCH_EXTEND: number;
  65924. /** NINE_PATCH */
  65925. static readonly STRETCH_NINE_PATCH: number;
  65926. }
  65927. }
  65928. declare module BABYLON.GUI {
  65929. /**
  65930. * Class used to create 2D buttons
  65931. */
  65932. export class Button extends Rectangle {
  65933. name?: string | undefined;
  65934. /**
  65935. * Function called to generate a pointer enter animation
  65936. */
  65937. pointerEnterAnimation: () => void;
  65938. /**
  65939. * Function called to generate a pointer out animation
  65940. */
  65941. pointerOutAnimation: () => void;
  65942. /**
  65943. * Function called to generate a pointer down animation
  65944. */
  65945. pointerDownAnimation: () => void;
  65946. /**
  65947. * Function called to generate a pointer up animation
  65948. */
  65949. pointerUpAnimation: () => void;
  65950. /**
  65951. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65952. */
  65953. delegatePickingToChildren: boolean;
  65954. private _image;
  65955. /**
  65956. * Returns the image part of the button (if any)
  65957. */
  65958. readonly image: BABYLON.Nullable<Image>;
  65959. private _textBlock;
  65960. /**
  65961. * Returns the image part of the button (if any)
  65962. */
  65963. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65964. /**
  65965. * Creates a new Button
  65966. * @param name defines the name of the button
  65967. */
  65968. constructor(name?: string | undefined);
  65969. protected _getTypeName(): string;
  65970. /** @hidden */
  65971. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65972. /** @hidden */
  65973. _onPointerEnter(target: Control): boolean;
  65974. /** @hidden */
  65975. _onPointerOut(target: Control, force?: boolean): void;
  65976. /** @hidden */
  65977. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65978. /** @hidden */
  65979. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65980. /**
  65981. * Creates a new button made with an image and a text
  65982. * @param name defines the name of the button
  65983. * @param text defines the text of the button
  65984. * @param imageUrl defines the url of the image
  65985. * @returns a new Button
  65986. */
  65987. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65988. /**
  65989. * Creates a new button made with an image
  65990. * @param name defines the name of the button
  65991. * @param imageUrl defines the url of the image
  65992. * @returns a new Button
  65993. */
  65994. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65995. /**
  65996. * Creates a new button made with a text
  65997. * @param name defines the name of the button
  65998. * @param text defines the text of the button
  65999. * @returns a new Button
  66000. */
  66001. static CreateSimpleButton(name: string, text: string): Button;
  66002. /**
  66003. * Creates a new button made with an image and a centered text
  66004. * @param name defines the name of the button
  66005. * @param text defines the text of the button
  66006. * @param imageUrl defines the url of the image
  66007. * @returns a new Button
  66008. */
  66009. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66010. }
  66011. }
  66012. declare module BABYLON.GUI {
  66013. /**
  66014. * Class used to create a 2D stack panel container
  66015. */
  66016. export class StackPanel extends Container {
  66017. name?: string | undefined;
  66018. private _isVertical;
  66019. private _manualWidth;
  66020. private _manualHeight;
  66021. private _doNotTrackManualChanges;
  66022. /**
  66023. * Gets or sets a boolean indicating that layou warnings should be ignored
  66024. */
  66025. ignoreLayoutWarnings: boolean;
  66026. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66027. isVertical: boolean;
  66028. /**
  66029. * Gets or sets panel width.
  66030. * This value should not be set when in horizontal mode as it will be computed automatically
  66031. */
  66032. width: string | number;
  66033. /**
  66034. * Gets or sets panel height.
  66035. * This value should not be set when in vertical mode as it will be computed automatically
  66036. */
  66037. height: string | number;
  66038. /**
  66039. * Creates a new StackPanel
  66040. * @param name defines control name
  66041. */
  66042. constructor(name?: string | undefined);
  66043. protected _getTypeName(): string;
  66044. /** @hidden */
  66045. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66046. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66047. protected _postMeasure(): void;
  66048. }
  66049. }
  66050. declare module BABYLON.GUI {
  66051. /**
  66052. * Class used to represent a 2D checkbox
  66053. */
  66054. export class Checkbox extends Control {
  66055. name?: string | undefined;
  66056. private _isChecked;
  66057. private _background;
  66058. private _checkSizeRatio;
  66059. private _thickness;
  66060. /** Gets or sets border thickness */
  66061. thickness: number;
  66062. /**
  66063. * BABYLON.Observable raised when isChecked property changes
  66064. */
  66065. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66066. /** Gets or sets a value indicating the ratio between overall size and check size */
  66067. checkSizeRatio: number;
  66068. /** Gets or sets background color */
  66069. background: string;
  66070. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66071. isChecked: boolean;
  66072. /**
  66073. * Creates a new CheckBox
  66074. * @param name defines the control name
  66075. */
  66076. constructor(name?: string | undefined);
  66077. protected _getTypeName(): string;
  66078. /** @hidden */
  66079. _draw(context: CanvasRenderingContext2D): void;
  66080. /** @hidden */
  66081. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66082. /**
  66083. * Utility function to easily create a checkbox with a header
  66084. * @param title defines the label to use for the header
  66085. * @param onValueChanged defines the callback to call when value changes
  66086. * @returns a StackPanel containing the checkbox and a textBlock
  66087. */
  66088. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66089. }
  66090. }
  66091. declare module BABYLON.GUI {
  66092. /**
  66093. * Class used to store key control properties
  66094. */
  66095. export class KeyPropertySet {
  66096. /** Width */
  66097. width?: string;
  66098. /** Height */
  66099. height?: string;
  66100. /** Left padding */
  66101. paddingLeft?: string;
  66102. /** Right padding */
  66103. paddingRight?: string;
  66104. /** Top padding */
  66105. paddingTop?: string;
  66106. /** Bottom padding */
  66107. paddingBottom?: string;
  66108. /** Foreground color */
  66109. color?: string;
  66110. /** Background color */
  66111. background?: string;
  66112. }
  66113. /**
  66114. * Class used to create virtual keyboard
  66115. */
  66116. export class VirtualKeyboard extends StackPanel {
  66117. /** BABYLON.Observable raised when a key is pressed */
  66118. onKeyPressObservable: BABYLON.Observable<string>;
  66119. /** Gets or sets default key button width */
  66120. defaultButtonWidth: string;
  66121. /** Gets or sets default key button height */
  66122. defaultButtonHeight: string;
  66123. /** Gets or sets default key button left padding */
  66124. defaultButtonPaddingLeft: string;
  66125. /** Gets or sets default key button right padding */
  66126. defaultButtonPaddingRight: string;
  66127. /** Gets or sets default key button top padding */
  66128. defaultButtonPaddingTop: string;
  66129. /** Gets or sets default key button bottom padding */
  66130. defaultButtonPaddingBottom: string;
  66131. /** Gets or sets default key button foreground color */
  66132. defaultButtonColor: string;
  66133. /** Gets or sets default key button background color */
  66134. defaultButtonBackground: string;
  66135. /** Gets or sets shift button foreground color */
  66136. shiftButtonColor: string;
  66137. /** Gets or sets shift button thickness*/
  66138. selectedShiftThickness: number;
  66139. /** Gets shift key state */
  66140. shiftState: number;
  66141. protected _getTypeName(): string;
  66142. private _createKey;
  66143. /**
  66144. * Adds a new row of keys
  66145. * @param keys defines the list of keys to add
  66146. * @param propertySets defines the associated property sets
  66147. */
  66148. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66149. /**
  66150. * Set the shift key to a specific state
  66151. * @param shiftState defines the new shift state
  66152. */
  66153. applyShiftState(shiftState: number): void;
  66154. private _currentlyConnectedInputText;
  66155. private _connectedInputTexts;
  66156. private _onKeyPressObserver;
  66157. /** Gets the input text control currently attached to the keyboard */
  66158. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66159. /**
  66160. * Connects the keyboard with an input text control
  66161. *
  66162. * @param input defines the target control
  66163. */
  66164. connect(input: InputText): void;
  66165. /**
  66166. * Disconnects the keyboard from connected InputText controls
  66167. *
  66168. * @param input optionally defines a target control, otherwise all are disconnected
  66169. */
  66170. disconnect(input?: InputText): void;
  66171. private _removeConnectedInputObservables;
  66172. /**
  66173. * Release all resources
  66174. */
  66175. dispose(): void;
  66176. /**
  66177. * Creates a new keyboard using a default layout
  66178. *
  66179. * @param name defines control name
  66180. * @returns a new VirtualKeyboard
  66181. */
  66182. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66183. }
  66184. }
  66185. declare module BABYLON.GUI {
  66186. /**
  66187. * Class used to create input text control
  66188. */
  66189. export class InputText extends Control implements IFocusableControl {
  66190. name?: string | undefined;
  66191. private _text;
  66192. private _placeholderText;
  66193. private _background;
  66194. private _focusedBackground;
  66195. private _focusedColor;
  66196. private _placeholderColor;
  66197. private _thickness;
  66198. private _margin;
  66199. private _autoStretchWidth;
  66200. private _maxWidth;
  66201. private _isFocused;
  66202. private _blinkTimeout;
  66203. private _blinkIsEven;
  66204. private _cursorOffset;
  66205. private _scrollLeft;
  66206. private _textWidth;
  66207. private _clickedCoordinate;
  66208. private _deadKey;
  66209. private _addKey;
  66210. private _currentKey;
  66211. private _isTextHighlightOn;
  66212. private _textHighlightColor;
  66213. private _highligherOpacity;
  66214. private _highlightedText;
  66215. private _startHighlightIndex;
  66216. private _endHighlightIndex;
  66217. private _cursorIndex;
  66218. private _onFocusSelectAll;
  66219. private _isPointerDown;
  66220. private _onClipboardObserver;
  66221. private _onPointerDblTapObserver;
  66222. /** @hidden */
  66223. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66224. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66225. promptMessage: string;
  66226. /** Force disable prompt on mobile device */
  66227. disableMobilePrompt: boolean;
  66228. /** BABYLON.Observable raised when the text changes */
  66229. onTextChangedObservable: BABYLON.Observable<InputText>;
  66230. /** BABYLON.Observable raised just before an entered character is to be added */
  66231. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66232. /** BABYLON.Observable raised when the control gets the focus */
  66233. onFocusObservable: BABYLON.Observable<InputText>;
  66234. /** BABYLON.Observable raised when the control loses the focus */
  66235. onBlurObservable: BABYLON.Observable<InputText>;
  66236. /**Observable raised when the text is highlighted */
  66237. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66238. /**Observable raised when copy event is triggered */
  66239. onTextCopyObservable: BABYLON.Observable<InputText>;
  66240. /** BABYLON.Observable raised when cut event is triggered */
  66241. onTextCutObservable: BABYLON.Observable<InputText>;
  66242. /** BABYLON.Observable raised when paste event is triggered */
  66243. onTextPasteObservable: BABYLON.Observable<InputText>;
  66244. /** BABYLON.Observable raised when a key event was processed */
  66245. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66246. /** Gets or sets the maximum width allowed by the control */
  66247. maxWidth: string | number;
  66248. /** Gets the maximum width allowed by the control in pixels */
  66249. readonly maxWidthInPixels: number;
  66250. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66251. highligherOpacity: number;
  66252. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66253. onFocusSelectAll: boolean;
  66254. /** Gets or sets the text hightlight color */
  66255. textHighlightColor: string;
  66256. /** Gets or sets control margin */
  66257. margin: string;
  66258. /** Gets control margin in pixels */
  66259. readonly marginInPixels: number;
  66260. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66261. autoStretchWidth: boolean;
  66262. /** Gets or sets border thickness */
  66263. thickness: number;
  66264. /** Gets or sets the background color when focused */
  66265. focusedBackground: string;
  66266. /** Gets or sets the background color when focused */
  66267. focusedColor: string;
  66268. /** Gets or sets the background color */
  66269. background: string;
  66270. /** Gets or sets the placeholder color */
  66271. placeholderColor: string;
  66272. /** Gets or sets the text displayed when the control is empty */
  66273. placeholderText: string;
  66274. /** Gets or sets the dead key flag */
  66275. deadKey: boolean;
  66276. /** Gets or sets the highlight text */
  66277. highlightedText: string;
  66278. /** Gets or sets if the current key should be added */
  66279. addKey: boolean;
  66280. /** Gets or sets the value of the current key being entered */
  66281. currentKey: string;
  66282. /** Gets or sets the text displayed in the control */
  66283. text: string;
  66284. /** Gets or sets control width */
  66285. width: string | number;
  66286. /**
  66287. * Creates a new InputText
  66288. * @param name defines the control name
  66289. * @param text defines the text of the control
  66290. */
  66291. constructor(name?: string | undefined, text?: string);
  66292. /** @hidden */
  66293. onBlur(): void;
  66294. /** @hidden */
  66295. onFocus(): void;
  66296. protected _getTypeName(): string;
  66297. /**
  66298. * Function called to get the list of controls that should not steal the focus from this control
  66299. * @returns an array of controls
  66300. */
  66301. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66302. /** @hidden */
  66303. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66304. /** @hidden */
  66305. private _updateValueFromCursorIndex;
  66306. /** @hidden */
  66307. private _processDblClick;
  66308. /** @hidden */
  66309. private _selectAllText;
  66310. /**
  66311. * Handles the keyboard event
  66312. * @param evt Defines the KeyboardEvent
  66313. */
  66314. processKeyboard(evt: KeyboardEvent): void;
  66315. /** @hidden */
  66316. private _onCopyText;
  66317. /** @hidden */
  66318. private _onCutText;
  66319. /** @hidden */
  66320. private _onPasteText;
  66321. _draw(context: CanvasRenderingContext2D): void;
  66322. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66324. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66325. protected _beforeRenderText(text: string): string;
  66326. dispose(): void;
  66327. }
  66328. }
  66329. declare module BABYLON.GUI {
  66330. /**
  66331. * Class used to create a 2D grid container
  66332. */
  66333. export class Grid extends Container {
  66334. name?: string | undefined;
  66335. private _rowDefinitions;
  66336. private _columnDefinitions;
  66337. private _cells;
  66338. private _childControls;
  66339. /**
  66340. * Gets the number of columns
  66341. */
  66342. readonly columnCount: number;
  66343. /**
  66344. * Gets the number of rows
  66345. */
  66346. readonly rowCount: number;
  66347. /** Gets the list of children */
  66348. readonly children: Control[];
  66349. /** Gets the list of cells (e.g. the containers) */
  66350. readonly cells: {
  66351. [key: string]: Container;
  66352. };
  66353. /**
  66354. * Gets the definition of a specific row
  66355. * @param index defines the index of the row
  66356. * @returns the row definition
  66357. */
  66358. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66359. /**
  66360. * Gets the definition of a specific column
  66361. * @param index defines the index of the column
  66362. * @returns the column definition
  66363. */
  66364. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66365. /**
  66366. * Adds a new row to the grid
  66367. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66368. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66369. * @returns the current grid
  66370. */
  66371. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66372. /**
  66373. * Adds a new column to the grid
  66374. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66375. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66376. * @returns the current grid
  66377. */
  66378. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66379. /**
  66380. * Update a row definition
  66381. * @param index defines the index of the row to update
  66382. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66383. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66384. * @returns the current grid
  66385. */
  66386. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66387. /**
  66388. * Update a column definition
  66389. * @param index defines the index of the column to update
  66390. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66391. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66392. * @returns the current grid
  66393. */
  66394. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66395. /**
  66396. * Gets the list of children stored in a specific cell
  66397. * @param row defines the row to check
  66398. * @param column defines the column to check
  66399. * @returns the list of controls
  66400. */
  66401. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66402. /**
  66403. * Gets a string representing the child cell info (row x column)
  66404. * @param child defines the control to get info from
  66405. * @returns a string containing the child cell info (row x column)
  66406. */
  66407. getChildCellInfo(child: Control): string;
  66408. private _removeCell;
  66409. private _offsetCell;
  66410. /**
  66411. * Remove a column definition at specified index
  66412. * @param index defines the index of the column to remove
  66413. * @returns the current grid
  66414. */
  66415. removeColumnDefinition(index: number): Grid;
  66416. /**
  66417. * Remove a row definition at specified index
  66418. * @param index defines the index of the row to remove
  66419. * @returns the current grid
  66420. */
  66421. removeRowDefinition(index: number): Grid;
  66422. /**
  66423. * Adds a new control to the current grid
  66424. * @param control defines the control to add
  66425. * @param row defines the row where to add the control (0 by default)
  66426. * @param column defines the column where to add the control (0 by default)
  66427. * @returns the current grid
  66428. */
  66429. addControl(control: Control, row?: number, column?: number): Grid;
  66430. /**
  66431. * Removes a control from the current container
  66432. * @param control defines the control to remove
  66433. * @returns the current container
  66434. */
  66435. removeControl(control: Control): Container;
  66436. /**
  66437. * Creates a new Grid
  66438. * @param name defines control name
  66439. */
  66440. constructor(name?: string | undefined);
  66441. protected _getTypeName(): string;
  66442. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66443. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66444. _flagDescendantsAsMatrixDirty(): void;
  66445. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66446. /** Releases associated resources */
  66447. dispose(): void;
  66448. }
  66449. }
  66450. declare module BABYLON.GUI {
  66451. /** Class used to create color pickers */
  66452. export class ColorPicker extends Control {
  66453. name?: string | undefined;
  66454. private static _Epsilon;
  66455. private _colorWheelCanvas;
  66456. private _value;
  66457. private _tmpColor;
  66458. private _pointerStartedOnSquare;
  66459. private _pointerStartedOnWheel;
  66460. private _squareLeft;
  66461. private _squareTop;
  66462. private _squareSize;
  66463. private _h;
  66464. private _s;
  66465. private _v;
  66466. private _lastPointerDownID;
  66467. /**
  66468. * BABYLON.Observable raised when the value changes
  66469. */
  66470. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66471. /** Gets or sets the color of the color picker */
  66472. value: BABYLON.Color3;
  66473. /**
  66474. * Gets or sets control width
  66475. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66476. */
  66477. width: string | number;
  66478. /**
  66479. * Gets or sets control height
  66480. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66481. */
  66482. /** Gets or sets control height */
  66483. height: string | number;
  66484. /** Gets or sets control size */
  66485. size: string | number;
  66486. /**
  66487. * Creates a new ColorPicker
  66488. * @param name defines the control name
  66489. */
  66490. constructor(name?: string | undefined);
  66491. protected _getTypeName(): string;
  66492. /** @hidden */
  66493. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66494. private _updateSquareProps;
  66495. private _drawGradientSquare;
  66496. private _drawCircle;
  66497. private _createColorWheelCanvas;
  66498. /** @hidden */
  66499. _draw(context: CanvasRenderingContext2D): void;
  66500. private _pointerIsDown;
  66501. private _updateValueFromPointer;
  66502. private _isPointOnSquare;
  66503. private _isPointOnWheel;
  66504. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66505. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66506. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66507. /**
  66508. * This function expands the color picker by creating a color picker dialog with manual
  66509. * color value input and the ability to save colors into an array to be used later in
  66510. * subsequent launches of the dialogue.
  66511. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66512. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  66513. * @returns picked color as a hex string and the saved colors array as hex strings.
  66514. */
  66515. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66516. pickerWidth?: string;
  66517. pickerHeight?: string;
  66518. headerHeight?: string;
  66519. lastColor?: string;
  66520. swatchLimit?: number;
  66521. numSwatchesPerLine?: number;
  66522. savedColors?: Array<string>;
  66523. }): Promise<{
  66524. savedColors?: string[];
  66525. pickedColor: string;
  66526. }>;
  66527. }
  66528. }
  66529. declare module BABYLON.GUI {
  66530. /** Class used to create 2D ellipse containers */
  66531. export class Ellipse extends Container {
  66532. name?: string | undefined;
  66533. private _thickness;
  66534. /** Gets or sets border thickness */
  66535. thickness: number;
  66536. /**
  66537. * Creates a new Ellipse
  66538. * @param name defines the control name
  66539. */
  66540. constructor(name?: string | undefined);
  66541. protected _getTypeName(): string;
  66542. protected _localDraw(context: CanvasRenderingContext2D): void;
  66543. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66544. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66545. }
  66546. }
  66547. declare module BABYLON.GUI {
  66548. /**
  66549. * Class used to create a password control
  66550. */
  66551. export class InputPassword extends InputText {
  66552. protected _beforeRenderText(text: string): string;
  66553. }
  66554. }
  66555. declare module BABYLON.GUI {
  66556. /** Class used to render 2D lines */
  66557. export class Line extends Control {
  66558. name?: string | undefined;
  66559. private _lineWidth;
  66560. private _x1;
  66561. private _y1;
  66562. private _x2;
  66563. private _y2;
  66564. private _dash;
  66565. private _connectedControl;
  66566. private _connectedControlDirtyObserver;
  66567. /** Gets or sets the dash pattern */
  66568. dash: Array<number>;
  66569. /** Gets or sets the control connected with the line end */
  66570. connectedControl: Control;
  66571. /** Gets or sets start coordinates on X axis */
  66572. x1: string | number;
  66573. /** Gets or sets start coordinates on Y axis */
  66574. y1: string | number;
  66575. /** Gets or sets end coordinates on X axis */
  66576. x2: string | number;
  66577. /** Gets or sets end coordinates on Y axis */
  66578. y2: string | number;
  66579. /** Gets or sets line width */
  66580. lineWidth: number;
  66581. /** Gets or sets horizontal alignment */
  66582. horizontalAlignment: number;
  66583. /** Gets or sets vertical alignment */
  66584. verticalAlignment: number;
  66585. private readonly _effectiveX2;
  66586. private readonly _effectiveY2;
  66587. /**
  66588. * Creates a new Line
  66589. * @param name defines the control name
  66590. */
  66591. constructor(name?: string | undefined);
  66592. protected _getTypeName(): string;
  66593. _draw(context: CanvasRenderingContext2D): void;
  66594. _measure(): void;
  66595. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66596. /**
  66597. * Move one end of the line given 3D cartesian coordinates.
  66598. * @param position Targeted world position
  66599. * @param scene BABYLON.Scene
  66600. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66601. */
  66602. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66603. /**
  66604. * Move one end of the line to a position in screen absolute space.
  66605. * @param projectedPosition Position in screen absolute space (X, Y)
  66606. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66607. */
  66608. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66609. }
  66610. }
  66611. declare module BABYLON.GUI {
  66612. /**
  66613. * Class used to store a point for a MultiLine object.
  66614. * The point can be pure 2D coordinates, a mesh or a control
  66615. */
  66616. export class MultiLinePoint {
  66617. private _multiLine;
  66618. private _x;
  66619. private _y;
  66620. private _control;
  66621. private _mesh;
  66622. private _controlObserver;
  66623. private _meshObserver;
  66624. /** @hidden */
  66625. _point: BABYLON.Vector2;
  66626. /**
  66627. * Creates a new MultiLinePoint
  66628. * @param multiLine defines the source MultiLine object
  66629. */
  66630. constructor(multiLine: MultiLine);
  66631. /** Gets or sets x coordinate */
  66632. x: string | number;
  66633. /** Gets or sets y coordinate */
  66634. y: string | number;
  66635. /** Gets or sets the control associated with this point */
  66636. control: BABYLON.Nullable<Control>;
  66637. /** Gets or sets the mesh associated with this point */
  66638. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66639. /** Resets links */
  66640. resetLinks(): void;
  66641. /**
  66642. * Gets a translation vector
  66643. * @returns the translation vector
  66644. */
  66645. translate(): BABYLON.Vector2;
  66646. private _translatePoint;
  66647. /** Release associated resources */
  66648. dispose(): void;
  66649. }
  66650. }
  66651. declare module BABYLON.GUI {
  66652. /**
  66653. * Class used to create multi line control
  66654. */
  66655. export class MultiLine extends Control {
  66656. name?: string | undefined;
  66657. private _lineWidth;
  66658. private _dash;
  66659. private _points;
  66660. private _minX;
  66661. private _minY;
  66662. private _maxX;
  66663. private _maxY;
  66664. /**
  66665. * Creates a new MultiLine
  66666. * @param name defines the control name
  66667. */
  66668. constructor(name?: string | undefined);
  66669. /** Gets or sets dash pattern */
  66670. dash: Array<number>;
  66671. /**
  66672. * Gets point stored at specified index
  66673. * @param index defines the index to look for
  66674. * @returns the requested point if found
  66675. */
  66676. getAt(index: number): MultiLinePoint;
  66677. /** Function called when a point is updated */
  66678. onPointUpdate: () => void;
  66679. /**
  66680. * Adds new points to the point collection
  66681. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66682. * @returns the list of created MultiLinePoint
  66683. */
  66684. add(...items: (AbstractMesh | Control | {
  66685. x: string | number;
  66686. y: string | number;
  66687. })[]): MultiLinePoint[];
  66688. /**
  66689. * Adds a new point to the point collection
  66690. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66691. * @returns the created MultiLinePoint
  66692. */
  66693. push(item?: (AbstractMesh | Control | {
  66694. x: string | number;
  66695. y: string | number;
  66696. })): MultiLinePoint;
  66697. /**
  66698. * Remove a specific value or point from the active point collection
  66699. * @param value defines the value or point to remove
  66700. */
  66701. remove(value: number | MultiLinePoint): void;
  66702. /**
  66703. * Resets this object to initial state (no point)
  66704. */
  66705. reset(): void;
  66706. /**
  66707. * Resets all links
  66708. */
  66709. resetLinks(): void;
  66710. /** Gets or sets line width */
  66711. lineWidth: number;
  66712. horizontalAlignment: number;
  66713. verticalAlignment: number;
  66714. protected _getTypeName(): string;
  66715. _draw(context: CanvasRenderingContext2D): void;
  66716. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66717. _measure(): void;
  66718. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66719. dispose(): void;
  66720. }
  66721. }
  66722. declare module BABYLON.GUI {
  66723. /**
  66724. * Class used to create radio button controls
  66725. */
  66726. export class RadioButton extends Control {
  66727. name?: string | undefined;
  66728. private _isChecked;
  66729. private _background;
  66730. private _checkSizeRatio;
  66731. private _thickness;
  66732. /** Gets or sets border thickness */
  66733. thickness: number;
  66734. /** Gets or sets group name */
  66735. group: string;
  66736. /** BABYLON.Observable raised when isChecked is changed */
  66737. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66738. /** Gets or sets a value indicating the ratio between overall size and check size */
  66739. checkSizeRatio: number;
  66740. /** Gets or sets background color */
  66741. background: string;
  66742. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66743. isChecked: boolean;
  66744. /**
  66745. * Creates a new RadioButton
  66746. * @param name defines the control name
  66747. */
  66748. constructor(name?: string | undefined);
  66749. protected _getTypeName(): string;
  66750. _draw(context: CanvasRenderingContext2D): void;
  66751. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66752. /**
  66753. * Utility function to easily create a radio button with a header
  66754. * @param title defines the label to use for the header
  66755. * @param group defines the group to use for the radio button
  66756. * @param isChecked defines the initial state of the radio button
  66757. * @param onValueChanged defines the callback to call when value changes
  66758. * @returns a StackPanel containing the radio button and a textBlock
  66759. */
  66760. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66761. }
  66762. }
  66763. declare module BABYLON.GUI {
  66764. /**
  66765. * Class used to create slider controls
  66766. */
  66767. export class BaseSlider extends Control {
  66768. name?: string | undefined;
  66769. protected _thumbWidth: ValueAndUnit;
  66770. private _minimum;
  66771. private _maximum;
  66772. private _value;
  66773. private _isVertical;
  66774. protected _barOffset: ValueAndUnit;
  66775. private _isThumbClamped;
  66776. protected _displayThumb: boolean;
  66777. private _step;
  66778. private _lastPointerDownID;
  66779. protected _effectiveBarOffset: number;
  66780. protected _renderLeft: number;
  66781. protected _renderTop: number;
  66782. protected _renderWidth: number;
  66783. protected _renderHeight: number;
  66784. protected _backgroundBoxLength: number;
  66785. protected _backgroundBoxThickness: number;
  66786. protected _effectiveThumbThickness: number;
  66787. /** BABYLON.Observable raised when the sldier value changes */
  66788. onValueChangedObservable: BABYLON.Observable<number>;
  66789. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66790. displayThumb: boolean;
  66791. /** Gets or sets a step to apply to values (0 by default) */
  66792. step: number;
  66793. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66794. barOffset: string | number;
  66795. /** Gets main bar offset in pixels*/
  66796. readonly barOffsetInPixels: number;
  66797. /** Gets or sets thumb width */
  66798. thumbWidth: string | number;
  66799. /** Gets thumb width in pixels */
  66800. readonly thumbWidthInPixels: number;
  66801. /** Gets or sets minimum value */
  66802. minimum: number;
  66803. /** Gets or sets maximum value */
  66804. maximum: number;
  66805. /** Gets or sets current value */
  66806. value: number;
  66807. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66808. isVertical: boolean;
  66809. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66810. isThumbClamped: boolean;
  66811. /**
  66812. * Creates a new BaseSlider
  66813. * @param name defines the control name
  66814. */
  66815. constructor(name?: string | undefined);
  66816. protected _getTypeName(): string;
  66817. protected _getThumbPosition(): number;
  66818. protected _getThumbThickness(type: string): number;
  66819. protected _prepareRenderingData(type: string): void;
  66820. private _pointerIsDown;
  66821. /** @hidden */
  66822. protected _updateValueFromPointer(x: number, y: number): void;
  66823. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66824. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66825. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66826. }
  66827. }
  66828. declare module BABYLON.GUI {
  66829. /**
  66830. * Class used to create slider controls
  66831. */
  66832. export class Slider extends BaseSlider {
  66833. name?: string | undefined;
  66834. private _background;
  66835. private _borderColor;
  66836. private _isThumbCircle;
  66837. protected _displayValueBar: boolean;
  66838. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66839. displayValueBar: boolean;
  66840. /** Gets or sets border color */
  66841. borderColor: string;
  66842. /** Gets or sets background color */
  66843. background: string;
  66844. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66845. isThumbCircle: boolean;
  66846. /**
  66847. * Creates a new Slider
  66848. * @param name defines the control name
  66849. */
  66850. constructor(name?: string | undefined);
  66851. protected _getTypeName(): string;
  66852. _draw(context: CanvasRenderingContext2D): void;
  66853. }
  66854. }
  66855. declare module BABYLON.GUI {
  66856. /** Class used to create a RadioGroup
  66857. * which contains groups of radio buttons
  66858. */
  66859. export class SelectorGroup {
  66860. /** name of SelectorGroup */
  66861. name: string;
  66862. private _groupPanel;
  66863. private _selectors;
  66864. private _groupHeader;
  66865. /**
  66866. * Creates a new SelectorGroup
  66867. * @param name of group, used as a group heading
  66868. */
  66869. constructor(
  66870. /** name of SelectorGroup */
  66871. name: string);
  66872. /** Gets the groupPanel of the SelectorGroup */
  66873. readonly groupPanel: StackPanel;
  66874. /** Gets the selectors array */
  66875. readonly selectors: StackPanel[];
  66876. /** Gets and sets the group header */
  66877. header: string;
  66878. /** @hidden */
  66879. private _addGroupHeader;
  66880. /** @hidden*/
  66881. _getSelector(selectorNb: number): StackPanel | undefined;
  66882. /** Removes the selector at the given position
  66883. * @param selectorNb the position of the selector within the group
  66884. */
  66885. removeSelector(selectorNb: number): void;
  66886. }
  66887. /** Class used to create a CheckboxGroup
  66888. * which contains groups of checkbox buttons
  66889. */
  66890. export class CheckboxGroup extends SelectorGroup {
  66891. /** Adds a checkbox as a control
  66892. * @param text is the label for the selector
  66893. * @param func is the function called when the Selector is checked
  66894. * @param checked is true when Selector is checked
  66895. */
  66896. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66897. /** @hidden */
  66898. _setSelectorLabel(selectorNb: number, label: string): void;
  66899. /** @hidden */
  66900. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66901. /** @hidden */
  66902. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66903. /** @hidden */
  66904. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66905. }
  66906. /** Class used to create a RadioGroup
  66907. * which contains groups of radio buttons
  66908. */
  66909. export class RadioGroup extends SelectorGroup {
  66910. private _selectNb;
  66911. /** Adds a radio button as a control
  66912. * @param label is the label for the selector
  66913. * @param func is the function called when the Selector is checked
  66914. * @param checked is true when Selector is checked
  66915. */
  66916. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66917. /** @hidden */
  66918. _setSelectorLabel(selectorNb: number, label: string): void;
  66919. /** @hidden */
  66920. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66921. /** @hidden */
  66922. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66923. /** @hidden */
  66924. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66925. }
  66926. /** Class used to create a SliderGroup
  66927. * which contains groups of slider buttons
  66928. */
  66929. export class SliderGroup extends SelectorGroup {
  66930. /**
  66931. * Adds a slider to the SelectorGroup
  66932. * @param label is the label for the SliderBar
  66933. * @param func is the function called when the Slider moves
  66934. * @param unit is a string describing the units used, eg degrees or metres
  66935. * @param min is the minimum value for the Slider
  66936. * @param max is the maximum value for the Slider
  66937. * @param value is the start value for the Slider between min and max
  66938. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66939. */
  66940. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66941. /** @hidden */
  66942. _setSelectorLabel(selectorNb: number, label: string): void;
  66943. /** @hidden */
  66944. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66945. /** @hidden */
  66946. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66947. /** @hidden */
  66948. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66949. }
  66950. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66951. * @see http://doc.babylonjs.com/how_to/selector
  66952. */
  66953. export class SelectionPanel extends Rectangle {
  66954. /** name of SelectionPanel */
  66955. name: string;
  66956. /** an array of SelectionGroups */
  66957. groups: SelectorGroup[];
  66958. private _panel;
  66959. private _buttonColor;
  66960. private _buttonBackground;
  66961. private _headerColor;
  66962. private _barColor;
  66963. private _barHeight;
  66964. private _spacerHeight;
  66965. private _labelColor;
  66966. private _groups;
  66967. private _bars;
  66968. /**
  66969. * Creates a new SelectionPanel
  66970. * @param name of SelectionPanel
  66971. * @param groups is an array of SelectionGroups
  66972. */
  66973. constructor(
  66974. /** name of SelectionPanel */
  66975. name: string,
  66976. /** an array of SelectionGroups */
  66977. groups?: SelectorGroup[]);
  66978. protected _getTypeName(): string;
  66979. /** Gets or sets the headerColor */
  66980. headerColor: string;
  66981. private _setHeaderColor;
  66982. /** Gets or sets the button color */
  66983. buttonColor: string;
  66984. private _setbuttonColor;
  66985. /** Gets or sets the label color */
  66986. labelColor: string;
  66987. private _setLabelColor;
  66988. /** Gets or sets the button background */
  66989. buttonBackground: string;
  66990. private _setButtonBackground;
  66991. /** Gets or sets the color of separator bar */
  66992. barColor: string;
  66993. private _setBarColor;
  66994. /** Gets or sets the height of separator bar */
  66995. barHeight: string;
  66996. private _setBarHeight;
  66997. /** Gets or sets the height of spacers*/
  66998. spacerHeight: string;
  66999. private _setSpacerHeight;
  67000. /** Adds a bar between groups */
  67001. private _addSpacer;
  67002. /** Add a group to the selection panel
  67003. * @param group is the selector group to add
  67004. */
  67005. addGroup(group: SelectorGroup): void;
  67006. /** Remove the group from the given position
  67007. * @param groupNb is the position of the group in the list
  67008. */
  67009. removeGroup(groupNb: number): void;
  67010. /** Change a group header label
  67011. * @param label is the new group header label
  67012. * @param groupNb is the number of the group to relabel
  67013. * */
  67014. setHeaderName(label: string, groupNb: number): void;
  67015. /** Change selector label to the one given
  67016. * @param label is the new selector label
  67017. * @param groupNb is the number of the groupcontaining the selector
  67018. * @param selectorNb is the number of the selector within a group to relabel
  67019. * */
  67020. relabel(label: string, groupNb: number, selectorNb: number): void;
  67021. /** For a given group position remove the selector at the given position
  67022. * @param groupNb is the number of the group to remove the selector from
  67023. * @param selectorNb is the number of the selector within the group
  67024. */
  67025. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67026. /** For a given group position of correct type add a checkbox button
  67027. * @param groupNb is the number of the group to remove the selector from
  67028. * @param label is the label for the selector
  67029. * @param func is the function called when the Selector is checked
  67030. * @param checked is true when Selector is checked
  67031. */
  67032. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67033. /** For a given group position of correct type add a radio button
  67034. * @param groupNb is the number of the group to remove the selector from
  67035. * @param label is the label for the selector
  67036. * @param func is the function called when the Selector is checked
  67037. * @param checked is true when Selector is checked
  67038. */
  67039. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67040. /**
  67041. * For a given slider group add a slider
  67042. * @param groupNb is the number of the group to add the slider to
  67043. * @param label is the label for the Slider
  67044. * @param func is the function called when the Slider moves
  67045. * @param unit is a string describing the units used, eg degrees or metres
  67046. * @param min is the minimum value for the Slider
  67047. * @param max is the maximum value for the Slider
  67048. * @param value is the start value for the Slider between min and max
  67049. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67050. */
  67051. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67052. }
  67053. }
  67054. declare module BABYLON.GUI {
  67055. /**
  67056. * Class used to hold a the container for ScrollViewer
  67057. * @hidden
  67058. */
  67059. export class _ScrollViewerWindow extends Container {
  67060. parentClientWidth: number;
  67061. parentClientHeight: number;
  67062. /**
  67063. * Creates a new ScrollViewerWindow
  67064. * @param name of ScrollViewerWindow
  67065. */
  67066. constructor(name?: string);
  67067. protected _getTypeName(): string;
  67068. /** @hidden */
  67069. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67070. protected _postMeasure(): void;
  67071. }
  67072. }
  67073. declare module BABYLON.GUI {
  67074. /**
  67075. * Class used to create slider controls
  67076. */
  67077. export class ScrollBar extends BaseSlider {
  67078. name?: string | undefined;
  67079. private _background;
  67080. private _borderColor;
  67081. private _thumbMeasure;
  67082. /** Gets or sets border color */
  67083. borderColor: string;
  67084. /** Gets or sets background color */
  67085. background: string;
  67086. /**
  67087. * Creates a new Slider
  67088. * @param name defines the control name
  67089. */
  67090. constructor(name?: string | undefined);
  67091. protected _getTypeName(): string;
  67092. protected _getThumbThickness(): number;
  67093. _draw(context: CanvasRenderingContext2D): void;
  67094. private _first;
  67095. private _originX;
  67096. private _originY;
  67097. /** @hidden */
  67098. protected _updateValueFromPointer(x: number, y: number): void;
  67099. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67100. }
  67101. }
  67102. declare module BABYLON.GUI {
  67103. /**
  67104. * Class used to hold a viewer window and sliders in a grid
  67105. */
  67106. export class ScrollViewer extends Rectangle {
  67107. private _grid;
  67108. private _horizontalBarSpace;
  67109. private _verticalBarSpace;
  67110. private _dragSpace;
  67111. private _horizontalBar;
  67112. private _verticalBar;
  67113. private _barColor;
  67114. private _barBackground;
  67115. private _barSize;
  67116. private _endLeft;
  67117. private _endTop;
  67118. private _window;
  67119. private _pointerIsOver;
  67120. private _wheelPrecision;
  67121. private _onPointerObserver;
  67122. private _clientWidth;
  67123. private _clientHeight;
  67124. /**
  67125. * Gets the horizontal scrollbar
  67126. */
  67127. readonly horizontalBar: ScrollBar;
  67128. /**
  67129. * Gets the vertical scrollbar
  67130. */
  67131. readonly verticalBar: ScrollBar;
  67132. /**
  67133. * Adds a new control to the current container
  67134. * @param control defines the control to add
  67135. * @returns the current container
  67136. */
  67137. addControl(control: BABYLON.Nullable<Control>): Container;
  67138. /**
  67139. * Removes a control from the current container
  67140. * @param control defines the control to remove
  67141. * @returns the current container
  67142. */
  67143. removeControl(control: Control): Container;
  67144. /** Gets the list of children */
  67145. readonly children: Control[];
  67146. _flagDescendantsAsMatrixDirty(): void;
  67147. /**
  67148. * Creates a new ScrollViewer
  67149. * @param name of ScrollViewer
  67150. */
  67151. constructor(name?: string);
  67152. /** Reset the scroll viewer window to initial size */
  67153. resetWindow(): void;
  67154. protected _getTypeName(): string;
  67155. private _buildClientSizes;
  67156. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67157. protected _postMeasure(): void;
  67158. /**
  67159. * Gets or sets the mouse wheel precision
  67160. * from 0 to 1 with a default value of 0.05
  67161. * */
  67162. wheelPrecision: number;
  67163. /** Gets or sets the bar color */
  67164. barColor: string;
  67165. /** Gets or sets the size of the bar */
  67166. barSize: number;
  67167. /** Gets or sets the bar background */
  67168. barBackground: string;
  67169. /** @hidden */
  67170. private _updateScroller;
  67171. _link(host: AdvancedDynamicTexture): void;
  67172. /** @hidden */
  67173. private _attachWheel;
  67174. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67175. /** Releases associated resources */
  67176. dispose(): void;
  67177. }
  67178. }
  67179. declare module BABYLON.GUI {
  67180. /** Class used to render a grid */
  67181. export class DisplayGrid extends Control {
  67182. name?: string | undefined;
  67183. private _cellWidth;
  67184. private _cellHeight;
  67185. private _minorLineTickness;
  67186. private _minorLineColor;
  67187. private _majorLineTickness;
  67188. private _majorLineColor;
  67189. private _majorLineFrequency;
  67190. private _background;
  67191. private _displayMajorLines;
  67192. private _displayMinorLines;
  67193. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67194. displayMinorLines: boolean;
  67195. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67196. displayMajorLines: boolean;
  67197. /** Gets or sets background color (Black by default) */
  67198. background: string;
  67199. /** Gets or sets the width of each cell (20 by default) */
  67200. cellWidth: number;
  67201. /** Gets or sets the height of each cell (20 by default) */
  67202. cellHeight: number;
  67203. /** Gets or sets the tickness of minor lines (1 by default) */
  67204. minorLineTickness: number;
  67205. /** Gets or sets the color of minor lines (DarkGray by default) */
  67206. minorLineColor: string;
  67207. /** Gets or sets the tickness of major lines (2 by default) */
  67208. majorLineTickness: number;
  67209. /** Gets or sets the color of major lines (White by default) */
  67210. majorLineColor: string;
  67211. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67212. majorLineFrequency: number;
  67213. /**
  67214. * Creates a new GridDisplayRectangle
  67215. * @param name defines the control name
  67216. */
  67217. constructor(name?: string | undefined);
  67218. _draw(context: CanvasRenderingContext2D): void;
  67219. protected _getTypeName(): string;
  67220. }
  67221. }
  67222. declare module BABYLON.GUI {
  67223. /**
  67224. * Class used to create slider controls based on images
  67225. */
  67226. export class ImageBasedSlider extends BaseSlider {
  67227. name?: string | undefined;
  67228. private _backgroundImage;
  67229. private _thumbImage;
  67230. private _valueBarImage;
  67231. private _tempMeasure;
  67232. displayThumb: boolean;
  67233. /**
  67234. * Gets or sets the image used to render the background
  67235. */
  67236. backgroundImage: Image;
  67237. /**
  67238. * Gets or sets the image used to render the value bar
  67239. */
  67240. valueBarImage: Image;
  67241. /**
  67242. * Gets or sets the image used to render the thumb
  67243. */
  67244. thumbImage: Image;
  67245. /**
  67246. * Creates a new ImageBasedSlider
  67247. * @param name defines the control name
  67248. */
  67249. constructor(name?: string | undefined);
  67250. protected _getTypeName(): string;
  67251. _draw(context: CanvasRenderingContext2D): void;
  67252. }
  67253. }
  67254. declare module BABYLON.GUI {
  67255. /**
  67256. * Forcing an export so that this code will execute
  67257. * @hidden
  67258. */
  67259. const name = "Statics";
  67260. }
  67261. declare module BABYLON.GUI {
  67262. /**
  67263. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67264. */
  67265. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67266. /**
  67267. * Define the instrumented AdvancedDynamicTexture.
  67268. */
  67269. texture: AdvancedDynamicTexture;
  67270. private _captureRenderTime;
  67271. private _renderTime;
  67272. private _captureLayoutTime;
  67273. private _layoutTime;
  67274. private _onBeginRenderObserver;
  67275. private _onEndRenderObserver;
  67276. private _onBeginLayoutObserver;
  67277. private _onEndLayoutObserver;
  67278. /**
  67279. * Gets the perf counter used to capture render time
  67280. */
  67281. readonly renderTimeCounter: BABYLON.PerfCounter;
  67282. /**
  67283. * Gets the perf counter used to capture layout time
  67284. */
  67285. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67286. /**
  67287. * Enable or disable the render time capture
  67288. */
  67289. captureRenderTime: boolean;
  67290. /**
  67291. * Enable or disable the layout time capture
  67292. */
  67293. captureLayoutTime: boolean;
  67294. /**
  67295. * Instantiates a new advanced dynamic texture instrumentation.
  67296. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67297. * @param texture Defines the AdvancedDynamicTexture to instrument
  67298. */
  67299. constructor(
  67300. /**
  67301. * Define the instrumented AdvancedDynamicTexture.
  67302. */
  67303. texture: AdvancedDynamicTexture);
  67304. /**
  67305. * Dispose and release associated resources.
  67306. */
  67307. dispose(): void;
  67308. }
  67309. }
  67310. declare module BABYLON.GUI {
  67311. /**
  67312. * Class used to load GUI via XML.
  67313. */
  67314. export class XmlLoader {
  67315. private _nodes;
  67316. private _nodeTypes;
  67317. private _isLoaded;
  67318. private _objectAttributes;
  67319. private _parentClass;
  67320. /**
  67321. * Create a new xml loader
  67322. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67323. */
  67324. constructor(parentClass?: null);
  67325. private _getChainElement;
  67326. private _getClassAttribute;
  67327. private _createGuiElement;
  67328. private _parseGrid;
  67329. private _parseElement;
  67330. private _prepareSourceElement;
  67331. private _parseElementsFromSource;
  67332. private _parseXml;
  67333. /**
  67334. * Gets if the loading has finished.
  67335. * @returns whether the loading has finished or not
  67336. */
  67337. isLoaded(): boolean;
  67338. /**
  67339. * Gets a loaded node / control by id.
  67340. * @param id the Controls id set in the xml
  67341. * @returns element of type Control
  67342. */
  67343. getNodeById(id: string): any;
  67344. /**
  67345. * Gets all loaded nodes / controls
  67346. * @returns Array of controls
  67347. */
  67348. getNodes(): any;
  67349. /**
  67350. * Initiates the xml layout loading
  67351. * @param xmlFile defines the xml layout to load
  67352. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67353. * @param callback defines the callback called on layout load.
  67354. */
  67355. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67356. }
  67357. }
  67358. declare module BABYLON.GUI {
  67359. /**
  67360. * Class used to create containers for controls
  67361. */
  67362. export class Container3D extends Control3D {
  67363. private _blockLayout;
  67364. /**
  67365. * Gets the list of child controls
  67366. */
  67367. protected _children: Control3D[];
  67368. /**
  67369. * Gets the list of child controls
  67370. */
  67371. readonly children: Array<Control3D>;
  67372. /**
  67373. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67374. * This is helpful to optimize layout operation when adding multiple children in a row
  67375. */
  67376. blockLayout: boolean;
  67377. /**
  67378. * Creates a new container
  67379. * @param name defines the container name
  67380. */
  67381. constructor(name?: string);
  67382. /**
  67383. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67384. * @returns the current container
  67385. */
  67386. updateLayout(): Container3D;
  67387. /**
  67388. * Gets a boolean indicating if the given control is in the children of this control
  67389. * @param control defines the control to check
  67390. * @returns true if the control is in the child list
  67391. */
  67392. containsControl(control: Control3D): boolean;
  67393. /**
  67394. * Adds a control to the children of this control
  67395. * @param control defines the control to add
  67396. * @returns the current container
  67397. */
  67398. addControl(control: Control3D): Container3D;
  67399. /**
  67400. * This function will be called everytime a new control is added
  67401. */
  67402. protected _arrangeChildren(): void;
  67403. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67404. /**
  67405. * Removes a control from the children of this control
  67406. * @param control defines the control to remove
  67407. * @returns the current container
  67408. */
  67409. removeControl(control: Control3D): Container3D;
  67410. protected _getTypeName(): string;
  67411. /**
  67412. * Releases all associated resources
  67413. */
  67414. dispose(): void;
  67415. /** Control rotation will remain unchanged */
  67416. static readonly UNSET_ORIENTATION: number;
  67417. /** Control will rotate to make it look at sphere central axis */
  67418. static readonly FACEORIGIN_ORIENTATION: number;
  67419. /** Control will rotate to make it look back at sphere central axis */
  67420. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67421. /** Control will rotate to look at z axis (0, 0, 1) */
  67422. static readonly FACEFORWARD_ORIENTATION: number;
  67423. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67424. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67425. }
  67426. }
  67427. declare module BABYLON.GUI {
  67428. /**
  67429. * Class used to manage 3D user interface
  67430. * @see http://doc.babylonjs.com/how_to/gui3d
  67431. */
  67432. export class GUI3DManager implements BABYLON.IDisposable {
  67433. private _scene;
  67434. private _sceneDisposeObserver;
  67435. private _utilityLayer;
  67436. private _rootContainer;
  67437. private _pointerObserver;
  67438. private _pointerOutObserver;
  67439. /** @hidden */
  67440. _lastPickedControl: Control3D;
  67441. /** @hidden */
  67442. _lastControlOver: {
  67443. [pointerId: number]: Control3D;
  67444. };
  67445. /** @hidden */
  67446. _lastControlDown: {
  67447. [pointerId: number]: Control3D;
  67448. };
  67449. /**
  67450. * BABYLON.Observable raised when the point picked by the pointer events changed
  67451. */
  67452. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67453. /** @hidden */
  67454. _sharedMaterials: {
  67455. [key: string]: BABYLON.Material;
  67456. };
  67457. /** Gets the hosting scene */
  67458. readonly scene: BABYLON.Scene;
  67459. /** Gets associated utility layer */
  67460. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67461. /**
  67462. * Creates a new GUI3DManager
  67463. * @param scene
  67464. */
  67465. constructor(scene?: BABYLON.Scene);
  67466. private _handlePointerOut;
  67467. private _doPicking;
  67468. /**
  67469. * Gets the root container
  67470. */
  67471. readonly rootContainer: Container3D;
  67472. /**
  67473. * Gets a boolean indicating if the given control is in the root child list
  67474. * @param control defines the control to check
  67475. * @returns true if the control is in the root child list
  67476. */
  67477. containsControl(control: Control3D): boolean;
  67478. /**
  67479. * Adds a control to the root child list
  67480. * @param control defines the control to add
  67481. * @returns the current manager
  67482. */
  67483. addControl(control: Control3D): GUI3DManager;
  67484. /**
  67485. * Removes a control from the root child list
  67486. * @param control defines the control to remove
  67487. * @returns the current container
  67488. */
  67489. removeControl(control: Control3D): GUI3DManager;
  67490. /**
  67491. * Releases all associated resources
  67492. */
  67493. dispose(): void;
  67494. }
  67495. }
  67496. declare module BABYLON.GUI {
  67497. /**
  67498. * Class used to transport BABYLON.Vector3 information for pointer events
  67499. */
  67500. export class Vector3WithInfo extends BABYLON.Vector3 {
  67501. /** defines the current mouse button index */
  67502. buttonIndex: number;
  67503. /**
  67504. * Creates a new Vector3WithInfo
  67505. * @param source defines the vector3 data to transport
  67506. * @param buttonIndex defines the current mouse button index
  67507. */
  67508. constructor(source: BABYLON.Vector3,
  67509. /** defines the current mouse button index */
  67510. buttonIndex?: number);
  67511. }
  67512. }
  67513. declare module BABYLON.GUI {
  67514. /**
  67515. * Class used as base class for controls
  67516. */
  67517. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67518. /** Defines the control name */
  67519. name?: string | undefined;
  67520. /** @hidden */
  67521. _host: GUI3DManager;
  67522. private _node;
  67523. private _downCount;
  67524. private _enterCount;
  67525. private _downPointerIds;
  67526. private _isVisible;
  67527. /** Gets or sets the control position in world space */
  67528. position: BABYLON.Vector3;
  67529. /** Gets or sets the control scaling in world space */
  67530. scaling: BABYLON.Vector3;
  67531. /** Callback used to start pointer enter animation */
  67532. pointerEnterAnimation: () => void;
  67533. /** Callback used to start pointer out animation */
  67534. pointerOutAnimation: () => void;
  67535. /** Callback used to start pointer down animation */
  67536. pointerDownAnimation: () => void;
  67537. /** Callback used to start pointer up animation */
  67538. pointerUpAnimation: () => void;
  67539. /**
  67540. * An event triggered when the pointer move over the control
  67541. */
  67542. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67543. /**
  67544. * An event triggered when the pointer move out of the control
  67545. */
  67546. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67547. /**
  67548. * An event triggered when the pointer taps the control
  67549. */
  67550. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67551. /**
  67552. * An event triggered when pointer is up
  67553. */
  67554. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67555. /**
  67556. * An event triggered when a control is clicked on (with a mouse)
  67557. */
  67558. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67559. /**
  67560. * An event triggered when pointer enters the control
  67561. */
  67562. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67563. /**
  67564. * Gets or sets the parent container
  67565. */
  67566. parent: BABYLON.Nullable<Container3D>;
  67567. private _behaviors;
  67568. /**
  67569. * Gets the list of attached behaviors
  67570. * @see http://doc.babylonjs.com/features/behaviour
  67571. */
  67572. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67573. /**
  67574. * Attach a behavior to the control
  67575. * @see http://doc.babylonjs.com/features/behaviour
  67576. * @param behavior defines the behavior to attach
  67577. * @returns the current control
  67578. */
  67579. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67580. /**
  67581. * Remove an attached behavior
  67582. * @see http://doc.babylonjs.com/features/behaviour
  67583. * @param behavior defines the behavior to attach
  67584. * @returns the current control
  67585. */
  67586. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67587. /**
  67588. * Gets an attached behavior by name
  67589. * @param name defines the name of the behavior to look for
  67590. * @see http://doc.babylonjs.com/features/behaviour
  67591. * @returns null if behavior was not found else the requested behavior
  67592. */
  67593. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67594. /** Gets or sets a boolean indicating if the control is visible */
  67595. isVisible: boolean;
  67596. /**
  67597. * Creates a new control
  67598. * @param name defines the control name
  67599. */
  67600. constructor(
  67601. /** Defines the control name */
  67602. name?: string | undefined);
  67603. /**
  67604. * Gets a string representing the class name
  67605. */
  67606. readonly typeName: string;
  67607. /**
  67608. * Get the current class name of the control.
  67609. * @returns current class name
  67610. */
  67611. getClassName(): string;
  67612. protected _getTypeName(): string;
  67613. /**
  67614. * Gets the transform node used by this control
  67615. */
  67616. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67617. /**
  67618. * Gets the mesh used to render this control
  67619. */
  67620. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67621. /**
  67622. * Link the control as child of the given node
  67623. * @param node defines the node to link to. Use null to unlink the control
  67624. * @returns the current control
  67625. */
  67626. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67627. /** @hidden **/
  67628. _prepareNode(scene: BABYLON.Scene): void;
  67629. /**
  67630. * Node creation.
  67631. * Can be overriden by children
  67632. * @param scene defines the scene where the node must be attached
  67633. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67634. */
  67635. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67636. /**
  67637. * Affect a material to the given mesh
  67638. * @param mesh defines the mesh which will represent the control
  67639. */
  67640. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67641. /** @hidden */
  67642. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67643. /** @hidden */
  67644. _onPointerEnter(target: Control3D): boolean;
  67645. /** @hidden */
  67646. _onPointerOut(target: Control3D): void;
  67647. /** @hidden */
  67648. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67649. /** @hidden */
  67650. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67651. /** @hidden */
  67652. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67653. /** @hidden */
  67654. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67655. /** @hidden */
  67656. _disposeNode(): void;
  67657. /**
  67658. * Releases all associated resources
  67659. */
  67660. dispose(): void;
  67661. }
  67662. }
  67663. declare module BABYLON.GUI {
  67664. /**
  67665. * Class used as a root to all buttons
  67666. */
  67667. export class AbstractButton3D extends Control3D {
  67668. /**
  67669. * Creates a new button
  67670. * @param name defines the control name
  67671. */
  67672. constructor(name?: string);
  67673. protected _getTypeName(): string;
  67674. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67675. }
  67676. }
  67677. declare module BABYLON.GUI {
  67678. /**
  67679. * Class used to create a button in 3D
  67680. */
  67681. export class Button3D extends AbstractButton3D {
  67682. /** @hidden */
  67683. protected _currentMaterial: BABYLON.Material;
  67684. private _facadeTexture;
  67685. private _content;
  67686. private _contentResolution;
  67687. private _contentScaleRatio;
  67688. /**
  67689. * Gets or sets the texture resolution used to render content (512 by default)
  67690. */
  67691. contentResolution: BABYLON.int;
  67692. /**
  67693. * Gets or sets the texture scale ratio used to render content (2 by default)
  67694. */
  67695. contentScaleRatio: number;
  67696. protected _disposeFacadeTexture(): void;
  67697. protected _resetContent(): void;
  67698. /**
  67699. * Creates a new button
  67700. * @param name defines the control name
  67701. */
  67702. constructor(name?: string);
  67703. /**
  67704. * Gets or sets the GUI 2D content used to display the button's facade
  67705. */
  67706. content: Control;
  67707. /**
  67708. * Apply the facade texture (created from the content property).
  67709. * This function can be overloaded by child classes
  67710. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67711. */
  67712. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67713. protected _getTypeName(): string;
  67714. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67715. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67716. /**
  67717. * Releases all associated resources
  67718. */
  67719. dispose(): void;
  67720. }
  67721. }
  67722. declare module BABYLON.GUI {
  67723. /**
  67724. * Abstract class used to create a container panel deployed on the surface of a volume
  67725. */
  67726. export abstract class VolumeBasedPanel extends Container3D {
  67727. private _columns;
  67728. private _rows;
  67729. private _rowThenColum;
  67730. private _orientation;
  67731. protected _cellWidth: number;
  67732. protected _cellHeight: number;
  67733. /**
  67734. * Gets or sets the distance between elements
  67735. */
  67736. margin: number;
  67737. /**
  67738. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67739. * | Value | Type | Description |
  67740. * | ----- | ----------------------------------- | ----------- |
  67741. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67742. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67743. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67744. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67745. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67746. */
  67747. orientation: number;
  67748. /**
  67749. * Gets or sets the number of columns requested (10 by default).
  67750. * The panel will automatically compute the number of rows based on number of child controls.
  67751. */
  67752. columns: BABYLON.int;
  67753. /**
  67754. * Gets or sets a the number of rows requested.
  67755. * The panel will automatically compute the number of columns based on number of child controls.
  67756. */
  67757. rows: BABYLON.int;
  67758. /**
  67759. * Creates new VolumeBasedPanel
  67760. */
  67761. constructor();
  67762. protected _arrangeChildren(): void;
  67763. /** Child classes must implement this function to provide correct control positioning */
  67764. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67765. /** Child classes can implement this function to provide additional processing */
  67766. protected _finalProcessing(): void;
  67767. }
  67768. }
  67769. declare module BABYLON.GUI {
  67770. /**
  67771. * Class used to create a container panel deployed on the surface of a cylinder
  67772. */
  67773. export class CylinderPanel extends VolumeBasedPanel {
  67774. private _radius;
  67775. /**
  67776. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67777. */
  67778. radius: BABYLON.float;
  67779. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67780. private _cylindricalMapping;
  67781. }
  67782. }
  67783. declare module BABYLON.GUI {
  67784. /** @hidden */
  67785. export var fluentVertexShader: {
  67786. name: string;
  67787. shader: string;
  67788. };
  67789. }
  67790. declare module BABYLON.GUI {
  67791. /** @hidden */
  67792. export var fluentPixelShader: {
  67793. name: string;
  67794. shader: string;
  67795. };
  67796. }
  67797. declare module BABYLON.GUI {
  67798. /** @hidden */
  67799. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67800. INNERGLOW: boolean;
  67801. BORDER: boolean;
  67802. HOVERLIGHT: boolean;
  67803. TEXTURE: boolean;
  67804. constructor();
  67805. }
  67806. /**
  67807. * Class used to render controls with fluent desgin
  67808. */
  67809. export class FluentMaterial extends BABYLON.PushMaterial {
  67810. /**
  67811. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67812. */
  67813. innerGlowColorIntensity: number;
  67814. /**
  67815. * Gets or sets the inner glow color (white by default)
  67816. */
  67817. innerGlowColor: BABYLON.Color3;
  67818. /**
  67819. * Gets or sets alpha value (default is 1.0)
  67820. */
  67821. alpha: number;
  67822. /**
  67823. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67824. */
  67825. albedoColor: BABYLON.Color3;
  67826. /**
  67827. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67828. */
  67829. renderBorders: boolean;
  67830. /**
  67831. * Gets or sets border width (default is 0.5)
  67832. */
  67833. borderWidth: number;
  67834. /**
  67835. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67836. */
  67837. edgeSmoothingValue: number;
  67838. /**
  67839. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67840. */
  67841. borderMinValue: number;
  67842. /**
  67843. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67844. */
  67845. renderHoverLight: boolean;
  67846. /**
  67847. * Gets or sets the radius used to render the hover light (default is 1.0)
  67848. */
  67849. hoverRadius: number;
  67850. /**
  67851. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67852. */
  67853. hoverColor: BABYLON.Color4;
  67854. /**
  67855. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67856. */
  67857. hoverPosition: BABYLON.Vector3;
  67858. private _albedoTexture;
  67859. /** Gets or sets the texture to use for albedo color */
  67860. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67861. /**
  67862. * Creates a new Fluent material
  67863. * @param name defines the name of the material
  67864. * @param scene defines the hosting scene
  67865. */
  67866. constructor(name: string, scene: BABYLON.Scene);
  67867. needAlphaBlending(): boolean;
  67868. needAlphaTesting(): boolean;
  67869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67872. getActiveTextures(): BABYLON.BaseTexture[];
  67873. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67874. dispose(forceDisposeEffect?: boolean): void;
  67875. clone(name: string): FluentMaterial;
  67876. serialize(): any;
  67877. getClassName(): string;
  67878. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67879. }
  67880. }
  67881. declare module BABYLON.GUI {
  67882. /**
  67883. * Class used to create a holographic button in 3D
  67884. */
  67885. export class HolographicButton extends Button3D {
  67886. private _backPlate;
  67887. private _textPlate;
  67888. private _frontPlate;
  67889. private _text;
  67890. private _imageUrl;
  67891. private _shareMaterials;
  67892. private _frontMaterial;
  67893. private _backMaterial;
  67894. private _plateMaterial;
  67895. private _pickedPointObserver;
  67896. private _tooltipFade;
  67897. private _tooltipTextBlock;
  67898. private _tooltipTexture;
  67899. private _tooltipMesh;
  67900. private _tooltipHoverObserver;
  67901. private _tooltipOutObserver;
  67902. private _disposeTooltip;
  67903. /**
  67904. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67905. */
  67906. tooltipText: BABYLON.Nullable<string>;
  67907. /**
  67908. * Gets or sets text for the button
  67909. */
  67910. text: string;
  67911. /**
  67912. * Gets or sets the image url for the button
  67913. */
  67914. imageUrl: string;
  67915. /**
  67916. * Gets the back material used by this button
  67917. */
  67918. readonly backMaterial: FluentMaterial;
  67919. /**
  67920. * Gets the front material used by this button
  67921. */
  67922. readonly frontMaterial: FluentMaterial;
  67923. /**
  67924. * Gets the plate material used by this button
  67925. */
  67926. readonly plateMaterial: BABYLON.StandardMaterial;
  67927. /**
  67928. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67929. */
  67930. readonly shareMaterials: boolean;
  67931. /**
  67932. * Creates a new button
  67933. * @param name defines the control name
  67934. */
  67935. constructor(name?: string, shareMaterials?: boolean);
  67936. protected _getTypeName(): string;
  67937. private _rebuildContent;
  67938. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67939. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67940. private _createBackMaterial;
  67941. private _createFrontMaterial;
  67942. private _createPlateMaterial;
  67943. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67944. /**
  67945. * Releases all associated resources
  67946. */
  67947. dispose(): void;
  67948. }
  67949. }
  67950. declare module BABYLON.GUI {
  67951. /**
  67952. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67953. */
  67954. export class MeshButton3D extends Button3D {
  67955. /** @hidden */
  67956. protected _currentMesh: BABYLON.Mesh;
  67957. /**
  67958. * Creates a new 3D button based on a mesh
  67959. * @param mesh mesh to become a 3D button
  67960. * @param name defines the control name
  67961. */
  67962. constructor(mesh: BABYLON.Mesh, name?: string);
  67963. protected _getTypeName(): string;
  67964. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67965. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67966. }
  67967. }
  67968. declare module BABYLON.GUI {
  67969. /**
  67970. * Class used to create a container panel deployed on the surface of a plane
  67971. */
  67972. export class PlanePanel extends VolumeBasedPanel {
  67973. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67974. }
  67975. }
  67976. declare module BABYLON.GUI {
  67977. /**
  67978. * Class used to create a container panel where items get randomized planar mapping
  67979. */
  67980. export class ScatterPanel extends VolumeBasedPanel {
  67981. private _iteration;
  67982. /**
  67983. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67984. */
  67985. iteration: BABYLON.float;
  67986. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67987. private _scatterMapping;
  67988. protected _finalProcessing(): void;
  67989. }
  67990. }
  67991. declare module BABYLON.GUI {
  67992. /**
  67993. * Class used to create a container panel deployed on the surface of a sphere
  67994. */
  67995. export class SpherePanel extends VolumeBasedPanel {
  67996. private _radius;
  67997. /**
  67998. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67999. */
  68000. radius: BABYLON.float;
  68001. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68002. private _sphericalMapping;
  68003. }
  68004. }
  68005. declare module BABYLON.GUI {
  68006. /**
  68007. * Class used to create a stack panel in 3D on XY plane
  68008. */
  68009. export class StackPanel3D extends Container3D {
  68010. private _isVertical;
  68011. /**
  68012. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68013. */
  68014. isVertical: boolean;
  68015. /**
  68016. * Gets or sets the distance between elements
  68017. */
  68018. margin: number;
  68019. /**
  68020. * Creates new StackPanel
  68021. * @param isVertical
  68022. */
  68023. constructor(isVertical?: boolean);
  68024. protected _arrangeChildren(): void;
  68025. }
  68026. }
  68027. declare module BABYLON {
  68028. /**
  68029. * Interface for a data buffer
  68030. */
  68031. export interface IDataBuffer {
  68032. /**
  68033. * Reads bytes from the data buffer.
  68034. * @param byteOffset The byte offset to read
  68035. * @param byteLength The byte length to read
  68036. * @returns A promise that resolves when the bytes are read
  68037. */
  68038. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68039. /**
  68040. * The byte length of the buffer.
  68041. */
  68042. readonly byteLength: number;
  68043. }
  68044. /**
  68045. * Utility class for reading from a data buffer
  68046. */
  68047. export class DataReader {
  68048. /**
  68049. * The data buffer associated with this data reader.
  68050. */
  68051. readonly buffer: IDataBuffer;
  68052. /**
  68053. * The current byte offset from the beginning of the data buffer.
  68054. */
  68055. byteOffset: number;
  68056. private _dataView;
  68057. private _dataByteOffset;
  68058. /**
  68059. * Constructor
  68060. * @param buffer The buffer to read
  68061. */
  68062. constructor(buffer: IDataBuffer);
  68063. /**
  68064. * Loads the given byte length.
  68065. * @param byteLength The byte length to load
  68066. * @returns A promise that resolves when the load is complete
  68067. */
  68068. loadAsync(byteLength: number): Promise<void>;
  68069. /**
  68070. * Read a unsigned 32-bit integer from the currently loaded data range.
  68071. * @returns The 32-bit integer read
  68072. */
  68073. readUint32(): number;
  68074. /**
  68075. * Read a byte array from the currently loaded data range.
  68076. * @param byteLength The byte length to read
  68077. * @returns The byte array read
  68078. */
  68079. readUint8Array(byteLength: number): Uint8Array;
  68080. /**
  68081. * Read a string from the currently loaded data range.
  68082. * @param byteLength The byte length to read
  68083. * @returns The string read
  68084. */
  68085. readString(byteLength: number): string;
  68086. /**
  68087. * Skips the given byte length the currently loaded data range.
  68088. * @param byteLength The byte length to skip
  68089. */
  68090. skipBytes(byteLength: number): void;
  68091. }
  68092. }
  68093. declare module BABYLON {
  68094. /**
  68095. * Mode that determines the coordinate system to use.
  68096. */
  68097. export enum GLTFLoaderCoordinateSystemMode {
  68098. /**
  68099. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68100. */
  68101. AUTO = 0,
  68102. /**
  68103. * Sets the useRightHandedSystem flag on the scene.
  68104. */
  68105. FORCE_RIGHT_HANDED = 1
  68106. }
  68107. /**
  68108. * Mode that determines what animations will start.
  68109. */
  68110. export enum GLTFLoaderAnimationStartMode {
  68111. /**
  68112. * No animation will start.
  68113. */
  68114. NONE = 0,
  68115. /**
  68116. * The first animation will start.
  68117. */
  68118. FIRST = 1,
  68119. /**
  68120. * All animations will start.
  68121. */
  68122. ALL = 2
  68123. }
  68124. /**
  68125. * Interface that contains the data for the glTF asset.
  68126. */
  68127. export interface IGLTFLoaderData {
  68128. /**
  68129. * The object that represents the glTF JSON.
  68130. */
  68131. json: Object;
  68132. /**
  68133. * The BIN chunk of a binary glTF.
  68134. */
  68135. bin: Nullable<IDataBuffer>;
  68136. }
  68137. /**
  68138. * Interface for extending the loader.
  68139. */
  68140. export interface IGLTFLoaderExtension {
  68141. /**
  68142. * The name of this extension.
  68143. */
  68144. readonly name: string;
  68145. /**
  68146. * Defines whether this extension is enabled.
  68147. */
  68148. enabled: boolean;
  68149. }
  68150. /**
  68151. * Loader state.
  68152. */
  68153. export enum GLTFLoaderState {
  68154. /**
  68155. * The asset is loading.
  68156. */
  68157. LOADING = 0,
  68158. /**
  68159. * The asset is ready for rendering.
  68160. */
  68161. READY = 1,
  68162. /**
  68163. * The asset is completely loaded.
  68164. */
  68165. COMPLETE = 2
  68166. }
  68167. /** @hidden */
  68168. export interface IGLTFLoader extends IDisposable {
  68169. readonly state: Nullable<GLTFLoaderState>;
  68170. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68171. meshes: AbstractMesh[];
  68172. particleSystems: IParticleSystem[];
  68173. skeletons: Skeleton[];
  68174. animationGroups: AnimationGroup[];
  68175. }>;
  68176. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68177. }
  68178. /**
  68179. * File loader for loading glTF files into a scene.
  68180. */
  68181. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68182. /** @hidden */
  68183. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68184. /** @hidden */
  68185. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68186. /**
  68187. * Raised when the asset has been parsed
  68188. */
  68189. onParsedObservable: Observable<IGLTFLoaderData>;
  68190. private _onParsedObserver;
  68191. /**
  68192. * Raised when the asset has been parsed
  68193. */
  68194. onParsed: (loaderData: IGLTFLoaderData) => void;
  68195. /**
  68196. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  68197. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68198. * Defaults to true.
  68199. * @hidden
  68200. */
  68201. static IncrementalLoading: boolean;
  68202. /**
  68203. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68204. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68205. * @hidden
  68206. */
  68207. static HomogeneousCoordinates: boolean;
  68208. /**
  68209. * The coordinate system mode. Defaults to AUTO.
  68210. */
  68211. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68212. /**
  68213. * The animation start mode. Defaults to FIRST.
  68214. */
  68215. animationStartMode: GLTFLoaderAnimationStartMode;
  68216. /**
  68217. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68218. */
  68219. compileMaterials: boolean;
  68220. /**
  68221. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68222. */
  68223. useClipPlane: boolean;
  68224. /**
  68225. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68226. */
  68227. compileShadowGenerators: boolean;
  68228. /**
  68229. * Defines if the Alpha blended materials are only applied as coverage.
  68230. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68231. * If true, no extra effects are applied to transparent pixels.
  68232. */
  68233. transparencyAsCoverage: boolean;
  68234. /**
  68235. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68236. * Enabling will disable offline support and glTF validator.
  68237. * Defaults to false.
  68238. */
  68239. useRangeRequests: boolean;
  68240. /**
  68241. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68242. */
  68243. createInstances: boolean;
  68244. /**
  68245. * Function called before loading a url referenced by the asset.
  68246. */
  68247. preprocessUrlAsync: (url: string) => Promise<string>;
  68248. /**
  68249. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68250. */
  68251. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68252. private _onMeshLoadedObserver;
  68253. /**
  68254. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68255. */
  68256. onMeshLoaded: (mesh: AbstractMesh) => void;
  68257. /**
  68258. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68259. */
  68260. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68261. private _onTextureLoadedObserver;
  68262. /**
  68263. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68264. */
  68265. onTextureLoaded: (texture: BaseTexture) => void;
  68266. /**
  68267. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68268. */
  68269. readonly onMaterialLoadedObservable: Observable<Material>;
  68270. private _onMaterialLoadedObserver;
  68271. /**
  68272. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68273. */
  68274. onMaterialLoaded: (material: Material) => void;
  68275. /**
  68276. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68277. */
  68278. readonly onCameraLoadedObservable: Observable<Camera>;
  68279. private _onCameraLoadedObserver;
  68280. /**
  68281. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68282. */
  68283. onCameraLoaded: (camera: Camera) => void;
  68284. /**
  68285. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68286. * For assets with LODs, raised when all of the LODs are complete.
  68287. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68288. */
  68289. readonly onCompleteObservable: Observable<void>;
  68290. private _onCompleteObserver;
  68291. /**
  68292. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68293. * For assets with LODs, raised when all of the LODs are complete.
  68294. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68295. */
  68296. onComplete: () => void;
  68297. /**
  68298. * Observable raised when an error occurs.
  68299. */
  68300. readonly onErrorObservable: Observable<any>;
  68301. private _onErrorObserver;
  68302. /**
  68303. * Callback raised when an error occurs.
  68304. */
  68305. onError: (reason: any) => void;
  68306. /**
  68307. * Observable raised after the loader is disposed.
  68308. */
  68309. readonly onDisposeObservable: Observable<void>;
  68310. private _onDisposeObserver;
  68311. /**
  68312. * Callback raised after the loader is disposed.
  68313. */
  68314. onDispose: () => void;
  68315. /**
  68316. * Observable raised after a loader extension is created.
  68317. * Set additional options for a loader extension in this event.
  68318. */
  68319. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68320. private _onExtensionLoadedObserver;
  68321. /**
  68322. * Callback raised after a loader extension is created.
  68323. */
  68324. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68325. /**
  68326. * Defines if the loader logging is enabled.
  68327. */
  68328. loggingEnabled: boolean;
  68329. /**
  68330. * Defines if the loader should capture performance counters.
  68331. */
  68332. capturePerformanceCounters: boolean;
  68333. /**
  68334. * Defines if the loader should validate the asset.
  68335. */
  68336. validate: boolean;
  68337. /**
  68338. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68339. */
  68340. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68341. private _onValidatedObserver;
  68342. /**
  68343. * Callback raised after a loader extension is created.
  68344. */
  68345. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68346. private _loader;
  68347. /**
  68348. * Name of the loader ("gltf")
  68349. */
  68350. name: string;
  68351. /**
  68352. * Supported file extensions of the loader (.gltf, .glb)
  68353. */
  68354. extensions: ISceneLoaderPluginExtensions;
  68355. /**
  68356. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68357. */
  68358. dispose(): void;
  68359. /** @hidden */
  68360. _clear(): void;
  68361. /**
  68362. * The callback called when loading from a url.
  68363. * @param scene scene loading this url
  68364. * @param url url to load
  68365. * @param onSuccess callback called when the file successfully loads
  68366. * @param onProgress callback called while file is loading (if the server supports this mode)
  68367. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68368. * @param onError callback called when the file fails to load
  68369. * @returns a file request object
  68370. */
  68371. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68372. /**
  68373. * The callback called when loading from a file object.
  68374. * @param scene scene loading this file
  68375. * @param file defines the file to load
  68376. * @param onSuccess defines the callback to call when data is loaded
  68377. * @param onProgress defines the callback to call during loading process
  68378. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68379. * @param onError defines the callback to call when an error occurs
  68380. * @returns a file request object
  68381. */
  68382. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68383. /**
  68384. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  68385. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68386. * @param scene the scene the meshes should be added to
  68387. * @param data the glTF data to load
  68388. * @param rootUrl root url to load from
  68389. * @param onProgress event that fires when loading progress has occured
  68390. * @param fileName Defines the name of the file to load
  68391. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68392. */
  68393. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68394. meshes: AbstractMesh[];
  68395. particleSystems: IParticleSystem[];
  68396. skeletons: Skeleton[];
  68397. animationGroups: AnimationGroup[];
  68398. }>;
  68399. /**
  68400. * Imports all objects from the loaded glTF data and adds them to the scene
  68401. * @param scene the scene the objects should be added to
  68402. * @param data the glTF data to load
  68403. * @param rootUrl root url to load from
  68404. * @param onProgress event that fires when loading progress has occured
  68405. * @param fileName Defines the name of the file to load
  68406. * @returns a promise which completes when objects have been loaded to the scene
  68407. */
  68408. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68409. /**
  68410. * Load into an asset container.
  68411. * @param scene The scene to load into
  68412. * @param data The data to import
  68413. * @param rootUrl The root url for scene and resources
  68414. * @param onProgress The callback when the load progresses
  68415. * @param fileName Defines the name of the file to load
  68416. * @returns The loaded asset container
  68417. */
  68418. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68419. /**
  68420. * The callback that returns true if the data can be directly loaded.
  68421. * @param data string containing the file data
  68422. * @returns if the data can be loaded directly
  68423. */
  68424. canDirectLoad(data: string): boolean;
  68425. /**
  68426. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  68427. * @param scene scene loading this data
  68428. * @param data string containing the data
  68429. * @returns data to pass to the plugin
  68430. */
  68431. directLoad(scene: Scene, data: string): any;
  68432. /**
  68433. * The callback that allows custom handling of the root url based on the response url.
  68434. * @param rootUrl the original root url
  68435. * @param responseURL the response url if available
  68436. * @returns the new root url
  68437. */
  68438. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68439. /**
  68440. * Instantiates a glTF file loader plugin.
  68441. * @returns the created plugin
  68442. */
  68443. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68444. /**
  68445. * The loader state or null if the loader is not active.
  68446. */
  68447. readonly loaderState: Nullable<GLTFLoaderState>;
  68448. /**
  68449. * Returns a promise that resolves when the asset is completely loaded.
  68450. * @returns a promise that resolves when the asset is completely loaded.
  68451. */
  68452. whenCompleteAsync(): Promise<void>;
  68453. private _validateAsync;
  68454. private _getLoader;
  68455. private _parseJson;
  68456. private _unpackBinaryAsync;
  68457. private _unpackBinaryV1Async;
  68458. private _unpackBinaryV2Async;
  68459. private static _parseVersion;
  68460. private static _compareVersion;
  68461. private static readonly _logSpaces;
  68462. private _logIndentLevel;
  68463. private _loggingEnabled;
  68464. /** @hidden */
  68465. _log: (message: string) => void;
  68466. /** @hidden */
  68467. _logOpen(message: string): void;
  68468. /** @hidden */
  68469. _logClose(): void;
  68470. private _logEnabled;
  68471. private _logDisabled;
  68472. private _capturePerformanceCounters;
  68473. /** @hidden */
  68474. _startPerformanceCounter: (counterName: string) => void;
  68475. /** @hidden */
  68476. _endPerformanceCounter: (counterName: string) => void;
  68477. private _startPerformanceCounterEnabled;
  68478. private _startPerformanceCounterDisabled;
  68479. private _endPerformanceCounterEnabled;
  68480. private _endPerformanceCounterDisabled;
  68481. }
  68482. }
  68483. declare module BABYLON.GLTF1 {
  68484. /**
  68485. * Enums
  68486. * @hidden
  68487. */
  68488. export enum EComponentType {
  68489. BYTE = 5120,
  68490. UNSIGNED_BYTE = 5121,
  68491. SHORT = 5122,
  68492. UNSIGNED_SHORT = 5123,
  68493. FLOAT = 5126
  68494. }
  68495. /** @hidden */
  68496. export enum EShaderType {
  68497. FRAGMENT = 35632,
  68498. VERTEX = 35633
  68499. }
  68500. /** @hidden */
  68501. export enum EParameterType {
  68502. BYTE = 5120,
  68503. UNSIGNED_BYTE = 5121,
  68504. SHORT = 5122,
  68505. UNSIGNED_SHORT = 5123,
  68506. INT = 5124,
  68507. UNSIGNED_INT = 5125,
  68508. FLOAT = 5126,
  68509. FLOAT_VEC2 = 35664,
  68510. FLOAT_VEC3 = 35665,
  68511. FLOAT_VEC4 = 35666,
  68512. INT_VEC2 = 35667,
  68513. INT_VEC3 = 35668,
  68514. INT_VEC4 = 35669,
  68515. BOOL = 35670,
  68516. BOOL_VEC2 = 35671,
  68517. BOOL_VEC3 = 35672,
  68518. BOOL_VEC4 = 35673,
  68519. FLOAT_MAT2 = 35674,
  68520. FLOAT_MAT3 = 35675,
  68521. FLOAT_MAT4 = 35676,
  68522. SAMPLER_2D = 35678
  68523. }
  68524. /** @hidden */
  68525. export enum ETextureWrapMode {
  68526. CLAMP_TO_EDGE = 33071,
  68527. MIRRORED_REPEAT = 33648,
  68528. REPEAT = 10497
  68529. }
  68530. /** @hidden */
  68531. export enum ETextureFilterType {
  68532. NEAREST = 9728,
  68533. LINEAR = 9728,
  68534. NEAREST_MIPMAP_NEAREST = 9984,
  68535. LINEAR_MIPMAP_NEAREST = 9985,
  68536. NEAREST_MIPMAP_LINEAR = 9986,
  68537. LINEAR_MIPMAP_LINEAR = 9987
  68538. }
  68539. /** @hidden */
  68540. export enum ETextureFormat {
  68541. ALPHA = 6406,
  68542. RGB = 6407,
  68543. RGBA = 6408,
  68544. LUMINANCE = 6409,
  68545. LUMINANCE_ALPHA = 6410
  68546. }
  68547. /** @hidden */
  68548. export enum ECullingType {
  68549. FRONT = 1028,
  68550. BACK = 1029,
  68551. FRONT_AND_BACK = 1032
  68552. }
  68553. /** @hidden */
  68554. export enum EBlendingFunction {
  68555. ZERO = 0,
  68556. ONE = 1,
  68557. SRC_COLOR = 768,
  68558. ONE_MINUS_SRC_COLOR = 769,
  68559. DST_COLOR = 774,
  68560. ONE_MINUS_DST_COLOR = 775,
  68561. SRC_ALPHA = 770,
  68562. ONE_MINUS_SRC_ALPHA = 771,
  68563. DST_ALPHA = 772,
  68564. ONE_MINUS_DST_ALPHA = 773,
  68565. CONSTANT_COLOR = 32769,
  68566. ONE_MINUS_CONSTANT_COLOR = 32770,
  68567. CONSTANT_ALPHA = 32771,
  68568. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68569. SRC_ALPHA_SATURATE = 776
  68570. }
  68571. /** @hidden */
  68572. export interface IGLTFProperty {
  68573. extensions?: {
  68574. [key: string]: any;
  68575. };
  68576. extras?: Object;
  68577. }
  68578. /** @hidden */
  68579. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68580. name?: string;
  68581. }
  68582. /** @hidden */
  68583. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68584. bufferView: string;
  68585. byteOffset: number;
  68586. byteStride: number;
  68587. count: number;
  68588. type: string;
  68589. componentType: EComponentType;
  68590. max?: number[];
  68591. min?: number[];
  68592. name?: string;
  68593. }
  68594. /** @hidden */
  68595. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68596. buffer: string;
  68597. byteOffset: number;
  68598. byteLength: number;
  68599. byteStride: number;
  68600. target?: number;
  68601. }
  68602. /** @hidden */
  68603. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68604. uri: string;
  68605. byteLength?: number;
  68606. type?: string;
  68607. }
  68608. /** @hidden */
  68609. export interface IGLTFShader extends IGLTFChildRootProperty {
  68610. uri: string;
  68611. type: EShaderType;
  68612. }
  68613. /** @hidden */
  68614. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68615. attributes: string[];
  68616. fragmentShader: string;
  68617. vertexShader: string;
  68618. }
  68619. /** @hidden */
  68620. export interface IGLTFTechniqueParameter {
  68621. type: number;
  68622. count?: number;
  68623. semantic?: string;
  68624. node?: string;
  68625. value?: number | boolean | string | Array<any>;
  68626. source?: string;
  68627. babylonValue?: any;
  68628. }
  68629. /** @hidden */
  68630. export interface IGLTFTechniqueCommonProfile {
  68631. lightingModel: string;
  68632. texcoordBindings: Object;
  68633. parameters?: Array<any>;
  68634. }
  68635. /** @hidden */
  68636. export interface IGLTFTechniqueStatesFunctions {
  68637. blendColor?: number[];
  68638. blendEquationSeparate?: number[];
  68639. blendFuncSeparate?: number[];
  68640. colorMask: boolean[];
  68641. cullFace: number[];
  68642. }
  68643. /** @hidden */
  68644. export interface IGLTFTechniqueStates {
  68645. enable: number[];
  68646. functions: IGLTFTechniqueStatesFunctions;
  68647. }
  68648. /** @hidden */
  68649. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68650. parameters: {
  68651. [key: string]: IGLTFTechniqueParameter;
  68652. };
  68653. program: string;
  68654. attributes: {
  68655. [key: string]: string;
  68656. };
  68657. uniforms: {
  68658. [key: string]: string;
  68659. };
  68660. states: IGLTFTechniqueStates;
  68661. }
  68662. /** @hidden */
  68663. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68664. technique?: string;
  68665. values: string[];
  68666. }
  68667. /** @hidden */
  68668. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68669. attributes: {
  68670. [key: string]: string;
  68671. };
  68672. indices: string;
  68673. material: string;
  68674. mode?: number;
  68675. }
  68676. /** @hidden */
  68677. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68678. primitives: IGLTFMeshPrimitive[];
  68679. }
  68680. /** @hidden */
  68681. export interface IGLTFImage extends IGLTFChildRootProperty {
  68682. uri: string;
  68683. }
  68684. /** @hidden */
  68685. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68686. magFilter?: number;
  68687. minFilter?: number;
  68688. wrapS?: number;
  68689. wrapT?: number;
  68690. }
  68691. /** @hidden */
  68692. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68693. sampler: string;
  68694. source: string;
  68695. format?: ETextureFormat;
  68696. internalFormat?: ETextureFormat;
  68697. target?: number;
  68698. type?: number;
  68699. babylonTexture?: Texture;
  68700. }
  68701. /** @hidden */
  68702. export interface IGLTFAmbienLight {
  68703. color?: number[];
  68704. }
  68705. /** @hidden */
  68706. export interface IGLTFDirectionalLight {
  68707. color?: number[];
  68708. }
  68709. /** @hidden */
  68710. export interface IGLTFPointLight {
  68711. color?: number[];
  68712. constantAttenuation?: number;
  68713. linearAttenuation?: number;
  68714. quadraticAttenuation?: number;
  68715. }
  68716. /** @hidden */
  68717. export interface IGLTFSpotLight {
  68718. color?: number[];
  68719. constantAttenuation?: number;
  68720. fallOfAngle?: number;
  68721. fallOffExponent?: number;
  68722. linearAttenuation?: number;
  68723. quadraticAttenuation?: number;
  68724. }
  68725. /** @hidden */
  68726. export interface IGLTFLight extends IGLTFChildRootProperty {
  68727. type: string;
  68728. }
  68729. /** @hidden */
  68730. export interface IGLTFCameraOrthographic {
  68731. xmag: number;
  68732. ymag: number;
  68733. zfar: number;
  68734. znear: number;
  68735. }
  68736. /** @hidden */
  68737. export interface IGLTFCameraPerspective {
  68738. aspectRatio: number;
  68739. yfov: number;
  68740. zfar: number;
  68741. znear: number;
  68742. }
  68743. /** @hidden */
  68744. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68745. type: string;
  68746. }
  68747. /** @hidden */
  68748. export interface IGLTFAnimationChannelTarget {
  68749. id: string;
  68750. path: string;
  68751. }
  68752. /** @hidden */
  68753. export interface IGLTFAnimationChannel {
  68754. sampler: string;
  68755. target: IGLTFAnimationChannelTarget;
  68756. }
  68757. /** @hidden */
  68758. export interface IGLTFAnimationSampler {
  68759. input: string;
  68760. output: string;
  68761. interpolation?: string;
  68762. }
  68763. /** @hidden */
  68764. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68765. channels?: IGLTFAnimationChannel[];
  68766. parameters?: {
  68767. [key: string]: string;
  68768. };
  68769. samplers?: {
  68770. [key: string]: IGLTFAnimationSampler;
  68771. };
  68772. }
  68773. /** @hidden */
  68774. export interface IGLTFNodeInstanceSkin {
  68775. skeletons: string[];
  68776. skin: string;
  68777. meshes: string[];
  68778. }
  68779. /** @hidden */
  68780. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68781. bindShapeMatrix: number[];
  68782. inverseBindMatrices: string;
  68783. jointNames: string[];
  68784. babylonSkeleton?: Skeleton;
  68785. }
  68786. /** @hidden */
  68787. export interface IGLTFNode extends IGLTFChildRootProperty {
  68788. camera?: string;
  68789. children: string[];
  68790. skin?: string;
  68791. jointName?: string;
  68792. light?: string;
  68793. matrix: number[];
  68794. mesh?: string;
  68795. meshes?: string[];
  68796. rotation?: number[];
  68797. scale?: number[];
  68798. translation?: number[];
  68799. babylonNode?: Node;
  68800. }
  68801. /** @hidden */
  68802. export interface IGLTFScene extends IGLTFChildRootProperty {
  68803. nodes: string[];
  68804. }
  68805. /** @hidden */
  68806. export interface IGLTFRuntime {
  68807. extensions: {
  68808. [key: string]: any;
  68809. };
  68810. accessors: {
  68811. [key: string]: IGLTFAccessor;
  68812. };
  68813. buffers: {
  68814. [key: string]: IGLTFBuffer;
  68815. };
  68816. bufferViews: {
  68817. [key: string]: IGLTFBufferView;
  68818. };
  68819. meshes: {
  68820. [key: string]: IGLTFMesh;
  68821. };
  68822. lights: {
  68823. [key: string]: IGLTFLight;
  68824. };
  68825. cameras: {
  68826. [key: string]: IGLTFCamera;
  68827. };
  68828. nodes: {
  68829. [key: string]: IGLTFNode;
  68830. };
  68831. images: {
  68832. [key: string]: IGLTFImage;
  68833. };
  68834. textures: {
  68835. [key: string]: IGLTFTexture;
  68836. };
  68837. shaders: {
  68838. [key: string]: IGLTFShader;
  68839. };
  68840. programs: {
  68841. [key: string]: IGLTFProgram;
  68842. };
  68843. samplers: {
  68844. [key: string]: IGLTFSampler;
  68845. };
  68846. techniques: {
  68847. [key: string]: IGLTFTechnique;
  68848. };
  68849. materials: {
  68850. [key: string]: IGLTFMaterial;
  68851. };
  68852. animations: {
  68853. [key: string]: IGLTFAnimation;
  68854. };
  68855. skins: {
  68856. [key: string]: IGLTFSkins;
  68857. };
  68858. currentScene?: Object;
  68859. scenes: {
  68860. [key: string]: IGLTFScene;
  68861. };
  68862. extensionsUsed: string[];
  68863. extensionsRequired?: string[];
  68864. buffersCount: number;
  68865. shaderscount: number;
  68866. scene: Scene;
  68867. rootUrl: string;
  68868. loadedBufferCount: number;
  68869. loadedBufferViews: {
  68870. [name: string]: ArrayBufferView;
  68871. };
  68872. loadedShaderCount: number;
  68873. importOnlyMeshes: boolean;
  68874. importMeshesNames?: string[];
  68875. dummyNodes: Node[];
  68876. }
  68877. /** @hidden */
  68878. export interface INodeToRoot {
  68879. bone: Bone;
  68880. node: IGLTFNode;
  68881. id: string;
  68882. }
  68883. /** @hidden */
  68884. export interface IJointNode {
  68885. node: IGLTFNode;
  68886. id: string;
  68887. }
  68888. }
  68889. declare module BABYLON.GLTF1 {
  68890. /**
  68891. * Utils functions for GLTF
  68892. * @hidden
  68893. */
  68894. export class GLTFUtils {
  68895. /**
  68896. * Sets the given "parameter" matrix
  68897. * @param scene: the Scene object
  68898. * @param source: the source node where to pick the matrix
  68899. * @param parameter: the GLTF technique parameter
  68900. * @param uniformName: the name of the shader's uniform
  68901. * @param shaderMaterial: the shader material
  68902. */
  68903. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68904. /**
  68905. * Sets the given "parameter" matrix
  68906. * @param shaderMaterial: the shader material
  68907. * @param uniform: the name of the shader's uniform
  68908. * @param value: the value of the uniform
  68909. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68910. */
  68911. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68912. /**
  68913. * Returns the wrap mode of the texture
  68914. * @param mode: the mode value
  68915. */
  68916. static GetWrapMode(mode: number): number;
  68917. /**
  68918. * Returns the byte stride giving an accessor
  68919. * @param accessor: the GLTF accessor objet
  68920. */
  68921. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68922. /**
  68923. * Returns the texture filter mode giving a mode value
  68924. * @param mode: the filter mode value
  68925. */
  68926. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68927. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68928. /**
  68929. * Returns a buffer from its accessor
  68930. * @param gltfRuntime: the GLTF runtime
  68931. * @param accessor: the GLTF accessor
  68932. */
  68933. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68934. /**
  68935. * Decodes a buffer view into a string
  68936. * @param view: the buffer view
  68937. */
  68938. static DecodeBufferToText(view: ArrayBufferView): string;
  68939. /**
  68940. * Returns the default material of gltf. Related to
  68941. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68942. * @param scene: the Babylon.js scene
  68943. */
  68944. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68945. private static _DefaultMaterial;
  68946. }
  68947. }
  68948. declare module BABYLON.GLTF1 {
  68949. /**
  68950. * Implementation of the base glTF spec
  68951. * @hidden
  68952. */
  68953. export class GLTFLoaderBase {
  68954. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68955. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68956. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68957. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68958. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68959. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68960. }
  68961. /**
  68962. * glTF V1 Loader
  68963. * @hidden
  68964. */
  68965. export class GLTFLoader implements IGLTFLoader {
  68966. static Extensions: {
  68967. [name: string]: GLTFLoaderExtension;
  68968. };
  68969. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68970. state: Nullable<GLTFLoaderState>;
  68971. dispose(): void;
  68972. private _importMeshAsync;
  68973. /**
  68974. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68975. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68976. * @param scene the scene the meshes should be added to
  68977. * @param data gltf data containing information of the meshes in a loaded file
  68978. * @param rootUrl root url to load from
  68979. * @param onProgress event that fires when loading progress has occured
  68980. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68981. */
  68982. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68983. meshes: AbstractMesh[];
  68984. particleSystems: IParticleSystem[];
  68985. skeletons: Skeleton[];
  68986. animationGroups: AnimationGroup[];
  68987. }>;
  68988. private _loadAsync;
  68989. /**
  68990. * Imports all objects from a loaded gltf file and adds them to the scene
  68991. * @param scene the scene the objects should be added to
  68992. * @param data gltf data containing information of the meshes in a loaded file
  68993. * @param rootUrl root url to load from
  68994. * @param onProgress event that fires when loading progress has occured
  68995. * @returns a promise which completes when objects have been loaded to the scene
  68996. */
  68997. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  68998. private _loadShadersAsync;
  68999. private _loadBuffersAsync;
  69000. private _createNodes;
  69001. }
  69002. /** @hidden */
  69003. export abstract class GLTFLoaderExtension {
  69004. private _name;
  69005. constructor(name: string);
  69006. readonly name: string;
  69007. /**
  69008. * Defines an override for loading the runtime
  69009. * Return true to stop further extensions from loading the runtime
  69010. */
  69011. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69012. /**
  69013. * Defines an onverride for creating gltf runtime
  69014. * Return true to stop further extensions from creating the runtime
  69015. */
  69016. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69017. /**
  69018. * Defines an override for loading buffers
  69019. * Return true to stop further extensions from loading this buffer
  69020. */
  69021. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69022. /**
  69023. * Defines an override for loading texture buffers
  69024. * Return true to stop further extensions from loading this texture data
  69025. */
  69026. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69027. /**
  69028. * Defines an override for creating textures
  69029. * Return true to stop further extensions from loading this texture
  69030. */
  69031. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69032. /**
  69033. * Defines an override for loading shader strings
  69034. * Return true to stop further extensions from loading this shader data
  69035. */
  69036. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69037. /**
  69038. * Defines an override for loading materials
  69039. * Return true to stop further extensions from loading this material
  69040. */
  69041. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69042. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69043. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69044. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69045. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69046. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69047. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69048. private static LoadTextureBufferAsync;
  69049. private static CreateTextureAsync;
  69050. private static ApplyExtensions;
  69051. }
  69052. }
  69053. declare module BABYLON.GLTF1 {
  69054. /** @hidden */
  69055. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69056. private _bin;
  69057. constructor();
  69058. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69059. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69060. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69061. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69062. }
  69063. }
  69064. declare module BABYLON.GLTF1 {
  69065. /** @hidden */
  69066. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69067. constructor();
  69068. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69069. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69070. private _loadTexture;
  69071. }
  69072. }
  69073. declare module BABYLON.GLTF2.Loader {
  69074. /**
  69075. * Loader interface with an index field.
  69076. */
  69077. export interface IArrayItem {
  69078. /**
  69079. * The index of this item in the array.
  69080. */
  69081. index: number;
  69082. }
  69083. /**
  69084. * Loader interface with additional members.
  69085. */
  69086. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69087. /** @hidden */
  69088. _data?: Promise<ArrayBufferView>;
  69089. /** @hidden */
  69090. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69091. }
  69092. /**
  69093. * Loader interface with additional members.
  69094. */
  69095. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69096. }
  69097. /** @hidden */
  69098. export interface _IAnimationSamplerData {
  69099. input: Float32Array;
  69100. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69101. output: Float32Array;
  69102. }
  69103. /**
  69104. * Loader interface with additional members.
  69105. */
  69106. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69107. /** @hidden */
  69108. _data?: Promise<_IAnimationSamplerData>;
  69109. }
  69110. /**
  69111. * Loader interface with additional members.
  69112. */
  69113. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69114. channels: IAnimationChannel[];
  69115. samplers: IAnimationSampler[];
  69116. /** @hidden */
  69117. _babylonAnimationGroup?: AnimationGroup;
  69118. }
  69119. /**
  69120. * Loader interface with additional members.
  69121. */
  69122. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69123. /** @hidden */
  69124. _data?: Promise<ArrayBufferView>;
  69125. }
  69126. /**
  69127. * Loader interface with additional members.
  69128. */
  69129. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69130. /** @hidden */
  69131. _data?: Promise<ArrayBufferView>;
  69132. /** @hidden */
  69133. _babylonBuffer?: Promise<Buffer>;
  69134. }
  69135. /**
  69136. * Loader interface with additional members.
  69137. */
  69138. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69139. }
  69140. /**
  69141. * Loader interface with additional members.
  69142. */
  69143. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69144. /** @hidden */
  69145. _data?: Promise<ArrayBufferView>;
  69146. }
  69147. /**
  69148. * Loader interface with additional members.
  69149. */
  69150. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69151. }
  69152. /**
  69153. * Loader interface with additional members.
  69154. */
  69155. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69156. }
  69157. /**
  69158. * Loader interface with additional members.
  69159. */
  69160. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69161. baseColorTexture?: ITextureInfo;
  69162. metallicRoughnessTexture?: ITextureInfo;
  69163. }
  69164. /**
  69165. * Loader interface with additional members.
  69166. */
  69167. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69168. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69169. normalTexture?: IMaterialNormalTextureInfo;
  69170. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69171. emissiveTexture?: ITextureInfo;
  69172. /** @hidden */
  69173. _data?: {
  69174. [babylonDrawMode: number]: {
  69175. babylonMaterial: Material;
  69176. babylonMeshes: AbstractMesh[];
  69177. promise: Promise<void>;
  69178. };
  69179. };
  69180. }
  69181. /**
  69182. * Loader interface with additional members.
  69183. */
  69184. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69185. primitives: IMeshPrimitive[];
  69186. }
  69187. /**
  69188. * Loader interface with additional members.
  69189. */
  69190. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69191. /** @hidden */
  69192. _instanceData?: {
  69193. babylonSourceMesh: Mesh;
  69194. promise: Promise<any>;
  69195. };
  69196. }
  69197. /**
  69198. * Loader interface with additional members.
  69199. */
  69200. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69201. /**
  69202. * The parent glTF node.
  69203. */
  69204. parent?: INode;
  69205. /** @hidden */
  69206. _babylonTransformNode?: TransformNode;
  69207. /** @hidden */
  69208. _primitiveBabylonMeshes?: AbstractMesh[];
  69209. /** @hidden */
  69210. _babylonBones?: Bone[];
  69211. /** @hidden */
  69212. _numMorphTargets?: number;
  69213. }
  69214. /** @hidden */
  69215. export interface _ISamplerData {
  69216. noMipMaps: boolean;
  69217. samplingMode: number;
  69218. wrapU: number;
  69219. wrapV: number;
  69220. }
  69221. /**
  69222. * Loader interface with additional members.
  69223. */
  69224. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69225. /** @hidden */
  69226. _data?: _ISamplerData;
  69227. }
  69228. /**
  69229. * Loader interface with additional members.
  69230. */
  69231. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69232. }
  69233. /**
  69234. * Loader interface with additional members.
  69235. */
  69236. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69237. /** @hidden */
  69238. _data?: {
  69239. babylonSkeleton: Skeleton;
  69240. promise: Promise<void>;
  69241. };
  69242. }
  69243. /**
  69244. * Loader interface with additional members.
  69245. */
  69246. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69247. }
  69248. /**
  69249. * Loader interface with additional members.
  69250. */
  69251. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69252. }
  69253. /**
  69254. * Loader interface with additional members.
  69255. */
  69256. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69257. accessors?: IAccessor[];
  69258. animations?: IAnimation[];
  69259. buffers?: IBuffer[];
  69260. bufferViews?: IBufferView[];
  69261. cameras?: ICamera[];
  69262. images?: IImage[];
  69263. materials?: IMaterial[];
  69264. meshes?: IMesh[];
  69265. nodes?: INode[];
  69266. samplers?: ISampler[];
  69267. scenes?: IScene[];
  69268. skins?: ISkin[];
  69269. textures?: ITexture[];
  69270. }
  69271. }
  69272. declare module BABYLON.GLTF2 {
  69273. /**
  69274. * Interface for a glTF loader extension.
  69275. */
  69276. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69277. /**
  69278. * Called after the loader state changes to LOADING.
  69279. */
  69280. onLoading?(): void;
  69281. /**
  69282. * Called after the loader state changes to READY.
  69283. */
  69284. onReady?(): void;
  69285. /**
  69286. * Define this method to modify the default behavior when loading scenes.
  69287. * @param context The context when loading the asset
  69288. * @param scene The glTF scene property
  69289. * @returns A promise that resolves when the load is complete or null if not handled
  69290. */
  69291. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69292. /**
  69293. * Define this method to modify the default behavior when loading nodes.
  69294. * @param context The context when loading the asset
  69295. * @param node The glTF node property
  69296. * @param assign A function called synchronously after parsing the glTF properties
  69297. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69298. */
  69299. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69300. /**
  69301. * Define this method to modify the default behavior when loading cameras.
  69302. * @param context The context when loading the asset
  69303. * @param camera The glTF camera property
  69304. * @param assign A function called synchronously after parsing the glTF properties
  69305. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69306. */
  69307. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69308. /**
  69309. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69310. * @param context The context when loading the asset
  69311. * @param primitive The glTF mesh primitive property
  69312. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69313. */
  69314. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69315. /**
  69316. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69317. * @param context The context when loading the asset
  69318. * @param name The mesh name when loading the asset
  69319. * @param node The glTF node when loading the asset
  69320. * @param mesh The glTF mesh when loading the asset
  69321. * @param primitive The glTF mesh primitive property
  69322. * @param assign A function called synchronously after parsing the glTF properties
  69323. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69324. */
  69325. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69326. /**
  69327. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69328. * @param context The context when loading the asset
  69329. * @param material The glTF material property
  69330. * @param assign A function called synchronously after parsing the glTF properties
  69331. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69332. */
  69333. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69334. /**
  69335. * Define this method to modify the default behavior when creating materials.
  69336. * @param context The context when loading the asset
  69337. * @param material The glTF material property
  69338. * @param babylonDrawMode The draw mode for the Babylon material
  69339. * @returns The Babylon material or null if not handled
  69340. */
  69341. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69342. /**
  69343. * Define this method to modify the default behavior when loading material properties.
  69344. * @param context The context when loading the asset
  69345. * @param material The glTF material property
  69346. * @param babylonMaterial The Babylon material
  69347. * @returns A promise that resolves when the load is complete or null if not handled
  69348. */
  69349. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69350. /**
  69351. * Define this method to modify the default behavior when loading texture infos.
  69352. * @param context The context when loading the asset
  69353. * @param textureInfo The glTF texture info property
  69354. * @param assign A function called synchronously after parsing the glTF properties
  69355. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69356. */
  69357. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69358. /**
  69359. * Define this method to modify the default behavior when loading animations.
  69360. * @param context The context when loading the asset
  69361. * @param animation The glTF animation property
  69362. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69363. */
  69364. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69365. /**
  69366. * @hidden Define this method to modify the default behavior when loading skins.
  69367. * @param context The context when loading the asset
  69368. * @param node The glTF node property
  69369. * @param skin The glTF skin property
  69370. * @returns A promise that resolves when the load is complete or null if not handled
  69371. */
  69372. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69373. /**
  69374. * @hidden Define this method to modify the default behavior when loading uris.
  69375. * @param context The context when loading the asset
  69376. * @param property The glTF property associated with the uri
  69377. * @param uri The uri to load
  69378. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69379. */
  69380. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69381. /**
  69382. * Define this method to modify the default behavior when loading buffer views.
  69383. * @param context The context when loading the asset
  69384. * @param bufferView The glTF buffer view property
  69385. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69386. */
  69387. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69388. /**
  69389. * Define this method to modify the default behavior when loading buffers.
  69390. * @param context The context when loading the asset
  69391. * @param buffer The glTF buffer property
  69392. * @param byteOffset The byte offset to load
  69393. * @param byteLength The byte length to load
  69394. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69395. */
  69396. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69397. }
  69398. }
  69399. declare module BABYLON.GLTF2 {
  69400. /**
  69401. * Helper class for working with arrays when loading the glTF asset
  69402. */
  69403. export class ArrayItem {
  69404. /**
  69405. * Gets an item from the given array.
  69406. * @param context The context when loading the asset
  69407. * @param array The array to get the item from
  69408. * @param index The index to the array
  69409. * @returns The array item
  69410. */
  69411. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69412. /**
  69413. * Assign an `index` field to each item of the given array.
  69414. * @param array The array of items
  69415. */
  69416. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69417. }
  69418. /**
  69419. * The glTF 2.0 loader
  69420. */
  69421. export class GLTFLoader implements IGLTFLoader {
  69422. /** @hidden */
  69423. _completePromises: Promise<any>[];
  69424. private _disposed;
  69425. private _parent;
  69426. private _state;
  69427. private _extensions;
  69428. private _rootUrl;
  69429. private _fileName;
  69430. private _uniqueRootUrl;
  69431. private _gltf;
  69432. private _bin;
  69433. private _babylonScene;
  69434. private _rootBabylonMesh;
  69435. private _defaultBabylonMaterialData;
  69436. private _progressCallback?;
  69437. private _requests;
  69438. private static readonly _DefaultSampler;
  69439. private static _ExtensionNames;
  69440. private static _ExtensionFactories;
  69441. /**
  69442. * Registers a loader extension.
  69443. * @param name The name of the loader extension.
  69444. * @param factory The factory function that creates the loader extension.
  69445. */
  69446. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69447. /**
  69448. * Unregisters a loader extension.
  69449. * @param name The name of the loader extenion.
  69450. * @returns A boolean indicating whether the extension has been unregistered
  69451. */
  69452. static UnregisterExtension(name: string): boolean;
  69453. /**
  69454. * Gets the loader state.
  69455. */
  69456. readonly state: Nullable<GLTFLoaderState>;
  69457. /**
  69458. * The object that represents the glTF JSON.
  69459. */
  69460. readonly gltf: IGLTF;
  69461. /**
  69462. * The BIN chunk of a binary glTF.
  69463. */
  69464. readonly bin: Nullable<IDataBuffer>;
  69465. /**
  69466. * The parent file loader.
  69467. */
  69468. readonly parent: GLTFFileLoader;
  69469. /**
  69470. * The Babylon scene when loading the asset.
  69471. */
  69472. readonly babylonScene: Scene;
  69473. /**
  69474. * The root Babylon mesh when loading the asset.
  69475. */
  69476. readonly rootBabylonMesh: Mesh;
  69477. /** @hidden */
  69478. constructor(parent: GLTFFileLoader);
  69479. /** @hidden */
  69480. dispose(): void;
  69481. /** @hidden */
  69482. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69483. meshes: AbstractMesh[];
  69484. particleSystems: IParticleSystem[];
  69485. skeletons: Skeleton[];
  69486. animationGroups: AnimationGroup[];
  69487. }>;
  69488. /** @hidden */
  69489. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69490. private _loadAsync;
  69491. private _loadData;
  69492. private _setupData;
  69493. private _loadExtensions;
  69494. private _checkExtensions;
  69495. private _setState;
  69496. private _createRootNode;
  69497. /**
  69498. * Loads a glTF scene.
  69499. * @param context The context when loading the asset
  69500. * @param scene The glTF scene property
  69501. * @returns A promise that resolves when the load is complete
  69502. */
  69503. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69504. private _forEachPrimitive;
  69505. private _getMeshes;
  69506. private _getSkeletons;
  69507. private _getAnimationGroups;
  69508. private _startAnimations;
  69509. /**
  69510. * Loads a glTF node.
  69511. * @param context The context when loading the asset
  69512. * @param node The glTF node property
  69513. * @param assign A function called synchronously after parsing the glTF properties
  69514. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69515. */
  69516. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69517. private _loadMeshAsync;
  69518. /**
  69519. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69520. * @param context The context when loading the asset
  69521. * @param name The mesh name when loading the asset
  69522. * @param node The glTF node when loading the asset
  69523. * @param mesh The glTF mesh when loading the asset
  69524. * @param primitive The glTF mesh primitive property
  69525. * @param assign A function called synchronously after parsing the glTF properties
  69526. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69527. */
  69528. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69529. private _loadVertexDataAsync;
  69530. private _createMorphTargets;
  69531. private _loadMorphTargetsAsync;
  69532. private _loadMorphTargetVertexDataAsync;
  69533. private static _LoadTransform;
  69534. private _loadSkinAsync;
  69535. private _loadBones;
  69536. private _loadBone;
  69537. private _loadSkinInverseBindMatricesDataAsync;
  69538. private _updateBoneMatrices;
  69539. private _getNodeMatrix;
  69540. /**
  69541. * Loads a glTF camera.
  69542. * @param context The context when loading the asset
  69543. * @param camera The glTF camera property
  69544. * @param assign A function called synchronously after parsing the glTF properties
  69545. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69546. */
  69547. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69548. private _loadAnimationsAsync;
  69549. /**
  69550. * Loads a glTF animation.
  69551. * @param context The context when loading the asset
  69552. * @param animation The glTF animation property
  69553. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69554. */
  69555. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69556. /**
  69557. * @hidden Loads a glTF animation channel.
  69558. * @param context The context when loading the asset
  69559. * @param animationContext The context of the animation when loading the asset
  69560. * @param animation The glTF animation property
  69561. * @param channel The glTF animation channel property
  69562. * @param babylonAnimationGroup The babylon animation group property
  69563. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69564. * @returns A void promise when the channel load is complete
  69565. */
  69566. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69567. private _loadAnimationSamplerAsync;
  69568. private _loadBufferAsync;
  69569. /**
  69570. * Loads a glTF buffer view.
  69571. * @param context The context when loading the asset
  69572. * @param bufferView The glTF buffer view property
  69573. * @returns A promise that resolves with the loaded data when the load is complete
  69574. */
  69575. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69576. private _loadAccessorAsync;
  69577. private _loadFloatAccessorAsync;
  69578. private _loadIndicesAccessorAsync;
  69579. private _loadVertexBufferViewAsync;
  69580. private _loadVertexAccessorAsync;
  69581. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69582. /** @hidden */
  69583. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69584. private _createDefaultMaterial;
  69585. /**
  69586. * Creates a Babylon material from a glTF material.
  69587. * @param context The context when loading the asset
  69588. * @param material The glTF material property
  69589. * @param babylonDrawMode The draw mode for the Babylon material
  69590. * @returns The Babylon material
  69591. */
  69592. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69593. /**
  69594. * Loads properties from a glTF material into a Babylon material.
  69595. * @param context The context when loading the asset
  69596. * @param material The glTF material property
  69597. * @param babylonMaterial The Babylon material
  69598. * @returns A promise that resolves when the load is complete
  69599. */
  69600. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69601. /**
  69602. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69603. * @param context The context when loading the asset
  69604. * @param material The glTF material property
  69605. * @param babylonMaterial The Babylon material
  69606. * @returns A promise that resolves when the load is complete
  69607. */
  69608. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69609. /**
  69610. * Loads the alpha properties from a glTF material into a Babylon material.
  69611. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69612. * @param context The context when loading the asset
  69613. * @param material The glTF material property
  69614. * @param babylonMaterial The Babylon material
  69615. */
  69616. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69617. /**
  69618. * Loads a glTF texture info.
  69619. * @param context The context when loading the asset
  69620. * @param textureInfo The glTF texture info property
  69621. * @param assign A function called synchronously after parsing the glTF properties
  69622. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69623. */
  69624. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69625. private _loadTextureAsync;
  69626. private _loadSampler;
  69627. /**
  69628. * Loads a glTF image.
  69629. * @param context The context when loading the asset
  69630. * @param image The glTF image property
  69631. * @returns A promise that resolves with the loaded data when the load is complete
  69632. */
  69633. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69634. /**
  69635. * Loads a glTF uri.
  69636. * @param context The context when loading the asset
  69637. * @param property The glTF property associated with the uri
  69638. * @param uri The base64 or relative uri
  69639. * @returns A promise that resolves with the loaded data when the load is complete
  69640. */
  69641. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69642. private _onProgress;
  69643. /**
  69644. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69645. * @param babylonObject the Babylon object with metadata
  69646. * @param pointer the JSON pointer
  69647. */
  69648. static AddPointerMetadata(babylonObject: {
  69649. metadata: any;
  69650. }, pointer: string): void;
  69651. private static _GetTextureWrapMode;
  69652. private static _GetTextureSamplingMode;
  69653. private static _GetTypedArrayConstructor;
  69654. private static _GetTypedArray;
  69655. private static _GetNumComponents;
  69656. private static _ValidateUri;
  69657. private static _GetDrawMode;
  69658. private _compileMaterialsAsync;
  69659. private _compileShadowGeneratorsAsync;
  69660. private _forEachExtensions;
  69661. private _applyExtensions;
  69662. private _extensionsOnLoading;
  69663. private _extensionsOnReady;
  69664. private _extensionsLoadSceneAsync;
  69665. private _extensionsLoadNodeAsync;
  69666. private _extensionsLoadCameraAsync;
  69667. private _extensionsLoadVertexDataAsync;
  69668. private _extensionsLoadMeshPrimitiveAsync;
  69669. private _extensionsLoadMaterialAsync;
  69670. private _extensionsCreateMaterial;
  69671. private _extensionsLoadMaterialPropertiesAsync;
  69672. private _extensionsLoadTextureInfoAsync;
  69673. private _extensionsLoadAnimationAsync;
  69674. private _extensionsLoadSkinAsync;
  69675. private _extensionsLoadUriAsync;
  69676. private _extensionsLoadBufferViewAsync;
  69677. private _extensionsLoadBufferAsync;
  69678. /**
  69679. * Helper method called by a loader extension to load an glTF extension.
  69680. * @param context The context when loading the asset
  69681. * @param property The glTF property to load the extension from
  69682. * @param extensionName The name of the extension to load
  69683. * @param actionAsync The action to run
  69684. * @returns The promise returned by actionAsync or null if the extension does not exist
  69685. */
  69686. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69687. /**
  69688. * Helper method called by a loader extension to load a glTF extra.
  69689. * @param context The context when loading the asset
  69690. * @param property The glTF property to load the extra from
  69691. * @param extensionName The name of the extension to load
  69692. * @param actionAsync The action to run
  69693. * @returns The promise returned by actionAsync or null if the extra does not exist
  69694. */
  69695. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69696. /**
  69697. * Checks for presence of an extension.
  69698. * @param name The name of the extension to check
  69699. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  69700. */
  69701. isExtensionUsed(name: string): boolean;
  69702. /**
  69703. * Increments the indentation level and logs a message.
  69704. * @param message The message to log
  69705. */
  69706. logOpen(message: string): void;
  69707. /**
  69708. * Decrements the indentation level.
  69709. */
  69710. logClose(): void;
  69711. /**
  69712. * Logs a message
  69713. * @param message The message to log
  69714. */
  69715. log(message: string): void;
  69716. /**
  69717. * Starts a performance counter.
  69718. * @param counterName The name of the performance counter
  69719. */
  69720. startPerformanceCounter(counterName: string): void;
  69721. /**
  69722. * Ends a performance counter.
  69723. * @param counterName The name of the performance counter
  69724. */
  69725. endPerformanceCounter(counterName: string): void;
  69726. }
  69727. }
  69728. declare module BABYLON.GLTF2.Loader.Extensions {
  69729. /**
  69730. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  69731. */
  69732. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69733. /** The name of this extension. */
  69734. readonly name: string;
  69735. /** Defines whether this extension is enabled. */
  69736. enabled: boolean;
  69737. private _loader;
  69738. private _lights?;
  69739. /** @hidden */
  69740. constructor(loader: GLTFLoader);
  69741. /** @hidden */
  69742. dispose(): void;
  69743. /** @hidden */
  69744. onLoading(): void;
  69745. /** @hidden */
  69746. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69747. private _loadLightAsync;
  69748. }
  69749. }
  69750. declare module BABYLON.GLTF2.Loader.Extensions {
  69751. /**
  69752. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69753. */
  69754. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69755. /** The name of this extension. */
  69756. readonly name: string;
  69757. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69758. dracoCompression?: DracoCompression;
  69759. /** Defines whether this extension is enabled. */
  69760. enabled: boolean;
  69761. private _loader;
  69762. /** @hidden */
  69763. constructor(loader: GLTFLoader);
  69764. /** @hidden */
  69765. dispose(): void;
  69766. /** @hidden */
  69767. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69768. }
  69769. }
  69770. declare module BABYLON.GLTF2.Loader.Extensions {
  69771. /**
  69772. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69773. */
  69774. export class KHR_lights implements IGLTFLoaderExtension {
  69775. /** The name of this extension. */
  69776. readonly name: string;
  69777. /** Defines whether this extension is enabled. */
  69778. enabled: boolean;
  69779. private _loader;
  69780. private _lights?;
  69781. /** @hidden */
  69782. constructor(loader: GLTFLoader);
  69783. /** @hidden */
  69784. dispose(): void;
  69785. /** @hidden */
  69786. onLoading(): void;
  69787. /** @hidden */
  69788. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69789. }
  69790. }
  69791. declare module BABYLON.GLTF2.Loader.Extensions {
  69792. /**
  69793. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69794. */
  69795. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69796. /** The name of this extension. */
  69797. readonly name: string;
  69798. /** Defines whether this extension is enabled. */
  69799. enabled: boolean;
  69800. private _loader;
  69801. /** @hidden */
  69802. constructor(loader: GLTFLoader);
  69803. /** @hidden */
  69804. dispose(): void;
  69805. /** @hidden */
  69806. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69807. private _loadSpecularGlossinessPropertiesAsync;
  69808. }
  69809. }
  69810. declare module BABYLON.GLTF2.Loader.Extensions {
  69811. /**
  69812. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69813. */
  69814. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69815. /** The name of this extension. */
  69816. readonly name: string;
  69817. /** Defines whether this extension is enabled. */
  69818. enabled: boolean;
  69819. private _loader;
  69820. /** @hidden */
  69821. constructor(loader: GLTFLoader);
  69822. /** @hidden */
  69823. dispose(): void;
  69824. /** @hidden */
  69825. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69826. private _loadUnlitPropertiesAsync;
  69827. }
  69828. }
  69829. declare module BABYLON.GLTF2.Loader.Extensions {
  69830. /**
  69831. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69832. */
  69833. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69834. /** The name of this extension. */
  69835. readonly name: string;
  69836. /** Defines whether this extension is enabled. */
  69837. enabled: boolean;
  69838. private _loader;
  69839. /** @hidden */
  69840. constructor(loader: GLTFLoader);
  69841. /** @hidden */
  69842. dispose(): void;
  69843. /** @hidden */
  69844. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69845. }
  69846. }
  69847. declare module BABYLON.GLTF2.Loader.Extensions {
  69848. /**
  69849. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69850. */
  69851. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69852. /** The name of this extension. */
  69853. readonly name: string;
  69854. /** Defines whether this extension is enabled. */
  69855. enabled: boolean;
  69856. private _loader;
  69857. private _clips;
  69858. private _emitters;
  69859. /** @hidden */
  69860. constructor(loader: GLTFLoader);
  69861. /** @hidden */
  69862. dispose(): void;
  69863. /** @hidden */
  69864. onLoading(): void;
  69865. /** @hidden */
  69866. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69867. /** @hidden */
  69868. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69869. /** @hidden */
  69870. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69871. private _loadClipAsync;
  69872. private _loadEmitterAsync;
  69873. private _getEventAction;
  69874. private _loadAnimationEventAsync;
  69875. }
  69876. }
  69877. declare module BABYLON.GLTF2.Loader.Extensions {
  69878. /**
  69879. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69880. */
  69881. export class MSFT_lod implements IGLTFLoaderExtension {
  69882. /** The name of this extension. */
  69883. readonly name: string;
  69884. /** Defines whether this extension is enabled. */
  69885. enabled: boolean;
  69886. /**
  69887. * Maximum number of LODs to load, starting from the lowest LOD.
  69888. */
  69889. maxLODsToLoad: number;
  69890. /**
  69891. * Observable raised when all node LODs of one level are loaded.
  69892. * The event data is the index of the loaded LOD starting from zero.
  69893. * Dispose the loader to cancel the loading of the next level of LODs.
  69894. */
  69895. onNodeLODsLoadedObservable: Observable<number>;
  69896. /**
  69897. * Observable raised when all material LODs of one level are loaded.
  69898. * The event data is the index of the loaded LOD starting from zero.
  69899. * Dispose the loader to cancel the loading of the next level of LODs.
  69900. */
  69901. onMaterialLODsLoadedObservable: Observable<number>;
  69902. private _loader;
  69903. private _nodeIndexLOD;
  69904. private _nodeSignalLODs;
  69905. private _nodePromiseLODs;
  69906. private _materialIndexLOD;
  69907. private _materialSignalLODs;
  69908. private _materialPromiseLODs;
  69909. private _indexLOD;
  69910. private _bufferLODs;
  69911. /** @hidden */
  69912. constructor(loader: GLTFLoader);
  69913. /** @hidden */
  69914. dispose(): void;
  69915. /** @hidden */
  69916. onReady(): void;
  69917. /** @hidden */
  69918. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69919. /** @hidden */
  69920. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69921. /** @hidden */
  69922. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69923. /** @hidden */
  69924. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69925. private _loadBufferLOD;
  69926. /**
  69927. * Gets an array of LOD properties from lowest to highest.
  69928. */
  69929. private _getLODs;
  69930. private _disposeUnusedMaterials;
  69931. }
  69932. }
  69933. declare module BABYLON.GLTF2.Loader.Extensions {
  69934. /** @hidden */
  69935. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69936. readonly name: string;
  69937. enabled: boolean;
  69938. private _loader;
  69939. constructor(loader: GLTFLoader);
  69940. dispose(): void;
  69941. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69942. }
  69943. }
  69944. declare module BABYLON.GLTF2.Loader.Extensions {
  69945. /** @hidden */
  69946. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69947. readonly name: string;
  69948. enabled: boolean;
  69949. private _loader;
  69950. constructor(loader: GLTFLoader);
  69951. dispose(): void;
  69952. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69953. }
  69954. }
  69955. declare module BABYLON.GLTF2.Loader.Extensions {
  69956. /**
  69957. * Store glTF extras (if present) in BJS objects' metadata
  69958. */
  69959. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69960. /** The name of this extension. */
  69961. readonly name: string;
  69962. /** Defines whether this extension is enabled. */
  69963. enabled: boolean;
  69964. private _loader;
  69965. private _assignExtras;
  69966. /** @hidden */
  69967. constructor(loader: GLTFLoader);
  69968. /** @hidden */
  69969. dispose(): void;
  69970. /** @hidden */
  69971. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69972. /** @hidden */
  69973. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69974. /** @hidden */
  69975. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69976. }
  69977. }
  69978. declare module BABYLON {
  69979. /**
  69980. * Class reading and parsing the MTL file bundled with the obj file.
  69981. */
  69982. export class MTLFileLoader {
  69983. /**
  69984. * All material loaded from the mtl will be set here
  69985. */
  69986. materials: StandardMaterial[];
  69987. /**
  69988. * This function will read the mtl file and create each material described inside
  69989. * This function could be improve by adding :
  69990. * -some component missing (Ni, Tf...)
  69991. * -including the specific options available
  69992. *
  69993. * @param scene defines the scene the material will be created in
  69994. * @param data defines the mtl data to parse
  69995. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  69996. */
  69997. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  69998. /**
  69999. * Gets the texture for the material.
  70000. *
  70001. * If the material is imported from input file,
  70002. * We sanitize the url to ensure it takes the textre from aside the material.
  70003. *
  70004. * @param rootUrl The root url to load from
  70005. * @param value The value stored in the mtl
  70006. * @return The Texture
  70007. */
  70008. private static _getTexture;
  70009. }
  70010. /**
  70011. * Options for loading OBJ/MTL files
  70012. */
  70013. type MeshLoadOptions = {
  70014. /**
  70015. * Defines if UVs are optimized by default during load.
  70016. */
  70017. OptimizeWithUV: boolean;
  70018. /**
  70019. * Defines custom scaling of UV coordinates of loaded meshes.
  70020. */
  70021. UVScaling: Vector2;
  70022. /**
  70023. * Invert model on y-axis (does a model scaling inversion)
  70024. */
  70025. InvertY: boolean;
  70026. /**
  70027. * Invert Y-Axis of referenced textures on load
  70028. */
  70029. InvertTextureY: boolean;
  70030. /**
  70031. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70032. */
  70033. ImportVertexColors: boolean;
  70034. /**
  70035. * Compute the normals for the model, even if normals are present in the file.
  70036. */
  70037. ComputeNormals: boolean;
  70038. /**
  70039. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70040. */
  70041. SkipMaterials: boolean;
  70042. /**
  70043. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70044. */
  70045. MaterialLoadingFailsSilently: boolean;
  70046. };
  70047. /**
  70048. * OBJ file type loader.
  70049. * This is a babylon scene loader plugin.
  70050. */
  70051. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70052. /**
  70053. * Defines if UVs are optimized by default during load.
  70054. */
  70055. static OPTIMIZE_WITH_UV: boolean;
  70056. /**
  70057. * Invert model on y-axis (does a model scaling inversion)
  70058. */
  70059. static INVERT_Y: boolean;
  70060. /**
  70061. * Invert Y-Axis of referenced textures on load
  70062. */
  70063. static INVERT_TEXTURE_Y: boolean;
  70064. /**
  70065. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70066. */
  70067. static IMPORT_VERTEX_COLORS: boolean;
  70068. /**
  70069. * Compute the normals for the model, even if normals are present in the file.
  70070. */
  70071. static COMPUTE_NORMALS: boolean;
  70072. /**
  70073. * Defines custom scaling of UV coordinates of loaded meshes.
  70074. */
  70075. static UV_SCALING: Vector2;
  70076. /**
  70077. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70078. */
  70079. static SKIP_MATERIALS: boolean;
  70080. /**
  70081. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70082. *
  70083. * Defaults to true for backwards compatibility.
  70084. */
  70085. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70086. /**
  70087. * Defines the name of the plugin.
  70088. */
  70089. name: string;
  70090. /**
  70091. * Defines the extension the plugin is able to load.
  70092. */
  70093. extensions: string;
  70094. /** @hidden */
  70095. obj: RegExp;
  70096. /** @hidden */
  70097. group: RegExp;
  70098. /** @hidden */
  70099. mtllib: RegExp;
  70100. /** @hidden */
  70101. usemtl: RegExp;
  70102. /** @hidden */
  70103. smooth: RegExp;
  70104. /** @hidden */
  70105. vertexPattern: RegExp;
  70106. /** @hidden */
  70107. normalPattern: RegExp;
  70108. /** @hidden */
  70109. uvPattern: RegExp;
  70110. /** @hidden */
  70111. facePattern1: RegExp;
  70112. /** @hidden */
  70113. facePattern2: RegExp;
  70114. /** @hidden */
  70115. facePattern3: RegExp;
  70116. /** @hidden */
  70117. facePattern4: RegExp;
  70118. /** @hidden */
  70119. facePattern5: RegExp;
  70120. private _meshLoadOptions;
  70121. /**
  70122. * Creates loader for .OBJ files
  70123. *
  70124. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70125. */
  70126. constructor(meshLoadOptions?: MeshLoadOptions);
  70127. private static readonly currentMeshLoadOptions;
  70128. /**
  70129. * Calls synchronously the MTL file attached to this obj.
  70130. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70131. * Without this function materials are not displayed in the first frame (but displayed after).
  70132. * In consequence it is impossible to get material information in your HTML file
  70133. *
  70134. * @param url The URL of the MTL file
  70135. * @param rootUrl
  70136. * @param onSuccess Callback function to be called when the MTL file is loaded
  70137. * @private
  70138. */
  70139. private _loadMTL;
  70140. /**
  70141. * Instantiates a OBJ file loader plugin.
  70142. * @returns the created plugin
  70143. */
  70144. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70145. /**
  70146. * If the data string can be loaded directly.
  70147. *
  70148. * @param data string containing the file data
  70149. * @returns if the data can be loaded directly
  70150. */
  70151. canDirectLoad(data: string): boolean;
  70152. /**
  70153. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70154. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70155. * @param scene the scene the meshes should be added to
  70156. * @param data the OBJ data to load
  70157. * @param rootUrl root url to load from
  70158. * @param onProgress event that fires when loading progress has occured
  70159. * @param fileName Defines the name of the file to load
  70160. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70161. */
  70162. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70163. meshes: AbstractMesh[];
  70164. particleSystems: IParticleSystem[];
  70165. skeletons: Skeleton[];
  70166. animationGroups: AnimationGroup[];
  70167. }>;
  70168. /**
  70169. * Imports all objects from the loaded OBJ data and adds them to the scene
  70170. * @param scene the scene the objects should be added to
  70171. * @param data the OBJ data to load
  70172. * @param rootUrl root url to load from
  70173. * @param onProgress event that fires when loading progress has occured
  70174. * @param fileName Defines the name of the file to load
  70175. * @returns a promise which completes when objects have been loaded to the scene
  70176. */
  70177. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70178. /**
  70179. * Load into an asset container.
  70180. * @param scene The scene to load into
  70181. * @param data The data to import
  70182. * @param rootUrl The root url for scene and resources
  70183. * @param onProgress The callback when the load progresses
  70184. * @param fileName Defines the name of the file to load
  70185. * @returns The loaded asset container
  70186. */
  70187. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70188. /**
  70189. * Read the OBJ file and create an Array of meshes.
  70190. * Each mesh contains all information given by the OBJ and the MTL file.
  70191. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70192. *
  70193. * @param meshesNames
  70194. * @param scene Scene The scene where are displayed the data
  70195. * @param data String The content of the obj file
  70196. * @param rootUrl String The path to the folder
  70197. * @returns Array<AbstractMesh>
  70198. * @private
  70199. */
  70200. private _parseSolid;
  70201. }
  70202. }
  70203. declare module BABYLON {
  70204. /**
  70205. * STL file type loader.
  70206. * This is a babylon scene loader plugin.
  70207. */
  70208. export class STLFileLoader implements ISceneLoaderPlugin {
  70209. /** @hidden */
  70210. solidPattern: RegExp;
  70211. /** @hidden */
  70212. facetsPattern: RegExp;
  70213. /** @hidden */
  70214. normalPattern: RegExp;
  70215. /** @hidden */
  70216. vertexPattern: RegExp;
  70217. /**
  70218. * Defines the name of the plugin.
  70219. */
  70220. name: string;
  70221. /**
  70222. * Defines the extensions the stl loader is able to load.
  70223. * force data to come in as an ArrayBuffer
  70224. * we'll convert to string if it looks like it's an ASCII .stl
  70225. */
  70226. extensions: ISceneLoaderPluginExtensions;
  70227. /**
  70228. * Import meshes into a scene.
  70229. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70230. * @param scene The scene to import into
  70231. * @param data The data to import
  70232. * @param rootUrl The root url for scene and resources
  70233. * @param meshes The meshes array to import into
  70234. * @param particleSystems The particle systems array to import into
  70235. * @param skeletons The skeletons array to import into
  70236. * @param onError The callback when import fails
  70237. * @returns True if successful or false otherwise
  70238. */
  70239. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70240. /**
  70241. * Load into a scene.
  70242. * @param scene The scene to load into
  70243. * @param data The data to import
  70244. * @param rootUrl The root url for scene and resources
  70245. * @param onError The callback when import fails
  70246. * @returns true if successful or false otherwise
  70247. */
  70248. load(scene: Scene, data: any, rootUrl: string): boolean;
  70249. /**
  70250. * Load into an asset container.
  70251. * @param scene The scene to load into
  70252. * @param data The data to import
  70253. * @param rootUrl The root url for scene and resources
  70254. * @param onError The callback when import fails
  70255. * @returns The loaded asset container
  70256. */
  70257. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70258. private _isBinary;
  70259. private _parseBinary;
  70260. private _parseASCII;
  70261. }
  70262. }
  70263. declare module BABYLON {
  70264. /**
  70265. * Class for generating OBJ data from a Babylon scene.
  70266. */
  70267. export class OBJExport {
  70268. /**
  70269. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70270. * @param mesh defines the list of meshes to serialize
  70271. * @param materials defines if materials should be exported
  70272. * @param matlibname defines the name of the associated mtl file
  70273. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70274. * @returns the OBJ content
  70275. */
  70276. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70277. /**
  70278. * Exports the material(s) of a mesh in .MTL file format (text)
  70279. * @param mesh defines the mesh to extract the material from
  70280. * @returns the mtl content
  70281. */
  70282. static MTL(mesh: Mesh): string;
  70283. }
  70284. }
  70285. declare module BABYLON {
  70286. /** @hidden */
  70287. export var __IGLTFExporterExtension: number;
  70288. /**
  70289. * Interface for extending the exporter
  70290. * @hidden
  70291. */
  70292. export interface IGLTFExporterExtension {
  70293. /**
  70294. * The name of this extension
  70295. */
  70296. readonly name: string;
  70297. /**
  70298. * Defines whether this extension is enabled
  70299. */
  70300. enabled: boolean;
  70301. /**
  70302. * Defines whether this extension is required
  70303. */
  70304. required: boolean;
  70305. }
  70306. }
  70307. declare module BABYLON.GLTF2.Exporter {
  70308. /** @hidden */
  70309. export var __IGLTFExporterExtensionV2: number;
  70310. /**
  70311. * Interface for a glTF exporter extension
  70312. * @hidden
  70313. */
  70314. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70315. /**
  70316. * Define this method to modify the default behavior before exporting a texture
  70317. * @param context The context when loading the asset
  70318. * @param babylonTexture The glTF texture info property
  70319. * @param mimeType The mime-type of the generated image
  70320. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70321. */
  70322. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70323. /**
  70324. * Define this method to modify the default behavior when exporting texture info
  70325. * @param context The context when loading the asset
  70326. * @param meshPrimitive glTF mesh primitive
  70327. * @param babylonSubMesh Babylon submesh
  70328. * @param binaryWriter glTF serializer binary writer instance
  70329. * @returns nullable IMeshPrimitive promise
  70330. */
  70331. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70332. /**
  70333. * Define this method to modify the default behavior when exporting a node
  70334. * @param context The context when exporting the node
  70335. * @param node glTF node
  70336. * @param babylonNode BabylonJS node
  70337. * @returns nullable INode promise
  70338. */
  70339. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70340. /**
  70341. * Called after the exporter state changes to EXPORTING
  70342. */
  70343. onExporting?(): void;
  70344. }
  70345. }
  70346. declare module BABYLON.GLTF2.Exporter {
  70347. /**
  70348. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70349. * @hidden
  70350. */
  70351. export class _GLTFMaterialExporter {
  70352. /**
  70353. * Represents the dielectric specular values for R, G and B
  70354. */
  70355. private static readonly _DielectricSpecular;
  70356. /**
  70357. * Allows the maximum specular power to be defined for material calculations
  70358. */
  70359. private static readonly _MaxSpecularPower;
  70360. /**
  70361. * Mapping to store textures
  70362. */
  70363. private _textureMap;
  70364. /**
  70365. * Numeric tolerance value
  70366. */
  70367. private static readonly _Epsilon;
  70368. /**
  70369. * Reference to the glTF Exporter
  70370. */
  70371. private _exporter;
  70372. constructor(exporter: _Exporter);
  70373. /**
  70374. * Specifies if two colors are approximately equal in value
  70375. * @param color1 first color to compare to
  70376. * @param color2 second color to compare to
  70377. * @param epsilon threshold value
  70378. */
  70379. private static FuzzyEquals;
  70380. /**
  70381. * Gets the materials from a Babylon scene and converts them to glTF materials
  70382. * @param scene babylonjs scene
  70383. * @param mimeType texture mime type
  70384. * @param images array of images
  70385. * @param textures array of textures
  70386. * @param materials array of materials
  70387. * @param imageData mapping of texture names to base64 textures
  70388. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70389. */
  70390. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70391. /**
  70392. * Makes a copy of the glTF material without the texture parameters
  70393. * @param originalMaterial original glTF material
  70394. * @returns glTF material without texture parameters
  70395. */
  70396. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70397. /**
  70398. * Specifies if the material has any texture parameters present
  70399. * @param material glTF Material
  70400. * @returns boolean specifying if texture parameters are present
  70401. */
  70402. _hasTexturesPresent(material: IMaterial): boolean;
  70403. /**
  70404. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70405. * @param babylonStandardMaterial
  70406. * @returns glTF Metallic Roughness Material representation
  70407. */
  70408. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70409. /**
  70410. * Computes the metallic factor
  70411. * @param diffuse diffused value
  70412. * @param specular specular value
  70413. * @param oneMinusSpecularStrength one minus the specular strength
  70414. * @returns metallic value
  70415. */
  70416. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70417. /**
  70418. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70419. * @param glTFMaterial glTF material
  70420. * @param babylonMaterial Babylon material
  70421. */
  70422. private static _SetAlphaMode;
  70423. /**
  70424. * Converts a Babylon Standard Material to a glTF Material
  70425. * @param babylonStandardMaterial BJS Standard Material
  70426. * @param mimeType mime type to use for the textures
  70427. * @param images array of glTF image interfaces
  70428. * @param textures array of glTF texture interfaces
  70429. * @param materials array of glTF material interfaces
  70430. * @param imageData map of image file name to data
  70431. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70432. */
  70433. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70434. /**
  70435. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70436. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70437. * @param mimeType mime type to use for the textures
  70438. * @param images array of glTF image interfaces
  70439. * @param textures array of glTF texture interfaces
  70440. * @param materials array of glTF material interfaces
  70441. * @param imageData map of image file name to data
  70442. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70443. */
  70444. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70445. /**
  70446. * Converts an image typed array buffer to a base64 image
  70447. * @param buffer typed array buffer
  70448. * @param width width of the image
  70449. * @param height height of the image
  70450. * @param mimeType mimetype of the image
  70451. * @returns base64 image string
  70452. */
  70453. private _createBase64FromCanvasAsync;
  70454. /**
  70455. * Generates a white texture based on the specified width and height
  70456. * @param width width of the texture in pixels
  70457. * @param height height of the texture in pixels
  70458. * @param scene babylonjs scene
  70459. * @returns white texture
  70460. */
  70461. private _createWhiteTexture;
  70462. /**
  70463. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  70464. * @param texture1 first texture to resize
  70465. * @param texture2 second texture to resize
  70466. * @param scene babylonjs scene
  70467. * @returns resized textures or null
  70468. */
  70469. private _resizeTexturesToSameDimensions;
  70470. /**
  70471. * Converts an array of pixels to a Float32Array
  70472. * Throws an error if the pixel format is not supported
  70473. * @param pixels - array buffer containing pixel values
  70474. * @returns Float32 of pixels
  70475. */
  70476. private _convertPixelArrayToFloat32;
  70477. /**
  70478. * Convert Specular Glossiness Textures to Metallic Roughness
  70479. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70480. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70481. * @param diffuseTexture texture used to store diffuse information
  70482. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70483. * @param factors specular glossiness material factors
  70484. * @param mimeType the mime type to use for the texture
  70485. * @returns pbr metallic roughness interface or null
  70486. */
  70487. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70488. /**
  70489. * Converts specular glossiness material properties to metallic roughness
  70490. * @param specularGlossiness interface with specular glossiness material properties
  70491. * @returns interface with metallic roughness material properties
  70492. */
  70493. private _convertSpecularGlossinessToMetallicRoughness;
  70494. /**
  70495. * Calculates the surface reflectance, independent of lighting conditions
  70496. * @param color Color source to calculate brightness from
  70497. * @returns number representing the perceived brightness, or zero if color is undefined
  70498. */
  70499. private _getPerceivedBrightness;
  70500. /**
  70501. * Returns the maximum color component value
  70502. * @param color
  70503. * @returns maximum color component value, or zero if color is null or undefined
  70504. */
  70505. private _getMaxComponent;
  70506. /**
  70507. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70508. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70509. * @param mimeType mime type to use for the textures
  70510. * @param images array of glTF image interfaces
  70511. * @param textures array of glTF texture interfaces
  70512. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70513. * @param imageData map of image file name to data
  70514. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70515. * @returns glTF PBR Metallic Roughness factors
  70516. */
  70517. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70518. private _getGLTFTextureSampler;
  70519. private _getGLTFTextureWrapMode;
  70520. private _getGLTFTextureWrapModesSampler;
  70521. /**
  70522. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70523. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70524. * @param mimeType mime type to use for the textures
  70525. * @param images array of glTF image interfaces
  70526. * @param textures array of glTF texture interfaces
  70527. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70528. * @param imageData map of image file name to data
  70529. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70530. * @returns glTF PBR Metallic Roughness factors
  70531. */
  70532. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70533. /**
  70534. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70535. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70536. * @param mimeType mime type to use for the textures
  70537. * @param images array of glTF image interfaces
  70538. * @param textures array of glTF texture interfaces
  70539. * @param materials array of glTF material interfaces
  70540. * @param imageData map of image file name to data
  70541. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70542. */
  70543. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70544. private setMetallicRoughnessPbrMaterial;
  70545. private getPixelsFromTexture;
  70546. /**
  70547. * Extracts a texture from a Babylon texture into file data and glTF data
  70548. * @param babylonTexture Babylon texture to extract
  70549. * @param mimeType Mime Type of the babylonTexture
  70550. * @return glTF texture info, or null if the texture format is not supported
  70551. */
  70552. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70553. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70554. /**
  70555. * Builds a texture from base64 string
  70556. * @param base64Texture base64 texture string
  70557. * @param baseTextureName Name to use for the texture
  70558. * @param mimeType image mime type for the texture
  70559. * @param images array of images
  70560. * @param textures array of textures
  70561. * @param imageData map of image data
  70562. * @returns glTF texture info, or null if the texture format is not supported
  70563. */
  70564. private _getTextureInfoFromBase64;
  70565. }
  70566. }
  70567. declare module BABYLON {
  70568. /**
  70569. * Class for holding and downloading glTF file data
  70570. */
  70571. export class GLTFData {
  70572. /**
  70573. * Object which contains the file name as the key and its data as the value
  70574. */
  70575. glTFFiles: {
  70576. [fileName: string]: string | Blob;
  70577. };
  70578. /**
  70579. * Initializes the glTF file object
  70580. */
  70581. constructor();
  70582. /**
  70583. * Downloads the glTF data as files based on their names and data
  70584. */
  70585. downloadFiles(): void;
  70586. }
  70587. }
  70588. declare module BABYLON {
  70589. /**
  70590. * Holds a collection of exporter options and parameters
  70591. */
  70592. export interface IExportOptions {
  70593. /**
  70594. * Function which indicates whether a babylon node should be exported or not
  70595. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70596. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70597. */
  70598. shouldExportNode?(node: Node): boolean;
  70599. /**
  70600. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70601. * @param metadata source metadata to read from
  70602. * @returns the data to store to glTF node extras
  70603. */
  70604. metadataSelector?(metadata: any): any;
  70605. /**
  70606. * The sample rate to bake animation curves
  70607. */
  70608. animationSampleRate?: number;
  70609. /**
  70610. * Begin serialization without waiting for the scene to be ready
  70611. */
  70612. exportWithoutWaitingForScene?: boolean;
  70613. }
  70614. /**
  70615. * Class for generating glTF data from a Babylon scene.
  70616. */
  70617. export class GLTF2Export {
  70618. /**
  70619. * Exports the geometry of the scene to .gltf file format asynchronously
  70620. * @param scene Babylon scene with scene hierarchy information
  70621. * @param filePrefix File prefix to use when generating the glTF file
  70622. * @param options Exporter options
  70623. * @returns Returns an object with a .gltf file and associates texture names
  70624. * as keys and their data and paths as values
  70625. */
  70626. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70627. private static _PreExportAsync;
  70628. private static _PostExportAsync;
  70629. /**
  70630. * Exports the geometry of the scene to .glb file format asychronously
  70631. * @param scene Babylon scene with scene hierarchy information
  70632. * @param filePrefix File prefix to use when generating glb file
  70633. * @param options Exporter options
  70634. * @returns Returns an object with a .glb filename as key and data as value
  70635. */
  70636. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70637. }
  70638. }
  70639. declare module BABYLON.GLTF2.Exporter {
  70640. /**
  70641. * @hidden
  70642. */
  70643. export class _GLTFUtilities {
  70644. /**
  70645. * Creates a buffer view based on the supplied arguments
  70646. * @param bufferIndex index value of the specified buffer
  70647. * @param byteOffset byte offset value
  70648. * @param byteLength byte length of the bufferView
  70649. * @param byteStride byte distance between conequential elements
  70650. * @param name name of the buffer view
  70651. * @returns bufferView for glTF
  70652. */
  70653. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70654. /**
  70655. * Creates an accessor based on the supplied arguments
  70656. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70657. * @param name The name of the accessor
  70658. * @param type The type of the accessor
  70659. * @param componentType The datatype of components in the attribute
  70660. * @param count The number of attributes referenced by this accessor
  70661. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70662. * @param min Minimum value of each component in this attribute
  70663. * @param max Maximum value of each component in this attribute
  70664. * @returns accessor for glTF
  70665. */
  70666. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70667. /**
  70668. * Calculates the minimum and maximum values of an array of position floats
  70669. * @param positions Positions array of a mesh
  70670. * @param vertexStart Starting vertex offset to calculate min and max values
  70671. * @param vertexCount Number of vertices to check for min and max values
  70672. * @returns min number array and max number array
  70673. */
  70674. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70675. min: number[];
  70676. max: number[];
  70677. };
  70678. /**
  70679. * Converts a new right-handed Vector3
  70680. * @param vector vector3 array
  70681. * @returns right-handed Vector3
  70682. */
  70683. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70684. /**
  70685. * Converts a Vector3 to right-handed
  70686. * @param vector Vector3 to convert to right-handed
  70687. */
  70688. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70689. /**
  70690. * Converts a three element number array to right-handed
  70691. * @param vector number array to convert to right-handed
  70692. */
  70693. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70694. /**
  70695. * Converts a new right-handed Vector3
  70696. * @param vector vector3 array
  70697. * @returns right-handed Vector3
  70698. */
  70699. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70700. /**
  70701. * Converts a Vector3 to right-handed
  70702. * @param vector Vector3 to convert to right-handed
  70703. */
  70704. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70705. /**
  70706. * Converts a three element number array to right-handed
  70707. * @param vector number array to convert to right-handed
  70708. */
  70709. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70710. /**
  70711. * Converts a Vector4 to right-handed
  70712. * @param vector Vector4 to convert to right-handed
  70713. */
  70714. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70715. /**
  70716. * Converts a Vector4 to right-handed
  70717. * @param vector Vector4 to convert to right-handed
  70718. */
  70719. static _GetRightHandedArray4FromRef(vector: number[]): void;
  70720. /**
  70721. * Converts a Quaternion to right-handed
  70722. * @param quaternion Source quaternion to convert to right-handed
  70723. */
  70724. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70725. /**
  70726. * Converts a Quaternion to right-handed
  70727. * @param quaternion Source quaternion to convert to right-handed
  70728. */
  70729. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  70730. static _NormalizeTangentFromRef(tangent: Vector4): void;
  70731. }
  70732. }
  70733. declare module BABYLON.GLTF2.Exporter {
  70734. /**
  70735. * Converts Babylon Scene into glTF 2.0.
  70736. * @hidden
  70737. */
  70738. export class _Exporter {
  70739. /**
  70740. * Stores the glTF to export
  70741. */
  70742. _glTF: IGLTF;
  70743. /**
  70744. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70745. */
  70746. _bufferViews: IBufferView[];
  70747. /**
  70748. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70749. */
  70750. _accessors: IAccessor[];
  70751. /**
  70752. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70753. */
  70754. private _nodes;
  70755. /**
  70756. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70757. */
  70758. private _scenes;
  70759. /**
  70760. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70761. */
  70762. private _meshes;
  70763. /**
  70764. * Stores all the generated material information, which represents the appearance of each primitive
  70765. */
  70766. _materials: IMaterial[];
  70767. _materialMap: {
  70768. [materialID: number]: number;
  70769. };
  70770. /**
  70771. * Stores all the generated texture information, which is referenced by glTF materials
  70772. */
  70773. _textures: ITexture[];
  70774. /**
  70775. * Stores all the generated image information, which is referenced by glTF textures
  70776. */
  70777. _images: IImage[];
  70778. /**
  70779. * Stores all the texture samplers
  70780. */
  70781. _samplers: ISampler[];
  70782. /**
  70783. * Stores all the generated animation samplers, which is referenced by glTF animations
  70784. */
  70785. /**
  70786. * Stores the animations for glTF models
  70787. */
  70788. private _animations;
  70789. /**
  70790. * Stores the total amount of bytes stored in the glTF buffer
  70791. */
  70792. private _totalByteLength;
  70793. /**
  70794. * Stores a reference to the Babylon scene containing the source geometry and material information
  70795. */
  70796. _babylonScene: Scene;
  70797. /**
  70798. * Stores a map of the image data, where the key is the file name and the value
  70799. * is the image data
  70800. */
  70801. _imageData: {
  70802. [fileName: string]: {
  70803. data: Uint8Array;
  70804. mimeType: ImageMimeType;
  70805. };
  70806. };
  70807. /**
  70808. * Stores a map of the unique id of a node to its index in the node array
  70809. */
  70810. private _nodeMap;
  70811. /**
  70812. * Specifies if the Babylon scene should be converted to right-handed on export
  70813. */
  70814. _convertToRightHandedSystem: boolean;
  70815. /**
  70816. * Baked animation sample rate
  70817. */
  70818. private _animationSampleRate;
  70819. private _options;
  70820. private _localEngine;
  70821. _glTFMaterialExporter: _GLTFMaterialExporter;
  70822. private _extensions;
  70823. private static _ExtensionNames;
  70824. private static _ExtensionFactories;
  70825. private _applyExtensions;
  70826. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70827. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70828. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70829. private _forEachExtensions;
  70830. private _extensionsOnExporting;
  70831. /**
  70832. * Load glTF serializer extensions
  70833. */
  70834. private _loadExtensions;
  70835. /**
  70836. * Creates a glTF Exporter instance, which can accept optional exporter options
  70837. * @param babylonScene Babylon scene object
  70838. * @param options Options to modify the behavior of the exporter
  70839. */
  70840. constructor(babylonScene: Scene, options?: IExportOptions);
  70841. /**
  70842. * Registers a glTF exporter extension
  70843. * @param name Name of the extension to export
  70844. * @param factory The factory function that creates the exporter extension
  70845. */
  70846. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70847. /**
  70848. * Un-registers an exporter extension
  70849. * @param name The name fo the exporter extension
  70850. * @returns A boolean indicating whether the extension has been un-registered
  70851. */
  70852. static UnregisterExtension(name: string): boolean;
  70853. /**
  70854. * Lazy load a local engine with premultiplied alpha set to false
  70855. */
  70856. _getLocalEngine(): Engine;
  70857. private reorderIndicesBasedOnPrimitiveMode;
  70858. /**
  70859. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70860. * clock-wise during export to glTF
  70861. * @param submesh BabylonJS submesh
  70862. * @param primitiveMode Primitive mode of the mesh
  70863. * @param sideOrientation the winding order of the submesh
  70864. * @param vertexBufferKind The type of vertex attribute
  70865. * @param meshAttributeArray The vertex attribute data
  70866. * @param byteOffset The offset to the binary data
  70867. * @param binaryWriter The binary data for the glTF file
  70868. */
  70869. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70870. /**
  70871. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70872. * clock-wise during export to glTF
  70873. * @param submesh BabylonJS submesh
  70874. * @param primitiveMode Primitive mode of the mesh
  70875. * @param sideOrientation the winding order of the submesh
  70876. * @param vertexBufferKind The type of vertex attribute
  70877. * @param meshAttributeArray The vertex attribute data
  70878. * @param byteOffset The offset to the binary data
  70879. * @param binaryWriter The binary data for the glTF file
  70880. */
  70881. private reorderTriangleFillMode;
  70882. /**
  70883. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70884. * clock-wise during export to glTF
  70885. * @param submesh BabylonJS submesh
  70886. * @param primitiveMode Primitive mode of the mesh
  70887. * @param sideOrientation the winding order of the submesh
  70888. * @param vertexBufferKind The type of vertex attribute
  70889. * @param meshAttributeArray The vertex attribute data
  70890. * @param byteOffset The offset to the binary data
  70891. * @param binaryWriter The binary data for the glTF file
  70892. */
  70893. private reorderTriangleStripDrawMode;
  70894. /**
  70895. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70896. * clock-wise during export to glTF
  70897. * @param submesh BabylonJS submesh
  70898. * @param primitiveMode Primitive mode of the mesh
  70899. * @param sideOrientation the winding order of the submesh
  70900. * @param vertexBufferKind The type of vertex attribute
  70901. * @param meshAttributeArray The vertex attribute data
  70902. * @param byteOffset The offset to the binary data
  70903. * @param binaryWriter The binary data for the glTF file
  70904. */
  70905. private reorderTriangleFanMode;
  70906. /**
  70907. * Writes the vertex attribute data to binary
  70908. * @param vertices The vertices to write to the binary writer
  70909. * @param byteOffset The offset into the binary writer to overwrite binary data
  70910. * @param vertexAttributeKind The vertex attribute type
  70911. * @param meshAttributeArray The vertex attribute data
  70912. * @param binaryWriter The writer containing the binary data
  70913. */
  70914. private writeVertexAttributeData;
  70915. /**
  70916. * Writes mesh attribute data to a data buffer
  70917. * Returns the bytelength of the data
  70918. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70919. * @param meshAttributeArray Array containing the attribute data
  70920. * @param binaryWriter The buffer to write the binary data to
  70921. * @param indices Used to specify the order of the vertex data
  70922. */
  70923. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70924. /**
  70925. * Generates glTF json data
  70926. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70927. * @param glTFPrefix Text to use when prefixing a glTF file
  70928. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70929. * @returns json data as string
  70930. */
  70931. private generateJSON;
  70932. /**
  70933. * Generates data for .gltf and .bin files based on the glTF prefix string
  70934. * @param glTFPrefix Text to use when prefixing a glTF file
  70935. * @returns GLTFData with glTF file data
  70936. */
  70937. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70938. /**
  70939. * Creates a binary buffer for glTF
  70940. * @returns array buffer for binary data
  70941. */
  70942. private _generateBinaryAsync;
  70943. /**
  70944. * Pads the number to a multiple of 4
  70945. * @param num number to pad
  70946. * @returns padded number
  70947. */
  70948. private _getPadding;
  70949. /**
  70950. * Generates a glb file from the json and binary data
  70951. * Returns an object with the glb file name as the key and data as the value
  70952. * @param glTFPrefix
  70953. * @returns object with glb filename as key and data as value
  70954. */
  70955. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70956. /**
  70957. * Sets the TRS for each node
  70958. * @param node glTF Node for storing the transformation data
  70959. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70960. */
  70961. private setNodeTransformation;
  70962. private getVertexBufferFromMesh;
  70963. /**
  70964. * Creates a bufferview based on the vertices type for the Babylon mesh
  70965. * @param kind Indicates the type of vertices data
  70966. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70967. * @param binaryWriter The buffer to write the bufferview data to
  70968. */
  70969. private createBufferViewKind;
  70970. /**
  70971. * The primitive mode of the Babylon mesh
  70972. * @param babylonMesh The BabylonJS mesh
  70973. */
  70974. private getMeshPrimitiveMode;
  70975. /**
  70976. * Sets the primitive mode of the glTF mesh primitive
  70977. * @param meshPrimitive glTF mesh primitive
  70978. * @param primitiveMode The primitive mode
  70979. */
  70980. private setPrimitiveMode;
  70981. /**
  70982. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70983. * @param meshPrimitive glTF mesh primitive
  70984. * @param attributeKind vertex attribute
  70985. * @returns boolean specifying if uv coordinates are present
  70986. */
  70987. private setAttributeKind;
  70988. /**
  70989. * Sets data for the primitive attributes of each submesh
  70990. * @param mesh glTF Mesh object to store the primitive attribute information
  70991. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70992. * @param binaryWriter Buffer to write the attribute data to
  70993. */
  70994. private setPrimitiveAttributesAsync;
  70995. /**
  70996. * Creates a glTF scene based on the array of meshes
  70997. * Returns the the total byte offset
  70998. * @param babylonScene Babylon scene to get the mesh data from
  70999. * @param binaryWriter Buffer to write binary data to
  71000. */
  71001. private createSceneAsync;
  71002. /**
  71003. * Creates a mapping of Node unique id to node index and handles animations
  71004. * @param babylonScene Babylon Scene
  71005. * @param nodes Babylon transform nodes
  71006. * @param binaryWriter Buffer to write binary data to
  71007. * @returns Node mapping of unique id to index
  71008. */
  71009. private createNodeMapAndAnimationsAsync;
  71010. /**
  71011. * Creates a glTF node from a Babylon mesh
  71012. * @param babylonMesh Source Babylon mesh
  71013. * @param binaryWriter Buffer for storing geometry data
  71014. * @returns glTF node
  71015. */
  71016. private createNodeAsync;
  71017. }
  71018. /**
  71019. * @hidden
  71020. *
  71021. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71022. */
  71023. export class _BinaryWriter {
  71024. /**
  71025. * Array buffer which stores all binary data
  71026. */
  71027. private _arrayBuffer;
  71028. /**
  71029. * View of the array buffer
  71030. */
  71031. private _dataView;
  71032. /**
  71033. * byte offset of data in array buffer
  71034. */
  71035. private _byteOffset;
  71036. /**
  71037. * Initialize binary writer with an initial byte length
  71038. * @param byteLength Initial byte length of the array buffer
  71039. */
  71040. constructor(byteLength: number);
  71041. /**
  71042. * Resize the array buffer to the specified byte length
  71043. * @param byteLength
  71044. */
  71045. private resizeBuffer;
  71046. /**
  71047. * Get an array buffer with the length of the byte offset
  71048. * @returns ArrayBuffer resized to the byte offset
  71049. */
  71050. getArrayBuffer(): ArrayBuffer;
  71051. /**
  71052. * Get the byte offset of the array buffer
  71053. * @returns byte offset
  71054. */
  71055. getByteOffset(): number;
  71056. /**
  71057. * Stores an UInt8 in the array buffer
  71058. * @param entry
  71059. * @param byteOffset If defined, specifies where to set the value as an offset.
  71060. */
  71061. setUInt8(entry: number, byteOffset?: number): void;
  71062. /**
  71063. * Gets an UInt32 in the array buffer
  71064. * @param entry
  71065. * @param byteOffset If defined, specifies where to set the value as an offset.
  71066. */
  71067. getUInt32(byteOffset: number): number;
  71068. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71069. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71070. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71071. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71072. /**
  71073. * Stores a Float32 in the array buffer
  71074. * @param entry
  71075. */
  71076. setFloat32(entry: number, byteOffset?: number): void;
  71077. /**
  71078. * Stores an UInt32 in the array buffer
  71079. * @param entry
  71080. * @param byteOffset If defined, specifies where to set the value as an offset.
  71081. */
  71082. setUInt32(entry: number, byteOffset?: number): void;
  71083. }
  71084. }
  71085. declare module BABYLON.GLTF2.Exporter {
  71086. /**
  71087. * @hidden
  71088. * Interface to store animation data.
  71089. */
  71090. export interface _IAnimationData {
  71091. /**
  71092. * Keyframe data.
  71093. */
  71094. inputs: number[];
  71095. /**
  71096. * Value data.
  71097. */
  71098. outputs: number[][];
  71099. /**
  71100. * Animation interpolation data.
  71101. */
  71102. samplerInterpolation: AnimationSamplerInterpolation;
  71103. /**
  71104. * Minimum keyframe value.
  71105. */
  71106. inputsMin: number;
  71107. /**
  71108. * Maximum keyframe value.
  71109. */
  71110. inputsMax: number;
  71111. }
  71112. /**
  71113. * @hidden
  71114. */
  71115. export interface _IAnimationInfo {
  71116. /**
  71117. * The target channel for the animation
  71118. */
  71119. animationChannelTargetPath: AnimationChannelTargetPath;
  71120. /**
  71121. * The glTF accessor type for the data.
  71122. */
  71123. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71124. /**
  71125. * Specifies if quaternions should be used.
  71126. */
  71127. useQuaternion: boolean;
  71128. }
  71129. /**
  71130. * @hidden
  71131. * Utility class for generating glTF animation data from BabylonJS.
  71132. */
  71133. export class _GLTFAnimation {
  71134. /**
  71135. * @ignore
  71136. *
  71137. * Creates glTF channel animation from BabylonJS animation.
  71138. * @param babylonTransformNode - BabylonJS mesh.
  71139. * @param animation - animation.
  71140. * @param animationChannelTargetPath - The target animation channel.
  71141. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71142. * @param useQuaternion - Specifies if quaternions are used.
  71143. * @returns nullable IAnimationData
  71144. */
  71145. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71146. private static _DeduceAnimationInfo;
  71147. /**
  71148. * @ignore
  71149. * Create node animations from the transform node animations
  71150. * @param babylonNode
  71151. * @param runtimeGLTFAnimation
  71152. * @param idleGLTFAnimations
  71153. * @param nodeMap
  71154. * @param nodes
  71155. * @param binaryWriter
  71156. * @param bufferViews
  71157. * @param accessors
  71158. * @param convertToRightHandedSystem
  71159. */
  71160. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71161. [key: number]: number;
  71162. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71163. /**
  71164. * @ignore
  71165. * Create node animations from the animation groups
  71166. * @param babylonScene
  71167. * @param glTFAnimations
  71168. * @param nodeMap
  71169. * @param nodes
  71170. * @param binaryWriter
  71171. * @param bufferViews
  71172. * @param accessors
  71173. * @param convertToRightHandedSystem
  71174. */
  71175. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71176. [key: number]: number;
  71177. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71178. private static AddAnimation;
  71179. /**
  71180. * Create a baked animation
  71181. * @param babylonTransformNode BabylonJS mesh
  71182. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71183. * @param animationChannelTargetPath animation target channel
  71184. * @param minFrame minimum animation frame
  71185. * @param maxFrame maximum animation frame
  71186. * @param fps frames per second of the animation
  71187. * @param inputs input key frames of the animation
  71188. * @param outputs output key frame data of the animation
  71189. * @param convertToRightHandedSystem converts the values to right-handed
  71190. * @param useQuaternion specifies if quaternions should be used
  71191. */
  71192. private static _CreateBakedAnimation;
  71193. private static _ConvertFactorToVector3OrQuaternion;
  71194. private static _SetInterpolatedValue;
  71195. /**
  71196. * Creates linear animation from the animation key frames
  71197. * @param babylonTransformNode BabylonJS mesh
  71198. * @param animation BabylonJS animation
  71199. * @param animationChannelTargetPath The target animation channel
  71200. * @param frameDelta The difference between the last and first frame of the animation
  71201. * @param inputs Array to store the key frame times
  71202. * @param outputs Array to store the key frame data
  71203. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71204. * @param useQuaternion Specifies if quaternions are used in the animation
  71205. */
  71206. private static _CreateLinearOrStepAnimation;
  71207. /**
  71208. * Creates cubic spline animation from the animation key frames
  71209. * @param babylonTransformNode BabylonJS mesh
  71210. * @param animation BabylonJS animation
  71211. * @param animationChannelTargetPath The target animation channel
  71212. * @param frameDelta The difference between the last and first frame of the animation
  71213. * @param inputs Array to store the key frame times
  71214. * @param outputs Array to store the key frame data
  71215. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71216. * @param useQuaternion Specifies if quaternions are used in the animation
  71217. */
  71218. private static _CreateCubicSplineAnimation;
  71219. private static _GetBasePositionRotationOrScale;
  71220. /**
  71221. * Adds a key frame value
  71222. * @param keyFrame
  71223. * @param animation
  71224. * @param outputs
  71225. * @param animationChannelTargetPath
  71226. * @param basePositionRotationOrScale
  71227. * @param convertToRightHandedSystem
  71228. * @param useQuaternion
  71229. */
  71230. private static _AddKeyframeValue;
  71231. /**
  71232. * Determine the interpolation based on the key frames
  71233. * @param keyFrames
  71234. * @param animationChannelTargetPath
  71235. * @param useQuaternion
  71236. */
  71237. private static _DeduceInterpolation;
  71238. /**
  71239. * Adds an input tangent or output tangent to the output data
  71240. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71241. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71242. * @param outputs The animation data by keyframe
  71243. * @param animationChannelTargetPath The target animation channel
  71244. * @param interpolation The interpolation type
  71245. * @param keyFrame The key frame with the animation data
  71246. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71247. * @param useQuaternion Specifies if quaternions are used
  71248. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71249. */
  71250. private static AddSplineTangent;
  71251. /**
  71252. * Get the minimum and maximum key frames' frame values
  71253. * @param keyFrames animation key frames
  71254. * @returns the minimum and maximum key frame value
  71255. */
  71256. private static calculateMinMaxKeyFrames;
  71257. }
  71258. }
  71259. declare module BABYLON.GLTF2.Exporter {
  71260. /** @hidden */
  71261. export var textureTransformPixelShader: {
  71262. name: string;
  71263. shader: string;
  71264. };
  71265. }
  71266. declare module BABYLON.GLTF2.Exporter.Extensions {
  71267. /**
  71268. * @hidden
  71269. */
  71270. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71271. /** Name of this extension */
  71272. readonly name: string;
  71273. /** Defines whether this extension is enabled */
  71274. enabled: boolean;
  71275. /** Defines whether this extension is required */
  71276. required: boolean;
  71277. /** Reference to the glTF exporter */
  71278. private _exporter;
  71279. constructor(exporter: _Exporter);
  71280. dispose(): void;
  71281. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71282. /**
  71283. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71284. * @param babylonTexture
  71285. * @param offset
  71286. * @param rotation
  71287. * @param scale
  71288. * @param scene
  71289. */
  71290. private _textureTransformTextureAsync;
  71291. }
  71292. }
  71293. declare module BABYLON.GLTF2.Exporter.Extensions {
  71294. /**
  71295. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71296. */
  71297. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71298. /** The name of this extension. */
  71299. readonly name: string;
  71300. /** Defines whether this extension is enabled. */
  71301. enabled: boolean;
  71302. /** Defines whether this extension is required */
  71303. required: boolean;
  71304. /** Reference to the glTF exporter */
  71305. private _exporter;
  71306. private _lights;
  71307. /** @hidden */
  71308. constructor(exporter: _Exporter);
  71309. /** @hidden */
  71310. dispose(): void;
  71311. /** @hidden */
  71312. onExporting(): void;
  71313. /**
  71314. * Define this method to modify the default behavior when exporting a node
  71315. * @param context The context when exporting the node
  71316. * @param node glTF node
  71317. * @param babylonNode BabylonJS node
  71318. * @returns nullable INode promise
  71319. */
  71320. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71321. }
  71322. }
  71323. declare module BABYLON {
  71324. /**
  71325. * Class for generating STL data from a Babylon scene.
  71326. */
  71327. export class STLExport {
  71328. /**
  71329. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71330. * @param meshes list defines the mesh to serialize
  71331. * @param download triggers the automatic download of the file.
  71332. * @param fileName changes the downloads fileName.
  71333. * @param binary changes the STL to a binary type.
  71334. * @param isLittleEndian toggle for binary type exporter.
  71335. * @returns the STL as UTF8 string
  71336. */
  71337. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71338. }
  71339. }
  71340. declare module "babylonjs-gltf2interface" {
  71341. export = BABYLON.GLTF2;
  71342. }
  71343. /**
  71344. * Module for glTF 2.0 Interface
  71345. */
  71346. declare module BABYLON.GLTF2 {
  71347. /**
  71348. * The datatype of the components in the attribute
  71349. */
  71350. const enum AccessorComponentType {
  71351. /**
  71352. * Byte
  71353. */
  71354. BYTE = 5120,
  71355. /**
  71356. * Unsigned Byte
  71357. */
  71358. UNSIGNED_BYTE = 5121,
  71359. /**
  71360. * Short
  71361. */
  71362. SHORT = 5122,
  71363. /**
  71364. * Unsigned Short
  71365. */
  71366. UNSIGNED_SHORT = 5123,
  71367. /**
  71368. * Unsigned Int
  71369. */
  71370. UNSIGNED_INT = 5125,
  71371. /**
  71372. * Float
  71373. */
  71374. FLOAT = 5126,
  71375. }
  71376. /**
  71377. * Specifies if the attirbute is a scalar, vector, or matrix
  71378. */
  71379. const enum AccessorType {
  71380. /**
  71381. * Scalar
  71382. */
  71383. SCALAR = "SCALAR",
  71384. /**
  71385. * Vector2
  71386. */
  71387. VEC2 = "VEC2",
  71388. /**
  71389. * Vector3
  71390. */
  71391. VEC3 = "VEC3",
  71392. /**
  71393. * Vector4
  71394. */
  71395. VEC4 = "VEC4",
  71396. /**
  71397. * Matrix2x2
  71398. */
  71399. MAT2 = "MAT2",
  71400. /**
  71401. * Matrix3x3
  71402. */
  71403. MAT3 = "MAT3",
  71404. /**
  71405. * Matrix4x4
  71406. */
  71407. MAT4 = "MAT4",
  71408. }
  71409. /**
  71410. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71411. */
  71412. const enum AnimationChannelTargetPath {
  71413. /**
  71414. * Translation
  71415. */
  71416. TRANSLATION = "translation",
  71417. /**
  71418. * Rotation
  71419. */
  71420. ROTATION = "rotation",
  71421. /**
  71422. * Scale
  71423. */
  71424. SCALE = "scale",
  71425. /**
  71426. * Weights
  71427. */
  71428. WEIGHTS = "weights",
  71429. }
  71430. /**
  71431. * Interpolation algorithm
  71432. */
  71433. const enum AnimationSamplerInterpolation {
  71434. /**
  71435. * The animated values are linearly interpolated between keyframes
  71436. */
  71437. LINEAR = "LINEAR",
  71438. /**
  71439. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71440. */
  71441. STEP = "STEP",
  71442. /**
  71443. * The animation's interpolation is computed using a cubic spline with specified tangents
  71444. */
  71445. CUBICSPLINE = "CUBICSPLINE",
  71446. }
  71447. /**
  71448. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71449. */
  71450. const enum CameraType {
  71451. /**
  71452. * A perspective camera containing properties to create a perspective projection matrix
  71453. */
  71454. PERSPECTIVE = "perspective",
  71455. /**
  71456. * An orthographic camera containing properties to create an orthographic projection matrix
  71457. */
  71458. ORTHOGRAPHIC = "orthographic",
  71459. }
  71460. /**
  71461. * The mime-type of the image
  71462. */
  71463. const enum ImageMimeType {
  71464. /**
  71465. * JPEG Mime-type
  71466. */
  71467. JPEG = "image/jpeg",
  71468. /**
  71469. * PNG Mime-type
  71470. */
  71471. PNG = "image/png",
  71472. }
  71473. /**
  71474. * The alpha rendering mode of the material
  71475. */
  71476. const enum MaterialAlphaMode {
  71477. /**
  71478. * The alpha value is ignored and the rendered output is fully opaque
  71479. */
  71480. OPAQUE = "OPAQUE",
  71481. /**
  71482. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71483. */
  71484. MASK = "MASK",
  71485. /**
  71486. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  71487. */
  71488. BLEND = "BLEND",
  71489. }
  71490. /**
  71491. * The type of the primitives to render
  71492. */
  71493. const enum MeshPrimitiveMode {
  71494. /**
  71495. * Points
  71496. */
  71497. POINTS = 0,
  71498. /**
  71499. * Lines
  71500. */
  71501. LINES = 1,
  71502. /**
  71503. * Line Loop
  71504. */
  71505. LINE_LOOP = 2,
  71506. /**
  71507. * Line Strip
  71508. */
  71509. LINE_STRIP = 3,
  71510. /**
  71511. * Triangles
  71512. */
  71513. TRIANGLES = 4,
  71514. /**
  71515. * Triangle Strip
  71516. */
  71517. TRIANGLE_STRIP = 5,
  71518. /**
  71519. * Triangle Fan
  71520. */
  71521. TRIANGLE_FAN = 6,
  71522. }
  71523. /**
  71524. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71525. */
  71526. const enum TextureMagFilter {
  71527. /**
  71528. * Nearest
  71529. */
  71530. NEAREST = 9728,
  71531. /**
  71532. * Linear
  71533. */
  71534. LINEAR = 9729,
  71535. }
  71536. /**
  71537. * Minification filter. All valid values correspond to WebGL enums
  71538. */
  71539. const enum TextureMinFilter {
  71540. /**
  71541. * Nearest
  71542. */
  71543. NEAREST = 9728,
  71544. /**
  71545. * Linear
  71546. */
  71547. LINEAR = 9729,
  71548. /**
  71549. * Nearest Mip-Map Nearest
  71550. */
  71551. NEAREST_MIPMAP_NEAREST = 9984,
  71552. /**
  71553. * Linear Mipmap Nearest
  71554. */
  71555. LINEAR_MIPMAP_NEAREST = 9985,
  71556. /**
  71557. * Nearest Mipmap Linear
  71558. */
  71559. NEAREST_MIPMAP_LINEAR = 9986,
  71560. /**
  71561. * Linear Mipmap Linear
  71562. */
  71563. LINEAR_MIPMAP_LINEAR = 9987,
  71564. }
  71565. /**
  71566. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71567. */
  71568. const enum TextureWrapMode {
  71569. /**
  71570. * Clamp to Edge
  71571. */
  71572. CLAMP_TO_EDGE = 33071,
  71573. /**
  71574. * Mirrored Repeat
  71575. */
  71576. MIRRORED_REPEAT = 33648,
  71577. /**
  71578. * Repeat
  71579. */
  71580. REPEAT = 10497,
  71581. }
  71582. /**
  71583. * glTF Property
  71584. */
  71585. interface IProperty {
  71586. /**
  71587. * Dictionary object with extension-specific objects
  71588. */
  71589. extensions?: {
  71590. [key: string]: any;
  71591. };
  71592. /**
  71593. * Application-Specific data
  71594. */
  71595. extras?: any;
  71596. }
  71597. /**
  71598. * glTF Child of Root Property
  71599. */
  71600. interface IChildRootProperty extends IProperty {
  71601. /**
  71602. * The user-defined name of this object
  71603. */
  71604. name?: string;
  71605. }
  71606. /**
  71607. * Indices of those attributes that deviate from their initialization value
  71608. */
  71609. interface IAccessorSparseIndices extends IProperty {
  71610. /**
  71611. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71612. */
  71613. bufferView: number;
  71614. /**
  71615. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71616. */
  71617. byteOffset?: number;
  71618. /**
  71619. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71620. */
  71621. componentType: AccessorComponentType;
  71622. }
  71623. /**
  71624. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71625. */
  71626. interface IAccessorSparseValues extends IProperty {
  71627. /**
  71628. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71629. */
  71630. bufferView: number;
  71631. /**
  71632. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71633. */
  71634. byteOffset?: number;
  71635. }
  71636. /**
  71637. * Sparse storage of attributes that deviate from their initialization value
  71638. */
  71639. interface IAccessorSparse extends IProperty {
  71640. /**
  71641. * The number of attributes encoded in this sparse accessor
  71642. */
  71643. count: number;
  71644. /**
  71645. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71646. */
  71647. indices: IAccessorSparseIndices;
  71648. /**
  71649. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  71650. */
  71651. values: IAccessorSparseValues;
  71652. }
  71653. /**
  71654. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  71655. */
  71656. interface IAccessor extends IChildRootProperty {
  71657. /**
  71658. * The index of the bufferview
  71659. */
  71660. bufferView?: number;
  71661. /**
  71662. * The offset relative to the start of the bufferView in bytes
  71663. */
  71664. byteOffset?: number;
  71665. /**
  71666. * The datatype of components in the attribute
  71667. */
  71668. componentType: AccessorComponentType;
  71669. /**
  71670. * Specifies whether integer data values should be normalized
  71671. */
  71672. normalized?: boolean;
  71673. /**
  71674. * The number of attributes referenced by this accessor
  71675. */
  71676. count: number;
  71677. /**
  71678. * Specifies if the attribute is a scalar, vector, or matrix
  71679. */
  71680. type: AccessorType;
  71681. /**
  71682. * Maximum value of each component in this attribute
  71683. */
  71684. max?: number[];
  71685. /**
  71686. * Minimum value of each component in this attribute
  71687. */
  71688. min?: number[];
  71689. /**
  71690. * Sparse storage of attributes that deviate from their initialization value
  71691. */
  71692. sparse?: IAccessorSparse;
  71693. }
  71694. /**
  71695. * Targets an animation's sampler at a node's property
  71696. */
  71697. interface IAnimationChannel extends IProperty {
  71698. /**
  71699. * The index of a sampler in this animation used to compute the value for the target
  71700. */
  71701. sampler: number;
  71702. /**
  71703. * The index of the node and TRS property to target
  71704. */
  71705. target: IAnimationChannelTarget;
  71706. }
  71707. /**
  71708. * The index of the node and TRS property that an animation channel targets
  71709. */
  71710. interface IAnimationChannelTarget extends IProperty {
  71711. /**
  71712. * The index of the node to target
  71713. */
  71714. node: number;
  71715. /**
  71716. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71717. */
  71718. path: AnimationChannelTargetPath;
  71719. }
  71720. /**
  71721. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71722. */
  71723. interface IAnimationSampler extends IProperty {
  71724. /**
  71725. * The index of an accessor containing keyframe input values, e.g., time
  71726. */
  71727. input: number;
  71728. /**
  71729. * Interpolation algorithm
  71730. */
  71731. interpolation?: AnimationSamplerInterpolation;
  71732. /**
  71733. * The index of an accessor, containing keyframe output values
  71734. */
  71735. output: number;
  71736. }
  71737. /**
  71738. * A keyframe animation
  71739. */
  71740. interface IAnimation extends IChildRootProperty {
  71741. /**
  71742. * An array of channels, each of which targets an animation's sampler at a node's property
  71743. */
  71744. channels: IAnimationChannel[];
  71745. /**
  71746. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71747. */
  71748. samplers: IAnimationSampler[];
  71749. }
  71750. /**
  71751. * Metadata about the glTF asset
  71752. */
  71753. interface IAsset extends IChildRootProperty {
  71754. /**
  71755. * A copyright message suitable for display to credit the content creator
  71756. */
  71757. copyright?: string;
  71758. /**
  71759. * Tool that generated this glTF model. Useful for debugging
  71760. */
  71761. generator?: string;
  71762. /**
  71763. * The glTF version that this asset targets
  71764. */
  71765. version: string;
  71766. /**
  71767. * The minimum glTF version that this asset targets
  71768. */
  71769. minVersion?: string;
  71770. }
  71771. /**
  71772. * A buffer points to binary geometry, animation, or skins
  71773. */
  71774. interface IBuffer extends IChildRootProperty {
  71775. /**
  71776. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  71777. */
  71778. uri?: string;
  71779. /**
  71780. * The length of the buffer in bytes
  71781. */
  71782. byteLength: number;
  71783. }
  71784. /**
  71785. * A view into a buffer generally representing a subset of the buffer
  71786. */
  71787. interface IBufferView extends IChildRootProperty {
  71788. /**
  71789. * The index of the buffer
  71790. */
  71791. buffer: number;
  71792. /**
  71793. * The offset into the buffer in bytes
  71794. */
  71795. byteOffset?: number;
  71796. /**
  71797. * The lenth of the bufferView in bytes
  71798. */
  71799. byteLength: number;
  71800. /**
  71801. * The stride, in bytes
  71802. */
  71803. byteStride?: number;
  71804. }
  71805. /**
  71806. * An orthographic camera containing properties to create an orthographic projection matrix
  71807. */
  71808. interface ICameraOrthographic extends IProperty {
  71809. /**
  71810. * The floating-point horizontal magnification of the view. Must not be zero
  71811. */
  71812. xmag: number;
  71813. /**
  71814. * The floating-point vertical magnification of the view. Must not be zero
  71815. */
  71816. ymag: number;
  71817. /**
  71818. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71819. */
  71820. zfar: number;
  71821. /**
  71822. * The floating-point distance to the near clipping plane
  71823. */
  71824. znear: number;
  71825. }
  71826. /**
  71827. * A perspective camera containing properties to create a perspective projection matrix
  71828. */
  71829. interface ICameraPerspective extends IProperty {
  71830. /**
  71831. * The floating-point aspect ratio of the field of view
  71832. */
  71833. aspectRatio?: number;
  71834. /**
  71835. * The floating-point vertical field of view in radians
  71836. */
  71837. yfov: number;
  71838. /**
  71839. * The floating-point distance to the far clipping plane
  71840. */
  71841. zfar?: number;
  71842. /**
  71843. * The floating-point distance to the near clipping plane
  71844. */
  71845. znear: number;
  71846. }
  71847. /**
  71848. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71849. */
  71850. interface ICamera extends IChildRootProperty {
  71851. /**
  71852. * An orthographic camera containing properties to create an orthographic projection matrix
  71853. */
  71854. orthographic?: ICameraOrthographic;
  71855. /**
  71856. * A perspective camera containing properties to create a perspective projection matrix
  71857. */
  71858. perspective?: ICameraPerspective;
  71859. /**
  71860. * Specifies if the camera uses a perspective or orthographic projection
  71861. */
  71862. type: CameraType;
  71863. }
  71864. /**
  71865. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71866. */
  71867. interface IImage extends IChildRootProperty {
  71868. /**
  71869. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  71870. */
  71871. uri?: string;
  71872. /**
  71873. * The image's MIME type
  71874. */
  71875. mimeType?: ImageMimeType;
  71876. /**
  71877. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71878. */
  71879. bufferView?: number;
  71880. }
  71881. /**
  71882. * Material Normal Texture Info
  71883. */
  71884. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71885. /**
  71886. * The scalar multiplier applied to each normal vector of the normal texture
  71887. */
  71888. scale?: number;
  71889. }
  71890. /**
  71891. * Material Occlusion Texture Info
  71892. */
  71893. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71894. /**
  71895. * A scalar multiplier controlling the amount of occlusion applied
  71896. */
  71897. strength?: number;
  71898. }
  71899. /**
  71900. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71901. */
  71902. interface IMaterialPbrMetallicRoughness {
  71903. /**
  71904. * The material's base color factor
  71905. */
  71906. baseColorFactor?: number[];
  71907. /**
  71908. * The base color texture
  71909. */
  71910. baseColorTexture?: ITextureInfo;
  71911. /**
  71912. * The metalness of the material
  71913. */
  71914. metallicFactor?: number;
  71915. /**
  71916. * The roughness of the material
  71917. */
  71918. roughnessFactor?: number;
  71919. /**
  71920. * The metallic-roughness texture
  71921. */
  71922. metallicRoughnessTexture?: ITextureInfo;
  71923. }
  71924. /**
  71925. * The material appearance of a primitive
  71926. */
  71927. interface IMaterial extends IChildRootProperty {
  71928. /**
  71929. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  71930. */
  71931. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71932. /**
  71933. * The normal map texture
  71934. */
  71935. normalTexture?: IMaterialNormalTextureInfo;
  71936. /**
  71937. * The occlusion map texture
  71938. */
  71939. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71940. /**
  71941. * The emissive map texture
  71942. */
  71943. emissiveTexture?: ITextureInfo;
  71944. /**
  71945. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  71946. */
  71947. emissiveFactor?: number[];
  71948. /**
  71949. * The alpha rendering mode of the material
  71950. */
  71951. alphaMode?: MaterialAlphaMode;
  71952. /**
  71953. * The alpha cutoff value of the material
  71954. */
  71955. alphaCutoff?: number;
  71956. /**
  71957. * Specifies whether the material is double sided
  71958. */
  71959. doubleSided?: boolean;
  71960. }
  71961. /**
  71962. * Geometry to be rendered with the given material
  71963. */
  71964. interface IMeshPrimitive extends IProperty {
  71965. /**
  71966. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71967. */
  71968. attributes: {
  71969. [name: string]: number;
  71970. };
  71971. /**
  71972. * The index of the accessor that contains the indices
  71973. */
  71974. indices?: number;
  71975. /**
  71976. * The index of the material to apply to this primitive when rendering
  71977. */
  71978. material?: number;
  71979. /**
  71980. * The type of primitives to render. All valid values correspond to WebGL enums
  71981. */
  71982. mode?: MeshPrimitiveMode;
  71983. /**
  71984. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  71985. */
  71986. targets?: {
  71987. [name: string]: number;
  71988. }[];
  71989. }
  71990. /**
  71991. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71992. */
  71993. interface IMesh extends IChildRootProperty {
  71994. /**
  71995. * An array of primitives, each defining geometry to be rendered with a material
  71996. */
  71997. primitives: IMeshPrimitive[];
  71998. /**
  71999. * Array of weights to be applied to the Morph Targets
  72000. */
  72001. weights?: number[];
  72002. }
  72003. /**
  72004. * A node in the node hierarchy
  72005. */
  72006. interface INode extends IChildRootProperty {
  72007. /**
  72008. * The index of the camera referenced by this node
  72009. */
  72010. camera?: number;
  72011. /**
  72012. * The indices of this node's children
  72013. */
  72014. children?: number[];
  72015. /**
  72016. * The index of the skin referenced by this node
  72017. */
  72018. skin?: number;
  72019. /**
  72020. * A floating-point 4x4 transformation matrix stored in column-major order
  72021. */
  72022. matrix?: number[];
  72023. /**
  72024. * The index of the mesh in this node
  72025. */
  72026. mesh?: number;
  72027. /**
  72028. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72029. */
  72030. rotation?: number[];
  72031. /**
  72032. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72033. */
  72034. scale?: number[];
  72035. /**
  72036. * The node's translation along the x, y, and z axes
  72037. */
  72038. translation?: number[];
  72039. /**
  72040. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72041. */
  72042. weights?: number[];
  72043. }
  72044. /**
  72045. * Texture sampler properties for filtering and wrapping modes
  72046. */
  72047. interface ISampler extends IChildRootProperty {
  72048. /**
  72049. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72050. */
  72051. magFilter?: TextureMagFilter;
  72052. /**
  72053. * Minification filter. All valid values correspond to WebGL enums
  72054. */
  72055. minFilter?: TextureMinFilter;
  72056. /**
  72057. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72058. */
  72059. wrapS?: TextureWrapMode;
  72060. /**
  72061. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72062. */
  72063. wrapT?: TextureWrapMode;
  72064. }
  72065. /**
  72066. * The root nodes of a scene
  72067. */
  72068. interface IScene extends IChildRootProperty {
  72069. /**
  72070. * The indices of each root node
  72071. */
  72072. nodes: number[];
  72073. }
  72074. /**
  72075. * Joints and matrices defining a skin
  72076. */
  72077. interface ISkin extends IChildRootProperty {
  72078. /**
  72079. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  72080. */
  72081. inverseBindMatrices?: number;
  72082. /**
  72083. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72084. */
  72085. skeleton?: number;
  72086. /**
  72087. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  72088. */
  72089. joints: number[];
  72090. }
  72091. /**
  72092. * A texture and its sampler
  72093. */
  72094. interface ITexture extends IChildRootProperty {
  72095. /**
  72096. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72097. */
  72098. sampler?: number;
  72099. /**
  72100. * The index of the image used by this texture
  72101. */
  72102. source: number;
  72103. }
  72104. /**
  72105. * Reference to a texture
  72106. */
  72107. interface ITextureInfo extends IProperty {
  72108. /**
  72109. * The index of the texture
  72110. */
  72111. index: number;
  72112. /**
  72113. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72114. */
  72115. texCoord?: number;
  72116. }
  72117. /**
  72118. * The root object for a glTF asset
  72119. */
  72120. interface IGLTF extends IProperty {
  72121. /**
  72122. * An array of accessors. An accessor is a typed view into a bufferView
  72123. */
  72124. accessors?: IAccessor[];
  72125. /**
  72126. * An array of keyframe animations
  72127. */
  72128. animations?: IAnimation[];
  72129. /**
  72130. * Metadata about the glTF asset
  72131. */
  72132. asset: IAsset;
  72133. /**
  72134. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72135. */
  72136. buffers?: IBuffer[];
  72137. /**
  72138. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72139. */
  72140. bufferViews?: IBufferView[];
  72141. /**
  72142. * An array of cameras
  72143. */
  72144. cameras?: ICamera[];
  72145. /**
  72146. * Names of glTF extensions used somewhere in this asset
  72147. */
  72148. extensionsUsed?: string[];
  72149. /**
  72150. * Names of glTF extensions required to properly load this asset
  72151. */
  72152. extensionsRequired?: string[];
  72153. /**
  72154. * An array of images. An image defines data used to create a texture
  72155. */
  72156. images?: IImage[];
  72157. /**
  72158. * An array of materials. A material defines the appearance of a primitive
  72159. */
  72160. materials?: IMaterial[];
  72161. /**
  72162. * An array of meshes. A mesh is a set of primitives to be rendered
  72163. */
  72164. meshes?: IMesh[];
  72165. /**
  72166. * An array of nodes
  72167. */
  72168. nodes?: INode[];
  72169. /**
  72170. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72171. */
  72172. samplers?: ISampler[];
  72173. /**
  72174. * The index of the default scene
  72175. */
  72176. scene?: number;
  72177. /**
  72178. * An array of scenes
  72179. */
  72180. scenes?: IScene[];
  72181. /**
  72182. * An array of skins. A skin is defined by joints and matrices
  72183. */
  72184. skins?: ISkin[];
  72185. /**
  72186. * An array of textures
  72187. */
  72188. textures?: ITexture[];
  72189. }
  72190. /**
  72191. * The glTF validation results
  72192. * @ignore
  72193. */
  72194. interface IGLTFValidationResults {
  72195. info: {
  72196. generator: string;
  72197. hasAnimations: boolean;
  72198. hasDefaultScene: boolean;
  72199. hasMaterials: boolean;
  72200. hasMorphTargets: boolean;
  72201. hasSkins: boolean;
  72202. hasTextures: boolean;
  72203. maxAttributesUsed: number;
  72204. primitivesCount: number
  72205. };
  72206. issues: {
  72207. messages: Array<string>;
  72208. numErrors: number;
  72209. numHints: number;
  72210. numInfos: number;
  72211. numWarnings: number;
  72212. truncated: boolean
  72213. };
  72214. mimeType: string;
  72215. uri: string;
  72216. validatedAt: string;
  72217. validatorVersion: string;
  72218. }
  72219. /**
  72220. * The glTF validation options
  72221. */
  72222. interface IGLTFValidationOptions {
  72223. /** Uri to use */
  72224. uri?: string;
  72225. /** Function used to load external resources */
  72226. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72227. /** Boolean indicating that we need to validate accessor data */
  72228. validateAccessorData?: boolean;
  72229. /** max number of issues allowed */
  72230. maxIssues?: number;
  72231. /** Ignored issues */
  72232. ignoredIssues?: Array<string>;
  72233. /** Value to override severy settings */
  72234. severityOverrides?: Object;
  72235. }
  72236. /**
  72237. * The glTF validator object
  72238. * @ignore
  72239. */
  72240. interface IGLTFValidator {
  72241. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72242. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72243. }
  72244. }
  72245. declare module BABYLON {
  72246. /** @hidden */
  72247. export var cellPixelShader: {
  72248. name: string;
  72249. shader: string;
  72250. };
  72251. }
  72252. declare module BABYLON {
  72253. /** @hidden */
  72254. export var cellVertexShader: {
  72255. name: string;
  72256. shader: string;
  72257. };
  72258. }
  72259. declare module BABYLON {
  72260. export class CellMaterial extends BABYLON.PushMaterial {
  72261. private _diffuseTexture;
  72262. diffuseTexture: BABYLON.BaseTexture;
  72263. diffuseColor: BABYLON.Color3;
  72264. _computeHighLevel: boolean;
  72265. computeHighLevel: boolean;
  72266. private _disableLighting;
  72267. disableLighting: boolean;
  72268. private _maxSimultaneousLights;
  72269. maxSimultaneousLights: number;
  72270. private _renderId;
  72271. constructor(name: string, scene: BABYLON.Scene);
  72272. needAlphaBlending(): boolean;
  72273. needAlphaTesting(): boolean;
  72274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72277. getAnimatables(): BABYLON.IAnimatable[];
  72278. getActiveTextures(): BABYLON.BaseTexture[];
  72279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72280. dispose(forceDisposeEffect?: boolean): void;
  72281. getClassName(): string;
  72282. clone(name: string): CellMaterial;
  72283. serialize(): any;
  72284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72285. }
  72286. }
  72287. declare module BABYLON {
  72288. export class CustomShaderStructure {
  72289. FragmentStore: string;
  72290. VertexStore: string;
  72291. constructor();
  72292. }
  72293. export class ShaderSpecialParts {
  72294. constructor();
  72295. Fragment_Begin: string;
  72296. Fragment_Definitions: string;
  72297. Fragment_MainBegin: string;
  72298. Fragment_Custom_Diffuse: string;
  72299. Fragment_Before_Lights: string;
  72300. Fragment_Before_Fog: string;
  72301. Fragment_Custom_Alpha: string;
  72302. Fragment_Before_FragColor: string;
  72303. Vertex_Begin: string;
  72304. Vertex_Definitions: string;
  72305. Vertex_MainBegin: string;
  72306. Vertex_Before_PositionUpdated: string;
  72307. Vertex_Before_NormalUpdated: string;
  72308. Vertex_MainEnd: string;
  72309. }
  72310. export class CustomMaterial extends BABYLON.StandardMaterial {
  72311. static ShaderIndexer: number;
  72312. CustomParts: ShaderSpecialParts;
  72313. _isCreatedShader: boolean;
  72314. _createdShaderName: string;
  72315. _customUniform: string[];
  72316. _newUniforms: string[];
  72317. _newUniformInstances: any[];
  72318. _newSamplerInstances: BABYLON.Texture[];
  72319. FragmentShader: string;
  72320. VertexShader: string;
  72321. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72322. ReviewUniform(name: string, arr: string[]): string[];
  72323. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72324. constructor(name: string, scene: BABYLON.Scene);
  72325. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72326. Fragment_Begin(shaderPart: string): CustomMaterial;
  72327. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72328. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72329. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72330. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72331. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72332. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72333. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72334. Vertex_Begin(shaderPart: string): CustomMaterial;
  72335. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72336. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72337. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72338. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72339. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72340. }
  72341. }
  72342. declare module BABYLON {
  72343. export class ShaderAlebdoParts {
  72344. constructor();
  72345. Fragment_Begin: string;
  72346. Fragment_Definitions: string;
  72347. Fragment_MainBegin: string;
  72348. Fragment_Custom_Albedo: string;
  72349. Fragment_Before_Lights: string;
  72350. Fragment_Custom_MetallicRoughness: string;
  72351. Fragment_Custom_MicroSurface: string;
  72352. Fragment_Before_Fog: string;
  72353. Fragment_Custom_Alpha: string;
  72354. Fragment_Before_FragColor: string;
  72355. Vertex_Begin: string;
  72356. Vertex_Definitions: string;
  72357. Vertex_MainBegin: string;
  72358. Vertex_Before_PositionUpdated: string;
  72359. Vertex_Before_NormalUpdated: string;
  72360. Vertex_MainEnd: string;
  72361. }
  72362. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72363. static ShaderIndexer: number;
  72364. CustomParts: ShaderAlebdoParts;
  72365. _isCreatedShader: boolean;
  72366. _createdShaderName: string;
  72367. _customUniform: string[];
  72368. _newUniforms: string[];
  72369. _newUniformInstances: any[];
  72370. _newSamplerInstances: BABYLON.Texture[];
  72371. FragmentShader: string;
  72372. VertexShader: string;
  72373. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72374. ReviewUniform(name: string, arr: string[]): string[];
  72375. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72376. constructor(name: string, scene: BABYLON.Scene);
  72377. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72378. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72379. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72380. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72381. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72382. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72383. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72384. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72385. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72386. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72387. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72388. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72389. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72390. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72391. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72392. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72393. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72394. }
  72395. }
  72396. declare module BABYLON {
  72397. /** @hidden */
  72398. export var firePixelShader: {
  72399. name: string;
  72400. shader: string;
  72401. };
  72402. }
  72403. declare module BABYLON {
  72404. /** @hidden */
  72405. export var fireVertexShader: {
  72406. name: string;
  72407. shader: string;
  72408. };
  72409. }
  72410. declare module BABYLON {
  72411. export class FireMaterial extends BABYLON.PushMaterial {
  72412. private _diffuseTexture;
  72413. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72414. private _distortionTexture;
  72415. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72416. private _opacityTexture;
  72417. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72418. diffuseColor: BABYLON.Color3;
  72419. speed: number;
  72420. private _scaledDiffuse;
  72421. private _renderId;
  72422. private _lastTime;
  72423. constructor(name: string, scene: BABYLON.Scene);
  72424. needAlphaBlending(): boolean;
  72425. needAlphaTesting(): boolean;
  72426. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72427. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72428. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72429. getAnimatables(): BABYLON.IAnimatable[];
  72430. getActiveTextures(): BABYLON.BaseTexture[];
  72431. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72432. getClassName(): string;
  72433. dispose(forceDisposeEffect?: boolean): void;
  72434. clone(name: string): FireMaterial;
  72435. serialize(): any;
  72436. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72437. }
  72438. }
  72439. declare module BABYLON {
  72440. /** @hidden */
  72441. export var furPixelShader: {
  72442. name: string;
  72443. shader: string;
  72444. };
  72445. }
  72446. declare module BABYLON {
  72447. /** @hidden */
  72448. export var furVertexShader: {
  72449. name: string;
  72450. shader: string;
  72451. };
  72452. }
  72453. declare module BABYLON {
  72454. export class FurMaterial extends BABYLON.PushMaterial {
  72455. private _diffuseTexture;
  72456. diffuseTexture: BABYLON.BaseTexture;
  72457. private _heightTexture;
  72458. heightTexture: BABYLON.BaseTexture;
  72459. diffuseColor: BABYLON.Color3;
  72460. furLength: number;
  72461. furAngle: number;
  72462. furColor: BABYLON.Color3;
  72463. furOffset: number;
  72464. furSpacing: number;
  72465. furGravity: BABYLON.Vector3;
  72466. furSpeed: number;
  72467. furDensity: number;
  72468. furOcclusion: number;
  72469. furTexture: BABYLON.DynamicTexture;
  72470. private _disableLighting;
  72471. disableLighting: boolean;
  72472. private _maxSimultaneousLights;
  72473. maxSimultaneousLights: number;
  72474. highLevelFur: boolean;
  72475. _meshes: BABYLON.AbstractMesh[];
  72476. private _renderId;
  72477. private _furTime;
  72478. constructor(name: string, scene: BABYLON.Scene);
  72479. furTime: number;
  72480. needAlphaBlending(): boolean;
  72481. needAlphaTesting(): boolean;
  72482. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72483. updateFur(): void;
  72484. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72485. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72486. getAnimatables(): BABYLON.IAnimatable[];
  72487. getActiveTextures(): BABYLON.BaseTexture[];
  72488. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72489. dispose(forceDisposeEffect?: boolean): void;
  72490. clone(name: string): FurMaterial;
  72491. serialize(): any;
  72492. getClassName(): string;
  72493. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72494. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72495. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72496. }
  72497. }
  72498. declare module BABYLON {
  72499. /** @hidden */
  72500. export var gradientPixelShader: {
  72501. name: string;
  72502. shader: string;
  72503. };
  72504. }
  72505. declare module BABYLON {
  72506. /** @hidden */
  72507. export var gradientVertexShader: {
  72508. name: string;
  72509. shader: string;
  72510. };
  72511. }
  72512. declare module BABYLON {
  72513. export class GradientMaterial extends BABYLON.PushMaterial {
  72514. private _maxSimultaneousLights;
  72515. maxSimultaneousLights: number;
  72516. topColor: BABYLON.Color3;
  72517. topColorAlpha: number;
  72518. bottomColor: BABYLON.Color3;
  72519. bottomColorAlpha: number;
  72520. offset: number;
  72521. scale: number;
  72522. smoothness: number;
  72523. private _disableLighting;
  72524. disableLighting: boolean;
  72525. private _renderId;
  72526. constructor(name: string, scene: BABYLON.Scene);
  72527. needAlphaBlending(): boolean;
  72528. needAlphaTesting(): boolean;
  72529. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72530. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72531. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72532. getAnimatables(): BABYLON.IAnimatable[];
  72533. dispose(forceDisposeEffect?: boolean): void;
  72534. clone(name: string): GradientMaterial;
  72535. serialize(): any;
  72536. getClassName(): string;
  72537. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72538. }
  72539. }
  72540. declare module BABYLON {
  72541. /** @hidden */
  72542. export var gridPixelShader: {
  72543. name: string;
  72544. shader: string;
  72545. };
  72546. }
  72547. declare module BABYLON {
  72548. /** @hidden */
  72549. export var gridVertexShader: {
  72550. name: string;
  72551. shader: string;
  72552. };
  72553. }
  72554. declare module BABYLON {
  72555. /**
  72556. * The grid materials allows you to wrap any shape with a grid.
  72557. * Colors are customizable.
  72558. */
  72559. export class GridMaterial extends BABYLON.PushMaterial {
  72560. /**
  72561. * Main color of the grid (e.g. between lines)
  72562. */
  72563. mainColor: BABYLON.Color3;
  72564. /**
  72565. * Color of the grid lines.
  72566. */
  72567. lineColor: BABYLON.Color3;
  72568. /**
  72569. * The scale of the grid compared to unit.
  72570. */
  72571. gridRatio: number;
  72572. /**
  72573. * Allows setting an offset for the grid lines.
  72574. */
  72575. gridOffset: BABYLON.Vector3;
  72576. /**
  72577. * The frequency of thicker lines.
  72578. */
  72579. majorUnitFrequency: number;
  72580. /**
  72581. * The visibility of minor units in the grid.
  72582. */
  72583. minorUnitVisibility: number;
  72584. /**
  72585. * The grid opacity outside of the lines.
  72586. */
  72587. opacity: number;
  72588. /**
  72589. * Determine RBG output is premultiplied by alpha value.
  72590. */
  72591. preMultiplyAlpha: boolean;
  72592. private _opacityTexture;
  72593. opacityTexture: BABYLON.BaseTexture;
  72594. private _gridControl;
  72595. private _renderId;
  72596. /**
  72597. * constructor
  72598. * @param name The name given to the material in order to identify it afterwards.
  72599. * @param scene The scene the material is used in.
  72600. */
  72601. constructor(name: string, scene: BABYLON.Scene);
  72602. /**
  72603. * Returns wehter or not the grid requires alpha blending.
  72604. */
  72605. needAlphaBlending(): boolean;
  72606. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72607. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72608. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72609. /**
  72610. * Dispose the material and its associated resources.
  72611. * @param forceDisposeEffect will also dispose the used effect when true
  72612. */
  72613. dispose(forceDisposeEffect?: boolean): void;
  72614. clone(name: string): GridMaterial;
  72615. serialize(): any;
  72616. getClassName(): string;
  72617. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72618. }
  72619. }
  72620. declare module BABYLON {
  72621. /** @hidden */
  72622. export var lavaPixelShader: {
  72623. name: string;
  72624. shader: string;
  72625. };
  72626. }
  72627. declare module BABYLON {
  72628. /** @hidden */
  72629. export var lavaVertexShader: {
  72630. name: string;
  72631. shader: string;
  72632. };
  72633. }
  72634. declare module BABYLON {
  72635. export class LavaMaterial extends BABYLON.PushMaterial {
  72636. private _diffuseTexture;
  72637. diffuseTexture: BABYLON.BaseTexture;
  72638. noiseTexture: BABYLON.BaseTexture;
  72639. fogColor: BABYLON.Color3;
  72640. speed: number;
  72641. movingSpeed: number;
  72642. lowFrequencySpeed: number;
  72643. fogDensity: number;
  72644. private _lastTime;
  72645. diffuseColor: BABYLON.Color3;
  72646. private _disableLighting;
  72647. disableLighting: boolean;
  72648. private _unlit;
  72649. unlit: boolean;
  72650. private _maxSimultaneousLights;
  72651. maxSimultaneousLights: number;
  72652. private _scaledDiffuse;
  72653. private _renderId;
  72654. constructor(name: string, scene: BABYLON.Scene);
  72655. needAlphaBlending(): boolean;
  72656. needAlphaTesting(): boolean;
  72657. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72658. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72659. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72660. getAnimatables(): BABYLON.IAnimatable[];
  72661. getActiveTextures(): BABYLON.BaseTexture[];
  72662. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72663. dispose(forceDisposeEffect?: boolean): void;
  72664. clone(name: string): LavaMaterial;
  72665. serialize(): any;
  72666. getClassName(): string;
  72667. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72668. }
  72669. }
  72670. declare module BABYLON {
  72671. /** @hidden */
  72672. export var mixPixelShader: {
  72673. name: string;
  72674. shader: string;
  72675. };
  72676. }
  72677. declare module BABYLON {
  72678. /** @hidden */
  72679. export var mixVertexShader: {
  72680. name: string;
  72681. shader: string;
  72682. };
  72683. }
  72684. declare module BABYLON {
  72685. export class MixMaterial extends BABYLON.PushMaterial {
  72686. /**
  72687. * Mix textures
  72688. */
  72689. private _mixTexture1;
  72690. mixTexture1: BABYLON.BaseTexture;
  72691. private _mixTexture2;
  72692. mixTexture2: BABYLON.BaseTexture;
  72693. /**
  72694. * Diffuse textures
  72695. */
  72696. private _diffuseTexture1;
  72697. diffuseTexture1: BABYLON.Texture;
  72698. private _diffuseTexture2;
  72699. diffuseTexture2: BABYLON.Texture;
  72700. private _diffuseTexture3;
  72701. diffuseTexture3: BABYLON.Texture;
  72702. private _diffuseTexture4;
  72703. diffuseTexture4: BABYLON.Texture;
  72704. private _diffuseTexture5;
  72705. diffuseTexture5: BABYLON.Texture;
  72706. private _diffuseTexture6;
  72707. diffuseTexture6: BABYLON.Texture;
  72708. private _diffuseTexture7;
  72709. diffuseTexture7: BABYLON.Texture;
  72710. private _diffuseTexture8;
  72711. diffuseTexture8: BABYLON.Texture;
  72712. /**
  72713. * Uniforms
  72714. */
  72715. diffuseColor: BABYLON.Color3;
  72716. specularColor: BABYLON.Color3;
  72717. specularPower: number;
  72718. private _disableLighting;
  72719. disableLighting: boolean;
  72720. private _maxSimultaneousLights;
  72721. maxSimultaneousLights: number;
  72722. private _renderId;
  72723. constructor(name: string, scene: BABYLON.Scene);
  72724. needAlphaBlending(): boolean;
  72725. needAlphaTesting(): boolean;
  72726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72727. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72728. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72729. getAnimatables(): BABYLON.IAnimatable[];
  72730. getActiveTextures(): BABYLON.BaseTexture[];
  72731. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72732. dispose(forceDisposeEffect?: boolean): void;
  72733. clone(name: string): MixMaterial;
  72734. serialize(): any;
  72735. getClassName(): string;
  72736. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72737. }
  72738. }
  72739. declare module BABYLON {
  72740. /** @hidden */
  72741. export var normalPixelShader: {
  72742. name: string;
  72743. shader: string;
  72744. };
  72745. }
  72746. declare module BABYLON {
  72747. /** @hidden */
  72748. export var normalVertexShader: {
  72749. name: string;
  72750. shader: string;
  72751. };
  72752. }
  72753. declare module BABYLON {
  72754. export class NormalMaterial extends BABYLON.PushMaterial {
  72755. private _diffuseTexture;
  72756. diffuseTexture: BABYLON.BaseTexture;
  72757. diffuseColor: BABYLON.Color3;
  72758. private _disableLighting;
  72759. disableLighting: boolean;
  72760. private _maxSimultaneousLights;
  72761. maxSimultaneousLights: number;
  72762. private _renderId;
  72763. constructor(name: string, scene: BABYLON.Scene);
  72764. needAlphaBlending(): boolean;
  72765. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72766. needAlphaTesting(): boolean;
  72767. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72768. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72769. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72770. getAnimatables(): BABYLON.IAnimatable[];
  72771. getActiveTextures(): BABYLON.BaseTexture[];
  72772. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72773. dispose(forceDisposeEffect?: boolean): void;
  72774. clone(name: string): NormalMaterial;
  72775. serialize(): any;
  72776. getClassName(): string;
  72777. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72778. }
  72779. }
  72780. declare module BABYLON {
  72781. /** @hidden */
  72782. export var shadowOnlyPixelShader: {
  72783. name: string;
  72784. shader: string;
  72785. };
  72786. }
  72787. declare module BABYLON {
  72788. /** @hidden */
  72789. export var shadowOnlyVertexShader: {
  72790. name: string;
  72791. shader: string;
  72792. };
  72793. }
  72794. declare module BABYLON {
  72795. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72796. private _renderId;
  72797. private _activeLight;
  72798. constructor(name: string, scene: BABYLON.Scene);
  72799. shadowColor: BABYLON.Color3;
  72800. needAlphaBlending(): boolean;
  72801. needAlphaTesting(): boolean;
  72802. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72803. activeLight: BABYLON.IShadowLight;
  72804. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72806. clone(name: string): ShadowOnlyMaterial;
  72807. serialize(): any;
  72808. getClassName(): string;
  72809. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72810. }
  72811. }
  72812. declare module BABYLON {
  72813. /** @hidden */
  72814. export var simplePixelShader: {
  72815. name: string;
  72816. shader: string;
  72817. };
  72818. }
  72819. declare module BABYLON {
  72820. /** @hidden */
  72821. export var simpleVertexShader: {
  72822. name: string;
  72823. shader: string;
  72824. };
  72825. }
  72826. declare module BABYLON {
  72827. export class SimpleMaterial extends BABYLON.PushMaterial {
  72828. private _diffuseTexture;
  72829. diffuseTexture: BABYLON.BaseTexture;
  72830. diffuseColor: BABYLON.Color3;
  72831. private _disableLighting;
  72832. disableLighting: boolean;
  72833. private _maxSimultaneousLights;
  72834. maxSimultaneousLights: number;
  72835. private _renderId;
  72836. constructor(name: string, scene: BABYLON.Scene);
  72837. needAlphaBlending(): boolean;
  72838. needAlphaTesting(): boolean;
  72839. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72840. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72841. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72842. getAnimatables(): BABYLON.IAnimatable[];
  72843. getActiveTextures(): BABYLON.BaseTexture[];
  72844. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72845. dispose(forceDisposeEffect?: boolean): void;
  72846. clone(name: string): SimpleMaterial;
  72847. serialize(): any;
  72848. getClassName(): string;
  72849. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72850. }
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export var skyPixelShader: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module BABYLON {
  72860. /** @hidden */
  72861. export var skyVertexShader: {
  72862. name: string;
  72863. shader: string;
  72864. };
  72865. }
  72866. declare module BABYLON {
  72867. /**
  72868. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72869. * @see https://doc.babylonjs.com/extensions/sky
  72870. */
  72871. export class SkyMaterial extends BABYLON.PushMaterial {
  72872. /**
  72873. * Defines the overall luminance of sky in interval ]0, 1[.
  72874. */
  72875. luminance: number;
  72876. /**
  72877. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72878. */
  72879. turbidity: number;
  72880. /**
  72881. * Defines the sky appearance (light intensity).
  72882. */
  72883. rayleigh: number;
  72884. /**
  72885. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72886. */
  72887. mieCoefficient: number;
  72888. /**
  72889. * Defines the amount of haze particles following the Mie scattering theory.
  72890. */
  72891. mieDirectionalG: number;
  72892. /**
  72893. * Defines the distance of the sun according to the active scene camera.
  72894. */
  72895. distance: number;
  72896. /**
  72897. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72898. * "inclined".
  72899. */
  72900. inclination: number;
  72901. /**
  72902. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72903. * an object direction and a reference direction.
  72904. */
  72905. azimuth: number;
  72906. /**
  72907. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72908. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72909. */
  72910. sunPosition: BABYLON.Vector3;
  72911. /**
  72912. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72913. * .sunPosition property.
  72914. */
  72915. useSunPosition: boolean;
  72916. /**
  72917. * Defines an offset vector used to get a horizon offset.
  72918. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72919. */
  72920. cameraOffset: BABYLON.Vector3;
  72921. private _cameraPosition;
  72922. private _renderId;
  72923. /**
  72924. * Instantiates a new sky material.
  72925. * This material allows to create dynamic and texture free
  72926. * effects for skyboxes by taking care of the atmosphere state.
  72927. * @see https://doc.babylonjs.com/extensions/sky
  72928. * @param name Define the name of the material in the scene
  72929. * @param scene Define the scene the material belong to
  72930. */
  72931. constructor(name: string, scene: BABYLON.Scene);
  72932. /**
  72933. * Specifies if the material will require alpha blending
  72934. * @returns a boolean specifying if alpha blending is needed
  72935. */
  72936. needAlphaBlending(): boolean;
  72937. /**
  72938. * Specifies if this material should be rendered in alpha test mode
  72939. * @returns false as the sky material doesn't need alpha testing.
  72940. */
  72941. needAlphaTesting(): boolean;
  72942. /**
  72943. * Get the texture used for alpha test purpose.
  72944. * @returns null as the sky material has no texture.
  72945. */
  72946. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72947. /**
  72948. * Get if the submesh is ready to be used and all its information available.
  72949. * Child classes can use it to update shaders
  72950. * @param mesh defines the mesh to check
  72951. * @param subMesh defines which submesh to check
  72952. * @param useInstances specifies that instances should be used
  72953. * @returns a boolean indicating that the submesh is ready or not
  72954. */
  72955. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72956. /**
  72957. * Binds the submesh to this material by preparing the effect and shader to draw
  72958. * @param world defines the world transformation matrix
  72959. * @param mesh defines the mesh containing the submesh
  72960. * @param subMesh defines the submesh to bind the material to
  72961. */
  72962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72963. /**
  72964. * Get the list of animatables in the material.
  72965. * @returns the list of animatables object used in the material
  72966. */
  72967. getAnimatables(): BABYLON.IAnimatable[];
  72968. /**
  72969. * Disposes the material
  72970. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72971. */
  72972. dispose(forceDisposeEffect?: boolean): void;
  72973. /**
  72974. * Makes a duplicate of the material, and gives it a new name
  72975. * @param name defines the new name for the duplicated material
  72976. * @returns the cloned material
  72977. */
  72978. clone(name: string): SkyMaterial;
  72979. /**
  72980. * Serializes this material in a JSON representation
  72981. * @returns the serialized material object
  72982. */
  72983. serialize(): any;
  72984. /**
  72985. * Gets the current class name of the material e.g. "SkyMaterial"
  72986. * Mainly use in serialization.
  72987. * @returns the class name
  72988. */
  72989. getClassName(): string;
  72990. /**
  72991. * Creates a sky material from parsed material data
  72992. * @param source defines the JSON representation of the material
  72993. * @param scene defines the hosting scene
  72994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72995. * @returns a new sky material
  72996. */
  72997. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  72998. }
  72999. }
  73000. declare module BABYLON {
  73001. /** @hidden */
  73002. export var terrainPixelShader: {
  73003. name: string;
  73004. shader: string;
  73005. };
  73006. }
  73007. declare module BABYLON {
  73008. /** @hidden */
  73009. export var terrainVertexShader: {
  73010. name: string;
  73011. shader: string;
  73012. };
  73013. }
  73014. declare module BABYLON {
  73015. export class TerrainMaterial extends BABYLON.PushMaterial {
  73016. private _mixTexture;
  73017. mixTexture: BABYLON.BaseTexture;
  73018. private _diffuseTexture1;
  73019. diffuseTexture1: BABYLON.Texture;
  73020. private _diffuseTexture2;
  73021. diffuseTexture2: BABYLON.Texture;
  73022. private _diffuseTexture3;
  73023. diffuseTexture3: BABYLON.Texture;
  73024. private _bumpTexture1;
  73025. bumpTexture1: BABYLON.Texture;
  73026. private _bumpTexture2;
  73027. bumpTexture2: BABYLON.Texture;
  73028. private _bumpTexture3;
  73029. bumpTexture3: BABYLON.Texture;
  73030. diffuseColor: BABYLON.Color3;
  73031. specularColor: BABYLON.Color3;
  73032. specularPower: number;
  73033. private _disableLighting;
  73034. disableLighting: boolean;
  73035. private _maxSimultaneousLights;
  73036. maxSimultaneousLights: number;
  73037. private _renderId;
  73038. constructor(name: string, scene: BABYLON.Scene);
  73039. needAlphaBlending(): boolean;
  73040. needAlphaTesting(): boolean;
  73041. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73042. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73044. getAnimatables(): BABYLON.IAnimatable[];
  73045. getActiveTextures(): BABYLON.BaseTexture[];
  73046. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73047. dispose(forceDisposeEffect?: boolean): void;
  73048. clone(name: string): TerrainMaterial;
  73049. serialize(): any;
  73050. getClassName(): string;
  73051. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73052. }
  73053. }
  73054. declare module BABYLON {
  73055. /** @hidden */
  73056. export var triplanarPixelShader: {
  73057. name: string;
  73058. shader: string;
  73059. };
  73060. }
  73061. declare module BABYLON {
  73062. /** @hidden */
  73063. export var triplanarVertexShader: {
  73064. name: string;
  73065. shader: string;
  73066. };
  73067. }
  73068. declare module BABYLON {
  73069. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73070. mixTexture: BABYLON.BaseTexture;
  73071. private _diffuseTextureX;
  73072. diffuseTextureX: BABYLON.BaseTexture;
  73073. private _diffuseTextureY;
  73074. diffuseTextureY: BABYLON.BaseTexture;
  73075. private _diffuseTextureZ;
  73076. diffuseTextureZ: BABYLON.BaseTexture;
  73077. private _normalTextureX;
  73078. normalTextureX: BABYLON.BaseTexture;
  73079. private _normalTextureY;
  73080. normalTextureY: BABYLON.BaseTexture;
  73081. private _normalTextureZ;
  73082. normalTextureZ: BABYLON.BaseTexture;
  73083. tileSize: number;
  73084. diffuseColor: BABYLON.Color3;
  73085. specularColor: BABYLON.Color3;
  73086. specularPower: number;
  73087. private _disableLighting;
  73088. disableLighting: boolean;
  73089. private _maxSimultaneousLights;
  73090. maxSimultaneousLights: number;
  73091. private _renderId;
  73092. constructor(name: string, scene: BABYLON.Scene);
  73093. needAlphaBlending(): boolean;
  73094. needAlphaTesting(): boolean;
  73095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73096. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73097. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73098. getAnimatables(): BABYLON.IAnimatable[];
  73099. getActiveTextures(): BABYLON.BaseTexture[];
  73100. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73101. dispose(forceDisposeEffect?: boolean): void;
  73102. clone(name: string): TriPlanarMaterial;
  73103. serialize(): any;
  73104. getClassName(): string;
  73105. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73106. }
  73107. }
  73108. declare module BABYLON {
  73109. /** @hidden */
  73110. export var waterPixelShader: {
  73111. name: string;
  73112. shader: string;
  73113. };
  73114. }
  73115. declare module BABYLON {
  73116. /** @hidden */
  73117. export var waterVertexShader: {
  73118. name: string;
  73119. shader: string;
  73120. };
  73121. }
  73122. declare module BABYLON {
  73123. export class WaterMaterial extends BABYLON.PushMaterial {
  73124. renderTargetSize: BABYLON.Vector2;
  73125. private _bumpTexture;
  73126. bumpTexture: BABYLON.BaseTexture;
  73127. diffuseColor: BABYLON.Color3;
  73128. specularColor: BABYLON.Color3;
  73129. specularPower: number;
  73130. private _disableLighting;
  73131. disableLighting: boolean;
  73132. private _maxSimultaneousLights;
  73133. maxSimultaneousLights: number;
  73134. /**
  73135. * @param {number}: Represents the wind force
  73136. */
  73137. windForce: number;
  73138. /**
  73139. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73140. */
  73141. windDirection: BABYLON.Vector2;
  73142. /**
  73143. * @param {number}: Wave height, represents the height of the waves
  73144. */
  73145. waveHeight: number;
  73146. /**
  73147. * @param {number}: Bump height, represents the bump height related to the bump map
  73148. */
  73149. bumpHeight: number;
  73150. /**
  73151. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73152. */
  73153. private _bumpSuperimpose;
  73154. bumpSuperimpose: boolean;
  73155. /**
  73156. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73157. */
  73158. private _fresnelSeparate;
  73159. fresnelSeparate: boolean;
  73160. /**
  73161. * @param {boolean}: bump Waves modify the reflection.
  73162. */
  73163. private _bumpAffectsReflection;
  73164. bumpAffectsReflection: boolean;
  73165. /**
  73166. * @param {number}: The water color blended with the refraction (near)
  73167. */
  73168. waterColor: BABYLON.Color3;
  73169. /**
  73170. * @param {number}: The blend factor related to the water color
  73171. */
  73172. colorBlendFactor: number;
  73173. /**
  73174. * @param {number}: The water color blended with the reflection (far)
  73175. */
  73176. waterColor2: BABYLON.Color3;
  73177. /**
  73178. * @param {number}: The blend factor related to the water color (reflection, far)
  73179. */
  73180. colorBlendFactor2: number;
  73181. /**
  73182. * @param {number}: Represents the maximum length of a wave
  73183. */
  73184. waveLength: number;
  73185. /**
  73186. * @param {number}: Defines the waves speed
  73187. */
  73188. waveSpeed: number;
  73189. /**
  73190. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73191. * will avoid calculating useless pixels in the pixel shader of the water material.
  73192. */
  73193. disableClipPlane: boolean;
  73194. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73195. private _mesh;
  73196. private _refractionRTT;
  73197. private _reflectionRTT;
  73198. private _reflectionTransform;
  73199. private _lastTime;
  73200. private _lastDeltaTime;
  73201. private _renderId;
  73202. private _useLogarithmicDepth;
  73203. private _waitingRenderList;
  73204. private _imageProcessingConfiguration;
  73205. private _imageProcessingObserver;
  73206. /**
  73207. * Gets a boolean indicating that current material needs to register RTT
  73208. */
  73209. readonly hasRenderTargetTextures: boolean;
  73210. /**
  73211. * Constructor
  73212. */
  73213. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73214. useLogarithmicDepth: boolean;
  73215. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73216. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73217. addToRenderList(node: any): void;
  73218. enableRenderTargets(enable: boolean): void;
  73219. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73220. readonly renderTargetsEnabled: boolean;
  73221. needAlphaBlending(): boolean;
  73222. needAlphaTesting(): boolean;
  73223. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73224. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73225. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73226. private _createRenderTargets;
  73227. getAnimatables(): BABYLON.IAnimatable[];
  73228. getActiveTextures(): BABYLON.BaseTexture[];
  73229. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73230. dispose(forceDisposeEffect?: boolean): void;
  73231. clone(name: string): WaterMaterial;
  73232. serialize(): any;
  73233. getClassName(): string;
  73234. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73235. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73236. }
  73237. }
  73238. declare module BABYLON {
  73239. /** @hidden */
  73240. export var asciiartPixelShader: {
  73241. name: string;
  73242. shader: string;
  73243. };
  73244. }
  73245. declare module BABYLON {
  73246. /**
  73247. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73248. *
  73249. * It basically takes care rendering the font front the given font size to a texture.
  73250. * This is used later on in the postprocess.
  73251. */
  73252. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73253. private _font;
  73254. private _text;
  73255. private _charSize;
  73256. /**
  73257. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73258. */
  73259. readonly charSize: number;
  73260. /**
  73261. * Create a new instance of the Ascii Art FontTexture class
  73262. * @param name the name of the texture
  73263. * @param font the font to use, use the W3C CSS notation
  73264. * @param text the caracter set to use in the rendering.
  73265. * @param scene the scene that owns the texture
  73266. */
  73267. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73268. /**
  73269. * Gets the max char width of a font.
  73270. * @param font the font to use, use the W3C CSS notation
  73271. * @return the max char width
  73272. */
  73273. private getFontWidth;
  73274. /**
  73275. * Gets the max char height of a font.
  73276. * @param font the font to use, use the W3C CSS notation
  73277. * @return the max char height
  73278. */
  73279. private getFontHeight;
  73280. /**
  73281. * Clones the current AsciiArtTexture.
  73282. * @return the clone of the texture.
  73283. */
  73284. clone(): AsciiArtFontTexture;
  73285. /**
  73286. * Parses a json object representing the texture and returns an instance of it.
  73287. * @param source the source JSON representation
  73288. * @param scene the scene to create the texture for
  73289. * @return the parsed texture
  73290. */
  73291. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73292. }
  73293. /**
  73294. * Option available in the Ascii Art Post Process.
  73295. */
  73296. export interface IAsciiArtPostProcessOptions {
  73297. /**
  73298. * The font to use following the w3c font definition.
  73299. */
  73300. font?: string;
  73301. /**
  73302. * The character set to use in the postprocess.
  73303. */
  73304. characterSet?: string;
  73305. /**
  73306. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73307. * This number is defined between 0 and 1;
  73308. */
  73309. mixToTile?: number;
  73310. /**
  73311. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73312. * This number is defined between 0 and 1;
  73313. */
  73314. mixToNormal?: number;
  73315. }
  73316. /**
  73317. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73318. *
  73319. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73320. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73321. */
  73322. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73323. /**
  73324. * The font texture used to render the char in the post process.
  73325. */
  73326. private _asciiArtFontTexture;
  73327. /**
  73328. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73329. * This number is defined between 0 and 1;
  73330. */
  73331. mixToTile: number;
  73332. /**
  73333. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73334. * This number is defined between 0 and 1;
  73335. */
  73336. mixToNormal: number;
  73337. /**
  73338. * Instantiates a new Ascii Art Post Process.
  73339. * @param name the name to give to the postprocess
  73340. * @camera the camera to apply the post process to.
  73341. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73342. */
  73343. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73344. }
  73345. }
  73346. declare module BABYLON {
  73347. /** @hidden */
  73348. export var digitalrainPixelShader: {
  73349. name: string;
  73350. shader: string;
  73351. };
  73352. }
  73353. declare module BABYLON {
  73354. /**
  73355. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73356. *
  73357. * It basically takes care rendering the font front the given font size to a texture.
  73358. * This is used later on in the postprocess.
  73359. */
  73360. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73361. private _font;
  73362. private _text;
  73363. private _charSize;
  73364. /**
  73365. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73366. */
  73367. readonly charSize: number;
  73368. /**
  73369. * Create a new instance of the Digital Rain FontTexture class
  73370. * @param name the name of the texture
  73371. * @param font the font to use, use the W3C CSS notation
  73372. * @param text the caracter set to use in the rendering.
  73373. * @param scene the scene that owns the texture
  73374. */
  73375. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73376. /**
  73377. * Gets the max char width of a font.
  73378. * @param font the font to use, use the W3C CSS notation
  73379. * @return the max char width
  73380. */
  73381. private getFontWidth;
  73382. /**
  73383. * Gets the max char height of a font.
  73384. * @param font the font to use, use the W3C CSS notation
  73385. * @return the max char height
  73386. */
  73387. private getFontHeight;
  73388. /**
  73389. * Clones the current DigitalRainFontTexture.
  73390. * @return the clone of the texture.
  73391. */
  73392. clone(): DigitalRainFontTexture;
  73393. /**
  73394. * Parses a json object representing the texture and returns an instance of it.
  73395. * @param source the source JSON representation
  73396. * @param scene the scene to create the texture for
  73397. * @return the parsed texture
  73398. */
  73399. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73400. }
  73401. /**
  73402. * Option available in the Digital Rain Post Process.
  73403. */
  73404. export interface IDigitalRainPostProcessOptions {
  73405. /**
  73406. * The font to use following the w3c font definition.
  73407. */
  73408. font?: string;
  73409. /**
  73410. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73411. * This number is defined between 0 and 1;
  73412. */
  73413. mixToTile?: number;
  73414. /**
  73415. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73416. * This number is defined between 0 and 1;
  73417. */
  73418. mixToNormal?: number;
  73419. }
  73420. /**
  73421. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73422. *
  73423. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73424. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73425. */
  73426. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73427. /**
  73428. * The font texture used to render the char in the post process.
  73429. */
  73430. private _digitalRainFontTexture;
  73431. /**
  73432. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73433. * This number is defined between 0 and 1;
  73434. */
  73435. mixToTile: number;
  73436. /**
  73437. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73438. * This number is defined between 0 and 1;
  73439. */
  73440. mixToNormal: number;
  73441. /**
  73442. * Instantiates a new Digital Rain Post Process.
  73443. * @param name the name to give to the postprocess
  73444. * @camera the camera to apply the post process to.
  73445. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73446. */
  73447. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73448. }
  73449. }
  73450. declare module BABYLON {
  73451. /** @hidden */
  73452. export var oceanPostProcessPixelShader: {
  73453. name: string;
  73454. shader: string;
  73455. };
  73456. }
  73457. declare module BABYLON {
  73458. /**
  73459. * Option available in the Ocean Post Process.
  73460. */
  73461. export interface IOceanPostProcessOptions {
  73462. /**
  73463. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73464. */
  73465. reflectionSize?: number | {
  73466. width: number;
  73467. height: number;
  73468. } | {
  73469. ratio: number;
  73470. };
  73471. /**
  73472. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73473. */
  73474. refractionSize?: number | {
  73475. width: number;
  73476. height: number;
  73477. } | {
  73478. ratio: number;
  73479. };
  73480. }
  73481. /**
  73482. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73483. *
  73484. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73485. * Example usage:
  73486. * var pp = new OceanPostProcess("myOcean", camera);
  73487. * pp.reflectionEnabled = true;
  73488. * pp.refractionEnabled = true;
  73489. */
  73490. export class OceanPostProcess extends BABYLON.PostProcess {
  73491. /**
  73492. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73493. */
  73494. /**
  73495. * Sets weither or not the real-time reflection is enabled on the ocean.
  73496. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73497. */
  73498. reflectionEnabled: boolean;
  73499. /**
  73500. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73501. */
  73502. /**
  73503. * Sets weither or not the real-time refraction is enabled on the ocean.
  73504. * Is set to true, the refraction render target texture will be used as refraction texture.
  73505. */
  73506. refractionEnabled: boolean;
  73507. /**
  73508. * Gets wether or not the post-processes is supported by the running hardware.
  73509. * This requires draw buffer supports.
  73510. */
  73511. readonly isSupported: boolean;
  73512. /**
  73513. * This is the reflection mirror texture used to display reflections on the ocean.
  73514. * By default, render list is empty.
  73515. */
  73516. reflectionTexture: BABYLON.MirrorTexture;
  73517. /**
  73518. * This is the refraction render target texture used to display refraction on the ocean.
  73519. * By default, render list is empty.
  73520. */
  73521. refractionTexture: BABYLON.RenderTargetTexture;
  73522. private _time;
  73523. private _cameraRotation;
  73524. private _cameraViewMatrix;
  73525. private _reflectionEnabled;
  73526. private _refractionEnabled;
  73527. private _geometryRenderer;
  73528. /**
  73529. * Instantiates a new Ocean Post Process.
  73530. * @param name the name to give to the postprocess.
  73531. * @camera the camera to apply the post process to.
  73532. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73533. */
  73534. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73535. /**
  73536. * Returns the appropriate defines according to the current configuration.
  73537. */
  73538. private _getDefines;
  73539. /**
  73540. * Computes the current camera rotation as the shader requires a camera rotation.
  73541. */
  73542. private _computeCameraRotation;
  73543. }
  73544. }
  73545. declare module BABYLON {
  73546. /** @hidden */
  73547. export var brickProceduralTexturePixelShader: {
  73548. name: string;
  73549. shader: string;
  73550. };
  73551. }
  73552. declare module BABYLON {
  73553. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73554. private _numberOfBricksHeight;
  73555. private _numberOfBricksWidth;
  73556. private _jointColor;
  73557. private _brickColor;
  73558. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73559. updateShaderUniforms(): void;
  73560. numberOfBricksHeight: number;
  73561. numberOfBricksWidth: number;
  73562. jointColor: BABYLON.Color3;
  73563. brickColor: BABYLON.Color3;
  73564. /**
  73565. * Serializes this brick procedural texture
  73566. * @returns a serialized brick procedural texture object
  73567. */
  73568. serialize(): any;
  73569. /**
  73570. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73571. * @param parsedTexture defines parsed texture data
  73572. * @param scene defines the current scene
  73573. * @param rootUrl defines the root URL containing brick procedural texture information
  73574. * @returns a parsed Brick Procedural BABYLON.Texture
  73575. */
  73576. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73577. }
  73578. }
  73579. declare module BABYLON {
  73580. /** @hidden */
  73581. export var cloudProceduralTexturePixelShader: {
  73582. name: string;
  73583. shader: string;
  73584. };
  73585. }
  73586. declare module BABYLON {
  73587. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73588. private _skyColor;
  73589. private _cloudColor;
  73590. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73591. updateShaderUniforms(): void;
  73592. skyColor: BABYLON.Color4;
  73593. cloudColor: BABYLON.Color4;
  73594. /**
  73595. * Serializes this cloud procedural texture
  73596. * @returns a serialized cloud procedural texture object
  73597. */
  73598. serialize(): any;
  73599. /**
  73600. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73601. * @param parsedTexture defines parsed texture data
  73602. * @param scene defines the current scene
  73603. * @param rootUrl defines the root URL containing cloud procedural texture information
  73604. * @returns a parsed Cloud Procedural BABYLON.Texture
  73605. */
  73606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73607. }
  73608. }
  73609. declare module BABYLON {
  73610. /** @hidden */
  73611. export var fireProceduralTexturePixelShader: {
  73612. name: string;
  73613. shader: string;
  73614. };
  73615. }
  73616. declare module BABYLON {
  73617. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73618. private _time;
  73619. private _speed;
  73620. private _autoGenerateTime;
  73621. private _fireColors;
  73622. private _alphaThreshold;
  73623. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73624. updateShaderUniforms(): void;
  73625. render(useCameraPostProcess?: boolean): void;
  73626. static readonly PurpleFireColors: BABYLON.Color3[];
  73627. static readonly GreenFireColors: BABYLON.Color3[];
  73628. static readonly RedFireColors: BABYLON.Color3[];
  73629. static readonly BlueFireColors: BABYLON.Color3[];
  73630. autoGenerateTime: boolean;
  73631. fireColors: BABYLON.Color3[];
  73632. time: number;
  73633. speed: BABYLON.Vector2;
  73634. alphaThreshold: number;
  73635. /**
  73636. * Serializes this fire procedural texture
  73637. * @returns a serialized fire procedural texture object
  73638. */
  73639. serialize(): any;
  73640. /**
  73641. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73642. * @param parsedTexture defines parsed texture data
  73643. * @param scene defines the current scene
  73644. * @param rootUrl defines the root URL containing fire procedural texture information
  73645. * @returns a parsed Fire Procedural BABYLON.Texture
  73646. */
  73647. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73648. }
  73649. }
  73650. declare module BABYLON {
  73651. /** @hidden */
  73652. export var grassProceduralTexturePixelShader: {
  73653. name: string;
  73654. shader: string;
  73655. };
  73656. }
  73657. declare module BABYLON {
  73658. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73659. private _grassColors;
  73660. private _groundColor;
  73661. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73662. updateShaderUniforms(): void;
  73663. grassColors: BABYLON.Color3[];
  73664. groundColor: BABYLON.Color3;
  73665. /**
  73666. * Serializes this grass procedural texture
  73667. * @returns a serialized grass procedural texture object
  73668. */
  73669. serialize(): any;
  73670. /**
  73671. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73672. * @param parsedTexture defines parsed texture data
  73673. * @param scene defines the current scene
  73674. * @param rootUrl defines the root URL containing grass procedural texture information
  73675. * @returns a parsed Grass Procedural BABYLON.Texture
  73676. */
  73677. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73678. }
  73679. }
  73680. declare module BABYLON {
  73681. /** @hidden */
  73682. export var marbleProceduralTexturePixelShader: {
  73683. name: string;
  73684. shader: string;
  73685. };
  73686. }
  73687. declare module BABYLON {
  73688. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73689. private _numberOfTilesHeight;
  73690. private _numberOfTilesWidth;
  73691. private _amplitude;
  73692. private _jointColor;
  73693. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73694. updateShaderUniforms(): void;
  73695. numberOfTilesHeight: number;
  73696. amplitude: number;
  73697. numberOfTilesWidth: number;
  73698. jointColor: BABYLON.Color3;
  73699. /**
  73700. * Serializes this marble procedural texture
  73701. * @returns a serialized marble procedural texture object
  73702. */
  73703. serialize(): any;
  73704. /**
  73705. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73706. * @param parsedTexture defines parsed texture data
  73707. * @param scene defines the current scene
  73708. * @param rootUrl defines the root URL containing marble procedural texture information
  73709. * @returns a parsed Marble Procedural BABYLON.Texture
  73710. */
  73711. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73712. }
  73713. }
  73714. declare module BABYLON {
  73715. /** @hidden */
  73716. export var normalMapProceduralTexturePixelShader: {
  73717. name: string;
  73718. shader: string;
  73719. };
  73720. }
  73721. declare module BABYLON {
  73722. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73723. private _baseTexture;
  73724. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73725. updateShaderUniforms(): void;
  73726. render(useCameraPostProcess?: boolean): void;
  73727. resize(size: any, generateMipMaps: any): void;
  73728. baseTexture: BABYLON.Texture;
  73729. /**
  73730. * Serializes this normal map procedural texture
  73731. * @returns a serialized normal map procedural texture object
  73732. */
  73733. serialize(): any;
  73734. /**
  73735. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73736. * @param parsedTexture defines parsed texture data
  73737. * @param scene defines the current scene
  73738. * @param rootUrl defines the root URL containing normal map procedural texture information
  73739. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73740. */
  73741. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73742. }
  73743. }
  73744. declare module BABYLON {
  73745. /** @hidden */
  73746. export var perlinNoiseProceduralTexturePixelShader: {
  73747. name: string;
  73748. shader: string;
  73749. };
  73750. }
  73751. declare module BABYLON {
  73752. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73753. time: number;
  73754. timeScale: number;
  73755. translationSpeed: number;
  73756. private _currentTranslation;
  73757. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73758. updateShaderUniforms(): void;
  73759. render(useCameraPostProcess?: boolean): void;
  73760. resize(size: any, generateMipMaps: any): void;
  73761. /**
  73762. * Serializes this perlin noise procedural texture
  73763. * @returns a serialized perlin noise procedural texture object
  73764. */
  73765. serialize(): any;
  73766. /**
  73767. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73768. * @param parsedTexture defines parsed texture data
  73769. * @param scene defines the current scene
  73770. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73771. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73772. */
  73773. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73774. }
  73775. }
  73776. declare module BABYLON {
  73777. /** @hidden */
  73778. export var roadProceduralTexturePixelShader: {
  73779. name: string;
  73780. shader: string;
  73781. };
  73782. }
  73783. declare module BABYLON {
  73784. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73785. private _roadColor;
  73786. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73787. updateShaderUniforms(): void;
  73788. roadColor: BABYLON.Color3;
  73789. /**
  73790. * Serializes this road procedural texture
  73791. * @returns a serialized road procedural texture object
  73792. */
  73793. serialize(): any;
  73794. /**
  73795. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73796. * @param parsedTexture defines parsed texture data
  73797. * @param scene defines the current scene
  73798. * @param rootUrl defines the root URL containing road procedural texture information
  73799. * @returns a parsed Road Procedural BABYLON.Texture
  73800. */
  73801. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73802. }
  73803. }
  73804. declare module BABYLON {
  73805. /** @hidden */
  73806. export var starfieldProceduralTexturePixelShader: {
  73807. name: string;
  73808. shader: string;
  73809. };
  73810. }
  73811. declare module BABYLON {
  73812. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73813. private _time;
  73814. private _alpha;
  73815. private _beta;
  73816. private _zoom;
  73817. private _formuparam;
  73818. private _stepsize;
  73819. private _tile;
  73820. private _brightness;
  73821. private _darkmatter;
  73822. private _distfading;
  73823. private _saturation;
  73824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73825. updateShaderUniforms(): void;
  73826. time: number;
  73827. alpha: number;
  73828. beta: number;
  73829. formuparam: number;
  73830. stepsize: number;
  73831. zoom: number;
  73832. tile: number;
  73833. brightness: number;
  73834. darkmatter: number;
  73835. distfading: number;
  73836. saturation: number;
  73837. /**
  73838. * Serializes this starfield procedural texture
  73839. * @returns a serialized starfield procedural texture object
  73840. */
  73841. serialize(): any;
  73842. /**
  73843. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73844. * @param parsedTexture defines parsed texture data
  73845. * @param scene defines the current scene
  73846. * @param rootUrl defines the root URL containing startfield procedural texture information
  73847. * @returns a parsed Starfield Procedural BABYLON.Texture
  73848. */
  73849. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73850. }
  73851. }
  73852. declare module BABYLON {
  73853. /** @hidden */
  73854. export var woodProceduralTexturePixelShader: {
  73855. name: string;
  73856. shader: string;
  73857. };
  73858. }
  73859. declare module BABYLON {
  73860. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73861. private _ampScale;
  73862. private _woodColor;
  73863. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73864. updateShaderUniforms(): void;
  73865. ampScale: number;
  73866. woodColor: BABYLON.Color3;
  73867. /**
  73868. * Serializes this wood procedural texture
  73869. * @returns a serialized wood procedural texture object
  73870. */
  73871. serialize(): any;
  73872. /**
  73873. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73874. * @param parsedTexture defines parsed texture data
  73875. * @param scene defines the current scene
  73876. * @param rootUrl defines the root URL containing wood procedural texture information
  73877. * @returns a parsed Wood Procedural BABYLON.Texture
  73878. */
  73879. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73880. }
  73881. }